Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B507B9FB27D for ; Thu, 8 Feb 2007 11:33:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 35898-01-4 for ; Thu, 8 Feb 2007 11:32:24 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B5CB99FB2D7 for ; Thu, 8 Feb 2007 11:32:30 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l18FWPBc008065; Thu, 8 Feb 2007 10:32:26 -0500 (EST) To: Michael Fuhr cc: Greg Wittel , pgsql-sql@postgresql.org Subject: Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression In-reply-to: <20070208150746.GA77230@winnie.fuhr.org> References: <45CA5601.1090007@proofpoint.com> <20070208112331.GA75899@winnie.fuhr.org> <20070208141433.GD24069@alvh.no-ip.org> <20070208150746.GA77230@winnie.fuhr.org> Comments: In-reply-to Michael Fuhr message dated "Thu, 08 Feb 2007 08:07:47 -0700" Date: Thu, 08 Feb 2007 10:32:25 -0500 Message-ID: <8064.1170948745@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/89 X-Sequence-Number: 27423 Michael Fuhr 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