*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
} 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
* then some fields may be null'ed out instead of having valid values
* ----------------
*/
-PGconn *
+PGconn *
PQconnectdb(const char *conninfo)
{
PGconn *conn;
PQclear(res);
}
+ PQsetenv(conn);
+
return conn;
}
*
* 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 *
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 == '"')
{
}
PQclear(res);
}
+ PQsetenv(conn);
}
}
return conn;
conn->port = port;
- {
- struct EnvironmentOptions *eo;
- char setQuery[80]; /* mjl: size okay? XXX */
-
- for (eo = EnvironmentOptions; eo->envName; eo++)
- {
- const char *val;
-
- if ((val = getenv(eo->envName)))
- {
- PGresult *res;
-
- sprintf(setQuery, "SET %s TO '%.60s'", eo->pgName, val);
- res = PQexec(conn, setQuery);
- PQclear(res); /* Don't care? */
- }
- }
- }
return CONNECTION_OK;
connect_errReturn:
}
+void
+PQsetenv(PGconn *conn)
+{
+ struct EnvironmentOptions *eo;
+ char setQuery[80]; /* mjl: size okay? XXX */
+
+ for (eo = EnvironmentOptions; eo->envName; eo++)
+ {
+ const char *val;
+
+ if ((val = getenv(eo->envName)))
+ {
+ 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? */
+ }
+ }
+} /* PQsetenv() */
+
/*
* freePGconn
* - free the PGconn data structure