in C trigger function find out if column is part of primary key - Mailing list pgsql-general

From Enke, Dr., Michael
Subject in C trigger function find out if column is part of primary key
Date
Msg-id D0705BB737A20D4EA166124FF1BA8C630101F654279E@DEEXVS61.wincor-nixdorf.com
Whole thread Raw
Responses Re: in C trigger function find out if column is part of primary key
Re: in C trigger function find out if column is part of primary key
List pgsql-general

Hello C-(trigger)-experts,

I have to find out if a column ( i = 0, …, tupdesc->natts-1 ) is part of a primary key
but for performance reasons I do not want to execute another query via SPI.
Is this possible?

 

Currently I did not find a way, instead I check for “not null” attribute tupdesc->attrs[i]->attnotnull
and in addition if the column is used in an index via relation->rd_indexattr
but this Bitmapset has 8 leading zeros.
Is there a define which I can use instead of hardcode the 8? Currently I use bms_is_member(i + 8, rd_indexattr)

 

Thank you,

Michael

WINCOR NIXDORF International GmbH
Sitz der Gesellschaft: Paderborn
Registergericht Paderborn HRB 3507
Geschäftsführer: Eckard Heidloff (Vorsitzender), Dr. Jürgen Wunram (stellv. Vors.), Jens Bohlen
Vorsitzender des Aufsichtsrats: Dr. Alexander Dibelius
Steuernummer: 339/5884/0020 - Ust-ID Nr.: DE812927716 - WEEE-Reg.-Nr. DE44477193

Diese E-Mail enthält vertrauliche Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.

This e-mail may contain confidential information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

pgsql-general by date:

Previous
From: Misa Simic
Date:
Subject: Re: Money casting too liberal?
Next
From: Juan Pablo Cook
Date:
Subject: Fwd: JDBC Array double precision [] error