39#include "utils/fmgroids.h"
113 opts[
i].isset =
false;
117 opts[
i].boolval =
false;
129 &args, &
types, &nulls);
135 if (nargs == 1 && nulls[0])
141 errmsg(
"variadic arguments must be name/value pairs"),
142 errhint(
"Provide an even number of variadic arguments that can be divided into pairs.")));
148 for (
int i = 0;
i < nargs;
i += 2)
157 errmsg(
"option name at variadic position %d is null",
i + 1)));
164 errmsg(
"value for option \"%s\" must not be null",
name)));
179 errmsg(
"unrecognized option: \"%s\"",
name)));
184 errmsg(
"option \"%s\" is specified more than once",
195 errmsg(
"invalid value for boolean option \"%s\": %s",
215 errmsg(
"invalid value for integer option \"%s\": %s",
286 elog(
ERROR,
"invalid list syntax in setconfig item");
335 errmsg(
"role with OID %u does not exist", roleid)));
357 errdetail(
"Role names starting with \"pg_\" are reserved for system roles.")));
368 roleform->rolsuper ?
"SUPERUSER" :
"NOSUPERUSER");
371 roleform->rolinherit ?
"INHERIT" :
"NOINHERIT");
374 roleform->rolcreaterole ?
"CREATEROLE" :
"NOCREATEROLE");
377 roleform->rolcreatedb ?
"CREATEDB" :
"NOCREATEDB");
380 roleform->rolcanlogin ?
"LOGIN" :
"NOLOGIN");
383 roleform->rolreplication ?
"REPLICATION" :
"NOREPLICATION");
386 roleform->rolbypassrls ?
"BYPASSRLS" :
"NOBYPASSRLS");
416 errmsg(
"timestamp out of range")));
564 memform->admin_option ?
"TRUE" :
"FALSE",
565 memform->inherit_option ?
"TRUE" :
"FALSE",
566 memform->set_option ?
"TRUE" :
"FALSE");
674 errmsg(
"tablespace with OID %u does not exist",
695 errdetail(
"Tablespace names starting with \"pg_\" are reserved for system tablespaces.")));
879 errmsg(
"database with OID %u does not exist", dbid)));
898 errdetail(
"DDL generation is not supported for template0 and template1.")));
927 errmsg(
"unrecognized locale provider: %c",
928 dbform->datlocprovider)));
937 if (collate !=
NULL && ctype !=
NULL &&
strcmp(collate, ctype) == 0)
1000 if (
dbform->datconnlimit != -1)
1009 if (
dbform->datistemplate)
1018 if (!
dbform->datallowconn)
1147 opts[2].isset && !
opts[2].boolval);
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
#define DatumGetArrayTypeP(X)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
char * get_tablespace_name(Oid spc_oid)
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
void EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
void EncodeSpecialTimestamp(Timestamp dt, char *str)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
bool parse_bool(const char *value, bool *result)
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define pg_attribute_printf(f, a)
#define OidIsValid(objectId)
bool IsReservedName(const char *name)
#define TIMESTAMP_NOT_FINITE(j)
Datum pg_get_database_ddl(PG_FUNCTION_ARGS)
static List * pg_get_tablespace_ddl_internal(Oid tsid, bool pretty, bool no_owner)
Datum pg_get_tablespace_ddl_oid(PG_FUNCTION_ARGS)
static List * pg_get_role_ddl_internal(Oid roleid, bool pretty, bool memberships)
static Datum pg_get_tablespace_ddl_srf(FunctionCallInfo fcinfo, Oid tsid, bool isnull)
static List * pg_get_database_ddl_internal(Oid dbid, bool pretty, bool no_owner, bool no_tablespace)
static void parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start, DdlOption *opts, int nopts)
Datum pg_get_tablespace_ddl_name(PG_FUNCTION_ARGS)
static void append_ddl_option(StringInfo buf, bool pretty, int indent, const char *fmt,...) pg_attribute_printf(4
static void static void append_guc_value(StringInfo buf, const char *name, const char *value)
Datum pg_get_role_ddl(PG_FUNCTION_ARGS)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define PG_GETARG_NAME(n)
int extract_variadic_args(FunctionCallInfo fcinfo, int variadic_start, bool convert_unknown, Datum **args, Oid **types, bool **nulls)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
int GetConfigOptionFlags(const char *name, bool missing_ok)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
void list_free(List *list)
void list_free_deep(List *list)
char * get_database_name(Oid dbid)
char * pstrdup(const char *in)
void pfree(void *pointer)
char * GetUserNameFromId(Oid roleid, bool noerr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static AmcheckOptions opts
END_CATALOG_STRUCT typedef FormData_pg_auth_members * Form_pg_auth_members
END_CATALOG_STRUCT typedef FormData_pg_authid * Form_pg_authid
END_CATALOG_STRUCT typedef FormData_pg_database * Form_pg_database
END_CATALOG_STRUCT typedef FormData_pg_db_role_setting * Form_pg_db_role_setting
static int list_length(const List *l)
#define foreach_ptr(type, var, lst)
static void * list_nth(const List *list, int n)
char * get_tablespace_location(Oid tablespaceOid)
END_CATALOG_STRUCT typedef FormData_pg_tablespace * Form_pg_tablespace
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_encoding_to_char
int pg_strcasecmp(const char *s1, const char *s2)
static Datum ObjectIdGetDatum(Oid X)
char * quote_literal_cstr(const char *rawstr)
#define RelationGetDescr(relation)
#define PG_TBLSPC_DIR_SLASH
const char * quote_identifier(const char *ident)
void get_reloptions(StringInfo buf, Datum reloptions)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void enlargeStringInfo(StringInfo str, int needed)
void appendStringInfoSpaces(StringInfo str, int count)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static TimestampTz DatumGetTimestampTz(Datum X)
bool SplitGUCList(char *rawstring, char separator, List **namelist)