Getting NOT NULL constraint from pg_attribute

Поиск
Список
Период
Сортировка
От Wu Ivy
Тема Getting NOT NULL constraint from pg_attribute
Дата
Msg-id FCF4AD17-CBFF-472C-BCAF-B20CBE3C9C3F@gmail.com
обсуждение исходный текст
Ответы Re: Getting NOT NULL constraint from pg_attribute
Список pgsql-hackers
Hi developers,

I’m currently building a Postgres C extension that fetch data from a Postgres table.
Since the table can be large, in order to prevent memory overrun, I use SPI_cursor_fetch to fetch chunks of data. The result rows are saved in SPITupleTable* SPI_tuptable and attributes are saved in SPI_tuptable->tupdesc. 
In order to process my data, I need to get information of column nullability (whether column has NOT NULL constrain). I can get this information by calling:

TupleDesc tupdesc = SPI_tuptable->tupdesc;
bool is_nullable = TupleDescAttr(tupdesc, column_num - 1) -> attnotnull;
However, the result (is_nullable) is always 0, meaning the column does not have NOT NULLl constraint, even for columns that do have the NOT NULL constraint.

Any idea of why is it happening? 
Thanks in advance!

Best,
Ivy

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Fix for REFRESH MATERIALIZED VIEW ownership error message
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: Fix for REFRESH MATERIALIZED VIEW ownership error message