Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Pavel Stehule
2011/10/20 Tom Lane : > Pavel Stehule writes: >> I didn't design a PERFORM statement. There is two views - somebody >> from sybase's family know so SELECT without into is forwarded to >> client. This functionality is missing on Oracle's family. Is true so >> PERFORM statement is strange,  but mayb

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Merlin Moncure
On Thu, Oct 20, 2011 at 3:01 PM, Tom Lane wrote: > Pavel Stehule writes: >> I didn't design a PERFORM statement. There is two views - somebody >> from sybase's family know so SELECT without into is forwarded to >> client. This functionality is missing on Oracle's family. Is true so >> PERFORM sta

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Tom Lane
Pavel Stehule writes: > I didn't design a PERFORM statement. There is two views - somebody > from sybase's family know so SELECT without into is forwarded to > client. This functionality is missing on Oracle's family. Is true so > PERFORM statement is strange, but maybe it's open door for sybase'

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Pavel Stehule
2011/10/20 Tom Lane : > Valentine Gogichashvili writes: >> And, ernestly, if it were useless to have SELECT without INTO in plpgsql, >> there also would be no PERFORM command in plpgsql... > > Precisely.  Pavel's claim is nonsense.  The only real question is how > useful is it to call it PERFORM i

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Tom Lane
Valentine Gogichashvili writes: > And, ernestly, if it were useless to have SELECT without INTO in plpgsql, > there also would be no PERFORM command in plpgsql... Precisely. Pavel's claim is nonsense. The only real question is how useful is it to call it PERFORM instead of SELECT.

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Pavel Stehule
2011/10/20 Merlin Moncure : > On Thu, Oct 20, 2011 at 2:28 AM, Pavel Stehule > wrote: >>> >>> it would be really a good idea to allow SELECT without INTO in plpgsql. >> >> SELECT without INTO is useless in plpgsql - because you have to drop result. > > not if you're calling a function: > select f

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Valentine Gogichashvili
> > > >> > >> it would be really a good idea to allow SELECT without INTO in plpgsql. > > > > SELECT without INTO is useless in plpgsql - because you have to drop > result. > > not if you're calling a function: > select func(); > > or calling bunch of functions: SELECT func(param) FROM some_su

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Merlin Moncure
On Thu, Oct 20, 2011 at 2:28 AM, Pavel Stehule wrote: >> >> it would be really a good idea to allow SELECT without INTO in plpgsql. > > SELECT without INTO is useless in plpgsql - because you have to drop result. not if you're calling a function: select func(); merlin -- Sent via pgsql-bugs ma

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-20 Thread Pavel Stehule
2011/10/20 Valentine Gogichashvili : >> >> I suppose you could argue that selecting a value and implicitly throwing >> it away is confusing to novices, but on the other hand I've seen a whole >> lot of novices confused by the need to write PERFORM instead of SELECT. >> I think it wouldn't be an unr

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Valentine Gogichashvili
> > > I suppose you could argue that selecting a value and implicitly throwing > it away is confusing to novices, but on the other hand I've seen a whole > lot of novices confused by the need to write PERFORM instead of SELECT. > I think it wouldn't be an unreasonable thing to just interpret a SELE

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Pavel Stehule
2011/10/19 Tom Lane : > I wrote: >> Merlin Moncure writes: >>> The point being, how do I convert any query to a non WITH variant so >>> it can be PERFORM'd?  Anyways, I always thought having to do perform >>> at all was pretty weak sauce -- not sure why it's required. > >> Possibly it was an Oracl

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Craig Ringer
On 10/20/2011 05:23 AM, Tom Lane wrote: I wrote: Merlin Moncure writes: The point being, how do I convert any query to a non WITH variant so it can be PERFORM'd? Anyways, I always thought having to do perform at all was pretty weak sauce -- not sure why it's required. Possibly it was an Or

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Tom Lane
I wrote: > Merlin Moncure writes: >> The point being, how do I convert any query to a non WITH variant so >> it can be PERFORM'd? Anyways, I always thought having to do perform >> at all was pretty weak sauce -- not sure why it's required. > Possibly it was an Oracle compatibility thing ... anyo

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Kevin Grittner
Tom Lane wrote: > I think it wouldn't be an unreasonable thing to just interpret a > SELECT with no INTO clause as being a PERFORM (ie execute and > discard results). FWIW, that would probably confuse people coming from MS SQL Server or Sybase ASE, since doing that in Transact-SQL would return

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Tom Lane
Merlin Moncure writes: > The point being, how do I convert any query to a non WITH variant so > it can be PERFORM'd? Anyways, I always thought having to do perform > at all was pretty weak sauce -- not sure why it's required. Possibly it was an Oracle compatibility thing ... anyone know PL/SQL w

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Merlin Moncure
On Wed, Oct 19, 2011 at 7:36 AM, Robert Haas wrote: > On Tue, Sep 6, 2011 at 1:43 PM, Bruce Momjian wrote: >> Well, this problem isn't isolated to WITH queries: >> >>        test=> do >>        $$begin >>        perform( >>        select 1 UNION ALL select 1 >>        ); >>        end$$; >>      

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-10-19 Thread Robert Haas
On Tue, Sep 6, 2011 at 1:43 PM, Bruce Momjian wrote: > Well, this problem isn't isolated to WITH queries: > >        test=> do >        $$begin >        perform( >        select 1 UNION ALL select 1 >        ); >        end$$; >        ERROR:  more than one row returned by a subquery used as an ex

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-09-06 Thread Bruce Momjian
depst...@alliedtesting.com wrote: > Update: It has been suggested to wrap perform around a select like this: > > do > $$begin > perform( > with A as (select 1 as foo) > select foo from A > ); > end$$; > > This won't work if select returns more than one statement: > > do > $$begin > perform( > wi

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-09-06 Thread Bruce Momjian
Added to TODO: Improve PERFORM handling of WITH queries or document limitation --- depst...@alliedtesting.com wrote: > Update: It has been suggested to wrap perform around a select like this: > > do > $$begin > per

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-03-24 Thread Merlin Moncure
On Thu, Mar 24, 2011 at 10:36 AM, Pavel Stehule wrote: > Hello > > why you can do it? > > please, try to RETURN QUERY ... > > Regards > > Pavel Stehule > > >> >> $$begin >> >> perform( >> >> with A as (select generate_series(1,3) as foo) >> >> select foo from A >> >> ); >> >> end$$; This is 'DO'

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-03-24 Thread Pavel Stehule
Hello why you can do it? please, try to RETURN QUERY ... Regards Pavel Stehule > > $$begin > > perform( > > with A as (select generate_series(1,3) as foo) > > select foo from A > > ); > > end$$; > > -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subs

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-03-24 Thread depstein
Update: It has been suggested to wrap perform around a select like this: do $$begin perform( with A as (select 1 as foo) select foo from A ); end$$; This won't work if select returns more than one statement: do $$begin perform( with A as (select generate_series(1,3) as foo) select foo from A );

Re: [BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-03-06 Thread Vik Reykja
On Sun, Mar 6, 2011 at 14:29, wrote: > The only workaround that I can think of is to use a dummy variable to > capture the query result. This has to be done even when the query doesn’t > have a result (as when calling a function returning void). > > > > do > > $$declare > > dummy record; > > begi

[BUGS] Can't use WITH in a PERFORM query in PL/pgSQL?

2011-03-06 Thread depstein
PostgreSQL 9.0.1 It seems that PostgreSQL doesn't understand the WITH construct when used in a PERFORM query inside PL/pgSQL functions and code blocks: Example: do $$begin with A as (select 1 as foo) perform foo from A; end$$; syntax error at or near "perform" do $$begin with A as (select