56 #include "utils/fmgroids.h"
104 static char *
get_sql_insert(
Relation rel,
int *pkattnums,
int pknumatts,
char **src_pkattvals,
char **tgt_pkattvals);
106 static char *
get_sql_update(
Relation rel,
int *pkattnums,
int pknumatts,
char **src_pkattvals,
char **tgt_pkattvals);
120 int **pkattnums,
int *pknumatts);
166 dblink_conn_not_avail(const
char *conname)
170 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
171 errmsg(
"connection \"%s\" not available", conname)));
174 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
175 errmsg(
"connection not available")));
180 PGconn *
volatile *conn_p,
char **conname_p,
volatile bool *freeconn_p)
190 conname = conname_or_str;
211 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
212 errmsg(
"could not establish connection"),
213 errdetail(
"There are too many open files on the local server."),
214 errhint(
"Raise the server's max_files_per_process and/or \"ulimit -n\" limits.")));
217 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
218 errmsg(
"could not establish connection"),
219 errdetail(
"There are too many open files on the local server."),
220 errhint(
"Raise the server's max_files_per_process setting.")));
234 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
235 errmsg(
"could not establish connection"),
246 *conname_p = conname;
247 *freeconn_p = freeconn;
258 dblink_conn_not_avail(conname);
281 char *conname_or_str = NULL;
283 char *connname = NULL;
324 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
325 errmsg(
"could not establish connection"),
326 errdetail(
"There are too many open files on the local server."),
327 errhint(
"Raise the server's max_files_per_process and/or \"ulimit -n\" limits.")));
330 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
331 errmsg(
"could not establish connection"),
332 errdetail(
"There are too many open files on the local server."),
333 errhint(
"Raise the server's max_files_per_process setting.")));
349 (
errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
350 errmsg(
"could not establish connection"),
386 char *conname = NULL;
403 dblink_conn_not_avail(conname);
427 char *curname = NULL;
429 char *conname = NULL;
472 if (!rconn || !rconn->
conn)
473 dblink_conn_not_avail(conname);
482 dblink_res_internalerror(
conn,
res,
"begin error");
503 "while opening cursor \"%s\"", curname);
520 char *curname = NULL;
521 char *conname = NULL;
560 if (!rconn || !rconn->
conn)
561 dblink_conn_not_avail(conname);
572 "while closing cursor \"%s\"", curname);
590 dblink_res_internalerror(
conn,
res,
"commit error");
606 char *conname = NULL;
610 char *curname = NULL;
660 dblink_conn_not_avail(conname);
676 "while fetching from cursor \"%s\"", curname);
684 (
errcode(ERRCODE_INVALID_CURSOR_NAME),
685 errmsg(
"cursor \"%s\" does not exist", curname)));
717 elog(
ERROR,
"wrong number of arguments");
738 volatile bool freeconn =
false;
747 char *conname = NULL;
784 elog(
ERROR,
"wrong number of arguments");
804 elog(
ERROR,
"wrong number of arguments");
808 dblink_conn_not_avail(conname);
827 "while executing query");
865 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
866 errmsg(
"set-valued function called in context that cannot accept a set")));
869 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
870 errmsg(
"materialize mode required, but it is not allowed in this context")));
929 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
930 errmsg(
"function returning record called in context "
931 "that cannot accept type record")));
935 elog(
ERROR,
"return type must be a row type");
948 if (nfields != tupdesc->
natts)
950 (
errcode(ERRCODE_DATATYPE_MISMATCH),
951 errmsg(
"remote query result rowtype does not match "
952 "the specified FROM clause rowtype")));
978 for (row = 0; row < ntuples; row++)
986 for (
i = 0;
i < nfields;
i++)
1027 const char *conname,
1038 sinfo.fcinfo = fcinfo;
1044 "dblink temporary context",
1062 "while executing query");
1089 rsinfo->setResult = tupstore;
1090 rsinfo->setDesc = tupdesc;
1106 Assert(rsinfo->setResult != NULL);
1113 if (sinfo.tmpcontext != NULL)
1115 sinfo.tmpcontext = NULL;
1118 sinfo.last_res = NULL;
1120 sinfo.cur_res = NULL;
1150 elog(
ERROR,
"failed to set single-row mode for dblink query");
1169 if (first && nestlevel < 0)
1239 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1240 errmsg(
"function returning record called in context "
1241 "that cannot accept type record")));
1245 elog(
ERROR,
"return type must be a row type");
1253 if (nfields != tupdesc->
natts)
1255 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1256 errmsg(
"remote query result rowtype does not match "
1257 "the specified FROM clause rowtype")));
1279 sinfo->
cstrs = (
char **)
palloc(nfields *
sizeof(
char *));
1295 for (
i = 0;
i < nfields;
i++)
1421 if (msg == NULL || msg[0] ==
'\0')
1434 text *
volatile sql_cmd_status = NULL;
1436 volatile bool freeconn =
false;
1444 char *conname = NULL;
1479 elog(
ERROR,
"wrong number of arguments");
1482 dblink_conn_not_avail(conname);
1490 "while executing command");
1511 (
errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
1512 errmsg(
"statement returning results not allowed")));
1586 if ((results != NULL) && (indnkeyatts > 0))
1615 if (call_cntr < max_calls)
1623 values[1] = results[call_cntr];
1672 char **src_pkattvals;
1673 char **tgt_pkattvals;
1687 &pkattnums, &pknumatts);
1698 if (src_nitems != pknumatts)
1700 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
1701 errmsg(
"source key array length must match number of key attributes")));
1712 if (tgt_nitems != pknumatts)
1714 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
1715 errmsg(
"target key array length must match number of key attributes")));
1720 sql =
get_sql_insert(rel, pkattnums, pknumatts, src_pkattvals, tgt_pkattvals);
1760 char **tgt_pkattvals;
1773 &pkattnums, &pknumatts);
1784 if (tgt_nitems != pknumatts)
1786 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
1787 errmsg(
"target key array length must match number of key attributes")));
1837 char **src_pkattvals;
1838 char **tgt_pkattvals;
1852 &pkattnums, &pknumatts);
1863 if (src_nitems != pknumatts)
1865 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
1866 errmsg(
"source key array length must match number of key attributes")));
1877 if (tgt_nitems != pknumatts)
1879 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
1880 errmsg(
"target key array length must match number of key attributes")));
1885 sql =
get_sql_update(rel, pkattnums, pknumatts, src_pkattvals, tgt_pkattvals);
1920 #define DBLINK_NOTIFY_COLS 3
1945 memset(nulls, 0,
sizeof(nulls));
1954 if (notify->
extra != NULL)
1997 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
1999 errdetail(
"Could not get libpq's default connection options.")));
2003 foreach(cell, options_list)
2022 (
buf.len > 0) ?
", " :
"",
2026 (
errcode(ERRCODE_FDW_OPTION_NAME_NOT_FOUND),
2029 ?
errhint(
"Valid options in this context are: %s",
2031 :
errhint(
"There are no valid options in this context.")));
2058 char **result = NULL;
2069 Anum_pg_index_indrelid,
2081 if (
index->indisprimary)
2083 *indnkeyatts =
index->indnkeyatts;
2084 if (*indnkeyatts > 0)
2086 result = (
char **)
palloc(*indnkeyatts *
sizeof(
char *));
2088 for (
i = 0;
i < *indnkeyatts;
i++)
2133 for (
i = 0;
i < nitems;
i++)
2135 if (bitmap && (*bitmap & bitmask) == 0)
2150 if (bitmask == 0x100)
2180 natts = tupdesc->
natts;
2185 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
2186 errmsg(
"source row not found")));
2191 for (
i = 0;
i < natts;
i++)
2195 if (att->attisdropped)
2212 for (
i = 0;
i < natts;
i++)
2257 for (
i = 0;
i < pknumatts;
i++)
2259 int pkattnum = pkattnums[
i];
2268 if (tgt_pkattvals[
i] != NULL)
2297 natts = tupdesc->
natts;
2302 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
2303 errmsg(
"source row not found")));
2311 for (
i = 0;
i < natts;
i++)
2315 if (attr->attisdropped)
2343 for (
i = 0;
i < pknumatts;
i++)
2345 int pkattnum = pkattnums[
i];
2354 val = tgt_pkattvals[
i];
2392 for (
i = 0;
i < pknumatts;
i++)
2393 if (
key == pkattnums[
i])
2415 elog(
ERROR,
"SPI connect failure - returned %d", ret);
2423 natts = tupdesc->
natts;
2434 for (
i = 0;
i < natts;
i++)
2441 if (attr->attisdropped)
2450 for (
i = 0;
i < pknumatts;
i++)
2452 int pkattnum = pkattnums[
i];
2461 if (src_pkattvals[
i] != NULL)
2479 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
2480 errmsg(
"source criteria matched more than one record")));
2570 return hentry->
rconn;
2610 errmsg(
"duplicate connection name")));
2613 hentry->
rconn = rconn;
2634 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2635 errmsg(
"undefined connection name")));
2651 (
errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
2652 errmsg(
"password is required"),
2653 errdetail(
"Non-superuser cannot connect if the server does not request a password."),
2654 errhint(
"Target server's authentication method must be changed.")));
2672 bool connstr_gives_password =
false;
2679 if (strcmp(
option->keyword,
"password") == 0)
2683 connstr_gives_password =
true;
2691 if (!connstr_gives_password)
2693 (
errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
2694 errmsg(
"password is required"),
2695 errdetail(
"Non-superusers must provide a password in the connection string.")));
2709 bool fail,
const char *
fmt,...)
2718 char *message_primary;
2719 char *message_detail;
2721 char *message_context;
2723 char dblink_context_msg[512];
2730 if (pg_diag_sqlstate)
2732 pg_diag_sqlstate[1],
2733 pg_diag_sqlstate[2],
2734 pg_diag_sqlstate[3],
2735 pg_diag_sqlstate[4]);
2737 sqlstate = ERRCODE_CONNECTION_FAILURE;
2739 message_primary =
xpstrdup(pg_diag_message_primary);
2740 message_detail =
xpstrdup(pg_diag_message_detail);
2741 message_hint =
xpstrdup(pg_diag_message_hint);
2742 message_context =
xpstrdup(pg_diag_context);
2749 if (message_primary == NULL)
2768 vsnprintf(dblink_context_msg,
sizeof(dblink_context_msg),
fmt, ap);
2773 (message_primary != NULL && message_primary[0] !=
'\0') ?
2775 errmsg(
"could not obtain message string for remote error"),
2777 message_hint ?
errhint(
"%s", message_hint) : 0,
2778 message_context ? (
errcontext(
"%s", message_context)) : 0,
2780 (
errcontext(
"%s on dblink connection named \"%s\"",
2781 dblink_context_msg, conname)) :
2782 (
errcontext(
"%s on unnamed dblink connection",
2783 dblink_context_msg))));
2816 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
2818 errdetail(
"Could not get libpq's default connection options.")));
2822 srvname =
pstrdup(servername);
2849 foreach(cell, foreign_server->
options)
2858 foreach(cell, user_mapping->
options)
2887 for (cp =
str; *cp; cp++)
2889 if (*cp ==
'\\' || *cp ==
'\'')
2915 int **pkattnums,
int *pknumatts)
2918 int natts = tupdesc->
natts;
2922 pknumatts_arg =
Min(pknumatts_arg, pkattnums_arg->
dim1);
2925 if (pknumatts_arg <= 0)
2927 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2928 errmsg(
"number of key attributes must be > 0")));
2931 *pkattnums = (
int *)
palloc(pknumatts_arg *
sizeof(
int));
2932 *pknumatts = pknumatts_arg;
2935 for (
i = 0;
i < pknumatts_arg;
i++)
2937 int pkattnum = pkattnums_arg->
values[
i];
2942 if (pkattnum <= 0 || pkattnum > natts)
2944 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2945 errmsg(
"invalid attribute number %d", pkattnum)));
2949 for (
j = 0;
j < natts;
j++)
2955 if (++lnum == pkattnum)
2960 (*pkattnums)[
i] =
j;
2963 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2964 errmsg(
"invalid attribute number %d", pkattnum)));
3003 if (strcmp(opt->
keyword,
"client_encoding") == 0)
3012 if (context != UserMappingRelationId)
3017 if (context != ForeignServerRelationId)
3037 static const char *
const GUCsAffectingIO[] = {
3047 const char *gucName = GUCsAffectingIO[
i];
3049 const char *localVal;
3057 if (remoteVal == NULL)
3065 Assert(localVal != NULL);
3067 if (strcmp(remoteVal, localVal) == 0)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
AclResult pg_foreign_server_aclcheck(Oid srv_oid, Oid roleid, AclMode mode)
#define PG_GETARG_ARRAYTYPE_P(n)
#define ARR_NULLBITMAP(a)
#define PG_RETURN_ARRAYTYPE_P(x)
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)
Datum current_query(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define pg_attribute_printf(f, a)
static void createNewConnection(const char *name, remoteConn *rconn)
Datum dblink_get_result(PG_FUNCTION_ARGS)
static int get_attnum_pk_pos(int *pkattnums, int pknumatts, int key)
Datum dblink_build_sql_delete(PG_FUNCTION_ARGS)
Datum dblink_get_pkey(PG_FUNCTION_ARGS)
static void pg_attribute_noreturn() dblink_res_internalerror(PGconn *conn
Datum dblink_open(PG_FUNCTION_ARGS)
static remoteConn * pconn
static HeapTuple get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals)
Datum dblink_close(PG_FUNCTION_ARGS)
static void restoreLocalGucs(int nestlevel)
static PGconn * dblink_get_named_conn(const char *conname)
static char * quote_ident_cstr(char *rawstr)
static HTAB * createConnHash(void)
Datum dblink_exec(PG_FUNCTION_ARGS)
static void dblink_connstr_check(const char *connstr)
static char * get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals)
static void PGresult const char * p2
static char * get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals)
static bool is_valid_dblink_option(const PQconninfoOption *options, const char *option, Oid context)
Datum dblink_build_sql_insert(PG_FUNCTION_ARGS)
static remoteConn * getConnectionByName(const char *name)
Datum dblink_get_notify(PG_FUNCTION_ARGS)
static HTAB * remoteConnHash
static void storeRow(volatile storeInfo *sinfo, PGresult *res, bool first)
Datum dblink_disconnect(PG_FUNCTION_ARGS)
static void dblink_get_conn(char *conname_or_str, PGconn *volatile *conn_p, char **conname_p, volatile bool *freeconn_p)
static int applyRemoteGucs(PGconn *conn)
static char * escape_param_str(const char *from)
Datum dblink_fdw_validator(PG_FUNCTION_ARGS)
static void dblink_init(void)
static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
Datum dblink_get_connections(PG_FUNCTION_ARGS)
static char ** get_pkey_attnames(Relation rel, int16 *indnkeyatts)
static void prepTuplestoreResult(FunctionCallInfo fcinfo)
static void dblink_res_error(PGconn *conn, const char *conname, PGresult *res, bool fail, const char *fmt,...) pg_attribute_printf(5
Datum dblink_record(PG_FUNCTION_ARGS)
static void dblink_security_check(PGconn *conn, remoteConn *rconn)
static void materializeResult(FunctionCallInfo fcinfo, PGconn *conn, PGresult *res)
struct remoteConn remoteConn
Datum dblink_is_busy(PG_FUNCTION_ARGS)
static char ** get_text_array_contents(ArrayType *array, int *numitems)
static void static char * get_connect_string(const char *servername)
Datum dblink_connect(PG_FUNCTION_ARGS)
Datum dblink_current_query(PG_FUNCTION_ARGS)
Datum dblink_fetch(PG_FUNCTION_ARGS)
static void PGresult * res
struct remoteConnHashEnt remoteConnHashEnt
Datum dblink_build_sql_update(PG_FUNCTION_ARGS)
static void deleteConnection(const char *name)
static char * xpstrdup(const char *in)
struct storeInfo storeInfo
static char * generate_relation_name(Relation rel)
#define DBLINK_NOTIFY_COLS
Datum dblink_cancel_query(PG_FUNCTION_ARGS)
Datum dblink_send_query(PG_FUNCTION_ARGS)
static char * get_sql_delete(Relation rel, int *pkattnums, int pknumatts, char **tgt_pkattvals)
elog(ERROR, "%s: %s", p2, msg)
Datum dblink_error_message(PG_FUNCTION_ARGS)
static void validate_pkattnums(Relation rel, int2vector *pkattnums_arg, int32 pknumatts_arg, int **pkattnums, int *pknumatts)
static void materializeQueryResult(FunctionCallInfo fcinfo, PGconn *conn, const char *conname, const char *sql, bool fail)
static PGresult * storeQueryResult(volatile storeInfo *sinfo, PGconn *conn, const char *sql)
PG_FUNCTION_INFO_V1(dblink_connect)
static Relation get_rel_from_relname(text *relname_text, LOCKMODE lockmode, AclMode aclmode)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define MAKE_SQLSTATE(ch1, ch2, ch3, ch4, ch5)
#define ereport(elevel,...)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
void ReleaseExternalFD(void)
bool AcquireExternalFD(void)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
PGcancel * PQgetCancel(PGconn *conn)
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
PQconninfoOption * PQconndefaults(void)
int PQconnectionUsedPassword(const PGconn *conn)
void PQconninfoFree(PQconninfoOption *connOptions)
char * PQerrorMessage(const PGconn *conn)
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
ConnStatusType PQstatus(const PGconn *conn)
int PQclientEncoding(const PGconn *conn)
void PQfinish(PGconn *conn)
PGconn * PQconnectdb(const char *conninfo)
void PQfreeCancel(PGcancel *cancel)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
int PQsetSingleRowMode(PGconn *conn)
void PQfreemem(void *ptr)
PGnotify * PQnotifies(PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
int PQntuples(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
int PQconsumeInput(PGconn *conn)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
char * PQcmdStatus(PGresult *res)
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
int PQsendQuery(PGconn *conn, const char *query)
int PQisBusy(PGconn *conn)
char * PQresultErrorField(const PGresult *res, int fieldcode)
int PQnfields(const PGresult *res)
PGresult * PQgetResult(PGconn *conn)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define PG_GETARG_TEXT_PP(n)
#define DatumGetTextPP(X)
#define PG_GETARG_POINTER(n)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
ForeignDataWrapper * GetForeignDataWrapper(Oid fdwid)
UserMapping * GetUserMapping(Oid userid, Oid serverid)
ForeignServer * GetForeignServerByName(const char *srvname, bool missing_ok)
void SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define HeapTupleGetDatum(tuple)
#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 NewGUCNestLevel(void)
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
#define HeapTupleIsValid(tuple)
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
static void const char * fmt
char * get_namespace_name(Oid nspid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
int GetDatabaseEncoding(void)
const char * GetDatabaseEncodingName(void)
void MemoryContextReset(MemoryContext context)
char * pchomp(const char *in)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
RangeVar * makeRangeVarFromNameList(List *names)
bool RelationIsVisible(Oid relid)
#define IsA(nodeptr, _type_)
ObjectType get_relkind_objtype(char relkind)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
FormData_pg_index * Form_pg_index
static void static void status(const char *fmt,...) pg_attribute_printf(1
size_t strlcpy(char *dst, const char *src, size_t siz)
#define ObjectIdGetDatum(X)
#define PointerGetDatum(X)
#define PG_DIAG_MESSAGE_HINT
#define PG_DIAG_MESSAGE_PRIMARY
#define PG_DIAG_MESSAGE_DETAIL
char * psprintf(const char *fmt,...)
Datum quote_ident(PG_FUNCTION_ARGS)
char * quote_literal_cstr(const char *rawstr)
#define RelationGetRelid(relation)
#define RelationGetRelationName(relation)
List * untransformRelOptions(Datum options)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void truncate_identifier(char *ident, int len, bool warn)
SPITupleTable * SPI_tuptable
int SPI_exec(const char *src, long tcount)
char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
char * SPI_fname(TupleDesc tupdesc, int fnumber)
HeapTuple SPI_copytuple(HeapTuple tuple)
void relation_close(Relation relation, LOCKMODE lockmode)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
MemoryContext ecxt_per_query_memory
AttInMetadata * attinmeta
MemoryContext multi_call_memory_ctx
SetFunctionReturnMode returnMode
Tuplestorestate * setResult
int16 values[FLEXIBLE_ARRAY_MEMBER]
Tuplestorestate * tuplestore
AttInMetadata * attinmeta
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
TupleDesc CreateTemplateTupleDesc(int natts)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
#define TupleDescAttr(tupdesc, i)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
void tuplestore_end(Tuplestorestate *state)
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
#define att_align_nominal(cur_offset, attalign)
#define att_addlength_pointer(cur_offset, attlen, attptr)
List * textToQualifiedNameList(text *textval)
char * text_to_cstring(const text *t)
text * cstring_to_text(const char *s)