Re: Get primary key of a table through SPI

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Get primary key of a table through SPI
Дата
Msg-id 3016112.1648137547@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Get primary key of a table through SPI  (Oskar Stenberg <oskar_stenberg@outlook.com>)
Список pgsql-general
Oskar Stenberg <oskar_stenberg@outlook.com> writes:
> I need to get the primary keys of a few tables for some code that I'm writing in C. I've found out how to do this
throughregular SQL code and I know that I can use that SQL code through the SPI. But I was just wondering if there is a
better/fasterway to get information like this directly through the SPI? I'm imagining something similar to how I can
getfor example the name of the column with the SPI_fname function? Couldn't find anything when I was looking around,
butI might have looked in the wrong place? 

SPI doesn't concern itself with such things.  If you're writing C code,
there are a lot of server internal APIs you can use for catalog inquiries
--- in this case, RelationGetPrimaryKeyIndex() might be just what you
want.  However, you may or may not find those convenient to use, and in
any case they're less stable across major versions than the SPI APIs.
So it's a tradeoff.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: Oskar Stenberg
Дата:
Сообщение: Get primary key of a table through SPI
Следующее
От: Philip Semanchuk
Дата:
Сообщение: Leading comments and client applications