mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Add GetForeignColumnOptions() to foreign.c, and add some documentation.
GetForeignColumnOptions provides some abstraction for accessing column-specific FDW options, on a par with the access functions that were already provided here for other FDW-related information. Adjust file_fdw.c to use GetForeignColumnOptions instead of equivalent hand-rolled code. In addition, add some SGML documentation for the functions exported by foreign.c that are meant for use by FDW authors. (This is the fdw_helper portion of the proposed pgsql_fdw patch.) Hanada Shigeru, reviewed by KaiGai Kohei
This commit is contained in:
@@ -28,7 +28,6 @@ extern Datum pg_options_to_table(PG_FUNCTION_ARGS);
|
||||
extern Datum postgresql_fdw_validator(PG_FUNCTION_ARGS);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GetForeignDataWrapper - look up the foreign-data wrapper by OID.
|
||||
*/
|
||||
@@ -71,7 +70,6 @@ GetForeignDataWrapper(Oid fdwid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GetForeignDataWrapperByName - look up the foreign-data wrapper
|
||||
* definition by name.
|
||||
@@ -247,6 +245,39 @@ GetForeignTable(Oid relid)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetForeignColumnOptions - Get attfdwoptions of given relation/attnum
|
||||
* as list of DefElem.
|
||||
*/
|
||||
List *
|
||||
GetForeignColumnOptions(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetFdwRoutine - call the specified foreign-data wrapper handler routine
|
||||
* to get its FdwRoutine struct.
|
||||
@@ -498,6 +529,7 @@ postgresql_fdw_validator(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_foreign_data_wrapper_oid - given a FDW name, look up the OID
|
||||
*
|
||||
@@ -518,6 +550,7 @@ get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok)
|
||||
return oid;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_foreign_server_oid - given a FDW name, look up the OID
|
||||
*
|
||||
|
Reference in New Issue
Block a user