on RESET ALL those are restored.
show all: GUC + non-GUC.
SHOW ALL, RESET ALL
Marko Kreen
index 7bb87570add3fc4befbdd4cb78dd408a9fc316f5..85194663eb2e7baec5d3fc4ce4b7daad01e7d123 100644 (file)
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v 1.10 2000年12月25日 23:15:26 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v 1.11 2001年06月07日 04:50:56 momjian Exp $
Postgres documentation
-->
<synopsis>
RESET <replaceable class="PARAMETER">variable</replaceable>
</synopsis>
+ <synopsis>
+RESET ALL
+ </synopsis>
<refsect2 id="R2-SQL-RESET-1">
<title>Inputs</title>
@@ -30,6 +33,14 @@ RESET <replaceable class="PARAMETER">variable</replaceable>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>ALL</term>
+ <listitem>
+ <para>
+ Resets all run-time parameters to default values.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect2>
index 934b0567f2d695d2f6c25acf0f098449cf08f9d3..3674a97c5ba5d57932ea5e32174b5e89187ee7e4 100644 (file)
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v 1.11 2000年12月25日 23:15:26 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v 1.12 2001年06月07日 04:50:56 momjian Exp $
Postgres documentation
-->
<synopsis>
SHOW <replaceable class="PARAMETER">name</replaceable>
</synopsis>
+ <synopsis>
+SHOW ALL
+ </synopsis>
<refsect2 id="R2-SQL-SHOW-1">
<title>Inputs</title>
@@ -32,6 +35,14 @@ SHOW <replaceable class="PARAMETER">name</replaceable>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>ALL</term>
+ <listitem>
+ <para>
+ Show all current session parameters.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect2>
index eb43be8f3f0e7a57edf3859b77fcdb83e7efae94..6f22bcc33d2de615ffd3c9ef37503284d8857f05 100644 (file)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.48 2001年05月08日 21:06:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.49 2001年06月07日 04:50:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
-static bool show_date(void);
-static bool reset_date(void);
-static bool parse_date(char *);
+static bool show_datestyle(void);
+static bool reset_datestyle(void);
+static bool parse_datestyle(char *);
static bool show_timezone(void);
static bool reset_timezone(void);
static bool parse_timezone(char *);
static bool DefaultEuroDates;
static bool
-parse_date(char *value)
+parse_datestyle(char *value)
{
char *tok;
int dcnt = 0,
if (value == NULL)
{
- reset_date();
+ reset_datestyle();
return TRUE;
}
}
static bool
-show_date(void)
+show_datestyle(void)
{
char buf[64];
}
static bool
-reset_date(void)
+reset_datestyle(void)
{
DateStyle = DefaultDateStyle;
EuroDates = DefaultEuroDates;
DBDate = strdup(DBDate);
/* Parse desired setting into DateStyle/EuroDates */
- parse_date(DBDate);
+ parse_datestyle(DBDate);
free(DBDate);
tz = getenv("TZ");
- elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unknown"));
+ elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unset"));
return TRUE;
} /* show_timezone() */
static bool
show_random_seed(void)
{
- elog(NOTICE, "Seed for random number generator is not known");
+ elog(NOTICE, "Seed for random number generator is unavailable");
return (TRUE);
}
@@ -708,7 +708,7 @@ SetPGVariable(const char *name, const char *value)
* Special cases ought to be removed and handled separately by TCOP
*/
if (strcasecmp(name, "datestyle") == 0)
- parse_date(mvalue);
+ parse_datestyle(mvalue);
else if (strcasecmp(name, "timezone") == 0)
parse_timezone(mvalue);
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
@@ -724,18 +724,17 @@ SetPGVariable(const char *name, const char *value)
else if (strcasecmp(name, "session_authorization") == 0)
SetSessionAuthorization(value);
else
- SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET);
+ SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET, false);
if (mvalue)
pfree(mvalue);
}
-
void
GetPGVariable(const char *name)
{
if (strcasecmp(name, "datestyle") == 0)
- show_date();
+ show_datestyle();
else if (strcasecmp(name, "timezone") == 0)
show_timezone();
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
show_server_encoding();
else if (strcasecmp(name, "seed") == 0)
show_random_seed();
- else
+ else if (strcasecmp(name, "all") == 0)
+ {
+ ShowAllGUCConfig();
+ show_datestyle();
+ show_timezone();
+ show_DefaultXactIsoLevel();
+ show_XactIsoLevel();
+ show_client_encoding();
+ show_server_encoding();
+ show_random_seed();
+ } else
{
const char *val = GetConfigOption(name);
ResetPGVariable(const char *name)
{
if (strcasecmp(name, "datestyle") == 0)
- reset_date();
+ reset_datestyle();
else if (strcasecmp(name, "timezone") == 0)
reset_timezone();
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
reset_server_encoding();
else if (strcasecmp(name, "seed") == 0)
reset_random_seed();
- else
- SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET);
+ else if (strcasecmp(name, "all") == 0)
+ {
+ reset_DefaultXactIsoLevel();
+ reset_XactIsoLevel();
+ reset_random_seed();
+ /* reset_server_encoding(); */
+ reset_client_encoding();
+ reset_datestyle();
+ reset_timezone();
+
+ ResetAllOptions();
+ } else
+ SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET, false);
}
index 6cf2adcb5ba852e8366ecbf5a620a406b2b5398e..308b49fd727c13bb593512f0bea1abc420769d00 100644 (file)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.228 2001年06月04日 23:27:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.229 2001年06月07日 04:50:56 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
n->name = "timezone";
$$ = (Node *) n;
}
+ | SHOW ALL
+ {
+ VariableShowStmt *n = makeNode(VariableShowStmt);
+ n->name = "all";
+ $$ = (Node *) n;
+ }
| SHOW TRANSACTION ISOLATION LEVEL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "XactIsoLevel";
$$ = (Node *) n;
}
+ | RESET ALL
+ {
+ VariableResetStmt *n = makeNode(VariableResetStmt);
+ n->name = "all";
+ $$ = (Node *) n;
+ }
;
index 6ccc9e577ba9d24da788fdd97353fd9cd7c1ad40..96d7d1e3ad9c1bdd64445084b46f65d2a350eed5 100644 (file)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.216 2001年06月03日 14:53:56 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.217 2001年06月07日 04:50:57 momjian Exp $
*
* NOTES
*
elog(ERROR, "-c %s requires argument", optarg);
}
- SetConfigOption(name, value, PGC_POSTMASTER);
+ SetConfigOption(name, value, PGC_POSTMASTER, true);
free(name);
if (value)
free(value);
index 19a44ff67d72c9304d637402b11bdb59c678629a..8e5115f755a23e901fa63bfcc70e09989152aff4 100644 (file)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.218 2001年04月14日 19:11:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.219 2001年06月07日 04:50:57 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -1462,7 +1462,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
/* all options are allowed if not under postmaster */
SetConfigOption(name, value,
- (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER);
+ (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
free(name);
if (value)
free(value);
@@ -1709,7 +1709,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.218 $ $Date: 2001年04月14日 19:11:45 $\n");
+ puts("$Revision: 1.219 $ $Date: 2001年06月07日 04:50:57 $\n");
}
/*
index cb39525df928fa38519c3d6659fb50bbeed09e63..950dbb6ef92c9287ebf38c547192ac5fc551b548 100644 (file)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.7 2001年06月01日 20:29:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.8 2001年06月07日 04:50:57 momjian Exp $
*/
%{
*/
for(item = head; item; item=item->next)
{
- if (!set_config_option(item->name, item->value, context, false))
+ if (!set_config_option(item->name, item->value, context, 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);
+ set_config_option(item->name, item->value, context, true, true);
cleanup_exit:
free_name_value_list(head);
index 6e080594f8b6662891da9be5b2bb5a0c566f22d2..78c569f80b882e405e0fbcc09ea56bd38bf775f0 100644 (file)
* 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.36 2001年05月17日 17:44:18 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.37 2001年06月07日 04:50:57 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
const char *name;
GucContext context;
char **variable;
- const char *default_val;
+ const char *boot_default_val;
bool (*parse_hook) (const char *proposed);
void (*assign_hook) (const char *newval);
+ char *default_val;
};
{
char *str = NULL;
+ if (!ConfigureNamesString[i].default_val
+ && ConfigureNamesString[i].boot_default_val)
+ {
+ str = strdup(ConfigureNamesString[i].boot_default_val);
+ if (str == NULL)
+ elog(ERROR, "out of memory");
+
+ ConfigureNamesString[i].default_val = str;
+ }
if (ConfigureNamesString[i].default_val)
{
str = strdup(ConfigureNamesString[i].default_val);
@@ -582,7 +592,7 @@ parse_real(const char *value, double *result)
*/
bool
set_config_option(const char *name, const char *value, GucContext
- context, bool DoIt)
+ context, bool DoIt, bool makeDefault)
{
struct config_generic *record;
enum config_type type;
@@ -653,7 +663,11 @@ set_config_option(const char *name, const char *value, GucContext
return false;
}
if (DoIt)
+ {
*conf->variable = boolval;
+ if (makeDefault)
+ conf->default_val = boolval;
+ }
}
else if (DoIt)
*conf->variable = conf->default_val;
@@ -681,7 +695,11 @@ set_config_option(const char *name, const char *value, GucContext
return false;
}
if (DoIt)
+ {
*conf->variable = intval;
+ if (makeDefault)
+ conf->default_val = intval;
+ }
}
else if (DoIt)
*conf->variable = conf->default_val;
@@ -709,7 +727,11 @@ set_config_option(const char *name, const char *value, GucContext
return false;
}
if (DoIt)
+ {
*conf->variable = dval;
+ if (makeDefault)
+ conf->default_val = dval;
+ }
}
else if (DoIt)
*conf->variable = conf->default_val;
@@ -742,12 +764,33 @@ set_config_option(const char *name, const char *value, GucContext
if (*conf->variable)
free(*conf->variable);
*conf->variable = str;
+ if (makeDefault)
+ {
+ if (conf->default_val)
+ free(conf->default_val);
+ str = strdup(value);
+ if (str == NULL) {
+ elog(elevel, "out of memory");
+ return false;
+ }
+ conf->default_val = str;
+ }
}
}
else if (DoIt)
{
char *str;
+ if (!conf->default_val && conf->boot_default_val)
+ {
+ str = strdup(conf->boot_default_val);
+ if (str == NULL)
+ {
+ elog(elevel, "out of memory");
+ return false;
+ }
+ conf->boot_default_val = str;
+ }
str = strdup(conf->default_val);
if (str == NULL)
{
@@ -776,9 +819,9 @@ set_config_option(const char *name, const char *value, GucContext
*/
void
SetConfigOption(const char *name, const char *value, GucContext
- context)
+ context, bool makeDefault)
{
- (void) set_config_option(name, value, context, true);
+ (void) set_config_option(name, value, context, true, makeDefault);
}
return NULL;
}
+static void
+_ShowOption(enum config_type opttype, struct config_generic *record)
+{
+ static char buffer[256];
+ char *val;
+
+ switch (opttype)
+ {
+ case PGC_BOOL:
+ val = *((struct config_bool *) record)->variable ? "on" : "off";
+ break;
+ case PGC_INT:
+ snprintf(buffer, 256, "%d", *((struct config_int *) record)->variable);
+ val = buffer;
+ break;
+
+ case PGC_REAL:
+ snprintf(buffer, 256, "%g", *((struct config_real *) record)->variable);
+ val = buffer;
+ break;
+
+ case PGC_STRING:
+ val = strlen(*((struct config_string *) record)->variable) != 0 ?
+ *((struct config_string *) record)->variable : "unset";
+ break;
+
+ default:
+ val = "???";
+ }
+ elog(NOTICE, "%s is %s", record->name, val);
+}
+
+void
+ShowAllGUCConfig(void)
+{
+ int i;
+
+ for (i = 0; ConfigureNamesBool[i].name; i++)
+ _ShowOption(PGC_BOOL, (struct config_generic *)&ConfigureNamesBool[i]);
+
+ for (i = 0; ConfigureNamesInt[i].name; i++)
+ _ShowOption(PGC_INT, (struct config_generic *)&ConfigureNamesInt[i]);
+
+ for (i = 0; ConfigureNamesReal[i].name; i++)
+ _ShowOption(PGC_REAL, (struct config_generic *)&ConfigureNamesReal[i]);
+
+ for (i = 0; ConfigureNamesString[i].name; i++)
+ _ShowOption(PGC_STRING, (struct config_generic *)&ConfigureNamesString[i]);
+}
+
+
+
/*
index 978b9da859e7791e0d7623e4513516c5325601fa..1d925f0c3eade81346bb1e694cd33ae37899a506 100644 (file)
* 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.6 2001年03月22日 04:01:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.7 2001年06月07日 04:50:57 momjian Exp $
*/
#ifndef GUC_H
#define GUC_H
} GucContext;
-void SetConfigOption(const char *name, const char *value, GucContext context);
+void SetConfigOption(const char *name, const char *value, GucContext context, bool makeDefault);
const char *GetConfigOption(const char *name);
void ProcessConfigFile(GucContext context);
void ResetAllOptions(void);
void ParseLongOption(const char *string, char **name, char **value);
-bool set_config_option(const char *name, const char *value, GucContext context, bool DoIt);
+bool set_config_option(const char *name, const char *value, GucContext context, bool DoIt, bool makeDefault);
+void ShowAllGUCConfig(void);
extern bool Debug_print_query;