Re: Converting TBL->View complaining about indexes - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: Converting TBL->View complaining about indexes
Date
Msg-id 20050624174404.GA46407@winnie.fuhr.org
Whole thread Raw
In response to Converting TBL->View complaining about indexes  (KÖPFERL Robert <robert.koepferl@sonorys.at>)
List pgsql-sql
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/


pgsql-sql by date:

Previous
From: KÖPFERL Robert
Date:
Subject: Converting TBL->View complaining about indexes
Next
From: "Dmitri Bichko"
Date:
Subject: Default index space?