Applied. Thanks.
> Hi,
>
> I have added the pg_options variable to the SET command. It can be executed
> only by the superuser and is intended mainly as a debugging aid.
> I have also moved the disableFsync variable to the pg_options array, so it
> can now be set in the pg_options file or interactively with the commands:
>
> SET pg_options to 'nofsinc=1';
> SET pg_options to 'nofsinc=0';
>
> There are obviously also the SHOW and RESET pg_options commands.
>
>
> *** src/backend/commands/variable.c.orig Wed May 26 09:02:48 1999
> --- src/backend/commands/variable.c Mon Jun 14 20:45:58 1999
> ***************
> *** 15,20 ****
> --- 15,22 ----
> #include "commands/variable.h"
> #include "utils/builtins.h"
> #include "optimizer/internal.h"
> + #include "utils/trace.h"
> + #include "catalog/pg_shadow.h"
> #include "access/xact.h"
> #ifdef MULTIBYTE
> #include "mb/pg_wchar.h"
> ***************
> *** 581,589 ****
> ExecutorLimit(ALL_TUPLES);
> return (TRUE);
> }
> -
> #endif
>
> /*-----------------------------------------------------------------------*/
>
> struct VariableParsers
> --- 583,622 ----
> ExecutorLimit(ALL_TUPLES);
> return (TRUE);
> }
> #endif
>
> + /*
> + *
> + * Pg_options
> + *
> + */
> + static bool
> + parse_pg_options(const char *value)
> + {
> + if (!superuser()) {
> + elog(ERROR, "Only users with Postgres superuser can set pg_options");
> + }
> + parse_options((char *) value, TRUE);
> + return (TRUE);
> + }
> +
> + static bool
> + show_pg_options(void)
> + {
> + show_options();
> + return (TRUE);
> + }
> +
> + static bool
> + reset_pg_options(void)
> + {
> + if (!superuser()) {
> + elog(ERROR, "Only users with Postgres superuser can set pg_options");
> + }
> + read_pg_options(0);
> + return (TRUE);
> + }
> +
> /*-----------------------------------------------------------------------*/
>
> struct VariableParsers
> ***************
> *** 629,634 ****
> --- 662,670 ----
> "query_limit", parse_query_limit, show_query_limit, reset_query_limit
> },
> #endif
> + {
> + "pg_options", parse_pg_options, show_pg_options, reset_pg_options
> + },
> {
> NULL, NULL, NULL, NULL
> }
> *** src/backend/utils/init/globals.c.orig Wed May 26 09:05:49 1999
> --- src/backend/utils/init/globals.c Mon Jun 14 20:56:34 1999
> ***************
> *** 82,88 ****
> * malloc? XXX */
> char FloatFormat[20] = "%f";
>
> ! bool disableFsync = false;
> bool allowSystemTableMods = false;
> int SortMem = 512;
>
> --- 82,88 ----
> * malloc? XXX */
> char FloatFormat[20] = "%f";
>
> ! /* bool disableFsync = false; */
> bool allowSystemTableMods = false;
> int SortMem = 512;
>
> *** src/include/miscadmin.h.orig Wed May 26 09:06:39 1999
> --- src/include/miscadmin.h Mon Jun 14 20:01:27 1999
> ***************
> *** 22,27 ****
> --- 22,29 ----
> #ifndef MISCADMIN_H
> #define MISCADMIN_H
>
> + #include "utils/trace.h"
> +
> /*****************************************************************************
> * globals.h -- *
> *****************************************************************************/
> ***************
> *** 93,99 ****
> extern char FloatFormat[];
> extern char DateFormat[];
>
> ! extern bool disableFsync;
> extern bool allowSystemTableMods;
> extern int SortMem;
>
> --- 95,103 ----
> extern char FloatFormat[];
> extern char DateFormat[];
>
> ! /* extern bool disableFsync; */
> ! #define disableFsync pg_options[OPT_NOFSYNC]
> !
> extern bool allowSystemTableMods;
> extern int SortMem;
>
> *** src/bin/psql/psqlHelp.h.orig Fri Jun 4 09:00:17 1999
> --- src/bin/psql/psqlHelp.h Mon Jun 14 20:17:45 1999
> ***************
> *** 297,303 ****
> "set run-time environment back to default",
> "\
> \tRESET DATESTYLE|COST_HEAP|COST_INDEX|GEQO|KSQO|QUERY_LIMIT|\n\
> ! TIMEZONE|XACTISOLEVEL|CLIENT_ENCODING|SERVER_ENCODING"},
> {"revoke",
> "revoke access control from a user or group",
> "\
> --- 297,303 ----
> "set run-time environment back to default",
> "\
> \tRESET DATESTYLE|COST_HEAP|COST_INDEX|GEQO|KSQO|QUERY_LIMIT|\n\
> ! \t TIMEZONE|XACTISOLEVEL|CLIENT_ENCODING|SERVER_ENCODING|PG_OPTIONS"},
> {"revoke",
> "revoke access control from a user or group",
> "\
> ***************
> *** 331,336 ****
> --- 331,337 ----
> \tSET KSQO TO 'ON'|'OFF'\n\
> \tSET QUERY_LIMIT TO #\n\
> \tSET TIMEZONE TO 'value'\n\
> + \tSET PG_OPTIONS TO 'value'\n\
> \tSET TRANSACTION ISOLATION LEVEL 'SERIALIZABLE'|'READ COMMITTED'\n\
> \tSET CLIENT_ENCODING|NAMES TO 'EUC_JP'|'SJIS'|'EUC_CN'|'EUC_KR'|'EUC_TW'|\n\
> \t 'BIG5'|'MULE_INTERNAL'|'LATIN1'|'LATIN2'|'LATIN3'|'LATIN4'|'LATIN5'|\n\
> ***************
> *** 342,348 ****
> "show current run-time environment",
> "\
> \tSHOW DATESTYLE|COST_HEAP|COST_INDEX|GEQO|KSQO|QUERY_LIMIT|\n\
> ! TIMEZONE|XACTISOLEVEL|CLIENT_ENCODING|SERVER_ENCODING"},
> {"unlisten",
> "stop listening for notification on a condition name",
> "\
> --- 343,349 ----
> "show current run-time environment",
> "\
> \tSHOW DATESTYLE|COST_HEAP|COST_INDEX|GEQO|KSQO|QUERY_LIMIT|\n\
> ! \t TIMEZONE|XACTISOLEVEL|CLIENT_ENCODING|SERVER_ENCODING|PG_OPTIONS"},
> {"unlisten",
> "stop listening for notification on a condition name",
> "\
> *** src/include/utils/trace.h.orig Sat Jun 12 22:45:23 1999
> --- src/include/utils/trace.h Mon Jun 14 20:50:56 1999
> ***************
> *** 30,38 ****
> --- 30,39 ----
> extern int tprintf(int flag, const char *fmt,...);
> extern int eprintf(const char *fmt,...);
> extern void write_syslog(int level, char *line);
> + extern void show_options(void);
> extern void parse_options(char *str, bool secure);
> extern void read_pg_options(SIGNAL_ARGS);
>
> /*
> * Trace options, used as index into pg_options.
> * Must match the constants in pg_options[].
> ***************
> *** 61,66 ****
> --- 61,67 ----
> TRACE_LOCKRELATION,
> OPT_LOCKREADPRIORITY, /* lock priority, see lock.c */
> OPT_DEADLOCKTIMEOUT, /* deadlock timeout, see proc.c */
> + OPT_NOFSYNC, /* turn fsync off */
> OPT_SYSLOG, /* use syslog for error messages */
> OPT_HOSTLOOKUP, /* enable hostname lookup in ps_status */
> OPT_SHOWPORTNUMBER, /* show port number in ps_status */
> *** src/backend/utils/misc/trace.c.orig Sat Jun 12 22:47:32 1999
> --- src/backend/utils/misc/trace.c Mon Jun 14 20:50:06 1999
> ***************
> *** 70,75 ****
> --- 70,76 ----
> "lock_debug_relid",
> "lock_read_priority", /* lock priority, see lock.c */
> "deadlock_timeout", /* deadlock timeout, see proc.c */
> + "nofsync", /* turn fsync off */
> "syslog", /* use syslog for error messages */
> "hostlookup", /* enable hostname lookup in ps_status */
> "showportnumber", /* show port number in ps_status */
> ***************
> *** 407,412 ****
> --- 407,422 ----
> close(fd);
> }
>
> + void
> + show_options(void)
> + {
> + int i;
> +
> + for (i=0; i<NUM_PG_OPTIONS; i++) {
> + elog(NOTICE, "%s=%d", opt_names[i], pg_options[i]);
> + }
> + }
> +
> /*
> * Local Variables:
> * tab-width: 4
> *** src/backend/bootstrap/bootstrap.c.orig Wed May 26 09:02:25 1999
> --- src/backend/bootstrap/bootstrap.c Mon Jun 14 20:06:00 1999
> ***************
> *** 182,188 ****
> Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
> static char *values[MAXATTR]; /* cooresponding attribute values */
> int numattr; /* number of attributes for cur. rel */
> ! extern bool disableFsync; /* do not fsync the database */
>
> int DebugMode;
> static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
> --- 182,188 ----
> Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
> static char *values[MAXATTR]; /* cooresponding attribute values */
> int numattr; /* number of attributes for cur. rel */
> ! /* extern bool disableFsync; */ /* do not fsync the database */
>
> int DebugMode;
> static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
>
>
> --
> Massimo Dal Zotto
>
> +----------------------------------------------------------------------+
> | Massimo Dal Zotto email: dz@cs.unitn.it |
> | Via Marconi, 141 phone: ++39-0461534251 |
> | 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
> | Italy pgp: finger dz@tango.cs.unitn.it |
> +----------------------------------------------------------------------+
>
-- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026