Re: [SQL] Database views metadata always nullable columns

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [SQL] Database views metadata always nullable columns
Дата
Msg-id CAKFQuwYz2CJ722HJ0J4RY5WT8V-q+EdTC4EFfTKGQMbbqn2oVw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [SQL] Database views metadata always nullable columns  (basuraspam - <basuraspam0@gmail.com>)
Список pgsql-sql
On Fri, Jun 2, 2017 at 8:33 AM, basuraspam - <basuraspam0@gmail.com> wrote:
Hi Tom,
   I agree, it would be better including an example. The "issue" I reported is with database views not with tables. Taking your example as base:

​Since view columns cannot be specified NOT NULL (or have their own constraints for that matter) reporting false here is accurate.​

That we don't parse the view and attempt to derive constraints from the underlying query and tables, if any, is unsurprising.

i.e., should "CREATE VIEW test (col1) AS SELECT '1'::col1; 

report NOT NULL for test.col1?

About the only SQL-visible automated way to do what you describe, to some level of accuracy, is to EXPLAIN the view and extract the tables and columns and look them up.  That will fail for, say, SELECT * FROM tbl1 LEFT JOIN tbl2, when looking at properties of columns from tbl2.

David J.

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

Предыдущее
От: basuraspam -
Дата:
Сообщение: Re: [SQL] Database views metadata always nullable columns
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Database views metadata always nullable columns