This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new ce01f91c466 Fix conflict for utils/misc
ce01f91c466 is described below
commit ce01f91c46646d9b2985c7a5d5d6205c7000ccb0
Author: Jinbao Chen <[email protected]>
AuthorDate: Tue Oct 7 20:20:09 2025 +0800
Fix conflict for utils/misc
---
src/backend/utils/misc/guc-file.l | 403 ------------------------------------
src/backend/utils/misc/guc.c | 255 ++++++-----------------
src/backend/utils/misc/guc_funcs.c | 100 +++++++++
src/backend/utils/misc/guc_gp.c | 106 ++++------
src/backend/utils/misc/guc_tables.c | 41 +---
src/backend/utils/misc/ps_status.c | 40 ----
src/backend/utils/misc/sampling.c | 75 -------
src/include/access/xlog.h | 1 +
src/include/catalog/pg_profile.h | 1 +
src/include/utils/guc.h | 6 +-
src/include/utils/guc_tables.h | 9 +-
11 files changed, 220 insertions(+), 817 deletions(-)
diff --git a/src/backend/utils/misc/guc-file.l
b/src/backend/utils/misc/guc-file.l
index a0fc3b0203b..41d62a9f233 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -21,21 +21,6 @@
#include "utils/memutils.h"
}
-#define unify_version(a,b,c) ((a<<16)+(b<<8)+c)
-#if
unify_version(YY_FLEX_MAJOR_VERSION,YY_FLEX_MINOR_VERSION,YY_FLEX_SUBMINOR_VERSION)
< unify_version(2,5,35)
-int GUC_yylex_destroy (void);
-int GUC_yyget_lineno (void);
-FILE *GUC_yyget_in (void);
-FILE *GUC_yyget_out (void);
-int GUC_yyget_leng (void);
-char *GUC_yyget_text (void);
-void GUC_yyset_lineno (int line_number );
-void GUC_yyset_in (FILE * in_str );
-void GUC_yyset_out (FILE * out_str );
-int GUC_yyget_debug (void);
-void GUC_yyset_debug (int bdebug );
-int GUC_yylex_destroy (void);
-#endif
%{
/*
@@ -171,394 +156,6 @@ ProcessConfigFile(GucContext context)
MemoryContextDelete(config_cxt);
}
-/*
- * This function handles both actual config file (re)loads and execution of
- * show_all_file_settings() (i.e., the pg_file_settings view). In the latter
- * case we don't apply any of the settings, but we make all the usual validity
- * checks, and we return the ConfigVariable list so that it can be printed out
- * by show_all_file_settings().
- */
-static ConfigVariable *
-ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
-{
- bool error = false;
- bool applying = false;
- const char *ConfFileWithError;
- ConfigVariable *item,
- *head,
- *tail;
- int i;
-
- /* Parse the main config file into a list of option names and values */
- ConfFileWithError = ConfigFileName;
- head = tail = NULL;
-
- if (!ParseConfigFile(ConfigFileName, true,
- NULL, 0, 0, elevel,
- &head, &tail))
- {
- /* Syntax error(s) detected in the file, so bail out */
- error = true;
- goto bail_out;
- }
-
- /*
- * Parse the PG_AUTOCONF_FILENAME file, if present, after the main file
to
- * replace any parameters set by ALTER SYSTEM command. Because this
file
- * is in the data directory, we can't read it until the DataDir has been
- * set.
- */
- if (DataDir)
- {
- if (!ParseConfigFile(PG_AUTOCONF_FILENAME, false,
- NULL, 0, 0, elevel,
- &head, &tail))
- {
- /* Syntax error(s) detected in the file, so bail out */
- error = true;
- ConfFileWithError = PG_AUTOCONF_FILENAME;
- goto bail_out;
- }
- }
- else
- {
- /*
- * If DataDir is not set, the PG_AUTOCONF_FILENAME file cannot
be
- * read. In this case, we don't want to accept any settings but
- * data_directory from postgresql.conf, because they might be
- * overwritten with settings in the PG_AUTOCONF_FILENAME file
which
- * will be read later. OTOH, since data_directory isn't allowed
in the
- * PG_AUTOCONF_FILENAME file, it will never be overwritten
later.
- */
- ConfigVariable *newlist = NULL;
-
- /*
- * Prune all items except the last "data_directory" from the
list.
- */
- for (item = head; item; item = item->next)
- {
- if (!item->ignore &&
- strcmp(item->name, "data_directory") == 0)
- newlist = item;
- }
-
- if (newlist)
- newlist->next = NULL;
- head = tail = newlist;
-
- /*
- * Quick exit if data_directory is not present in file.
- *
- * We need not do any further processing, in particular we
don't set
- * PgReloadTime; that will be set soon by subsequent full
loading of
- * the config file.
- */
- if (head == NULL)
- goto bail_out;
- }
-
- /*
- * Mark all extant GUC variables as not present in the config file. We
- * need this so that we can tell below which ones have been removed from
- * the file since we last processed it.
- */
- for (i = 0; i < num_guc_variables; i++)
- {
- struct config_generic *gconf = guc_variables[i];
-
- gconf->status &= ~GUC_IS_IN_FILE;
- }
-
- /*
- * Check if all the supplied option names are valid, as an additional
- * quasi-syntactic check on the validity of the config file. It is
- * important that the postmaster and all backends agree on the results
of
- * this phase, else we will have strange inconsistencies about which
- * processes accept a config file update and which don't. Hence,
unknown
- * custom variable names have to be accepted without complaint. For the
- * same reason, we don't attempt to validate the options' values here.
- *
- * In addition, the GUC_IS_IN_FILE flag is set on each existing GUC
- * variable mentioned in the file; and we detect duplicate entries in
the
- * file and mark the earlier occurrences as ignorable.
- */
- for (item = head; item; item = item->next)
- {
- struct config_generic *record;
-
- /* Ignore anything already marked as ignorable */
- if (item->ignore)
- continue;
-
- /*
- * Try to find the variable; but do not create a custom
placeholder if
- * it's not there already.
- */
- record = find_option(item->name, false, true, elevel);
-
- if (record)
- {
- /* If it's already marked, then this is a duplicate
entry */
- if (record->status & GUC_IS_IN_FILE)
- {
- /*
- * Mark the earlier occurrence(s) as
dead/ignorable. We could
- * avoid the O(N^2) behavior here with some
additional state,
- * but it seems unlikely to be worth the
trouble.
- */
- ConfigVariable *pitem;
-
- for (pitem = head; pitem != item; pitem =
pitem->next)
- {
- if (!pitem->ignore &&
- strcmp(pitem->name, item->name)
== 0)
- pitem->ignore = true;
- }
- }
- /* Now mark it as present in file */
- record->status |= GUC_IS_IN_FILE;
- }
- else if (!valid_custom_variable_name(item->name))
- {
- /* Invalid non-custom variable, so complain */
- ereport(elevel,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("unrecognized configuration
parameter \"%s\" in file \"%s\" line %d",
- item->name,
- item->filename,
item->sourceline)));
- item->errmsg = pstrdup("unrecognized configuration
parameter");
- error = true;
- ConfFileWithError = item->filename;
- }
- }
-
- /*
- * If we've detected any errors so far, we don't want to risk applying
any
- * changes.
- */
- if (error)
- goto bail_out;
-
- /* Otherwise, set flag that we're beginning to apply changes */
- applying = true;
-
- /*
- * Check for variables having been removed from the config file, and
- * revert their reset values (and perhaps also effective values) to the
- * boot-time defaults. If such a variable can't be changed after
startup,
- * report that and continue.
- */
- for (i = 0; i < num_guc_variables; i++)
- {
- struct config_generic *gconf = guc_variables[i];
- GucStack *stack;
-
- if (gconf->reset_source != PGC_S_FILE ||
- (gconf->status & GUC_IS_IN_FILE))
- continue;
- if (gconf->context < PGC_SIGHUP)
- {
- /* The removal can't be effective without a restart */
- gconf->status |= GUC_PENDING_RESTART;
- ereport(elevel,
-
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
- errmsg("parameter \"%s\" cannot be
changed without restarting the server",
- gconf->name)));
- record_config_file_error(psprintf("parameter \"%s\"
cannot be changed without restarting the server",
-
gconf->name),
- NULL,
0,
- &head,
&tail);
- error = true;
- continue;
- }
-
- /* No more to do if we're just doing show_all_file_settings() */
- if (!applySettings)
- continue;
-
- /*
- * Reset any "file" sources to "default", else
set_config_option will
- * not override those settings.
- */
- if (gconf->reset_source == PGC_S_FILE)
- gconf->reset_source = PGC_S_DEFAULT;
- if (gconf->source == PGC_S_FILE)
- gconf->source = PGC_S_DEFAULT;
- for (stack = gconf->stack; stack; stack = stack->prev)
- {
- if (stack->source == PGC_S_FILE)
- stack->source = PGC_S_DEFAULT;
- }
-
- /* Now we can re-apply the wired-in default (i.e., the
boot_val) */
- if (set_config_option(gconf->name, NULL,
- context,
PGC_S_DEFAULT,
- GUC_ACTION_SET, true,
0, false) > 0)
- {
- /* Log the change if appropriate */
- if (context == PGC_SIGHUP)
- ereport(elevel,
- (errmsg("parameter \"%s\"
removed from configuration file, reset to default",
- gconf->name)));
- }
- }
-
- /*
- * Restore any variables determined by environment variables or
- * dynamically-computed defaults. This is a no-op except in the case
- * where one of these had been in the config file and is now removed.
- *
- * In particular, we *must not* do this during the postmaster's initial
- * loading of the file, since the timezone functions in particular
should
- * be run only after initialization is complete.
- *
- * XXX this is an unmaintainable crock, because we have to know how to
set
- * (or at least what to call to set) every variable that could
potentially
- * have PGC_S_DYNAMIC_DEFAULT or PGC_S_ENV_VAR source. However, there's
no
- * time to redesign it for 9.1.
- */
- if (context == PGC_SIGHUP && applySettings)
- {
- InitializeGUCOptionsFromEnvironment();
- pg_timezone_abbrev_initialize();
- /* this selects SQL_ASCII in processes not connected to a
database */
- SetConfigOption("client_encoding", GetDatabaseEncodingName(),
- PGC_BACKEND,
PGC_S_DYNAMIC_DEFAULT);
- }
-
- /*
- * Now apply the values from the config file.
- */
- for (item = head; item; item = item->next)
- {
- char *pre_value = NULL;
- int scres;
-
- /* Ignore anything marked as ignorable */
- if (item->ignore)
- continue;
-
- /* Ignore anything marked as ignorable */
- if (item->ignore)
- continue;
-
- /* In SIGHUP cases in the postmaster, we want to report changes
*/
- if (context == PGC_SIGHUP && applySettings &&
!IsUnderPostmaster)
- {
- const char *preval = GetConfigOption(item->name, true,
false);
-
- /* If option doesn't exist yet or is NULL, treat as
empty string */
- if (!preval)
- preval = "";
- /* must dup, else might have dangling pointer below */
- pre_value = pstrdup(preval);
- }
-
- scres = set_config_option(item->name, item->value,
- context,
PGC_S_FILE,
-
GUC_ACTION_SET, applySettings, 0, false);
- if (scres > 0)
- {
- /* variable was updated, so log the change if
appropriate */
- if (pre_value)
- {
- const char *post_value =
GetConfigOption(item->name, true, false);
-
- if (!post_value)
- post_value = "";
- if (strcmp(pre_value, post_value) != 0)
- ereport(elevel,
- (errmsg("parameter
\"%s\" changed to \"%s\"",
-
item->name, item->value)));
- }
- item->applied = true;
- }
- else if (scres == 0)
- {
- error = true;
- item->errmsg = pstrdup("setting could not be applied");
- ConfFileWithError = item->filename;
- }
- else
- {
- /* no error, but variable's active value was not
changed */
- item->applied = true;
- }
-
- /*
- * We should update source location unless there was an error,
since
- * even if the active value didn't change, the reset value
might have.
- * (In the postmaster, there won't be a difference, but it does
matter
- * in backends.)
- */
- if (scres != 0 && applySettings)
- set_config_sourcefile(item->name, item->filename,
-
item->sourceline);
-
- if (pre_value)
- pfree(pre_value);
- }
-
- /* Remember when we last successfully loaded the config file. */
- if (applySettings)
- PgReloadTime = GetCurrentTimestamp();
-
-bail_out:
- if (error && applySettings)
- {
- /* During postmaster startup, any error is fatal */
- if (context == PGC_POSTMASTER)
- ereport(ERROR,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("configuration file \"%s\"
contains errors",
- ConfFileWithError)));
- else if (applying)
- ereport(elevel,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("configuration file \"%s\"
contains errors; unaffected changes were applied",
- ConfFileWithError)));
- else
- ereport(elevel,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("configuration file \"%s\"
contains errors; no changes were applied",
- ConfFileWithError)));
- }
-
- /* Successful or otherwise, return the collected data list */
- return head;
-}
-
-/*
- * Given a configuration file or directory location that may be a relative
- * path, return an absolute one. We consider the location to be relative to
- * the directory holding the calling file, or to DataDir if no calling file.
- */
-static char *
-AbsoluteConfigLocation(const char *location, const char *calling_file)
-{
- char abs_path[MAXPGPATH];
-
- if (is_absolute_path(location))
- return pstrdup(location);
- else
- {
- if (calling_file != NULL)
- {
- strlcpy(abs_path, calling_file, sizeof(abs_path));
- get_parent_directory(abs_path);
- join_path_components(abs_path, abs_path, location);
- canonicalize_path(abs_path);
- }
- else
- {
- AssertState(DataDir);
- join_path_components(abs_path, DataDir, location);
- canonicalize_path(abs_path);
- }
- return pstrdup(abs_path);
- }
-}
-
/*
* Read and parse a single configuration file. This function recurses
* to handle "include" directives.
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 589ea0bf1ea..dcb57735be0 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -99,7 +99,6 @@
#include "utils/plancache.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
-#include "utils/queryjumble.h"
#include "utils/rls.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.h"
@@ -288,7 +287,6 @@ static bool reporting_enabled; /* true to enable
GUC_REPORT */
static int GUCNestLevel = 0; /* 1 when in main transaction */
-static int guc_var_name_compare(const void *key, const void *generic);
static int guc_var_compare(const void *a, const void *b);
static uint32 guc_name_hash(const void *key, Size keysize);
static int guc_name_match(const void *key1, const void *key2, Size
keysize);
@@ -296,7 +294,6 @@ static void InitializeGUCOptionsFromEnvironment(void);
static void InitializeOneGUCOption(struct config_generic *gconf);
static void RemoveGUCFromLists(struct config_generic *gconf);
static void set_guc_source(struct config_generic *gconf, GucSource newsource);
-static void pg_timezone_abbrev_initialize(void);
static void push_old_value(struct config_generic *gconf, GucAction action);
static void ReportGUCOption(struct config_generic *record);
static void set_config_sourcefile(const char *name, char *sourcefile,
@@ -326,8 +323,6 @@ static bool call_string_check_hook(struct config_string
*conf, char **newval,
static bool call_enum_check_hook(struct config_enum *conf, int *newval,
void **extra,
GucSource source, int elevel);
-static void DispatchSetPGVariable(const char *name, List *args, bool is_local);
-
/*
* This function handles both actual config file (re)loads and execution of
* show_all_file_settings() (i.e., the pg_file_settings view). In the latter
@@ -926,50 +921,30 @@ discard_stack_value(struct config_generic *gconf,
config_var_value *val)
* The array length is returned into *num_vars.
*/
struct config_generic **
-get_guc_variables(void)
-{
- return guc_variables;
-}
-
-int get_num_guc_variables(void)
-{
- return num_guc_variables;
-}
-
-/*
- * gp_guc_list_show
- *
- * Given a list of GUCs (a List of struct config_generic), construct a list
- * of human-readable strings of the option names and current values, skipping
- * any whose source <= 'excluding'.
- */
-List *
-gp_guc_list_show(GucSource excluding, List *guclist)
+get_guc_variables(int *num_vars)
{
- List *options = NIL;
- ListCell *cell;
- char *value;
- char buf[NAMEDATALEN];
+ struct config_generic **result;
+ HASH_SEQ_STATUS status;
+ GUCHashEntry *hentry;
+ int i;
- foreach(cell, guclist)
- {
- struct config_generic *gconf = (struct config_generic *)
lfirst(cell);
+ *num_vars = hash_get_num_entries(guc_hashtab);
+ result = palloc(sizeof(struct config_generic *) * *num_vars);
- if (gconf->source > excluding)
- {
- value = _ShowOption(gconf, true);
- snprintf(buf, sizeof(buf), "%s=%s", gconf->name, value);
- options = lappend(options, pstrdup(buf));
+ /* Extract pointers from the hash table */
+ i = 0;
+ hash_seq_init(&status, guc_hashtab);
+ while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
+ result[i++] = hentry->gucvar;
+ Assert(i == *num_vars);
- memset(&buf, '\0', sizeof(buf));
- pfree(value);
- }
- }
+ /* Sort by name */
+ qsort(result, *num_vars,
+ sizeof(struct config_generic *), guc_var_compare);
- return options;
+ return result;
}
-
/*
* Build the GUC hash table. This is split out so that help_config.c can
* extract all the variables without running all of InitializeGUCOptions.
@@ -1112,7 +1087,16 @@ build_guc_variables(void)
}
for (i = 0; ConfigureNamesBool_gp[i].gen.name; i++)
- guc_vars[num_vars++] = &ConfigureNamesBool_gp[i].gen;
+ {
+ struct config_generic *gucvar = &ConfigureNamesBool_gp[i].gen;
+
+ hentry = (GUCHashEntry *) hash_search(guc_hashtab,
+
&gucvar->name,
+
HASH_ENTER,
+
&found);
+ Assert(!found);
+ hentry->gucvar = gucvar;
+ }
for (i = 0; ConfigureNamesInt[i].gen.name; i++)
{
@@ -1127,7 +1111,16 @@ build_guc_variables(void)
}
for (i = 0; ConfigureNamesInt_gp[i].gen.name; i++)
- guc_vars[num_vars++] = &ConfigureNamesInt_gp[i].gen;
+ {
+ struct config_generic *gucvar = &ConfigureNamesInt_gp[i].gen;
+
+ hentry = (GUCHashEntry *) hash_search(guc_hashtab,
+
&gucvar->name,
+
HASH_ENTER,
+
&found);
+ Assert(!found);
+ hentry->gucvar = gucvar;
+ }
for (i = 0; ConfigureNamesReal[i].gen.name; i++)
{
@@ -1142,7 +1135,16 @@ build_guc_variables(void)
}
for (i = 0; ConfigureNamesReal_gp[i].gen.name; i++)
- guc_vars[num_vars++] = &ConfigureNamesReal_gp[i].gen;
+ {
+ struct config_generic *gucvar = &ConfigureNamesReal_gp[i].gen;
+
+ hentry = (GUCHashEntry *) hash_search(guc_hashtab,
+
&gucvar->name,
+
HASH_ENTER,
+
&found);
+ Assert(!found);
+ hentry->gucvar = gucvar;
+ }
for (i = 0; ConfigureNamesString[i].gen.name; i++)
{
@@ -1157,13 +1159,22 @@ build_guc_variables(void)
}
for (i = 0; ConfigureNamesString_gp[i].gen.name; i++)
- guc_vars[num_vars++] = &ConfigureNamesString_gp[i].gen;
+ {
+ struct config_generic *gucvar = &ConfigureNamesString_gp[i].gen;
+
+ hentry = (GUCHashEntry *) hash_search(guc_hashtab,
+
&gucvar->name,
+
HASH_ENTER,
+
&found);
+ Assert(!found);
+ hentry->gucvar = gucvar;
+ }
for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
{
struct config_generic *gucvar = &ConfigureNamesEnum[i].gen;
- hentry = (GUCH ashEntry *) hash_search(guc_hashtab,
+ hentry = (GUCHashEntry *) hash_search(guc_hashtab,
&gucvar->name,
HASH_ENTER,
&found);
@@ -1171,7 +1182,7 @@ build_guc_variables(void)
hentry->gucvar = gucvar;
}
- gpdb_assign_sync_flag(guc_variables, num_guc_variables, true /*
predefine */);
+ gpdb_assign_sync_flag(guc_hashtab);
Assert(num_vars == hash_get_num_entries(guc_hashtab));
}
@@ -1199,7 +1210,7 @@ add_guc_variable(struct config_generic *var, int elevel)
}
Assert(!found);
hentry->gucvar = var;
- gpdb_assign_sync_flag(&var, 1, false /* predefine */);
+ gpdb_assign_sync_flag_one(var, false /* predefine */);
return true;
}
@@ -1391,24 +1402,6 @@ find_option(const char *name, bool create_placeholders,
bool skip_errors,
return NULL;
}
-/*
- * comparator for bsearch guc_variables array
- * qsort requires that two arguments are the type of element,
- * but bsearch requires the first argument to be the key,
- * the second argument is type of the array element.
- *
- * In pg upstream, bsearch is not used in this file, so
- * the function should be removed later.
- */
-static int
-guc_var_name_compare(const void *key, const void *generic)
-{
- const char *name = *(char *const *)key;
- const struct config_generic *conf = *(struct config_generic *const *)
generic;
-
- return guc_name_compare(name, conf->name);
-}
-
/*
* comparator for qsorting an array of GUC pointers
*/
@@ -1706,36 +1699,6 @@ InitializeGUCOptions(void)
InitializeGUCOptionsFromEnvironment();
}
-/*
- * If any custom resource managers were specified in the
- * wal_consistency_checking GUC, processing was deferred. Now that
- * shared_preload_libraries have been loaded, process wal_consistency_checking
- * again.
- */
-void
-InitializeWalConsistencyChecking(void)
-{
- Assert(process_shared_preload_libraries_done);
-
- if (check_wal_consistency_checking_deferred)
- {
- struct config_generic *guc;
-
- guc = find_option("wal_consistency_checking", false, false,
ERROR);
-
- check_wal_consistency_checking_deferred = false;
-
- set_config_option("wal_consistency_checking",
-
wal_consistency_checking_string,
- PGC_POSTMASTER, guc->source,
- GUC_ACTION_SET, true, ERROR,
false);
-
- /* checking should not be deferred again */
- Assert(!check_wal_consistency_checking_deferred);
- }
-
-}
-
/*
* Assign any GUC values that can come from the server's environment.
*
@@ -2149,7 +2112,7 @@ SelectConfigFiles(const char *userDoption, const char
*progname)
* This can also be called from ProcessConfigFile to establish the default
* value after a postgresql.conf entry for it is removed.
*/
-static void
+void
pg_timezone_abbrev_initialize(void)
{
SetConfigOption("timezone_abbreviations", "Default",
@@ -4983,102 +4946,6 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
LWLockRelease(AutoFileLock);
}
-static void
-DispatchSetPGVariable(const char *name, List *args, bool is_local)
-{
- ListCell *l;
- StringInfoData buffer;
-
- if (Gp_role != GP_ROLE_DISPATCH || IsBootstrapProcessingMode())
- return;
-
- /*
- * client_encoding is always kept at SQL_ASCII in QE processes. (See
also
- * cdbconn_doConnectStart().)
- */
- if (strcmp(name, "client_encoding") == 0)
- return;
-
- initStringInfo( &buffer );
-
- if (args == NIL)
- {
- appendStringInfo(&buffer, "RESET %s", name);
- }
- else
- {
- appendStringInfo(&buffer, "SET ");
- if (is_local)
- appendStringInfo(&buffer, "LOCAL ");
-
- appendStringInfo(&buffer, "%s TO ", quote_identifier(name));
-
- /*
- * GPDB: We handle the timezone GUC specially. This is because
the
- * timezone GUC can be set with the SET TIME ZONE .. syntax
which is an
- * alias for SET timezone. Instead of dispatching the SET TIME
ZONE ..
- * as a special case, we dispatch the already set time zone
from the QD
- * with the usual SET syntax flavor (SET timezone TO <>).
- * Please refer to Issue: #9055 for additional detail.
- * #9055 - https://github.com/greenplum-db/gpdb/issues/9055
- */
- if (strcmp(name, "timezone") == 0)
- appendStringInfo(&buffer, "%s",
-
quote_literal_cstr(GetConfigOptionByName("timezone",
-
NULL,
-
false)));
- else
- {
- foreach(l, args)
- {
- Node *arg = (Node *) lfirst(l);
- char *val;
- A_Const *con;
-
- if (l != list_head(args))
- appendStringInfo(&buffer, ", ");
-
- if (IsA(arg, TypeCast))
- {
- TypeCast *tc = (TypeCast *) arg;
- arg = tc->arg;
- }
-
- con = (A_Const *) arg;
-
- if (!IsA(con, A_Const))
- elog(ERROR, "unrecognized node type:
%d", (int) nodeTag(arg));
-
- switch (nodeTag(&con->val))
- {
- case T_Integer:
- appendStringInfo(&buffer, "%d",
intVal(&con->val));
- break;
- case T_Float:
- /* represented as a string, so
just copy it */
- appendStringInfoString(&buffer,
strVal(&con->val));
- break;
- case T_String:
- val = strVal(&con->val);
-
- /*
- * Plain string literal or
identifier. Quote it.
- */
- appendStringInfo(&buffer, "%s",
quote_literal_cstr(val));
-
- break;
- default:
- elog(ERROR, "unrecognized node
type: %d",
- (int)
nodeTag(&con->val));
- break;
- }
- }
- }
- }
-
- CdbDispatchSetCommand(buffer.data, false);
-}
-
/*
* Common code for DefineCustomXXXVariable subroutines: allocate the
* new variable's config struct and fill in generic fields.
diff --git a/src/backend/utils/misc/guc_funcs.c
b/src/backend/utils/misc/guc_funcs.c
index 3a2630252de..6464665112a 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -22,6 +22,8 @@
#include "catalog/objectaccess.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_parameter_acl.h"
+#include "cdb/cdbdisp_query.h"
+#include "cdb/cdbvars.h"
#include "funcapi.h"
#include "guc_internal.h"
#include "parser/parse_type.h"
@@ -34,6 +36,7 @@
static char *flatten_set_variable_args(const char *name, List *args);
static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
static void ShowAllGUCConfig(DestReceiver *dest);
+static void DispatchSetPGVariable(const char *name, List *args, bool is_local);
/*
@@ -1106,3 +1109,100 @@ show_all_file_settings(PG_FUNCTION_ARGS)
return (Datum) 0;
}
+
+
+static void
+DispatchSetPGVariable(const char *name, List *args, bool is_local)
+{
+ ListCell *l;
+ StringInfoData buffer;
+
+ if (Gp_role != GP_ROLE_DISPATCH || IsBootstrapProcessingMode())
+ return;
+
+ /*
+ * client_encoding is always kept at SQL_ASCII in QE processes. (See
also
+ * cdbconn_doConnectStart().)
+ */
+ if (strcmp(name, "client_encoding") == 0)
+ return;
+
+ initStringInfo( &buffer );
+
+ if (args == NIL)
+ {
+ appendStringInfo(&buffer, "RESET %s", name);
+ }
+ else
+ {
+ appendStringInfo(&buffer, "SET ");
+ if (is_local)
+ appendStringInfo(&buffer, "LOCAL ");
+
+ appendStringInfo(&buffer, "%s TO ", quote_identifier(name));
+
+ /*
+ * GPDB: We handle the timezone GUC specially. This is because
the
+ * timezone GUC can be set with the SET TIME ZONE .. syntax
which is an
+ * alias for SET timezone. Instead of dispatching the SET TIME
ZONE ..
+ * as a special case, we dispatch the already set time zone
from the QD
+ * with the usual SET syntax flavor (SET timezone TO <>).
+ * Please refer to Issue: #9055 for additional detail.
+ * #9055 - https://github.com/greenplum-db/gpdb/issues/9055
+ */
+ if (strcmp(name, "timezone") == 0)
+ appendStringInfo(&buffer, "%s",
+
quote_literal_cstr(GetConfigOptionByName("timezone",
+
NULL,
+
false)));
+ else
+ {
+ foreach(l, args)
+ {
+ Node *arg = (Node *) lfirst(l);
+ char *val;
+ A_Const *con;
+
+ if (l != list_head(args))
+ appendStringInfo(&buffer, ", ");
+
+ if (IsA(arg, TypeCast))
+ {
+ TypeCast *tc = (TypeCast *) arg;
+ arg = tc->arg;
+ }
+
+ con = (A_Const *) arg;
+
+ if (!IsA(con, A_Const))
+ elog(ERROR, "unrecognized node type:
%d", (int) nodeTag(arg));
+
+ switch (nodeTag(&con->val))
+ {
+ case T_Integer:
+ appendStringInfo(&buffer, "%d",
intVal(&con->val));
+ break;
+ case T_Float:
+ /* represented as a string, so
just copy it */
+ appendStringInfoString(&buffer,
strVal(&con->val));
+ break;
+ case T_String:
+ val = strVal(&con->val);
+
+ /*
+ * Plain string literal or
identifier. Quote it.
+ */
+ appendStringInfo(&buffer, "%s",
quote_literal_cstr(val));
+
+ break;
+ default:
+ elog(ERROR, "unrecognized node
type: %d",
+ (int)
nodeTag(&con->val));
+ break;
+ }
+ }
+ }
+ }
+
+ CdbDispatchSetCommand(buffer.data, false);
+}
diff --git a/src/backend/utils/misc/guc_gp.c b/src/backend/utils/misc/guc_gp.c
index e342d762705..2c9eabf17ae 100644
--- a/src/backend/utils/misc/guc_gp.c
+++ b/src/backend/utils/misc/guc_gp.c
@@ -2959,15 +2959,6 @@ struct config_bool ConfigureNamesBool_gp[] =
true, NULL, NULL
},
- {
- {"stats_queue_level", PGC_SUSET, STATS_COLLECTOR,
- gettext_noop("Collects resource queue-level statistics
on database activity."),
- NULL
- },
- &pgstat_collect_queuelevel,
- false, NULL, NULL
- },
-
{
{"create_restartpoint_on_ckpt_record_replay", PGC_SIGHUP,
DEVELOPER_OPTIONS,
gettext_noop("Creates a restartpoint only on mirror
immediately after replaying a checkpoint record."),
@@ -5261,62 +5252,55 @@ static int guc_array_compare(const void *a, const void
*b)
return guc_name_compare(namea, nameb);
}
-void gpdb_assign_sync_flag(struct config_generic **guc_variables, int size,
bool predefine)
+void gpdb_assign_sync_flag_one(struct config_generic *var, bool predefine)
{
- static bool init = false;
- /* ordering guc_name_array alphabets */
- if (!init) {
- sync_guc_num = sizeof(sync_guc_names_array) / sizeof(char *);
- qsort((void *) sync_guc_names_array, sync_guc_num,
- sizeof(char *), guc_array_compare);
-
- unsync_guc_num = sizeof(unsync_guc_names_array) / sizeof(char
*);
- qsort((void *) unsync_guc_names_array, unsync_guc_num,
- sizeof(char *), guc_array_compare);
-
- init = true;
- }
+ /* if the sync flags is defined in guc variable, skip it */
+ if (var->flags & (GUC_GPDB_NEED_SYNC | GUC_GPDB_NO_SYNC))
+ return;
- for (int i = 0; i < size; i ++)
- {
- struct config_generic *var = guc_variables[i];
+ char *res = (char *) bsearch((void *) &var->name,
+ (void *)
sync_guc_names_array,
+ sync_guc_num,
+ sizeof(char *),
+
guc_array_compare);
+ if (!res)
+ {
+ res = (char *) bsearch((void *) &var->name,
+ (void
*) unsync_guc_names_array,
+
unsync_guc_num,
+
sizeof(char *),
+
guc_array_compare);
+
+ /* for predefined guc, we force its name in one array.
+ * for the third-part libraries gucs introduced by customer
+ * we assign unsync flags as default.
+ */
+ if (!res && predefine)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_INTERNAL_ERROR),
+ errmsg("Neither
sync_guc_names_array nor "
+
"unsync_guc_names_array contains predefined "
+ "guc name:
%s", var->name)));
+ }
- /* if the sync flags is defined in guc variable, skip it */
- if (var->flags & (GUC_GPDB_NEED_SYNC | GUC_GPDB_NO_SYNC))
- continue;
+ var->flags |= GUC_GPDB_NO_SYNC;
+ }
+ else
+ {
+ var->flags |= GUC_GPDB_NEED_SYNC;
+ }
+}
- char *res = (char *) bsearch((void *) &var->name,
- (void *) sync_guc_names_array,
- sync_guc_num,
- sizeof(char *),
- guc_array_compare);
- if (!res)
- {
- char *res = (char *) bsearch((void *) &var->name,
- (void *)
unsync_guc_names_array,
- unsync_guc_num,
- sizeof(char *),
- guc_array_compare);
-
- /* for predefined guc, we force its name in one array.
- * for the third-part libraries gucs introduced by
customer
- * we assign unsync flags as default.
- */
- if (!res && predefine)
- {
- ereport(ERROR,
- (errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("Neither
sync_guc_names_array nor "
-
"unsync_guc_names_array contains predefined "
- "guc name: %s",
var->name)));
- }
+void gpdb_assign_sync_flag(HTAB *guc_tab)
+{
+ HASH_SEQ_STATUS status;
+ struct config_generic *var;
- var->flags |= GUC_GPDB_NO_SYNC;
- }
- else
- {
- var->flags |= GUC_GPDB_NEED_SYNC;
- }
+ hash_seq_init(&status, guc_tab);
+ while((var = hash_seq_search(&status)) != NULL)
+ {
+ gpdb_assign_sync_flag_one(var, true);
}
}
@@ -5533,7 +5517,7 @@ assign_gp_default_storage_options(const char *newval,
void *extra)
void
set_gp_replication_config(const char *name, const char *value)
{
- A_Const aconst = {.type = T_A_Const, .val = {.type = T_String, .val.str
= pstrdup(value)}};
+ A_Const aconst = {.type = T_A_Const, .val = {.sval = {.type = T_String,
.sval = pstrdup(value)}}};
List *args = list_make1(&aconst);
VariableSetStmt setstmt = {.type = T_VariableSetStmt, .kind =
VAR_SET_VALUE, .name = pstrdup(name), .args = args};
AlterSystemStmt alterSystemStmt = {.type = T_AlterSystemStmt, .setstmt
= &setstmt};
diff --git a/src/backend/utils/misc/guc_tables.c
b/src/backend/utils/misc/guc_tables.c
index cea6fca9c55..ea1f953dc34 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -36,12 +36,15 @@
#include "archive/archive_module.h"
#include "catalog/namespace.h"
#include "catalog/storage.h"
+#include "catalog/storage_directory_table.h"
#include "commands/async.h"
#include "commands/tablespace.h"
#include "commands/trigger.h"
#include "commands/user.h"
#include "commands/vacuum.h"
+#include "commands/variable.h"
#include "common/scram-common.h"
+#include "crypto/kmgr.h"
#include "jit/jit.h"
#include "libpq/auth.h"
#include "libpq/libpq.h"
@@ -52,6 +55,7 @@
#include "optimizer/optimizer.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
+#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parser.h"
#include "pgstat.h"
@@ -757,6 +761,8 @@ const char *const config_group_names[] =
/* CLIENT_CONN_OTHER */
gettext_noop("Client Connection Defaults / Other Defaults"),
/* LOCK_MANAGEMENT */
+ /* COMPAT_OPTIONS */
+ gettext_noop("Version and Platform Compatibility"),
gettext_noop("Lock Management"),
/* COMPAT_OPTIONS_PREVIOUS */
gettext_noop("Version and Platform Compatibility / Previous PostgreSQL
Versions"),
@@ -2272,7 +2278,7 @@ struct config_int ConfigureNamesInt[] =
},
&MaxConnections,
200, 10, MAX_BACKENDS,
- check_maxconnections, NULL, NULL
+ check_max_connections, NULL, NULL
},
{
@@ -4143,28 +4149,6 @@ struct config_string ConfigureNamesString[] =
/* See main.c about why defaults for LC_foo are not all alike */
- {
- {"lc_collate", PGC_INTERNAL, PRESET_OPTIONS,
- gettext_noop("Shows the collation order locale."),
- NULL,
- GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
- },
- &locale_collate,
- "C",
- NULL, NULL, NULL
- },
-
- {
- {"lc_ctype", PGC_INTERNAL, PRESET_OPTIONS,
- gettext_noop("Shows the character classification and
case conversion locale."),
- NULL,
- GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
- },
- &locale_ctype,
- "C",
- NULL, NULL, NULL
- },
-
{
{"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
gettext_noop("Sets the language in which messages are
displayed."),
@@ -4531,17 +4515,6 @@ struct config_string ConfigureNamesString[] =
NULL, NULL, NULL
},
- {
- {"stats_temp_directory", PGC_SIGHUP, STATS_COLLECTOR,
- gettext_noop("Writes temporary statistics files to the
specified directory."),
- NULL,
- GUC_SUPERUSER_ONLY | GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
- },
- &pgstat_temp_directory,
- PG_STAT_TMP_DIR,
- check_canonical_path, assign_pgstat_temp_directory, NULL
- },
-
{
{"synchronous_standby_names", PGC_SIGHUP, REPLICATION_PRIMARY,
gettext_noop("Number of synchronous standbys and list
of names of potential synchronous ones."),
diff --git a/src/backend/utils/misc/ps_status.c
b/src/backend/utils/misc/ps_status.c
index 8337c53bd2d..5fc203f32dd 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -373,46 +373,6 @@ update_ps_display_precheck(void)
return false;
#endif
- Assert(cp >= ps_buffer);
-
- /* Add client session's global id. */
- if (gp_session_id > 0 && ep - cp > 0 &&
- strstr(ps_buffer, "dtx recovery process") == NULL &&
- strstr(ps_buffer, "ftsprobe process") == NULL)
- {
- cp += snprintf(cp, ep - cp, "con%d ", gp_session_id);
-
- /* Which segment is accessed by this qExec? */
- if (Gp_role == GP_ROLE_EXECUTE && GpIdentity.segindex >= -1)
- cp += snprintf(cp, ep - cp, "seg%d ",
GpIdentity.segindex);
- }
-
- /* Add count of commands received from client session. */
- if (gp_command_count > 0 && ep - cp > 0)
- cp += snprintf(cp, ep - cp, "cmd%d ", gp_command_count);
-
- /* Add slice number information */
- if (currentSliceId > 0 && ep - cp > 0)
- cp += snprintf(cp, ep - cp, "slice%d ", currentSliceId);
-
- /*
- * Calculate the size preceding the actual activity string start.
- * snprintf returns the number of bytes that *would* have been written
if
- * enough space had been available. This means cp might go beyond, if
- * truncation happened. Hence need below check for Min. (ep - 1) is
- * performed because in normal case when no truncation happens, snprintf
- * doesn't count null, so in truncation case as well it shouldn't be
- * counted. End result simply intended here is really
real_act_prefix_size
- * = strlen(ps_buffer), for performance reasons kept this way.
- */
- real_act_prefix_size = Min(cp, (ep-1)) - ps_buffer;
-
- /* Append caller's activity string. */
- strlcpy(ps_buffer + real_act_prefix_size, activity,
- ps_buffer_size - real_act_prefix_size);
-
- ps_buffer_cur_len = strlen(ps_buffer);
-
return true;
}
#endif /* not PS_USE_NONE */
diff --git a/src/backend/utils/misc/sampling.c
b/src/backend/utils/misc/sampling.c
index 3514e740f6a..dae0ae71d76 100644
--- a/src/backend/utils/misc/sampling.c
+++ b/src/backend/utils/misc/sampling.c
@@ -115,81 +115,6 @@ BlockSampler_Next(BlockSampler bs)
return bs->t++;
}
-/*
- * This is a 64 bit version of BlockSampler.
- *
- * The code is same as BlockSampler except replacing
- * int type of variables with int64, which is intended
- * to support larger size of the data set (N).
- *
- * Duplicate code for not willing to break the original
- * design to conflict with upstream for some special case.
- */
-void
-RowSampler_Init(RowSampler rs, int64 nobjects, int64 samplesize,
- long randseed)
-{
- rs->N = nobjects; /* measured table size */
-
- /*
- * If we decide to reduce samplesize for tables that have less or not
much
- * more than samplesize objects, here is the place to do it.
- */
- rs->n = samplesize;
- rs->t = 0; /* objects scanned so
far */
- rs->m = 0; /* objects selected so
far */
-
- sampler_random_init_state(randseed, rs->randstate);
-}
-
-bool
-RowSampler_HasMore(RowSampler rs)
-{
- return (rs->t < rs->N) && (rs->m < rs->n);
-}
-
-int64
-RowSampler_Next(RowSampler rs)
-{
- int64 K = rs->N - rs->t; /* remaining objects */
- int64 k = rs->n - rs->m; /* objects still to sample */
- double p; /* probability to
skip object */
- double V; /* random */
-
- Assert(RowSampler_HasMore(rs)); /* hence K > 0 and k > 0 */
-
- if (k >= K)
- {
- /* need all the rest */
- rs->m++;
- return rs->t++;
- }
-
- /*
- * It is not obvious that this code matches Knuth's Algorithm S.
- * Refer to BlockSampler_Next() for detail.
- */
- V = sampler_random_fract(rs->randstate);
- /*
- * Don't bother overflow of conversion from int64 K (N) as it was
- * already converted to "double" range value when initialized.
- */
- p = 1.0 - (double) k / (double) K;
- while (V < p)
- {
- /* skip */
- rs->t++;
- K--; /* keep K == N - t */
-
- /* adjust p to be new cutoff point in reduced range */
- p *= 1.0 - (double) k / (double) K;
- }
-
- /* select */
- rs->m++;
- return rs->t++;
-}
-
/*
* These two routines embody Algorithm Z from "Random sampling with a
* reservoir" by Jeffrey S. Vitter, in ACM Trans. Math. Softw. 11, 1
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 983f6095bc0..4a9722c1cb5 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -68,6 +68,7 @@ extern PGDLLIMPORT int recoveryTargetAction;
extern PGDLLIMPORT int recovery_min_apply_delay;
extern PGDLLIMPORT char *PrimaryConnInfo;
extern PGDLLIMPORT char *PrimarySlotName;
+extern PGDLLIMPORT char *PromoteTriggerFile;
extern PGDLLIMPORT bool wal_receiver_create_temp_slot;
extern PGDLLIMPORT bool track_wal_io_timing;
extern PGDLLIMPORT int wal_decode_buffer_size;
diff --git a/src/include/catalog/pg_profile.h b/src/include/catalog/pg_profile.h
index b1e9228c6aa..5cae3186596 100644
--- a/src/include/catalog/pg_profile.h
+++ b/src/include/catalog/pg_profile.h
@@ -31,6 +31,7 @@
#ifndef PG_PROFILE_H
#define PG_PROFILE_H
+#include "catalog/objectaddress.h"
#include "catalog/genbki.h"
#include "catalog/pg_profile_d.h"
#include "parser/parse_node.h"
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 88066f8ca99..f697436a919 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -744,7 +744,7 @@ extern void MarkGUCPrefixReserved(const char *className);
/* old name for MarkGUCPrefixReserved, for backwards compatibility: */
#define EmitWarningsOnPlaceholders(className) MarkGUCPrefixReserved(className)
-extern struct config_generic **get_guc_variables(void);
+extern struct config_generic **get_guc_variables(int *num_vars);
extern const char *GetConfigOption(const char *name, bool missing_ok,
bool
restrict_privileged);
extern const char *GetConfigOptionResetString(const char *name);
@@ -753,7 +753,6 @@ extern void ProcessConfigFile(GucContext context);
extern char *convert_GUC_name_for_parameter_acl(const char *name);
extern bool check_GUC_name_for_parameter_acl(const char *name);
extern void InitializeGUCOptions(void);
-extern void InitializeWalConsistencyChecking(void);
extern bool SelectConfigFiles(const char *userDoption, const char *progname);
extern void ResetAllOptions(void);
extern void AtStart_GUC(void);
@@ -787,7 +786,6 @@ extern void SetPGVariableOptDispatch(const char *name, List
*args, bool is_local
extern void GetPGVariable(const char *name, DestReceiver *dest);
extern TupleDesc GetPGVariableResultDesc(const char *name);
-extern void ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel);
extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
extern void ProcessGUCArray(ArrayType *array,
@@ -798,8 +796,6 @@ extern ArrayType *GUCArrayReset(ArrayType *array);
extern void pg_timezone_abbrev_initialize(void);
-extern List *gp_guc_list_show(GucSource excluding, List *guclist);
-
extern struct config_generic *find_option(const char *name,
bool create_placeholders, bool skip_errors, int
elevel);
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index 4a4f4c8f0f9..dda395f6baf 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -18,6 +18,7 @@
#include "lib/ilist.h"
#include "utils/guc.h"
+#include "utils/hsearch.h"
/*
* GUC supports these types of variables:
@@ -98,7 +99,6 @@ enum config_group
STATS_ANALYZE, /*CDB*/
STATS_MONITORING,
- STATS_COLLECTOR,
ENCRYPTION,
STATS_CUMULATIVE,
AUTOVACUUM,
@@ -358,9 +358,6 @@ extern char *ShowGUCOption(struct config_generic *record,
bool use_units);
/* get whether or not the GUC variable is visible to current user */
extern bool ConfigOptionIsVisible(struct config_generic *conf);
-/* get the current set of variables */
-extern int get_num_guc_variables(void);
-
extern void build_guc_variables(void);
/* search in enum options */
@@ -381,7 +378,9 @@ extern struct config_real ConfigureNamesReal_gp[];
extern struct config_string ConfigureNamesString_gp[];
extern struct config_enum ConfigureNamesEnum_gp[];
-extern void gpdb_assign_sync_flag(struct config_generic **guc_variables, int
size, bool predefine);
+extern void gpdb_assign_sync_flag(HTAB *guc_tab);
+extern void gpdb_assign_sync_flag_one(struct config_generic *var, bool
predefine);
+
extern char *config_enum_get_options(struct config_enum *record,
const
char *prefix,
const
char *suffix,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]