MCPcopy Create free account
hub / github.com/apache/cloudberry / GetForeignServerSegByRelid

Function GetForeignServerSegByRelid

src/backend/foreign/foreign.c:1107–1152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1105}
1106
1107Oid
1108GetForeignServerSegByRelid(Oid relid)
1109{
1110 Form_pg_foreign_table tableform;
1111 ForeignTable *ft;
1112 HeapTuple tp;
1113 Datum datum;
1114 bool isnull;
1115 Oid foreignServerId;
1116
1117 if (Gp_role != GP_ROLE_EXECUTE)
1118 {
1119 tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid));
1120 if (!HeapTupleIsValid(tp))
1121 return InvalidOid;
1122 tableform = (Form_pg_foreign_table) GETSTRUCT(tp);
1123
1124 ft = (ForeignTable *) palloc(sizeof(ForeignTable));
1125 ft->relid = relid;
1126 ft->serverid = tableform->ftserver;
1127
1128 /* Extract the ftoptions */
1129 datum = SysCacheGetAttr(FOREIGNTABLEREL,
1130 tp,
1131 Anum_pg_foreign_table_ftoptions,
1132 &isnull);
1133 if (isnull)
1134 ft->options = NIL;
1135 else
1136 ft->options = untransformRelOptions(datum);
1137
1138 ReleaseSysCache(tp);
1139 }
1140 else
1141 {
1142 ft = GetForeignTableOnSegment(relid);
1143
1144 if (!ft)
1145 return InvalidOid;
1146 }
1147
1148 foreignServerId = ft->serverid;
1149 pfree(ft);
1150
1151 return foreignServerId;
1152}
1153
1154Datum
1155gp_foreign_server_id(PG_FUNCTION_ARGS)

Callers 3

heap_getsysattrFunction · 0.85
tts_virtual_getsysattrFunction · 0.85
gp_foreign_server_idFunction · 0.85

Calls 8

SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
SysCacheGetAttrFunction · 0.85
untransformRelOptionsFunction · 0.85
ReleaseSysCacheFunction · 0.85
GetForeignTableOnSegmentFunction · 0.85
pallocFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected