- バックアップ一覧
- ソース を表示
- PostgreSQL/開発/ForeignDataWrapper は削除されています。
- 1 (2017-05-11 (木) 22:49:36)
- 2 (2017-05-12 (金) 23:05:41)
- 3 (2017-05-13 (土) 00:37:41)
外部テーブル他,各種情報の取得 †
view source on doxygen.postgresql.org
#include "foreign/foreign.h" /* [Sample] CREATE FOREIGN TABLE T (....) SERVER postgres_server OPTIONS (table_name 'warehouse', schema_name 'sales'); */ ListCell *lc; ForeignTable *table = GetForeignTable(foreigntableid); foreach(lc, table->options) { // オプション情報の取得 DefElem *def = (DefElem *) lfirst(lc); // オプション名とオプション値の表示 elog(NOTICE, "%s = %s", def->defname, defGetString(def)); // table_name = warehouse // schema_name = sales }
テーブル属性の取得 †
以下では,Oidが24576のテーブルをオープンし属性名のリストを取得している。
Relation rel; Oid relid = 24576; rel = heap_open(relid, NoLock); TupleDesc tupdesc = RelationGetDescr(rel); for (int i = 1; i <= tupdesc->natts; i++) { Form_pg_attribute attr = tupdesc->attrs[i - 1]; if (attr->attisdropped) continue; char *colname = get_relid_attribute_name(relid, i); elog(NOTICE, "colname: %s", colname); } heap_close(relid, NoLock);