#author("2017-05-13T01:10:31+09:00","","")
[[PostgreSQL/開発]]

(参考)[[view source on doxygen.postgresql.org>https://doxygen.postgresql.org/heapam_8c.html]]

#contents

* 概要 [#haf3a94a]

- ヒープ操作のための機能
- リレーション(テーブル)のオープン・クローズ,タプルの追加・削除・更新などの機能も定義されている

* サンプルプログラム [#k4ee8168]
** テーブル属性の取得 [#eacff995]

以下では,oidが24576のテーブルをオープンし属性名のリストを取得している。

#geshi(c){{
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);
}}

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP