Re: BUG #5776: Unable to create view with parameter in PL/pgsql - Mailing list pgsql-bugs

From Robert Haas
Subject Re: BUG #5776: Unable to create view with parameter in PL/pgsql
Date
Msg-id AANLkTikTBzV+9X=3=qKJ2bjQNz4H1oVFpcHHwqJktxkF@mail.gmail.com
Whole thread Raw
In response to Re: BUG #5776: Unable to create view with parameter in PL/pgsql  ("Andrey G." <andvgal@gmail.com>)
Responses Re: BUG #5776: Unable to create view with parameter in PL/pgsql  ("Andrey G." <andvgal@gmail.com>)
List pgsql-bugs
On Mon, Dec 13, 2010 at 4:28 PM, Andrey G. <andvgal@gmail.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:=A0 there is no parameter $1
> LINE 1: CREATE VIEW v4 AS SELECT * FROM t1 WHERE some_field =3D $1
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ^
> QUERY:=A0 CREATE VIEW v4 AS SELECT * FROM t1 WHERE some_field =3D $1
> CONTEXT:=A0 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.

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

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: Problems with max_connections parameter
Next
From: Robert Haas
Date:
Subject: Re: BUG #5779: Large INSERT transaction with FOREIGN KEY constraints exhausts available RAM