X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 54C9352885 for ; Fri, 24 Jun 2005 14:44:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97304-02 for ; Fri, 24 Jun 2005 17:44:10 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0560E5284D for ; Fri, 24 Jun 2005 14:44:08 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j5OHi50e079907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Jun 2005 11:44:07 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j5OHi53h046496; Fri, 24 Jun 2005 11:44:05 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j5OHi5VK046495; Fri, 24 Jun 2005 11:44:05 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 24 Jun 2005 11:44:05 -0600 From: Michael Fuhr To: =?iso-8859-1?Q?K=D6PFERL?= Robert Cc: PgSQL - SQL Subject: Re: Converting TBL->View complaining about indexes Message-ID: <20050624174404.GA46407@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.108 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200506/294 X-Sequence-Number: 21895 On Fri, Jun 24, 2005 at 05:49:02PM +0200, KÖPFERL Robert wrote: > > ERROR: could not convert table "smsMessagesrewtet" to a view because it has > indexes See the comments for pg_class.relhasindex: http://www.postgresql.org/docs/8.0/static/catalog-pg-class.html "True if this is a table and it has (or recently had) any indexes. This is set by CREATE INDEX, but not cleared immediately by DROP INDEX. VACUUM clears relhasindex if it finds the table has no indexes." test=> CREATE TABLE foo (x integer); CREATE TABLE test=> CREATE INDEX foo_x_idx ON foo (x); CREATE INDEX test=> DROP INDEX foo_x_idx; DROP INDEX test=> CREATE RULE "_RETURN" AS ON SELECT TO foo test-> DO INSTEAD SELECT 123::integer AS x; ERROR: could not convert table "foo" to a view because it has indexes test=> VACUUM foo; VACUUM test=> CREATE RULE "_RETURN" AS ON SELECT TO foo test-> DO INSTEAD SELECT 123::integer AS x; CREATE RULE test=> SELECT * FROM foo; x ----- 123 (1 row) test=> \d foo View "public.foo" Column | Type | Modifiers --------+---------+----------- x | integer | View definition: SELECT 123 AS x; -- Michael Fuhr http://www.fuhr.org/~mfuhr/