Re: ON SELECT rule on a table without columns

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ON SELECT rule on a table without columns
Date: 2019-02-11 10:09:03
Message-ID: CAE9k0PnC8iR_r=J2DMOkpigC4LKQAWijtmTZbVb1gpVLBb7NMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 9, 2019 at 12:20 AM Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> wrote:
>
> On Fri, Feb 8, 2019 at 11:32 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> writes:
> > > Attached is the patch that allows us to create view on a table without
> > > columns. I've also added some test-cases for it in create_view.sql.
> > > Please have a look and let me know your opinion.
> >
> > Haven't read the patch, but a question seems in order here: should
> > we regard this as a back-patchable bug fix? The original example
> > shows that it's possible to create a zero-column view in existing
> > releases, which I believe would then lead to dump/reload failures.
> > So that seems to qualify as a bug not just a missing feature.
> > On the other hand, given the lack of field complaints, maybe it's
> > not worth the trouble to back-patch. I don't have a strong
> > opinion either way.
> >
>
> In my opinion, this looks like a bug fix that needs to be back ported,
> else, we might encounter dump/restore failure in some cases, like the
> one described in the first email.
>
> > BTW, has anyone checked on what the matview code paths will do?
> > Or SELECT INTO?
> >
>
> I just checked on that and found that both mat view and SELECT INTO
> statement works like CREATE TABLE AS command and it doesn't really
> care about the target list of the source table unlike normal views
> which would error out when the source table has no columns.
>

Added the regression test-cases for mat views and SELECT INTO
statements in the attached patch. Earlier patch just had the
test-cases for normal views along with the fix.

Andres, Tom, Please have a look into the attached patch and let me
know if I'm still missing something. Thank you.

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

Attachment Content-Type Size
allow-create-view-on-table-without-columns-v2.patch text/x-patch 4.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-02-11 10:21:56 Re: ON SELECT rule on a table without columns
Previous Message Peter Eisentraut 2019-02-11 09:59:20 Re: pgsql: Restrict the use of temporary namespace in two-phase transaction