28#include "catalog/system_fk_info.h"
44#include "utils/fmgroids.h"
126 if ((*bitmap & bitmask) == 0)
130 if (bitmask == 0x100)
234 if (tablespaceOid == GLOBALTABLESPACE_OID)
237 (
errmsg(
"global tablespace never has databases")));
242 if (tablespaceOid == DEFAULTTABLESPACE_OID)
256 errmsg(
"could not open directory \"%s\": %m",
259 (
errmsg(
"%u is not a tablespace OID", tablespaceOid)));
264 while ((de =
ReadDir(dirdesc, location)) != NULL)
278 subdir =
psprintf(
"%s/%s", location, de->d_name);
320 if (tablespaceOid == DEFAULTTABLESPACE_OID ||
321 tablespaceOid == GLOBALTABLESPACE_OID)
336 if (
lstat(sourcepath, &st) < 0)
340 errmsg(
"could not stat file \"%s\": %m",
350 rllen =
readlink(sourcepath, targetpath,
sizeof(targetpath));
354 errmsg(
"could not read symbolic link \"%s\": %m",
356 if (rllen >=
sizeof(targetpath))
358 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
359 errmsg(
"symbolic link \"%s\" target is too long",
361 targetpath[rllen] =
'\0';
387#define GetNowFloat() ((float8) GetCurrentTimestamp() / 1000000.0)
401 else if (delay > 0.0)
402 delay_ms = (long) ceil(delay * 1000.0);
409 WAIT_EVENT_PG_SLEEP);
431 elog(
ERROR,
"return type must be a row type");
458 values[3] =
_(
"unreserved (cannot be function or type name)");
462 values[3] =
_(
"reserved (can be function or type name)");
477 values[4] =
_(
"can be bare label");
510 elog(
ERROR,
"return type must be a row type");
531 const SysFKRelationship *fkrel = &sys_fk_relationships[funcctx->
call_cntr];
536 memset(nulls,
false,
sizeof(nulls));
599 if (typTup->typtype != TYPTYPE_DOMAIN)
606 typid = typTup->typbasetype;
629 (
errcode(ERRCODE_DATATYPE_MISMATCH),
630 errmsg(
"collations are not supported by type %s",
681#define REQ_EVENTS ((1 << CMD_UPDATE) | (1 << CMD_DELETE))
726 elog(
ERROR,
"return type must be a row type");
733 memset(isnull,
true,
sizeof(isnull));
742 memset(isnull,
false,
sizeof(isnull));
778 if (my_extra == NULL)
802 if (my_extra->
typoid != typoid)
809 my_extra->
typoid = typoid;
833 if ((
c >=
'a' &&
c <=
'z') || (
c >=
'A' &&
c <=
'Z'))
849 if ((
c >=
'0' &&
c <=
'9') ||
c ==
'$')
868 bool after_dot =
false;
875 nextp = qualname_str;
884 bool missing_ident =
true;
893 endp = strchr(nextp + 1,
'"');
896 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
897 errmsg(
"string is not a valid identifier: \"%s\"",
899 errdetail(
"String has unclosed double quotes.")));
902 memmove(endp, endp + 1, strlen(endp));
908 if (endp - curname == 0)
910 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
911 errmsg(
"string is not a valid identifier: \"%s\"",
913 errdetail(
"Quoted identifier must not be empty.")));
917 missing_ident =
false;
929 len = nextp - curname;
941 missing_ident =
false;
949 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
950 errmsg(
"string is not a valid identifier: \"%s\"",
952 errdetail(
"No valid identifier before \".\".")));
955 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
956 errmsg(
"string is not a valid identifier: \"%s\"",
958 errdetail(
"No valid identifier after \".\".")));
961 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
962 errmsg(
"string is not a valid identifier: \"%s\"",
976 else if (*nextp ==
'\0')
984 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
985 errmsg(
"string is not a valid identifier: \"%s\"",
1013 if (strcmp(logfmt,
"stderr") != 0 &&
1014 strcmp(logfmt,
"csvlog") != 0 &&
1015 strcmp(logfmt,
"jsonlog") != 0)
1017 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1018 errmsg(
"log format \"%s\" is not supported", logfmt),
1019 errhint(
"The supported log formats are \"stderr\", \"csvlog\", and \"jsonlog\".")));
1025 if (errno != ENOENT)
1028 errmsg(
"could not read file \"%s\": %m",
1035 _setmode(_fileno(
fd), _O_TEXT);
1042 while (fgets(lbuffer,
sizeof(lbuffer),
fd) != NULL)
1049 log_format = lbuffer;
1050 log_filepath = strchr(lbuffer,
' ');
1051 if (log_filepath == NULL)
1059 *log_filepath =
'\0';
1061 nlpos = strchr(log_filepath,
'\n');
1071 if (logfmt == NULL || strcmp(logfmt, log_format) == 0)
#define PG_GETARG_ARRAYTYPE_P(n)
#define ARR_NULLBITMAP(a)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
int ArrayGetNItems(int ndim, const int *dims)
bool directory_is_empty(const char *path)
Datum pg_typeof(PG_FUNCTION_ARGS)
struct ValidIOData ValidIOData
Datum parse_ident(PG_FUNCTION_ARGS)
static bool count_nulls(FunctionCallInfo fcinfo, int32 *nargs, int32 *nulls)
Datum pg_tablespace_databases(PG_FUNCTION_ARGS)
static bool is_ident_cont(unsigned char c)
Datum current_query(PG_FUNCTION_ARGS)
Datum pg_get_catalog_foreign_keys(PG_FUNCTION_ARGS)
static bool pg_input_is_valid_common(FunctionCallInfo fcinfo, text *txt, text *typname, ErrorSaveContext *escontext)
Datum pg_input_error_info(PG_FUNCTION_ARGS)
Datum pg_input_is_valid(PG_FUNCTION_ARGS)
Datum any_value_transfn(PG_FUNCTION_ARGS)
Datum pg_sleep(PG_FUNCTION_ARGS)
Datum pg_get_replica_identity_index(PG_FUNCTION_ARGS)
Datum pg_current_logfile(PG_FUNCTION_ARGS)
Datum pg_get_keywords(PG_FUNCTION_ARGS)
static bool is_ident_start(unsigned char c)
Datum current_database(PG_FUNCTION_ARGS)
Datum pg_column_is_updatable(PG_FUNCTION_ARGS)
Datum pg_num_nulls(PG_FUNCTION_ARGS)
Datum pg_basetype(PG_FUNCTION_ARGS)
Datum pg_current_logfile_1arg(PG_FUNCTION_ARGS)
Datum pg_tablespace_location(PG_FUNCTION_ARGS)
Datum pg_relation_is_updatable(PG_FUNCTION_ARGS)
Datum pg_collation_for(PG_FUNCTION_ARGS)
Datum pg_num_nonnulls(PG_FUNCTION_ARGS)
Bitmapset * bms_make_singleton(int x)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define unconstify(underlying_type, expr)
#define IS_HIGHBIT_SET(ch)
#define Assert(condition)
#define OidIsValid(objectId)
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
const bool ScanKeywordBareLabel[SCANKEYWORDS_NUM_KEYWORDS]
char * get_database_name(Oid dbid)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
char * unpack_sql_state(int sql_state)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
DIR * AllocateDir(const char *dirname)
struct dirent * ReadDir(DIR *dir, const char *dirname)
FILE * AllocateFile(const char *name, const char *mode)
bool get_fn_expr_arg_stable(FmgrInfo *flinfo, int argnum)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod, fmNodePtr escontext, Datum *result)
bool get_fn_expr_variadic(FmgrInfo *flinfo)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_FLOAT8(n)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_RETURN_NAME(x)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define PG_GET_COLLATION()
#define FunctionCall3(flinfo, arg1, arg2, arg3)
#define PG_RETURN_BOOL(x)
#define PG_GETARG_INT16(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define SRF_RETURN_DONE(_funcctx)
#define MAT_SRF_USE_EXPECTED_DESC
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define HeapTupleIsValid(tuple)
if(TABLE==NULL||TABLE_index==NULL)
PGDLLIMPORT const ScanKeywordList ScanKeywords
#define UNRESERVED_KEYWORD
#define TYPE_FUNC_NAME_KEYWORD
static const char * GetScanKeyword(int n, const ScanKeywordList *keywords)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_EXIT_ON_PM_DEATH
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
bool type_is_collatable(Oid typid)
Oid get_base_element_type(Oid typid)
void * MemoryContextAlloc(MemoryContext context, Size size)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
void namestrcpy(Name name, const char *str)
bool parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, Node *escontext)
FormData_pg_type * Form_pg_type
const char * debug_query_string
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int fd(const char *x, int i)
char * psprintf(const char *fmt,...)
MemoryContextSwitchTo(old_ctx)
Oid RelationGetReplicaIndex(Relation relation)
#define TABLESPACE_VERSION_DIRECTORY
int relation_is_updatable(Oid reloid, List *outer_reloids, bool include_triggers, Bitmapset *include_cols)
char * generate_collation_name(Oid collid)
char * downcase_identifier(const char *ident, int len, bool warn, bool truncate)
bool scanner_isspace(char ch)
AttInMetadata * attinmeta
MemoryContext multi_call_memory_ctx
Tuplestorestate * setResult
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define LOG_METAINFO_DATAFILE
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
#define readlink(path, buf, size)