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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

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