Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8de20a3

Browse files
author
Thomas G. Lockhart
committed
Use environment variable PGDATESTYLE on backend startup to initialize
date/time formats and conventions.
1 parent a58825a commit 8de20a3

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/backend/tcop/postgres.c

+33-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.56 1997/12/11 17:36:42 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.57 1997/12/16 15:57:00 thomas Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -854,6 +854,7 @@ PostgresMain(int argc, char *argv[])
854854
Dlelem *curr;
855855
int status;
856856

857+
char *DBDate = NULL;
857858
extern int optind;
858859
extern char *optarg;
859860
extern short DebugLvl;
@@ -882,6 +883,10 @@ PostgresMain(int argc, char *argv[])
882883
* parse command line arguments
883884
* ----------------
884885
*/
886+
887+
/*
888+
* Set default values.
889+
*/
885890
flagC = flagQ = flagE = flagEu = ShowStats = 0;
886891
ShowParserStats = ShowPlannerStats = ShowExecutorStats = 0;
887892
#ifdef LOCK_MGR_DEBUG
@@ -893,9 +898,33 @@ PostgresMain(int argc, char *argv[])
893898
* NULL means Unix-socket only
894899
*/
895900
hostName = getenv("PGHOST");
901+
DataDir = getenv("PGDATA");
902+
/*
903+
* Try to get initial values for date styles and formats.
904+
* Does not do a complete job, but should be good enough for backend.
905+
* Cannot call parse_date() since palloc/pfree memory is not set up yet.
906+
*/
907+
DBDate = getenv("PGDATESTYLE");
908+
if (DBDate != NULL)
909+
{
910+
if (strcasecmp(DBDate, "ISO") == 0)
911+
DateStyle = USE_ISO_DATES;
912+
else if (strcasecmp(DBDate, "SQL") == 0)
913+
DateStyle = USE_SQL_DATES;
914+
else if (strcasecmp(DBDate, "POSTGRES") == 0)
915+
DateStyle = USE_POSTGRES_DATES;
916+
else if (strcasecmp(DBDate, "GERMAN") == 0)
917+
{
918+
DateStyle = USE_GERMAN_DATES;
919+
EuroDates = TRUE;
920+
}
896921

897-
DataDir = getenv("PGDATA"); /* default */
898-
multiplexedBackend = false; /* default */
922+
if (strcasecmp(DBDate, "NONEURO") == 0)
923+
EuroDates = FALSE;
924+
else if (strcasecmp(DBDate, "EURO") == 0)
925+
EuroDates = TRUE;
926+
}
927+
multiplexedBackend = false;
899928

900929
while ((flag = getopt(argc, argv, "B:bCD:d:Eef:iK:Lm:MNo:P:pQS:st:x:F"))
901930
!= EOF)
@@ -1343,7 +1372,7 @@ PostgresMain(int argc, char *argv[])
13431372
if (IsUnderPostmaster == false)
13441373
{
13451374
puts("\nPOSTGRES backend interactive interface");
1346-
puts("$Revision: 1.56 $ $Date: 1997/12/11 17:36:42 $");
1375+
puts("$Revision: 1.57 $ $Date: 1997/12/16 15:57:00 $");
13471376
}
13481377

13491378
/* ----------------

0 commit comments

Comments
 (0)