]> granicus.if.org Git - postgresql/commit
Fix CREATE VIEW to allow zero-column views.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Feb 2019 17:37:31 +0000 (12:37 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Feb 2019 17:37:31 +0000 (12:37 -0500)
commita32ca7883629f6b1fbbf0bd2e2aa11ec86edb6b3
tree3dbf75427fab9df28f16d28b8420c4d2b6006326
parent290e3b77fde9cd063e20d96b1241566a429943de
Fix CREATE VIEW to allow zero-column views.

We should logically have allowed this case when we allowed zero-column
tables, but it was overlooked.

Although this might be thought a feature addition, it's really a bug
fix, because it was possible to create a zero-column view via
the convert-table-to-view code path, and then you'd have a situation
where dump/reload would fail.  Hence, back-patch to all supported
branches.

Arrange the added test cases to provide coverage of the related
pg_dump code paths (since these views will be dumped and reloaded
during the pg_upgrade regression test).  I also made them test
the case where pg_dump has to postpone the view rule into post-data,
which disturbingly had no regression coverage before.

Report and patch by Ashutosh Sharma (test case by me)

Discussion: https://postgr.es/m/CAE9k0PkmHdeSaeZt2ujnb_cKucmK3sDDceDzw7+d5UZoNJPYOg@mail.gmail.com
src/backend/commands/view.c
src/test/regress/expected/create_view.out
src/test/regress/expected/rules.out
src/test/regress/expected/sanity_check.out
src/test/regress/sql/create_view.sql