Commit 367089b0 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

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.
parent 4ebc4e39
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.44 1997/11/10 05:10:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.45 1997/11/10 15:41:58 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -47,6 +47,7 @@ static void closePGconn(PGconn *conn);
static int conninfo_parse(const char *conninfo, char *errorMessage);
static char *conninfo_getval(char *keyword);
static void conninfo_free(void);
void PQsetenv(PGconn *conn);
#define NOTIFYLIST_INITIAL_SIZE 10
#define NOTIFYLIST_GROWBY 10
......@@ -109,18 +110,15 @@ struct EnvironmentOptions
} EnvironmentOptions[] =
{
{
"PG_DATESTYLE", "datestyle"
},
{
NULL
}
{ "PGDATESTYLE", "datestyle" },
{ "PGTZ", "timezone" },
{ NULL }
};
/* ----------------
* PQconnectdb
*
* establishes a connectin to a postgres backend through the postmaster
* establishes a connection to a postgres backend through the postmaster
* using connection information in a string.
*
* The conninfo string is a list of
......@@ -255,6 +253,8 @@ PQconnectdb(const char *conninfo)
PQclear(res);
}
PQsetenv(conn);
return conn;
}
......@@ -309,6 +309,11 @@ PQconndefaults(void)
*
* None of the above need be defined. There are defaults for all of them.
*
* To support "delimited identifiers" for database names, only convert
* the database name to lower case if it is not surrounded by double quotes.
* Otherwise, strip the double quotes but leave the reset of the string intact.
* - thomas 1997-11-08
*
* ----------------
*/
PGconn *
......@@ -419,8 +424,8 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
conn->dbName = strdup(conn->pguser);
/*
* if the table name is surrounded by double-quotes, then
* don't convert case
* if the database name is surrounded by double-quotes,
* then don't convert case
*/
if (*conn->dbName == '"')
{
......@@ -457,6 +462,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
}
PQclear(res);
}
PQsetenv(conn);
}
}
return conn;
......@@ -625,7 +631,24 @@ connectDB(PGconn *conn)
conn->port = port;
{
return CONNECTION_OK;
connect_errReturn:
/*
* Igor/6/3/97 - We need to free it here...otherwise the function
* returns without setting conn->port to port. Because of that any way
* of referencing this variable will be lost and it's allocated memory
* will not be freed.
*/
free(port); /* PURIFY */
return CONNECTION_BAD;
}
void
PQsetenv(PGconn *conn)
{
struct EnvironmentOptions *eo;
char setQuery[80]; /* mjl: size okay? XXX */
......@@ -638,25 +661,14 @@ connectDB(PGconn *conn)
PGresult *res;
sprintf(setQuery, "SET %s TO '%.60s'", eo->pgName, val);
#ifdef CONNECTDEBUG
printf("Use environment variable %s to send %s\n", eo->envName, setQuery);
#endif
res = PQexec(conn, setQuery);
PQclear(res); /* Don't care? */
}
}
}
return CONNECTION_OK;
connect_errReturn:
/*
* Igor/6/3/97 - We need to free it here...otherwise the function
* returns without setting conn->port to port. Because of that any way
* of referencing this variable will be lost and it's allocated memory
* will not be freed.
*/
free(port); /* PURIFY */
return CONNECTION_BAD;
}
} /* PQsetenv() */
/*
* freePGconn
......
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