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

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Greg Wittel <gwittel(at)proofpoint(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression
Date: 2007-02-08 14:14:33
Message-ID: 20070208141433.GD24069@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Fuhr wrote:
> On Wed, Feb 07, 2007 at 02:43:13PM -0800, Greg Wittel wrote:
> > I'm having a strange problem with a PL/PGSQL query that executes some
> > dynamic SQL code. The code basically creates a dynamically named table,
> > some indexes, etc.
> >
> > The problem seems to be the an index expression. If I remove it and do a
> > plain index on the column, all works correctly. If I keep it, I get a
> > "relation does not exist" error.
>
> The error appears to happen for anything that uses SPI. A C function
> that executes the following fails with the same error:
>
> SPI_exec("CREATE TABLE foo (t text); CREATE INDEX foo_idx ON foo (lower(t))", 0);

Hmm, are we short of a CommandCounterIncrement in the middle of both
commands? Does the same error show up if you do

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

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Wilkinson, Jim 2007-02-08 14:45:26 unsubscribe
Previous Message Susan Evans 2007-02-08 13:36:10 unsubscribe