Second pass over run-time configuration system. Adjust priorities on some

option settings. Sort out SIGHUP vs BACKEND -- there is no total ordering
here, so make explicit checks. Add comments explaining all of this.
Removed permissions check on SHOW command.

Add examine_subclass to the game, rename to SQL_inheritance to fit the
official data model better. Adjust documentation.

Standalone backend needs to reset all options before it starts. To
facilitate that, have IsUnderPostmaster be set by the postmaster itself,
don't wait for the magic -p switch.

Also make sure that all environment variables and argv's survive
init_ps_display(). Use strdup where necessary.

Have initdb make configuration files (postgresql.conf, pg_hba.conf) mode
0600 -- having configuration files is no fun if you can't edit them.
This commit is contained in:
Peter Eisentraut 2000-06-22 22:31:24 +00:00
parent bc06269495
commit c446509565
13 changed files with 228 additions and 179 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.14 2000/06/14 13:12:52 thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.15 2000/06/22 22:31:15 petere Exp $
-->
<chapter id="advanced">
@ -116,22 +116,25 @@ SELECT name, altitude
support this <quote>ONLY</quote> notation.
</para>
<para>
Deprecated: In previous versions of postgres, the default was not to
get access to child classes. By experience this was found to be error
prone. Under the old syntax, to get the sub-classes you append "*"
to the table name. For example
<programlisting>
<note>
<title>Deprecated</title>
<para>
In previous versions of <productname>Postgres</productname>, the
default was not to get access to child tables. This was found to
be error prone and is also in violation of SQL. Under the old
syntax, to get the sub-classes you append "*" to the table name.
For example
<programlisting>
SELECT * from cities*;
</programlisting>
This old behaviour is still available by using a SET command:
<programlisting>
SET EXAMINE_SUBCLASS TO on;
</programlisting>
</para>
</programlisting>
To get the old behavior, the set configuration option
<literal>SQL_Inheritance</literal> to off, e.g.,
<programlisting>
SET SQL_Inheritance TO OFF;
</programlisting>
or add a line in your <filename>postgresql.conf</filename> file.
</para>
</note>
</sect1>
<sect1>

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.9 2000/06/14 13:12:52 thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.10 2000/06/22 22:31:15 petere Exp $
-->
<chapter id="inherit">
@ -96,19 +96,25 @@ CREATE TABLE capitals UNDER cities (
<command>UPDATE</command> and <command>DELETE</command> --
support this <quote>ONLY</quote> notation.
</para>
<para>
Deprecated: In previous versions of postgres, the default was not to
get access to child classes. By experience this was found to be error
prone. Under the old syntax, to get the sub-classes you append "*"
to the table name. For example
<programlisting>
SELECT * from cities*;
</programlisting>
This old behaviour is still available by using a SET command...
<programlisting>
SET EXAMINE_SUBCLASS TO on;
</programlisting>
</para>
<note>
<title>Deprecated</title>
<para>
In previous versions of <productname>Postgres</productname>, the
default was not to get access to child tables. This was found to
be error prone and is also in violation of SQL. Under the old
syntax, to get the sub-classes you append "*" to the table name.
For example
<programlisting>
SELECT * from cities*;
</programlisting>
To get the old behavior, the set configuration option
<literal>SQL_Inheritance</literal> to off, e.g.,
<programlisting>
SET SQL_Inheritance TO OFF;
</programlisting>
or add a line in your <filename>postgresql.conf</filename> file.
</para>
</note>
</chapter>
<!-- Keep this comment at the end of the file

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.29 2000/06/09 01:44:00 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.30 2000/06/22 22:31:16 petere Exp $
Postgres documentation
-->
@ -208,7 +208,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
This was previously the default result, and getting subclasses was
obtained by appending <command>*</command> to the table name.
The old behaviour is available via the command
<command>SET EXAMINE_SUBCLASS TO 'on';</command>
<command>SET SQL_Inheritance TO OFF;</command>
</para>
<para>

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.11 2000/06/18 21:24:51 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.12 2000/06/22 22:31:15 petere Exp $
-->
<Chapter Id="runtime">
@ -914,6 +914,23 @@ env PGOPTIONS='--geqo=off' psql
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SQL_INHERITANCE (<type>bool</type>)</term>
<listitem>
<para>
This controls the inheritance semantics, in particular whether
subtables are included into the consideration of various
commands by default. This was not the case in versions prior
to 7.1. If you need this behaviour you can set this variable
to off, but in the long run you are encouraged to change your
applications to use the <literal>ONLY</literal> keyword to
exclude subtables. See the SQL language reference and the
<citetitle>User's Guide</citetitle> for more information about
inheritance.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>

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.86 2000/06/17 23:41:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.87 2000/06/22 22:31:17 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -35,6 +35,7 @@
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/portal.h"
@ -248,8 +249,11 @@ BootstrapMain(int argc, char *argv[])
Quiet = false;
Noversion = false;
dbName = NULL;
DataDir = getenv("PGDATA"); /* Null if no PGDATA variable */
IsUnderPostmaster = false;
if (!IsUnderPostmaster)
{
ResetAllOptions();
DataDir = getenv("PGDATA"); /* Null if no PGDATA variable */
}
while ((flag = getopt(argc, argv, "D:dCQxpB:F")) != EOF)
{
@ -275,7 +279,7 @@ BootstrapMain(int argc, char *argv[])
xloginit = true;
break;
case 'p':
IsUnderPostmaster = true;
/* indicates fork from postmaster */
break;
case 'B':
NBuffers = atoi(optarg);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.37 2000/06/14 18:17:25 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.38 2000/06/22 22:31:17 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -49,12 +49,7 @@ static bool parse_XactIsoLevel(char *);
static bool parse_random_seed(char *);
static bool show_random_seed(void);
static bool reset_random_seed(void);
static bool parse_examine_subclass(char *);
static bool show_examine_subclass(void);
static bool reset_examine_subclass(void);
#define examine_subclass_default true
bool examine_subclass = examine_subclass_default;
/*
* get_token
@ -169,44 +164,6 @@ get_token(char **tok, char **val, char *str)
return str;
}
/*
*
* EXAMINE_SUBCLASS
*
*/
#define EXAMINE_SUBCLASS "EXAMINE_SUBCLASS"
static bool
parse_examine_subclass(char *value)
{
if (strcasecmp(value, "on") == 0)
examine_subclass = true;
else if (strcasecmp(value, "off") == 0)
examine_subclass = false;
else if (strcasecmp(value, "default") == 0)
examine_subclass = examine_subclass_default;
else
elog(ERROR, "Bad value for %s (%s)", EXAMINE_SUBCLASS, value);
return TRUE;
}
static bool
show_examine_subclass()
{
if (examine_subclass)
elog(NOTICE, "%s is ON", EXAMINE_SUBCLASS);
else
elog(NOTICE, "%s is OFF", EXAMINE_SUBCLASS);
return TRUE;
}
static bool
reset_examine_subclass(void)
{
examine_subclass = examine_subclass_default;
return TRUE;
}
/*
* DATE_STYLE
@ -571,7 +528,7 @@ void
SetPGVariable(const char *name, const char *value)
{
/*
* Special cases ought to be removed are handled separately
* Special cases ought to be removed and handled separately
* by TCOP
*/
if (strcasecmp(name, "datestyle")==0)
@ -588,8 +545,6 @@ SetPGVariable(const char *name, const char *value)
#endif
else if (strcasecmp(name, "random_seed")==0)
parse_random_seed(pstrdup(value));
else if (strcasecmp(name, "examine_subclass")==0)
parse_examine_subclass(pstrdup(value));
else
SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET);
}
@ -612,12 +567,10 @@ GetPGVariable(const char *name)
#endif
else if (strcasecmp(name, "random_seed")==0)
show_random_seed();
else if (strcasecmp(name, "examine_subclass")==0)
show_examine_subclass();
else
{
const char * val = GetConfigOption(name, superuser());
elog(NOTICE, "%s = %s", name, val);
const char * val = GetConfigOption(name);
elog(NOTICE, "%s is %s", name, val);
}
}
@ -638,8 +591,6 @@ ResetPGVariable(const char *name)
#endif
else if (strcasecmp(name, "random_seed")==0)
reset_random_seed();
else if (strcasecmp(name, "examine_subclass")==0)
reset_examine_subclass();
else
SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET);
}

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.173 2000/06/12 19:40:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.174 2000/06/22 22:31:18 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -49,7 +49,7 @@
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/numeric.h"
#include "commands/variable.h"
#include "utils/guc.h"
#ifdef MULTIBYTE
#include "miscadmin.h"
@ -884,7 +884,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'A';
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->def = $7;
$$ = (Node *)n;
}
@ -894,7 +894,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'T';
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->name = $7;
n->def = $8;
$$ = (Node *)n;
@ -905,7 +905,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
@ -916,7 +916,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'C';
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->def = $6;
$$ = (Node *)n;
}
@ -926,7 +926,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'X';
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
@ -2562,7 +2562,7 @@ RenameStmt: ALTER TABLE relation_name opt_inh_star
{
RenameStmt *n = makeNode(RenameStmt);
n->relname = $3;
n->inh = $4 || examine_subclass;
n->inh = $4 || SQL_inheritance;
n->column = $7;
n->newname = $9;
$$ = (Node *)n;
@ -3806,7 +3806,7 @@ relation_expr: relation_name
/* default inheritance */
$$ = makeNode(RelExpr);
$$->relname = $1;
$$->inh = examine_subclass;
$$->inh = SQL_inheritance;
}
| relation_name '*' %prec '='
{

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.148 2000/06/14 18:17:38 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.149 2000/06/22 22:31:20 petere Exp $
*
* NOTES
*
@ -364,6 +364,8 @@ PostmasterMain(int argc, char *argv[])
bool DataDirOK; /* We have a usable PGDATA value */
char original_extraoptions[MAXPGPATH];
IsUnderPostmaster = true; /* so that backends know this */
*original_extraoptions = '\0';
progname = argv[0];
@ -379,7 +381,8 @@ PostmasterMain(int argc, char *argv[])
ResetAllOptions();
MyProcPid = getpid();
DataDir = getenv("PGDATA"); /* default value */
if (getenv("PGDATA"))
DataDir = strdup(getenv("PGDATA")); /* default value */
if (getenv("PGPORT"))
PostPortName = atoi(getenv("PGPORT"));
@ -401,7 +404,11 @@ PostmasterMain(int argc, char *argv[])
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
{
if (opt == 'D')
DataDir = optarg;
{
if (DataDir)
free(DataDir);
DataDir = strdup(optarg);
}
}
optind = 1; /* start over */
@ -2040,7 +2047,7 @@ PostmasterRandom(void)
if (!initialized)
{
Assert(random_seed != 0 && !IsUnderPostmaster);
Assert(random_seed != 0);
srandom(random_seed);
initialized = true;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.160 2000/06/15 04:10:19 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.161 2000/06/22 22:31:20 petere Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -824,13 +824,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
/*
* Set default values for command-line options.
*/
IsUnderPostmaster = false;
Noversion = false;
EchoQuery = false;
#ifdef LOCK_MGR_DEBUG
LockDebug = 0;
#endif
DataDir = getenv("PGDATA");
if (!IsUnderPostmaster)
{
ResetAllOptions();
if (getenv("PGDATA"))
DataDir = strdup(getenv("PGDATA"));
}
StatFp = stderr;
SetProcessingMode(InitProcessing);
@ -891,7 +893,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
case 'D': /* PGDATA directory */
if (secure)
DataDir = optarg;
{
if (DataDir)
free(DataDir);
DataDir = strdup(optarg);
}
break;
case 'd': /* debug level */
@ -1022,8 +1028,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
*/
if (secure)
{
IsUnderPostmaster = true;
DBName = optarg;
DBName = strdup(optarg);
secure = false; /* subsequent switches are NOT
* secure */
}
@ -1170,12 +1175,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
proc_exit(1);
}
/*
* Make a copy of DataDir because the arguments and environment
* might be moved around later on.
*/
DataDir = strdup(DataDir);
/*
* 1. Set BlockSig and UnBlockSig masks. 2. Set up signal handlers. 3.
* Allow only SIGUSR1 signal (we never block it) during
@ -1330,7 +1329,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
/*
* Set process params for ps
* Set process parameters for ps
*
* WARNING: On some platforms the environment will be moved
* around to make room for the ps display string. So any
* references to optarg or getenv() from above will be invalid
* after this call. Better use strdup or something similar.
*/
init_ps_display(real_argc, real_argv, userName, DBName, remote_host);
set_ps_display("startup");
@ -1382,7 +1386,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.160 $ $Date: 2000/06/15 04:10:19 $\n");
puts("$Revision: 1.161 $ $Date: 2000/06/22 22:31:20 $\n");
}
/*

View File

@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.3 2000/06/15 04:10:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.4 2000/06/22 22:31:21 petere Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@ -49,6 +49,7 @@ bool Show_executor_stats = false;
bool Show_query_stats = false; /* this is sort of all three above together */
bool Show_btree_build_stats = false;
bool SQL_inheritance;
enum config_type
@ -115,6 +116,23 @@ struct config_string
};
/*
* TO ADD AN OPTION:
*
* 1. Declare a global variable of type bool, int, double, or char*
* and make use of it.
*
* 2. Decide at what times it's safe to set the option. See guc.h for
* details.
*
* 3. Decide on a name, a default value, upper and lower bounds (if
* applicable), etc.
*
* 4. Add a record below.
*
* 5. Don't forget to document that option.
*/
/******** option names follow ********/
@ -133,27 +151,27 @@ ConfigureNamesBool[] =
{"geqo", PGC_USERSET, &enable_geqo, true},
{"net_server", PGC_POSTMASTER, &NetServer, false},
{"fsync", PGC_BACKEND, &enableFsync, true},
{"fsync", PGC_USERSET, &enableFsync, true},
{"log_connections", PGC_POSTMASTER, &Log_connections, false},
{"log_timestamp", PGC_BACKEND, &Log_timestamp, false},
{"log_pid", PGC_BACKEND, &Log_pid, false},
{"log_connections", PGC_SIGHUP, &Log_connections, false},
{"log_timestamp", PGC_SIGHUP, &Log_timestamp, false},
{"log_pid", PGC_SIGHUP, &Log_pid, false},
{"debug_print_query", PGC_SUSET, &Debug_print_query, false},
{"debug_print_parse", PGC_SUSET, &Debug_print_parse, false},
{"debug_print_rewritten", PGC_SUSET, &Debug_print_rewritten, false},
{"debug_print_plan", PGC_SUSET, &Debug_print_plan, false},
{"debug_pretty_print", PGC_SUSET, &Debug_pretty_print, false},
{"debug_print_query", PGC_USERSET, &Debug_print_query, false},
{"debug_print_parse", PGC_USERSET, &Debug_print_parse, false},
{"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false},
{"debug_print_plan", PGC_USERSET, &Debug_print_plan, false},
{"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false},
{"show_parser_stats", PGC_SUSET, &Show_parser_stats, false},
{"show_planner_stats", PGC_SUSET, &Show_planner_stats, false},
{"show_executor_stats", PGC_SUSET, &Show_executor_stats, false},
{"show_query_stats", PGC_SUSET, &Show_query_stats, false},
{"show_parser_stats", PGC_USERSET, &Show_parser_stats, false},
{"show_planner_stats", PGC_USERSET, &Show_planner_stats, false},
{"show_executor_stats", PGC_USERSET, &Show_executor_stats, false},
{"show_query_stats", PGC_USERSET, &Show_query_stats, false},
#ifdef BTREE_BUILD_STATS
{"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false},
#endif
{"trace_notify", PGC_SUSET, &Trace_notify, false},
{"trace_notify", PGC_USERSET, &Trace_notify, false},
#ifdef LOCK_DEBUG
{"trace_locks", PGC_SUSET, &Trace_locks, false},
@ -162,8 +180,10 @@ ConfigureNamesBool[] =
{"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false},
#endif
{"hostlookup", PGC_POSTMASTER, &HostnameLookup, false},
{"showportnumber", PGC_POSTMASTER, &ShowPortNumber, false},
{"hostlookup", PGC_SIGHUP, &HostnameLookup, false},
{"showportnumber", PGC_SIGHUP, &ShowPortNumber, false},
{"sql_inheritance", PGC_USERSET, &SQL_inheritance, true},
{NULL, 0, NULL, false}
};
@ -187,7 +207,7 @@ ConfigureNamesInt[] =
1000, 0, INT_MAX},
#ifdef ENABLE_SYSLOG
{"syslog", PGC_POSTMASTER, &Use_syslog,
{"syslog", PGC_SIGHUP, &Use_syslog,
0, 0, 2},
#endif
@ -203,11 +223,10 @@ ConfigureNamesInt[] =
{"port", PGC_POSTMASTER, &PostPortName,
DEF_PGPORT, 1, 65535},
/* XXX Is this really changeable at runtime? */
{"sort_mem", PGC_SUSET, &SortMem,
{"sort_mem", PGC_USERSET, &SortMem,
512, 1, INT_MAX},
{"debug_level", PGC_SUSET, &DebugLvl,
{"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16},
#ifdef LOCK_DEBUG
@ -217,7 +236,7 @@ ConfigureNamesInt[] =
0, 0, INT_MAX},
#endif
{"max_expr_depth", PGC_USERSET, &max_expr_depth,
DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX},
DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX},
{NULL, 0, NULL, 0, 0, 0}
};
@ -483,29 +502,45 @@ set_config_option(const char * name, const char * value, GucContext
return false;
}
if (record->context < context)
/*
* Check if the option can be set at this time. See guc.h for the
* precise rules. Note that we don't want to throw errors if we're
* in the SIGHUP context. In that case we just ignore the attempt.
*/
if (record->context == PGC_POSTMASTER && context != PGC_POSTMASTER)
{
/* can't set option right now */
switch (context)
{
case PGC_USERSET:
elog(ERROR, "permission denied");
/*NORETURN*/
case PGC_SUSET:
elog(ERROR, "%s can only be set at startup", name);
/*NORETURN*/
case PGC_SIGHUP:
/* ignore the option */
return true;
case PGC_BACKEND:
/* ignore; is this the right thing to do? */
return true;
default:
elog(FATAL, "%s:%d: internal error", __FILE__, __LINE__);
/*NORETURN*/
}
if (context != PGC_SIGHUP)
elog(ERROR, "%s cannot be changed after server start", name);
else
return true;
}
else if (record->context == PGC_SIGHUP && context != PGC_SIGHUP &&
context != PGC_POSTMASTER)
{
elog(ERROR, "%s cannot be changed now", name);
/* Hmm, the idea of the SIGHUP context is "ought to be global,
* but can be changed after postmaster start". But there's
* nothing that prevents a crafty administrator from sending
* SIGHUP signals to individual backends only. */
}
else if (record->context == PGC_BACKEND && context != PGC_BACKEND
&& context != PGC_POSTMASTER)
{
if (context != PGC_SIGHUP)
elog(ERROR, "%s cannot be set after connection start", name);
else
return true;
}
else if (record->context == PGC_SUSET && (context == PGC_USERSET
|| context == PGC_BACKEND))
{
elog(ERROR, "permission denied");
}
/*
* Evaluate value and set variable
*/
switch(type)
{
case PGC_BOOL:
@ -652,7 +687,7 @@ SetConfigOption(const char * name, const char * value, GucContext
* valid until the next call to configuration related functions.
*/
const char *
GetConfigOption(const char * name, bool issuper)
GetConfigOption(const char * name)
{
struct config_generic * record;
static char buffer[256];
@ -662,13 +697,10 @@ GetConfigOption(const char * name, bool issuper)
if (opttype == PGC_NONE)
elog(ERROR, "not a valid option name: %s", name);
if (record->context < PGC_USERSET && !issuper)
elog(ERROR, "permission denied");
switch(opttype)
{
case PGC_BOOL:
return *((struct config_bool *)record)->variable ? "true" : "false";
return *((struct config_bool *)record)->variable ? "on" : "off";
case PGC_INT:
snprintf(buffer, 256, "%d", *((struct config_int *)record)->variable);

View File

@ -26,7 +26,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.96 2000/06/12 03:40:41 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.97 2000/06/22 22:31:22 petere Exp $
#
#-------------------------------------------------------------------------
@ -460,6 +460,7 @@ then
cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf || exit_nicely
cp "$POSTGRESQL_CONF_SAMPLE" "$PGDATA"/postgresql.conf || exit_nicely
chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/postgresql.conf
echo "Adding template1 database to pg_database"

View File

@ -2,7 +2,7 @@
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements
*
* $Id: variable.h,v 1.11 2000/06/09 01:44:24 momjian Exp $
* $Id: variable.h,v 1.12 2000/06/22 22:31:23 petere Exp $
*
*/
#ifndef VARIABLE_H
@ -13,6 +13,5 @@ extern void GetPGVariable(const char *name);
extern void ResetPGVariable(const char *name);
extern void set_default_datestyle(void);
extern bool examine_subclass;
#endif /* VARIABLE_H */

View File

@ -4,7 +4,7 @@
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
* $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.1 2000/05/31 00:28:40 petere Exp $
* $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.2 2000/06/22 22:31:24 petere Exp $
*/
#ifndef GUC_H
#define GUC_H
@ -12,20 +12,43 @@
#include "postgres.h"
/*
* This is sort of a permission list. Those contexts with a higher
* number can also be set via the lower numbered ways.
* Certain options can only be set at certain times. The rules are
* like this:
*
* POSTMASTER options can only be set when the postmaster starts,
* either from the configuration file or the command line.
*
* SIGHUP options can only be set at postmaster startup or by changing
* the configuration file and sending the HUP signal to the postmaster
* or a backend process. (Notice that the signal receipt will not be
* evaluated immediately. The postmaster and the backend block at a
* certain point in their main loop. It's safer to wait than to read a
* file asynchronously.)
*
* BACKEND options can only be set at postmaster startup or with the
* PGOPTIONS variable from the client when the connection is
* initiated. Note that you cannot change this kind of option using
* the SIGHUP mechanism, that would defeat the purpose of this being
* fixed for a given backend once started.
*
* SUSET options can be set at postmaster startup, with the SIGHUP
* mechanism, or from SQL if you're a superuser. These options cannot
* be set using the PGOPTIONS mechanism, because there is not check as
* to who does this.
*
* USERSET options can be set by anyone any time.
*/
typedef enum {
PGC_POSTMASTER = 1, /* static postmaster option */
PGC_BACKEND = 2, /* per backend startup option */
PGC_SIGHUP = 4, /* can change this option via SIGHUP */
PGC_SUSET = 8, /* can change this option via SET if superuser */
PGC_USERSET = 16, /* everyone can change this option via SET */
PGC_POSTMASTER,
PGC_SIGHUP,
PGC_BACKEND,
PGC_SUSET,
PGC_USERSET,
} GucContext;
void SetConfigOption(const char * name, const char * value, GucContext context);
const char * GetConfigOption(const char * name, bool issuper);
const char * GetConfigOption(const char * name);
void ProcessConfigFile(GucContext context);
void ResetAllOptions(void);
@ -44,4 +67,6 @@ extern bool Show_executor_stats;
extern bool Show_query_stats;
extern bool Show_btree_build_stats;
extern bool SQL_inheritance;
#endif /*GUC_H*/