7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.44 1997/11/1005:10:45 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.45 1997/11/1015:41:58 thomas Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -47,6 +47,7 @@ static void closePGconn(PGconn *conn);
47
47
static int conninfo_parse (const char * conninfo ,char * errorMessage );
48
48
static char * conninfo_getval (char * keyword );
49
49
static void conninfo_free (void );
50
+ void PQsetenv (PGconn * conn );
50
51
51
52
#define NOTIFYLIST_INITIAL_SIZE 10
52
53
#define NOTIFYLIST_GROWBY 10
@@ -109,18 +110,15 @@ struct EnvironmentOptions
109
110
}EnvironmentOptions []=
110
111
111
112
{
112
- {
113
- "PG_DATESTYLE" ,"datestyle"
114
- },
115
- {
116
- NULL
117
- }
113
+ {"PGDATESTYLE" ,"datestyle" },
114
+ {"PGTZ" ,"timezone" },
115
+ {NULL }
118
116
};
119
117
120
118
/* ----------------
121
119
*PQconnectdb
122
120
*
123
- * establishes aconnectin to a postgres backend through the postmaster
121
+ * establishes aconnection to a postgres backend through the postmaster
124
122
* using connection information in a string.
125
123
*
126
124
* The conninfo string is a list of
@@ -136,7 +134,7 @@ struct EnvironmentOptions
136
134
* then some fields may be null'ed out instead of having valid values
137
135
* ----------------
138
136
*/
139
- PGconn *
137
+ PGconn *
140
138
PQconnectdb (const char * conninfo )
141
139
{
142
140
PGconn * conn ;
@@ -255,6 +253,8 @@ PQconnectdb(const char *conninfo)
255
253
PQclear (res );
256
254
}
257
255
256
+ PQsetenv (conn );
257
+
258
258
return conn ;
259
259
}
260
260
@@ -309,6 +309,11 @@ PQconndefaults(void)
309
309
*
310
310
* None of the above need be defined. There are defaults for all of them.
311
311
*
312
+ * To support "delimited identifiers" for database names, only convert
313
+ * the database name to lower case if it is not surrounded by double quotes.
314
+ * Otherwise, strip the double quotes but leave the reset of the string intact.
315
+ * - thomas 1997-11-08
316
+ *
312
317
* ----------------
313
318
*/
314
319
PGconn *
@@ -419,8 +424,8 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
419
424
conn -> dbName = strdup (conn -> pguser );
420
425
421
426
/*
422
- * if thetable name is surrounded by double-quotes, then
423
- * don't convert case
427
+ * if thedatabase name is surrounded by double-quotes,
428
+ * then don't convert case
424
429
*/
425
430
if (* conn -> dbName == '"' )
426
431
{
@@ -457,6 +462,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
457
462
}
458
463
PQclear (res );
459
464
}
465
+ PQsetenv (conn );
460
466
}
461
467
}
462
468
return conn ;
@@ -625,24 +631,6 @@ connectDB(PGconn *conn)
625
631
626
632
conn -> port = port ;
627
633
628
- {
629
- struct EnvironmentOptions * eo ;
630
- char setQuery [80 ];/* mjl: size okay? XXX */
631
-
632
- for (eo = EnvironmentOptions ;eo -> envName ;eo ++ )
633
- {
634
- const char * val ;
635
-
636
- if ((val = getenv (eo -> envName )))
637
- {
638
- PGresult * res ;
639
-
640
- sprintf (setQuery ,"SET %s TO '%.60s'" ,eo -> pgName ,val );
641
- res = PQexec (conn ,setQuery );
642
- PQclear (res );/* Don't care? */
643
- }
644
- }
645
- }
646
634
return CONNECTION_OK ;
647
635
648
636
connect_errReturn :
@@ -658,6 +646,30 @@ connectDB(PGconn *conn)
658
646
659
647
}
660
648
649
+ void
650
+ PQsetenv (PGconn * conn )
651
+ {
652
+ struct EnvironmentOptions * eo ;
653
+ char setQuery [80 ];/* mjl: size okay? XXX */
654
+
655
+ for (eo = EnvironmentOptions ;eo -> envName ;eo ++ )
656
+ {
657
+ const char * val ;
658
+
659
+ if ((val = getenv (eo -> envName )))
660
+ {
661
+ PGresult * res ;
662
+
663
+ sprintf (setQuery ,"SET %s TO '%.60s'" ,eo -> pgName ,val );
664
+ #ifdef CONNECTDEBUG
665
+ printf ("Use environment variable %s to send %s\n" ,eo -> envName ,setQuery );
666
+ #endif
667
+ res = PQexec (conn ,setQuery );
668
+ PQclear (res );/* Don't care? */
669
+ }
670
+ }
671
+ }/* PQsetenv() */
672
+
661
673
/*
662
674
* freePGconn
663
675
* - free the PGconn data structure