Skip site navigation (1) Skip section navigation (2)

Re: BUG #5776: Unable to create view with parameter in PL/pgsql

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Andrey G(dot)" <andvgal(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5776: Unable to create view with parameter in PL/pgsql
Date: 2010-12-14 20:41:36
Message-ID: AANLkTikTBzV+9X=3=qKJ2bjQNz4H1oVFpcHHwqJktxkF@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, Dec 13, 2010 at 4:28 PM, Andrey G. <andvgal(at)gmail(dot)com> wrote:
> It seems my original test, which also includes the EXECUTE approach,
> has not come to you in full. EXECUTE statement also fails with
> parameter: The test is attached in file.
>
> psql -q < db/db/pgbug_5776.sql
> ERROR:  there is no parameter $1
> LINE 1: CREATE VIEW v4 AS SELECT * FROM t1 WHERE some_field = $1
>                                                               ^
> QUERY:  CREATE VIEW v4 AS SELECT * FROM t1 WHERE some_field = $1
> CONTEXT:  PL/pgSQL function "bug_create_tmp_view_exec_test" line 3 at
> EXECUTE statement

Yeah, parameter substitution doesn't work in this case.  You could
however build up a string with quote_identifier() and then EXECUTE the
resulting string.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

pgsql-bugs by date

Next:From: Robert HaasDate: 2010-12-14 20:44:47
Subject: Re: BUG #5779: Large INSERT transaction with FOREIGN KEY constraints exhausts available RAM
Previous:From: Robert HaasDate: 2010-12-14 20:40:23
Subject: Re: Problems with max_connections parameter

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group