index on function confuses drop table cascade on child

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: index on function confuses drop table cascade on child
Date: 2010-11-01 20:43:41
Message-ID: 4CCEE02D020000250003708E@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Checkout from HEAD this morning, no modifications. Did make
distclean and fresh build to ensure no problems caused by mixed
build. 32 bit kubuntu on single drive dual core workstation. Fresh
initdb. Default configuration.

postgres=# create database bug;
CREATE DATABASE
postgres=# \c bug
You are now connected to database "bug" as user "kgrittn".
bug=# create table person (namel text not null);
CREATE TABLE
bug=# create table t (id int primary key) inherits (person);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"t_pkey" for table "t"
CREATE TABLE
bug=# create or replace function sname(person) returns text
bug-# language sql immutable as $$select upper($1.namel)$$;
CREATE FUNCTION
bug=# create index t_sname on t (sname(t));
CREATE INDEX
bug=# select oid, relname from pg_class
bug-# where relname in ('person','t');
oid | relname
-------+---------
16385 | person
16391 | t
(2 rows)

bug=# drop table t cascade;
DROP TABLE

[so far, behavior is as expected]

bug=# drop table person cascade;
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to function sname(person)
drop cascades to index t_sname
ERROR: could not open relation with OID 16391
bug=# create table person (namel text not null);
ERROR: relation "person" already exists
bug=# create table t (id int primary key) inherits (person);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"t_pkey" for table "t"
CREATE TABLE
bug=# create or replace function sname(person) returns text
bug-# language sql immutable as $$select upper($1.namel)$$;
CREATE FUNCTION
bug=# create index t_sname on t (sname(t));
ERROR: relation "t_sname" already exists
bug=# select oid, relname from pg_class
bug-# where relname in ('person','t');
oid | relname
-------+---------
16385 | person
16401 | t
(2 rows)

All is fine if the t_searchname index is left out or the t table
defines all columns directly rather than inheriting them from
person. Similar failure if person is dropped first or on the same
statement as t.

-Kevin

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2010-11-01 21:45:15 Re: BUG #5739: postgresql will not start
Previous Message Kim Garren 2010-11-01 19:29:56 BUG #5739: postgresql will not start