aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/advanced.sgml35
-rw-r--r--doc/src/sgml/inherit.sgml34
-rw-r--r--doc/src/sgml/ref/select.sgml4
-rw-r--r--doc/src/sgml/runtime.sgml19
-rw-r--r--src/backend/bootstrap/bootstrap.c12
-rw-r--r--src/backend/commands/variable.c57
-rw-r--r--src/backend/parser/gram.y18
-rw-r--r--src/backend/postmaster/postmaster.c15
-rw-r--r--src/backend/tcop/postgres.c38
-rw-r--r--src/backend/utils/misc/guc.c132
-rw-r--r--src/bin/initdb/initdb.sh3
-rw-r--r--src/include/commands/variable.h3
-rw-r--r--src/include/utils/guc.h43
13 files changed, 231 insertions, 182 deletions
diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index 2807c8bc86b..1cf2c63ffab 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -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>
diff --git a/doc/src/sgml/inherit.sgml b/doc/src/sgml/inherit.sgml
index 73a2678655d..774795f94d9 100644
--- a/doc/src/sgml/inherit.sgml
+++ b/doc/src/sgml/inherit.sgml
@@ -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
diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml
index 8b21a3438d3..c9b412d9bbb 100644
--- a/doc/src/sgml/ref/select.sgml
+++ b/doc/src/sgml/ref/select.sgml
@@ -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>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index b92a1cc67b2..1f9a940aa00 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -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>
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 532d1bc3a82..b49d5ef8bf3 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -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);
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 27a732ec57e..154be6a23dd 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -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);
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 3f52e801050..b17185e4639 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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 '='
{
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index ca32fcbe496..f712d7cfeca 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -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;
}
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 631f482e81a..9209b6509f2 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -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 */
}
@@ -1171,12 +1176,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
}
/*
- * 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
* initialization.
@@ -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");
}
/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 300bb19b60a..f2cbe3651d3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -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},
-
- {"log_connections", PGC_POSTMASTER, &Log_connections, false},
- {"log_timestamp", PGC_BACKEND, &Log_timestamp, false},
- {"log_pid", PGC_BACKEND, &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},
-
- {"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},
+ {"fsync", PGC_USERSET, &enableFsync, true},
+
+ {"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_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_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);
diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh
index 663b8a16c85..a83bb981246 100644
--- a/src/bin/initdb/initdb.sh
+++ b/src/bin/initdb/initdb.sh
@@ -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"
diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h
index de26bcd6e04..87334dda4d4 100644
--- a/src/include/commands/variable.h
+++ b/src/include/commands/variable.h
@@ -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 */
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index bf0dfcbe4dc..c4ff10a1401 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -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*/