Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit367089b

Browse files
author
Thomas G. Lockhart
committed
Add PGTZ environment variable to initialization code.
Rename PG_DATESTYLE to PGDATESTYLE environment variable.Move environment variable code to a different place so it now works!Note that regression tests can now run with "setenv PGTZ PST8PDT" at the frontend rather than requiring the backend to have TZ set.
1 parent4ebc4e3 commit367089b

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -47,6 +47,7 @@ static void closePGconn(PGconn *conn);
4747
staticintconninfo_parse(constchar*conninfo,char*errorMessage);
4848
staticchar*conninfo_getval(char*keyword);
4949
staticvoidconninfo_free(void);
50+
voidPQsetenv(PGconn*conn);
5051

5152
#defineNOTIFYLIST_INITIAL_SIZE 10
5253
#defineNOTIFYLIST_GROWBY 10
@@ -109,18 +110,15 @@ struct EnvironmentOptions
109110
}EnvironmentOptions[]=
110111

111112
{
112-
{
113-
"PG_DATESTYLE","datestyle"
114-
},
115-
{
116-
NULL
117-
}
113+
{"PGDATESTYLE","datestyle" },
114+
{"PGTZ","timezone" },
115+
{NULL }
118116
};
119117

120118
/* ----------------
121119
*PQconnectdb
122120
*
123-
* establishes aconnectin to a postgres backend through the postmaster
121+
* establishes aconnection to a postgres backend through the postmaster
124122
* using connection information in a string.
125123
*
126124
* The conninfo string is a list of
@@ -136,7 +134,7 @@ struct EnvironmentOptions
136134
* then some fields may be null'ed out instead of having valid values
137135
* ----------------
138136
*/
139-
PGconn*
137+
PGconn*
140138
PQconnectdb(constchar*conninfo)
141139
{
142140
PGconn*conn;
@@ -255,6 +253,8 @@ PQconnectdb(const char *conninfo)
255253
PQclear(res);
256254
}
257255

256+
PQsetenv(conn);
257+
258258
returnconn;
259259
}
260260

@@ -309,6 +309,11 @@ PQconndefaults(void)
309309
*
310310
* None of the above need be defined. There are defaults for all of them.
311311
*
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+
*
312317
* ----------------
313318
*/
314319
PGconn*
@@ -419,8 +424,8 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
419424
conn->dbName=strdup(conn->pguser);
420425

421426
/*
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+
* thendon't convert case
424429
*/
425430
if (*conn->dbName=='"')
426431
{
@@ -457,6 +462,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
457462
}
458463
PQclear(res);
459464
}
465+
PQsetenv(conn);
460466
}
461467
}
462468
returnconn;
@@ -625,24 +631,6 @@ connectDB(PGconn *conn)
625631

626632
conn->port=port;
627633

628-
{
629-
structEnvironmentOptions*eo;
630-
charsetQuery[80];/* mjl: size okay? XXX */
631-
632-
for (eo=EnvironmentOptions;eo->envName;eo++)
633-
{
634-
constchar*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-
}
646634
returnCONNECTION_OK;
647635

648636
connect_errReturn:
@@ -658,6 +646,30 @@ connectDB(PGconn *conn)
658646

659647
}
660648

649+
void
650+
PQsetenv(PGconn*conn)
651+
{
652+
structEnvironmentOptions*eo;
653+
charsetQuery[80];/* mjl: size okay? XXX */
654+
655+
for (eo=EnvironmentOptions;eo->envName;eo++)
656+
{
657+
constchar*val;
658+
659+
if ((val=getenv(eo->envName)))
660+
{
661+
PGresult*res;
662+
663+
sprintf(setQuery,"SET %s TO '%.60s'",eo->pgName,val);
664+
#ifdefCONNECTDEBUG
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+
661673
/*
662674
* freePGconn
663675
* - free the PGconn data structure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp