Commit f4657116 authored by Tom Lane's avatar Tom Lane

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.
parent bd43ae0e
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "commands/async.h" #include "commands/async.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "commands/variable.h"
#include "libpq/libpq.h" #include "libpq/libpq.h"
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "libpq/pqsignal.h" #include "libpq/pqsignal.h"
...@@ -891,7 +892,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -891,7 +892,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
char *remote_host = ""; char *remote_host = "";
unsigned short remote_port = 0; unsigned short remote_port = 0;
char *DBDate = NULL;
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
extern int DebugLvl; extern int DebugLvl;
...@@ -912,30 +912,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -912,30 +912,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
SetProcessingMode(InitProcessing); SetProcessingMode(InitProcessing);
/* /* Check for PGDATESTYLE environment variable */
* Try to get initial values for date styles and formats. Does not do set_default_datestyle();
* 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;
}
/* /*
* Read default pg_options from file $DATADIR/pg_options. * Read default pg_options from file $DATADIR/pg_options.
...@@ -1525,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1525,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); 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");
} }
/* /*
......
...@@ -2,32 +2,16 @@ ...@@ -2,32 +2,16 @@
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements * statements
* *
* $Id: variable.h,v 1.8 1998/10/08 18:30:27 momjian Exp $ * $Id: variable.h,v 1.9 2000/02/19 22:10:43 tgl Exp $
* *
*/ */
#ifndef VARIABLE_H #ifndef VARIABLE_H
#define VARIABLE_H 1 #define VARIABLE_H 1
enum DateFormat extern bool SetPGVariable(const char *name, const char *value);
{ extern bool GetPGVariable(const char *name);
Date_Postgres, Date_SQL, Date_ISO extern bool ResetPGVariable(const char *name);
};
/*-----------------------------------------------------------------------*/ extern void set_default_datestyle(void);
struct PGVariables
{
struct
{
bool euro;
enum DateFormat format;
} date;
};
extern struct PGVariables PGVariables;
/*-----------------------------------------------------------------------*/
bool SetPGVariable(const char *, const char *);
bool GetPGVariable(const char *);
bool ResetPGVariable(const char *);
#endif /* VARIABLE_H */ #endif /* VARIABLE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment