How to identify Primary key column during build stage of Custom index?

From: Sairam Gaddam <gaddamsairam(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to identify Primary key column during build stage of Custom index?
Date: 2017-01-11 08:56:51
Message-ID: CAMsN=MA9nHK=vPyNgC_9BBisbLk6k=Z5onZ8WGcfR=QOrcU+WQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,
Basically I am new to postgresql, and I am trying to build a
custom Index to postgres using IndexAmRoutine. Further details on what I am
working is below.
amapi.h - API for Postgres index access methods.

IndexBuildResult *Indexbuild(Relation heap, Relation index, IndexInfo
*indexInfo){ }

The above function will be called during index build stage of custom index.
So If i create a custom index on primary key/or any column on some table,
the above function will be called and some details of table and index are
shared for further processing...

How do I identify primary key column of that table during build stage
through code?
Can I get details of primary key through
TupleDesc <https://doxygen.postgresql.org/structtupleDesc.html> rd_att
<https://doxygen.postgresql.org/structRelationData.html#a888d0630bc511944101812a989a4b427>;
/* tuple descriptor */ ?

I tried to access constraints attribute of above, but ConstrCheck
<https://doxygen.postgresql.org/structconstrCheck.html> in TupleConstr
<https://doxygen.postgresql.org/structtupleConstr.html> was NULL during
build.

I also tried to create index on primary key and check 'indisprimary' of
Form_pg_index
<https://doxygen.postgresql.org/pg__index_8h.html#aaf3f73286b0cf1baf9636770f5e695e4>
in
Index relationdata object but it was found to be 0 even for my custom index
on table primary key!!

So any other way to find a primary key column details during build stage of
a custom index???

Browse pgsql-general by date

  From Date Subject
Next Message Tom DalPozzo 2017-01-11 10:58:17 Re: requested timeline doesn't contain minimum recovery point
Previous Message John R Pierce 2017-01-11 08:55:48 Re: Are new connection/security features in order, given connection pooling?