pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Thom Brown <thom@linux.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: Dropped index on table preventing rule creation
Date: Tue, 13 Sep 2011 16:21:55 -0500
Message-ID: <C85619BB-735B-4821-9476-F2F489FD832C@gmail.com> (raw)
In-Reply-To: <28537.1315715201@sss.pgh.pa.us>
References: <CAA-aLv7sszmU+Fz-xLo6cOiASUiX0mCRwAMF2FB=2j-5MKqb+A@mail.gmail.com>
	<28537.1315715201@sss.pgh.pa.us>

On Sep 10, 2011, at 11:26 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thom Brown <thom@linux.com> writes:
>> I don't use rules, but in a bit of experimentation on Git master, I
>> discovered the following behaviour:
> 
>> CREATE TABLE test1 (id serial primary key, things text);
>> CREATE TABLE test2 (id serial primary key, things text);
>> ALTER TABLE test1 DROP CONSTRAINT test1_pkey;
>> ALTER TABLE test2 DROP CONSTRAINT test2_pkey;
>> CREATE RULE "_RETURN" AS ON SELECT TO test1 DO INSTEAD select * from test2;
> 
>> This produces the error message: could not convert table "test1" to a
>> view because it has indexes
> 
> IIRC, this is because the check is just checking relhasindex.  You
> should be able to recover and create the rule if you VACUUM the table.
> 
> We could no doubt add more code to make that more transparent, but I
> don't see the point.  The entire exercise of converting a table to a
> view is only meant to support loading of pg_dump output from versions
> that are probably ten years obsolete at this point.  We don't even
> document that you can do the above, do we?
> 
> (IOW, rather than "fix" this I'd prefer to rip out the code altogether.
> But maybe we should wait a couple more years for that.)

IIRC, it's not dead code. I think you can still generate such a dump if you use CREATE OR REPLACE VIEW to manufacture a pair of mutually recursive views.

Now we should probably disallow that, but we currently don't.

...Robert


view thread (7+ messages)  latest in thread

Message-ID: <C85619BB-735B-4821-9476-F2F489FD832C@gmail.com>
Permalink:  ../C85619BB-735B-4821-9476-F2F489FD832C@gmail.com/
Also on:    postgresql.org/message-id/C85619BB-735B-4821-9476-F2F489FD832C@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: robertmhaas@gmail.com, tgl@sss.pgh.pa.us, thom@linux.com
  Subject: Re: Dropped index on table preventing rule creation
  In-Reply-To: <C85619BB-735B-4821-9476-F2F489FD832C@gmail.com>
  References: <CAA-aLv7sszmU+Fz-xLo6cOiASUiX0mCRwAMF2FB=2j-5MKqb+A@mail.gmail.com> <28537.1315715201@sss.pgh.pa.us> <C85619BB-735B-4821-9476-F2F489FD832C@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox