Re: Getting NOT NULL constraint from pg_attribute
| От | Tom Lane | 
|---|---|
| Тема | Re: Getting NOT NULL constraint from pg_attribute | 
| Дата | |
| Msg-id | 9894.1534554129@sss.pgh.pa.us обсуждение исходный текст | 
| Ответ на | Getting NOT NULL constraint from pg_attribute (Wu Ivy <ivywuyzl@gmail.com>) | 
| Ответы | Re: Getting NOT NULL constraint from pg_attribute | 
| Список | pgsql-hackers | 
Wu Ivy <ivywuyzl@gmail.com> writes:
> 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
resultrows 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).
Ican 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
columnsthat do have the NOT NULL constraint. 
The output columns of a SELECT query are never marked nullable, regardless
of what the source data was.
            regards, tom lane
		
	В списке pgsql-hackers по дате отправления: