Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C04DB9FB33B for ; Thu, 8 Feb 2007 10:15:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 55901-06 for ; Thu, 8 Feb 2007 10:14:50 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from lists.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id 3166E9FB33A for ; Thu, 8 Feb 2007 10:14:49 -0400 (AST) Received: from perhan.alvh.no-ip.org (200-126-100-50.bk7-dsl.surnet.cl [200.126.100.50]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id l18EEYsl010691; Thu, 8 Feb 2007 06:14:35 -0800 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 1C02C7DCA; Thu, 8 Feb 2007 11:14:33 -0300 (CLST) Date: Thu, 8 Feb 2007 11:14:33 -0300 From: Alvaro Herrera 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 Message-ID: <20070208141433.GD24069@alvh.no-ip.org> Mail-Followup-To: Michael Fuhr , Greg Wittel , pgsql-sql@postgresql.org References: <45CA5601.1090007@proofpoint.com> <20070208112331.GA75899@winnie.fuhr.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070208112331.GA75899@winnie.fuhr.org> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: ClamAV version 0.88.5, clamav-milter version 0.88.5 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Thu, 08 Feb 2007 06:14:41 -0800 (PST) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/85 X-Sequence-Number: 27419 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