Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
625d4b38
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
625d4b38
编写于
12月 09, 2005
作者:
P
Peter Eisentraut
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Let initdb detect the date order of the lc_time locale and initialize the
datestyle parameter of the new cluster accordingly.
上级
cd8f3ec5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
79 addition
and
5 deletion
+79
-5
doc/TODO
doc/TODO
+1
-1
doc/src/sgml/config.sgml
doc/src/sgml/config.sgml
+6
-3
src/bin/initdb/initdb.c
src/bin/initdb/initdb.c
+72
-1
未找到文件。
doc/TODO
浏览文件 @
625d4b38
...
...
@@ -566,7 +566,7 @@ SQL Commands
Clients
=======
*
Have initdb set the input DateStyle (MDY or DMY) based on locale?
*
-Have initdb set the input DateStyle (MDY or DMY) based on locale
* Have pg_ctl look at PGHOST in case it is a socket directory?
* Allow pg_ctl to work properly with configuration files located outside
the PGDATA directory
...
...
doc/src/sgml/config.sgml
浏览文件 @
625d4b38
<!--
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.3
7 2005/11/17 22:14:50 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.3
8 2005/12/09 15:51:13 petere
Exp $
-->
<chapter Id="runtime-config">
<title>Server Configuration</title>
...
...
@@ -32,7 +32,7 @@ $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.37 2005/11/17 22:14:50 tgl Exp $
<para>
One way to set these parameters is to edit the file
<filename>postgresql.conf</><indexterm><primary>postgresql.conf</></>,
which is normally kept in the data directory. (<
command
>initdb</>
which is normally kept in the data directory. (<
application
>initdb</>
installs a default copy there.) An example of what this file might look
like is:
<programlisting>
...
...
@@ -3300,7 +3300,10 @@ SELECT * FROM parent WHERE key = 2400;
keywords <literal>US</>, <literal>NonEuro</>, and
<literal>NonEuropean</> are synonyms for <literal>MDY</>. See
<xref linkend="datatype-datetime"> for more information. The
default is <literal>ISO, MDY</>.
built-in default is <literal>ISO, MDY</>, but
<application>initdb</application> will initialize the
configuration file with a setting that corresponds to the
behavior of the chosen <varname>lc_time</varname> locale.
</para>
</listitem>
</varlistentry>
...
...
src/bin/initdb/initdb.c
浏览文件 @
625d4b38
...
...
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.10
0 2005/11/22 18:17:28 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.10
1 2005/12/09 15:51:14 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -57,11 +57,13 @@
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#include <time.h>
#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "getaddrinfo.h"
#include "getopt_long.h"
#include "miscadmin.h"
#ifndef HAVE_INT_OPTRESET
int
optreset
;
...
...
@@ -186,6 +188,7 @@ static void make_postgres(void);
static
void
trapsig
(
int
signum
);
static
void
check_ok
(
void
);
static
char
*
escape_quotes
(
const
char
*
src
);
static
int
locale_date_order
(
const
char
*
locale
);
static
bool
chklocale
(
const
char
*
locale
);
static
void
setlocales
(
void
);
static
void
usage
(
const
char
*
progname
);
...
...
@@ -1195,6 +1198,20 @@ setup_config(void)
snprintf
(
repltok
,
sizeof
(
repltok
),
"lc_time = '%s'"
,
lc_time
);
conflines
=
replace_token
(
conflines
,
"#lc_time = 'C'"
,
repltok
);
switch
(
locale_date_order
(
lc_time
))
{
case
DATEORDER_YMD
:
strcpy
(
repltok
,
"datestyle = 'iso, ymd'"
);
break
;
case
DATEORDER_DMY
:
strcpy
(
repltok
,
"datestyle = 'iso, dmy'"
);
break
;
case
DATEORDER_MDY
:
default:
strcpy
(
repltok
,
"datestyle = 'iso, mdy'"
);
break
;
}
conflines
=
replace_token
(
conflines
,
"#datestyle = 'iso, mdy'"
,
repltok
);
snprintf
(
path
,
sizeof
(
path
),
"%s/postgresql.conf"
,
pg_data
);
writefile
(
path
,
conflines
);
...
...
@@ -2052,6 +2069,60 @@ escape_quotes(const char *src)
return
result
;
}
/*
* Determine likely date order from locale
*/
static
int
locale_date_order
(
const
char
*
locale
)
{
struct
tm
testtime
;
char
buf
[
128
];
char
*
posD
;
char
*
posM
;
char
*
posY
;
char
*
save
;
size_t
res
;
int
result
;
result
=
DATEORDER_MDY
;
/* default */
save
=
setlocale
(
LC_TIME
,
NULL
);
if
(
!
save
)
return
result
;
save
=
xstrdup
(
save
);
setlocale
(
LC_TIME
,
locale
);
memset
(
&
testtime
,
0
,
sizeof
(
testtime
));
testtime
.
tm_mday
=
22
;
testtime
.
tm_mon
=
10
;
/* November, should come out as "11" */
testtime
.
tm_year
=
133
;
/* 2033 */
res
=
strftime
(
buf
,
sizeof
(
buf
),
"%x"
,
&
testtime
);
setlocale
(
LC_TIME
,
save
);
free
(
save
);
if
(
res
==
0
)
return
result
;
posM
=
strstr
(
buf
,
"11"
);
posD
=
strstr
(
buf
,
"22"
);
posY
=
strstr
(
buf
,
"33"
);
if
(
!
posM
||
!
posD
||
!
posY
)
return
result
;
if
(
posY
<
posM
&&
posM
<
posD
)
result
=
DATEORDER_YMD
;
else
if
(
posD
<
posM
)
result
=
DATEORDER_DMY
;
else
result
=
DATEORDER_MDY
;
return
result
;
}
/*
* check if given string is a valid locale specifier
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录