/* *check_datestyle:GUCcheck_hookfordatestyle
*/ bool
check_datestyle(char **newval, void **extra, GucSource source)
{ int newDateStyle = DateStyle; int newDateOrder = DateOrder; bool have_style = false; bool have_order = false; bool ok = true; char *rawstring; int *myextra; char *result;
List *elemlist;
ListCell *l;
/* 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); returnfalse;
}
pfree(val); if (interval->month != 0)
{
GUC_check_errdetail("Cannot specify months in time zone interval.");
pfree(interval); returnfalse;
} if (interval->day != 0)
{
GUC_check_errdetail("Cannot specify days in time zone interval.");
pfree(interval); returnfalse;
}
/* Here we change from SQL to Unix sign convention */
gmtoffset = -(interval->time / USECS_PER_SEC);
new_tz = pg_tzset_offset(gmtoffset);
pfree(interval);
} else
{ /* *Tryitasanumericnumberofhours(possiblyfractional).
*/
hours = strtod(*newval, &endptr); if (endptr != *newval && *endptr == '\0')
{ /* Here we change from SQL to Unix sign convention */
gmtoffset = -hours * SECS_PER_HOUR;
new_tz = pg_tzset_offset(gmtoffset);
} else
{ /* *Otherwiseassumeitisatimezonename,andtrytoloadit.
*/
new_tz = pg_tzset(*newval);
if (!new_tz)
{ /* Doesn't seem to be any great value in errdetail here */ returnfalse;
}
if (!pg_tz_acceptable(new_tz))
{
GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
*newval);
GUC_check_errdetail("PostgreSQL does not support leap seconds."); returnfalse;
}
}
}
/* Test for failure in pg_tzset_offset, which we assume is out-of-range */ if (!new_tz)
{
GUC_check_errdetail("UTC timezone offset is out of range."); returnfalse;
}
if (!new_tz)
{ /* Doesn't seem to be any great value in errdetail here */ returnfalse;
}
if (!pg_tz_acceptable(new_tz))
{
GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
*newval);
GUC_check_errdetail("PostgreSQL does not support leap seconds."); returnfalse;
}
/* OK, load the file and produce a guc_malloc'd TimeZoneAbbrevTable */
*extra = load_tzoffsets(*newval);
/* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */ if (!*extra) returnfalse;
returntrue;
}
/* *GUCassign_hookfortimezone_abbreviations
*/ void
assign_timezone_abbreviations(constchar *newval, void *extra)
{ /* Do nothing for the boot_val default of NULL */ if (!extra) return;
/* *SETTRANSACTIONREADONLYandSETTRANSACTIONREADWRITE * *Weallowidempotentchanges(r/w->r/wandr/o->r/o)atanytime,and *wealsoalwaysallowchangesfromread-writetoread-only.However, *read-onlymaybechangedtoread-writeonlywheninatop-leveltransaction *thathasnotyettakenaninitialsnapshot.Can'tdoitinahotstandby, *either. * *Ifwearenotinatransactionatall,justallowthechange;itmeans *nothingsinceXactReadOnlywillberesetbythenextStartTransaction(). *TheIsTransactionState()testprotectsusagainsttryingtocheck *RecoveryInProgress()incontextswheresharedmemoryisnotaccessible. *(Similarly,ifwe'rerestoringstateinaparallelworker,justallow *thechange.)
*/ bool
check_transaction_read_only(bool *newval, void **extra, GucSource source)
{ if (*newval == false && XactReadOnly && IsTransactionState() && !InitializingParallelWorker)
{ /* Can't go to r/w mode inside a r/o transaction */ if (IsSubTransaction())
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("cannot set transaction read-write mode inside a read-only transaction"); returnfalse;
} /* Top level transaction can't change to r/w after first snapshot. */ if (FirstSnapshotSet)
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("transaction read-write mode must be set before any query"); returnfalse;
} /* Can't go to r/w mode while recovery is still active */ if (RecoveryInProgress())
{
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errmsg("cannot set transaction read-write mode during recovery"); returnfalse;
}
}
if (newXactIsoLevel != XactIsoLevel &&
IsTransactionState() && !InitializingParallelWorker)
{ if (FirstSnapshotSet)
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query"); returnfalse;
} /* We ignore a subtransaction setting it to the existing value. */ if (IsSubTransaction())
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction"); returnfalse;
} /* Can't go to serializable mode while recovery is still active */ if (newXactIsoLevel == XACT_SERIALIZABLE && RecoveryInProgress())
{
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errmsg("cannot use serializable mode in a hot standby");
GUC_check_errhint("You can use REPEATABLE READ instead."); returnfalse;
}
}
returntrue;
}
/* *SETTRANSACTION[NOT]DEFERRABLE
*/
bool
check_transaction_deferrable(bool *newval, void **extra, GucSource source)
{ /* Just accept the value when restoring state in a parallel worker */ if (InitializingParallelWorker) returntrue;
if (IsSubTransaction())
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("SET TRANSACTION [NOT] DEFERRABLE cannot be called within a subtransaction"); returnfalse;
} if (FirstSnapshotSet)
{
GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
GUC_check_errmsg("SET TRANSACTION [NOT] DEFERRABLE must be called before any query"); returnfalse;
}
bool
check_random_seed(double *newval, void **extra, GucSource source)
{
*extra = guc_malloc(LOG, sizeof(int)); if (!*extra) returnfalse; /* Arm the assign only if source of value is an interactive SET */
*((int *) *extra) = (source >= PGC_S_INTERACTIVE);
returntrue;
}
void
assign_random_seed(double newval, void *extra)
{ /* We'll do this at most once for any setting of the GUC variable */ if (*((int *) extra))
DirectFunctionCall1(setseed, Float8GetDatum(newval));
*((int *) extra) = 0;
}
/* *Inaparallelworker,weneveroverridetheclientencodingthatwas *setbyParallelWorkerMain().
*/ if (IsParallelWorker()) return;
/* We do not expect an error if PrepareClientEncoding succeeded */ if (SetClientEncoding(encoding) < 0)
elog(LOG, "SetClientEncoding(%d) failed", encoding);
}
/* *SETSESSIONAUTHORIZATION
*/
typedefstruct
{ /* This is the "extra" state for both SESSION AUTHORIZATION and ROLE */
Oid roleid; bool is_superuser;
} role_auth_extra;
/* Look up the username */
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(*newval)); if (!HeapTupleIsValid(roleTup))
{ if (source == PGC_S_TEST)
{
ereport(NOTICE,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("role \"%s\" does not exist", *newval))); returntrue;
}
GUC_check_errmsg("role \"%s\" does not exist", *newval); returnfalse;
}
/* *OnlysuperusersmaySETSESSIONAUTHORIZATIONaroleotherthan *itself.NotethatincaseofmultipleSETsinasinglesession,the *originalauthenticateduser'ssuperusernessiswhatmatters.
*/ if (roleid != GetAuthenticatedUserId() &&
!superuser_arg(GetAuthenticatedUserId()))
{ if (source == PGC_S_TEST)
{
ereport(NOTICE,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission will be denied to set session authorization \"%s\"",
*newval))); returntrue;
}
GUC_check_errcode(ERRCODE_INSUFFICIENT_PRIVILEGE);
GUC_check_errmsg("permission denied to set session authorization \"%s\"",
*newval); returnfalse;
}
}
/* Set up "extra" struct for assign_session_authorization to use */
myextra = (role_auth_extra *) guc_malloc(LOG, sizeof(role_auth_extra)); if (!myextra) returnfalse;
myextra->roleid = roleid;
myextra->is_superuser = is_superuser;
*extra = myextra;
/* Look up the username */
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(*newval)); if (!HeapTupleIsValid(roleTup))
{ if (source == PGC_S_TEST)
{
ereport(NOTICE,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("role \"%s\" does not exist", *newval))); returntrue;
}
GUC_check_errmsg("role \"%s\" does not exist", *newval); returnfalse;
}
/* Verify that session user is allowed to become this role */ if (!member_can_set_role(GetSessionUserId(), roleid))
{ if (source == PGC_S_TEST)
{
ereport(NOTICE,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission will be denied to set role \"%s\"",
*newval))); returntrue;
}
GUC_check_errcode(ERRCODE_INSUFFICIENT_PRIVILEGE);
GUC_check_errmsg("permission denied to set role \"%s\"",
*newval); returnfalse;
}
}
/* Set up "extra" struct for assign_role to use */
myextra = (role_auth_extra *) guc_malloc(LOG, sizeof(role_auth_extra)); if (!myextra) returnfalse;
myextra->roleid = roleid;
myextra->is_superuser = is_superuser;
*extra = myextra;
bool
check_bonjour(bool *newval, void **extra, GucSource source)
{ #ifndef USE_BONJOUR if (*newval)
{
GUC_check_errmsg("Bonjour is not supported by this build"); returnfalse;
} #endif returntrue;
}
bool
check_default_with_oids(bool *newval, void **extra, GucSource source)
{ if (*newval)
{ /* check the GUC's definition for an explanation */
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errmsg("tables declared WITH OIDS are not supported");
returnfalse;
}
returntrue;
}
bool
check_ssl(bool *newval, void **extra, GucSource source)
{ #ifndef USE_SSL if (*newval)
{
GUC_check_errmsg("SSL is not supported by this build"); returnfalse;
} #endif returntrue;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet am 2026-08-08)
¤
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.