Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions | Variables

guc.c File Reference

#include "postgres.h"
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <unistd.h>
#include <sys/stat.h>
#include "access/gin.h"
#include "access/transam.h"
#include "access/twophase.h"
#include "access/xact.h"
#include "catalog/namespace.h"
#include "commands/async.h"
#include "commands/prepare.h"
#include "commands/vacuum.h"
#include "commands/variable.h"
#include "commands/trigger.h"
#include "funcapi.h"
#include "libpq/auth.h"
#include "libpq/be-fsstubs.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "optimizer/geqo.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
#include "parser/parser.h"
#include "parser/scansup.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker.h"
#include "postmaster/bgwriter.h"
#include "postmaster/postmaster.h"
#include "postmaster/syslogger.h"
#include "postmaster/walwriter.h"
#include "replication/syncrep.h"
#include "replication/walreceiver.h"
#include "replication/walsender.h"
#include "storage/bufmgr.h"
#include "storage/standby.h"
#include "storage/fd.h"
#include "storage/proc.h"
#include "storage/predicate.h"
#include "tcop/tcopprot.h"
#include "tsearch/ts_cache.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/guc_tables.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/plancache.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.h"
#include "utils/xml.h"
#include "guc-file.c"

Go to the source code of this file.

Defines

#define PG_KRB_SRVTAB   ""
#define PG_KRB_SRVNAM   ""
#define CONFIG_FILENAME   "postgresql.conf"
#define HBA_FILENAME   "pg_hba.conf"
#define IDENT_FILENAME   "pg_ident.conf"
#define MAX_KILOBYTES   (INT_MAX / 1024)
#define KB_PER_MB   (1024)
#define KB_PER_GB   (1024*1024)
#define MS_PER_S   1000
#define S_PER_MIN   60
#define MS_PER_MIN   (1000 * 60)
#define MIN_PER_H   60
#define S_PER_H   (60 * 60)
#define MS_PER_H   (1000 * 60 * 60)
#define MIN_PER_D   (60 * 24)
#define S_PER_D   (60 * 60 * 24)
#define MS_PER_D   (1000 * 60 * 60 * 24)
#define NUM_PG_SETTINGS_ATTS   16

Functions

static void set_config_sourcefile (const char *name, char *sourcefile, int sourceline)
static bool call_bool_check_hook (struct config_bool *conf, bool *newval, void **extra, GucSource source, int elevel)
static bool call_int_check_hook (struct config_int *conf, int *newval, void **extra, GucSource source, int elevel)
static bool call_real_check_hook (struct config_real *conf, double *newval, void **extra, GucSource source, int elevel)
static bool call_string_check_hook (struct config_string *conf, char **newval, void **extra, GucSource source, int elevel)
static bool call_enum_check_hook (struct config_enum *conf, int *newval, void **extra, GucSource source, int elevel)
static bool check_log_destination (char **newval, void **extra, GucSource source)
static void assign_log_destination (const char *newval, void *extra)
static void assign_syslog_facility (int newval, void *extra)
static void assign_syslog_ident (const char *newval, void *extra)
static void assign_session_replication_role (int newval, void *extra)
static bool check_temp_buffers (int *newval, void **extra, GucSource source)
static bool check_phony_autocommit (bool *newval, void **extra, GucSource source)
static bool check_debug_assertions (bool *newval, void **extra, GucSource source)
static bool check_bonjour (bool *newval, void **extra, GucSource source)
static bool check_ssl (bool *newval, void **extra, GucSource source)
static bool check_stage_log_stats (bool *newval, void **extra, GucSource source)
static bool check_log_stats (bool *newval, void **extra, GucSource source)
static bool check_canonical_path (char **newval, void **extra, GucSource source)
static bool check_timezone_abbreviations (char **newval, void **extra, GucSource source)
static void assign_timezone_abbreviations (const char *newval, void *extra)
static void pg_timezone_abbrev_initialize (void)
static const char * show_archive_command (void)
static void assign_tcp_keepalives_idle (int newval, void *extra)
static void assign_tcp_keepalives_interval (int newval, void *extra)
static void assign_tcp_keepalives_count (int newval, void *extra)
static const char * show_tcp_keepalives_idle (void)
static const char * show_tcp_keepalives_interval (void)
static const char * show_tcp_keepalives_count (void)
static bool check_maxconnections (int *newval, void **extra, GucSource source)
static bool check_autovacuum_max_workers (int *newval, void **extra, GucSource source)
static bool check_effective_io_concurrency (int *newval, void **extra, GucSource source)
static void assign_effective_io_concurrency (int newval, void *extra)
static void assign_pgstat_temp_directory (const char *newval, void *extra)
static bool check_application_name (char **newval, void **extra, GucSource source)
static void assign_application_name (const char *newval, void *extra)
static const char * show_unix_socket_permissions (void)
static const char * show_log_file_mode (void)
static char * config_enum_get_options (struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
static int guc_var_compare (const void *a, const void *b)
static int guc_name_compare (const char *namea, const char *nameb)
static void InitializeGUCOptionsFromEnvironment (void)
static void InitializeOneGUCOption (struct config_generic *gconf)
static void push_old_value (struct config_generic *gconf, GucAction action)
static void ReportGUCOption (struct config_generic *record)
static void reapply_stacked_values (struct config_generic *variable, struct config_string *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource)
static void ShowGUCConfigOption (const char *name, DestReceiver *dest)
static void ShowAllGUCConfig (DestReceiver *dest)
static char * _ShowOption (struct config_generic *record, bool use_units)
static bool validate_option_array_item (const char *name, const char *value, bool skipIfNoPermissions)
static void * guc_malloc (int elevel, size_t size)
static void * guc_realloc (int elevel, void *old, size_t size)
static char * guc_strdup (int elevel, const char *src)
static bool string_field_used (struct config_string *conf, char *strval)
static void set_string_field (struct config_string *conf, char **field, char *newval)
static bool extra_field_used (struct config_generic *gconf, void *extra)
static void set_extra_field (struct config_generic *gconf, void **field, void *newval)
static void set_stack_value (struct config_generic *gconf, config_var_value *val)
static void discard_stack_value (struct config_generic *gconf, config_var_value *val)
struct config_generic ** get_guc_variables (void)
void build_guc_variables (void)
static bool add_guc_variable (struct config_generic *var, int elevel)
static struct config_genericadd_placeholder_variable (const char *name, int elevel)
static struct config_genericfind_option (const char *name, bool create_placeholders, int elevel)
void InitializeGUCOptions (void)
bool SelectConfigFiles (const char *userDoption, const char *progname)
void ResetAllOptions (void)
void AtStart_GUC (void)
int NewGUCNestLevel (void)
void AtEOXact_GUC (bool isCommit, int nestLevel)
void BeginReportingGUCOptions (void)
bool parse_int (const char *value, int *result, int flags, const char **hintmsg)
bool parse_real (const char *value, double *result)
const char * config_enum_lookup_by_value (struct config_enum *record, int val)
bool config_enum_lookup_by_name (struct config_enum *record, const char *value, int *retval)
int set_config_option (const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel)
void SetConfigOption (const char *name, const char *value, GucContext context, GucSource source)
const char * GetConfigOption (const char *name, bool missing_ok, bool restrict_superuser)
const char * GetConfigOptionResetString (const char *name)
static char * flatten_set_variable_args (const char *name, List *args)
void ExecSetVariableStmt (VariableSetStmt *stmt)
char * ExtractSetVariableArgs (VariableSetStmt *stmt)
void SetPGVariable (const char *name, List *args, bool is_local)
Datum set_config_by_name (PG_FUNCTION_ARGS)
static struct config_genericinit_custom_variable (const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
static void define_custom_variable (struct config_generic *variable)
void DefineCustomBoolVariable (const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)
void DefineCustomIntVariable (const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, int minValue, int maxValue, GucContext context, int flags, GucIntCheckHook check_hook, GucIntAssignHook assign_hook, GucShowHook show_hook)
void DefineCustomRealVariable (const char *name, const char *short_desc, const char *long_desc, double *valueAddr, double bootValue, double minValue, double maxValue, GucContext context, int flags, GucRealCheckHook check_hook, GucRealAssignHook assign_hook, GucShowHook show_hook)
void DefineCustomStringVariable (const char *name, const char *short_desc, const char *long_desc, char **valueAddr, const char *bootValue, GucContext context, int flags, GucStringCheckHook check_hook, GucStringAssignHook assign_hook, GucShowHook show_hook)
void DefineCustomEnumVariable (const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, const struct config_enum_entry *options, GucContext context, int flags, GucEnumCheckHook check_hook, GucEnumAssignHook assign_hook, GucShowHook show_hook)
void EmitWarningsOnPlaceholders (const char *className)
void GetPGVariable (const char *name, DestReceiver *dest)
TupleDesc GetPGVariableResultDesc (const char *name)
char * GetConfigOptionByName (const char *name, const char **varname)
void GetConfigOptionByNum (int varnum, const char **values, bool *noshow)
int GetNumConfigOptions (void)
Datum show_config_by_name (PG_FUNCTION_ARGS)
Datum show_all_settings (PG_FUNCTION_ARGS)
void ParseLongOption (const char *string, char **name, char **value)
void ProcessGUCArray (ArrayType *array, GucContext context, GucSource source, GucAction action)
ArrayTypeGUCArrayAdd (ArrayType *array, const char *name, const char *value)
ArrayTypeGUCArrayDelete (ArrayType *array, const char *name)
ArrayTypeGUCArrayReset (ArrayType *array)
void GUC_check_errcode (int sqlerrcode)

Variables

bool Log_disconnections
int CommitDelay
int CommitSiblings
char * default_tablespace
char * temp_tablespaces
bool ignore_checksum_failure
bool synchronize_seqscans
int ssl_renegotiation_limit
char * SSLCipherSuites
static int GUC_check_errcode_value
char * GUC_check_errmsg_string
char * GUC_check_errdetail_string
char * GUC_check_errhint_string
static int syslog_facility = 0
static struct config_enum_entry bytea_output_options []
static struct config_enum_entry client_message_level_options []
static struct config_enum_entry server_message_level_options []
static struct config_enum_entry intervalstyle_options []
static struct config_enum_entry log_error_verbosity_options []
static struct config_enum_entry log_statement_options []
static struct config_enum_entry isolation_level_options []
static struct config_enum_entry session_replication_role_options []
static struct config_enum_entry syslog_facility_options []
static struct config_enum_entry track_function_options []
static struct config_enum_entry xmlbinary_options []
static struct config_enum_entry xmloption_options []
static struct config_enum_entry backslash_quote_options []
static struct config_enum_entry constraint_exclusion_options []
static struct config_enum_entry synchronous_commit_options []
struct config_enum_entry wal_level_options []
struct config_enum_entry sync_method_options []
bool assert_enabled = false
bool log_duration = false
bool Debug_print_plan = false
bool Debug_print_parse = false
bool Debug_print_rewritten = false
bool Debug_pretty_print = true
bool log_parser_stats = false
bool log_planner_stats = false
bool log_executor_stats = false
bool log_statement_stats = false
bool log_btree_build_stats = false
char * event_source
bool check_function_bodies = true
bool default_with_oids = false
bool SQL_inheritance = true
bool Password_encryption = true
int log_min_error_statement = ERROR
int log_min_messages = WARNING
int client_min_messages = NOTICE
int log_min_duration_statement = -1
int log_temp_files = -1
int trace_recovery_messages = LOG
int temp_file_limit = -1
int num_temp_buffers = 1024
char * data_directory
char * ConfigFileName
char * HbaFileName
char * IdentFileName
char * external_pid_file
char * pgstat_temp_directory
char * application_name
int tcp_keepalives_idle
int tcp_keepalives_interval
int tcp_keepalives_count
static char * log_destination_string
static char * syslog_ident_str
static bool phony_autocommit
static bool session_auth_is_superuser
static double phony_random_seed
static char * client_encoding_string
static char * datestyle_string
static char * locale_collate
static char * locale_ctype
static char * server_encoding_string
static char * server_version_string
static int server_version_num
static char * timezone_string
static char * log_timezone_string
static char * timezone_abbreviations_string
static char * XactIsoLevel_string
static char * session_authorization_string
static int max_function_args
static int max_index_keys
static int max_identifier_length
static int block_size
static int segment_size
static int wal_block_size
static int wal_segment_size
static bool integer_datetimes
static int effective_io_concurrency
char * role_string
const char *const GucContext_Names []
const char *const GucSource_Names []
const char *const config_group_names []
const char *const config_type_names []
static struct config_bool ConfigureNamesBool []
static struct config_int ConfigureNamesInt []
static struct config_real ConfigureNamesReal []
static struct config_string ConfigureNamesString []
static struct config_enum ConfigureNamesEnum []
static const char *const map_old_guc_names []
static struct config_generic ** guc_variables
static int num_guc_variables
static int size_guc_variables
static bool guc_dirty
static bool reporting_enabled
static int GUCNestLevel = 0

Define Documentation

#define CONFIG_FILENAME   "postgresql.conf"

Definition at line 89 of file guc.c.

Referenced by SelectConfigFiles().

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 90 of file guc.c.

Referenced by SelectConfigFiles().

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 91 of file guc.c.

Referenced by SelectConfigFiles().

#define KB_PER_GB   (1024*1024)

Definition at line 107 of file guc.c.

Referenced by _ShowOption(), and parse_int().

#define KB_PER_MB   (1024)

Definition at line 106 of file guc.c.

Referenced by _ShowOption(), and parse_int().

#define MAX_KILOBYTES   (INT_MAX / 1024)

Definition at line 103 of file guc.c.

#define MIN_PER_D   (60 * 24)

Definition at line 115 of file guc.c.

#define MIN_PER_H   60

Definition at line 112 of file guc.c.

#define MS_PER_D   (1000 * 60 * 60 * 24)

Definition at line 117 of file guc.c.

Referenced by _ShowOption().

#define MS_PER_H   (1000 * 60 * 60)

Definition at line 114 of file guc.c.

Referenced by _ShowOption().

#define MS_PER_MIN   (1000 * 60)

Definition at line 111 of file guc.c.

Referenced by _ShowOption().

#define MS_PER_S   1000

Definition at line 109 of file guc.c.

Referenced by _ShowOption().

#define NUM_PG_SETTINGS_ATTS   16

Definition at line 7220 of file guc.c.

Referenced by show_all_settings().

#define PG_KRB_SRVNAM   ""

Definition at line 86 of file guc.c.

#define PG_KRB_SRVTAB   ""

Definition at line 83 of file guc.c.

#define S_PER_D   (60 * 60 * 24)

Definition at line 116 of file guc.c.

#define S_PER_H   (60 * 60)

Definition at line 113 of file guc.c.

#define S_PER_MIN   60

Definition at line 110 of file guc.c.


Function Documentation

static char * _ShowOption ( struct config_generic record,
bool  use_units 
) [static]

Definition at line 7341 of file guc.c.

References config_enum_lookup_by_value(), config_generic::flags, GUC_UNIT_BLOCKS, GUC_UNIT_MEMORY, GUC_UNIT_MIN, GUC_UNIT_S, GUC_UNIT_TIME, GUC_UNIT_XBLOCKS, KB_PER_GB, KB_PER_MB, MS_PER_D, MS_PER_H, MS_PER_MIN, MS_PER_S, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, pstrdup(), config_enum::show_hook, config_string::show_hook, config_real::show_hook, config_int::show_hook, config_bool::show_hook, snprintf(), val, config_enum::variable, config_string::variable, config_real::variable, config_int::variable, config_bool::variable, and config_generic::vartype.

Referenced by GetConfigOptionByName(), GetConfigOptionByNum(), ReportGUCOption(), and ShowAllGUCConfig().

{
    char        buffer[256];
    const char *val;

    switch (record->vartype)
    {
        case PGC_BOOL:
            {
                struct config_bool *conf = (struct config_bool *) record;

                if (conf->show_hook)
                    val = (*conf->show_hook) ();
                else
                    val = *conf->variable ? "on" : "off";
            }
            break;

        case PGC_INT:
            {
                struct config_int *conf = (struct config_int *) record;

                if (conf->show_hook)
                    val = (*conf->show_hook) ();
                else
                {
                    /*
                     * Use int64 arithmetic to avoid overflows in units
                     * conversion.
                     */
                    int64       result = *conf->variable;
                    const char *unit;

                    if (use_units && result > 0 &&
                        (record->flags & GUC_UNIT_MEMORY))
                    {
                        switch (record->flags & GUC_UNIT_MEMORY)
                        {
                            case GUC_UNIT_BLOCKS:
                                result *= BLCKSZ / 1024;
                                break;
                            case GUC_UNIT_XBLOCKS:
                                result *= XLOG_BLCKSZ / 1024;
                                break;
                        }

                        if (result % KB_PER_GB == 0)
                        {
                            result /= KB_PER_GB;
                            unit = "GB";
                        }
                        else if (result % KB_PER_MB == 0)
                        {
                            result /= KB_PER_MB;
                            unit = "MB";
                        }
                        else
                        {
                            unit = "kB";
                        }
                    }
                    else if (use_units && result > 0 &&
                             (record->flags & GUC_UNIT_TIME))
                    {
                        switch (record->flags & GUC_UNIT_TIME)
                        {
                            case GUC_UNIT_S:
                                result *= MS_PER_S;
                                break;
                            case GUC_UNIT_MIN:
                                result *= MS_PER_MIN;
                                break;
                        }

                        if (result % MS_PER_D == 0)
                        {
                            result /= MS_PER_D;
                            unit = "d";
                        }
                        else if (result % MS_PER_H == 0)
                        {
                            result /= MS_PER_H;
                            unit = "h";
                        }
                        else if (result % MS_PER_MIN == 0)
                        {
                            result /= MS_PER_MIN;
                            unit = "min";
                        }
                        else if (result % MS_PER_S == 0)
                        {
                            result /= MS_PER_S;
                            unit = "s";
                        }
                        else
                        {
                            unit = "ms";
                        }
                    }
                    else
                        unit = "";

                    snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
                             result, unit);
                    val = buffer;
                }
            }
            break;

        case PGC_REAL:
            {
                struct config_real *conf = (struct config_real *) record;

                if (conf->show_hook)
                    val = (*conf->show_hook) ();
                else
                {
                    snprintf(buffer, sizeof(buffer), "%g",
                             *conf->variable);
                    val = buffer;
                }
            }
            break;

        case PGC_STRING:
            {
                struct config_string *conf = (struct config_string *) record;

                if (conf->show_hook)
                    val = (*conf->show_hook) ();
                else if (*conf->variable && **conf->variable)
                    val = *conf->variable;
                else
                    val = "";
            }
            break;

        case PGC_ENUM:
            {
                struct config_enum *conf = (struct config_enum *) record;

                if (conf->show_hook)
                    val = (*conf->show_hook) ();
                else
                    val = config_enum_lookup_by_value(conf, *conf->variable);
            }
            break;

        default:
            /* just to keep compiler quiet */
            val = "???";
            break;
    }

    return pstrdup(val);
}

static bool add_guc_variable ( struct config_generic var,
int  elevel 
) [static]

Definition at line 3695 of file guc.c.

References guc_malloc(), guc_realloc(), guc_var_compare(), NULL, and qsort.

Referenced by add_placeholder_variable(), and define_custom_variable().

{
    if (num_guc_variables + 1 >= size_guc_variables)
    {
        /*
         * Increase the vector by 25%
         */
        int         size_vars = size_guc_variables + size_guc_variables / 4;
        struct config_generic **guc_vars;

        if (size_vars == 0)
        {
            size_vars = 100;
            guc_vars = (struct config_generic **)
                guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
        }
        else
        {
            guc_vars = (struct config_generic **)
                guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
        }

        if (guc_vars == NULL)
            return false;       /* out of memory */

        guc_variables = guc_vars;
        size_guc_variables = size_vars;
    }
    guc_variables[num_guc_variables++] = var;
    qsort((void *) guc_variables, num_guc_variables,
          sizeof(struct config_generic *), guc_var_compare);
    return true;
}

static struct config_generic* add_placeholder_variable ( const char *  name,
int  elevel 
) [static, read]

Definition at line 3733 of file guc.c.

References add_guc_variable(), config_generic::context, config_generic::flags, free, config_string::gen, config_generic::group, guc_malloc(), GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE, guc_strdup(), config_generic::name, NULL, config_generic::short_desc, config_string::variable, and config_generic::vartype.

Referenced by find_option().

{
    size_t      sz = sizeof(struct config_string) + sizeof(char *);
    struct config_string *var;
    struct config_generic *gen;

    var = (struct config_string *) guc_malloc(elevel, sz);
    if (var == NULL)
        return NULL;
    memset(var, 0, sz);
    gen = &var->gen;

    gen->name = guc_strdup(elevel, name);
    if (gen->name == NULL)
    {
        free(var);
        return NULL;
    }

    gen->context = PGC_USERSET;
    gen->group = CUSTOM_OPTIONS;
    gen->short_desc = "GUC placeholder variable";
    gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
    gen->vartype = PGC_STRING;

    /*
     * The char* is allocated at the end of the struct since we have no
     * 'static' place to point to.  Note that the current value, as well as
     * the boot and reset values, start out NULL.
     */
    var->variable = (char **) (var + 1);

    if (!add_guc_variable((struct config_generic *) var, elevel))
    {
        free((void *) gen->name);
        free(var);
        return NULL;
    }

    return gen;
}

static void assign_application_name ( const char *  newval,
void *  extra 
) [static]

Definition at line 8776 of file guc.c.

References pgstat_report_appname().

{
    /* Update the pg_stat_activity view */
    pgstat_report_appname(newval);
}

static void assign_effective_io_concurrency ( int  newval,
void *  extra 
) [static]

Definition at line 8724 of file guc.c.

References target_prefetch_pages.

{
#ifdef USE_PREFETCH
    target_prefetch_pages = *((int *) extra);
#endif   /* USE_PREFETCH */
}

static void assign_log_destination ( const char *  newval,
void *  extra 
) [static]

Definition at line 8379 of file guc.c.

References Log_destination.

{
    Log_destination = *((int *) extra);
}

static void assign_pgstat_temp_directory ( const char *  newval,
void *  extra 
) [static]

Definition at line 8732 of file guc.c.

References ERROR, free, guc_malloc(), pgstat_stat_directory, pgstat_stat_filename, and pgstat_stat_tmpname.

{
    /* check_canonical_path already canonicalized newval for us */
    char       *dname;
    char       *tname;
    char       *fname;

    /* directory */
    dname = guc_malloc(ERROR, strlen(newval) + 1);      /* runtime dir */
    sprintf(dname, "%s", newval);

    /* global stats */
    tname = guc_malloc(ERROR, strlen(newval) + 12);     /* /global.tmp */
    sprintf(tname, "%s/global.tmp", newval);
    fname = guc_malloc(ERROR, strlen(newval) + 13);     /* /global.stat */
    sprintf(fname, "%s/global.stat", newval);

    if (pgstat_stat_directory)
        free(pgstat_stat_directory);
    pgstat_stat_directory = dname;
    if (pgstat_stat_tmpname)
        free(pgstat_stat_tmpname);
    pgstat_stat_tmpname = tname;
    if (pgstat_stat_filename)
        free(pgstat_stat_filename);
    pgstat_stat_filename = fname;
}

static void assign_session_replication_role ( int  newval,
void *  extra 
) [static]

Definition at line 8405 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

{
    /*
     * Must flush the plan cache when changing replication role; but don't
     * flush unnecessarily.
     */
    if (SessionReplicationRole != newval)
        ResetPlanCache();
}

static void assign_syslog_facility ( int  newval,
void *  extra 
) [static]

Definition at line 8385 of file guc.c.

References syslog_ident_str.

{
#ifdef HAVE_SYSLOG
    set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
                          newval);
#endif
    /* Without syslog support, just ignore it */
}

static void assign_syslog_ident ( const char *  newval,
void *  extra 
) [static]

Definition at line 8395 of file guc.c.

References syslog_facility.

{
#ifdef HAVE_SYSLOG
    set_syslog_parameters(newval, syslog_facility);
#endif
    /* Without syslog support, it will always be set to "none", so ignore */
}

static void assign_tcp_keepalives_count ( int  newval,
void *  extra 
) [static]

Definition at line 8629 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

{
    /* See comments in assign_tcp_keepalives_idle */
    (void) pq_setkeepalivescount(newval, MyProcPort);
}

static void assign_tcp_keepalives_idle ( int  newval,
void *  extra 
) [static]

Definition at line 8585 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

{
    /*
     * The kernel API provides no way to test a value without setting it; and
     * once we set it we might fail to unset it.  So there seems little point
     * in fully implementing the check-then-assign GUC API for these
     * variables.  Instead we just do the assignment on demand.  pqcomm.c
     * reports any problems via elog(LOG).
     *
     * This approach means that the GUC value might have little to do with the
     * actual kernel value, so we use a show_hook that retrieves the kernel
     * value rather than trusting GUC's copy.
     */
    (void) pq_setkeepalivesidle(newval, MyProcPort);
}

static void assign_tcp_keepalives_interval ( int  newval,
void *  extra 
) [static]

Definition at line 8612 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

{
    /* See comments in assign_tcp_keepalives_idle */
    (void) pq_setkeepalivesinterval(newval, MyProcPort);
}

static void assign_timezone_abbreviations ( const char *  newval,
void *  extra 
) [static]

Definition at line 8549 of file guc.c.

References InstallTimeZoneAbbrevs().

{
    /* Do nothing for the boot_val default of NULL */
    if (!extra)
        return;

    InstallTimeZoneAbbrevs((TimeZoneAbbrevTable *) extra);
}

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 4464 of file guc.c.

References Assert, config_enum::assign_hook, config_string::assign_hook, config_real::assign_hook, config_int::assign_hook, config_bool::assign_hook, config_var_val::boolval, discard_stack_value(), config_var_val::enumval, config_generic::extra, config_var_value::extra, config_generic::flags, config_enum::gen, config_string::gen, config_real::gen, config_int::gen, config_bool::gen, GUC_LOCAL, GUC_REPORT, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, i, config_var_val::intval, guc_stack::masked, guc_stack::masked_scontext, guc_stack::nest_level, NULL, pfree(), PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, guc_stack::prev, guc_stack::prior, config_var_val::realval, ReportGUCOption(), config_generic::scontext, guc_stack::scontext, set_extra_field(), set_string_field(), config_generic::source, guc_stack::source, config_generic::stack, guc_stack::state, config_var_val::stringval, config_var_value::val, config_enum::variable, config_string::variable, config_real::variable, config_int::variable, config_bool::variable, and config_generic::vartype.

Referenced by AbortSubTransaction(), AbortTransaction(), CommitSubTransaction(), CommitTransaction(), do_analyze_rel(), execute_extension_script(), fmgr_security_definer(), index_build(), PrepareTransaction(), ProcedureCreate(), reset_transmission_modes(), restoreLocalGucs(), RI_Initial_Check(), vacuum_rel(), and validate_index().

{
    bool        still_dirty;
    int         i;

    /*
     * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
     * abort, if there is a failure during transaction start before
     * AtStart_GUC is called.
     */
    Assert(nestLevel > 0 &&
           (nestLevel <= GUCNestLevel ||
            (nestLevel == GUCNestLevel + 1 && !isCommit)));

    /* Quick exit if nothing's changed in this transaction */
    if (!guc_dirty)
    {
        GUCNestLevel = nestLevel - 1;
        return;
    }

    still_dirty = false;
    for (i = 0; i < num_guc_variables; i++)
    {
        struct config_generic *gconf = guc_variables[i];
        GucStack   *stack;

        /*
         * Process and pop each stack entry within the nest level. To simplify
         * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
         * we allow failure exit from code that uses a local nest level to be
         * recovered at the surrounding transaction or subtransaction abort;
         * so there could be more than one stack entry to pop.
         */
        while ((stack = gconf->stack) != NULL &&
               stack->nest_level >= nestLevel)
        {
            GucStack   *prev = stack->prev;
            bool        restorePrior = false;
            bool        restoreMasked = false;
            bool        changed;

            /*
             * In this next bit, if we don't set either restorePrior or
             * restoreMasked, we must "discard" any unwanted fields of the
             * stack entries to avoid leaking memory.  If we do set one of
             * those flags, unused fields will be cleaned up after restoring.
             */
            if (!isCommit)      /* if abort, always restore prior value */
                restorePrior = true;
            else if (stack->state == GUC_SAVE)
                restorePrior = true;
            else if (stack->nest_level == 1)
            {
                /* transaction commit */
                if (stack->state == GUC_SET_LOCAL)
                    restoreMasked = true;
                else if (stack->state == GUC_SET)
                {
                    /* we keep the current active value */
                    discard_stack_value(gconf, &stack->prior);
                }
                else    /* must be GUC_LOCAL */
                    restorePrior = true;
            }
            else if (prev == NULL ||
                     prev->nest_level < stack->nest_level - 1)
            {
                /* decrement entry's level and do not pop it */
                stack->nest_level--;
                continue;
            }
            else
            {
                /*
                 * We have to merge this stack entry into prev. See README for
                 * discussion of this bit.
                 */
                switch (stack->state)
                {
                    case GUC_SAVE:
                        Assert(false);  /* can't get here */

                    case GUC_SET:
                        /* next level always becomes SET */
                        discard_stack_value(gconf, &stack->prior);
                        if (prev->state == GUC_SET_LOCAL)
                            discard_stack_value(gconf, &prev->masked);
                        prev->state = GUC_SET;
                        break;

                    case GUC_LOCAL:
                        if (prev->state == GUC_SET)
                        {
                            /* LOCAL migrates down */
                            prev->masked_scontext = stack->scontext;
                            prev->masked = stack->prior;
                            prev->state = GUC_SET_LOCAL;
                        }
                        else
                        {
                            /* else just forget this stack level */
                            discard_stack_value(gconf, &stack->prior);
                        }
                        break;

                    case GUC_SET_LOCAL:
                        /* prior state at this level no longer wanted */
                        discard_stack_value(gconf, &stack->prior);
                        /* copy down the masked state */
                        prev->masked_scontext = stack->masked_scontext;
                        if (prev->state == GUC_SET_LOCAL)
                            discard_stack_value(gconf, &prev->masked);
                        prev->masked = stack->masked;
                        prev->state = GUC_SET_LOCAL;
                        break;
                }
            }

            changed = false;

            if (restorePrior || restoreMasked)
            {
                /* Perform appropriate restoration of the stacked value */
                config_var_value newvalue;
                GucSource   newsource;
                GucContext  newscontext;

                if (restoreMasked)
                {
                    newvalue = stack->masked;
                    newsource = PGC_S_SESSION;
                    newscontext = stack->masked_scontext;
                }
                else
                {
                    newvalue = stack->prior;
                    newsource = stack->source;
                    newscontext = stack->scontext;
                }

                switch (gconf->vartype)
                {
                    case PGC_BOOL:
                        {
                            struct config_bool *conf = (struct config_bool *) gconf;
                            bool        newval = newvalue.val.boolval;
                            void       *newextra = newvalue.extra;

                            if (*conf->variable != newval ||
                                conf->gen.extra != newextra)
                            {
                                if (conf->assign_hook)
                                    (*conf->assign_hook) (newval, newextra);
                                *conf->variable = newval;
                                set_extra_field(&conf->gen, &conf->gen.extra,
                                                newextra);
                                changed = true;
                            }
                            break;
                        }
                    case PGC_INT:
                        {
                            struct config_int *conf = (struct config_int *) gconf;
                            int         newval = newvalue.val.intval;
                            void       *newextra = newvalue.extra;

                            if (*conf->variable != newval ||
                                conf->gen.extra != newextra)
                            {
                                if (conf->assign_hook)
                                    (*conf->assign_hook) (newval, newextra);
                                *conf->variable = newval;
                                set_extra_field(&conf->gen, &conf->gen.extra,
                                                newextra);
                                changed = true;
                            }
                            break;
                        }
                    case PGC_REAL:
                        {
                            struct config_real *conf = (struct config_real *) gconf;
                            double      newval = newvalue.val.realval;
                            void       *newextra = newvalue.extra;

                            if (*conf->variable != newval ||
                                conf->gen.extra != newextra)
                            {
                                if (conf->assign_hook)
                                    (*conf->assign_hook) (newval, newextra);
                                *conf->variable = newval;
                                set_extra_field(&conf->gen, &conf->gen.extra,
                                                newextra);
                                changed = true;
                            }
                            break;
                        }
                    case PGC_STRING:
                        {
                            struct config_string *conf = (struct config_string *) gconf;
                            char       *newval = newvalue.val.stringval;
                            void       *newextra = newvalue.extra;

                            if (*conf->variable != newval ||
                                conf->gen.extra != newextra)
                            {
                                if (conf->assign_hook)
                                    (*conf->assign_hook) (newval, newextra);
                                set_string_field(conf, conf->variable, newval);
                                set_extra_field(&conf->gen, &conf->gen.extra,
                                                newextra);
                                changed = true;
                            }

                            /*
                             * Release stacked values if not used anymore. We
                             * could use discard_stack_value() here, but since
                             * we have type-specific code anyway, might as
                             * well inline it.
                             */
                            set_string_field(conf, &stack->prior.val.stringval, NULL);
                            set_string_field(conf, &stack->masked.val.stringval, NULL);
                            break;
                        }
                    case PGC_ENUM:
                        {
                            struct config_enum *conf = (struct config_enum *) gconf;
                            int         newval = newvalue.val.enumval;
                            void       *newextra = newvalue.extra;

                            if (*conf->variable != newval ||
                                conf->gen.extra != newextra)
                            {
                                if (conf->assign_hook)
                                    (*conf->assign_hook) (newval, newextra);
                                *conf->variable = newval;
                                set_extra_field(&conf->gen, &conf->gen.extra,
                                                newextra);
                                changed = true;
                            }
                            break;
                        }
                }

                /*
                 * Release stacked extra values if not used anymore.
                 */
                set_extra_field(gconf, &(stack->prior.extra), NULL);
                set_extra_field(gconf, &(stack->masked.extra), NULL);

                /* And restore source information */
                gconf->source = newsource;
                gconf->scontext = newscontext;
            }

            /* Finish popping the state stack */
            gconf->stack = prev;
            pfree(stack);

            /* Report new value if we changed it */
            if (changed && (gconf->flags & GUC_REPORT))
                ReportGUCOption(gconf);
        }                       /* end of stack-popping loop */

        if (stack != NULL)
            still_dirty = true;
    }

    /* If there are no remaining stack entries, we can reset guc_dirty */
    guc_dirty = still_dirty;

    /* Update nesting level */
    GUCNestLevel = nestLevel - 1;
}

void AtStart_GUC ( void   ) 

Definition at line 4430 of file guc.c.

References elog, and WARNING.

Referenced by StartTransaction().

{
    /*
     * The nest level should be 0 between transactions; if it isn't, somebody
     * didn't call AtEOXact_GUC, or called it with the wrong nestLevel.  We
     * throw a warning but make no other effort to clean up.
     */
    if (GUCNestLevel != 0)
        elog(WARNING, "GUC nest level = %d at transaction start",
             GUCNestLevel);
    GUCNestLevel = 1;
}

void BeginReportingGUCOptions ( void   ) 

Definition at line 4745 of file guc.c.

References DestRemote, config_generic::flags, FrontendProtocol, GUC_REPORT, i, PG_PROTOCOL_MAJOR, ReportGUCOption(), and whereToSendOutput.

Referenced by PostgresMain().

{
    int         i;

    /*
     * Don't do anything unless talking to an interactive frontend of protocol
     * 3.0 or later.
     */
    if (whereToSendOutput != DestRemote ||
        PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
        return;

    reporting_enabled = true;

    /* Transmit initial values of interesting variables */
    for (i = 0; i < num_guc_variables; i++)
    {
        struct config_generic *conf = guc_variables[i];

        if (conf->flags & GUC_REPORT)
            ReportGUCOption(conf);
    }
}

void build_guc_variables ( void   ) 

Definition at line 3608 of file guc.c.

References FATAL, free, config_enum::gen, config_string::gen, config_real::gen, config_int::gen, config_bool::gen, guc_malloc(), guc_var_compare(), i, config_generic::name, qsort, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

{
    int         size_vars;
    int         num_vars = 0;
    struct config_generic **guc_vars;
    int         i;

    for (i = 0; ConfigureNamesBool[i].gen.name; i++)
    {
        struct config_bool *conf = &ConfigureNamesBool[i];

        /* Rather than requiring vartype to be filled in by hand, do this: */
        conf->gen.vartype = PGC_BOOL;
        num_vars++;
    }

    for (i = 0; ConfigureNamesInt[i].gen.name; i++)
    {
        struct config_int *conf = &ConfigureNamesInt[i];

        conf->gen.vartype = PGC_INT;
        num_vars++;
    }

    for (i = 0; ConfigureNamesReal[i].gen.name; i++)
    {
        struct config_real *conf = &ConfigureNamesReal[i];

        conf->gen.vartype = PGC_REAL;
        num_vars++;
    }

    for (i = 0; ConfigureNamesString[i].gen.name; i++)
    {
        struct config_string *conf = &ConfigureNamesString[i];

        conf->gen.vartype = PGC_STRING;
        num_vars++;
    }

    for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
    {
        struct config_enum *conf = &ConfigureNamesEnum[i];

        conf->gen.vartype = PGC_ENUM;
        num_vars++;
    }

    /*
     * Create table with 20% slack
     */
    size_vars = num_vars + num_vars / 4;

    guc_vars = (struct config_generic **)
        guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));

    num_vars = 0;

    for (i = 0; ConfigureNamesBool[i].gen.name; i++)
        guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;

    for (i = 0; ConfigureNamesInt[i].gen.name; i++)
        guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;

    for (i = 0; ConfigureNamesReal[i].gen.name; i++)
        guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;

    for (i = 0; ConfigureNamesString[i].gen.name; i++)
        guc_vars[num_vars++] = &ConfigureNamesString[i].gen;

    for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
        guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;

    if (guc_variables)
        free(guc_variables);
    guc_variables = guc_vars;
    num_guc_variables = num_vars;
    size_guc_variables = size_vars;
    qsort((void *) guc_variables, num_guc_variables,
          sizeof(struct config_generic *), guc_var_compare);
}

static bool call_bool_check_hook ( struct config_bool conf,
bool newval,
void **  extra,
GucSource  source,
int  elevel 
) [static]

Definition at line 8146 of file guc.c.

References config_bool::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), FlushErrorState(), config_bool::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, and config_generic::name.

Referenced by InitializeOneGUCOption(), and set_config_option().

{
    /* Quick success if no hook */
    if (!conf->check_hook)
        return true;

    /* Reset variables that might be set by hook */
    GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
    GUC_check_errmsg_string = NULL;
    GUC_check_errdetail_string = NULL;
    GUC_check_errhint_string = NULL;

    if (!(*conf->check_hook) (newval, extra, source))
    {
        ereport(elevel,
                (errcode(GUC_check_errcode_value),
                 GUC_check_errmsg_string ?
                 errmsg_internal("%s", GUC_check_errmsg_string) :
                 errmsg("invalid value for parameter \"%s\": %d",
                        conf->gen.name, (int) *newval),
                 GUC_check_errdetail_string ?
                 errdetail_internal("%s", GUC_check_errdetail_string) : 0,
                 GUC_check_errhint_string ?
                 errhint("%s", GUC_check_errhint_string) : 0));
        /* Flush any strings created in ErrorContext */
        FlushErrorState();
        return false;
    }

    return true;
}

static bool call_enum_check_hook ( struct config_enum conf,
int *  newval,
void **  extra,
GucSource  source,
int  elevel 
) [static]

Definition at line 8282 of file guc.c.

References config_enum::check_hook, config_enum_lookup_by_value(), ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), FlushErrorState(), config_enum::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, and config_generic::name.

Referenced by InitializeOneGUCOption(), and set_config_option().

{
    /* Quick success if no hook */
    if (!conf->check_hook)
        return true;

    /* Reset variables that might be set by hook */
    GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
    GUC_check_errmsg_string = NULL;
    GUC_check_errdetail_string = NULL;
    GUC_check_errhint_string = NULL;

    if (!(*conf->check_hook) (newval, extra, source))
    {
        ereport(elevel,
                (errcode(GUC_check_errcode_value),
                 GUC_check_errmsg_string ?
                 errmsg_internal("%s", GUC_check_errmsg_string) :
                 errmsg("invalid value for parameter \"%s\": \"%s\"",
                        conf->gen.name,
                        config_enum_lookup_by_value(conf, *newval)),
                 GUC_check_errdetail_string ?
                 errdetail_internal("%s", GUC_check_errdetail_string) : 0,
                 GUC_check_errhint_string ?
                 errhint("%s", GUC_check_errhint_string) : 0));
        /* Flush any strings created in ErrorContext */
        FlushErrorState();
        return false;
    }

    return true;
}

static bool call_int_check_hook ( struct config_int conf,
int *  newval,
void **  extra,
GucSource  source,
int  elevel 
) [static]

Definition at line 8180 of file guc.c.

References config_int::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), FlushErrorState(), config_int::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, and config_generic::name.

Referenced by InitializeOneGUCOption(), and set_config_option().

{
    /* Quick success if no hook */
    if (!conf->check_hook)
        return true;

    /* Reset variables that might be set by hook */
    GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
    GUC_check_errmsg_string = NULL;
    GUC_check_errdetail_string = NULL;
    GUC_check_errhint_string = NULL;

    if (!(*conf->check_hook) (newval, extra, source))
    {
        ereport(elevel,
                (errcode(GUC_check_errcode_value),
                 GUC_check_errmsg_string ?
                 errmsg_internal("%s", GUC_check_errmsg_string) :
                 errmsg("invalid value for parameter \"%s\": %d",
                        conf->gen.name, *newval),
                 GUC_check_errdetail_string ?
                 errdetail_internal("%s", GUC_check_errdetail_string) : 0,
                 GUC_check_errhint_string ?
                 errhint("%s", GUC_check_errhint_string) : 0));
        /* Flush any strings created in ErrorContext */
        FlushErrorState();
        return false;
    }

    return true;
}

static bool call_real_check_hook ( struct config_real conf,
double *  newval,
void **  extra,
GucSource  source,
int  elevel 
) [static]

Definition at line 8214 of file guc.c.

References config_real::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), FlushErrorState(), config_real::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, and config_generic::name.

Referenced by InitializeOneGUCOption(), and set_config_option().

{
    /* Quick success if no hook */
    if (!conf->check_hook)
        return true;

    /* Reset variables that might be set by hook */
    GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
    GUC_check_errmsg_string = NULL;
    GUC_check_errdetail_string = NULL;
    GUC_check_errhint_string = NULL;

    if (!(*conf->check_hook) (newval, extra, source))
    {
        ereport(elevel,
                (errcode(GUC_check_errcode_value),
                 GUC_check_errmsg_string ?
                 errmsg_internal("%s", GUC_check_errmsg_string) :
                 errmsg("invalid value for parameter \"%s\": %g",
                        conf->gen.name, *newval),
                 GUC_check_errdetail_string ?
                 errdetail_internal("%s", GUC_check_errdetail_string) : 0,
                 GUC_check_errhint_string ?
                 errhint("%s", GUC_check_errhint_string) : 0));
        /* Flush any strings created in ErrorContext */
        FlushErrorState();
        return false;
    }

    return true;
}

static bool call_string_check_hook ( struct config_string conf,
char **  newval,
void **  extra,
GucSource  source,
int  elevel 
) [static]

Definition at line 8248 of file guc.c.

References config_string::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), FlushErrorState(), config_string::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, and config_generic::name.

Referenced by InitializeOneGUCOption(), and set_config_option().

{
    /* Quick success if no hook */
    if (!conf->check_hook)
        return true;

    /* Reset variables that might be set by hook */
    GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
    GUC_check_errmsg_string = NULL;
    GUC_check_errdetail_string = NULL;
    GUC_check_errhint_string = NULL;

    if (!(*conf->check_hook) (newval, extra, source))
    {
        ereport(elevel,
                (errcode(GUC_check_errcode_value),
                 GUC_check_errmsg_string ?
                 errmsg_internal("%s", GUC_check_errmsg_string) :
                 errmsg("invalid value for parameter \"%s\": \"%s\"",
                        conf->gen.name, *newval ? *newval : ""),
                 GUC_check_errdetail_string ?
                 errdetail_internal("%s", GUC_check_errdetail_string) : 0,
                 GUC_check_errhint_string ?
                 errhint("%s", GUC_check_errhint_string) : 0));
        /* Flush any strings created in ErrorContext */
        FlushErrorState();
        return false;
    }

    return true;
}

static bool check_application_name ( char **  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8761 of file guc.c.

{
    /* Only allow clean ASCII chars in the application name */
    char       *p;

    for (p = *newval; *p; p++)
    {
        if (*p < 32 || *p > 126)
            *p = '?';
    }

    return true;
}

static bool check_autovacuum_max_workers ( int *  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8655 of file guc.c.

References GetNumShmemAttachedBgworkers(), MAX_BACKENDS, and MaxConnections.

{
    if (MaxConnections + *newval + 1 + GetNumShmemAttachedBgworkers() >
        MAX_BACKENDS)
        return false;
    return true;
}

static bool check_bonjour ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8455 of file guc.c.

References GUC_check_errmsg.

{
#ifndef USE_BONJOUR
    if (*newval)
    {
        GUC_check_errmsg("Bonjour is not supported by this build");
        return false;
    }
#endif
    return true;
}

static bool check_canonical_path ( char **  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8506 of file guc.c.

References canonicalize_path().

{
    /*
     * Since canonicalize_path never enlarges the string, we can just modify
     * newval in-place.  But watch out for NULL, which is the default value
     * for external_pid_file.
     */
    if (*newval)
        canonicalize_path(*newval);
    return true;
}

static bool check_debug_assertions ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8442 of file guc.c.

References GUC_check_errmsg.

{
#ifndef USE_ASSERT_CHECKING
    if (*newval)
    {
        GUC_check_errmsg("assertion checking is not supported by this build");
        return false;
    }
#endif
    return true;
}

static bool check_effective_io_concurrency ( int *  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8664 of file guc.c.

References ERROR, guc_malloc(), and rint().

{
#ifdef USE_PREFETCH
    double      new_prefetch_pages = 0.0;
    int         i;

    /*----------
     * The user-visible GUC parameter is the number of drives (spindles),
     * which we need to translate to a number-of-pages-to-prefetch target.
     * The target value is stashed in *extra and then assigned to the actual
     * variable by assign_effective_io_concurrency.
     *
     * The expected number of prefetch pages needed to keep N drives busy is:
     *
     * drives |   I/O requests
     * -------+----------------
     *      1 |   1
     *      2 |   2/1 + 2/2 = 3
     *      3 |   3/1 + 3/2 + 3/3 = 5 1/2
     *      4 |   4/1 + 4/2 + 4/3 + 4/4 = 8 1/3
     *      n |   n * H(n)
     *
     * This is called the "coupon collector problem" and H(n) is called the
     * harmonic series.  This could be approximated by n * ln(n), but for
     * reasonable numbers of drives we might as well just compute the series.
     *
     * Alternatively we could set the target to the number of pages necessary
     * so that the expected number of active spindles is some arbitrary
     * percentage of the total.  This sounds the same but is actually slightly
     * different.  The result ends up being ln(1-P)/ln((n-1)/n) where P is
     * that desired fraction.
     *
     * Experimental results show that both of these formulas aren't aggressive
     * enough, but we don't really have any better proposals.
     *
     * Note that if *newval = 0 (disabled), we must set target = 0.
     *----------
     */

    for (i = 1; i <= *newval; i++)
        new_prefetch_pages += (double) *newval / (double) i;

    /* This range check shouldn't fail, but let's be paranoid */
    if (new_prefetch_pages >= 0.0 && new_prefetch_pages < (double) INT_MAX)
    {
        int        *myextra = (int *) guc_malloc(ERROR, sizeof(int));

        *myextra = (int) rint(new_prefetch_pages);
        *extra = (void *) myextra;

        return true;
    }
    else
        return false;
#else
    return true;
#endif   /* USE_PREFETCH */
}

static bool check_log_destination ( char **  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8322 of file guc.c.

References ERROR, GUC_check_errdetail, guc_malloc(), lfirst, list_free(), LOG_DESTINATION_CSVLOG, LOG_DESTINATION_EVENTLOG, LOG_DESTINATION_STDERR, LOG_DESTINATION_SYSLOG, pfree(), pg_strcasecmp(), pstrdup(), and SplitIdentifierString().

{
    char       *rawstring;
    List       *elemlist;
    ListCell   *l;
    int         newlogdest = 0;
    int        *myextra;

    /* Need a modifiable copy of string */
    rawstring = pstrdup(*newval);

    /* Parse string into list of identifiers */
    if (!SplitIdentifierString(rawstring, ',', &elemlist))
    {
        /* syntax error in list */
        GUC_check_errdetail("List syntax is invalid.");
        pfree(rawstring);
        list_free(elemlist);
        return false;
    }

    foreach(l, elemlist)
    {
        char       *tok = (char *) lfirst(l);

        if (pg_strcasecmp(tok, "stderr") == 0)
            newlogdest |= LOG_DESTINATION_STDERR;
        else if (pg_strcasecmp(tok, "csvlog") == 0)
            newlogdest |= LOG_DESTINATION_CSVLOG;
#ifdef HAVE_SYSLOG
        else if (pg_strcasecmp(tok, "syslog") == 0)
            newlogdest |= LOG_DESTINATION_SYSLOG;
#endif
#ifdef WIN32
        else if (pg_strcasecmp(tok, "eventlog") == 0)
            newlogdest |= LOG_DESTINATION_EVENTLOG;
#endif
        else
        {
            GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
            pfree(rawstring);
            list_free(elemlist);
            return false;
        }
    }

    pfree(rawstring);
    list_free(elemlist);

    myextra = (int *) guc_malloc(ERROR, sizeof(int));
    *myextra = newlogdest;
    *extra = (void *) myextra;

    return true;
}

static bool check_log_stats ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8492 of file guc.c.

References GUC_check_errdetail, log_executor_stats, log_parser_stats, and log_planner_stats.

{
    if (*newval &&
        (log_parser_stats || log_planner_stats || log_executor_stats))
    {
        GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
                            "\"log_parser_stats\", \"log_planner_stats\", "
                            "or \"log_executor_stats\" is true.");
        return false;
    }
    return true;
}

static bool check_maxconnections ( int *  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8646 of file guc.c.

References autovacuum_max_workers, GetNumShmemAttachedBgworkers(), and MAX_BACKENDS.

{
    if (*newval + GetNumShmemAttachedBgworkers() + autovacuum_max_workers + 1 >
        MAX_BACKENDS)
        return false;
    return true;
}

static bool check_phony_autocommit ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8430 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

{
    if (!*newval)
    {
        GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
        GUC_check_errmsg("SET AUTOCOMMIT TO OFF is no longer supported");
        return false;
    }
    return true;
}

static bool check_ssl ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8468 of file guc.c.

References GUC_check_errmsg.

{
#ifndef USE_SSL
    if (*newval)
    {
        GUC_check_errmsg("SSL is not supported by this build");
        return false;
    }
#endif
    return true;
}

static bool check_stage_log_stats ( bool newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8481 of file guc.c.

References GUC_check_errdetail, and log_statement_stats.

{
    if (*newval && log_statement_stats)
    {
        GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
        return false;
    }
    return true;
}

static bool check_temp_buffers ( int *  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8416 of file guc.c.

References GUC_check_errdetail, and NLocBuffer.

{
    /*
     * Once local buffers have been initialized, it's too late to change this.
     */
    if (NLocBuffer && NLocBuffer != *newval)
    {
        GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
        return false;
    }
    return true;
}

static bool check_timezone_abbreviations ( char **  newval,
void **  extra,
GucSource  source 
) [static]

Definition at line 8519 of file guc.c.

References Assert, load_tzoffsets(), NULL, and PGC_S_DEFAULT.

{
    /*
     * The boot_val given above for timezone_abbreviations is NULL. When we
     * see this we just do nothing.  If this value isn't overridden from the
     * config file then pg_timezone_abbrev_initialize() will eventually
     * replace it with "Default".  This hack has two purposes: to avoid
     * wasting cycles loading values that might soon be overridden from the
     * config file, and to avoid trying to read the timezone abbrev files
     * during InitializeGUCOptions().  The latter doesn't work in an
     * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
     * we can't locate PGSHAREDIR.
     */
    if (*newval == NULL)
    {
        Assert(source == PGC_S_DEFAULT);
        return true;
    }

    /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
    *extra = load_tzoffsets(*newval);

    /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
    if (!*extra)
        return false;

    return true;
}

static char * config_enum_get_options ( struct config_enum record,
const char *  prefix,
const char *  suffix,
const char *  separator 
) [static]

Definition at line 5086 of file guc.c.

References appendBinaryStringInfo(), appendStringInfoString(), StringInfoData::data, config_enum_entry::hidden, initStringInfo(), StringInfoData::len, config_enum_entry::name, and config_enum::options.

Referenced by GetConfigOptionByNum(), and set_config_option().

{
    const struct config_enum_entry *entry;
    StringInfoData retstr;
    int         seplen;

    initStringInfo(&retstr);
    appendStringInfoString(&retstr, prefix);

    seplen = strlen(separator);
    for (entry = record->options; entry && entry->name; entry++)
    {
        if (!entry->hidden)
        {
            appendStringInfoString(&retstr, entry->name);
            appendBinaryStringInfo(&retstr, separator, seplen);
        }
    }

    /*
     * All the entries may have been hidden, leaving the string empty if no
     * prefix was given. This indicates a broken GUC setup, since there is no
     * use for an enum without any values, so we just check to make sure we
     * don't write to invalid memory instead of actually trying to do
     * something smart with it.
     */
    if (retstr.len >= seplen)
    {
        /* Replace final separator */
        retstr.data[retstr.len - seplen] = '\0';
        retstr.len -= seplen;
    }

    appendStringInfoString(&retstr, suffix);

    return retstr.data;
}

bool config_enum_lookup_by_name ( struct config_enum record,
const char *  value,
int *  retval 
)

Definition at line 5060 of file guc.c.

References config_enum_entry::name, config_enum::options, pg_strcasecmp(), and config_enum_entry::val.

Referenced by set_config_option().

{
    const struct config_enum_entry *entry;

    for (entry = record->options; entry && entry->name; entry++)
    {
        if (pg_strcasecmp(value, entry->name) == 0)
        {
            *retval = entry->val;
            return TRUE;
        }
    }

    *retval = 0;
    return FALSE;
}

const char* config_enum_lookup_by_value ( struct config_enum record,
int  val 
)

Definition at line 5037 of file guc.c.

References elog, ERROR, config_enum::gen, config_generic::name, config_enum_entry::name, config_enum::options, and config_enum_entry::val.

Referenced by _ShowOption(), call_enum_check_hook(), GetConfigOption(), GetConfigOptionByNum(), GetConfigOptionResetString(), and printMixedStruct().

{
    const struct config_enum_entry *entry;

    for (entry = record->options; entry && entry->name; entry++)
    {
        if (entry->val == val)
            return entry->name;
    }

    elog(ERROR, "could not find enum option %d for %s",
         val, record->gen.name);
    return NULL;                /* silence compiler */
}

static void define_custom_variable ( struct config_generic variable  )  [static]

Definition at line 6429 of file guc.c.

References add_guc_variable(), Assert, ereport, errcode(), errmsg(), ERROR, free, config_string::gen, GUC_ACTION_SET, GUC_CUSTOM_PLACEHOLDER, InitializeOneGUCOption(), config_generic::name, name, NULL, PGC_STRING, reapply_stacked_values(), config_generic::reset_scontext, config_generic::reset_source, config_string::reset_val, config_generic::scontext, set_config_option(), set_config_sourcefile(), set_string_field(), config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_generic::stack, config_string::variable, and WARNING.

Referenced by DefineCustomBoolVariable(), DefineCustomEnumVariable(), DefineCustomIntVariable(), DefineCustomRealVariable(), and DefineCustomStringVariable().

{
    const char *name = variable->name;
    const char **nameAddr = &name;
    struct config_string *pHolder;
    struct config_generic **res;

    /*
     * See if there's a placeholder by the same name.
     */
    res = (struct config_generic **) bsearch((void *) &nameAddr,
                                             (void *) guc_variables,
                                             num_guc_variables,
                                             sizeof(struct config_generic *),
                                             guc_var_compare);
    if (res == NULL)
    {
        /*
         * No placeholder to replace, so we can just add it ... but first,
         * make sure it's initialized to its default value.
         */
        InitializeOneGUCOption(variable);
        add_guc_variable(variable, ERROR);
        return;
    }

    /*
     * This better be a placeholder
     */
    if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
        ereport(ERROR,
                (errcode(ERRCODE_INTERNAL_ERROR),
                 errmsg("attempt to redefine parameter \"%s\"", name)));

    Assert((*res)->vartype == PGC_STRING);
    pHolder = (struct config_string *) (*res);

    /*
     * First, set the variable to its default value.  We must do this even
     * though we intend to immediately apply a new value, since it's possible
     * that the new value is invalid.
     */
    InitializeOneGUCOption(variable);

    /*
     * Replace the placeholder. We aren't changing the name, so no re-sorting
     * is necessary
     */
    *res = variable;

    /*
     * Assign the string value(s) stored in the placeholder to the real
     * variable.  Essentially, we need to duplicate all the active and stacked
     * values, but with appropriate validation and datatype adjustment.
     *
     * If an assignment fails, we report a WARNING and keep going.  We don't
     * want to throw ERROR for bad values, because it'd bollix the add-on
     * module that's presumably halfway through getting loaded.  In such cases
     * the default or previous state will become active instead.
     */

    /* First, apply the reset value if any */
    if (pHolder->reset_val)
        (void) set_config_option(name, pHolder->reset_val,
                                 pHolder->gen.reset_scontext,
                                 pHolder->gen.reset_source,
                                 GUC_ACTION_SET, true, WARNING);
    /* That should not have resulted in stacking anything */
    Assert(variable->stack == NULL);

    /* Now, apply current and stacked values, in the order they were stacked */
    reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
                           *(pHolder->variable),
                           pHolder->gen.scontext, pHolder->gen.source);

    /* Also copy over any saved source-location information */
    if (pHolder->gen.sourcefile)
        set_config_sourcefile(name, pHolder->gen.sourcefile,
                              pHolder->gen.sourceline);

    /*
     * Free up as much as we conveniently can of the placeholder structure.
     * (This neglects any stack items, so it's possible for some memory to be
     * leaked.  Since this can only happen once per session per variable, it
     * doesn't seem worth spending much code on.)
     */
    set_string_field(pHolder, pHolder->variable, NULL);
    set_string_field(pHolder, &pHolder->reset_val, NULL);

    free(pHolder);
}

void DefineCustomBoolVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
bool valueAddr,
bool  bootValue,
GucContext  context,
int  flags,
GucBoolCheckHook  check_hook,
GucBoolAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 6605 of file guc.c.

References config_bool::assign_hook, config_bool::boot_val, config_bool::check_hook, define_custom_variable(), config_bool::gen, init_custom_variable(), PGC_BOOL, config_bool::reset_val, config_bool::show_hook, and config_bool::variable.

Referenced by _PG_init().

{
    struct config_bool *var;

    var = (struct config_bool *)
        init_custom_variable(name, short_desc, long_desc, context, flags,
                             PGC_BOOL, sizeof(struct config_bool));
    var->variable = valueAddr;
    var->boot_val = bootValue;
    var->reset_val = bootValue;
    var->check_hook = check_hook;
    var->assign_hook = assign_hook;
    var->show_hook = show_hook;
    define_custom_variable(&var->gen);
}

void DefineCustomEnumVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
int *  valueAddr,
int  bootValue,
const struct config_enum_entry options,
GucContext  context,
int  flags,
GucEnumCheckHook  check_hook,
GucEnumAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 6716 of file guc.c.

References config_enum::assign_hook, config_enum::boot_val, config_enum::check_hook, define_custom_variable(), config_enum::gen, init_custom_variable(), config_enum::options, PGC_ENUM, config_enum::reset_val, config_enum::show_hook, and config_enum::variable.

Referenced by _PG_init().

{
    struct config_enum *var;

    var = (struct config_enum *)
        init_custom_variable(name, short_desc, long_desc, context, flags,
                             PGC_ENUM, sizeof(struct config_enum));
    var->variable = valueAddr;
    var->boot_val = bootValue;
    var->reset_val = bootValue;
    var->options = options;
    var->check_hook = check_hook;
    var->assign_hook = assign_hook;
    var->show_hook = show_hook;
    define_custom_variable(&var->gen);
}

void DefineCustomIntVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
int *  valueAddr,
int  bootValue,
int  minValue,
int  maxValue,
GucContext  context,
int  flags,
GucIntCheckHook  check_hook,
GucIntAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 6631 of file guc.c.

References config_int::assign_hook, config_int::boot_val, config_int::check_hook, define_custom_variable(), config_int::gen, init_custom_variable(), config_int::max, config_int::min, PGC_INT, config_int::reset_val, config_int::show_hook, and config_int::variable.

Referenced by _PG_init().

{
    struct config_int *var;

    var = (struct config_int *)
        init_custom_variable(name, short_desc, long_desc, context, flags,
                             PGC_INT, sizeof(struct config_int));
    var->variable = valueAddr;
    var->boot_val = bootValue;
    var->reset_val = bootValue;
    var->min = minValue;
    var->max = maxValue;
    var->check_hook = check_hook;
    var->assign_hook = assign_hook;
    var->show_hook = show_hook;
    define_custom_variable(&var->gen);
}

void DefineCustomRealVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
double *  valueAddr,
double  bootValue,
double  minValue,
double  maxValue,
GucContext  context,
int  flags,
GucRealCheckHook  check_hook,
GucRealAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 6661 of file guc.c.

References config_real::assign_hook, config_real::boot_val, config_real::check_hook, define_custom_variable(), config_real::gen, init_custom_variable(), config_real::max, config_real::min, PGC_REAL, config_real::reset_val, config_real::show_hook, and config_real::variable.

{
    struct config_real *var;

    var = (struct config_real *)
        init_custom_variable(name, short_desc, long_desc, context, flags,
                             PGC_REAL, sizeof(struct config_real));
    var->variable = valueAddr;
    var->boot_val = bootValue;
    var->reset_val = bootValue;
    var->min = minValue;
    var->max = maxValue;
    var->check_hook = check_hook;
    var->assign_hook = assign_hook;
    var->show_hook = show_hook;
    define_custom_variable(&var->gen);
}

void DefineCustomStringVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
char **  valueAddr,
const char *  bootValue,
GucContext  context,
int  flags,
GucStringCheckHook  check_hook,
GucStringAssignHook  assign_hook,
GucShowHook  show_hook 
)
static void discard_stack_value ( struct config_generic gconf,
config_var_value val 
) [static]

Definition at line 3572 of file guc.c.

References config_var_value::extra, NULL, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, set_extra_field(), set_string_field(), config_var_val::stringval, config_var_value::val, and config_generic::vartype.

Referenced by AtEOXact_GUC(), and push_old_value().

{
    switch (gconf->vartype)
    {
        case PGC_BOOL:
        case PGC_INT:
        case PGC_REAL:
        case PGC_ENUM:
            /* no need to do anything */
            break;
        case PGC_STRING:
            set_string_field((struct config_string *) gconf,
                             &(val->val.stringval),
                             NULL);
            break;
    }
    set_extra_field(gconf, &(val->extra), NULL);
}

void EmitWarningsOnPlaceholders ( const char *  className  ) 

Definition at line 6744 of file guc.c.

References ereport, errcode(), errmsg(), config_generic::flags, GUC_CUSTOM_PLACEHOLDER, GUC_QUALIFIER_SEPARATOR, i, config_generic::name, and WARNING.

Referenced by _PG_init().

{
    int         classLen = strlen(className);
    int         i;

    for (i = 0; i < num_guc_variables; i++)
    {
        struct config_generic *var = guc_variables[i];

        if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
            strncmp(className, var->name, classLen) == 0 &&
            var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
        {
            ereport(WARNING,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("unrecognized configuration parameter \"%s\"",
                            var->name)));
        }
    }
}

void ExecSetVariableStmt ( VariableSetStmt stmt  ) 

Definition at line 6191 of file guc.c.

References DefElem::arg, VariableSetStmt::args, Assert, DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, ExtractSetVariableArgs(), GUC_ACTION_LOCAL, ImportSnapshot(), VariableSetStmt::is_local, IsA, VariableSetStmt::kind, lfirst, linitial, list_make1, VariableSetStmt::name, nodeTag, NULL, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, ResetAllOptions(), set_config_option(), SetPGVariable(), strVal, superuser(), T_String, A_Const::val, VAR_RESET, VAR_RESET_ALL, VAR_SET_CURRENT, VAR_SET_DEFAULT, VAR_SET_MULTI, and VAR_SET_VALUE.

Referenced by standard_ProcessUtility().

{
    GucAction   action = stmt->is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET;

    switch (stmt->kind)
    {
        case VAR_SET_VALUE:
        case VAR_SET_CURRENT:
            (void) set_config_option(stmt->name,
                                     ExtractSetVariableArgs(stmt),
                                     (superuser() ? PGC_SUSET : PGC_USERSET),
                                     PGC_S_SESSION,
                                     action,
                                     true,
                                     0);
            break;
        case VAR_SET_MULTI:

            /*
             * Special-case SQL syntaxes.  The TRANSACTION and SESSION
             * CHARACTERISTICS cases effectively set more than one variable
             * per statement.  TRANSACTION SNAPSHOT only takes one argument,
             * but we put it here anyway since it's a special case and not
             * related to any GUC variable.
             */
            if (strcmp(stmt->name, "TRANSACTION") == 0)
            {
                ListCell   *head;

                foreach(head, stmt->args)
                {
                    DefElem    *item = (DefElem *) lfirst(head);

                    if (strcmp(item->defname, "transaction_isolation") == 0)
                        SetPGVariable("transaction_isolation",
                                      list_make1(item->arg), stmt->is_local);
                    else if (strcmp(item->defname, "transaction_read_only") == 0)
                        SetPGVariable("transaction_read_only",
                                      list_make1(item->arg), stmt->is_local);
                    else if (strcmp(item->defname, "transaction_deferrable") == 0)
                        SetPGVariable("transaction_deferrable",
                                      list_make1(item->arg), stmt->is_local);
                    else
                        elog(ERROR, "unexpected SET TRANSACTION element: %s",
                             item->defname);
                }
            }
            else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
            {
                ListCell   *head;

                foreach(head, stmt->args)
                {
                    DefElem    *item = (DefElem *) lfirst(head);

                    if (strcmp(item->defname, "transaction_isolation") == 0)
                        SetPGVariable("default_transaction_isolation",
                                      list_make1(item->arg), stmt->is_local);
                    else if (strcmp(item->defname, "transaction_read_only") == 0)
                        SetPGVariable("default_transaction_read_only",
                                      list_make1(item->arg), stmt->is_local);
                    else if (strcmp(item->defname, "transaction_deferrable") == 0)
                        SetPGVariable("default_transaction_deferrable",
                                      list_make1(item->arg), stmt->is_local);
                    else
                        elog(ERROR, "unexpected SET SESSION element: %s",
                             item->defname);
                }
            }
            else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
            {
                A_Const    *con = (A_Const *) linitial(stmt->args);

                if (stmt->is_local)
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                             errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
                Assert(IsA(con, A_Const));
                Assert(nodeTag(&con->val) == T_String);
                ImportSnapshot(strVal(&con->val));
            }
            else
                elog(ERROR, "unexpected SET MULTI element: %s",
                     stmt->name);
            break;
        case VAR_SET_DEFAULT:
        case VAR_RESET:
            (void) set_config_option(stmt->name,
                                     NULL,
                                     (superuser() ? PGC_SUSET : PGC_USERSET),
                                     PGC_S_SESSION,
                                     action,
                                     true,
                                     0);
            break;
        case VAR_RESET_ALL:
            ResetAllOptions();
            break;
    }
}

static bool extra_field_used ( struct config_generic gconf,
void *  extra 
) [static]

Definition at line 3473 of file guc.c.

References config_var_value::extra, config_generic::extra, guc_stack::masked, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, guc_stack::prev, guc_stack::prior, config_generic::stack, and config_generic::vartype.

Referenced by set_config_option(), and set_extra_field().

{
    GucStack   *stack;

    if (extra == gconf->extra)
        return true;
    switch (gconf->vartype)
    {
        case PGC_BOOL:
            if (extra == ((struct config_bool *) gconf)->reset_extra)
                return true;
            break;
        case PGC_INT:
            if (extra == ((struct config_int *) gconf)->reset_extra)
                return true;
            break;
        case PGC_REAL:
            if (extra == ((struct config_real *) gconf)->reset_extra)
                return true;
            break;
        case PGC_STRING:
            if (extra == ((struct config_string *) gconf)->reset_extra)
                return true;
            break;
        case PGC_ENUM:
            if (extra == ((struct config_enum *) gconf)->reset_extra)
                return true;
            break;
    }
    for (stack = gconf->stack; stack; stack = stack->prev)
    {
        if (extra == stack->prior.extra ||
            extra == stack->masked.extra)
            return true;
    }

    return false;
}

char* ExtractSetVariableArgs ( VariableSetStmt stmt  ) 
static struct config_generic* find_option ( const char *  name,
bool  create_placeholders,
int  elevel 
) [static, read]

Definition at line 3781 of file guc.c.

References add_placeholder_variable(), Assert, guc_name_compare(), GUC_QUALIFIER_SEPARATOR, and i.

Referenced by flatten_set_variable_args(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionResetString(), GUCArrayAdd(), GUCArrayDelete(), set_config_option(), set_config_sourcefile(), and validate_option_array_item().

{
    const char **key = &name;
    struct config_generic **res;
    int         i;

    Assert(name);

    /*
     * By equating const char ** with struct config_generic *, we are assuming
     * the name field is first in config_generic.
     */
    res = (struct config_generic **) bsearch((void *) &key,
                                             (void *) guc_variables,
                                             num_guc_variables,
                                             sizeof(struct config_generic *),
                                             guc_var_compare);
    if (res)
        return *res;

    /*
     * See if the name is an obsolete name for a variable.  We assume that the
     * set of supported old names is short enough that a brute-force search is
     * the best way.
     */
    for (i = 0; map_old_guc_names[i] != NULL; i += 2)
    {
        if (guc_name_compare(name, map_old_guc_names[i]) == 0)
            return find_option(map_old_guc_names[i + 1], false, elevel);
    }

    if (create_placeholders)
    {
        /*
         * Check if the name is qualified, and if so, add a placeholder.
         */
        if (strchr(name, GUC_QUALIFIER_SEPARATOR) != NULL)
            return add_placeholder_variable(name, elevel);
    }

    /* Unknown name */
    return NULL;
}

static char* flatten_set_variable_args ( const char *  name,
List args 
) [static]

Definition at line 6070 of file guc.c.

References appendStringInfo(), appendStringInfoString(), TypeCast::arg, arg, Assert, buf, CStringGetDatum, StringInfoData::data, DatumGetCString, DirectFunctionCall1, DirectFunctionCall3, elog, ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_LIST_INPUT, GUC_LIST_QUOTE, initStringInfo(), Int32GetDatum, interval_in(), interval_out(), INTERVALOID, intVal, InvalidOid, IsA, lfirst, list_head(), list_length(), NIL, nodeTag, NULL, ObjectIdGetDatum, quote_identifier(), strVal, T_Float, T_Integer, T_String, TypeCast::typeName, typenameTypeIdAndMod(), A_Const::val, val, and WARNING.

Referenced by ExtractSetVariableArgs(), and SetPGVariable().

{
    struct config_generic *record;
    int         flags;
    StringInfoData buf;
    ListCell   *l;

    /* Fast path if just DEFAULT */
    if (args == NIL)
        return NULL;

    /*
     * Get flags for the variable; if it's not known, use default flags.
     * (Caller might throw error later, but not our business to do so here.)
     */
    record = find_option(name, false, WARNING);
    if (record)
        flags = record->flags;
    else
        flags = 0;

    /* Complain if list input and non-list variable */
    if ((flags & GUC_LIST_INPUT) == 0 &&
        list_length(args) != 1)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                 errmsg("SET %s takes only one argument", name)));

    initStringInfo(&buf);

    /*
     * Each list member may be a plain A_Const node, or an A_Const within a
     * TypeCast; the latter case is supported only for ConstInterval arguments
     * (for SET TIME ZONE).
     */
    foreach(l, args)
    {
        Node       *arg = (Node *) lfirst(l);
        char       *val;
        TypeName   *typeName = NULL;
        A_Const    *con;

        if (l != list_head(args))
            appendStringInfo(&buf, ", ");

        if (IsA(arg, TypeCast))
        {
            TypeCast   *tc = (TypeCast *) arg;

            arg = tc->arg;
            typeName = tc->typeName;
        }

        if (!IsA(arg, A_Const))
            elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
        con = (A_Const *) arg;

        switch (nodeTag(&con->val))
        {
            case T_Integer:
                appendStringInfo(&buf, "%ld", intVal(&con->val));
                break;
            case T_Float:
                /* represented as a string, so just copy it */
                appendStringInfoString(&buf, strVal(&con->val));
                break;
            case T_String:
                val = strVal(&con->val);
                if (typeName != NULL)
                {
                    /*
                     * Must be a ConstInterval argument for TIME ZONE. Coerce
                     * to interval and back to normalize the value and account
                     * for any typmod.
                     */
                    Oid         typoid;
                    int32       typmod;
                    Datum       interval;
                    char       *intervalout;

                    typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
                    Assert(typoid == INTERVALOID);

                    interval =
                        DirectFunctionCall3(interval_in,
                                            CStringGetDatum(val),
                                            ObjectIdGetDatum(InvalidOid),
                                            Int32GetDatum(typmod));

                    intervalout =
                        DatumGetCString(DirectFunctionCall1(interval_out,
                                                            interval));
                    appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
                }
                else
                {
                    /*
                     * Plain string literal or identifier.  For quote mode,
                     * quote it if it's not a vanilla identifier.
                     */
                    if (flags & GUC_LIST_QUOTE)
                        appendStringInfoString(&buf, quote_identifier(val));
                    else
                        appendStringInfoString(&buf, val);
                }
                break;
            default:
                elog(ERROR, "unrecognized node type: %d",
                     (int) nodeTag(&con->val));
                break;
        }
    }

    return buf.data;
}

struct config_generic** get_guc_variables ( void   )  [read]

Definition at line 3596 of file guc.c.

Referenced by GucInfoMain().

{
    return guc_variables;
}

const char* GetConfigOption ( const char *  name,
bool  missing_ok,
bool  restrict_superuser 
)

Definition at line 5962 of file guc.c.

References config_enum_lookup_by_value(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_SUPERUSER_ONLY, NULL, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, snprintf(), superuser(), and config_generic::vartype.

Referenced by applyRemoteGucs(), and PostmasterMain().

{
    struct config_generic *record;
    static char buffer[256];

    record = find_option(name, false, ERROR);
    if (record == NULL)
    {
        if (missing_ok)
            return NULL;
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("unrecognized configuration parameter \"%s\"",
                        name)));
    }
    if (restrict_superuser &&
        (record->flags & GUC_SUPERUSER_ONLY) &&
        !superuser())
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to examine \"%s\"", name)));

    switch (record->vartype)
    {
        case PGC_BOOL:
            return *((struct config_bool *) record)->variable ? "on" : "off";

        case PGC_INT:
            snprintf(buffer, sizeof(buffer), "%d",
                     *((struct config_int *) record)->variable);
            return buffer;

        case PGC_REAL:
            snprintf(buffer, sizeof(buffer), "%g",
                     *((struct config_real *) record)->variable);
            return buffer;

        case PGC_STRING:
            return *((struct config_string *) record)->variable;

        case PGC_ENUM:
            return config_enum_lookup_by_value((struct config_enum *) record,
                                 *((struct config_enum *) record)->variable);
    }
    return NULL;
}

char* GetConfigOptionByName ( const char *  name,
const char **  varname 
)

Definition at line 6910 of file guc.c.

References _ShowOption(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_SUPERUSER_ONLY, config_generic::name, NULL, and superuser().

Referenced by ExtractSetVariableArgs(), GetPGVariableResultDesc(), set_config_by_name(), show_config_by_name(), ShowGUCConfigOption(), and tsa_tsearch2().

{
    struct config_generic *record;

    record = find_option(name, false, ERROR);
    if (record == NULL)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
               errmsg("unrecognized configuration parameter \"%s\"", name)));
    if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to examine \"%s\"", name)));

    if (varname)
        *varname = record->name;

    return _ShowOption(record, true);
}

void GetConfigOptionByNum ( int  varnum,
const char **  values,
bool noshow 
)

Definition at line 6935 of file guc.c.

References _ShowOption(), Assert, config_enum::boot_val, config_string::boot_val, config_real::boot_val, config_int::boot_val, config_bool::boot_val, buf, config_enum_get_options(), config_enum_lookup_by_value(), config_group_names, config_type_names, config_generic::context, config_generic::flags, config_generic::group, GUC_NO_SHOW_ALL, GUC_SUPERUSER_ONLY, GUC_UNIT_BLOCKS, GUC_UNIT_KB, GUC_UNIT_MEMORY, GUC_UNIT_MIN, GUC_UNIT_MS, GUC_UNIT_S, GUC_UNIT_TIME, GUC_UNIT_XBLOCKS, GucContext_Names, GucSource_Names, config_generic::long_desc, config_real::max, config_int::max, config_real::min, config_int::min, config_generic::name, NULL, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_FILE, PGC_STRING, pstrdup(), config_enum::reset_val, config_string::reset_val, config_real::reset_val, config_int::reset_val, config_bool::reset_val, config_generic::short_desc, snprintf(), config_generic::source, config_generic::sourcefile, config_generic::sourceline, superuser(), and config_generic::vartype.

Referenced by show_all_settings().

{
    char        buffer[256];
    struct config_generic *conf;

    /* check requested variable number valid */
    Assert((varnum >= 0) && (varnum < num_guc_variables));

    conf = guc_variables[varnum];

    if (noshow)
    {
        if ((conf->flags & GUC_NO_SHOW_ALL) ||
            ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
            *noshow = true;
        else
            *noshow = false;
    }

    /* first get the generic attributes */

    /* name */
    values[0] = conf->name;

    /* setting : use _ShowOption in order to avoid duplicating the logic */
    values[1] = _ShowOption(conf, false);

    /* unit */
    if (conf->vartype == PGC_INT)
    {
        static char buf[8];

        switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
        {
            case GUC_UNIT_KB:
                values[2] = "kB";
                break;
            case GUC_UNIT_BLOCKS:
                snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
                values[2] = buf;
                break;
            case GUC_UNIT_XBLOCKS:
                snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
                values[2] = buf;
                break;
            case GUC_UNIT_MS:
                values[2] = "ms";
                break;
            case GUC_UNIT_S:
                values[2] = "s";
                break;
            case GUC_UNIT_MIN:
                values[2] = "min";
                break;
            default:
                values[2] = "";
                break;
        }
    }
    else
        values[2] = NULL;

    /* group */
    values[3] = config_group_names[conf->group];

    /* short_desc */
    values[4] = conf->short_desc;

    /* extra_desc */
    values[5] = conf->long_desc;

    /* context */
    values[6] = GucContext_Names[conf->context];

    /* vartype */
    values[7] = config_type_names[conf->vartype];

    /* source */
    values[8] = GucSource_Names[conf->source];

    /* now get the type specifc attributes */
    switch (conf->vartype)
    {
        case PGC_BOOL:
            {
                struct config_bool *lconf = (struct config_bool *) conf;

                /* min_val */
                values[9] = NULL;

                /* max_val */
                values[10] = NULL;

                /* enumvals */
                values[11] = NULL;

                /* boot_val */
                values[12] = pstrdup(lconf->boot_val ? "on" : "off");

                /* reset_val */
                values[13] = pstrdup(lconf->reset_val ? "on" : "off");
            }
            break;

        case PGC_INT:
            {
                struct config_int *lconf = (struct config_int *) conf;

                /* min_val */
                snprintf(buffer, sizeof(buffer), "%d", lconf->min);
                values[9] = pstrdup(buffer);

                /* max_val */
                snprintf(buffer, sizeof(buffer), "%d", lconf->max);
                values[10] = pstrdup(buffer);

                /* enumvals */
                values[11] = NULL;

                /* boot_val */
                snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
                values[12] = pstrdup(buffer);

                /* reset_val */
                snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
                values[13] = pstrdup(buffer);
            }
            break;

        case PGC_REAL:
            {
                struct config_real *lconf = (struct config_real *) conf;

                /* min_val */
                snprintf(buffer, sizeof(buffer), "%g", lconf->min);
                values[9] = pstrdup(buffer);

                /* max_val */
                snprintf(buffer, sizeof(buffer), "%g", lconf->max);
                values[10] = pstrdup(buffer);

                /* enumvals */
                values[11] = NULL;

                /* boot_val */
                snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
                values[12] = pstrdup(buffer);

                /* reset_val */
                snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
                values[13] = pstrdup(buffer);
            }
            break;

        case PGC_STRING:
            {
                struct config_string *lconf = (struct config_string *) conf;

                /* min_val */
                values[9] = NULL;

                /* max_val */
                values[10] = NULL;

                /* enumvals */
                values[11] = NULL;

                /* boot_val */
                if (lconf->boot_val == NULL)
                    values[12] = NULL;
                else
                    values[12] = pstrdup(lconf->boot_val);

                /* reset_val */
                if (lconf->reset_val == NULL)
                    values[13] = NULL;
                else
                    values[13] = pstrdup(lconf->reset_val);
            }
            break;

        case PGC_ENUM:
            {
                struct config_enum *lconf = (struct config_enum *) conf;

                /* min_val */
                values[9] = NULL;

                /* max_val */
                values[10] = NULL;

                /* enumvals */

                /*
                 * NOTE! enumvals with double quotes in them are not
                 * supported!
                 */
                values[11] = config_enum_get_options((struct config_enum *) conf,
                                                     "{\"", "\"}", "\",\"");

                /* boot_val */
                values[12] = pstrdup(config_enum_lookup_by_value(lconf,
                                                           lconf->boot_val));

                /* reset_val */
                values[13] = pstrdup(config_enum_lookup_by_value(lconf,
                                                          lconf->reset_val));
            }
            break;

        default:
            {
                /*
                 * should never get here, but in case we do, set 'em to NULL
                 */

                /* min_val */
                values[9] = NULL;

                /* max_val */
                values[10] = NULL;

                /* enumvals */
                values[11] = NULL;

                /* boot_val */
                values[12] = NULL;

                /* reset_val */
                values[13] = NULL;
            }
            break;
    }

    /*
     * If the setting came from a config file, set the source location. For
     * security reasons, we don't show source file/line number for
     * non-superusers.
     */
    if (conf->source == PGC_S_FILE && superuser())
    {
        values[14] = conf->sourcefile;
        snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
        values[15] = pstrdup(buffer);
    }
    else
    {
        values[14] = NULL;
        values[15] = NULL;
    }
}

const char* GetConfigOptionResetString ( const char *  name  ) 

Definition at line 6017 of file guc.c.

References config_enum_lookup_by_value(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_SUPERUSER_ONLY, NULL, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, snprintf(), superuser(), and config_generic::vartype.

Referenced by check_datestyle().

{
    struct config_generic *record;
    static char buffer[256];

    record = find_option(name, false, ERROR);
    if (record == NULL)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
               errmsg("unrecognized configuration parameter \"%s\"", name)));
    if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to examine \"%s\"", name)));

    switch (record->vartype)
    {
        case PGC_BOOL:
            return ((struct config_bool *) record)->reset_val ? "on" : "off";

        case PGC_INT:
            snprintf(buffer, sizeof(buffer), "%d",
                     ((struct config_int *) record)->reset_val);
            return buffer;

        case PGC_REAL:
            snprintf(buffer, sizeof(buffer), "%g",
                     ((struct config_real *) record)->reset_val);
            return buffer;

        case PGC_STRING:
            return ((struct config_string *) record)->reset_val;

        case PGC_ENUM:
            return config_enum_lookup_by_value((struct config_enum *) record,
                                 ((struct config_enum *) record)->reset_val);
    }
    return NULL;
}

int GetNumConfigOptions ( void   ) 

Definition at line 7191 of file guc.c.

Referenced by GucInfoMain(), and show_all_settings().

{
    return num_guc_variables;
}

void GetPGVariable ( const char *  name,
DestReceiver dest 
)

Definition at line 6770 of file guc.c.

References guc_name_compare(), ShowAllGUCConfig(), and ShowGUCConfigOption().

Referenced by standard_ProcessUtility().

{
    if (guc_name_compare(name, "all") == 0)
        ShowAllGUCConfig(dest);
    else
        ShowGUCConfigOption(name, dest);
}

TupleDesc GetPGVariableResultDesc ( const char *  name  ) 

Definition at line 6779 of file guc.c.

References CreateTemplateTupleDesc(), GetConfigOptionByName(), guc_name_compare(), TEXTOID, and TupleDescInitEntry().

Referenced by UtilityTupleDescriptor().

{
    TupleDesc   tupdesc;

    if (guc_name_compare(name, "all") == 0)
    {
        /* need a tuple descriptor representing three TEXT columns */
        tupdesc = CreateTemplateTupleDesc(3, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
                           TEXTOID, -1, 0);
    }
    else
    {
        const char *varname;

        /* Get the canonical spelling of name */
        (void) GetConfigOptionByName(name, &varname);

        /* need a tuple descriptor representing a single TEXT column */
        tupdesc = CreateTemplateTupleDesc(1, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
                           TEXTOID, -1, 0);
    }
    return tupdesc;
}

void GUC_check_errcode ( int  sqlerrcode  ) 
static void* guc_malloc ( int  elevel,
size_t  size 
) [static]

Definition at line 3385 of file guc.c.

References ereport, errcode(), errmsg(), malloc, and NULL.

Referenced by add_guc_variable(), add_placeholder_variable(), assign_pgstat_temp_directory(), build_guc_variables(), check_effective_io_concurrency(), check_log_destination(), init_custom_variable(), ParseLongOption(), and SelectConfigFiles().

{
    void       *data;

    /* Avoid unportable behavior of malloc(0) */
    if (size == 0)
        size = 1;
    data = malloc(size);
    if (data == NULL)
        ereport(elevel,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory")));
    return data;
}

static int guc_name_compare ( const char *  namea,
const char *  nameb 
) [static]

Definition at line 3842 of file guc.c.

Referenced by find_option(), GetPGVariable(), GetPGVariableResultDesc(), and guc_var_compare().

{
    /*
     * The temptation to use strcasecmp() here must be resisted, because the
     * array ordering has to remain stable across setlocale() calls. So, build
     * our own with a simple ASCII-only downcasing.
     */
    while (*namea && *nameb)
    {
        char        cha = *namea++;
        char        chb = *nameb++;

        if (cha >= 'A' && cha <= 'Z')
            cha += 'a' - 'A';
        if (chb >= 'A' && chb <= 'Z')
            chb += 'a' - 'A';
        if (cha != chb)
            return cha - chb;
    }
    if (*namea)
        return 1;               /* a is longer */
    if (*nameb)
        return -1;              /* b is longer */
    return 0;
}

static void* guc_realloc ( int  elevel,
void *  old,
size_t  size 
) [static]

Definition at line 3401 of file guc.c.

References ereport, errcode(), errmsg(), NULL, and realloc.

Referenced by add_guc_variable().

{
    void       *data;

    /* Avoid unportable behavior of realloc(NULL, 0) */
    if (old == NULL && size == 0)
        size = 1;
    data = realloc(old, size);
    if (data == NULL)
        ereport(elevel,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory")));
    return data;
}

static char* guc_strdup ( int  elevel,
const char *  src 
) [static]

Definition at line 3417 of file guc.c.

References ereport, errcode(), errmsg(), and NULL.

Referenced by add_placeholder_variable(), init_custom_variable(), InitializeOneGUCOption(), ParseLongOption(), set_config_option(), and set_config_sourcefile().

{
    char       *data;

    data = strdup(src);
    if (data == NULL)
        ereport(elevel,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory")));
    return data;
}

static int guc_var_compare ( const void *  a,
const void *  b 
) [static]

Definition at line 3830 of file guc.c.

References guc_name_compare(), and config_generic::name.

Referenced by add_guc_variable(), and build_guc_variables().

{
    const struct config_generic *confa = *(struct config_generic * const *) a;
    const struct config_generic *confb = *(struct config_generic * const *) b;

    return guc_name_compare(confa->name, confb->name);
}

ArrayType* GUCArrayAdd ( ArrayType array,
const char *  name,
const char *  value 
)

Definition at line 7829 of file guc.c.

References ARR_DIMS, ARR_ELEMTYPE, ARR_LBOUND, ARR_NDIM, array_ref(), array_set(), Assert, construct_array(), CStringGetTextDatum, find_option(), config_generic::name, palloc(), TextDatumGetCString, TEXTOID, validate_option_array_item(), and WARNING.

Referenced by AlterSetting(), and update_proconfig_value().

{
    struct config_generic *record;
    Datum       datum;
    char       *newval;
    ArrayType  *a;

    Assert(name);
    Assert(value);

    /* test if the option is valid and we're allowed to set it */
    (void) validate_option_array_item(name, value, false);

    /* normalize name (converts obsolete GUC names to modern spellings) */
    record = find_option(name, false, WARNING);
    if (record)
        name = record->name;

    /* build new item for array */
    newval = palloc(strlen(name) + 1 + strlen(value) + 1);
    sprintf(newval, "%s=%s", name, value);
    datum = CStringGetTextDatum(newval);

    if (array)
    {
        int         index;
        bool        isnull;
        int         i;

        Assert(ARR_ELEMTYPE(array) == TEXTOID);
        Assert(ARR_NDIM(array) == 1);
        Assert(ARR_LBOUND(array)[0] == 1);

        index = ARR_DIMS(array)[0] + 1; /* add after end */

        for (i = 1; i <= ARR_DIMS(array)[0]; i++)
        {
            Datum       d;
            char       *current;

            d = array_ref(array, 1, &i,
                          -1 /* varlenarray */ ,
                          -1 /* TEXT's typlen */ ,
                          false /* TEXT's typbyval */ ,
                          'i' /* TEXT's typalign */ ,
                          &isnull);
            if (isnull)
                continue;
            current = TextDatumGetCString(d);

            /* check for match up through and including '=' */
            if (strncmp(current, newval, strlen(name) + 1) == 0)
            {
                index = i;
                break;
            }
        }

        a = array_set(array, 1, &index,
                      datum,
                      false,
                      -1 /* varlena array */ ,
                      -1 /* TEXT's typlen */ ,
                      false /* TEXT's typbyval */ ,
                      'i' /* TEXT's typalign */ );
    }
    else
        a = construct_array(&datum, 1,
                            TEXTOID,
                            -1, false, 'i');

    return a;
}

ArrayType* GUCArrayDelete ( ArrayType array,
const char *  name 
)

Definition at line 7910 of file guc.c.

References ARR_DIMS, array_ref(), array_set(), Assert, construct_array(), find_option(), config_generic::name, NULL, TextDatumGetCString, TEXTOID, val, validate_option_array_item(), and WARNING.

Referenced by AlterSetting(), and update_proconfig_value().

{
    struct config_generic *record;
    ArrayType  *newarray;
    int         i;
    int         index;

    Assert(name);

    /* test if the option is valid and we're allowed to set it */
    (void) validate_option_array_item(name, NULL, false);

    /* normalize name (converts obsolete GUC names to modern spellings) */
    record = find_option(name, false, WARNING);
    if (record)
        name = record->name;

    /* if array is currently null, then surely nothing to delete */
    if (!array)
        return NULL;

    newarray = NULL;
    index = 1;

    for (i = 1; i <= ARR_DIMS(array)[0]; i++)
    {
        Datum       d;
        char       *val;
        bool        isnull;

        d = array_ref(array, 1, &i,
                      -1 /* varlenarray */ ,
                      -1 /* TEXT's typlen */ ,
                      false /* TEXT's typbyval */ ,
                      'i' /* TEXT's typalign */ ,
                      &isnull);
        if (isnull)
            continue;
        val = TextDatumGetCString(d);

        /* ignore entry if it's what we want to delete */
        if (strncmp(val, name, strlen(name)) == 0
            && val[strlen(name)] == '=')
            continue;

        /* else add it to the output array */
        if (newarray)
            newarray = array_set(newarray, 1, &index,
                                 d,
                                 false,
                                 -1 /* varlenarray */ ,
                                 -1 /* TEXT's typlen */ ,
                                 false /* TEXT's typbyval */ ,
                                 'i' /* TEXT's typalign */ );
        else
            newarray = construct_array(&d, 1,
                                       TEXTOID,
                                       -1, false, 'i');

        index++;
    }

    return newarray;
}

ArrayType* GUCArrayReset ( ArrayType array  ) 

Definition at line 7982 of file guc.c.

References ARR_DIMS, array_ref(), array_set(), construct_array(), NULL, pfree(), superuser(), TextDatumGetCString, TEXTOID, val, and validate_option_array_item().

Referenced by AlterSetting().

{
    ArrayType  *newarray;
    int         i;
    int         index;

    /* if array is currently null, nothing to do */
    if (!array)
        return NULL;

    /* if we're superuser, we can delete everything, so just do it */
    if (superuser())
        return NULL;

    newarray = NULL;
    index = 1;

    for (i = 1; i <= ARR_DIMS(array)[0]; i++)
    {
        Datum       d;
        char       *val;
        char       *eqsgn;
        bool        isnull;

        d = array_ref(array, 1, &i,
                      -1 /* varlenarray */ ,
                      -1 /* TEXT's typlen */ ,
                      false /* TEXT's typbyval */ ,
                      'i' /* TEXT's typalign */ ,
                      &isnull);
        if (isnull)
            continue;
        val = TextDatumGetCString(d);

        eqsgn = strchr(val, '=');
        *eqsgn = '\0';

        /* skip if we have permission to delete it */
        if (validate_option_array_item(val, NULL, true))
            continue;

        /* else add it to the output array */
        if (newarray)
            newarray = array_set(newarray, 1, &index,
                                 d,
                                 false,
                                 -1 /* varlenarray */ ,
                                 -1 /* TEXT's typlen */ ,
                                 false /* TEXT's typbyval */ ,
                                 'i' /* TEXT's typalign */ );
        else
            newarray = construct_array(&d, 1,
                                       TEXTOID,
                                       -1, false, 'i');

        index++;
        pfree(val);
    }

    return newarray;
}

static struct config_generic* init_custom_variable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
GucContext  context,
int  flags,
enum config_type  type,
size_t  sz 
) [static, read]

Definition at line 6389 of file guc.c.

References config_generic::context, elog, ERROR, FATAL, config_generic::flags, config_generic::group, guc_malloc(), guc_strdup(), config_generic::long_desc, config_generic::name, PGC_POSTMASTER, process_shared_preload_libraries_in_progress, config_generic::short_desc, and config_generic::vartype.

Referenced by DefineCustomBoolVariable(), DefineCustomEnumVariable(), DefineCustomIntVariable(), DefineCustomRealVariable(), and DefineCustomStringVariable().

{
    struct config_generic *gen;

    /*
     * Only allow custom PGC_POSTMASTER variables to be created during shared
     * library preload; any later than that, we can't ensure that the value
     * doesn't change after startup.  This is a fatal elog if it happens; just
     * erroring out isn't safe because we don't know what the calling loadable
     * module might already have hooked into.
     */
    if (context == PGC_POSTMASTER &&
        !process_shared_preload_libraries_in_progress)
        elog(FATAL, "cannot create PGC_POSTMASTER variables after startup");

    gen = (struct config_generic *) guc_malloc(ERROR, sz);
    memset(gen, 0, sz);

    gen->name = guc_strdup(ERROR, name);
    gen->context = context;
    gen->group = CUSTOM_OPTIONS;
    gen->short_desc = short_desc;
    gen->long_desc = long_desc;
    gen->flags = flags;
    gen->vartype = type;

    return gen;
}

void InitializeGUCOptions ( void   ) 

Definition at line 3876 of file guc.c.

References build_guc_variables(), i, InitializeGUCOptionsFromEnvironment(), InitializeOneGUCOption(), pg_timezone_initialize(), PGC_POSTMASTER, PGC_S_OVERRIDE, and SetConfigOption().

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

{
    int         i;

    /*
     * Before log_line_prefix could possibly receive a nonempty setting, make
     * sure that timezone processing is minimally alive (see elog.c).
     */
    pg_timezone_initialize();

    /*
     * Build sorted array of all GUC variables.
     */
    build_guc_variables();

    /*
     * Load all variables with their compiled-in defaults, and initialize
     * status fields as needed.
     */
    for (i = 0; i < num_guc_variables; i++)
    {
        InitializeOneGUCOption(guc_variables[i]);
    }

    guc_dirty = false;

    reporting_enabled = false;

    /*
     * Prevent any attempt to override the transaction modes from
     * non-interactive sources.
     */
    SetConfigOption("transaction_isolation", "default",
                    PGC_POSTMASTER, PGC_S_OVERRIDE);
    SetConfigOption("transaction_read_only", "no",
                    PGC_POSTMASTER, PGC_S_OVERRIDE);
    SetConfigOption("transaction_deferrable", "no",
                    PGC_POSTMASTER, PGC_S_OVERRIDE);

    /*
     * For historical reasons, some GUC parameters can receive defaults from
     * environment variables.  Process those settings.
     */
    InitializeGUCOptionsFromEnvironment();
}

static void InitializeGUCOptionsFromEnvironment ( void   )  [static]

Definition at line 3932 of file guc.c.

References get_stack_depth_rlimit(), Min, NULL, PGC_POSTMASTER, PGC_S_ENV_VAR, and SetConfigOption().

Referenced by InitializeGUCOptions().

{
    char       *env;
    long        stack_rlimit;

    env = getenv("PGPORT");
    if (env != NULL)
        SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);

    env = getenv("PGDATESTYLE");
    if (env != NULL)
        SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);

    env = getenv("PGCLIENTENCODING");
    if (env != NULL)
        SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);

    /*
     * rlimit isn't exactly an "environment variable", but it behaves about
     * the same.  If we can identify the platform stack depth rlimit, increase
     * default stack depth setting up to whatever is safe (but at most 2MB).
     */
    stack_rlimit = get_stack_depth_rlimit();
    if (stack_rlimit > 0)
    {
        long        new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;

        if (new_limit > 100)
        {
            char        limbuf[16];

            new_limit = Min(new_limit, 2048);
            sprintf(limbuf, "%ld", new_limit);
            SetConfigOption("max_stack_depth", limbuf,
                            PGC_POSTMASTER, PGC_S_ENV_VAR);
        }
    }
}

static void InitializeOneGUCOption ( struct config_generic gconf  )  [static]

Definition at line 3978 of file guc.c.

References Assert, config_enum::assign_hook, config_string::assign_hook, config_real::assign_hook, config_int::assign_hook, config_bool::assign_hook, config_enum::boot_val, config_string::boot_val, config_real::boot_val, config_int::boot_val, config_bool::boot_val, call_bool_check_hook(), call_enum_check_hook(), call_int_check_hook(), call_real_check_hook(), call_string_check_hook(), elog, config_generic::extra, FATAL, config_enum::gen, config_string::gen, config_real::gen, config_int::gen, config_bool::gen, guc_strdup(), LOG, config_real::max, config_int::max, config_real::min, config_int::min, config_generic::name, NULL, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_DEFAULT, PGC_STRING, config_enum::reset_extra, config_string::reset_extra, config_real::reset_extra, config_int::reset_extra, config_bool::reset_extra, config_generic::reset_scontext, config_generic::reset_source, config_enum::reset_val, config_string::reset_val, config_real::reset_val, config_int::reset_val, config_bool::reset_val, config_generic::scontext, config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_generic::stack, config_generic::status, config_enum::variable, config_string::variable, config_real::variable, config_int::variable, config_bool::variable, and config_generic::vartype.

Referenced by define_custom_variable(), and InitializeGUCOptions().

{
    gconf->status = 0;
    gconf->source = PGC_S_DEFAULT;
    gconf->reset_source = PGC_S_DEFAULT;
    gconf->scontext = PGC_INTERNAL;
    gconf->reset_scontext = PGC_INTERNAL;
    gconf->stack = NULL;
    gconf->extra = NULL;
    gconf->sourcefile = NULL;
    gconf->sourceline = 0;

    switch (gconf->vartype)
    {
        case PGC_BOOL:
            {
                struct config_bool *conf = (struct config_bool *) gconf;
                bool        newval = conf->boot_val;
                void       *extra = NULL;

                if (!call_bool_check_hook(conf, &newval, &extra,
                                          PGC_S_DEFAULT, LOG))
                    elog(FATAL, "failed to initialize %s to %d",
                         conf->gen.name, (int) newval);
                if (conf->assign_hook)
                    (*conf->assign_hook) (newval, extra);
                *conf->variable = conf->reset_val = newval;
                conf->gen.extra = conf->reset_extra = extra;
                break;
            }
        case PGC_INT:
            {
                struct config_int *conf = (struct config_int *) gconf;
                int         newval = conf->boot_val;
                void       *extra = NULL;

                Assert(newval >= conf->min);
                Assert(newval <= conf->max);
                if (!call_int_check_hook(conf, &newval, &extra,
                                         PGC_S_DEFAULT, LOG))
                    elog(FATAL, "failed to initialize %s to %d",
                         conf->gen.name, newval);
                if (conf->assign_hook)
                    (*conf->assign_hook) (newval, extra);
                *conf->variable = conf->reset_val = newval;
                conf->gen.extra = conf->reset_extra = extra;
                break;
            }
        case PGC_REAL:
            {
                struct config_real *conf = (struct config_real *) gconf;
                double      newval = conf->boot_val;
                void       *extra = NULL;

                Assert(newval >= conf->min);
                Assert(newval <= conf->max);
                if (!call_real_check_hook(conf, &newval, &extra,
                                          PGC_S_DEFAULT, LOG))
                    elog(FATAL, "failed to initialize %s to %g",
                         conf->gen.name, newval);
                if (conf->assign_hook)
                    (*conf->assign_hook) (newval, extra);
                *conf->variable = conf->reset_val = newval;
                conf->gen.extra = conf->reset_extra = extra;
                break;
            }
        case PGC_STRING:
            {
                struct config_string *conf = (struct config_string *) gconf;
                char       *newval;
                void       *extra = NULL;

                /* non-NULL boot_val must always get strdup'd */
                if (conf->boot_val != NULL)
                    newval = guc_strdup(FATAL, conf->boot_val);
                else
                    newval = NULL;

                if (!call_string_check_hook(conf, &newval, &extra,
                                            PGC_S_DEFAULT, LOG))
                    elog(FATAL, "failed to initialize %s to \"%s\"",
                         conf->gen.name, newval ? newval : "");
                if (conf->assign_hook)
                    (*conf->assign_hook) (newval, extra);
                *conf->variable = conf->reset_val = newval;
                conf->gen.extra = conf->reset_extra = extra;
                break;
            }
        case PGC_ENUM:
            {
                struct config_enum *conf = (struct config_enum *) gconf;
                int         newval = conf->boot_val;
                void       *extra = NULL;

                if (!call_enum_check_hook(conf, &newval, &extra,
                                          PGC_S_DEFAULT, LOG))
                    elog(FATAL, "failed to initialize %s to %d",
                         conf->gen.name, newval);
                if (conf->assign_hook)
                    (*conf->assign_hook) (newval, extra);
                *conf->variable = conf->reset_val = newval;
                conf->gen.extra = conf->reset_extra = extra;
                break;
            }
    }
}

int NewGUCNestLevel ( void   ) 
bool parse_int ( const char *  value,
int *  result,
int  flags,
const char **  hintmsg 
)

Definition at line 4800 of file guc.c.

References gettext_noop, GUC_UNIT_BLOCKS, GUC_UNIT_KB, GUC_UNIT_MEMORY, GUC_UNIT_MIN, GUC_UNIT_MS, GUC_UNIT_S, GUC_UNIT_TIME, GUC_UNIT_XBLOCKS, KB_PER_GB, KB_PER_MB, and val.

Referenced by parse_one_reloption(), and set_config_option().

{
    int64       val;
    char       *endptr;

    /* To suppress compiler warnings, always set output params */
    if (result)
        *result = 0;
    if (hintmsg)
        *hintmsg = NULL;

    /* We assume here that int64 is at least as wide as long */
    errno = 0;
    val = strtol(value, &endptr, 0);

    if (endptr == value)
        return false;           /* no HINT for integer syntax error */

    if (errno == ERANGE || val != (int64) ((int32) val))
    {
        if (hintmsg)
            *hintmsg = gettext_noop("Value exceeds integer range.");
        return false;
    }

    /* allow whitespace between integer and unit */
    while (isspace((unsigned char) *endptr))
        endptr++;

    /* Handle possible unit */
    if (*endptr != '\0')
    {
        /*
         * Note: the multiple-switch coding technique here is a bit tedious,
         * but seems necessary to avoid intermediate-value overflows.
         */
        if (flags & GUC_UNIT_MEMORY)
        {
            /* Set hint for use if no match or trailing garbage */
            if (hintmsg)
                *hintmsg = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", and \"GB\".");

#if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
#error BLCKSZ must be between 1KB and 1MB
#endif
#if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
#error XLOG_BLCKSZ must be between 1KB and 1MB
#endif

            if (strncmp(endptr, "kB", 2) == 0)
            {
                endptr += 2;
                switch (flags & GUC_UNIT_MEMORY)
                {
                    case GUC_UNIT_BLOCKS:
                        val /= (BLCKSZ / 1024);
                        break;
                    case GUC_UNIT_XBLOCKS:
                        val /= (XLOG_BLCKSZ / 1024);
                        break;
                }
            }
            else if (strncmp(endptr, "MB", 2) == 0)
            {
                endptr += 2;
                switch (flags & GUC_UNIT_MEMORY)
                {
                    case GUC_UNIT_KB:
                        val *= KB_PER_MB;
                        break;
                    case GUC_UNIT_BLOCKS:
                        val *= KB_PER_MB / (BLCKSZ / 1024);
                        break;
                    case GUC_UNIT_XBLOCKS:
                        val *= KB_PER_MB / (XLOG_BLCKSZ / 1024);
                        break;
                }
            }
            else if (strncmp(endptr, "GB", 2) == 0)
            {
                endptr += 2;
                switch (flags & GUC_UNIT_MEMORY)
                {
                    case GUC_UNIT_KB:
                        val *= KB_PER_GB;
                        break;
                    case GUC_UNIT_BLOCKS:
                        val *= KB_PER_GB / (BLCKSZ / 1024);
                        break;
                    case GUC_UNIT_XBLOCKS:
                        val *= KB_PER_GB / (XLOG_BLCKSZ / 1024);
                        break;
                }
            }
        }
        else if (flags & GUC_UNIT_TIME)
        {
            /* Set hint for use if no match or trailing garbage */
            if (hintmsg)
                *hintmsg = gettext_noop("Valid units for this parameter are \"ms\", \"s\", \"min\", \"h\", and \"d\".");

            if (strncmp(endptr, "ms", 2) == 0)
            {
                endptr += 2;
                switch (flags & GUC_UNIT_TIME)
                {
                    case GUC_UNIT_S:
                        val /= MS_PER_S;
                        break;
                    case GUC_UNIT_MIN:
                        val /= MS_PER_MIN;
                        break;
                }
            }
            else if (strncmp(endptr, "s", 1) == 0)
            {
                endptr += 1;
                switch (flags & GUC_UNIT_TIME)
                {
                    case GUC_UNIT_MS:
                        val *= MS_PER_S;
                        break;
                    case GUC_UNIT_MIN:
                        val /= S_PER_MIN;
                        break;
                }
            }
            else if (strncmp(endptr, "min", 3) == 0)
            {
                endptr += 3;
                switch (flags & GUC_UNIT_TIME)
                {
                    case GUC_UNIT_MS:
                        val *= MS_PER_MIN;
                        break;
                    case GUC_UNIT_S:
                        val *= S_PER_MIN;
                        break;
                }
            }
            else if (strncmp(endptr, "h", 1) == 0)
            {
                endptr += 1;
                switch (flags & GUC_UNIT_TIME)
                {
                    case GUC_UNIT_MS:
                        val *= MS_PER_H;
                        break;
                    case GUC_UNIT_S:
                        val *= S_PER_H;
                        break;
                    case GUC_UNIT_MIN:
                        val *= MIN_PER_H;
                        break;
                }
            }
            else if (strncmp(endptr, "d", 1) == 0)
            {
                endptr += 1;
                switch (flags & GUC_UNIT_TIME)
                {
                    case GUC_UNIT_MS:
                        val *= MS_PER_D;
                        break;
                    case GUC_UNIT_S:
                        val *= S_PER_D;
                        break;
                    case GUC_UNIT_MIN:
                        val *= MIN_PER_D;
                        break;
                }
            }
        }

        /* allow whitespace after unit */
        while (isspace((unsigned char) *endptr))
            endptr++;

        if (*endptr != '\0')
            return false;       /* appropriate hint, if any, already set */

        /* Check for overflow due to units conversion */
        if (val != (int64) ((int32) val))
        {
            if (hintmsg)
                *hintmsg = gettext_noop("Value exceeds integer range.");
            return false;
        }
    }

    if (result)
        *result = (int) val;
    return true;
}

bool parse_real ( const char *  value,
double *  result 
)

Definition at line 5003 of file guc.c.

References val.

Referenced by parse_one_reloption(), and set_config_option().

{
    double      val;
    char       *endptr;

    if (result)
        *result = 0;            /* suppress compiler warning */

    errno = 0;
    val = strtod(value, &endptr);
    if (endptr == value || errno == ERANGE)
        return false;

    /* allow whitespace after number */
    while (isspace((unsigned char) *endptr))
        endptr++;
    if (*endptr != '\0')
        return false;

    if (result)
        *result = val;
    return true;
}

void ParseLongOption ( const char *  string,
char **  name,
char **  value 
)

Definition at line 7733 of file guc.c.

References AssertArg, FATAL, guc_malloc(), guc_strdup(), and strlcpy().

Referenced by AuxiliaryProcessMain(), PostmasterMain(), process_postgres_switches(), and ProcessGUCArray().

{
    size_t      equal_pos;
    char       *cp;

    AssertArg(string);
    AssertArg(name);
    AssertArg(value);

    equal_pos = strcspn(string, "=");

    if (string[equal_pos] == '=')
    {
        *name = guc_malloc(FATAL, equal_pos + 1);
        strlcpy(*name, string, equal_pos + 1);

        *value = guc_strdup(FATAL, &string[equal_pos + 1]);
    }
    else
    {
        /* no equal sign in string */
        *name = guc_strdup(FATAL, string);
        *value = NULL;
    }

    for (cp = *name; *cp; cp++)
        if (*cp == '-')
            *cp = '_';
}

static void pg_timezone_abbrev_initialize ( void   )  [static]

Definition at line 8569 of file guc.c.

References PGC_POSTMASTER, PGC_S_DYNAMIC_DEFAULT, and SetConfigOption().

Referenced by SelectConfigFiles().

{
    SetConfigOption("timezone_abbreviations", "Default",
                    PGC_POSTMASTER, PGC_S_DYNAMIC_DEFAULT);
}

void ProcessGUCArray ( ArrayType array,
GucContext  context,
GucSource  source,
GucAction  action 
)

Definition at line 7771 of file guc.c.

References ARR_DIMS, ARR_ELEMTYPE, ARR_LBOUND, ARR_NDIM, array_ref(), Assert, ereport, errcode(), errmsg(), free, name, NULL, ParseLongOption(), pfree(), set_config_option(), TextDatumGetCString, TEXTOID, value, and WARNING.

Referenced by ApplySetting(), fmgr_security_definer(), and ProcedureCreate().

{
    int         i;

    Assert(array != NULL);
    Assert(ARR_ELEMTYPE(array) == TEXTOID);
    Assert(ARR_NDIM(array) == 1);
    Assert(ARR_LBOUND(array)[0] == 1);

    for (i = 1; i <= ARR_DIMS(array)[0]; i++)
    {
        Datum       d;
        bool        isnull;
        char       *s;
        char       *name;
        char       *value;

        d = array_ref(array, 1, &i,
                      -1 /* varlenarray */ ,
                      -1 /* TEXT's typlen */ ,
                      false /* TEXT's typbyval */ ,
                      'i' /* TEXT's typalign */ ,
                      &isnull);

        if (isnull)
            continue;

        s = TextDatumGetCString(d);

        ParseLongOption(s, &name, &value);
        if (!value)
        {
            ereport(WARNING,
                    (errcode(ERRCODE_SYNTAX_ERROR),
                     errmsg("could not parse setting for parameter \"%s\"",
                            name)));
            free(name);
            continue;
        }

        (void) set_config_option(name, value,
                                 context, source,
                                 action, true, 0);

        free(name);
        if (value)
            free(value);
        pfree(s);
    }
}

static void push_old_value ( struct config_generic gconf,
GucAction  action 
) [static]

Definition at line 4349 of file guc.c.

References Assert, discard_stack_value(), GUC_ACTION_LOCAL, GUC_ACTION_SAVE, GUC_ACTION_SET, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, guc_stack::masked, guc_stack::masked_scontext, MemoryContextAllocZero(), guc_stack::nest_level, guc_stack::prev, guc_stack::prior, guc_stack::scontext, config_generic::scontext, set_stack_value(), config_generic::source, guc_stack::source, config_generic::stack, guc_stack::state, and TopTransactionContext.

Referenced by ResetAllOptions(), and set_config_option().

{
    GucStack   *stack;

    /* If we're not inside a nest level, do nothing */
    if (GUCNestLevel == 0)
        return;

    /* Do we already have a stack entry of the current nest level? */
    stack = gconf->stack;
    if (stack && stack->nest_level >= GUCNestLevel)
    {
        /* Yes, so adjust its state if necessary */
        Assert(stack->nest_level == GUCNestLevel);
        switch (action)
        {
            case GUC_ACTION_SET:
                /* SET overrides any prior action at same nest level */
                if (stack->state == GUC_SET_LOCAL)
                {
                    /* must discard old masked value */
                    discard_stack_value(gconf, &stack->masked);
                }
                stack->state = GUC_SET;
                break;
            case GUC_ACTION_LOCAL:
                if (stack->state == GUC_SET)
                {
                    /* SET followed by SET LOCAL, remember SET's value */
                    stack->masked_scontext = gconf->scontext;
                    set_stack_value(gconf, &stack->masked);
                    stack->state = GUC_SET_LOCAL;
                }
                /* in all other cases, no change to stack entry */
                break;
            case GUC_ACTION_SAVE:
                /* Could only have a prior SAVE of same variable */
                Assert(stack->state == GUC_SAVE);
                break;
        }
        Assert(guc_dirty);      /* must be set already */
        return;
    }

    /*
     * Push a new stack entry
     *
     * We keep all the stack entries in TopTransactionContext for simplicity.
     */
    stack = (GucStack *) MemoryContextAllocZero(TopTransactionContext,
                                                sizeof(GucStack));

    stack->prev = gconf->stack;
    stack->nest_level = GUCNestLevel;
    switch (action)
    {
        case GUC_ACTION_SET:
            stack->state = GUC_SET;
            break;
        case GUC_ACTION_LOCAL:
            stack->state = GUC_LOCAL;
            break;
        case GUC_ACTION_SAVE:
            stack->state = GUC_SAVE;
            break;
    }
    stack->source = gconf->source;
    stack->scontext = gconf->scontext;
    set_stack_value(gconf, &stack->prior);

    gconf->stack = stack;

    /* Ensure we remember to pop at end of xact */
    guc_dirty = true;
}

static void reapply_stacked_values ( struct config_generic variable,
struct config_string pHolder,
GucStack stack,
const char *  curvalue,
GucContext  curscontext,
GucSource  cursource 
) [static]

Definition at line 6529 of file guc.c.

References config_string::gen, GUC_ACTION_LOCAL, GUC_ACTION_SAVE, GUC_ACTION_SET, GUC_LOCAL, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, guc_stack::masked, guc_stack::masked_scontext, config_generic::name, name, guc_stack::nest_level, NULL, PGC_S_SESSION, guc_stack::prev, guc_stack::prior, config_generic::reset_scontext, config_generic::reset_source, config_string::reset_val, guc_stack::scontext, set_config_option(), guc_stack::source, config_generic::stack, guc_stack::state, config_var_val::stringval, config_var_value::val, and WARNING.

Referenced by define_custom_variable().

{
    const char *name = variable->name;
    GucStack   *oldvarstack = variable->stack;

    if (stack != NULL)
    {
        /* First, recurse, so that stack items are processed bottom to top */
        reapply_stacked_values(variable, pHolder, stack->prev,
                               stack->prior.val.stringval,
                               stack->scontext, stack->source);

        /* See how to apply the passed-in value */
        switch (stack->state)
        {
            case GUC_SAVE:
                (void) set_config_option(name, curvalue,
                                         curscontext, cursource,
                                         GUC_ACTION_SAVE, true, WARNING);
                break;

            case GUC_SET:
                (void) set_config_option(name, curvalue,
                                         curscontext, cursource,
                                         GUC_ACTION_SET, true, WARNING);
                break;

            case GUC_LOCAL:
                (void) set_config_option(name, curvalue,
                                         curscontext, cursource,
                                         GUC_ACTION_LOCAL, true, WARNING);
                break;

            case GUC_SET_LOCAL:
                /* first, apply the masked value as SET */
                (void) set_config_option(name, stack->masked.val.stringval,
                                       stack->masked_scontext, PGC_S_SESSION,
                                         GUC_ACTION_SET, true, WARNING);
                /* then apply the current value as LOCAL */
                (void) set_config_option(name, curvalue,
                                         curscontext, cursource,
                                         GUC_ACTION_LOCAL, true, WARNING);
                break;
        }

        /* If we successfully made a stack entry, adjust its nest level */
        if (variable->stack != oldvarstack)
            variable->stack->nest_level = stack->nest_level;
    }
    else
    {
        /*
         * We are at the end of the stack.  If the active/previous value is
         * different from the reset value, it must represent a previously
         * committed session value.  Apply it, and then drop the stack entry
         * that set_config_option will have created under the impression that
         * this is to be just a transactional assignment.  (We leak the stack
         * entry.)
         */
        if (curvalue != pHolder->reset_val ||
            curscontext != pHolder->gen.reset_scontext ||
            cursource != pHolder->gen.reset_source)
        {
            (void) set_config_option(name, curvalue,
                                     curscontext, cursource,
                                     GUC_ACTION_SET, true, WARNING);
            variable->stack = NULL;
        }
    }
}

static void ReportGUCOption ( struct config_generic record  )  [static]

Definition at line 4773 of file guc.c.

References _ShowOption(), config_generic::flags, GUC_REPORT, config_generic::name, pfree(), pq_beginmessage(), pq_endmessage(), pq_sendstring(), and val.

Referenced by AtEOXact_GUC(), BeginReportingGUCOptions(), ResetAllOptions(), and set_config_option().

{
    if (reporting_enabled && (record->flags & GUC_REPORT))
    {
        char       *val = _ShowOption(record, false);
        StringInfoData msgbuf;

        pq_beginmessage(&msgbuf, 'S');
        pq_sendstring(&msgbuf, record->name);
        pq_sendstring(&msgbuf, val);
        pq_endmessage(&msgbuf);

        pfree(val);
    }
}

void ResetAllOptions ( void   ) 

Definition at line 4249 of file guc.c.

References config_enum::assign_hook, config_string::assign_hook, config_real::assign_hook, config_int::assign_hook, config_bool::assign_hook, config_generic::context, config_generic::extra, config_generic::flags, config_enum::gen, config_string::gen, config_real::gen, config_int::gen, config_bool::gen, GUC_ACTION_SET, GUC_NO_RESET_ALL, GUC_REPORT, i, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_OVERRIDE, PGC_STRING, PGC_SUSET, PGC_USERSET, push_old_value(), ReportGUCOption(), config_enum::reset_extra, config_string::reset_extra, config_real::reset_extra, config_int::reset_extra, config_bool::reset_extra, config_generic::reset_scontext, config_generic::reset_source, config_enum::reset_val, config_string::reset_val, config_real::reset_val, config_int::reset_val, config_bool::reset_val, config_generic::scontext, set_extra_field(), set_string_field(), config_generic::source, config_enum::variable, config_string::variable, config_real::variable, config_int::variable, config_bool::variable, and config_generic::vartype.

Referenced by DiscardAll(), and ExecSetVariableStmt().

{
    int         i;

    for (i = 0; i < num_guc_variables; i++)
    {
        struct config_generic *gconf = guc_variables[i];

        /* Don't reset non-SET-able values */
        if (gconf->context != PGC_SUSET &&
            gconf->context != PGC_USERSET)
            continue;
        /* Don't reset if special exclusion from RESET ALL */
        if (gconf->flags & GUC_NO_RESET_ALL)
            continue;
        /* No need to reset if wasn't SET */
        if (gconf->source <= PGC_S_OVERRIDE)
            continue;

        /* Save old value to support transaction abort */
        push_old_value(gconf, GUC_ACTION_SET);

        switch (gconf->vartype)
        {
            case PGC_BOOL:
                {
                    struct config_bool *conf = (struct config_bool *) gconf;

                    if (conf->assign_hook)
                        (*conf->assign_hook) (conf->reset_val,
                                              conf->reset_extra);
                    *conf->variable = conf->reset_val;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    conf->reset_extra);
                    break;
                }
            case PGC_INT:
                {
                    struct config_int *conf = (struct config_int *) gconf;

                    if (conf->assign_hook)
                        (*conf->assign_hook) (conf->reset_val,
                                              conf->reset_extra);
                    *conf->variable = conf->reset_val;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    conf->reset_extra);
                    break;
                }
            case PGC_REAL:
                {
                    struct config_real *conf = (struct config_real *) gconf;

                    if (conf->assign_hook)
                        (*conf->assign_hook) (conf->reset_val,
                                              conf->reset_extra);
                    *conf->variable = conf->reset_val;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    conf->reset_extra);
                    break;
                }
            case PGC_STRING:
                {
                    struct config_string *conf = (struct config_string *) gconf;

                    if (conf->assign_hook)
                        (*conf->assign_hook) (conf->reset_val,
                                              conf->reset_extra);
                    set_string_field(conf, conf->variable, conf->reset_val);
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    conf->reset_extra);
                    break;
                }
            case PGC_ENUM:
                {
                    struct config_enum *conf = (struct config_enum *) gconf;

                    if (conf->assign_hook)
                        (*conf->assign_hook) (conf->reset_val,
                                              conf->reset_extra);
                    *conf->variable = conf->reset_val;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    conf->reset_extra);
                    break;
                }
        }

        gconf->source = gconf->reset_source;
        gconf->scontext = gconf->reset_scontext;

        if (gconf->flags & GUC_REPORT)
            ReportGUCOption(gconf);
    }
}

bool SelectConfigFiles ( const char *  userDoption,
const char *  progname 
)

Definition at line 4098 of file guc.c.

References CONFIG_FILENAME, ConfigFileName, data_directory, DataDir, FATAL, free, guc_malloc(), HBA_FILENAME, HbaFileName, IDENT_FILENAME, IdentFileName, make_absolute_path(), pg_timezone_abbrev_initialize(), PGC_POSTMASTER, PGC_S_OVERRIDE, ProcessConfigFile(), SetConfigOption(), SetDataDir(), strerror(), and write_stderr.

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

{
    char       *configdir;
    char       *fname;
    struct stat stat_buf;

    /* configdir is -D option, or $PGDATA if no -D */
    if (userDoption)
        configdir = make_absolute_path(userDoption);
    else
        configdir = make_absolute_path(getenv("PGDATA"));

    /*
     * Find the configuration file: if config_file was specified on the
     * command line, use it, else use configdir/postgresql.conf.  In any case
     * ensure the result is an absolute path, so that it will be interpreted
     * the same way by future backends.
     */
    if (ConfigFileName)
        fname = make_absolute_path(ConfigFileName);
    else if (configdir)
    {
        fname = guc_malloc(FATAL,
                           strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
        sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
    }
    else
    {
        write_stderr("%s does not know where to find the server configuration file.\n"
                     "You must specify the --config-file or -D invocation "
                     "option or set the PGDATA environment variable.\n",
                     progname);
        return false;
    }

    /*
     * Set the ConfigFileName GUC variable to its final value, ensuring that
     * it can't be overridden later.
     */
    SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
    free(fname);

    /*
     * Now read the config file for the first time.
     */
    if (stat(ConfigFileName, &stat_buf) != 0)
    {
        write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
                     progname, ConfigFileName, strerror(errno));
        free(configdir);
        return false;
    }

    ProcessConfigFile(PGC_POSTMASTER);

    /*
     * If the data_directory GUC variable has been set, use that as DataDir;
     * otherwise use configdir if set; else punt.
     *
     * Note: SetDataDir will copy and absolute-ize its argument, so we don't
     * have to.
     */
    if (data_directory)
        SetDataDir(data_directory);
    else if (configdir)
        SetDataDir(configdir);
    else
    {
        write_stderr("%s does not know where to find the database system data.\n"
                     "This can be specified as \"data_directory\" in \"%s\", "
                     "or by the -D invocation option, or by the "
                     "PGDATA environment variable.\n",
                     progname, ConfigFileName);
        return false;
    }

    /*
     * Reflect the final DataDir value back into the data_directory GUC var.
     * (If you are wondering why we don't just make them a single variable,
     * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
     * child backends specially.  XXX is that still true?  Given that we now
     * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
     * DataDir in advance.)
     */
    SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);

    /*
     * If timezone_abbreviations wasn't set in the configuration file, install
     * the default value.  We do it this way because we can't safely install a
     * "real" value until my_exec_path is set, which may not have happened
     * when InitializeGUCOptions runs, so the bootstrap default value cannot
     * be the real desired default.
     */
    pg_timezone_abbrev_initialize();

    /*
     * Figure out where pg_hba.conf is, and make sure the path is absolute.
     */
    if (HbaFileName)
        fname = make_absolute_path(HbaFileName);
    else if (configdir)
    {
        fname = guc_malloc(FATAL,
                           strlen(configdir) + strlen(HBA_FILENAME) + 2);
        sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
    }
    else
    {
        write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
                     "This can be specified as \"hba_file\" in \"%s\", "
                     "or by the -D invocation option, or by the "
                     "PGDATA environment variable.\n",
                     progname, ConfigFileName);
        return false;
    }
    SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
    free(fname);

    /*
     * Likewise for pg_ident.conf.
     */
    if (IdentFileName)
        fname = make_absolute_path(IdentFileName);
    else if (configdir)
    {
        fname = guc_malloc(FATAL,
                           strlen(configdir) + strlen(IDENT_FILENAME) + 2);
        sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
    }
    else
    {
        write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
                     "This can be specified as \"ident_file\" in \"%s\", "
                     "or by the -D invocation option, or by the "
                     "PGDATA environment variable.\n",
                     progname, ConfigFileName);
        return false;
    }
    SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
    free(fname);

    free(configdir);

    return true;
}

Datum set_config_by_name ( PG_FUNCTION_ARGS   ) 

Definition at line 6337 of file guc.c.

References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, GetConfigOptionByName(), GUC_ACTION_LOCAL, name, NULL, PG_ARGISNULL, PG_GETARG_BOOL, PG_GETARG_DATUM, PG_RETURN_TEXT_P, PGC_SUSET, PGC_USERSET, set_config_option(), superuser(), TextDatumGetCString, and value.

{
    char       *name;
    char       *value;
    char       *new_value;
    bool        is_local;

    if (PG_ARGISNULL(0))
        ereport(ERROR,
                (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
                 errmsg("SET requires parameter name")));

    /* Get the GUC variable name */
    name = TextDatumGetCString(PG_GETARG_DATUM(0));

    /* Get the desired value or set to NULL for a reset request */
    if (PG_ARGISNULL(1))
        value = NULL;
    else
        value = TextDatumGetCString(PG_GETARG_DATUM(1));

    /*
     * Get the desired state of is_local. Default to false if provided value
     * is NULL
     */
    if (PG_ARGISNULL(2))
        is_local = false;
    else
        is_local = PG_GETARG_BOOL(2);

    /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
    (void) set_config_option(name,
                             value,
                             (superuser() ? PGC_SUSET : PGC_USERSET),
                             PGC_S_SESSION,
                             is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
                             true,
                             0);

    /* get the new current value */
    new_value = GetConfigOptionByName(name, NULL);

    /* Convert return string to text */
    PG_RETURN_TEXT_P(cstring_to_text(new_value));
}

int set_config_option ( const char *  name,
const char *  value,
GucContext  context,
GucSource  source,
GucAction  action,
bool  changeVal,
int  elevel 
)

Definition at line 5162 of file guc.c.

References _, config_enum::assign_hook, config_string::assign_hook, config_real::assign_hook, config_int::assign_hook, config_bool::assign_hook, config_var_val::boolval, config_enum::boot_val, config_string::boot_val, config_real::boot_val, config_int::boot_val, config_bool::boot_val, call_bool_check_hook(), call_enum_check_hook(), call_int_check_hook(), call_real_check_hook(), call_string_check_hook(), config_enum_get_options(), config_enum_lookup_by_name(), config_generic::context, DEBUG3, elog, config_var_val::enumval, ereport, errcode(), errhint(), errmsg(), config_var_value::extra, config_generic::extra, extra_field_used(), find_option(), config_generic::flags, free, config_enum::gen, config_string::gen, config_real::gen, config_int::gen, config_bool::gen, GUC_IS_NAME, GUC_NOT_WHILE_SEC_REST, GUC_REPORT, guc_strdup(), InLocalUserIdChange(), InSecurityRestrictedOperation(), config_var_val::intval, IsUnderPostmaster, config_real::max, config_int::max, config_real::min, config_int::min, NULL, parse_bool(), parse_int(), parse_real(), pfree(), PGC_BACKEND, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_INTERNAL, PGC_POSTMASTER, PGC_REAL, PGC_S_CLIENT, PGC_S_DATABASE, PGC_S_DATABASE_USER, PGC_S_DEFAULT, PGC_S_FILE, PGC_S_GLOBAL, PGC_S_USER, PGC_SIGHUP, PGC_STRING, PGC_SUSET, PGC_USERSET, guc_stack::prev, guc_stack::prior, push_old_value(), config_var_val::realval, ReportGUCOption(), config_enum::reset_extra, config_string::reset_extra, config_real::reset_extra, config_int::reset_extra, config_bool::reset_extra, config_generic::reset_scontext, config_generic::reset_source, config_enum::reset_val, config_string::reset_val, config_real::reset_val, config_int::reset_val, config_bool::reset_val, guc_stack::scontext, config_generic::scontext, set_extra_field(), set_string_field(), guc_stack::source, config_generic::source, config_generic::stack, string_field_used(), config_var_val::stringval, truncate_identifier(), config_var_value::val, config_enum::variable, config_string::variable, config_real::variable, config_int::variable, config_bool::variable, and config_generic::vartype.

Referenced by applyRemoteGucs(), define_custom_variable(), ExecSetVariableStmt(), execute_extension_script(), ProcessGUCArray(), reapply_stacked_values(), RI_Initial_Check(), set_config_by_name(), set_transmission_modes(), SetConfigOption(), SetPGVariable(), and validate_option_array_item().

{
    struct config_generic *record;
    bool        prohibitValueChange = false;
    bool        makeDefault;

    if (elevel == 0)
    {
        if (source == PGC_S_DEFAULT || source == PGC_S_FILE)
        {
            /*
             * To avoid cluttering the log, only the postmaster bleats loudly
             * about problems with the config file.
             */
            elevel = IsUnderPostmaster ? DEBUG3 : LOG;
        }
        else if (source == PGC_S_GLOBAL || source == PGC_S_DATABASE || source == PGC_S_USER ||
                 source == PGC_S_DATABASE_USER)
            elevel = WARNING;
        else
            elevel = ERROR;
    }

    record = find_option(name, true, elevel);
    if (record == NULL)
    {
        ereport(elevel,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
               errmsg("unrecognized configuration parameter \"%s\"", name)));
        return 0;
    }

    /*
     * Check if the option can be set at this time. See guc.h for the precise
     * rules.
     */
    switch (record->context)
    {
        case PGC_INTERNAL:
            if (context != PGC_INTERNAL)
            {
                ereport(elevel,
                        (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                         errmsg("parameter \"%s\" cannot be changed",
                                name)));
                return 0;
            }
            break;
        case PGC_POSTMASTER:
            if (context == PGC_SIGHUP)
            {
                /*
                 * We are re-reading a PGC_POSTMASTER variable from
                 * postgresql.conf.  We can't change the setting, so we should
                 * give a warning if the DBA tries to change it.  However,
                 * because of variant formats, canonicalization by check
                 * hooks, etc, we can't just compare the given string directly
                 * to what's stored.  Set a flag to check below after we have
                 * the final storable value.
                 */
                prohibitValueChange = true;
            }
            else if (context != PGC_POSTMASTER)
            {
                ereport(elevel,
                        (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                         errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                name)));
                return 0;
            }
            break;
        case PGC_SIGHUP:
            if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
            {
                ereport(elevel,
                        (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                         errmsg("parameter \"%s\" cannot be changed now",
                                name)));
                return 0;
            }

            /*
             * 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.
             */
            break;
        case PGC_BACKEND:
            if (context == PGC_SIGHUP)
            {
                /*
                 * If a PGC_BACKEND parameter is changed in the config file,
                 * we want to accept the new value in the postmaster (whence
                 * it will propagate to subsequently-started backends), but
                 * ignore it in existing backends.  This is a tad klugy, but
                 * necessary because we don't re-read the config file during
                 * backend start.
                 */
                if (IsUnderPostmaster)
                    return -1;
            }
            else if (context != PGC_POSTMASTER && context != PGC_BACKEND &&
                     source != PGC_S_CLIENT)
            {
                ereport(elevel,
                        (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                         errmsg("parameter \"%s\" cannot be set after connection start",
                                name)));
                return 0;
            }
            break;
        case PGC_SUSET:
            if (context == PGC_USERSET || context == PGC_BACKEND)
            {
                ereport(elevel,
                        (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                         errmsg("permission denied to set parameter \"%s\"",
                                name)));
                return 0;
            }
            break;
        case PGC_USERSET:
            /* always okay */
            break;
    }

    /*
     * Disallow changing GUC_NOT_WHILE_SEC_REST values if we are inside a
     * security restriction context.  We can reject this regardless of the GUC
     * context or source, mainly because sources that it might be reasonable
     * to override for won't be seen while inside a function.
     *
     * Note: variables marked GUC_NOT_WHILE_SEC_REST should usually be marked
     * GUC_NO_RESET_ALL as well, because ResetAllOptions() doesn't check this.
     * An exception might be made if the reset value is assumed to be "safe".
     *
     * Note: this flag is currently used for "session_authorization" and
     * "role".  We need to prohibit changing these inside a local userid
     * context because when we exit it, GUC won't be notified, leaving things
     * out of sync.  (This could be fixed by forcing a new GUC nesting level,
     * but that would change behavior in possibly-undesirable ways.)  Also, we
     * prohibit changing these in a security-restricted operation because
     * otherwise RESET could be used to regain the session user's privileges.
     */
    if (record->flags & GUC_NOT_WHILE_SEC_REST)
    {
        if (InLocalUserIdChange())
        {
            /*
             * Phrasing of this error message is historical, but it's the most
             * common case.
             */
            ereport(elevel,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                     errmsg("cannot set parameter \"%s\" within security-definer function",
                            name)));
            return 0;
        }
        if (InSecurityRestrictedOperation())
        {
            ereport(elevel,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                     errmsg("cannot set parameter \"%s\" within security-restricted operation",
                            name)));
            return 0;
        }
    }

    /*
     * Should we set reset/stacked values?  (If so, the behavior is not
     * transactional.)  This is done either when we get a default value from
     * the database's/user's/client's default settings or when we reset a
     * value to its default.
     */
    makeDefault = changeVal && (source <= PGC_S_OVERRIDE) &&
        ((value != NULL) || source == PGC_S_DEFAULT);

    /*
     * Ignore attempted set if overridden by previously processed setting.
     * However, if changeVal is false then plow ahead anyway since we are
     * trying to find out if the value is potentially good, not actually use
     * it. Also keep going if makeDefault is true, since we may want to set
     * the reset/stacked values even if we can't set the variable itself.
     */
    if (record->source > source)
    {
        if (changeVal && !makeDefault)
        {
            elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
                 name);
            return -1;
        }
        changeVal = false;
    }

    /*
     * Evaluate value and set variable.
     */
    switch (record->vartype)
    {
        case PGC_BOOL:
            {
                struct config_bool *conf = (struct config_bool *) record;
                bool        newval;
                void       *newextra = NULL;

                if (value)
                {
                    if (!parse_bool(value, &newval))
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                          errmsg("parameter \"%s\" requires a Boolean value",
                                 name)));
                        return 0;
                    }
                    if (!call_bool_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else if (source == PGC_S_DEFAULT)
                {
                    newval = conf->boot_val;
                    if (!call_bool_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else
                {
                    newval = conf->reset_val;
                    newextra = conf->reset_extra;
                    source = conf->gen.reset_source;
                    context = conf->gen.reset_scontext;
                }

                if (prohibitValueChange)
                {
                    if (*conf->variable != newval)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                                 errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                        name)));
                        return 0;
                    }
                    return -1;
                }

                if (changeVal)
                {
                    /* Save old value to support transaction abort */
                    if (!makeDefault)
                        push_old_value(&conf->gen, action);

                    if (conf->assign_hook)
                        (*conf->assign_hook) (newval, newextra);
                    *conf->variable = newval;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    newextra);
                    conf->gen.source = source;
                    conf->gen.scontext = context;
                }
                if (makeDefault)
                {
                    GucStack   *stack;

                    if (conf->gen.reset_source <= source)
                    {
                        conf->reset_val = newval;
                        set_extra_field(&conf->gen, &conf->reset_extra,
                                        newextra);
                        conf->gen.reset_source = source;
                        conf->gen.reset_scontext = context;
                    }
                    for (stack = conf->gen.stack; stack; stack = stack->prev)
                    {
                        if (stack->source <= source)
                        {
                            stack->prior.val.boolval = newval;
                            set_extra_field(&conf->gen, &stack->prior.extra,
                                            newextra);
                            stack->source = source;
                            stack->scontext = context;
                        }
                    }
                }

                /* Perhaps we didn't install newextra anywhere */
                if (newextra && !extra_field_used(&conf->gen, newextra))
                    free(newextra);
                break;
            }

        case PGC_INT:
            {
                struct config_int *conf = (struct config_int *) record;
                int         newval;
                void       *newextra = NULL;

                if (value)
                {
                    const char *hintmsg;

                    if (!parse_int(value, &newval, conf->gen.flags, &hintmsg))
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                         errmsg("invalid value for parameter \"%s\": \"%s\"",
                                name, value),
                                 hintmsg ? errhint("%s", _(hintmsg)) : 0));
                        return 0;
                    }
                    if (newval < conf->min || newval > conf->max)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
                                        newval, name, conf->min, conf->max)));
                        return 0;
                    }
                    if (!call_int_check_hook(conf, &newval, &newextra,
                                             source, elevel))
                        return 0;
                }
                else if (source == PGC_S_DEFAULT)
                {
                    newval = conf->boot_val;
                    if (!call_int_check_hook(conf, &newval, &newextra,
                                             source, elevel))
                        return 0;
                }
                else
                {
                    newval = conf->reset_val;
                    newextra = conf->reset_extra;
                    source = conf->gen.reset_source;
                    context = conf->gen.reset_scontext;
                }

                if (prohibitValueChange)
                {
                    if (*conf->variable != newval)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                                 errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                        name)));
                        return 0;
                    }
                    return -1;
                }

                if (changeVal)
                {
                    /* Save old value to support transaction abort */
                    if (!makeDefault)
                        push_old_value(&conf->gen, action);

                    if (conf->assign_hook)
                        (*conf->assign_hook) (newval, newextra);
                    *conf->variable = newval;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    newextra);
                    conf->gen.source = source;
                    conf->gen.scontext = context;
                }
                if (makeDefault)
                {
                    GucStack   *stack;

                    if (conf->gen.reset_source <= source)
                    {
                        conf->reset_val = newval;
                        set_extra_field(&conf->gen, &conf->reset_extra,
                                        newextra);
                        conf->gen.reset_source = source;
                        conf->gen.reset_scontext = context;
                    }
                    for (stack = conf->gen.stack; stack; stack = stack->prev)
                    {
                        if (stack->source <= source)
                        {
                            stack->prior.val.intval = newval;
                            set_extra_field(&conf->gen, &stack->prior.extra,
                                            newextra);
                            stack->source = source;
                            stack->scontext = context;
                        }
                    }
                }

                /* Perhaps we didn't install newextra anywhere */
                if (newextra && !extra_field_used(&conf->gen, newextra))
                    free(newextra);
                break;
            }

        case PGC_REAL:
            {
                struct config_real *conf = (struct config_real *) record;
                double      newval;
                void       *newextra = NULL;

                if (value)
                {
                    if (!parse_real(value, &newval))
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                          errmsg("parameter \"%s\" requires a numeric value",
                                 name)));
                        return 0;
                    }
                    if (newval < conf->min || newval > conf->max)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
                                        newval, name, conf->min, conf->max)));
                        return 0;
                    }
                    if (!call_real_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else if (source == PGC_S_DEFAULT)
                {
                    newval = conf->boot_val;
                    if (!call_real_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else
                {
                    newval = conf->reset_val;
                    newextra = conf->reset_extra;
                    source = conf->gen.reset_source;
                    context = conf->gen.reset_scontext;
                }

                if (prohibitValueChange)
                {
                    if (*conf->variable != newval)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                                 errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                        name)));
                        return 0;
                    }
                    return -1;
                }

                if (changeVal)
                {
                    /* Save old value to support transaction abort */
                    if (!makeDefault)
                        push_old_value(&conf->gen, action);

                    if (conf->assign_hook)
                        (*conf->assign_hook) (newval, newextra);
                    *conf->variable = newval;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    newextra);
                    conf->gen.source = source;
                    conf->gen.scontext = context;
                }
                if (makeDefault)
                {
                    GucStack   *stack;

                    if (conf->gen.reset_source <= source)
                    {
                        conf->reset_val = newval;
                        set_extra_field(&conf->gen, &conf->reset_extra,
                                        newextra);
                        conf->gen.reset_source = source;
                        conf->gen.reset_scontext = context;
                    }
                    for (stack = conf->gen.stack; stack; stack = stack->prev)
                    {
                        if (stack->source <= source)
                        {
                            stack->prior.val.realval = newval;
                            set_extra_field(&conf->gen, &stack->prior.extra,
                                            newextra);
                            stack->source = source;
                            stack->scontext = context;
                        }
                    }
                }

                /* Perhaps we didn't install newextra anywhere */
                if (newextra && !extra_field_used(&conf->gen, newextra))
                    free(newextra);
                break;
            }

        case PGC_STRING:
            {
                struct config_string *conf = (struct config_string *) record;
                char       *newval;
                void       *newextra = NULL;

                if (value)
                {
                    /*
                     * The value passed by the caller could be transient, so
                     * we always strdup it.
                     */
                    newval = guc_strdup(elevel, value);
                    if (newval == NULL)
                        return 0;

                    /*
                     * The only built-in "parsing" check we have is to apply
                     * truncation if GUC_IS_NAME.
                     */
                    if (conf->gen.flags & GUC_IS_NAME)
                        truncate_identifier(newval, strlen(newval), true);

                    if (!call_string_check_hook(conf, &newval, &newextra,
                                                source, elevel))
                    {
                        free(newval);
                        return 0;
                    }
                }
                else if (source == PGC_S_DEFAULT)
                {
                    /* non-NULL boot_val must always get strdup'd */
                    if (conf->boot_val != NULL)
                    {
                        newval = guc_strdup(elevel, conf->boot_val);
                        if (newval == NULL)
                            return 0;
                    }
                    else
                        newval = NULL;

                    if (!call_string_check_hook(conf, &newval, &newextra,
                                                source, elevel))
                    {
                        free(newval);
                        return 0;
                    }
                }
                else
                {
                    /*
                     * strdup not needed, since reset_val is already under
                     * guc.c's control
                     */
                    newval = conf->reset_val;
                    newextra = conf->reset_extra;
                    source = conf->gen.reset_source;
                    context = conf->gen.reset_scontext;
                }

                if (prohibitValueChange)
                {
                    /* newval shouldn't be NULL, so we're a bit sloppy here */
                    if (*conf->variable == NULL || newval == NULL ||
                        strcmp(*conf->variable, newval) != 0)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                                 errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                        name)));
                        return 0;
                    }
                    return -1;
                }

                if (changeVal)
                {
                    /* Save old value to support transaction abort */
                    if (!makeDefault)
                        push_old_value(&conf->gen, action);

                    if (conf->assign_hook)
                        (*conf->assign_hook) (newval, newextra);
                    set_string_field(conf, conf->variable, newval);
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    newextra);
                    conf->gen.source = source;
                    conf->gen.scontext = context;
                }

                if (makeDefault)
                {
                    GucStack   *stack;

                    if (conf->gen.reset_source <= source)
                    {
                        set_string_field(conf, &conf->reset_val, newval);
                        set_extra_field(&conf->gen, &conf->reset_extra,
                                        newextra);
                        conf->gen.reset_source = source;
                        conf->gen.reset_scontext = context;
                    }
                    for (stack = conf->gen.stack; stack; stack = stack->prev)
                    {
                        if (stack->source <= source)
                        {
                            set_string_field(conf, &stack->prior.val.stringval,
                                             newval);
                            set_extra_field(&conf->gen, &stack->prior.extra,
                                            newextra);
                            stack->source = source;
                            stack->scontext = context;
                        }
                    }
                }

                /* Perhaps we didn't install newval anywhere */
                if (newval && !string_field_used(conf, newval))
                    free(newval);
                /* Perhaps we didn't install newextra anywhere */
                if (newextra && !extra_field_used(&conf->gen, newextra))
                    free(newextra);
                break;
            }

        case PGC_ENUM:
            {
                struct config_enum *conf = (struct config_enum *) record;
                int         newval;
                void       *newextra = NULL;

                if (value)
                {
                    if (!config_enum_lookup_by_name(conf, value, &newval))
                    {
                        char       *hintmsg;

                        hintmsg = config_enum_get_options(conf,
                                                        "Available values: ",
                                                          ".", ", ");

                        ereport(elevel,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                         errmsg("invalid value for parameter \"%s\": \"%s\"",
                                name, value),
                                 hintmsg ? errhint("%s", _(hintmsg)) : 0));

                        if (hintmsg)
                            pfree(hintmsg);
                        return 0;
                    }
                    if (!call_enum_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else if (source == PGC_S_DEFAULT)
                {
                    newval = conf->boot_val;
                    if (!call_enum_check_hook(conf, &newval, &newextra,
                                              source, elevel))
                        return 0;
                }
                else
                {
                    newval = conf->reset_val;
                    newextra = conf->reset_extra;
                    source = conf->gen.reset_source;
                    context = conf->gen.reset_scontext;
                }

                if (prohibitValueChange)
                {
                    if (*conf->variable != newval)
                    {
                        ereport(elevel,
                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
                                 errmsg("parameter \"%s\" cannot be changed without restarting the server",
                                        name)));
                        return 0;
                    }
                    return -1;
                }

                if (changeVal)
                {
                    /* Save old value to support transaction abort */
                    if (!makeDefault)
                        push_old_value(&conf->gen, action);

                    if (conf->assign_hook)
                        (*conf->assign_hook) (newval, newextra);
                    *conf->variable = newval;
                    set_extra_field(&conf->gen, &conf->gen.extra,
                                    newextra);
                    conf->gen.source = source;
                    conf->gen.scontext = context;
                }
                if (makeDefault)
                {
                    GucStack   *stack;

                    if (conf->gen.reset_source <= source)
                    {
                        conf->reset_val = newval;
                        set_extra_field(&conf->gen, &conf->reset_extra,
                                        newextra);
                        conf->gen.reset_source = source;
                        conf->gen.reset_scontext = context;
                    }
                    for (stack = conf->gen.stack; stack; stack = stack->prev)
                    {
                        if (stack->source <= source)
                        {
                            stack->prior.val.enumval = newval;
                            set_extra_field(&conf->gen, &stack->prior.extra,
                                            newextra);
                            stack->source = source;
                            stack->scontext = context;
                        }
                    }
                }

                /* Perhaps we didn't install newextra anywhere */
                if (newextra && !extra_field_used(&conf->gen, newextra))
                    free(newextra);
                break;
            }
    }

    if (changeVal && (record->flags & GUC_REPORT))
        ReportGUCOption(record);

    return changeVal ? 1 : -1;
}

static void set_config_sourcefile ( const char *  name,
char *  sourcefile,
int  sourceline 
) [static]

Definition at line 5904 of file guc.c.

References DEBUG3, elevel, elog, ERROR, find_option(), free, guc_strdup(), IsUnderPostmaster, NULL, config_generic::sourcefile, and config_generic::sourceline.

Referenced by define_custom_variable().

{
    struct config_generic *record;
    int         elevel;

    /*
     * To avoid cluttering the log, only the postmaster bleats loudly about
     * problems with the config file.
     */
    elevel = IsUnderPostmaster ? DEBUG3 : LOG;

    record = find_option(name, true, elevel);
    /* should not happen */
    if (record == NULL)
        elog(ERROR, "unrecognized configuration parameter \"%s\"", name);

    sourcefile = guc_strdup(elevel, sourcefile);
    if (record->sourcefile)
        free(record->sourcefile);
    record->sourcefile = sourcefile;
    record->sourceline = sourceline;
}

static void set_extra_field ( struct config_generic gconf,
void **  field,
void *  newval 
) [static]

Definition at line 3518 of file guc.c.

References extra_field_used(), and free.

Referenced by AtEOXact_GUC(), discard_stack_value(), ResetAllOptions(), set_config_option(), and set_stack_value().

{
    void       *oldval = *field;

    /* Do the assignment */
    *field = newval;

    /* Free old value if it's not NULL and isn't referenced anymore */
    if (oldval && !extra_field_used(gconf, oldval))
        free(oldval);
}

static void set_stack_value ( struct config_generic gconf,
config_var_value val 
) [static]

Definition at line 3538 of file guc.c.

References config_var_val::boolval, config_var_val::enumval, config_generic::extra, config_var_value::extra, config_var_val::intval, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, config_var_val::realval, set_extra_field(), set_string_field(), config_var_val::stringval, config_var_value::val, and config_generic::vartype.

Referenced by push_old_value().

{
    switch (gconf->vartype)
    {
        case PGC_BOOL:
            val->val.boolval =
                *((struct config_bool *) gconf)->variable;
            break;
        case PGC_INT:
            val->val.intval =
                *((struct config_int *) gconf)->variable;
            break;
        case PGC_REAL:
            val->val.realval =
                *((struct config_real *) gconf)->variable;
            break;
        case PGC_STRING:
            set_string_field((struct config_string *) gconf,
                             &(val->val.stringval),
                             *((struct config_string *) gconf)->variable);
            break;
        case PGC_ENUM:
            val->val.enumval =
                *((struct config_enum *) gconf)->variable;
            break;
    }
    set_extra_field(gconf, &(val->extra), gconf->extra);
}

static void set_string_field ( struct config_string conf,
char **  field,
char *  newval 
) [static]

Definition at line 3457 of file guc.c.

References free, and string_field_used().

Referenced by AtEOXact_GUC(), define_custom_variable(), discard_stack_value(), ResetAllOptions(), set_config_option(), and set_stack_value().

{
    char       *oldval = *field;

    /* Do the assignment */
    *field = newval;

    /* Free old value if it's not NULL and isn't referenced anymore */
    if (oldval && !string_field_used(conf, oldval))
        free(oldval);
}

void SetConfigOption ( const char *  name,
const char *  value,
GucContext  context,
GucSource  source 
)
void SetPGVariable ( const char *  name,
List args,
bool  is_local 
)

Definition at line 6319 of file guc.c.

References flatten_set_variable_args(), GUC_ACTION_LOCAL, PGC_SUSET, PGC_USERSET, set_config_option(), and superuser().

Referenced by DiscardAll(), ExecSetVariableStmt(), and standard_ProcessUtility().

{
    char       *argstring = flatten_set_variable_args(name, args);

    /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
    (void) set_config_option(name,
                             argstring,
                             (superuser() ? PGC_SUSET : PGC_USERSET),
                             PGC_S_SESSION,
                             is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
                             true,
                             0);
}

Datum show_all_settings ( PG_FUNCTION_ARGS   ) 

Definition at line 7223 of file guc.c.

References FuncCallContext::attinmeta, BuildTupleFromCStrings(), FuncCallContext::call_cntr, CreateTemplateTupleDesc(), GetConfigOptionByNum(), GetNumConfigOptions(), HeapTupleGetDatum, INT4OID, FuncCallContext::max_calls, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, NUM_PG_SETTINGS_ATTS, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, TEXTARRAYOID, TEXTOID, TupleDescGetAttInMetadata(), TupleDescInitEntry(), and values.

{
    FuncCallContext *funcctx;
    TupleDesc   tupdesc;
    int         call_cntr;
    int         max_calls;
    AttInMetadata *attinmeta;
    MemoryContext oldcontext;

    /* stuff done only on the first call of the function */
    if (SRF_IS_FIRSTCALL())
    {
        /* create a function context for cross-call persistence */
        funcctx = SRF_FIRSTCALL_INIT();

        /*
         * switch to memory context appropriate for multiple function calls
         */
        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);

        /*
         * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
         * of the appropriate types
         */
        tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 3, "unit",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 4, "category",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 5, "short_desc",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 6, "extra_desc",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 7, "context",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 8, "vartype",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 9, "source",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 10, "min_val",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
                           TEXTARRAYOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourcefile",
                           TEXTOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 16, "sourceline",
                           INT4OID, -1, 0);

        /*
         * Generate attribute metadata needed later to produce tuples from raw
         * C strings
         */
        attinmeta = TupleDescGetAttInMetadata(tupdesc);
        funcctx->attinmeta = attinmeta;

        /* total number of tuples to be returned */
        funcctx->max_calls = GetNumConfigOptions();

        MemoryContextSwitchTo(oldcontext);
    }

    /* stuff done on every call of the function */
    funcctx = SRF_PERCALL_SETUP();

    call_cntr = funcctx->call_cntr;
    max_calls = funcctx->max_calls;
    attinmeta = funcctx->attinmeta;

    if (call_cntr < max_calls)  /* do when there is more left to send */
    {
        char       *values[NUM_PG_SETTINGS_ATTS];
        bool        noshow;
        HeapTuple   tuple;
        Datum       result;

        /*
         * Get the next visible GUC variable name and value
         */
        do
        {
            GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
            if (noshow)
            {
                /* bump the counter and get the next config setting */
                call_cntr = ++funcctx->call_cntr;

                /* make sure we haven't gone too far now */
                if (call_cntr >= max_calls)
                    SRF_RETURN_DONE(funcctx);
            }
        } while (noshow);

        /* build a tuple */
        tuple = BuildTupleFromCStrings(attinmeta, values);

        /* make the tuple into a datum */
        result = HeapTupleGetDatum(tuple);

        SRF_RETURN_NEXT(funcctx, result);
    }
    else
    {
        /* do when there is no more left */
        SRF_RETURN_DONE(funcctx);
    }
}

static const char * show_archive_command ( void   )  [static]

Definition at line 8576 of file guc.c.

References XLogArchiveCommand, and XLogArchivingActive.

{
    if (XLogArchivingActive())
        return XLogArchiveCommand;
    else
        return "(disabled)";
}

Datum show_config_by_name ( PG_FUNCTION_ARGS   ) 

Definition at line 7201 of file guc.c.

References cstring_to_text(), GetConfigOptionByName(), NULL, PG_GETARG_DATUM, PG_RETURN_TEXT_P, and TextDatumGetCString.

{
    char       *varname;
    char       *varval;

    /* Get the GUC variable name */
    varname = TextDatumGetCString(PG_GETARG_DATUM(0));

    /* Get the value */
    varval = GetConfigOptionByName(varname, NULL);

    /* Convert to text */
    PG_RETURN_TEXT_P(cstring_to_text(varval));
}

static const char * show_log_file_mode ( void   )  [static]

Definition at line 8792 of file guc.c.

References buf, Log_file_mode, and snprintf().

{
    static char buf[8];

    snprintf(buf, sizeof(buf), "%04o", Log_file_mode);
    return buf;
}

static const char * show_tcp_keepalives_count ( void   )  [static]

Definition at line 8636 of file guc.c.

References MyProcPort, pq_getkeepalivescount(), and snprintf().

{
    /* See comments in assign_tcp_keepalives_idle */
    static char nbuf[16];

    snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
    return nbuf;
}

static const char * show_tcp_keepalives_idle ( void   )  [static]

Definition at line 8602 of file guc.c.

References MyProcPort, pq_getkeepalivesidle(), and snprintf().

{
    /* See comments in assign_tcp_keepalives_idle */
    static char nbuf[16];

    snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
    return nbuf;
}

static const char * show_tcp_keepalives_interval ( void   )  [static]

Definition at line 8619 of file guc.c.

References MyProcPort, pq_getkeepalivesinterval(), and snprintf().

{
    /* See comments in assign_tcp_keepalives_idle */
    static char nbuf[16];

    snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
    return nbuf;
}

static const char * show_unix_socket_permissions ( void   )  [static]

Definition at line 8783 of file guc.c.

References buf, snprintf(), and Unix_socket_permissions.

{
    static char buf[8];

    snprintf(buf, sizeof(buf), "%04o", Unix_socket_permissions);
    return buf;
}

static void ShowAllGUCConfig ( DestReceiver dest  )  [static]

Definition at line 6842 of file guc.c.

References _ShowOption(), begin_tup_output_tupdesc(), CreateTemplateTupleDesc(), cstring_to_text(), DatumGetPointer, do_tup_output(), end_tup_output(), config_generic::flags, GUC_NO_SHOW_ALL, GUC_SUPERUSER_ONLY, i, config_generic::name, NULL, pfree(), PointerGetDatum, config_generic::short_desc, superuser(), TEXTOID, TupleDescInitEntry(), and values.

Referenced by GetPGVariable().

{
    bool        am_superuser = superuser();
    int         i;
    TupOutputState *tstate;
    TupleDesc   tupdesc;
    Datum       values[3];
    bool        isnull[3] = {false, false, false};

    /* need a tuple descriptor representing three TEXT columns */
    tupdesc = CreateTemplateTupleDesc(3, false);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
                       TEXTOID, -1, 0);

    /* prepare for projection of tuples */
    tstate = begin_tup_output_tupdesc(dest, tupdesc);

    for (i = 0; i < num_guc_variables; i++)
    {
        struct config_generic *conf = guc_variables[i];
        char       *setting;

        if ((conf->flags & GUC_NO_SHOW_ALL) ||
            ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
            continue;

        /* assign to the values array */
        values[0] = PointerGetDatum(cstring_to_text(conf->name));

        setting = _ShowOption(conf, true);
        if (setting)
        {
            values[1] = PointerGetDatum(cstring_to_text(setting));
            isnull[1] = false;
        }
        else
        {
            values[1] = PointerGetDatum(NULL);
            isnull[1] = true;
        }

        values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));

        /* send it to dest */
        do_tup_output(tstate, values, isnull);

        /* clean up */
        pfree(DatumGetPointer(values[0]));
        if (setting)
        {
            pfree(setting);
            pfree(DatumGetPointer(values[1]));
        }
        pfree(DatumGetPointer(values[2]));
    }

    end_tup_output(tstate);
}

static void ShowGUCConfigOption ( const char *  name,
DestReceiver dest 
) [static]

Definition at line 6814 of file guc.c.

References begin_tup_output_tupdesc(), CreateTemplateTupleDesc(), do_text_output_oneline, end_tup_output(), GetConfigOptionByName(), TEXTOID, TupleDescInitEntry(), and value.

Referenced by GetPGVariable().

{
    TupOutputState *tstate;
    TupleDesc   tupdesc;
    const char *varname;
    char       *value;

    /* Get the value and canonical spelling of name */
    value = GetConfigOptionByName(name, &varname);

    /* need a tuple descriptor representing a single TEXT column */
    tupdesc = CreateTemplateTupleDesc(1, false);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
                       TEXTOID, -1, 0);

    /* prepare for projection of tuples */
    tstate = begin_tup_output_tupdesc(dest, tupdesc);

    /* Send it */
    do_text_output_oneline(tstate, value);

    end_tup_output(tstate);
}

static bool string_field_used ( struct config_string conf,
char *  strval 
) [static]

Definition at line 3434 of file guc.c.

References config_string::boot_val, config_string::gen, guc_stack::masked, guc_stack::prev, guc_stack::prior, config_string::reset_val, config_generic::stack, config_var_val::stringval, config_var_value::val, and config_string::variable.

Referenced by set_config_option(), and set_string_field().

{
    GucStack   *stack;

    if (strval == *(conf->variable) ||
        strval == conf->reset_val ||
        strval == conf->boot_val)
        return true;
    for (stack = conf->gen.stack; stack; stack = stack->prev)
    {
        if (strval == stack->prior.val.stringval ||
            strval == stack->masked.val.stringval)
            return true;
    }
    return false;
}

static bool validate_option_array_item ( const char *  name,
const char *  value,
bool  skipIfNoPermissions 
) [static]

Definition at line 8056 of file guc.c.

References config_generic::context, ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_CUSTOM_PLACEHOLDER, PGC_SUSET, PGC_USERSET, set_config_option(), superuser(), and WARNING.

Referenced by GUCArrayAdd(), GUCArrayDelete(), and GUCArrayReset().

{
    struct config_generic *gconf;

    /*
     * There are three cases to consider:
     *
     * name is a known GUC variable.  Check the value normally, check
     * permissions normally (ie, allow if variable is USERSET, or if it's
     * SUSET and user is superuser).
     *
     * name is not known, but exists or can be created as a placeholder (i.e.,
     * it has a prefixed name).  We allow this case if you're a superuser,
     * otherwise not.  Superusers are assumed to know what they're doing. We
     * can't allow it for other users, because when the placeholder is
     * resolved it might turn out to be a SUSET variable;
     * define_custom_variable assumes we checked that.
     *
     * name is not known and can't be created as a placeholder.  Throw error,
     * unless skipIfNoPermissions is true, in which case return FALSE.
     */
    gconf = find_option(name, true, WARNING);
    if (!gconf)
    {
        /* not known, failed to make a placeholder */
        if (skipIfNoPermissions)
            return false;
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("unrecognized configuration parameter \"%s\"",
                        name)));
    }

    if (gconf->flags & GUC_CUSTOM_PLACEHOLDER)
    {
        /*
         * We cannot do any meaningful check on the value, so only permissions
         * are useful to check.
         */
        if (superuser())
            return true;
        if (skipIfNoPermissions)
            return false;
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("permission denied to set parameter \"%s\"", name)));
    }

    /* manual permissions check so we can avoid an error being thrown */
    if (gconf->context == PGC_USERSET)
         /* ok */ ;
    else if (gconf->context == PGC_SUSET && superuser())
         /* ok */ ;
    else if (skipIfNoPermissions)
        return false;
    /* if a permissions error should be thrown, let set_config_option do it */

    /* test for permissions and valid option value */
    (void) set_config_option(name, value,
                             superuser() ? PGC_SUSET : PGC_USERSET,
                             PGC_S_TEST, GUC_ACTION_SET, false, 0);

    return true;
}


Variable Documentation

Definition at line 393 of file guc.c.

Initial value:
 {
    {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING, false},
    {"on", BACKSLASH_QUOTE_ON, false},
    {"off", BACKSLASH_QUOTE_OFF, false},
    {"true", BACKSLASH_QUOTE_ON, true},
    {"false", BACKSLASH_QUOTE_OFF, true},
    {"yes", BACKSLASH_QUOTE_ON, true},
    {"no", BACKSLASH_QUOTE_OFF, true},
    {"1", BACKSLASH_QUOTE_ON, true},
    {"0", BACKSLASH_QUOTE_OFF, true},
    {NULL, 0, false}
}

Definition at line 333 of file guc.c.

int block_size [static]

Definition at line 466 of file guc.c.

Initial value:
 {
    {"escape", BYTEA_OUTPUT_ESCAPE, false},
    {"hex", BYTEA_OUTPUT_HEX, false},
    {NULL, 0, false}
}

Definition at line 212 of file guc.c.

char* client_encoding_string [static]

Definition at line 451 of file guc.c.

Initial value:
 {
    {"debug", DEBUG2, true},
    {"debug5", DEBUG5, false},
    {"debug4", DEBUG4, false},
    {"debug3", DEBUG3, false},
    {"debug2", DEBUG2, false},
    {"debug1", DEBUG1, false},
    {"log", LOG, false},
    {"info", INFO, true},
    {"notice", NOTICE, false},
    {"warning", WARNING, false},
    {"error", ERROR, false},
    {"fatal", FATAL, true},
    {"panic", PANIC, true},
    {NULL, 0, false}
}

Definition at line 222 of file guc.c.

int client_min_messages = NOTICE

Definition at line 84 of file xlog.c.

Referenced by XLogFlush().

Definition at line 85 of file xlog.c.

Referenced by XLogFlush().

const char* const config_group_names[]

Definition at line 518 of file guc.c.

Referenced by GetConfigOptionByNum(), and printMixedStruct().

const char* const config_type_names[]
Initial value:
{
      "bool",
      "integer",
      "real",
      "string",
      "enum"
}

Definition at line 619 of file guc.c.

Referenced by GetConfigOptionByNum().

Definition at line 427 of file guc.c.

Referenced by SelectConfigFiles().

struct config_bool ConfigureNamesBool[] [static]

Definition at line 659 of file guc.c.

struct config_enum ConfigureNamesEnum[] [static]

Definition at line 3112 of file guc.c.

struct config_int ConfigureNamesInt[] [static]

Definition at line 1465 of file guc.c.

struct config_real ConfigureNamesReal[] [static]

Definition at line 2420 of file guc.c.

Definition at line 2561 of file guc.c.

Initial value:
 {
    {"partition", CONSTRAINT_EXCLUSION_PARTITION, false},
    {"on", CONSTRAINT_EXCLUSION_ON, false},
    {"off", CONSTRAINT_EXCLUSION_OFF, false},
    {"true", CONSTRAINT_EXCLUSION_ON, true},
    {"false", CONSTRAINT_EXCLUSION_OFF, true},
    {"yes", CONSTRAINT_EXCLUSION_ON, true},
    {"no", CONSTRAINT_EXCLUSION_OFF, true},
    {"1", CONSTRAINT_EXCLUSION_ON, true},
    {"0", CONSTRAINT_EXCLUSION_OFF, true},
    {NULL, 0, false}
}

Definition at line 350 of file guc.c.

Definition at line 426 of file guc.c.

Referenced by SelectConfigFiles().

char* datestyle_string [static]

Definition at line 452 of file guc.c.

Definition at line 399 of file guc.c.

Referenced by pg_plan_query(), and pg_rewrite_query().

Definition at line 397 of file guc.c.

Referenced by pg_rewrite_query().

Definition at line 396 of file guc.c.

Referenced by pg_plan_query().

Definition at line 398 of file guc.c.

Referenced by pg_rewrite_query().

Definition at line 82 of file tablespace.c.

Referenced by GetDefaultTablespace().

Definition at line 410 of file guc.c.

Referenced by interpretOidsOption().

Definition at line 471 of file guc.c.

char* event_source

Definition at line 407 of file guc.c.

Referenced by DllInstall(), DllRegisterServer(), and DllUnregisterServer().

Definition at line 430 of file guc.c.

Referenced by PostmasterMain(), and unlink_external_pid_file().

bool guc_dirty [static]

Definition at line 3356 of file guc.c.

struct config_generic** guc_variables [static]

Definition at line 3347 of file guc.c.

const char* const GucContext_Names[]
Initial value:
{
      "internal",
      "postmaster",
      "sighup",
      "backend",
      "superuser",
      "user"
}

Definition at line 482 of file guc.c.

Referenced by GetConfigOptionByNum(), and printMixedStruct().

int GUCNestLevel = 0 [static]

Definition at line 3360 of file guc.c.

const char* const GucSource_Names[]
Initial value:
{
      "default",
      "default",
      "environment variable",
      "configuration file",
      "command line",
      "global",
      "database",
      "user",
      "database user",
      "client",
      "override",
      "interactive",
      "test",
      "session"
}

Definition at line 497 of file guc.c.

Referenced by GetConfigOptionByNum().

char* HbaFileName

Definition at line 428 of file guc.c.

Referenced by load_hba(), parse_hba_auth_opt(), parse_hba_line(), and SelectConfigFiles().

Definition at line 429 of file guc.c.

Referenced by load_ident(), and SelectConfigFiles().

Definition at line 21 of file bufpage.c.

Referenced by PageIsVerified().

Definition at line 470 of file guc.c.

Initial value:
 {
    {"postgres", INTSTYLE_POSTGRES, false},
    {"postgres_verbose", INTSTYLE_POSTGRES_VERBOSE, false},
    {"sql_standard", INTSTYLE_SQL_STANDARD, false},
    {"iso_8601", INTSTYLE_ISO_8601, false},
    {NULL, 0, false}
}

Definition at line 256 of file guc.c.

Initial value:
 {
    {"serializable", XACT_SERIALIZABLE, false},
    {"repeatable read", XACT_REPEATABLE_READ, false},
    {"read committed", XACT_READ_COMMITTED, false},
    {"read uncommitted", XACT_READ_UNCOMMITTED, false},
    {NULL, 0}
}

Definition at line 279 of file guc.c.

char* locale_collate [static]

Definition at line 453 of file guc.c.

char* locale_ctype [static]

Definition at line 454 of file guc.c.

Definition at line 406 of file guc.c.

Referenced by _bt_leafbuild(), and btbuild().

char* log_destination_string [static]

Definition at line 445 of file guc.c.

Definition at line 98 of file postgres.c.

Referenced by PostgresMain().

bool log_duration = false

Definition at line 395 of file guc.c.

Referenced by check_log_duration().

Initial value:
 {
    {"terse", PGERROR_TERSE, false},
    {"default", PGERROR_DEFAULT, false},
    {"verbose", PGERROR_VERBOSE, false},
    {NULL, 0, false}
}

Definition at line 264 of file guc.c.

Definition at line 403 of file guc.c.

Referenced by check_log_stats(), PortalRun(), and PortalRunMulti().

Definition at line 418 of file guc.c.

Referenced by check_log_duration().

Definition at line 415 of file guc.c.

Referenced by send_message_to_server_log(), and write_csvlog().

int log_min_messages = WARNING

Definition at line 402 of file guc.c.

Referenced by check_log_stats(), and pg_plan_query().

Initial value:
 {
    {"none", LOGSTMT_NONE, false},
    {"ddl", LOGSTMT_DDL, false},
    {"mod", LOGSTMT_MOD, false},
    {"all", LOGSTMT_ALL, false},
    {NULL, 0, false}
}

Definition at line 271 of file guc.c.

int log_temp_files = -1

Definition at line 419 of file guc.c.

Referenced by FileClose().

char* log_timezone_string [static]

Definition at line 459 of file guc.c.

const char* const map_old_guc_names[] [static]
Initial value:
 {
    "sort_mem", "work_mem",
    "vacuum_mem", "maintenance_work_mem",
    NULL
}

Definition at line 3337 of file guc.c.

int max_function_args [static]

Definition at line 463 of file guc.c.

int max_identifier_length [static]

Definition at line 465 of file guc.c.

int max_index_keys [static]

Definition at line 464 of file guc.c.

int num_guc_variables [static]

Definition at line 3350 of file guc.c.

int num_temp_buffers = 1024

Definition at line 424 of file guc.c.

Referenced by InitLocalBuffers().

Definition at line 413 of file guc.c.

Referenced by AlterRole(), and CreateRole().

Definition at line 432 of file guc.c.

Definition at line 448 of file guc.c.

double phony_random_seed [static]

Definition at line 450 of file guc.c.

Definition at line 3358 of file guc.c.

char* role_string

Definition at line 474 of file guc.c.

Referenced by show_role().

int segment_size [static]

Definition at line 467 of file guc.c.

char* server_encoding_string [static]

Definition at line 455 of file guc.c.

Initial value:
 {
    {"debug", DEBUG2, true},
    {"debug5", DEBUG5, false},
    {"debug4", DEBUG4, false},
    {"debug3", DEBUG3, false},
    {"debug2", DEBUG2, false},
    {"debug1", DEBUG1, false},
    {"info", INFO, false},
    {"notice", NOTICE, false},
    {"warning", WARNING, false},
    {"error", ERROR, false},
    {"log", LOG, false},
    {"fatal", FATAL, false},
    {"panic", PANIC, false},
    {NULL, 0, false}
}

Definition at line 239 of file guc.c.

int server_version_num [static]

Definition at line 457 of file guc.c.

char* server_version_string [static]

Definition at line 456 of file guc.c.

Definition at line 449 of file guc.c.

Definition at line 462 of file guc.c.

Initial value:
 {
    {"origin", SESSION_REPLICATION_ROLE_ORIGIN, false},
    {"replica", SESSION_REPLICATION_ROLE_REPLICA, false},
    {"local", SESSION_REPLICATION_ROLE_LOCAL, false},
    {NULL, 0, false}
}

Definition at line 287 of file guc.c.

int size_guc_variables [static]

Definition at line 3353 of file guc.c.

Definition at line 411 of file guc.c.

Referenced by interpretInhOption().

Definition at line 102 of file be-secure.c.

Referenced by secure_write().

Definition at line 110 of file be-secure.c.

Definition at line 108 of file xlog.c.

Definition at line 76 of file heapam.c.

Referenced by initscan().

Initial value:
 {
    {"local", SYNCHRONOUS_COMMIT_LOCAL_FLUSH, false},
    {"remote_write", SYNCHRONOUS_COMMIT_REMOTE_WRITE, false},
    {"on", SYNCHRONOUS_COMMIT_ON, false},
    {"off", SYNCHRONOUS_COMMIT_OFF, false},
    {"true", SYNCHRONOUS_COMMIT_ON, true},
    {"false", SYNCHRONOUS_COMMIT_OFF, true},
    {"yes", SYNCHRONOUS_COMMIT_ON, true},
    {"no", SYNCHRONOUS_COMMIT_OFF, true},
    {"1", SYNCHRONOUS_COMMIT_ON, true},
    {"0", SYNCHRONOUS_COMMIT_OFF, true},
    {NULL, 0, false}
}

Definition at line 367 of file guc.c.

int syslog_facility = 0 [static]

Definition at line 167 of file guc.c.

Referenced by assign_syslog_ident().

Initial value:
 {










    {"none", 0, false},

    {NULL, 0}
}

Definition at line 294 of file guc.c.

char* syslog_ident_str [static]

Definition at line 447 of file guc.c.

Referenced by assign_syslog_facility().

Definition at line 438 of file guc.c.

Referenced by StreamConnection().

Definition at line 436 of file guc.c.

Referenced by StreamConnection().

Definition at line 437 of file guc.c.

Referenced by StreamConnection().

int temp_file_limit = -1

Definition at line 422 of file guc.c.

Referenced by FileWrite().

Definition at line 83 of file tablespace.c.

Referenced by PrepareTempTablespaces().

Definition at line 460 of file guc.c.

char* timezone_string [static]

Definition at line 458 of file guc.c.

Definition at line 420 of file guc.c.

Referenced by StartupXLOG(), and trace_recovery().

Initial value:
 {
    {"none", TRACK_FUNC_OFF, false},
    {"pl", TRACK_FUNC_PL, false},
    {"all", TRACK_FUNC_ALL, false},
    {NULL, 0, false}
}

Definition at line 310 of file guc.c.

int wal_block_size [static]

Definition at line 468 of file guc.c.

Definition at line 27 of file xlogdesc.c.

int wal_segment_size [static]

Definition at line 469 of file guc.c.

char* XactIsoLevel_string [static]

Definition at line 461 of file guc.c.

Initial value:
 {
    {"base64", XMLBINARY_BASE64, false},
    {"hex", XMLBINARY_HEX, false},
    {NULL, 0, false}
}

Definition at line 317 of file guc.c.

Initial value:
 {
    {"content", XMLOPTION_CONTENT, false},
    {"document", XMLOPTION_DOCUMENT, false},
    {NULL, 0, false}
}

Definition at line 323 of file guc.c.