Обсуждение: Converting TBL->View complaining about indexes

Поиск
Список
Период
Сортировка

Converting TBL->View complaining about indexes

От
KÖPFERL Robert
Дата:
Hi, 
I'm currently trying to make a table (where many fcns depend on) become a
view.

Thus I did a _truncate_ and lots of _alter table drop constraint_ and  _drop
index_

and then
CREATE OR REPLACE RULE "_RETURN" AS  ON SELECT TO "smsMessagesrewtet"  DO INSTEAD 
SELECT  "MessageID",.....


Postgres keeps returning 
ERROR:  could not convert table "smsMessagesrewtet" to a view because it has
indexes


However I am sure there are no indexes nor PK or any constraints. What else
could it be?


Thanks


Re: Converting TBL->View complaining about indexes

От
Michael Fuhr
Дата:
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/