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

Function GetForeignTableOnSegment

src/backend/foreign/foreign.c:412–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412static ForeignTable *
413GetForeignTableOnSegment(Oid relid)
414{
415 Form_pg_foreign_table_seg tablesegform;
416 ForeignTable *ft = NULL;
417 Relation foreignTableRel;
418 ScanKeyData ftkey;
419 SysScanDesc ftscan;
420 HeapTuple fttuple;
421 int i;
422 int segNumber;
423
424 segNumber = GetForeignTableSegNumbers(relid);
425
426 foreignTableRel = table_open(ForeignTableRelationSegId, AccessShareLock);
427
428 ScanKeyInit(&ftkey,
429 Anum_pg_foreign_table_seg_ftsrelid,
430 BTEqualStrategyNumber, F_OIDEQ,
431 ObjectIdGetDatum(relid));
432
433 ftscan = systable_beginscan(foreignTableRel, InvalidOid,
434 false, NULL, 1, &ftkey);
435
436 i = 0;
437 while (HeapTupleIsValid(fttuple = systable_getnext(ftscan)))
438 {
439
440 if (i == qe_idx)
441 {
442 tablesegform = (Form_pg_foreign_table_seg) GETSTRUCT(fttuple);
443 ft = (ForeignTable *) palloc(sizeof(ForeignTable));
444 ft->relid = relid;
445 ft->serverid = tablesegform->ftsserver;
446 break;
447 }
448 i++;
449 }
450
451 systable_endscan(ftscan);
452
453 table_close(foreignTableRel, AccessShareLock);
454
455 return ft;
456}
457
458/*
459 * GetForeignTable - look up the foreign table definition by relation oid.

Callers 2

GetForeignTableFunction · 0.85

Calls 9

table_openFunction · 0.85
ScanKeyInitFunction · 0.85
ObjectIdGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
systable_endscanFunction · 0.85
table_closeFunction · 0.85
pallocFunction · 0.50

Tested by

no test coverage detected