Re: in C trigger function find out if column is part of primary key

Поиск
Список
Период
Сортировка
От Marko Kreen
Тема Re: in C trigger function find out if column is part of primary key
Дата
Msg-id 20130401072510.GA25503@gmail.com
обсуждение исходный текст
Ответ на in C trigger function find out if column is part of primary key  ("Enke, Dr., Michael" <michael.enke@wincor-nixdorf.com>)
Список pgsql-general
On Mon, Apr 01, 2013 at 12:06:25AM +0200, Enke, Dr., Michael wrote:
> 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?

Simpler and probably even faster approach would be to do
catalog lookup via SPI and then cache the result.

The trick here is to get cache invalidation right,
so on any table change cache is refreshed.

You can use PgQ triggers as example:

  https://github.com/markokr/skytools/blob/master/sql/pgq/triggers/common.c

It implements various unrelated features, but basics are in
find_table_info() which loads cached data and relcache_reset_cb()
which invalidates.

--
marko



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

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: Using varchar primary keys.
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Problem with pg_basebackup and streaming replication. (9.2.3 / win64)