Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
07a56067
Commit
07a56067
authored
May 19, 2008
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make to_char()'s localized month/day names depend on LC_TIME, not LC_MESSAGES.
Euler Taveira de Oliveira
parent
63e98b55
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
242 additions
and
265 deletions
+242
-265
doc/src/sgml/config.sgml
doc/src/sgml/config.sgml
+4
-4
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+3
-2
src/backend/utils/adt/formatting.c
src/backend/utils/adt/formatting.c
+128
-253
src/backend/utils/adt/oracle_compat.c
src/backend/utils/adt/oracle_compat.c
+5
-3
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/pg_locale.c
+91
-2
src/include/utils/pg_locale.h
src/include/utils/pg_locale.h
+11
-1
No files found.
doc/src/sgml/config.sgml
View file @
07a56067
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.17
8 2008/05/15 00:17:39
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.17
9 2008/05/19 18:08:15
tgl Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
...
...
@@ -4184,9 +4184,9 @@ SET XML OPTION { DOCUMENT | CONTENT };
</indexterm>
<listitem>
<para>
Sets the locale to use for formatting date
and time values.
(Currently, this setting does nothing, but it might in the
fu
ture.)
Acceptable values are system-dependent; see <xref
Sets the locale to use for formatting date
s and times, for example
with the <function>to_char</function> family of
fu
nctions.
Acceptable values are system-dependent; see <xref
linkend="locale"> for more information. If this variable is
set to the empty string (which is the default) then the value
is inherited from the execution environment of the server in a
...
...
doc/src/sgml/func.sgml
View file @
07a56067
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.43
6 2008/05/04 23:19:23
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.43
7 2008/05/19 18:08:15
tgl Exp $ -->
<chapter
id=
"functions"
>
<title>
Functions and Operators
</title>
...
...
@@ -5079,7 +5079,8 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
</row>
<row>
<entry><literal>
TM
</literal>
prefix
</entry>
<entry>
translation mode (print localized day and month names based on
<varname>
lc_messages
</>
)
</entry>
<entry>
translation mode (print localized day and month names based on
<xref
linkend=
"guc-lc-time"
>
)
</entry>
<entry><literal>
TMMonth
</literal></entry>
</row>
<row>
...
...
src/backend/utils/adt/formatting.c
View file @
07a56067
This diff is collapsed.
Click to expand it.
src/backend/utils/adt/oracle_compat.c
View file @
07a56067
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.7
8 2008/03/25 22:42:44
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.7
9 2008/05/19 18:08:16
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -48,6 +48,8 @@
#define USE_WIDE_UPPER_LOWER
char
*
wstring_lower
(
char
*
str
);
char
*
wstring_upper
(
char
*
str
);
wchar_t
*
texttowcs
(
const
text
*
txt
);
text
*
wcstotext
(
const
wchar_t
*
str
,
int
ncodes
);
#endif
static
text
*
dotrim
(
const
char
*
string
,
int
stringlen
,
...
...
@@ -60,7 +62,7 @@ static text *dotrim(const char *string, int stringlen,
/*
* Convert a TEXT value into a palloc'd wchar string.
*/
static
wchar_t
*
wchar_t
*
texttowcs
(
const
text
*
txt
)
{
int
nbytes
=
VARSIZE_ANY_EXHDR
(
txt
);
...
...
@@ -112,7 +114,7 @@ texttowcs(const text *txt)
* must be zero-terminated, but we also require the caller to pass the string
* length, since it will know it anyway in current uses.
*/
static
text
*
text
*
wcstotext
(
const
wchar_t
*
str
,
int
ncodes
)
{
text
*
result
;
...
...
src/backend/utils/adt/pg_locale.c
View file @
07a56067
...
...
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 2002-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.4
0 2008/01/01 19:45:52 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.4
1 2008/05/19 18:08:16 tgl
Exp $
*
*-----------------------------------------------------------------------
*/
...
...
@@ -48,20 +48,31 @@
#include "postgres.h"
#include <locale.h>
#include <time.h>
#include "catalog/pg_control.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
/* GUC storage area */
#define MAX_L10N_DATA 80
/* GUC settings */
char
*
locale_messages
;
char
*
locale_monetary
;
char
*
locale_numeric
;
char
*
locale_time
;
/* lc_time localization cache */
char
*
localized_abbrev_days
[
7
];
char
*
localized_full_days
[
7
];
char
*
localized_abbrev_months
[
12
];
char
*
localized_full_months
[
12
];
/* indicates whether locale information cache is valid */
static
bool
CurrentLocaleConvValid
=
false
;
static
bool
CurrentLCTimeValid
=
false
;
/* Environment variable storage area */
...
...
@@ -209,7 +220,10 @@ locale_xxx_assign(int category, const char *value, bool doit, GucSource source)
/* need to reload cache next time? */
if
(
doit
&&
value
!=
NULL
)
{
CurrentLocaleConvValid
=
false
;
CurrentLCTimeValid
=
false
;
}
return
value
;
}
...
...
@@ -424,3 +438,78 @@ PGLC_localeconv(void)
CurrentLocaleConvValid
=
true
;
return
&
CurrentLocaleConv
;
}
/*
* Update the lc_time localization cache variables if needed.
*/
void
cache_locale_time
(
void
)
{
char
*
save_lc_time
;
time_t
timenow
;
struct
tm
*
timeinfo
;
char
buf
[
MAX_L10N_DATA
];
char
*
ptr
;
int
i
;
/* did we do this already? */
if
(
CurrentLCTimeValid
)
return
;
elog
(
DEBUG3
,
"cache_locale_time() executed; locale:
\"
%s
\"
"
,
locale_time
);
/* set user's value of time locale */
save_lc_time
=
setlocale
(
LC_TIME
,
NULL
);
if
(
save_lc_time
)
save_lc_time
=
pstrdup
(
save_lc_time
);
setlocale
(
LC_TIME
,
locale_time
);
timenow
=
time
(
NULL
);
timeinfo
=
localtime
(
&
timenow
);
/* localized days */
for
(
i
=
0
;
i
<
7
;
i
++
)
{
timeinfo
->
tm_wday
=
i
;
strftime
(
buf
,
MAX_L10N_DATA
,
"%a"
,
timeinfo
);
ptr
=
MemoryContextStrdup
(
TopMemoryContext
,
buf
);
if
(
localized_abbrev_days
[
i
])
pfree
(
localized_abbrev_days
[
i
]);
localized_abbrev_days
[
i
]
=
ptr
;
strftime
(
buf
,
MAX_L10N_DATA
,
"%A"
,
timeinfo
);
ptr
=
MemoryContextStrdup
(
TopMemoryContext
,
buf
);
if
(
localized_full_days
[
i
])
pfree
(
localized_full_days
[
i
]);
localized_full_days
[
i
]
=
ptr
;
}
/* localized months */
for
(
i
=
0
;
i
<
12
;
i
++
)
{
timeinfo
->
tm_mon
=
i
;
timeinfo
->
tm_mday
=
1
;
/* make sure we don't have invalid date */
strftime
(
buf
,
MAX_L10N_DATA
,
"%b"
,
timeinfo
);
ptr
=
MemoryContextStrdup
(
TopMemoryContext
,
buf
);
if
(
localized_abbrev_months
[
i
])
pfree
(
localized_abbrev_months
[
i
]);
localized_abbrev_months
[
i
]
=
ptr
;
strftime
(
buf
,
MAX_L10N_DATA
,
"%B"
,
timeinfo
);
ptr
=
MemoryContextStrdup
(
TopMemoryContext
,
buf
);
if
(
localized_full_months
[
i
])
pfree
(
localized_full_months
[
i
]);
localized_full_months
[
i
]
=
ptr
;
}
/* try to restore internal settings */
if
(
save_lc_time
)
{
setlocale
(
LC_TIME
,
save_lc_time
);
pfree
(
save_lc_time
);
}
CurrentLCTimeValid
=
true
;
}
src/include/utils/pg_locale.h
View file @
07a56067
...
...
@@ -2,7 +2,7 @@
*
* PostgreSQL locale utilities
*
* $PostgreSQL: pgsql/src/include/utils/pg_locale.h,v 1.2
4 2008/01/01 19:45:59 momjian
Exp $
* $PostgreSQL: pgsql/src/include/utils/pg_locale.h,v 1.2
5 2008/05/19 18:08:16 tgl
Exp $
*
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
*
...
...
@@ -17,11 +17,19 @@
#include "utils/guc.h"
/* GUC settings */
extern
char
*
locale_messages
;
extern
char
*
locale_monetary
;
extern
char
*
locale_numeric
;
extern
char
*
locale_time
;
/* lc_time localization cache */
extern
char
*
localized_abbrev_days
[];
extern
char
*
localized_full_days
[];
extern
char
*
localized_abbrev_months
[];
extern
char
*
localized_full_months
[];
extern
const
char
*
locale_messages_assign
(
const
char
*
value
,
bool
doit
,
GucSource
source
);
extern
const
char
*
locale_monetary_assign
(
const
char
*
value
,
...
...
@@ -42,4 +50,6 @@ extern bool lc_ctype_is_c(void);
*/
extern
struct
lconv
*
PGLC_localeconv
(
void
);
extern
void
cache_locale_time
(
void
);
#endif
/* _PG_LOCALE_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment