Re: Can't use WITH in a PERFORM query in PL/pgSQL? - Mailing list pgsql-bugs

From Robert Haas
Subject Re: Can't use WITH in a PERFORM query in PL/pgSQL?
Date
Msg-id CA+TgmoazonH3XsKwCO1-MSpd+YnT48TpzcHjEJRJQDjkY1Y-AA@mail.gmail.com
Whole thread Raw
In response to Re: Can't use WITH in a PERFORM query in PL/pgSQL?  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Can't use WITH in a PERFORM query in PL/pgSQL?  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-bugs
On Tue, Sep 6, 2011 at 1:43 PM, Bruce Momjian <bruce@momjian.us> wrote:
> Well, this problem isn't isolated to WITH queries:
>
> =A0 =A0 =A0 =A0test=3D> do
> =A0 =A0 =A0 =A0$$begin
> =A0 =A0 =A0 =A0perform(
> =A0 =A0 =A0 =A0select 1 UNION ALL select 1
> =A0 =A0 =A0 =A0);
> =A0 =A0 =A0 =A0end$$;
> =A0 =A0 =A0 =A0ERROR: =A0more than one row returned by a subquery used as=
 an expression
>
> =A0 =A0 =A0 =A0test=3D> do
> =A0 =A0 =A0 =A0$$begin
> =A0 =A0 =A0 =A0perform(
> =A0 =A0 =A0 =A0select relname from pg_class
> =A0 =A0 =A0 =A0);
> =A0 =A0 =A0 =A0end$$;
> =A0 =A0 =A0 =A0ERROR: =A0more than one row returned by a subquery used as=
 an expression
>

Based on previous experience with PL/pgsql, my understanding is that
PL/pgsql basically replaces "perform" with "select" to get the query
that it actually runs.  You'd get the same error from:

rhaas=3D# select (select relname from pg_class);
ERROR:  more than one row returned by a subquery used as an expression

I've never really liked this behavior, but I don't have a clear idea
what to do about it.

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

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: BUG #6215: ODBC - ovelflow with the OIDs - Large Objects
Next
From: Robert Haas
Date:
Subject: Re: BUG #5944: COPY FROM doesn't work with international characters