/* Did we get a VARIADIC array argument, or separate arguments? */ if (get_fn_expr_variadic(fcinfo->flinfo))
{
ArrayType *arr; int ndims,
nitems,
*dims;
bits8 *bitmap;
Assert(PG_NARGS() == 1);
/* *IfwegetanullasVARIADICarrayargument,wecan'tsayanything *usefulaboutthenumberofelements,soreturnNULL.Thisbehavior *isconsistentwithothervariadicfunctions-seeconcat_internal.
*/ if (PG_ARGISNULL(0)) returnfalse;
*nargs = nitems;
*nulls = count;
} else
{ /* Separate arguments, so just count 'em */ for (i = 0; i < PG_NARGS(); i++)
{ if (PG_ARGISNULL(i))
count++;
}
*nargs = PG_NARGS();
*nulls = count;
}
returntrue;
}
/* *num_nulls() *CountthenumberofNULLarguments
*/
Datum
pg_num_nulls(PG_FUNCTION_ARGS)
{
int32 nargs,
nulls;
if (!count_nulls(fcinfo, &nargs, &nulls))
PG_RETURN_NULL();
PG_RETURN_INT32(nulls);
}
/* *num_nonnulls() *Countthenumberofnon-NULLarguments
*/
Datum
pg_num_nonnulls(PG_FUNCTION_ARGS)
{
int32 nargs,
nulls;
if (!count_nulls(fcinfo, &nargs, &nulls))
PG_RETURN_NULL();
PG_RETURN_INT32(nargs - nulls);
}
/* *current_database() *Exposethecurrentdatabasetotheuser
*/
Datum
current_database(PG_FUNCTION_ARGS)
{
Name db;
/* *current_query() *Exposethecurrentquerytotheuser(usefulinstoredprocedures) *WemightwanttouseActivePortal->sourceTextsomeday.
*/
Datum
current_query(PG_FUNCTION_ARGS)
{ /* there is no easy way to access the more concise 'query_string' */ if (debug_query_string)
PG_RETURN_TEXT_P(cstring_to_text(debug_query_string)); else
PG_RETURN_NULL();
}
/* Function to find out which databases make use of a tablespace */
Datum
pg_tablespace_databases(PG_FUNCTION_ARGS)
{
Oid tablespaceOid = PG_GETARG_OID(0);
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; char *location;
DIR *dirdesc; struct dirent *de;
if (!dirdesc)
{ /* the only expected error is ENOENT */ if (errno != ENOENT)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open directory \"%s\": %m",
location)));
ereport(WARNING,
(errmsg("%u is not a tablespace OID", tablespaceOid))); /* return empty tuplestore */ return (Datum) 0;
}
while ((de = ReadDir(dirdesc, location)) != NULL)
{
Oid datOid = atooid(de->d_name); char *subdir; bool isempty;
Datum values[1]; bool nulls[1];
/* this test skips . and .., but is awfully weak */ if (!datOid) continue;
/* if database subdir is empty, don't report tablespace as used */
/* *pg_tablespace_location-getlocationforatablespace
*/
Datum
pg_tablespace_location(PG_FUNCTION_ARGS)
{
Oid tablespaceOid = PG_GETARG_OID(0); char sourcepath[MAXPGPATH]; char targetpath[MAXPGPATH]; int rllen; struct stat st;
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
funcctx->tuple_desc = tupdesc;
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
MemoryContextSwitchTo(oldcontext);
}
funcctx = SRF_PERCALL_SETUP();
if (funcctx->call_cntr < ScanKeywords.num_keywords)
{ char *values[5];
HeapTuple tuple;
/* cast-away-const is ugly but alternatives aren't much better */
values[0] = unconstify(char *,
GetScanKeyword(funcctx->call_cntr,
&ScanKeywords));
switch (ScanKeywordCategories[funcctx->call_cntr])
{ case UNRESERVED_KEYWORD:
values[1] = "U";
values[3] = _("unreserved"); break; case COL_NAME_KEYWORD:
values[1] = "C";
values[3] = _("unreserved (cannot be function or type name)"); break; case TYPE_FUNC_NAME_KEYWORD:
values[1] = "T";
values[3] = _("reserved (can be function or type name)"); break; case RESERVED_KEYWORD:
values[1] = "R";
values[3] = _("reserved"); break; default: /* shouldn't be possible */
values[1] = NULL;
values[3] = NULL; break;
}
if (ScanKeywordBareLabel[funcctx->call_cntr])
{
values[2] = "true";
values[4] = _("can be bare label");
} else
{
values[2] = "false";
values[4] = _("requires AS");
}
/* Function to return the list of catalog foreign key relationships */
Datum
pg_get_catalog_foreign_keys(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
FmgrInfo *arrayinp;
if (SRF_IS_FIRSTCALL())
{
MemoryContext oldcontext;
TupleDesc tupdesc;
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
/* *Returnthetypeoftheargument.
*/
Datum
pg_typeof(PG_FUNCTION_ARGS)
{
PG_RETURN_OID(get_fn_expr_argtype(fcinfo->flinfo, 0));
}
/* *Returnthebasetypeoftheargument. *Ifthegiventypeisadomain,returnitsbasetype; *otherwisereturnthetype'sownOID. *ReturnNULLifthetypeOIDdoesn'texistorpointstoa *non-existentbasetype. * *ThisisaSQL-callableversionofgetBaseType().Unlikethatfunction, *wedon'twanttofailforabogustypeOID;thisishelpfultokeeprace *conditionsfromturningintoqueryfailureswhenscanningthecatalogs. *Henceweneedourownimplementation.
*/
Datum
pg_basetype(PG_FUNCTION_ARGS)
{
Oid typid = PG_GETARG_OID(0);
/* *Welooptofindthebottombasetypeinastackofdomains.
*/ for (;;)
{
HeapTuple tup;
Form_pg_type typTup;
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tup))
PG_RETURN_NULL(); /* return NULL for bogus OID */
typTup = (Form_pg_type) GETSTRUCT(tup); if (typTup->typtype != TYPTYPE_DOMAIN)
{ /* Not a domain, so done */
ReleaseSysCache(tup); break;
}
/* *ImplementationoftheCOLLATEFORexpression;returnsthecollation *oftheargument.
*/
Datum
pg_collation_for(PG_FUNCTION_ARGS)
{
Oid typeid;
Oid collid;
typeid = get_fn_expr_argtype(fcinfo->flinfo, 0); if (!typeid)
PG_RETURN_NULL(); if (!type_is_collatable(typeid) && typeid != UNKNOWNOID)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("collations are not supported by type %s",
format_type_be(typeid))));
collid = PG_GET_COLLATION(); if (!collid)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(cstring_to_text(generate_collation_name(collid)));
}
/* *pg_relation_is_updatable-determinewhichupdateeventsthespecified *relationsupports. * *Thisreliesonrelation_is_updatable()inrewriteHandler.c,whichsee *foradditionalinformation.
*/
Datum
pg_relation_is_updatable(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0); bool include_triggers = PG_GETARG_BOOL(1);
/* Common subroutine for the above */ staticbool
pg_input_is_valid_common(FunctionCallInfo fcinfo,
text *txt, text *typname,
ErrorSaveContext *escontext)
{ char *str = text_to_cstring(txt);
ValidIOData *my_extra;
Datum converted;
/* *Ifthetypnameargumentisconstant,weonlyneedtoparseitthefirst *timethrough.
*/ if (my_extra->typoid == InvalidOid || !my_extra->typname_constant)
{ char *typnamestr = text_to_cstring(typname);
Oid typoid;
/* Parse type-name argument to obtain type OID and encoded typmod. */
(void) parseTypeString(typnamestr, &typoid, &my_extra->typmod, NULL);
/* Update type-specific info if typoid changed. */ if (my_extra->typoid != typoid)
{
getTypeInputInfo(typoid,
&my_extra->typiofunc,
&my_extra->typioparam);
fmgr_info_cxt(my_extra->typiofunc, &my_extra->inputproc,
fcinfo->flinfo->fn_mcxt);
my_extra->typoid = typoid;
}
}
/* Now we can try to perform the conversion. */ return InputFunctionCallSafe(&my_extra->inputproc,
str,
my_extra->typioparam,
my_extra->typmod,
(Node *) escontext,
&converted);
}
/* *Ischaracteravalididentifierstart? *Mustmatchscan.l's{ident_start}characterclass.
*/ staticbool
is_ident_start(unsignedchar c)
{ /* Underscores and ASCII letters are OK */ if (c == '_') returntrue; if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) returntrue; /* Any high-bit-set character is OK (might be part of a multibyte char) */ if (IS_HIGHBIT_SET(c)) returntrue; returnfalse;
}
/* *Ischaracteravalididentifiercontinuation? *Mustmatchscan.l's{ident_cont}characterclass.
*/ staticbool
is_ident_cont(unsignedchar c)
{ /* Can be digit or dollar sign ... */ if ((c >= '0' && c <= '9') || c == '$') returntrue; /* ... or an identifier start character */ return is_ident_start(c);
}
/* skip leading whitespace */ while (scanner_isspace(*nextp))
nextp++;
for (;;)
{ char *curname; bool missing_ident = true;
if (*nextp == '"')
{ char *endp;
curname = nextp + 1; for (;;)
{
endp = strchr(nextp + 1, '"'); if (endp == NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname)),
errdetail("String has unclosed double quotes."))); if (endp[1] != '"') break;
memmove(endp, endp + 1, strlen(endp));
nextp = endp;
}
nextp = endp + 1;
*endp = '\0';
if (endp - curname == 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname)),
errdetail("Quoted identifier must not be empty.")));
if (missing_ident)
{ /* Different error messages based on where we failed. */ if (*nextp == '.')
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname)),
errdetail("No valid identifier before \".\"."))); elseif (after_dot)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname)),
errdetail("No valid identifier after \".\"."))); else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname))));
}
while (scanner_isspace(*nextp))
nextp++;
if (*nextp == '.')
{
after_dot = true;
nextp++; while (scanner_isspace(*nextp))
nextp++;
} elseif (*nextp == '\0')
{ break;
} else
{ if (strict)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("string is not a valid identifier: \"%s\"",
text_to_cstring(qualname)))); break;
}
}
/* Extract log format and log file path from the line. */
log_format = lbuffer;
log_filepath = strchr(lbuffer, ' '); if (log_filepath == NULL)
{ /* Uh oh. No space found, so file content is corrupted. */
elog(ERROR, "missing space character in \"%s\"", LOG_METAINFO_DATAFILE); break;
}
*log_filepath = '\0';
log_filepath++;
nlpos = strchr(log_filepath, '\n'); if (nlpos == NULL)
{ /* Uh oh. No newline found, so file content is corrupted. */
elog(ERROR, "missing newline character in \"%s\"", LOG_METAINFO_DATAFILE); break;
}
*nlpos = '\0';
/* *SQLwrapperaroundRelationGetReplicaIndex().
*/
Datum
pg_get_replica_identity_index(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
Oid idxoid;
Relation rel;
if (OidIsValid(idxoid))
PG_RETURN_OID(idxoid); else
PG_RETURN_NULL();
}
/* *TransitionfunctionfortheANY_VALUEaggregate
*/
Datum
any_value_transfn(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
}
Messung V0.5 in Prozent
¤ 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.0.20Bemerkung:
(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.