MCPcopy Create free account
hub / github.com/apache/cloudberry / AlterSystemSetConfigFile

Function AlterSystemSetConfigFile

src/backend/utils/misc/guc.c:8842–9047  ·  view source on GitHub ↗

* Execute ALTER SYSTEM statement. * * Read the old PG_AUTOCONF_FILENAME file, merge in the new variable value, * and write out an updated file. If the command is ALTER SYSTEM RESET ALL, * we can skip reading the old file and just write an empty file. * * An LWLock is used to serialize updates of the configuration file. * * In case of an error, we leave the original automatic * configurat

Source from the content-addressed store, hash-verified

8840 * configuration file (PG_AUTOCONF_FILENAME) intact.
8841 */
8842void
8843AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
8844{
8845 char *name;
8846 char *value;
8847 bool resetall = false;
8848 ConfigVariable *head = NULL;
8849 ConfigVariable *tail = NULL;
8850 volatile int Tmpfd;
8851 char AutoConfFileName[MAXPGPATH];
8852 char AutoConfTmpFileName[MAXPGPATH];
8853
8854 if (!am_ftshandler && !superuser())
8855 ereport(ERROR,
8856 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8857 errmsg("must be superuser to execute ALTER SYSTEM command")));
8858
8859 /*
8860 * Extract statement arguments
8861 */
8862 name = altersysstmt->setstmt->name;
8863
8864 switch (altersysstmt->setstmt->kind)
8865 {
8866 case VAR_SET_VALUE:
8867 value = ExtractSetVariableArgs(altersysstmt->setstmt);
8868 break;
8869
8870 case VAR_SET_DEFAULT:
8871 case VAR_RESET:
8872 value = NULL;
8873 break;
8874
8875 case VAR_RESET_ALL:
8876 value = NULL;
8877 resetall = true;
8878 break;
8879
8880 default:
8881 elog(ERROR, "unrecognized alter system stmt type: %d",
8882 altersysstmt->setstmt->kind);
8883 break;
8884 }
8885
8886 /*
8887 * Unless it's RESET_ALL, validate the target variable and value
8888 */
8889 if (!resetall)
8890 {
8891 struct config_generic *record;
8892
8893 record = find_option(name, false, false, ERROR);
8894 Assert(record != NULL);
8895
8896 /*
8897 * Don't allow parameters that can't be set in configuration files to
8898 * be set in PG_AUTOCONF_FILENAME file.
8899 */

Callers 2

standard_ProcessUtilityFunction · 0.85

Calls 15

superuserFunction · 0.85
ExtractSetVariableArgsFunction · 0.85
find_optionFunction · 0.85
parse_and_validate_valueFunction · 0.85
LWLockAcquireFunction · 0.85
AllocateFileFunction · 0.85
FreeFileFunction · 0.85
BasicOpenFileFunction · 0.85
write_auto_conf_fileFunction · 0.85
LWLockReleaseFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected