BUG #3718: Unexpected undefined_table error after creating/dropping tables

From: "Dean" <ratq92nomr(at)hotmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3718: Unexpected undefined_table error after creating/dropping tables
Date: 2007-11-04 10:44:54
Message-ID: 200711041044.lA4AisFI035563@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3718
Logged by: Dean
Email address: ratq92nomr(at)hotmail(dot)com
PostgreSQL version: 8.2.5
Operating system: Linux (opensuse 10.3 64-bit) and Windows 2000 SP4
Description: Unexpected undefined_table error after creating/dropping
tables
Details:

If I create a function which relies on the undefined_table exception to test
if a table exists, it does not behave as expected. Here's the simplest
example I could come up with:

CREATE OR REPLACE FUNCTION foo() RETURNS text AS
$$
BEGIN
DELETE FROM bar;
RETURN 'Table exists';
EXCEPTION
WHEN undefined_table THEN
RETURN 'Table missing';
END;
$$ LANGUAGE plpgsql VOLATILE;

DROP TABLE IF EXISTS bar;
SELECT foo();
CREATE TABLE bar(dummy int);
SELECT foo();
DROP TABLE bar;
SELECT foo();
CREATE TABLE bar(dummy int);
SELECT foo();

The 4 calls to foo() return

Table missing
Table exists
Table missing
Table missing

I expect the final call to foo() to return 'Table exists' not 'Table
missing'.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Meskes 2007-11-04 12:36:38 Re: BUG #3706: ecpg regression: "MOVE FORWARD"
Previous Message Tom Lane 2007-11-04 01:54:50 Re: BUG #3716: utf8 crash with replace