Thread: take 2: show all / reset all
Ok, now I am awake. How about this one? reset all: command line and .conf options change defaults on RESET ALL those are restored. show all: GUC + non-GUC. -- marko Index: doc/src/sgml/ref/reset.sgml =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v retrieving revision 1.10 diff -c -r1.10 reset.sgml *** doc/src/sgml/ref/reset.sgml 2000/12/25 23:15:26 1.10 --- doc/src/sgml/ref/reset.sgml 2001/06/02 11:04:32 *************** *** 16,21 **** --- 16,24 ---- <synopsis> RESET <replaceable class="PARAMETER">variable</replaceable> </synopsis> + <synopsis> + RESET ALL + </synopsis> <refsect2 id="R2-SQL-RESET-1"> <title>Inputs</title> *************** *** 27,32 **** --- 30,43 ---- <para> The name of a run-time parameter. See <xref linkend="sql-set" endterm="sql-set-title"> for a list. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ALL</term> + <listitem> + <para> + Resets all run-time parameters to default values. </para> </listitem> </varlistentry> Index: doc/src/sgml/ref/show.sgml =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v retrieving revision 1.11 diff -c -r1.11 show.sgml *** doc/src/sgml/ref/show.sgml 2000/12/25 23:15:26 1.11 --- doc/src/sgml/ref/show.sgml 2001/06/02 11:04:32 *************** *** 16,21 **** --- 16,24 ---- <synopsis> SHOW <replaceable class="PARAMETER">name</replaceable> </synopsis> + <synopsis> + SHOW ALL + </synopsis> <refsect2 id="R2-SQL-SHOW-1"> <title>Inputs</title> *************** *** 29,34 **** --- 32,45 ---- The name of a run-time parameter. See <xref linkend="sql-set" endterm="sql-set-title"> for a list. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ALL</term> + <listitem> + <para> + Show all current session parameters. </para> </listitem> </varlistentry> Index: src/backend/commands/variable.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/variable.c,v retrieving revision 1.48 diff -c -r1.48 variable.c *** src/backend/commands/variable.c 2001/05/08 21:06:42 1.48 --- src/backend/commands/variable.c 2001/06/02 11:04:34 *************** *** 724,736 **** else if (strcasecmp(name, "session_authorization") == 0) SetSessionAuthorization(value); else ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET); if (mvalue) pfree(mvalue); } - void GetPGVariable(const char *name) { --- 724,735 ---- else if (strcasecmp(name, "session_authorization") == 0) SetSessionAuthorization(value); else ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET, false); if (mvalue) pfree(mvalue); } void GetPGVariable(const char *name) { *************** *** 747,754 **** else if (strcasecmp(name, "server_encoding") == 0) show_server_encoding(); else if (strcasecmp(name, "seed") == 0) show_random_seed(); ! else { const char *val = GetConfigOption(name); --- 746,763 ---- else if (strcasecmp(name, "server_encoding") == 0) show_server_encoding(); else if (strcasecmp(name, "seed") == 0) + show_random_seed(); + else if (strcasecmp(name, "all") == 0) + { + ShowAllGUCConfig(); + show_date(); + show_timezone(); + show_DefaultXactIsoLevel(); + show_XactIsoLevel(); + show_client_encoding(); + show_server_encoding(); show_random_seed(); ! } else { const char *val = GetConfigOption(name); *************** *** 773,778 **** reset_server_encoding(); else if (strcasecmp(name, "seed") == 0) reset_random_seed(); ! else ! SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET); } --- 782,798 ---- reset_server_encoding(); else if (strcasecmp(name, "seed") == 0) reset_random_seed(); ! else if (strcasecmp(name, "all") == 0) ! { ! reset_DefaultXactIsoLevel(); ! reset_XactIsoLevel(); ! reset_random_seed(); ! /* reset_server_encoding(); */ ! reset_client_encoding(); ! reset_date(); ! reset_timezone(); ! ! ResetAllOptions(); ! } else ! SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET, false); } Index: src/backend/parser/gram.y =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/gram.y,v retrieving revision 2.227 diff -c -r2.227 gram.y *** src/backend/parser/gram.y 2001/05/27 09:59:29 2.227 --- src/backend/parser/gram.y 2001/06/02 11:04:46 *************** *** 860,865 **** --- 860,871 ---- n->name = "timezone"; $$ = (Node *) n; } + | SHOW ALL + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "all"; + $$ = (Node *) n; + } | SHOW TRANSACTION ISOLATION LEVEL { VariableShowStmt *n = makeNode(VariableShowStmt); *************** *** 884,889 **** --- 890,901 ---- { VariableResetStmt *n = makeNode(VariableResetStmt); n->name = "XactIsoLevel"; + $$ = (Node *) n; + } + | RESET ALL + { + VariableResetStmt *n = makeNode(VariableResetStmt); + n->name = "all"; $$ = (Node *) n; } ; Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v retrieving revision 1.215 diff -c -r1.215 postmaster.c *** src/backend/postmaster/postmaster.c 2001/05/30 14:15:26 1.215 --- src/backend/postmaster/postmaster.c 2001/06/02 11:04:52 *************** *** 530,536 **** elog(ERROR, "-c %s requires argument", optarg); } ! SetConfigOption(name, value, PGC_POSTMASTER); free(name); if (value) free(value); --- 530,536 ---- elog(ERROR, "-c %s requires argument", optarg); } ! SetConfigOption(name, value, PGC_POSTMASTER, true); free(name); if (value) free(value); Index: src/backend/tcop/postgres.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v retrieving revision 1.218 diff -c -r1.218 postgres.c *** src/backend/tcop/postgres.c 2001/04/14 19:11:45 1.218 --- src/backend/tcop/postgres.c 2001/06/02 11:04:57 *************** *** 1462,1468 **** /* all options are allowed if not under postmaster */ SetConfigOption(name, value, ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER); free(name); if (value) free(value); --- 1462,1468 ---- /* all options are allowed if not under postmaster */ SetConfigOption(name, value, ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true); free(name); if (value) free(value); Index: src/backend/utils/misc/guc-file.l =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v retrieving revision 1.6 diff -c -r1.6 guc-file.l *** src/backend/utils/misc/guc-file.l 2001/01/24 19:01:31 1.6 --- src/backend/utils/misc/guc-file.l 2001/06/02 11:05:07 *************** *** 260,272 **** */ for(item = head; item; item=item->next) { ! if (!set_config_option(item->name, item->value, context, 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); cleanup_exit: free_name_value_list(head); --- 260,272 ---- */ for(item = head; item; item=item->next) { ! 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, true); cleanup_exit: free_name_value_list(head); Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v retrieving revision 1.36 diff -c -r1.36 guc.c *** src/backend/utils/misc/guc.c 2001/05/17 17:44:18 1.36 --- src/backend/utils/misc/guc.c 2001/06/02 11:05:10 *************** *** 136,144 **** const char *name; GucContext context; char **variable; ! const char *default_val; bool (*parse_hook) (const char *proposed); void (*assign_hook) (const char *newval); }; --- 136,145 ---- const char *name; GucContext context; char **variable; ! const char *boot_default_val; bool (*parse_hook) (const char *proposed); void (*assign_hook) (const char *newval); + char *default_val; }; *************** *** 433,438 **** --- 434,448 ---- { 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,588 **** */ bool set_config_option(const char *name, const char *value, GucContext ! context, bool DoIt) { struct config_generic *record; enum config_type type; --- 592,598 ---- */ bool set_config_option(const char *name, const char *value, GucContext ! context, bool DoIt, bool makeDefault) { struct config_generic *record; enum config_type type; *************** *** 653,659 **** --- 663,673 ---- return false; } if (DoIt) + { *conf->variable = boolval; + if (makeDefault) + conf->default_val = boolval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 681,687 **** --- 695,705 ---- return false; } if (DoIt) + { *conf->variable = intval; + if (makeDefault) + conf->default_val = intval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 709,715 **** --- 727,737 ---- return false; } if (DoIt) + { *conf->variable = dval; + if (makeDefault) + conf->default_val = dval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 742,753 **** --- 764,796 ---- 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,784 **** */ void SetConfigOption(const char *name, const char *value, GucContext ! context) { ! (void) set_config_option(name, value, context, true); } --- 819,827 ---- */ void SetConfigOption(const char *name, const char *value, GucContext ! context, bool makeDefault) { ! (void) set_config_option(name, value, context, true, makeDefault); } *************** *** 825,830 **** --- 868,924 ---- } 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 = *((struct config_string *) record)->variable; + 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: src/include/utils/guc.h =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/utils/guc.h,v retrieving revision 1.6 diff -c -r1.6 guc.h *** src/include/utils/guc.h 2001/03/22 04:01:12 1.6 --- src/include/utils/guc.h 2001/06/02 11:05:23 *************** *** 46,57 **** } GucContext; ! void SetConfigOption(const char *name, const char *value, GucContext context); 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); extern bool Debug_print_query; --- 46,58 ---- } GucContext; ! 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 makeDefault); ! void ShowAllGUCConfig(void); extern bool Debug_print_query;
I will make some manual patches to this before applying and show you the changes. Thanks. Your patch has been added to the PostgreSQL unapplied patches list at: http://candle.pha.pa.us/cgi-bin/pgpatches I will try to apply it within the next 48 hours. > > Ok, now I am awake. How about this one? > > reset all: command line and .conf options change defaults > on RESET ALL those are restored. > > show all: GUC + non-GUC. > > -- > marko > > > > Index: doc/src/sgml/ref/reset.sgml > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v > retrieving revision 1.10 > diff -c -r1.10 reset.sgml > *** doc/src/sgml/ref/reset.sgml 2000/12/25 23:15:26 1.10 > --- doc/src/sgml/ref/reset.sgml 2001/06/02 11:04:32 > *************** > *** 16,21 **** > --- 16,24 ---- > <synopsis> > RESET <replaceable class="PARAMETER">variable</replaceable> > </synopsis> > + <synopsis> > + RESET ALL > + </synopsis> > > <refsect2 id="R2-SQL-RESET-1"> > <title>Inputs</title> > *************** > *** 27,32 **** > --- 30,43 ---- > <para> > The name of a run-time parameter. See <xref > linkend="sql-set" endterm="sql-set-title"> for a list. > + </para> > + </listitem> > + </varlistentry> > + <varlistentry> > + <term>ALL</term> > + <listitem> > + <para> > + Resets all run-time parameters to default values. > </para> > </listitem> > </varlistentry> > Index: doc/src/sgml/ref/show.sgml > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v > retrieving revision 1.11 > diff -c -r1.11 show.sgml > *** doc/src/sgml/ref/show.sgml 2000/12/25 23:15:26 1.11 > --- doc/src/sgml/ref/show.sgml 2001/06/02 11:04:32 > *************** > *** 16,21 **** > --- 16,24 ---- > <synopsis> > SHOW <replaceable class="PARAMETER">name</replaceable> > </synopsis> > + <synopsis> > + SHOW ALL > + </synopsis> > > <refsect2 id="R2-SQL-SHOW-1"> > <title>Inputs</title> > *************** > *** 29,34 **** > --- 32,45 ---- > The name of a run-time parameter. See > <xref linkend="sql-set" endterm="sql-set-title"> > for a list. > + </para> > + </listitem> > + </varlistentry> > + <varlistentry> > + <term>ALL</term> > + <listitem> > + <para> > + Show all current session parameters. > </para> > </listitem> > </varlistentry> > Index: src/backend/commands/variable.c > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/variable.c,v > retrieving revision 1.48 > diff -c -r1.48 variable.c > *** src/backend/commands/variable.c 2001/05/08 21:06:42 1.48 > --- src/backend/commands/variable.c 2001/06/02 11:04:34 > *************** > *** 724,736 **** > else if (strcasecmp(name, "session_authorization") == 0) > SetSessionAuthorization(value); > else > ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET); > > if (mvalue) > pfree(mvalue); > } > > - > void > GetPGVariable(const char *name) > { > --- 724,735 ---- > else if (strcasecmp(name, "session_authorization") == 0) > SetSessionAuthorization(value); > else > ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET, false); > > if (mvalue) > pfree(mvalue); > } > > void > GetPGVariable(const char *name) > { > *************** > *** 747,754 **** > else if (strcasecmp(name, "server_encoding") == 0) > show_server_encoding(); > else if (strcasecmp(name, "seed") == 0) > show_random_seed(); > ! else > { > const char *val = GetConfigOption(name); > > --- 746,763 ---- > else if (strcasecmp(name, "server_encoding") == 0) > show_server_encoding(); > else if (strcasecmp(name, "seed") == 0) > + show_random_seed(); > + else if (strcasecmp(name, "all") == 0) > + { > + ShowAllGUCConfig(); > + show_date(); > + show_timezone(); > + show_DefaultXactIsoLevel(); > + show_XactIsoLevel(); > + show_client_encoding(); > + show_server_encoding(); > show_random_seed(); > ! } else > { > const char *val = GetConfigOption(name); > > *************** > *** 773,778 **** > reset_server_encoding(); > else if (strcasecmp(name, "seed") == 0) > reset_random_seed(); > ! else > ! SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET); > } > --- 782,798 ---- > reset_server_encoding(); > else if (strcasecmp(name, "seed") == 0) > reset_random_seed(); > ! else if (strcasecmp(name, "all") == 0) > ! { > ! reset_DefaultXactIsoLevel(); > ! reset_XactIsoLevel(); > ! reset_random_seed(); > ! /* reset_server_encoding(); */ > ! reset_client_encoding(); > ! reset_date(); > ! reset_timezone(); > ! > ! ResetAllOptions(); > ! } else > ! SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET, false); > } > Index: src/backend/parser/gram.y > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/gram.y,v > retrieving revision 2.227 > diff -c -r2.227 gram.y > *** src/backend/parser/gram.y 2001/05/27 09:59:29 2.227 > --- src/backend/parser/gram.y 2001/06/02 11:04:46 > *************** > *** 860,865 **** > --- 860,871 ---- > n->name = "timezone"; > $$ = (Node *) n; > } > + | SHOW ALL > + { > + VariableShowStmt *n = makeNode(VariableShowStmt); > + n->name = "all"; > + $$ = (Node *) n; > + } > | SHOW TRANSACTION ISOLATION LEVEL > { > VariableShowStmt *n = makeNode(VariableShowStmt); > *************** > *** 884,889 **** > --- 890,901 ---- > { > VariableResetStmt *n = makeNode(VariableResetStmt); > n->name = "XactIsoLevel"; > + $$ = (Node *) n; > + } > + | RESET ALL > + { > + VariableResetStmt *n = makeNode(VariableResetStmt); > + n->name = "all"; > $$ = (Node *) n; > } > ; > Index: src/backend/postmaster/postmaster.c > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v > retrieving revision 1.215 > diff -c -r1.215 postmaster.c > *** src/backend/postmaster/postmaster.c 2001/05/30 14:15:26 1.215 > --- src/backend/postmaster/postmaster.c 2001/06/02 11:04:52 > *************** > *** 530,536 **** > elog(ERROR, "-c %s requires argument", optarg); > } > > ! SetConfigOption(name, value, PGC_POSTMASTER); > free(name); > if (value) > free(value); > --- 530,536 ---- > elog(ERROR, "-c %s requires argument", optarg); > } > > ! SetConfigOption(name, value, PGC_POSTMASTER, true); > free(name); > if (value) > free(value); > Index: src/backend/tcop/postgres.c > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v > retrieving revision 1.218 > diff -c -r1.218 postgres.c > *** src/backend/tcop/postgres.c 2001/04/14 19:11:45 1.218 > --- src/backend/tcop/postgres.c 2001/06/02 11:04:57 > *************** > *** 1462,1468 **** > > /* all options are allowed if not under postmaster */ > SetConfigOption(name, value, > ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER); > free(name); > if (value) > free(value); > --- 1462,1468 ---- > > /* all options are allowed if not under postmaster */ > SetConfigOption(name, value, > ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true); > free(name); > if (value) > free(value); > Index: src/backend/utils/misc/guc-file.l > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v > retrieving revision 1.6 > diff -c -r1.6 guc-file.l > *** src/backend/utils/misc/guc-file.l 2001/01/24 19:01:31 1.6 > --- src/backend/utils/misc/guc-file.l 2001/06/02 11:05:07 > *************** > *** 260,272 **** > */ > for(item = head; item; item=item->next) > { > ! if (!set_config_option(item->name, item->value, context, 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); > > cleanup_exit: > free_name_value_list(head); > --- 260,272 ---- > */ > for(item = head; item; item=item->next) > { > ! 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, true); > > cleanup_exit: > free_name_value_list(head); > Index: src/backend/utils/misc/guc.c > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v > retrieving revision 1.36 > diff -c -r1.36 guc.c > *** src/backend/utils/misc/guc.c 2001/05/17 17:44:18 1.36 > --- src/backend/utils/misc/guc.c 2001/06/02 11:05:10 > *************** > *** 136,144 **** > const char *name; > GucContext context; > char **variable; > ! const char *default_val; > bool (*parse_hook) (const char *proposed); > void (*assign_hook) (const char *newval); > }; > > > --- 136,145 ---- > const char *name; > GucContext context; > char **variable; > ! const char *boot_default_val; > bool (*parse_hook) (const char *proposed); > void (*assign_hook) (const char *newval); > + char *default_val; > }; > > > *************** > *** 433,438 **** > --- 434,448 ---- > { > 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,588 **** > */ > bool > set_config_option(const char *name, const char *value, GucContext > ! context, bool DoIt) > { > struct config_generic *record; > enum config_type type; > --- 592,598 ---- > */ > bool > set_config_option(const char *name, const char *value, GucContext > ! context, bool DoIt, bool makeDefault) > { > struct config_generic *record; > enum config_type type; > *************** > *** 653,659 **** > --- 663,673 ---- > return false; > } > if (DoIt) > + { > *conf->variable = boolval; > + if (makeDefault) > + conf->default_val = boolval; > + } > } > else if (DoIt) > *conf->variable = conf->default_val; > *************** > *** 681,687 **** > --- 695,705 ---- > return false; > } > if (DoIt) > + { > *conf->variable = intval; > + if (makeDefault) > + conf->default_val = intval; > + } > } > else if (DoIt) > *conf->variable = conf->default_val; > *************** > *** 709,715 **** > --- 727,737 ---- > return false; > } > if (DoIt) > + { > *conf->variable = dval; > + if (makeDefault) > + conf->default_val = dval; > + } > } > else if (DoIt) > *conf->variable = conf->default_val; > *************** > *** 742,753 **** > --- 764,796 ---- > 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,784 **** > */ > void > SetConfigOption(const char *name, const char *value, GucContext > ! context) > { > ! (void) set_config_option(name, value, context, true); > } > > > --- 819,827 ---- > */ > void > SetConfigOption(const char *name, const char *value, GucContext > ! context, bool makeDefault) > { > ! (void) set_config_option(name, value, context, true, makeDefault); > } > > > *************** > *** 825,830 **** > --- 868,924 ---- > } > 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 = *((struct config_string *) record)->variable; > + 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: src/include/utils/guc.h > =================================================================== > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/utils/guc.h,v > retrieving revision 1.6 > diff -c -r1.6 guc.h > *** src/include/utils/guc.h 2001/03/22 04:01:12 1.6 > --- src/include/utils/guc.h 2001/06/02 11:05:23 > *************** > *** 46,57 **** > } GucContext; > > > ! void SetConfigOption(const char *name, const char *value, GucContext context); > 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); > > > extern bool Debug_print_query; > --- 46,58 ---- > } GucContext; > > > ! 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 makeDefault); > ! void ShowAllGUCConfig(void); > > > extern bool Debug_print_query; > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> > Ok, now I am awake. How about this one? > > reset all: command line and .conf options change defaults > on RESET ALL those are restored. > > show all: GUC + non-GUC. I have applied this patch with minor modifications to make it more meaningful. I added meaningful default values if not set, and changed function names of set/reset/parse_date to *_datestyle to match the actual meaning of the value. There is no clear distinction between set-able and non-setable because RESET ALL just calls the GUC code to set variables as though the backend was just starting up. Seems quite difficult to make that distinction in the code and I am not sure it is worth it. Here is the SHOW ALL output. NOTICE: enable_seqscan is on NOTICE: enable_indexscan is on NOTICE: enable_tidscan is on NOTICE: enable_sort is on NOTICE: enable_nestloop is on NOTICE: enable_mergejoin is on NOTICE: enable_hashjoin is on NOTICE: ksqo is off NOTICE: geqo is on NOTICE: tcpip_socket is on NOTICE: ssl is off NOTICE: fsync is off NOTICE: silent_mode is off NOTICE: log_connections is off NOTICE: log_timestamp is off NOTICE: log_pid is off NOTICE: debug_assertions is on NOTICE: debug_print_query is off NOTICE: debug_print_parse is off NOTICE: debug_print_rewritten is off NOTICE: debug_print_plan is off NOTICE: debug_pretty_print is off NOTICE: show_parser_stats is off NOTICE: show_planner_stats is off NOTICE: show_executor_stats is off NOTICE: show_query_stats is off NOTICE: trace_notify is off NOTICE: hostname_lookup is off NOTICE: show_source_port is off NOTICE: sql_inheritance is on NOTICE: fixbtree is on NOTICE: geqo_threshold is 11 NOTICE: geqo_pool_size is 0 NOTICE: geqo_effort is 1 NOTICE: geqo_generations is 0 NOTICE: geqo_random_seed is -1 NOTICE: deadlock_timeout is 1000 NOTICE: max_connections is 32 NOTICE: shared_buffers is 64 NOTICE: port is 5432 NOTICE: sort_mem is 512 NOTICE: debug_level is 0 NOTICE: max_expr_depth is 10000 NOTICE: unix_socket_permissions is 511 NOTICE: checkpoint_segments is 3 NOTICE: checkpoint_timeout is 300 NOTICE: wal_buffers is 8 NOTICE: wal_files is 0 NOTICE: wal_debug is 0 NOTICE: commit_delay is 0 NOTICE: commit_siblings is 5 NOTICE: effective_cache_size is 1000 NOTICE: random_page_cost is 4 NOTICE: cpu_tuple_cost is 0.01 NOTICE: cpu_index_tuple_cost is 0.001 NOTICE: cpu_operator_cost is 0.0025 NOTICE: geqo_selection_bias is 2 NOTICE: dynamic_library_path is $libdir NOTICE: krb_server_keyfile is unset NOTICE: unix_socket_group is unset NOTICE: unix_socket_directory is unset NOTICE: virtual_host is unset NOTICE: wal_sync_method is fsync NOTICE: DateStyle is ISO with US (NonEuropean) conventions NOTICE: Time zone is unset NOTICE: Default TRANSACTION ISOLATION LEVEL is READ COMMITTED NOTICE: TRANSACTION ISOLATION LEVEL is READ COMMITTED NOTICE: Current client encoding is SQL_ASCII NOTICE: Current server encoding is SQL_ASCII NOTICE: Seed for random number generator is unavailable SHOW VARIABLE -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: doc/src/sgml/ref/reset.sgml =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v retrieving revision 1.10 diff -c -r1.10 reset.sgml *** doc/src/sgml/ref/reset.sgml 2000/12/25 23:15:26 1.10 --- doc/src/sgml/ref/reset.sgml 2001/06/07 04:43:17 *************** *** 16,21 **** --- 16,24 ---- <synopsis> RESET <replaceable class="PARAMETER">variable</replaceable> </synopsis> + <synopsis> + RESET ALL + </synopsis> <refsect2 id="R2-SQL-RESET-1"> <title>Inputs</title> *************** *** 27,32 **** --- 30,43 ---- <para> The name of a run-time parameter. See <xref linkend="sql-set" endterm="sql-set-title"> for a list. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ALL</term> + <listitem> + <para> + Resets all run-time parameters to default values. </para> </listitem> </varlistentry> Index: doc/src/sgml/ref/show.sgml =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v retrieving revision 1.11 diff -c -r1.11 show.sgml *** doc/src/sgml/ref/show.sgml 2000/12/25 23:15:26 1.11 --- doc/src/sgml/ref/show.sgml 2001/06/07 04:43:17 *************** *** 16,21 **** --- 16,24 ---- <synopsis> SHOW <replaceable class="PARAMETER">name</replaceable> </synopsis> + <synopsis> + SHOW ALL + </synopsis> <refsect2 id="R2-SQL-SHOW-1"> <title>Inputs</title> *************** *** 29,34 **** --- 32,45 ---- The name of a run-time parameter. See <xref linkend="sql-set" endterm="sql-set-title"> for a list. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ALL</term> + <listitem> + <para> + Show all current session parameters. </para> </listitem> </varlistentry> Index: src/backend/commands/variable.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/variable.c,v retrieving revision 1.48 diff -c -r1.48 variable.c *** src/backend/commands/variable.c 2001/05/08 21:06:42 1.48 --- src/backend/commands/variable.c 2001/06/07 04:43:17 *************** *** 39,47 **** #endif ! static bool show_date(void); ! static bool reset_date(void); ! static bool parse_date(char *); static bool show_timezone(void); static bool reset_timezone(void); static bool parse_timezone(char *); --- 39,47 ---- #endif ! 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 *); *************** *** 192,198 **** static bool DefaultEuroDates; static bool ! parse_date(char *value) { char *tok; int dcnt = 0, --- 192,198 ---- static bool DefaultEuroDates; static bool ! parse_datestyle(char *value) { char *tok; int dcnt = 0, *************** *** 200,206 **** if (value == NULL) { ! reset_date(); return TRUE; } --- 200,206 ---- if (value == NULL) { ! reset_datestyle(); return TRUE; } *************** *** 261,267 **** } static bool ! show_date(void) { char buf[64]; --- 261,267 ---- } static bool ! show_datestyle(void) { char buf[64]; *************** *** 291,297 **** } static bool ! reset_date(void) { DateStyle = DefaultDateStyle; EuroDates = DefaultEuroDates; --- 291,297 ---- } static bool ! reset_datestyle(void) { DateStyle = DefaultDateStyle; EuroDates = DefaultEuroDates; *************** *** 325,331 **** DBDate = strdup(DBDate); /* Parse desired setting into DateStyle/EuroDates */ ! parse_date(DBDate); free(DBDate); --- 325,331 ---- DBDate = strdup(DBDate); /* Parse desired setting into DateStyle/EuroDates */ ! parse_datestyle(DBDate); free(DBDate); *************** *** 396,402 **** tz = getenv("TZ"); ! elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unknown")); return TRUE; } /* show_timezone() */ --- 396,402 ---- tz = getenv("TZ"); ! elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unset")); return TRUE; } /* show_timezone() */ *************** *** 586,592 **** static bool show_random_seed(void) { ! elog(NOTICE, "Seed for random number generator is not known"); return (TRUE); } --- 586,592 ---- static bool show_random_seed(void) { ! elog(NOTICE, "Seed for random number generator is unavailable"); return (TRUE); } *************** *** 708,714 **** * Special cases ought to be removed and handled separately by TCOP */ if (strcasecmp(name, "datestyle") == 0) ! parse_date(mvalue); else if (strcasecmp(name, "timezone") == 0) parse_timezone(mvalue); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) --- 708,714 ---- * Special cases ought to be removed and handled separately by TCOP */ if (strcasecmp(name, "datestyle") == 0) ! parse_datestyle(mvalue); else if (strcasecmp(name, "timezone") == 0) parse_timezone(mvalue); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) *************** *** 724,741 **** else if (strcasecmp(name, "session_authorization") == 0) SetSessionAuthorization(value); else ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET); if (mvalue) pfree(mvalue); } - void GetPGVariable(const char *name) { if (strcasecmp(name, "datestyle") == 0) ! show_date(); else if (strcasecmp(name, "timezone") == 0) show_timezone(); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) --- 724,740 ---- else if (strcasecmp(name, "session_authorization") == 0) SetSessionAuthorization(value); else ! SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET, false); if (mvalue) pfree(mvalue); } void GetPGVariable(const char *name) { if (strcasecmp(name, "datestyle") == 0) ! show_datestyle(); else if (strcasecmp(name, "timezone") == 0) show_timezone(); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) *************** *** 748,754 **** show_server_encoding(); else if (strcasecmp(name, "seed") == 0) show_random_seed(); ! else { const char *val = GetConfigOption(name); --- 747,763 ---- show_server_encoding(); else if (strcasecmp(name, "seed") == 0) show_random_seed(); ! 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); *************** *** 760,766 **** ResetPGVariable(const char *name) { if (strcasecmp(name, "datestyle") == 0) ! reset_date(); else if (strcasecmp(name, "timezone") == 0) reset_timezone(); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) --- 769,775 ---- ResetPGVariable(const char *name) { if (strcasecmp(name, "datestyle") == 0) ! reset_datestyle(); else if (strcasecmp(name, "timezone") == 0) reset_timezone(); else if (strcasecmp(name, "DefaultXactIsoLevel") == 0) *************** *** 773,778 **** reset_server_encoding(); else if (strcasecmp(name, "seed") == 0) reset_random_seed(); ! else ! SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET); } --- 782,798 ---- reset_server_encoding(); else if (strcasecmp(name, "seed") == 0) reset_random_seed(); ! 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: src/backend/parser/gram.y =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/gram.y,v retrieving revision 2.228 diff -c -r2.228 gram.y *** src/backend/parser/gram.y 2001/06/04 23:27:23 2.228 --- src/backend/parser/gram.y 2001/06/07 04:43:21 *************** *** 860,865 **** --- 860,871 ---- n->name = "timezone"; $$ = (Node *) n; } + | SHOW ALL + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "all"; + $$ = (Node *) n; + } | SHOW TRANSACTION ISOLATION LEVEL { VariableShowStmt *n = makeNode(VariableShowStmt); *************** *** 884,889 **** --- 890,901 ---- { VariableResetStmt *n = makeNode(VariableResetStmt); n->name = "XactIsoLevel"; + $$ = (Node *) n; + } + | RESET ALL + { + VariableResetStmt *n = makeNode(VariableResetStmt); + n->name = "all"; $$ = (Node *) n; } ; Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v retrieving revision 1.216 diff -c -r1.216 postmaster.c *** src/backend/postmaster/postmaster.c 2001/06/03 14:53:56 1.216 --- src/backend/postmaster/postmaster.c 2001/06/07 04:43:23 *************** *** 533,539 **** elog(ERROR, "-c %s requires argument", optarg); } ! SetConfigOption(name, value, PGC_POSTMASTER); free(name); if (value) free(value); --- 533,539 ---- elog(ERROR, "-c %s requires argument", optarg); } ! SetConfigOption(name, value, PGC_POSTMASTER, true); free(name); if (value) free(value); Index: src/backend/tcop/postgres.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v retrieving revision 1.218 diff -c -r1.218 postgres.c *** src/backend/tcop/postgres.c 2001/04/14 19:11:45 1.218 --- src/backend/tcop/postgres.c 2001/06/07 04:43:29 *************** *** 1462,1468 **** /* all options are allowed if not under postmaster */ SetConfigOption(name, value, ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER); free(name); if (value) free(value); --- 1462,1468 ---- /* all options are allowed if not under postmaster */ SetConfigOption(name, value, ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true); free(name); if (value) free(value); Index: src/backend/utils/misc/guc-file.l =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v retrieving revision 1.7 diff -c -r1.7 guc-file.l *** src/backend/utils/misc/guc-file.l 2001/06/01 20:29:43 1.7 --- src/backend/utils/misc/guc-file.l 2001/06/07 04:43:29 *************** *** 260,272 **** */ for(item = head; item; item=item->next) { ! if (!set_config_option(item->name, item->value, context, 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); cleanup_exit: free_name_value_list(head); --- 260,272 ---- */ for(item = head; item; item=item->next) { ! 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, true); cleanup_exit: free_name_value_list(head); Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v retrieving revision 1.36 diff -c -r1.36 guc.c *** src/backend/utils/misc/guc.c 2001/05/17 17:44:18 1.36 --- src/backend/utils/misc/guc.c 2001/06/07 04:43:30 *************** *** 136,144 **** const char *name; GucContext context; char **variable; ! const char *default_val; bool (*parse_hook) (const char *proposed); void (*assign_hook) (const char *newval); }; --- 136,145 ---- const char *name; GucContext context; char **variable; ! const char *boot_default_val; bool (*parse_hook) (const char *proposed); void (*assign_hook) (const char *newval); + char *default_val; }; *************** *** 433,438 **** --- 434,448 ---- { 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,588 **** */ bool set_config_option(const char *name, const char *value, GucContext ! context, bool DoIt) { struct config_generic *record; enum config_type type; --- 592,598 ---- */ bool set_config_option(const char *name, const char *value, GucContext ! context, bool DoIt, bool makeDefault) { struct config_generic *record; enum config_type type; *************** *** 653,659 **** --- 663,673 ---- return false; } if (DoIt) + { *conf->variable = boolval; + if (makeDefault) + conf->default_val = boolval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 681,687 **** --- 695,705 ---- return false; } if (DoIt) + { *conf->variable = intval; + if (makeDefault) + conf->default_val = intval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 709,715 **** --- 727,737 ---- return false; } if (DoIt) + { *conf->variable = dval; + if (makeDefault) + conf->default_val = dval; + } } else if (DoIt) *conf->variable = conf->default_val; *************** *** 742,753 **** --- 764,796 ---- 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,784 **** */ void SetConfigOption(const char *name, const char *value, GucContext ! context) { ! (void) set_config_option(name, value, context, true); } --- 819,827 ---- */ void SetConfigOption(const char *name, const char *value, GucContext ! context, bool makeDefault) { ! (void) set_config_option(name, value, context, true, makeDefault); } *************** *** 825,830 **** --- 868,925 ---- } 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: src/include/utils/guc.h =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/utils/guc.h,v retrieving revision 1.6 diff -c -r1.6 guc.h *** src/include/utils/guc.h 2001/03/22 04:01:12 1.6 --- src/include/utils/guc.h 2001/06/07 04:43:32 *************** *** 46,57 **** } GucContext; ! void SetConfigOption(const char *name, const char *value, GucContext context); 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); extern bool Debug_print_query; --- 46,58 ---- } GucContext; ! 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 makeDefault); ! void ShowAllGUCConfig(void); extern bool Debug_print_query;
On Thu, Jun 07, 2001 at 12:50:21AM -0400, Bruce Momjian wrote: > > > > Ok, now I am awake. How about this one? > > > > reset all: command line and .conf options change defaults > > on RESET ALL those are restored. > > > > show all: GUC + non-GUC. > > I have applied this patch with minor modifications to make it more > meaningful. I added meaningful default values if not set, and changed > function names of set/reset/parse_date to *_datestyle to match the > actual meaning of the value. Fine. > There is no clear distinction between set-able and non-setable because > RESET ALL just calls the GUC code to set variables as though the backend > was just starting up. Seems quite difficult to make that distinction in > the code and I am not sure it is worth it. It is not needed, as on non-SETable values will have value == default_val. Same goes for permissions, if user has no right to SET a value, the reset will do nothing. At least in my understanding it is ok already. Although - one thing that is worth adding is checking on RESET if var has changed - if not then do nothing. _And_ if it is, the RESET should go through set_, so the callbacks get called too (ATM they are not). This means splitting the set_config_option() up, set_config_option_real() should take then the actual record. The SHOW output should be reworked some time, but this is not possible until we have tuples-returning-funtions. -- marko
Bruce Momjian <pgman@candle.pha.pa.us> writes: > ! 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 This looks fairly bogus, given the comment on ResetAllOptions: /* * Reset all options to their specified default values. Should only be * called at program startup. */ Or is that OK now with the "makeDefault" addition to SetConfigOption? Peter, your thoughts please? (If it is OK, the patch needs to change this comment. Some additional commentary about what exactly the makeDefault switch does would be appropriate too, since it's not real clear exactly how "default" the value is becoming.) I also wonder whether it's a good idea to reset the client encoding here... it might be correct in a pure sense, but isn't it likely to break the client? regards, tom lane
> Bruce Momjian <pgman@candle.pha.pa.us> writes: > > ! 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 > > This looks fairly bogus, given the comment on ResetAllOptions: > > /* > * Reset all options to their specified default values. Should only be > * called at program startup. > */ > > Or is that OK now with the "makeDefault" addition to SetConfigOption? > Peter, your thoughts please? (If it is OK, the patch needs to change > this comment. Some additional commentary about what exactly the > makeDefault switch does would be appropriate too, since it's not real > clear exactly how "default" the value is becoming.) > > I also wonder whether it's a good idea to reset the client encoding > here... it might be correct in a pure sense, but isn't it likely to > break the client? I assumed those were items not controlled by postgresql.conf like isolation level. Also, do we have a way to clear transaction state? Is BEGIN;COMMIT; the clean way to do it? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Tom Lane writes: > This looks fairly bogus, given the comment on ResetAllOptions: > > /* > * Reset all options to their specified default values. Should only be > * called at program startup. > */ > > Or is that OK now with the "makeDefault" addition to SetConfigOption? Evidently not quite: peter=# show port; NOTICE: port is 6543 SHOW VARIABLE peter=# reset all; RESET VARIABLE peter=# show port; NOTICE: port is 5432 SHOW VARIABLE This is because I started the postmaster with -p 6543, but that assigns to the variable directly and does not save it as default. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Looks like this is fixed in the pending patch that uses GUC calls to set variables from the command line. > Tom Lane writes: > > > This looks fairly bogus, given the comment on ResetAllOptions: > > > > /* > > * Reset all options to their specified default values. Should only be > > * called at program startup. > > */ > > > > Or is that OK now with the "makeDefault" addition to SetConfigOption? > > Evidently not quite: > > peter=# show port; > NOTICE: port is 6543 > SHOW VARIABLE > peter=# reset all; > RESET VARIABLE > peter=# show port; > NOTICE: port is 5432 > SHOW VARIABLE > > This is because I started the postmaster with -p 6543, but that assigns to > the variable directly and does not save it as default. > > -- > Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Peter Eisentraut <peter_e@gmx.net> writes: >> Or is that OK now with the "makeDefault" addition to SetConfigOption? > Evidently not quite: > peter=# show port; > NOTICE: port is 6543 > SHOW VARIABLE > peter=# reset all; > RESET VARIABLE > peter=# show port; > NOTICE: port is 5432 > SHOW VARIABLE I've fixed this. regards, tom lane