support this ONLY
notation.
- 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
-
+
+
Deprecated
+ In previous versions of
Postgres, 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
SELECT * from cities*;
-
-
- This old behaviour is still available by using a SET command:
-
-SET EXAMINE_SUBCLASS TO on;
-
-
+
+ To get the old behavior, the set configuration option
+ SQL_Inheritance to off, e.g.,
+SET SQL_Inheritance TO OFF;
+
+ or add a line in your postgresql.conf file.
+
+
UPDATE and DELETE --
support this ONLY
notation.
- 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
- SELECT * from cities*;
-
- This old behaviour is still available by using a SET command...
- SET EXAMINE_SUBCLASS TO on;
-
-
+
+
Deprecated
+ In previous versions of
Postgres, 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
+SELECT * from cities*;
+
+ To get the old behavior, the set configuration option
+ SQL_Inheritance to off, e.g.,
+SET SQL_Inheritance TO OFF;
+
+ or add a line in your postgresql.conf file.
+
+
This was previously the default result, and getting subclasses was
obtained by appending * to the table name.
The old behaviour is available via the command
- SET EXAMINE_SUBCLASS TO 'on';
+ SET SQL_Inheritance TO OFF;
+
+
+ SQL_INHERITANCE (bool)
+
+ 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 ONLY keyword to
+ exclude subtables. See the SQL language reference and the
+ User's Guide for more information about
+ inheritance.
+
+
+
* 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 $
*
*-------------------------------------------------------------------------
*/
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
+#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/portal.h"
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)
{
xloginit = true;
break;
case 'p':
- IsUnderPostmaster = true;
+ /* indicates fork from postmaster */
break;
case 'B':
NBuffers = atoi(optarg);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
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
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)
#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);
}
#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);
}
}
#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);
}
*
*
* 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
#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"
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;
}
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;
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;
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;
}
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;
{
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;
/* default inheritance */
$$ = makeNode(RelExpr);
$$->relname = $1;
- $$->inh = examine_subclass;
+ $$->inh = SQL_inheritance;
}
| relation_name '*' %prec '='
{
*
*
* 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
*
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];
ResetAllOptions();
MyProcPid = getpid();
- DataDir = getenv("PGDATA"); /* default value */
+ if (getenv("PGDATA"))
+ DataDir = strdup(getenv("PGDATA")); /* default value */
if (getenv("PGPORT"))
PostPortName = atoi(getenv("PGPORT"));
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 */
if (!initialized)
{
- Assert(random_seed != 0 && !IsUnderPostmaster);
+ Assert(random_seed != 0);
srandom(random_seed);
initialized = true;
}
*
*
* 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
/*
* 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);
case 'D': /* PGDATA directory */
if (secure)
- DataDir = optarg;
+ {
+ if (DataDir)
+ free(DataDir);
+ DataDir = strdup(optarg);
+ }
break;
case 'd': /* debug level */
*/
if (secure)
{
- IsUnderPostmaster = true;
- DBName = optarg;
+ DBName = strdup(optarg);
secure = false; /* subsequent switches are NOT
* secure */
}
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
/*
- * 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");
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");
}
/*
* 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
.
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
};
+/*
+ * 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 ********/
{"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},
{"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}
};
1000, 0, INT_MAX},
#ifdef ENABLE_SYSLOG
- {"syslog", PGC_POSTMASTER, &Use_syslog,
+ {"syslog", PGC_SIGHUP, &Use_syslog,
0, 0, 2},
#endif
{"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
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}
};
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:
* 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];
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);
#
#
# 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 $
#
#-------------------------------------------------------------------------
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"
* 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
extern void ResetPGVariable(const char *name);
extern void set_default_datestyle(void);
-extern bool examine_subclass;
#endif /* VARIABLE_H */
* 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
#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);
extern bool Show_query_stats;
extern bool Show_btree_build_stats;
+extern bool SQL_inheritance;
+
#endif /*GUC_H*/