]> granicus.if.org Git - postgresql/commitdiff
Bring in a patch from Keith Parks to move the use of European dates
authorMarc G. Fournier <scrappy@hub.org>
Sun, 26 Jan 1997 15:32:28 +0000 (15:32 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Sun, 26 Jan 1997 15:32:28 +0000 (15:32 +0000)
from a #define to a run-time option '-e'

Man page was updated to reflect new option

src/backend/parser/sysfunc.c
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/backend/utils/adt/datetimes.c
src/backend/utils/init/globals.c
src/include/config.h
src/include/miscadmin.h
src/man/postgres.1
src/man/postmaster.1

index 7cad3ab7ba590b1765164f1dbeeb8236594063b0..18e3c5afe54d4625d98c04c31ceebce966f6c014 100644 (file)
@@ -19,6 +19,8 @@
 #include <time.h>
 
 #include <config.h>
+#include <postgres.h>
+#include <miscadmin.h>
 #include <parser/sysfunc.h>
 
 /*
@@ -33,13 +35,13 @@ static char *Sysfunc_system_date(void)
        
        time(&cur_time_secs);
        cur_time_expanded = localtime(&cur_time_secs);
-#if defined(EUROPEAN_DATES)
-       sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mday,
+       if (EuroDates == 1)
+               sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mday,
                        cur_time_expanded->tm_mon+1, cur_time_expanded->tm_year+1900);
-#else
-       sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mon+1,
+       else
+               sprintf(buf, "%2.2d-%2.2d-%4.4d", cur_time_expanded->tm_mon+1,
                        cur_time_expanded->tm_mday, cur_time_expanded->tm_year+1900);
-#endif
+
        return &buf[0];
 }
 
index e8c0bf5719e42f832c1c870adda854d34849bfd8..fc708d0d469306f14f21396ca06ea0d1a02b1b40 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.34 1997/01/24 18:27:29 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.35 1997/01/26 15:30:23 scrappy Exp $
  *
  * NOTES
  *
@@ -251,7 +251,7 @@ PostmasterMain(int argc, char *argv[])
     DataDir = getenv("PGDATA");  /* default value */
     
     opterr = 0;
-    while ((opt = getopt(argc, argv, "a:B:b:D:dmM:no:p:Ss")) != EOF) {
+    while ((opt = getopt(argc, argv, "a:B:b:D:demM:no:p:Ss")) != EOF) {
         switch (opt) {
         case 'a': 
             /* Set the authentication system. */
@@ -294,13 +294,19 @@ PostmasterMain(int argc, char *argv[])
             else
                 DebugLvl = 1;
             break;
-          case 'm':
+        case 'e':
+            /*
+             * Use european date formats.
+             */
+            EuroDates = 1;
+            break;
+        case 'm':
             MultiplexedBackends = 1;
             MultiplexedBackendPort = atoi(optarg);
             break;
         case 'M':
             /* ignore this flag.  This may be passed in because the
-               program was run as 'postgres -M' instead of 'postmaster' */
+                program was run as 'postgres -M' instead of 'postmaster' */
             break;
         case 'n': 
             /* Don't reinit shared mem after abnormal exit */
@@ -1128,6 +1134,10 @@ DoExec(StartupInfo *packet, int portFd)
 #endif /* WIN32 */
 
     }
+
+    /* tell the backend we're using European dates */
+    if (EuroDates == 1)
+      av[ac++] = "-e";
     
     /* tell the multiplexed backend to start on a certain port */
     if (MultiplexedBackends) {
index 09ee96fca5f3b594a432e6e4516f89d14868cf69..07bae4af5fe50c7a1f9698efaffa2fab9ef788b4 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.25 1997/01/14 08:05:26 bryanh Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.26 1997/01/26 15:30:48 scrappy Exp $
  *
  * NOTES
  *    this is the "main" module of the postgres backend and
@@ -784,6 +784,7 @@ PostgresMain(int argc, char *argv[])
     int    flagQ;
     int    flagS;
     int    flagE;
+    int    flagEu;
     int    flag;
     
     char   *DBName = NULL; 
@@ -842,7 +843,7 @@ PostgresMain(int argc, char *argv[])
      *  parse command line arguments
      * ----------------
      */
-    flagC = flagQ = flagS = flagE = ShowStats = 0;
+    flagC = flagQ = flagS = flagE = flagEu = ShowStats = 0;
     ShowParserStats = ShowPlannerStats = ShowExecutorStats = 0;
     
     /* get hostname is either the environment variable PGHOST
@@ -856,7 +857,7 @@ PostgresMain(int argc, char *argv[])
     DataDir = getenv("PGDATA");   /* default */
     multiplexedBackend = false;   /* default */
 
-    while ((flag = getopt(argc, argv, "B:bCD:d:Ef:iLm:MNo:P:pQSst:x:F")) 
+    while ((flag = getopt(argc, argv, "B:bCD:d:Eef:iLm:MNo:P:pQSst:x:F")) 
            != EOF)
         switch (flag) {
             
@@ -907,6 +908,14 @@ PostgresMain(int argc, char *argv[])
             flagE = 1;
             break;
             
+        case 'e':
+            /* --------------------------
+             * Use european date formats.
+             * --------------------------
+             */
+            flagEu = 1;
+            break;
+
         case 'F':
             /* --------------------
              *  turn off fsync
@@ -1135,6 +1144,7 @@ PostgresMain(int argc, char *argv[])
     Noversion = flagC;
     Quiet = flagQ;
     EchoQuery = flagE;
+    EuroDates = flagEu;
     
     /* ----------------
      *  print flags
@@ -1146,6 +1156,7 @@ PostgresMain(int argc, char *argv[])
         printf("\tNoversion =    %c\n", Noversion ? 't' : 'f');
         printf("\tstable    =    %c\n", flagS     ? 't' : 'f');
         printf("\ttimings   =    %c\n", ShowStats ? 't' : 'f');
+        printf("\tdates     =    %s\n", EuroDates ? "European" : "Normal");
         printf("\tbufsize   =    %d\n", NBuffers);
         
         printf("\tquery echo =   %c\n", EchoQuery ? 't' : 'f');
@@ -1271,7 +1282,7 @@ PostgresMain(int argc, char *argv[])
      */
     if (IsUnderPostmaster == false) {
         puts("\nPOSTGRES backend interactive interface");
-        puts("$Revision: 1.25 $ $Date: 1997/01/14 08:05:26 $");
+        puts("$Revision: 1.26 $ $Date: 1997/01/26 15:30:48 $");
     }
     
     /* ----------------
index 693351a380e503042a63791d5bb8203649f8636a..614bccd72df741ed47ad08ad529cd7bcfdaaac7b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.7 1996/11/14 21:38:58 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.8 1997/01/26 15:31:12 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,6 +15,7 @@
 #include <string.h>
 
 #include <postgres.h>
+#include <miscadmin.h>
 #include <utils/builtins.h>
 #include <utils/datetime.h>
 
@@ -50,19 +51,19 @@ date_in(char *datestr)
 # define CHECK_DATE_LEN(datestr) 1
 #endif
 
-#ifndef EUROPEAN_DATES
-    if (!CHECK_DATE_LEN(datestr) ||
-       sscanf(datestr, "%d%*c%d%*c%d", &m, &d, &y) != 3) {
-       elog(WARN, "date_in: date \"%s\" not of the form mm-dd-yyyy",
-            datestr);
-    }
-#else
-    if (!CHECK_DATE_LEN(datestr) ||
-       sscanf(datestr, "%d%*c%d%*c%d", &d, &m, &y) != 3) {
-       elog(WARN, "date_in: date \"%s\" not of the form dd-mm-yyyy",
-            datestr);
+    if (EuroDates == 1) { /* Expect european format dates */
+        if (!CHECK_DATE_LEN(datestr) ||
+          sscanf(datestr, "%d%*c%d%*c%d", &d, &m, &y) != 3) {
+            elog(WARN, "date_in: date \"%s\" not of the form dd-mm-yyyy",
+             datestr);
+        }
+    } else {
+        if (!CHECK_DATE_LEN(datestr) ||
+          sscanf(datestr, "%d%*c%d%*c%d", &m, &d, &y) != 3) {
+            elog(WARN, "date_in: date \"%s\" not of the form mm-dd-yyyy",
+              datestr);
+        }
     }
-#endif
     if (y < 0 || y > 32767)
        elog(WARN, "date_in: year must be limited to values 0 through 32767 in \"%s\"", datestr);
     if (m < 1 || m > 12)
@@ -94,13 +95,12 @@ date_out(int4 dateVal)
     date = (DateADT*)&dateStore;
     dateStore = dateVal;
 
-#ifndef EUROPEAN_DATES
-    sprintf(datestr, "%02d-%02d-%04d",
-            (int)date->month, (int)date->day, (int)date->year);
-#else
-    sprintf(datestr, "%02d-%02d-%04d",
-            (int)date->day, (int)date->month, (int)date->year);
-#endif
+    if (EuroDates == 1) /* Output european format dates */
+        sprintf(datestr, "%02d-%02d-%04d",
+                (int)date->day, (int)date->month, (int)date->year);
+    else
+        sprintf(datestr, "%02d-%02d-%04d",
+                (int)date->month, (int)date->day, (int)date->year);
 
     return datestr;
 }
index ccc93783022a84204f16e51361dc84929162e550..8ab5fa82f91baa93e137e563d32fdfa03ebbf053 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.4 1997/01/14 08:05:36 bryanh Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.5 1997/01/26 15:31:29 scrappy Exp $
  *
  * NOTES
  *    Globals used all over the place should be declared here and not
@@ -65,6 +65,8 @@ bool          IsPostmaster = false;
 
 short          DebugLvl = 0;
 
+int             EuroDates = 0;
+
 char *IndexedCatalogNames[] = {
     AttributeRelationName,
     ProcedureRelationName,
index 4fbeb1f82a38a7422fef2c94b475471d0c74ea68..e481cbc779ff7c1e468a181bc14651bc43c5bb4c 100644 (file)
@@ -21,7 +21,7 @@
 
 /* Define one for either <history.h> or <readline/history.h> 
  */
-/* #undef HAVE_HISTORY  */
+/* #undef HAVE_HISTORY */
 
 
 #define HAVE_SYS_SELECT_H
@@ -265,11 +265,6 @@ typedef unsigned char slock_t;
 
 #define DEF_PGPORT "5432"
 
-/* turn this on if you prefer European style dates instead of American
- * style dates
- */
-/* #define EUROPEAN_DATES  */
-
 /*
  * If you do not plan to use Host based authentication,
  * comment out the following line
index 844340f9ef0a3bf43bf2f75a77e244a240b09d72..5fab595f175879c9b8709dac2a3909648716c671 100644 (file)
@@ -11,7 +11,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: miscadmin.h,v 1.4 1996/11/14 10:25:42 bryanh Exp $
+ * $Id: miscadmin.h,v 1.5 1997/01/26 15:32:06 scrappy Exp $
  *
  * NOTES
  *    some of the information in this file will be moved to
@@ -57,6 +57,8 @@ extern bool       IsPostmaster;
 
 extern short       DebugLvl;
 
+extern int          EuroDates;
+
 extern Oid         LastOidProcessed;   /* for query rewrite */
 
 #define MAX_PARSE_BUFFER 8192
index 09767c52c7eee67c2551722efa061e46513aa983..940e1822f9f46a44b6d11f2b354657d57b5e99a2 100644 (file)
@@ -1,6 +1,6 @@
 .\" This is -*-nroff-*-
 .\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/postgres.1,v 1.4 1996/12/11 22:58:14 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/postgres.1,v 1.5 1997/01/26 15:32:20 scrappy Exp $
 .TH POSTGRES95 UNIX 12/08/96 Postgres95 Postgres95
 .SH NAME
 postgres \(em the Postgres backend server
@@ -25,6 +25,9 @@ filedes]
 [\c
 .BR "-Q"
 ]
+[\c
+.BR "-e"
+]
 .br
 [\c
 .BR "-d"
@@ -78,9 +81,6 @@ has allocated for the backend server processes that it starts.  If the
 backend is running standalone, this specifies the number of buffers to
 allocate.  This value defaults to 64.
 .TP
-.BR "-E"
-Echo all queries.
-.TP
 .BR "-F"
 Disable automatic fsync() call after each transaction.
 This option improves performance, but an operating system crash
@@ -96,6 +96,26 @@ useful for interactive use.
 .BR "-Q"
 Specifies \*(lqquiet\*(rq mode.
 .TP
+.BR "-E"
+Echo all queries.
+.TP
+.BR "-e"
+The
+.IR "-e"
+option controls how dates are input to and output from the database.
+.IP
+If the
+.IR "-e"
+option is supplied, then all dates passed to and from the frontend
+processes will be assumed to be in
+.IR "European"
+format ie.
+.IR "DD-MM-YYYY"
+otherwise dates are input and output in
+.IR "American"
+format ie.
+.IR "MM-DD-YYYY"
+.TP
 .BR "-d" " debug_level"
 Turns on debugging at the numeric level
 .IR "debug_level" .
index bad69d7e1055ab93d95204713ffe21fa474b7a0c..3ee1f457c2e6cf91f3340742af50968be743984e 100644 (file)
@@ -1,6 +1,6 @@
 .\" This is -*-nroff-*-
 .\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/postmaster.1,v 1.2 1996/12/11 00:28:02 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/postmaster.1,v 1.3 1997/01/26 15:32:28 scrappy Exp $
 .TH POSTMASTER UNIX 11/05/95 PostgreSQL PostgreSQL
 .SH "NAME"
 postmaster \(em run the Postgres postmaster
@@ -29,6 +29,9 @@ backend_pathname]
 [\c
 .BR "-n" \c
 ]
+[\c
+.BR "-e" \c
+]
 .br
 [\c
 .BR "-o"
@@ -170,6 +173,23 @@ programmer can then use the
 .IR shmemdoc
 program to examine shared memory and semaphore state.
 .TP
+.BR "-e"
+The
+.IR "-e"
+option controls how dates are input to and output from the database.
+.IP
+If the
+.IR "-e"
+option is supplied, then all dates passed to and from the frontend
+processes will be assumed to be in
+.IR "European"
+format ie.
+.IR "DD-MM-YYYY"
+otherwise dates are input and output in
+.IR "American"
+format ie.
+.IR "MM-DD-YYYY"
+.TP
 .BR "-o" " backend_options"
 The 
 .IR postgres (1)