From f46571165d0d0e82b36e1f4ca2a10efb7255e3e6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 19 Feb 2000 22:10:47 +0000 Subject: Get rid of postgres.c's separate parsing logic for PGDATESTYLE env. variable, instead calling same code in variable.c that is used to parse SET DATESTYLE. Fix bug: although backend's startup datestyle had been changed to ISO, 'RESET DATESTYLE' and 'SET DATESTYLE TO DEFAULT' didn't know about it. For consistency I have made the latter two reset to the PGDATESTYLE-defined initial value, which may not be the same as the compiled-in default of ISO. --- src/backend/tcop/postgres.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 77422deb386..2415ef3c96d 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.142 2000/02/18 09:29:27 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.143 2000/02/19 22:10:47 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -40,6 +40,7 @@ #include "commands/async.h" #include "commands/trigger.h" +#include "commands/variable.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" #include "libpq/pqsignal.h" @@ -891,7 +892,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) char *remote_host = ""; unsigned short remote_port = 0; - char *DBDate = NULL; extern int optind; extern char *optarg; extern int DebugLvl; @@ -912,30 +912,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) SetProcessingMode(InitProcessing); - /* - * Try to get initial values for date styles and formats. Does not do - * a complete job, but should be good enough for backend. Cannot call - * parse_date() since palloc/pfree memory is not set up yet. - */ - DBDate = getenv("PGDATESTYLE"); - if (DBDate != NULL) - { - if (strcasecmp(DBDate, "ISO") == 0) - DateStyle = USE_ISO_DATES; - else if (strcasecmp(DBDate, "SQL") == 0) - DateStyle = USE_SQL_DATES; - else if (strcasecmp(DBDate, "POSTGRES") == 0) - DateStyle = USE_POSTGRES_DATES; - else if (strcasecmp(DBDate, "GERMAN") == 0) - { - DateStyle = USE_GERMAN_DATES; - EuroDates = TRUE; - } - else if (strcasecmp(DBDate, "NONEURO") == 0) - EuroDates = FALSE; - else if (strcasecmp(DBDate, "EURO") == 0) - EuroDates = TRUE; - } + /* Check for PGDATESTYLE environment variable */ + set_default_datestyle(); /* * Read default pg_options from file $DATADIR/pg_options. @@ -1525,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.142 $ $Date: 2000/02/18 09:29:27 $\n"); + puts("$Revision: 1.143 $ $Date: 2000/02/19 22:10:47 $\n"); } /* -- cgit v1.2.3