Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression - Mailing list pgsql-sql

From Tom Lane
Subject Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression
Date
Msg-id 8064.1170948745@sss.pgh.pa.us
Whole thread Raw
In response to Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression  (Michael Fuhr <mike@fuhr.org>)
List pgsql-sql
Michael Fuhr <mike@fuhr.org> writes:
> Using separate calls to SPI_exec() works.  Using a single call to
> SPI_exec() works if the index is on (t) instead of (lower(t)):

> SPI_exec("CREATE TABLE foo (t text); CREATE INDEX foo_idx ON foo (t)", 0);

It's only by chance that it works in that case: the current coding of
transformIndexStmt happens not to try to touch the underlying table
if there aren't any expressions to analyze.  You can make a large number
of variants that will fail, eg, create the table and try to insert into
it in one command string.

My advice is not to try to execute multiple commands in the same EXECUTE
string --- if we were going to do anything to "fix" this, I think it
would be along the lines of enforcing that advice.  Trying to make the
world safe for it doesn't sound productive.
        regards, tom lane


pgsql-sql by date:

Previous
From: Adrien Lebre
Date:
Subject: unsubscribe
Next
From: Michael Fuhr
Date:
Subject: Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression