Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1034AB5DC13 for ; Tue, 13 Sep 2011 18:21:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 66166-06 for ; Tue, 13 Sep 2011 21:21:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id CF8D6B5DC07 for ; Tue, 13 Sep 2011 18:21:38 -0300 (ADT) Received: by gyg10 with SMTP id 10so861674gyg.19 for ; Tue, 13 Sep 2011 14:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=YU3ek9lNqQJgklq1acBU5eutIbBD9UQrUeGubL3bZb4=; b=qsmu5M/zj7WoCrKnQp2MoYhSiNm6AENo4rH1V0s3COCok95cQ/4+LwBavhyIMNoSAk Bx5tcsJvajmXh4yKp5uZNMjNFSmOlUW/tb9uWPAZawu2vjWG3BhV8NWTPZxUu7ReXXI6 AHorSgwlqTH8gyA16O3PQX30d+zoTNF05zPkY= Received: by 10.236.182.66 with SMTP id n42mr36184689yhm.128.1315948898566; Tue, 13 Sep 2011 14:21:38 -0700 (PDT) Received: from [10.5.108.206] (mobile-166-137-141-045.mycingular.net [166.137.141.45]) by mx.google.com with ESMTPS id x65sm2840049yhh.26.2011.09.13.14.21.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Sep 2011 14:21:37 -0700 (PDT) References: <28537.1315715201@sss.pgh.pa.us> In-Reply-To: <28537.1315715201@sss.pgh.pa.us> Mime-Version: 1.0 (iPhone Mail 8A293) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: Cc: Thom Brown , pgsql-bugs X-Mailer: iPhone Mail (8A293) From: Robert Haas Subject: Re: Dropped index on table preventing rule creation Date: Tue, 13 Sep 2011 16:21:55 -0500 To: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, MIME_QP_LONG_LINE=0.001 X-Spam-Level: X-Archive-Number: 201109/72 X-Sequence-Number: 31089 On Sep 10, 2011, at 11:26 PM, Tom Lane wrote: > Thom Brown writes: >> I don't use rules, but in a bit of experimentation on Git master, I >> discovered the following behaviour: >=20 >> 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 test= 2; >=20 >> This produces the error message: could not convert table "test1" to a >> view because it has indexes >=20 > 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. >=20 > 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? >=20 > (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 u= se CREATE OR REPLACE VIEW to manufacture a pair of mutually recursive views.= Now we should probably disallow that, but we currently don't. ...Robert=