Re: [HACKERS] CREATE OR REPLACE VIEW bug - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: [HACKERS] CREATE OR REPLACE VIEW bug
Date
Msg-id CAEZATCU+MtAc=OHKP3s3r-abK9gV8VM=4uE+8ZtiuTnb--V7RA@mail.gmail.com
Whole thread Raw
In response to [HACKERS] CREATE OR REPLACE VIEW bug  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: [HACKERS] CREATE OR REPLACE VIEW bug  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 17 December 2016 at 15:42, Dean Rasheed <dean.a.rasheed@gmail.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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pg_authid.rolpassword format (was Re: [HACKERS] Passwordidentifiers, protocol aging and SCRAM protocol)
Next
From: Corey Huinker
Date:
Subject: Re: [HACKERS] PSQL commands: \quit_if, \quit_unless