Re: CREATE OR REPLACE VIEW bug

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE OR REPLACE VIEW bug
Date: 2016-12-17 20:30:29
Message-ID: CAEZATCU+MtAc=OHKP3s3r-abK9gV8VM=4uE+8ZtiuTnb--V7RA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 17 December 2016 at 15:42, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> It seems that there is a bug in CREATE OR REPLACE VIEW...
>
> DefineView()/DefineVirtualRelation() will need a little re-jigging to
> do things in the required order.

...and the required order for existing views is

1. Add any new columns
2. Add rules to store the new query
3. Update the view options

because 2 will fail if the view's columns don't match the query's columns.

Attached is a patch enforcing this order and adding some comments to
make it clear why the order matters here.

Barring objections I'll back-patch this to 9.4 where WCO was added.

Regards,
Dean

Attachment Content-Type Size
cor-view-bug.patch text/x-diff 6.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2016-12-17 20:39:22 Re: PSQL commands: \quit_if, \quit_unless
Previous Message Robert Haas 2016-12-17 18:59:41 Re: pg_authid.rolpassword format (was Re: Password identifiers, protocol aging and SCRAM protocol)