#include "nodes/parsenodes.h"
Go to the source code of this file.
#define MappingUserName | ( | userid | ) | (OidIsValid(userid) ? GetUserNameFromId(userid) : "public") |
Definition at line 20 of file foreign.h.
Referenced by AlterUserMapping(), CreateUserMapping(), GetUserMapping(), and RemoveUserMapping().
typedef struct ForeignDataWrapper ForeignDataWrapper |
typedef struct ForeignServer ForeignServer |
typedef struct ForeignTable ForeignTable |
typedef struct UserMapping UserMapping |
enum GenericOptionFlags |
Definition at line 28 of file foreign.h.
{ ServerOpt = 1, /* options applicable to SERVER */ UserMappingOpt = 2, /* options for USER MAPPING */ FdwOpt = 4 /* options for FOREIGN DATA WRAPPER */ } GenericOptionFlags;
Definition at line 592 of file foreign.c.
References CStringGetDatum, ereport, errcode(), errmsg(), ERROR, FOREIGNDATAWRAPPERNAME, GetSysCacheOid1, and OidIsValid.
Referenced by convert_foreign_data_wrapper_name(), get_object_address_unqualified(), GetForeignDataWrapperByName(), and objectNamesToOids().
{ Oid oid; oid = GetSysCacheOid1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(fdwname)); if (!OidIsValid(oid) && !missing_ok) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign-data wrapper \"%s\" does not exist", fdwname))); return oid; }
Definition at line 613 of file foreign.c.
References CStringGetDatum, ereport, errcode(), errmsg(), ERROR, FOREIGNSERVERNAME, GetSysCacheOid1, and OidIsValid.
Referenced by convert_server_name(), get_object_address_unqualified(), GetForeignServerByName(), and objectNamesToOids().
{ Oid oid; oid = GetSysCacheOid1(FOREIGNSERVERNAME, CStringGetDatum(servername)); if (!OidIsValid(oid) && !missing_ok) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("server \"%s\" does not exist", servername))); return oid; }
List* GetForeignColumnOptions | ( | Oid | relid, | |
AttrNumber | attnum | |||
) |
Definition at line 257 of file foreign.c.
References Anum_pg_attribute_attfdwoptions, ATTNUM, elog, ERROR, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache2, SysCacheGetAttr(), and untransformRelOptions().
Referenced by deparseAnalyzeSql(), deparseColumnRef(), and get_file_fdw_attribute_options().
{ List *options; HeapTuple tp; Datum datum; bool isnull; tp = SearchSysCache2(ATTNUM, ObjectIdGetDatum(relid), Int16GetDatum(attnum)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); datum = SysCacheGetAttr(ATTNUM, tp, Anum_pg_attribute_attfdwoptions, &isnull); if (isnull) options = NIL; else options = untransformRelOptions(datum); ReleaseSysCache(tp); return options; }
ForeignDataWrapper* GetForeignDataWrapper | ( | Oid | fdwid | ) |
Definition at line 39 of file foreign.c.
References Anum_pg_foreign_data_wrapper_fdwoptions, elog, ERROR, ForeignDataWrapper::fdwhandler, ForeignDataWrapper::fdwid, ForeignDataWrapper::fdwname, ForeignDataWrapper::fdwvalidator, FOREIGNDATAWRAPPEROID, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, ForeignDataWrapper::options, ForeignDataWrapper::owner, palloc(), pstrdup(), ReleaseSysCache(), SearchSysCache1, SysCacheGetAttr(), and untransformRelOptions().
Referenced by AlterForeignServer(), AlterForeignServerOwner_internal(), AlterUserMapping(), ATExecAlterColumnGenericOptions(), ATExecGenericOptions(), CreateForeignTable(), CreateUserMapping(), fileGetOptions(), get_connect_string(), GetForeignDataWrapperByName(), getObjectDescription(), and getObjectIdentity().
{ Form_pg_foreign_data_wrapper fdwform; ForeignDataWrapper *fdw; Datum datum; HeapTuple tp; bool isnull; tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid); fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp); fdw = (ForeignDataWrapper *) palloc(sizeof(ForeignDataWrapper)); fdw->fdwid = fdwid; fdw->owner = fdwform->fdwowner; fdw->fdwname = pstrdup(NameStr(fdwform->fdwname)); fdw->fdwhandler = fdwform->fdwhandler; fdw->fdwvalidator = fdwform->fdwvalidator; /* Extract the fdwoptions */ datum = SysCacheGetAttr(FOREIGNDATAWRAPPEROID, tp, Anum_pg_foreign_data_wrapper_fdwoptions, &isnull); if (isnull) fdw->options = NIL; else fdw->options = untransformRelOptions(datum); ReleaseSysCache(tp); return fdw; }
ForeignDataWrapper* GetForeignDataWrapperByName | ( | const char * | name, | |
bool | missing_ok | |||
) |
Definition at line 82 of file foreign.c.
References get_foreign_data_wrapper_oid(), GetForeignDataWrapper(), and OidIsValid.
Referenced by CreateForeignDataWrapper(), and CreateForeignServer().
{ Oid fdwId = get_foreign_data_wrapper_oid(fdwname, missing_ok); if (!OidIsValid(fdwId)) return NULL; return GetForeignDataWrapper(fdwId); }
ForeignServer* GetForeignServer | ( | Oid | serverid | ) |
Definition at line 97 of file foreign.c.
References Anum_pg_foreign_server_srvoptions, Anum_pg_foreign_server_srvtype, Anum_pg_foreign_server_srvversion, elog, ERROR, ForeignServer::fdwid, FOREIGNSERVEROID, GETSTRUCT, HeapTupleIsValid, NameStr, NULL, ObjectIdGetDatum, ForeignServer::options, ForeignServer::owner, palloc(), pstrdup(), ReleaseSysCache(), SearchSysCache1, ForeignServer::serverid, ForeignServer::servername, ForeignServer::servertype, ForeignServer::serverversion, SysCacheGetAttr(), TextDatumGetCString, and untransformRelOptions().
Referenced by ATExecAlterColumnGenericOptions(), ATExecGenericOptions(), fileGetOptions(), GetForeignServerByName(), getObjectDescription(), getObjectIdentity(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginForeignModify(), postgresBeginForeignScan(), and postgresGetForeignRelSize().
{ Form_pg_foreign_server serverform; ForeignServer *server; HeapTuple tp; Datum datum; bool isnull; tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign server %u", serverid); serverform = (Form_pg_foreign_server) GETSTRUCT(tp); server = (ForeignServer *) palloc(sizeof(ForeignServer)); server->serverid = serverid; server->servername = pstrdup(NameStr(serverform->srvname)); server->owner = serverform->srvowner; server->fdwid = serverform->srvfdw; /* Extract server type */ datum = SysCacheGetAttr(FOREIGNSERVEROID, tp, Anum_pg_foreign_server_srvtype, &isnull); server->servertype = isnull ? NULL : pstrdup(TextDatumGetCString(datum)); /* Extract server version */ datum = SysCacheGetAttr(FOREIGNSERVEROID, tp, Anum_pg_foreign_server_srvversion, &isnull); server->serverversion = isnull ? NULL : pstrdup(TextDatumGetCString(datum)); /* Extract the srvoptions */ datum = SysCacheGetAttr(FOREIGNSERVEROID, tp, Anum_pg_foreign_server_srvoptions, &isnull); if (isnull) server->options = NIL; else server->options = untransformRelOptions(datum); ReleaseSysCache(tp); return server; }
ForeignServer* GetForeignServerByName | ( | const char * | name, | |
bool | missing_ok | |||
) |
Definition at line 152 of file foreign.c.
References get_foreign_server_oid(), GetForeignServer(), and OidIsValid.
Referenced by AlterUserMapping(), CreateForeignServer(), CreateForeignTable(), CreateUserMapping(), get_connect_string(), and RemoveUserMapping().
{ Oid serverid = get_foreign_server_oid(srvname, missing_ok); if (!OidIsValid(serverid)) return NULL; return GetForeignServer(serverid); }
ForeignTable* GetForeignTable | ( | Oid | relid | ) |
Definition at line 219 of file foreign.c.
References Anum_pg_foreign_table_ftoptions, elog, ERROR, FOREIGNTABLEREL, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ForeignTable::options, palloc(), ReleaseSysCache(), ForeignTable::relid, SearchSysCache1, ForeignTable::serverid, SysCacheGetAttr(), and untransformRelOptions().
Referenced by check_selective_binary_conversion(), deparseRelation(), fileGetOptions(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginForeignModify(), postgresBeginForeignScan(), and postgresGetForeignRelSize().
{ Form_pg_foreign_table tableform; ForeignTable *ft; HeapTuple tp; Datum datum; bool isnull; tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign table %u", relid); tableform = (Form_pg_foreign_table) GETSTRUCT(tp); ft = (ForeignTable *) palloc(sizeof(ForeignTable)); ft->relid = relid; ft->serverid = tableform->ftserver; /* Extract the ftoptions */ datum = SysCacheGetAttr(FOREIGNTABLEREL, tp, Anum_pg_foreign_table_ftoptions, &isnull); if (isnull) ft->options = NIL; else ft->options = untransformRelOptions(datum); ReleaseSysCache(tp); return ft; }
UserMapping* GetUserMapping | ( | Oid | userid, | |
Oid | serverid | |||
) |
Definition at line 170 of file foreign.c.
References Anum_pg_user_mapping_umoptions, ereport, errcode(), errmsg(), ERROR, HeapTupleIsValid, InvalidOid, MappingUserName, ObjectIdGetDatum, UserMapping::options, palloc(), ReleaseSysCache(), SearchSysCache2, UserMapping::serverid, SysCacheGetAttr(), untransformRelOptions(), UserMapping::userid, and USERMAPPINGUSERSERVER.
Referenced by get_connect_string(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginForeignModify(), postgresBeginForeignScan(), and postgresGetForeignRelSize().
{ Datum datum; HeapTuple tp; bool isnull; UserMapping *um; tp = SearchSysCache2(USERMAPPINGUSERSERVER, ObjectIdGetDatum(userid), ObjectIdGetDatum(serverid)); if (!HeapTupleIsValid(tp)) { /* Not found for the specific user -- try PUBLIC */ tp = SearchSysCache2(USERMAPPINGUSERSERVER, ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(serverid)); } if (!HeapTupleIsValid(tp)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("user mapping not found for \"%s\"", MappingUserName(userid)))); um = (UserMapping *) palloc(sizeof(UserMapping)); um->userid = userid; um->serverid = serverid; /* Extract the umoptions */ datum = SysCacheGetAttr(USERMAPPINGUSERSERVER, tp, Anum_pg_user_mapping_umoptions, &isnull); if (isnull) um->options = NIL; else um->options = untransformRelOptions(datum); ReleaseSysCache(tp); return um; }