29 #include "catalog/system_fk_info.h"
45 #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)
245 location =
psprintf(
"pg_tblspc/%u/%s", tablespaceOid,
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)
328 snprintf(sourcepath,
sizeof(sourcepath),
"pg_tblspc/%u", tablespaceOid);
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));
585 (
errcode(ERRCODE_DATATYPE_MISMATCH),
586 errmsg(
"collations are not supported by type %s",
637 #define REQ_EVENTS ((1 << CMD_UPDATE) | (1 << CMD_DELETE))
682 elog(
ERROR,
"return type must be a row type");
689 memset(isnull,
true,
sizeof(isnull));
698 memset(isnull,
false,
sizeof(isnull));
734 if (my_extra == NULL)
758 if (my_extra->
typoid != typoid)
765 my_extra->
typoid = typoid;
789 if ((
c >=
'a' &&
c <=
'z') || (
c >=
'A' &&
c <=
'Z'))
805 if ((
c >=
'0' &&
c <=
'9') ||
c ==
'$')
824 bool after_dot =
false;
831 nextp = qualname_str;
840 bool missing_ident =
true;
849 endp = strchr(nextp + 1,
'"');
852 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
853 errmsg(
"string is not a valid identifier: \"%s\"",
855 errdetail(
"String has unclosed double quotes.")));
858 memmove(endp, endp + 1, strlen(endp));
864 if (endp - curname == 0)
866 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
867 errmsg(
"string is not a valid identifier: \"%s\"",
869 errdetail(
"Quoted identifier must not be empty.")));
873 missing_ident =
false;
885 len = nextp - curname;
897 missing_ident =
false;
905 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
906 errmsg(
"string is not a valid identifier: \"%s\"",
908 errdetail(
"No valid identifier before \".\".")));
911 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
912 errmsg(
"string is not a valid identifier: \"%s\"",
914 errdetail(
"No valid identifier after \".\".")));
917 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
918 errmsg(
"string is not a valid identifier: \"%s\"",
932 else if (*nextp ==
'\0')
940 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
941 errmsg(
"string is not a valid identifier: \"%s\"",
969 if (strcmp(logfmt,
"stderr") != 0 &&
970 strcmp(logfmt,
"csvlog") != 0 &&
971 strcmp(logfmt,
"jsonlog") != 0)
973 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
974 errmsg(
"log format \"%s\" is not supported", logfmt),
975 errhint(
"The supported log formats are \"stderr\", \"csvlog\", and \"jsonlog\".")));
984 errmsg(
"could not read file \"%s\": %m",
991 _setmode(_fileno(
fd), _O_TEXT);
998 while (fgets(lbuffer,
sizeof(lbuffer),
fd) != NULL)
1005 log_format = lbuffer;
1006 log_filepath = strchr(lbuffer,
' ');
1007 if (log_filepath == NULL)
1015 *log_filepath =
'\0';
1017 nlpos = strchr(log_filepath,
'\n');
1027 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_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 OidIsValid(objectId)
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
const bool ScanKeywordBareLabel[SCANKEYWORDS_NUM_KEYWORDS]
char * get_database_name(Oid dbid)
elog(ERROR, "%s: %s", p2, msg)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
char * unpack_sql_state(int sql_state)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
struct dirent * ReadDir(DIR *dir, const char *dirname)
FILE * AllocateFile(const char *name, const char *mode)
DIR * AllocateDir(const char *dirname)
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, Datum *values, bool *isnull)
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
Assert(fmt[strlen(fmt) - 1] !='\n')
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
bool type_is_collatable(Oid typid)
Oid get_base_element_type(Oid typid)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
#define CHECK_FOR_INTERRUPTS()
void namestrcpy(Name name, const char *str)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
bool parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, Node *escontext)
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,...)
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)
bool scanner_isspace(char ch)
char * downcase_identifier(const char *ident, int len, bool warn, bool truncate)
AttInMetadata * attinmeta
MemoryContext multi_call_memory_ctx
Tuplestorestate * setResult
#define FirstLowInvalidHeapAttributeNumber
#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, Datum *values, bool *isnull)
char * text_to_cstring(const text *t)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
#define readlink(path, buf, size)