Getting NOT NULL constraint from pg_attribute - Mailing list pgsql-hackers

From Wu Ivy
Subject Getting NOT NULL constraint from pg_attribute
Date
Msg-id FCF4AD17-CBFF-472C-BCAF-B20CBE3C9C3F@gmail.com
Whole thread Raw
Responses Re: Getting NOT NULL constraint from pg_attribute
List 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 by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Fix for REFRESH MATERIALIZED VIEW ownership error message
Next
From: Dave Cramer
Date:
Subject: Re: Fix for REFRESH MATERIALIZED VIEW ownership error message