Re: Converting TBL->View complaining about indexes

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: KÖPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>
Cc: PgSQL - SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Converting TBL->View complaining about indexes
Date: 2005-06-24 17:44:05
Message-ID: 20050624174404.GA46407@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitri Bichko 2005-06-24 23:01:56 Default index space?
Previous Message KÖPFERL Robert 2005-06-24 15:49:02 Converting TBL->View complaining about indexes