1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Merge the last few variable.c configuration variables into the generic

GUC support.  It's now possible to set datestyle, timezone, and
client_encoding from postgresql.conf and per-database or per-user
settings.  Also, implement rollback of SET commands that occur in a
transaction that later fails.  Create a SET LOCAL var = value syntax
that sets the variable only for the duration of the current transaction.
All per previous discussions in pghackers.
This commit is contained in:
Tom Lane
2002-05-17 01:19:19 +00:00
parent fa613fa1ea
commit f0811a74b3
42 changed files with 2641 additions and 1802 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.120 2002/04/01 03:34:25 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.121 2002/05/17 01:19:16 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -173,6 +173,7 @@
#include "storage/proc.h"
#include "storage/sinval.h"
#include "storage/smgr.h"
#include "utils/guc.h"
#include "utils/inval.h"
#include "utils/memutils.h"
#include "utils/portal.h"
@ -1002,6 +1003,7 @@ CommitTransaction(void)
RelationPurgeLocalRelation(true);
smgrDoPendingDeletes(true);
AtEOXact_GUC(true);
AtEOXact_SPI();
AtEOXact_gist();
AtEOXact_hash();
@ -1104,6 +1106,7 @@ AbortTransaction(void)
RelationPurgeLocalRelation(false);
smgrDoPendingDeletes(false);
AtEOXact_GUC(false);
AtEOXact_SPI();
AtEOXact_gist();
AtEOXact_hash();

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.94 2002/05/09 13:30:24 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.95 2002/05/17 01:19:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -3272,31 +3272,10 @@ xlog_outrec(char *buf, XLogRecord *record)
/*
* GUC support routines
* GUC support
*/
bool
check_xlog_sync_method(const char *method)
{
if (strcasecmp(method, "fsync") == 0)
return true;
#ifdef HAVE_FDATASYNC
if (strcasecmp(method, "fdatasync") == 0)
return true;
#endif
#ifdef OPEN_SYNC_FLAG
if (strcasecmp(method, "open_sync") == 0)
return true;
#endif
#ifdef OPEN_DATASYNC_FLAG
if (strcasecmp(method, "open_datasync") == 0)
return true;
#endif
return false;
}
void
assign_xlog_sync_method(const char *method)
const char *
assign_xlog_sync_method(const char *method, bool doit, bool interactive)
{
int new_sync_method;
int new_sync_bit;
@ -3329,12 +3308,12 @@ assign_xlog_sync_method(const char *method)
#endif
else
{
/* Can't get here unless guc.c screwed up */
elog(ERROR, "bogus wal_sync_method %s", method);
new_sync_method = 0; /* keep compiler quiet */
new_sync_bit = 0;
return NULL;
}
if (!doit)
return method;
if (sync_method != new_sync_method || open_sync_bit != new_sync_bit)
{
/*
@ -3359,6 +3338,8 @@ assign_xlog_sync_method(const char *method)
sync_method = new_sync_method;
open_sync_bit = new_sync_bit;
}
return method;
}

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.128 2002/05/05 00:03:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.129 2002/05/17 01:19:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -249,7 +249,7 @@ BootstrapMain(int argc, char *argv[])
dbName = NULL;
if (!IsUnderPostmaster)
{
ResetAllOptions(true);
InitializeGUCOptions();
potential_DataDir = getenv("PGDATA"); /* Null if no PGDATA
* variable */
}
@ -263,12 +263,13 @@ BootstrapMain(int argc, char *argv[])
break;
case 'd':
{
/* Turn on debugging for the postmaster. */
/* Turn on debugging for the bootstrap process. */
char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
sprintf(debugstr, "debug%s", optarg);
/* We use PGC_S_SESSION because we will reset in backend */
SetConfigOption("server_min_messages", debugstr, PGC_POSTMASTER, PGC_S_ARGV);
SetConfigOption("client_min_messages", debugstr, PGC_POSTMASTER, PGC_S_ARGV);
SetConfigOption("server_min_messages", debugstr,
PGC_POSTMASTER, PGC_S_ARGV);
SetConfigOption("client_min_messages", debugstr,
PGC_POSTMASTER, PGC_S_ARGV);
pfree(debugstr);
break;
}

View File

@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.19 2002/05/12 20:10:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.20 2002/05/17 01:19:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1739,16 +1739,16 @@ RemoveTempRelationsCallback(void)
* Routines for handling the GUC variable 'search_path'.
*/
/* parse_hook: is proposed value valid? */
bool
check_search_path(const char *proposed)
/* assign_hook: validate new search_path, do extra actions as needed */
const char *
assign_search_path(const char *newval, bool doit, bool interactive)
{
char *rawname;
List *namelist;
List *l;
/* Need a modifiable copy of string */
rawname = pstrdup(proposed);
rawname = pstrdup(newval);
/* Parse string into list of identifiers */
if (!SplitIdentifierString(rawname, ',', &namelist))
@ -1756,59 +1756,45 @@ check_search_path(const char *proposed)
/* syntax error in name list */
pfree(rawname);
freeList(namelist);
return false;
return NULL;
}
/*
* If we aren't inside a transaction, we cannot do database access so
* cannot verify the individual names. Must accept the list on faith.
* (This case can happen, for example, when the postmaster reads a
* search_path setting from postgresql.conf.)
*/
if (!IsTransactionState())
if (interactive && IsTransactionState())
{
pfree(rawname);
freeList(namelist);
return true;
}
/*
* Verify that all the names are either valid namespace names or "$user".
* We do not require $user to correspond to a valid namespace.
* We do not check for USAGE rights, either; should we?
*/
foreach(l, namelist)
{
char *curname = (char *) lfirst(l);
if (strcmp(curname, "$user") == 0)
continue;
if (!SearchSysCacheExists(NAMESPACENAME,
CStringGetDatum(curname),
0, 0, 0))
/*
* Verify that all the names are either valid namespace names or
* "$user". We do not require $user to correspond to a valid
* namespace. We do not check for USAGE rights, either; should we?
*/
foreach(l, namelist)
{
pfree(rawname);
freeList(namelist);
return false;
char *curname = (char *) lfirst(l);
if (strcmp(curname, "$user") == 0)
continue;
if (!SearchSysCacheExists(NAMESPACENAME,
CStringGetDatum(curname),
0, 0, 0))
elog(ERROR, "Namespace \"%s\" does not exist", curname);
}
}
pfree(rawname);
freeList(namelist);
return true;
}
/* assign_hook: do extra actions needed when assigning to search_path */
void
assign_search_path(const char *newval)
{
/*
* We mark the path as needing recomputation, but don't do anything until
* it's needed. This avoids trying to do database access during GUC
* initialization.
*/
namespaceSearchPathValid = false;
if (doit)
namespaceSearchPathValid = false;
return newval;
}
/*
@ -1844,6 +1830,8 @@ InitializeSearchPath(void)
CacheRegisterSyscacheCallback(NAMESPACEOID,
NamespaceCallback,
(Datum) 0);
/* Force search path to be recomputed on next use */
namespaceSearchPathValid = false;
}
}

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.88 2002/04/27 21:24:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.89 2002/05/17 01:19:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -458,9 +458,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
char repl_null[Natts_pg_database];
char repl_repl[Natts_pg_database];
valuestr = (stmt->value
? ((A_Const *) lfirst(stmt->value))->val.val.str
: NULL);
valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname,
@ -477,7 +475,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
MemSet(repl_repl, ' ', sizeof(repl_repl));
repl_repl[Anum_pg_database_datconfig-1] = 'r';
if (strcmp(stmt->variable, "all")==0 && stmt->value == NULL)
if (strcmp(stmt->variable, "all")==0 && valuestr == NULL)
{
/* RESET ALL */
repl_null[Anum_pg_database_datconfig-1] = 'n';

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.100 2002/04/28 00:36:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.101 2002/05/17 01:19:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -851,9 +851,7 @@ AlterUserSet(AlterUserSetStmt *stmt)
char repl_repl[Natts_pg_shadow];
int i;
valuestr = (stmt->value
? ((A_Const *) lfirst(stmt->value))->val.val.str
: NULL);
valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
/*
* RowExclusiveLock is sufficient, because we don't need to update
@ -874,7 +872,7 @@ AlterUserSet(AlterUserSetStmt *stmt)
repl_repl[i] = ' ';
repl_repl[Anum_pg_shadow_useconfig-1] = 'r';
if (strcmp(stmt->variable, "all")==0 && stmt->value == NULL)
if (strcmp(stmt->variable, "all")==0 && valuestr == NULL)
/* RESET ALL */
repl_null[Anum_pg_shadow_useconfig-1] = 'n';
else

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.50 2002/04/03 05:39:29 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.51 2002/05/17 01:19:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -125,7 +125,7 @@ main(int argc, char *argv[])
* and COLLATE will be overridden later from pg_control if we are
* in an already-initialized database. We set them here so that
* they will be available to fill pg_control during initdb. The
* other ones will get reset later in ResetAllOptions, but we set
* other ones will get reset later in InitializeGUCOptions, but we set
* them here to get already localized behavior during startup
* (e.g., error messages).
*/

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.185 2002/05/13 20:39:43 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.186 2002/05/17 01:19:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -2342,6 +2342,7 @@ _copyVariableSetStmt(VariableSetStmt *from)
if (from->name)
newnode->name = pstrdup(from->name);
Node_Copy(from, newnode, args);
newnode->is_local = from->is_local;
return newnode;
}

View File

@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.132 2002/05/12 23:43:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.133 2002/05/17 01:19:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1173,6 +1173,8 @@ _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
return false;
if (!equal(a->args, b->args))
return false;
if (a->is_local != b->is_local)
return false;
return true;
}

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.315 2002/05/13 17:45:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.316 2002/05/17 01:19:17 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -128,6 +128,7 @@ static void doNegateFloat(Value *v);
PrivTarget *privtarget;
InsertStmt *istmt;
VariableSetStmt *vsetstmt;
}
%type <node> stmt, schema_stmt,
@ -246,6 +247,8 @@ static void doNegateFloat(Value *v);
%type <istmt> insert_rest
%type <vsetstmt> set_rest
%type <node> OptTableElement, ConstraintElem
%type <node> columnDef
%type <defelt> def_elem
@ -563,12 +566,12 @@ AlterUserStmt: ALTER USER UserId OptUserList
;
AlterUserSetStmt: ALTER USER UserId VariableSetStmt
AlterUserSetStmt: ALTER USER UserId SET set_rest
{
AlterUserSetStmt *n = makeNode(AlterUserSetStmt);
n->user = $3;
n->variable = ((VariableSetStmt *)$4)->name;
n->value = ((VariableSetStmt *)$4)->args;
n->variable = $5->name;
n->value = $5->args;
$$ = (Node *)n;
}
| ALTER USER UserId VariableResetStmt
@ -576,7 +579,7 @@ AlterUserSetStmt: ALTER USER UserId VariableSetStmt
AlterUserSetStmt *n = makeNode(AlterUserSetStmt);
n->user = $3;
n->variable = ((VariableResetStmt *)$4)->name;
n->value = NULL;
n->value = NIL;
$$ = (Node *)n;
}
;
@ -834,63 +837,83 @@ schema_stmt: CreateStmt
*
*****************************************************************************/
VariableSetStmt: SET ColId TO var_list_or_default
VariableSetStmt: SET set_rest
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = $2;
n->args = $4;
VariableSetStmt *n = $2;
n->is_local = false;
$$ = (Node *) n;
}
| SET ColId '=' var_list_or_default
| SET LOCAL set_rest
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = $2;
n->args = $4;
VariableSetStmt *n = $3;
n->is_local = true;
$$ = (Node *) n;
}
| SET TIME ZONE zone_value
| SET SESSION set_rest
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "timezone";
if ($4 != NULL)
n->args = makeList1($4);
VariableSetStmt *n = $3;
n->is_local = false;
$$ = (Node *) n;
}
| SET TRANSACTION ISOLATION LEVEL opt_level
;
set_rest: ColId TO var_list_or_default
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "XactIsoLevel";
n->args = makeList1(makeStringConst($5, NULL));
$$ = (Node *) n;
n->name = $1;
n->args = $3;
$$ = n;
}
| SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
| ColId '=' var_list_or_default
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "default_transaction_isolation";
n->args = makeList1(makeStringConst($8, NULL));
$$ = (Node *) n;
n->name = $1;
n->args = $3;
$$ = n;
}
| SET NAMES opt_encoding
| TIME ZONE zone_value
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "client_encoding";
n->name = "timezone";
if ($3 != NULL)
n->args = makeList1(makeStringConst($3, NULL));
$$ = (Node *) n;
n->args = makeList1($3);
$$ = n;
}
| SET SESSION AUTHORIZATION ColId_or_Sconst
| TRANSACTION ISOLATION LEVEL opt_level
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "TRANSACTION ISOLATION LEVEL";
n->args = makeList1(makeStringConst($4, NULL));
$$ = n;
}
| SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "default_transaction_isolation";
n->args = makeList1(makeStringConst($7, NULL));
$$ = n;
}
| NAMES opt_encoding
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "client_encoding";
if ($2 != NULL)
n->args = makeList1(makeStringConst($2, NULL));
$$ = n;
}
| SESSION AUTHORIZATION ColId_or_Sconst
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "session_authorization";
n->args = makeList1(makeStringConst($4, NULL));
$$ = (Node *) n;
n->args = makeList1(makeStringConst($3, NULL));
$$ = n;
}
| SET SESSION AUTHORIZATION DEFAULT
| SESSION AUTHORIZATION DEFAULT
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "session_authorization";
n->args = NIL;
$$ = (Node *) n;
$$ = n;
}
;
@ -926,10 +949,10 @@ opt_boolean: TRUE_P { $$ = "true"; }
/* Timezone values can be:
* - a string such as 'pst8pdt'
* - a column identifier such as "pst8pdt"
* - an identifier such as "pst8pdt"
* - an integer or floating point number
* - a time interval per SQL99
* ConstInterval and ColId give shift/reduce errors,
* ColId gives reduce/reduce errors against ConstInterval and LOCAL,
* so use IDENT and reject anything which is a reserved word.
*/
zone_value: Sconst
@ -988,25 +1011,31 @@ ColId_or_Sconst: ColId { $$ = $1; }
VariableShowStmt: SHOW ColId
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = $2;
n->name = $2;
$$ = (Node *) n;
}
| SHOW TIME ZONE
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "timezone";
$$ = (Node *) n;
}
| SHOW ALL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "all";
n->name = "timezone";
$$ = (Node *) n;
}
| SHOW TRANSACTION ISOLATION LEVEL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "XactIsoLevel";
n->name = "TRANSACTION ISOLATION LEVEL";
$$ = (Node *) n;
}
| SHOW SESSION AUTHORIZATION
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "session_authorization";
$$ = (Node *) n;
}
| SHOW ALL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "all";
$$ = (Node *) n;
}
;
@ -1014,19 +1043,19 @@ VariableShowStmt: SHOW ColId
VariableResetStmt: RESET ColId
{
VariableResetStmt *n = makeNode(VariableResetStmt);
n->name = $2;
n->name = $2;
$$ = (Node *) n;
}
| RESET TIME ZONE
{
VariableResetStmt *n = makeNode(VariableResetStmt);
n->name = "timezone";
n->name = "timezone";
$$ = (Node *) n;
}
| RESET TRANSACTION ISOLATION LEVEL
{
VariableResetStmt *n = makeNode(VariableResetStmt);
n->name = "XactIsoLevel";
n->name = "TRANSACTION ISOLATION LEVEL";
$$ = (Node *) n;
}
| RESET SESSION AUTHORIZATION
@ -1038,7 +1067,7 @@ VariableResetStmt: RESET ColId
| RESET ALL
{
VariableResetStmt *n = makeNode(VariableResetStmt);
n->name = "all";
n->name = "all";
$$ = (Node *) n;
}
;
@ -3329,12 +3358,12 @@ opt_equal: '=' { $$ = TRUE; }
*
*****************************************************************************/
AlterDatabaseSetStmt: ALTER DATABASE database_name VariableSetStmt
AlterDatabaseSetStmt: ALTER DATABASE database_name SET set_rest
{
AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt);
n->dbname = $3;
n->variable = ((VariableSetStmt *)$4)->name;
n->value = ((VariableSetStmt *)$4)->args;
n->variable = $5->name;
n->value = $5->args;
$$ = (Node *)n;
}
| ALTER DATABASE database_name VariableResetStmt
@ -3342,7 +3371,7 @@ AlterDatabaseSetStmt: ALTER DATABASE database_name VariableSetStmt
AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt);
n->dbname = $3;
n->variable = ((VariableResetStmt *)$4)->name;
n->value = NULL;
n->value = NIL;
$$ = (Node *)n;
}
;

View File

@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.273 2002/05/05 00:03:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.274 2002/05/17 01:19:17 tgl Exp $
*
* NOTES
*
@ -404,12 +404,7 @@ PostmasterMain(int argc, char *argv[])
/*
* Options setup
*/
ResetAllOptions(true);
/* PGPORT environment variable, if set, overrides GUC setting */
if (getenv("PGPORT"))
SetConfigOption("port", getenv("PGPORT"),
PGC_POSTMASTER, PGC_S_ARGV/*sortof*/);
InitializeGUCOptions();
potential_DataDir = getenv("PGDATA"); /* default value */
@ -443,8 +438,8 @@ PostmasterMain(int argc, char *argv[])
/* Turn on debugging for the postmaster. */
char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
sprintf(debugstr, "debug%s", optarg);
/* We use PGC_S_SESSION because we will reset in backend */
SetConfigOption("server_min_messages", debugstr, PGC_POSTMASTER, PGC_S_SESSION);
SetConfigOption("server_min_messages", debugstr,
PGC_POSTMASTER, PGC_S_ARGV);
pfree(debugstr);
break;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.264 2002/05/10 20:22:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.265 2002/05/17 01:19:18 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -37,7 +37,6 @@
#include "access/xlog.h"
#include "commands/async.h"
#include "commands/trigger.h"
#include "commands/variable.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "libpq/pqsignal.h"
@ -1184,13 +1183,10 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
ResetAllOptions(true);
InitializeGUCOptions();
potential_DataDir = getenv("PGDATA");
}
/* Check for PGDATESTYLE environment variable */
set_default_datestyle();
/* ----------------
* parse command line arguments
*
@ -1273,9 +1269,10 @@ PostgresMain(int argc, char *argv[], const char *username)
else
/*
* -d 0 allows user to prevent postmaster debug from
* propogating to backend.
* propagating to backend.
*/
SetConfigOption("server_min_messages", "notice", PGC_POSTMASTER, PGC_S_ARGV);
SetConfigOption("server_min_messages", "notice",
ctx, gucsource);
}
break;
@ -1292,7 +1289,7 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* Use european date formats.
*/
EuroDates = true;
SetConfigOption("datestyle", "euro", ctx, gucsource);
break;
case 'F':
@ -1691,7 +1688,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.264 $ $Date: 2002/05/10 20:22:13 $\n");
puts("$Revision: 1.265 $ $Date: 2002/05/17 01:19:18 $\n");
}
/*

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.153 2002/04/30 01:26:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.154 2002/05/17 01:19:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -36,7 +36,6 @@
#include "commands/trigger.h"
#include "commands/user.h"
#include "commands/vacuum.h"
#include "commands/variable.h"
#include "commands/view.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
@ -48,6 +47,7 @@
#include "rewrite/rewriteRemove.h"
#include "tcop/utility.h"
#include "utils/acl.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "access/xlog.h"
@ -718,7 +718,7 @@ ProcessUtility(Node *parsetree,
{
VariableSetStmt *n = (VariableSetStmt *) parsetree;
SetPGVariable(n->name, n->args);
SetPGVariable(n->name, n->args, n->is_local);
}
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.89 2002/04/21 19:48:12 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.90 2002/05/17 01:19:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -3571,11 +3571,17 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
} /* EncodeInterval() */
void
ClearDateCache(bool dummy)
/* GUC assign_hook for australian_timezones */
bool
ClearDateCache(bool newval, bool doit, bool interactive)
{
int i;
for (i = 0; i < MAXDATEFIELDS; i++)
datecache[i] = NULL;
if (doit)
{
for (i = 0; i < MAXDATEFIELDS; i++)
datecache[i] = NULL;
}
return true;
}

View File

@ -2,7 +2,7 @@
*
* PostgreSQL locale utilities
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.16 2002/04/03 05:39:31 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.17 2002/05/17 01:19:18 tgl Exp $
*
* Portions Copyright (c) 2002, PostgreSQL Global Development Group
*
@ -10,89 +10,73 @@
*/
#include "postgres.h"
#include "utils/pg_locale.h"
#include <locale.h>
#include "utils/pg_locale.h"
/* GUC storage area */
char * locale_messages;
char * locale_monetary;
char * locale_numeric;
char * locale_time;
char *locale_messages;
char *locale_monetary;
char *locale_numeric;
char *locale_time;
/* GUC parse hooks */
bool locale_messages_check(const char *proposed)
{
#ifdef LC_MESSAGES
return chklocale(LC_MESSAGES, proposed);
#else
/* We return true here so LC_MESSAGES can be set in the
configuration file on every system. */
return true;
#endif
}
bool locale_monetary_check(const char *proposed)
{
return chklocale(LC_MONETARY, proposed);
}
bool locale_numeric_check(const char *proposed)
{
return chklocale(LC_NUMERIC, proposed);
}
bool locale_time_check(const char *proposed)
{
return chklocale(LC_TIME, proposed);
}
/* GUC assign hooks */
void locale_messages_assign(const char *value)
static const char *
locale_xxx_assign(int category, const char *value, bool doit, bool interactive)
{
if (doit)
{
if (!setlocale(category, value))
return NULL;
}
else
{
char *save;
save = setlocale(category, NULL);
if (!save)
return NULL;
if (!setlocale(category, value))
return NULL;
setlocale(category, save);
}
return value;
}
const char *
locale_messages_assign(const char *value, bool doit, bool interactive)
{
/* LC_MESSAGES category does not exist everywhere, but accept it anyway */
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, value);
return locale_xxx_assign(LC_MESSAGES, value, doit, interactive);
#else
return value;
#endif
}
void locale_monetary_assign(const char *value)
const char *
locale_monetary_assign(const char *value, bool doit, bool interactive)
{
setlocale(LC_MONETARY, value);
return locale_xxx_assign(LC_MONETARY, value, doit, interactive);
}
void locale_numeric_assign(const char *value)
const char *
locale_numeric_assign(const char *value, bool doit, bool interactive)
{
setlocale(LC_NUMERIC, value);
return locale_xxx_assign(LC_NUMERIC, value, doit, interactive);
}
void locale_time_assign(const char *value)
const char *
locale_time_assign(const char *value, bool doit, bool interactive)
{
setlocale(LC_TIME, value);
}
/*
* Returns true if the proposed string represents a valid locale of
* the given category. This is probably pretty slow, but it's not
* called in critical places.
*/
bool
chklocale(int category, const char *proposed)
{
char *save;
save = setlocale(category, NULL);
if (!save)
return false;
if (!setlocale(category, proposed))
return false;
setlocale(category, save);
return true;
return locale_xxx_assign(LC_TIME, value, doit, interactive);
}
@ -123,7 +107,6 @@ lc_collate_is_c(void)
}
/*
* Return the POSIX lconv struct (contains number/money formatting
* information) with locale information for all categories.
@ -131,10 +114,11 @@ lc_collate_is_c(void)
struct lconv *
PGLC_localeconv(void)
{
struct lconv *extlconv;
static bool CurrentLocaleConvValid = false;
static struct lconv CurrentLocaleConv;
struct lconv *extlconv;
/* Did we do it already? */
if (CurrentLocaleConvValid)
return &CurrentLocaleConv;

View File

@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.104 2002/05/12 23:43:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.105 2002/05/17 01:19:18 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -2576,27 +2576,33 @@ quote_identifier(const char *ident)
* and contains only lowercase letters, digits, and underscores, *and* is
* not any SQL keyword. Otherwise, supply quotes.
*/
int nquotes = 0;
bool safe;
const char *ptr;
char *result;
char *optr;
/*
* would like to use <ctype.h> macros here, but they might yield
* unwanted locale-specific results...
*/
safe = ((ident[0] >= 'a' && ident[0] <= 'z') || ident[0] == '_');
if (safe)
for (ptr = ident; *ptr; ptr++)
{
const char *ptr;
char ch = *ptr;
for (ptr = ident + 1; *ptr; ptr++)
if ((ch >= 'a' && ch <= 'z') ||
(ch >= '0' && ch <= '9') ||
(ch == '_'))
{
char ch = *ptr;
safe = ((ch >= 'a' && ch <= 'z') ||
(ch >= '0' && ch <= '9') ||
(ch == '_'));
if (!safe)
break;
/* okay */
}
else
{
safe = false;
if (ch == '"')
nquotes++;
}
}
@ -2618,8 +2624,21 @@ quote_identifier(const char *ident)
if (safe)
return ident; /* no change needed */
result = (char *) palloc(strlen(ident) + 2 + 1);
sprintf(result, "\"%s\"", ident);
result = (char *) palloc(strlen(ident) + nquotes + 2 + 1);
optr = result;
*optr++ = '"';
for (ptr = ident; *ptr; ptr++)
{
char ch = *ptr;
if (ch == '"')
*optr++ = '"';
*optr++ = ch;
}
*optr++ = '"';
*optr = '\0';
return result;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.97 2002/05/05 00:03:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.98 2002/05/17 01:19:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -841,105 +841,68 @@ elog_message_prefix(int lev)
/*
* GUC support routines
*/
bool
check_server_min_messages(const char *lev)
const char *
assign_server_min_messages(const char *newval,
bool doit, bool interactive)
{
if (strcasecmp(lev, "debug") == 0 ||
strcasecmp(lev, "debug5") == 0 ||
strcasecmp(lev, "debug4") == 0 ||
strcasecmp(lev, "debug3") == 0 ||
strcasecmp(lev, "debug2") == 0 ||
strcasecmp(lev, "debug1") == 0 ||
strcasecmp(lev, "info") == 0 ||
strcasecmp(lev, "notice") == 0 ||
strcasecmp(lev, "warning") == 0 ||
strcasecmp(lev, "error") == 0 ||
strcasecmp(lev, "log") == 0 ||
strcasecmp(lev, "fatal") == 0 ||
strcasecmp(lev, "panic") == 0)
return true;
return false;
}
void
assign_server_min_messages(const char *lev)
{
if (strcasecmp(lev, "debug") == 0)
server_min_messages = DEBUG5;
else if (strcasecmp(lev, "debug5") == 0)
server_min_messages = DEBUG5;
else if (strcasecmp(lev, "debug4") == 0)
server_min_messages = DEBUG4;
else if (strcasecmp(lev, "debug3") == 0)
server_min_messages = DEBUG3;
else if (strcasecmp(lev, "debug2") == 0)
server_min_messages = DEBUG2;
else if (strcasecmp(lev, "debug1") == 0)
server_min_messages = DEBUG1;
else if (strcasecmp(lev, "info") == 0)
server_min_messages = INFO;
else if (strcasecmp(lev, "notice") == 0)
server_min_messages = NOTICE;
else if (strcasecmp(lev, "warning") == 0)
server_min_messages = WARNING;
else if (strcasecmp(lev, "error") == 0)
server_min_messages = ERROR;
else if (strcasecmp(lev, "log") == 0)
server_min_messages = LOG;
else if (strcasecmp(lev, "fatal") == 0)
server_min_messages = FATAL;
else if (strcasecmp(lev, "panic") == 0)
server_min_messages = PANIC;
if (strcasecmp(newval, "debug") == 0)
{ if (doit) server_min_messages = DEBUG1; }
else if (strcasecmp(newval, "debug5") == 0)
{ if (doit) server_min_messages = DEBUG5; }
else if (strcasecmp(newval, "debug4") == 0)
{ if (doit) server_min_messages = DEBUG4; }
else if (strcasecmp(newval, "debug3") == 0)
{ if (doit) server_min_messages = DEBUG3; }
else if (strcasecmp(newval, "debug2") == 0)
{ if (doit) server_min_messages = DEBUG2; }
else if (strcasecmp(newval, "debug1") == 0)
{ if (doit) server_min_messages = DEBUG1; }
else if (strcasecmp(newval, "info") == 0)
{ if (doit) server_min_messages = INFO; }
else if (strcasecmp(newval, "notice") == 0)
{ if (doit) server_min_messages = NOTICE; }
else if (strcasecmp(newval, "warning") == 0)
{ if (doit) server_min_messages = WARNING; }
else if (strcasecmp(newval, "error") == 0)
{ if (doit) server_min_messages = ERROR; }
else if (strcasecmp(newval, "log") == 0)
{ if (doit) server_min_messages = LOG; }
else if (strcasecmp(newval, "fatal") == 0)
{ if (doit) server_min_messages = FATAL; }
else if (strcasecmp(newval, "panic") == 0)
{ if (doit) server_min_messages = PANIC; }
else
/* Can't get here unless guc.c screwed up */
elog(ERROR, "bogus server_min_messages %s", lev);
return NULL; /* fail */
return newval; /* OK */
}
bool
check_client_min_messages(const char *lev)
const char *
assign_client_min_messages(const char *newval,
bool doit, bool interactive)
{
if (strcasecmp(lev, "debug") == 0 ||
strcasecmp(lev, "debug5") == 0 ||
strcasecmp(lev, "debug4") == 0 ||
strcasecmp(lev, "debug3") == 0 ||
strcasecmp(lev, "debug2") == 0 ||
strcasecmp(lev, "debug1") == 0 ||
strcasecmp(lev, "log") == 0 ||
strcasecmp(lev, "info") == 0 ||
strcasecmp(lev, "notice") == 0 ||
strcasecmp(lev, "warning") == 0 ||
strcasecmp(lev, "error") == 0)
return true;
return false;
}
void
assign_client_min_messages(const char *lev)
{
if (strcasecmp(lev, "debug") == 0)
client_min_messages = DEBUG5;
else if (strcasecmp(lev, "debug5") == 0)
client_min_messages = DEBUG5;
else if (strcasecmp(lev, "debug4") == 0)
client_min_messages = DEBUG4;
else if (strcasecmp(lev, "debug3") == 0)
client_min_messages = DEBUG3;
else if (strcasecmp(lev, "debug2") == 0)
client_min_messages = DEBUG2;
else if (strcasecmp(lev, "debug1") == 0)
client_min_messages = DEBUG1;
else if (strcasecmp(lev, "log") == 0)
client_min_messages = LOG;
else if (strcasecmp(lev, "info") == 0)
client_min_messages = INFO;
else if (strcasecmp(lev, "notice") == 0)
client_min_messages = NOTICE;
else if (strcasecmp(lev, "warning") == 0)
client_min_messages = WARNING;
else if (strcasecmp(lev, "error") == 0)
client_min_messages = ERROR;
if (strcasecmp(newval, "debug") == 0)
{ if (doit) client_min_messages = DEBUG1; }
else if (strcasecmp(newval, "debug5") == 0)
{ if (doit) client_min_messages = DEBUG5; }
else if (strcasecmp(newval, "debug4") == 0)
{ if (doit) client_min_messages = DEBUG4; }
else if (strcasecmp(newval, "debug3") == 0)
{ if (doit) client_min_messages = DEBUG3; }
else if (strcasecmp(newval, "debug2") == 0)
{ if (doit) client_min_messages = DEBUG2; }
else if (strcasecmp(newval, "debug1") == 0)
{ if (doit) client_min_messages = DEBUG1; }
else if (strcasecmp(newval, "log") == 0)
{ if (doit) client_min_messages = LOG; }
else if (strcasecmp(newval, "info") == 0)
{ if (doit) client_min_messages = INFO; }
else if (strcasecmp(newval, "notice") == 0)
{ if (doit) client_min_messages = NOTICE; }
else if (strcasecmp(newval, "warning") == 0)
{ if (doit) client_min_messages = WARNING; }
else if (strcasecmp(newval, "error") == 0)
{ if (doit) client_min_messages = ERROR; }
else
/* Can't get here unless guc.c screwed up */
elog(ERROR, "bogus client_min_messages %s", lev);
return NULL; /* fail */
return newval; /* OK */
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.90 2002/05/06 19:47:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.91 2002/05/17 01:19:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -614,6 +614,9 @@ InitializeSessionUserId(const char *username)
SetSessionUserId(usesysid); /* sets CurrentUserId too */
/* Record username as a config option too */
SetConfigOption("session_authorization", username,
PGC_BACKEND, PGC_S_OVERRIDE);
/*
* Set up user-specific configuration variables. This is a good
@ -653,23 +656,16 @@ InitializeSessionUserIdStandalone(void)
* Change session auth ID while running
*
* Only a superuser may set auth ID to something other than himself.
*
* username == NULL implies reset to default (AuthenticatedUserId).
*/
void
SetSessionAuthorization(const char *username)
SetSessionAuthorization(Oid userid)
{
Oid userid;
/* Must have authenticated already, else can't make permission check */
AssertState(OidIsValid(AuthenticatedUserId));
if (username == NULL)
userid = AuthenticatedUserId;
else
{
userid = get_usesysid(username);
if (userid != AuthenticatedUserId &&
!AuthenticatedUserIsSuperuser)
elog(ERROR, "permission denied");
}
if (userid != AuthenticatedUserId &&
!AuthenticatedUserIsSuperuser)
elog(ERROR, "permission denied");
SetSessionUserId(userid);
SetUserId(userid);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.104 2002/05/05 00:03:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.105 2002/05/17 01:19:18 tgl Exp $
*
*
*-------------------------------------------------------------------------
@ -28,7 +28,6 @@
#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
#include "commands/trigger.h"
#include "commands/variable.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "storage/backendid.h"
@ -132,6 +131,9 @@ ReverifyMyDatabase(const char *name)
*/
#ifdef MULTIBYTE
SetDatabaseEncoding(dbform->encoding);
/* If we have no other source of client_encoding, use server encoding */
SetConfigOption("client_encoding", GetDatabaseEncodingName(),
PGC_BACKEND, PGC_S_DEFAULT);
#else
if (dbform->encoding != PG_SQL_ASCII)
elog(FATAL, "database was initialized with MULTIBYTE encoding %d,\n\tbut the backend was compiled without multibyte support.\n\tlooks like you need to initdb or recompile.",
@ -388,11 +390,6 @@ InitPostgres(const char *dbname, const char *username)
/* set default namespace search path */
InitializeSearchPath();
#ifdef MULTIBYTE
/* set default client encoding --- uses info from ReverifyMyDatabase */
set_default_client_encoding();
#endif
/*
* Set up process-exit callback to do pre-shutdown cleanup. This should
* be last because we want shmem_exit to call this routine before the exit

View File

@ -0,0 +1,136 @@
$Header: /cvsroot/pgsql/src/backend/utils/misc/README,v 1.1 2002/05/17 01:19:18 tgl Exp $
GUC IMPLEMENTATION NOTES
The GUC (Grand Unified Configuration) module implements configuration
variables of multiple types (currently boolean, int, float, and string).
Variable settings can come from various places, with a priority ordering
determining which setting is used.
PER-VARIABLE HOOKS
Each variable known to GUC can optionally have an assign_hook and/or
a show_hook to provide customized behavior. Assign hooks are used to
perform validity checking on variable values (above and beyond what
GUC can do). They are also used to update any derived state that needs
to change when a GUC variable is set. Show hooks are used to modify
the default SHOW display for a variable.
If an assign_hook is provided, it points to a function of the signature
bool assign_hook(newvalue, bool doit, bool interactive)
where the type of 'newvalue' matches the kind of variable. This function
is called immediately before actually setting the variable's value (so it
can look at the actual variable to determine the old value). If the
function returns "true" then the assignment is completed; if it returns
"false" then newvalue is considered invalid and the assignment is not
performed. If "doit" is false then the function should simply check
validity of newvalue and not change any derived state. "interactive" is
true when we are performing a SET command; in this case it is okay for the
assign_hook to raise an error via elog(). If the function returns false
for an interactive assignment then guc.c will report a generic "invalid
value" error message. (An internal elog() in an assign_hook is only
needed if you want to generate a specialized error message.) But when
"interactive" is false we are reading a non-interactive option source,
such as postgresql.conf. In this case the assign_hook should *not* elog
but should just return false if it doesn't like the newvalue. (An
elog(LOG) call would be acceptable if you feel a need for a custom
complaint in this situation.)
For string variables, the signature for assign hooks is a bit different:
const char *assign_hook(const char *newvalue,
bool doit,
bool interactive)
The meanings of the parameters are the same as for the other types of GUC
variables, but the return value is handled differently:
NULL --- assignment fails (like returning false for other datatypes)
newvalue --- assignment succeeds, assign the newvalue as-is
malloc'd (not palloc'd!!!) string --- assign that value instead
The third choice is allowed in case the assign_hook wants to return a
"canonical" version of the new value. For example, the assign_hook for
datestyle always returns a string that includes both basic datestyle and
us/euro option, although the input might have specified only one.
If a show_hook is provided, it points to a function of the signature
const char *show_hook(void)
This hook allows variable-specific computation of the value displayed
by SHOW.
SAVING/RESTORING GUC VARIABLE VALUES
Prior values of configuration variables must be remembered in order to
deal with three special cases: RESET (a/k/a SET TO DEFAULT), rollback of
SET on transaction abort, and rollback of SET LOCAL at transaction end
(either commit or abort). RESET is defined as selecting the value that
would be effective had there never been any SET commands in the current
session.
To handle these cases we must keep track of as many as four distinct
values for each variable. They are:
* actual variable contents always the current effective value
* reset_value the value to use for RESET
* session_value the "committed" setting for the session
* tentative_value the uncommitted result of SET
During initialization we set the first three of these (actual, reset_value,
and session_value) based on whichever non-interactive source has the
highest priority. All three will have the same value.
A SET LOCAL command sets the actual variable (and nothing else). At
transaction end, the session_value is used to restore the actual variable
to its pre-transaction value.
A SET (or SET SESSION) command sets the actual variable, and if no error,
then sets the tentative_value. If the transaction commits, the
tentative_value is assigned to the session_value and the actual variable
(which could by now be different, if the SET was followed by SET LOCAL).
If the transaction aborts, the tentative_value is discarded and the
actual variable is restored from the session_value.
RESET is executed like a SET, but using the reset_value as the desired new
value. (We do not provide a RESET LOCAL command, but SET LOCAL TO DEFAULT
has the same behavior that RESET LOCAL would.) The source associated with
the reset_value also becomes associated with the actual and session values.
If SIGHUP is received, the GUC code rereads the postgresql.conf
configuration file (this does not happen in the signal handler, but at
next return to main loop; note that it can be executed while within a
transaction). New values from postgresql.conf are assigned to actual
variable, reset_value, and session_value, but only if each of these has a
current source priority <= PGC_S_FILE. (It is thus possible for
reset_value to track the config-file setting even if there is currently
a different interactive value of the actual variable.)
Note that tentative_value is unused and undefined except between a SET
command and the end of the transaction. Also notice that we must track
the source associated with each of the four values.
The assign_hook and show_hook routines work only with the actual variable,
and are not directly aware of the additional values maintained by GUC.
This is not a problem for normal usage, since we can assign first to the
actual variable and then (if that succeeds) to the additional values as
needed. However, for SIGHUP rereads we may not want to assign to the
actual variable. Our procedure in that case is to call the assign_hook
with doit = false so that the value is validated, but no derived state is
changed.
STRING MEMORY HANDLING
String option values are allocated with strdup, not with the
pstrdup/palloc mechanisms. We would need to keep them in a permanent
context anyway, and strdup gives us more control over handling
out-of-memory failures.
We allow a variable's actual value, reset_val, session_val, and
tentative_val to point at the same storage. This makes it slightly harder
to free space (must test that the value to be freed isn't equal to any of
the other three pointers). The main advantage is that we never need to
strdup during transaction commit/abort, so cannot cause an out-of-memory
failure there.

View File

@ -4,7 +4,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.11 2002/03/02 21:39:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.12 2002/05/17 01:19:18 tgl Exp $
*/
%{
@ -168,7 +168,7 @@ ProcessConfigFile(GucContext context)
head = tail = NULL;
opt_name = opt_value = NULL;
while((token = yylex()))
while ((token = yylex()))
switch(parse_state)
{
case 0: /* no previous input */
@ -188,23 +188,22 @@ ProcessConfigFile(GucContext context)
token = yylex();
if (token != GUC_ID && token != GUC_STRING &&
token != GUC_INTEGER && token != GUC_REAL &&
token != GUC_UNQUOTED_STRING)
token != GUC_INTEGER && token != GUC_REAL &&
token != GUC_UNQUOTED_STRING)
goto parse_error;
opt_value = strdup(yytext);
if (opt_value == NULL)
goto out_of_memory;
if (token == GUC_STRING)
{
/* remove the beginning and ending quote/apostrophe */
/* first: shift the whole shooting match down one
character */
memmove(opt_value,opt_value+1,strlen(opt_value)-1);
/* second: null out the 2 characters we shifted */
opt_value[strlen(opt_value)-2]='\0';
/* do the escape thing. free()'s the strdup above */
opt_value=GUC_scanstr(opt_value);
}
if (token == GUC_STRING)
{
/* remove the beginning and ending quote/apostrophe */
/* first: shift the whole thing down one character */
memmove(opt_value,opt_value+1,strlen(opt_value)-1);
/* second: null out the 2 characters we shifted */
opt_value[strlen(opt_value)-2]='\0';
/* do the escape thing. free()'s the strdup above */
opt_value=GUC_scanstr(opt_value);
}
parse_state = 2;
break;
@ -241,14 +240,14 @@ ProcessConfigFile(GucContext context)
for(item = head; item; item=item->next)
{
if (!set_config_option(item->name, item->value, context,
false, PGC_S_INFINITY))
PGC_S_FILE, false, false))
goto cleanup_exit;
}
/* If we got here all the options parsed okay. */
for(item = head; item; item=item->next)
set_config_option(item->name, item->value, context,
true, PGC_S_FILE);
PGC_S_FILE, false, true);
cleanup_exit:
free_name_value_list(head);

File diff suppressed because it is too large Load Diff

View File

@ -192,7 +192,10 @@
#
#dynamic_library_path = '$libdir'
#search_path = '$user,public'
#datestyle = 'iso, us'
#timezone = unknown # actually, defaults to TZ environment setting
#australian_timezones = false
#client_encoding = sql_ascii # actually, defaults to database encoding
#authentication_timeout = 60 # min 1, max 600
#deadlock_timeout = 1000
#default_transaction_isolation = 'read committed'

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: xlog.h,v 1.29 2002/03/15 19:20:36 tgl Exp $
* $Id: xlog.h,v 1.30 2002/05/17 01:19:19 tgl Exp $
*/
#ifndef XLOG_H
#define XLOG_H
@ -216,7 +216,7 @@ extern XLogRecPtr GetRedoRecPtr(void);
*/
extern XLogRecPtr GetUndoRecPtr(void);
extern bool check_xlog_sync_method(const char *method);
extern void assign_xlog_sync_method(const char *method);
extern const char *assign_xlog_sync_method(const char *method,
bool doit, bool interactive);
#endif /* XLOG_H */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: namespace.h,v 1.12 2002/05/01 23:06:41 tgl Exp $
* $Id: namespace.h,v 1.13 2002/05/17 01:19:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -75,8 +75,8 @@ extern bool isTempNamespace(Oid namespaceId);
/* stuff for search_path GUC variable */
extern char *namespace_search_path;
extern bool check_search_path(const char *proposed);
extern void assign_search_path(const char *newval);
extern const char *assign_search_path(const char *newval,
bool doit, bool interactive);
extern void InitializeSearchPath(void);
extern List *fetch_search_path(void);

View File

@ -1,18 +1,32 @@
/*
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements
* variable.h
* Routines for handling specialized SET variables.
*
* $Id: variable.h,v 1.17 2001/11/05 17:46:33 momjian Exp $
* $Id: variable.h,v 1.18 2002/05/17 01:19:19 tgl Exp $
*
*/
#ifndef VARIABLE_H
#define VARIABLE_H
extern void SetPGVariable(const char *name, List *args);
extern void GetPGVariable(const char *name);
extern void ResetPGVariable(const char *name);
extern void set_default_datestyle(void);
extern void set_default_client_encoding(void);
extern const char *assign_datestyle(const char *value,
bool doit, bool interactive);
extern const char *show_datestyle(void);
extern const char *assign_timezone(const char *value,
bool doit, bool interactive);
extern const char *show_timezone(void);
extern const char *assign_XactIsoLevel(const char *value,
bool doit, bool interactive);
extern const char *show_XactIsoLevel(void);
extern bool assign_random_seed(double value,
bool doit, bool interactive);
extern const char *show_random_seed(void);
extern const char *assign_client_encoding(const char *value,
bool doit, bool interactive);
extern const char *assign_server_encoding(const char *value,
bool doit, bool interactive);
extern const char *show_server_encoding(void);
extern const char *assign_session_authorization(const char *value,
bool doit, bool interactive);
extern const char *show_session_authorization(void);
#endif /* VARIABLE_H */

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.103 2002/05/05 00:03:29 tgl Exp $
* $Id: miscadmin.h,v 1.104 2002/05/17 01:19:19 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
@ -211,7 +211,7 @@ extern Oid GetSessionUserId(void);
extern void SetSessionUserId(Oid userid);
extern void InitializeSessionUserId(const char *username);
extern void InitializeSessionUserIdStandalone(void);
extern void SetSessionAuthorization(const char *username);
extern void SetSessionAuthorization(Oid userid);
extern void SetDataDir(const char *dir);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.176 2002/05/12 20:10:04 tgl Exp $
* $Id: parsenodes.h,v 1.177 2002/05/17 01:19:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1439,6 +1439,7 @@ typedef struct VariableSetStmt
NodeTag type;
char *name;
List *args;
bool is_local; /* SET LOCAL */
} VariableSetStmt;
/* ----------------------

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: datetime.h,v 1.29 2002/04/21 19:48:31 thomas Exp $
* $Id: datetime.h,v 1.30 2002/05/17 01:19:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -289,7 +289,7 @@ extern int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
extern int DecodeSpecial(int field, char *lowtoken, int *val);
extern int DecodeUnits(int field, char *lowtoken, int *val);
extern void ClearDateCache(bool);
extern bool ClearDateCache(bool, bool, bool);
extern int j2day(int jd);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.36 2002/04/21 00:22:52 ishii Exp $
* $Id: elog.h,v 1.37 2002/05/17 01:19:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -60,9 +60,9 @@ __attribute__((format(printf, 2, 3)));
extern int DebugFileOpen(void);
extern bool check_server_min_messages(const char *lev);
extern void assign_server_min_messages(const char *lev);
extern bool check_client_min_messages(const char *lev);
extern void assign_client_min_messages(const char *lev);
extern const char *assign_server_min_messages(const char *newval,
bool doit, bool interactive);
extern const char *assign_client_min_messages(const char *newval,
bool doit, bool interactive);
#endif /* ELOG_H */

View File

@ -4,13 +4,15 @@
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
* $Id: guc.h,v 1.16 2002/03/24 04:31:09 tgl Exp $
* $Id: guc.h,v 1.17 2002/05/17 01:19:19 tgl Exp $
*/
#ifndef GUC_H
#define GUC_H
#include "nodes/pg_list.h"
#include "utils/array.h"
/*
* Certain options can only be set at certain times. The rules are
* like this:
@ -52,30 +54,45 @@ typedef enum
* The following type records the source of the current setting. A
* new setting can only take effect if the previous setting had the
* same or lower level. (E.g, changing the config file doesn't
* override the postmaster command line.)
* override the postmaster command line.) Tracking the source allows us
* to process sources in any convenient order without affecting results.
* Sources <= PGC_S_OVERRIDE will set the default used by RESET, as well
* as the current value.
*/
typedef enum
{
PGC_S_DEFAULT = 0, /* wired-in default */
PGC_S_FILE = 1, /* postgresql.conf */
PGC_S_ARGV = 2, /* postmaster command line */
PGC_S_DATABASE = 3, /* per-database setting */
PGC_S_USER = 4, /* per-user setting */
PGC_S_CLIENT = 5, /* from client (PGOPTIONS) */
PGC_S_SESSION = 6, /* SET command */
PGC_S_INFINITY = 100 /* can be used to avoid checks */
PGC_S_ENV_VAR = 1, /* postmaster environment variable */
PGC_S_FILE = 2, /* postgresql.conf */
PGC_S_ARGV = 3, /* postmaster command line */
PGC_S_DATABASE = 4, /* per-database setting */
PGC_S_USER = 5, /* per-user setting */
PGC_S_CLIENT = 6, /* from client (PGOPTIONS) */
PGC_S_OVERRIDE = 7, /* special case to forcibly set default */
PGC_S_SESSION = 8 /* SET command */
} GucSource;
extern void SetConfigOption(const char *name, const char *value,
GucContext context, GucSource source);
extern const char *GetConfigOption(const char *name);
extern const char *GetConfigOptionResetString(const char *name);
extern void ProcessConfigFile(GucContext context);
extern void ResetAllOptions(bool isStartup);
extern void InitializeGUCOptions(void);
extern void ResetAllOptions(void);
extern void AtEOXact_GUC(bool isCommit);
extern void ParseLongOption(const char *string, char **name, char **value);
extern bool set_config_option(const char *name, const char *value,
GucContext context, bool DoIt, GucSource source);
GucContext context, GucSource source,
bool isLocal, bool DoIt);
extern void ShowGUCConfigOption(const char *name);
extern void ShowAllGUCConfig(void);
extern void SetPGVariable(const char *name, List *args, bool is_local);
extern void GetPGVariable(const char *name);
extern void ResetPGVariable(const char *name);
extern char *flatten_set_variable_args(const char *name, List *args);
extern void ProcessGUCArray(ArrayType *array, GucSource source);
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);

View File

@ -2,7 +2,7 @@
*
* PostgreSQL locale utilities
*
* $Header: /cvsroot/pgsql/src/include/utils/pg_locale.h,v 1.12 2002/04/03 05:39:33 petere Exp $
* $Id: pg_locale.h,v 1.13 2002/05/17 01:19:19 tgl Exp $
*
* Copyright (c) 2002, PostgreSQL Global Development Group
*
@ -12,26 +12,23 @@
#ifndef _PG_LOCALE_
#define _PG_LOCALE_
#include "postgres.h"
#include <locale.h>
extern char * locale_messages;
extern char * locale_monetary;
extern char * locale_numeric;
extern char * locale_time;
extern char *locale_messages;
extern char *locale_monetary;
extern char *locale_numeric;
extern char *locale_time;
bool locale_messages_check(const char *proposed);
bool locale_monetary_check(const char *proposed);
bool locale_numeric_check(const char *proposed);
bool locale_time_check(const char *proposed);
extern const char *locale_messages_assign(const char *value,
bool doit, bool interactive);
extern const char *locale_monetary_assign(const char *value,
bool doit, bool interactive);
extern const char *locale_numeric_assign(const char *value,
bool doit, bool interactive);
extern const char *locale_time_assign(const char *value,
bool doit, bool interactive);
void locale_messages_assign(const char *value);
void locale_monetary_assign(const char *value);
void locale_numeric_assign(const char *value);
void locale_time_assign(const char *value);
bool chklocale(int category, const char *proposed);
bool lc_collate_is_c(void);
extern bool lc_collate_is_c(void);
/*
* Return the POSIX lconv struct (contains number/money formatting

View File

@ -12,7 +12,7 @@ import org.postgresql.util.*;
import org.postgresql.core.*;
/*
* $Id: Connection.java,v 1.46 2002/05/14 03:00:35 barry Exp $
* $Id: Connection.java,v 1.47 2002/05/17 01:19:19 tgl Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@ -951,7 +951,7 @@ public abstract class Connection
public int getTransactionIsolation() throws SQLException
{
clearWarnings();
ExecSQL("show xactisolevel");
ExecSQL("show transaction isolation level");
SQLWarning warning = getWarnings();
if (warning != null)