/* *Workerssynchronizetheseparametersatthestartoftheparallel *operation;then,weblockSETduringtheoperation.
*/ if (IsInParallelMode())
ereport(ERROR,
(errcode(ERRCODE_INVALID_TRANSACTION_STATE),
errmsg("cannot set parameters during a parallel operation")));
switch (stmt->kind)
{ case VAR_SET_VALUE: case VAR_SET_CURRENT: if (stmt->is_local)
WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
(void) set_config_option(stmt->name,
ExtractSetVariableArgs(stmt),
(superuser() ? PGC_SUSET : PGC_USERSET),
PGC_S_SESSION,
action, true, 0, false); break; case VAR_SET_MULTI:
if (stmt->is_local)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
ImportSnapshot(strVal(&con->val));
} else
elog(ERROR, "unexpected SET MULTI element: %s",
stmt->name); break; case VAR_SET_DEFAULT: if (stmt->is_local)
WarnNoTransactionBlock(isTopLevel, "SET LOCAL"); /* fall through */ case VAR_RESET:
(void) set_config_option(stmt->name,
NULL,
(superuser() ? PGC_SUSET : PGC_USERSET),
PGC_S_SESSION,
action, true, 0, false); break; case VAR_RESET_ALL:
ResetAllOptions(); break;
}
/* Invoke the post-alter hook for setting this GUC variable, by name. */
InvokeObjectPostAlterHookArgStr(ParameterAclRelationId, stmt->name,
ACL_SET, stmt->kind, false);
}
/* Fast path if just DEFAULT */ if (args == NIL) return NULL;
/* *Getflagsforthevariable;ifit'snotknown,usedefaultflags. *(Callermightthrowerrorlater,butnotourbusinesstodosohere.)
*/
record = find_option(name, false, true, 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)));
if (l != list_head(args))
appendStringInfoString(&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, "%d", intVal(&con->val)); break; case T_Float: /* represented as a string, so just copy it */
appendStringInfoString(&buf, castNode(Float, &con->val)->fval); break; case T_String:
val = strVal(&con->val); if (typeName != NULL)
{ /* *MustbeaConstIntervalargumentforTIMEZONE.Coerce *tointervalandbacktonormalizethevalueandaccount *foranytypmod.
*/
Oid typoid;
int32 typmod;
Datum interval; char *intervalout;
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));
if (guc_name_compare(name, "all") == 0)
{ /* need a tuple descriptor representing three TEXT columns */
tupdesc = CreateTemplateTupleDesc(3);
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
{ constchar *varname;
/* Get the canonical spelling of name */
(void) GetConfigOptionByName(name, &varname, false);
/* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
TEXTOID, -1, 0);
} return tupdesc;
}
/* Get the value and canonical spelling of name */
value = GetConfigOptionByName(name, &varname, false);
/* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, varname,
TEXTOID, -1, 0);
/* prepare for projection of tuples */
tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
/* Send it */
do_text_output_oneline(tstate, value);
/* send it to dest */
do_tup_output(tstate, values, isnull);
/* clean up */
pfree(DatumGetPointer(values[0])); if (setting)
{
pfree(setting);
pfree(DatumGetPointer(values[1]));
} if (conf->short_desc)
pfree(DatumGetPointer(values[2]));
}
end_tup_output(tstate);
}
/* *ReturnsomeoftheflagsassociatedtothespecifiedGUCintheshapeof *atextarray,andNULLifitdoesnotexist.Anemptyarrayisreturned *iftheGUCexistswithoutanymeaningfulflagstoshow.
*/
Datum
pg_settings_get_flags(PG_FUNCTION_ARGS)
{ #define MAX_GUC_FLAGS 6 char *varname = TextDatumGetCString(PG_GETARG_DATUM(0)); struct config_generic *record; int cnt = 0;
Datum flags[MAX_GUC_FLAGS];
ArrayType *a;
record = find_option(varname, false, true, ERROR);
/* return NULL if no such variable */ if (record == NULL)
PG_RETURN_NULL();
if (record->flags & GUC_EXPLAIN)
flags[cnt++] = CStringGetTextDatum("EXPLAIN"); if (record->flags & GUC_NO_RESET)
flags[cnt++] = CStringGetTextDatum("NO_RESET"); if (record->flags & GUC_NO_RESET_ALL)
flags[cnt++] = CStringGetTextDatum("NO_RESET_ALL"); if (record->flags & GUC_NO_SHOW_ALL)
flags[cnt++] = CStringGetTextDatum("NO_SHOW_ALL"); if (record->flags & GUC_NOT_IN_SAMPLE)
flags[cnt++] = CStringGetTextDatum("NOT_IN_SAMPLE"); if (record->flags & GUC_RUNTIME_COMPUTED)
flags[cnt++] = CStringGetTextDatum("RUNTIME_COMPUTED");
Assert(cnt <= MAX_GUC_FLAGS);
/* Returns the record as Datum */
a = construct_array_builtin(flags, cnt, TEXTOID);
PG_RETURN_ARRAYTYPE_P(a);
}
Datum
show_all_settings(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx; struct config_generic **guc_vars; int num_vars;
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();
while (call_cntr < max_calls) /* do when there is more left to send */
{ struct config_generic *conf = guc_vars[call_cntr]; char *values[NUM_PG_SETTINGS_ATTS];
HeapTuple tuple;
Datum result;
/* skip if marked NO_SHOW_ALL or if not visible to current user */ if ((conf->flags & GUC_NO_SHOW_ALL) ||
!ConfigOptionIsVisible(conf))
{
call_cntr = ++funcctx->call_cntr; continue;
}
/* extract values for the current variable */
GetConfigOptionValues(conf, (constchar **) values);
/* build a tuple */
tuple = BuildTupleFromCStrings(attinmeta, values);
/* make the tuple into a datum */
result = HeapTupleGetDatum(tuple);
SRF_RETURN_NEXT(funcctx, result);
}
/* do when there is no more left */
SRF_RETURN_DONE(funcctx);
}
/* Scan the config files using current context as workspace */
conf = ProcessConfigFileInternal(PGC_SIGHUP, false, DEBUG3);
/* Build a tuplestore to return our results in */
InitMaterializedSRF(fcinfo, 0);
/* Process the results and create a tuplestore */ for (seqno = 1; conf != NULL; conf = conf->next, seqno++)
{
Datum values[NUM_PG_FILE_SETTINGS_ATTS]; bool nulls[NUM_PG_FILE_SETTINGS_ATTS];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.