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

2011-10-20 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 SELECT

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

2011-10-20 Thread Pavel Stehule
2011/10/20 Valentine Gogichashvili val...@gmail.com: 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

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 pavel.steh...@gmail.com 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

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

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

2011-10-20 Thread Pavel Stehule
2011/10/20 Merlin Moncure mmonc...@gmail.com: On Thu, Oct 20, 2011 at 2:28 AM, Pavel Stehule pavel.steh...@gmail.com 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

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

2011-10-20 Thread Tom Lane
Valentine Gogichashvili val...@gmail.com 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

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

2011-10-20 Thread Pavel Stehule
2011/10/20 Tom Lane t...@sss.pgh.pa.us: Valentine Gogichashvili val...@gmail.com 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

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

2011-10-20 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com 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

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 t...@sss.pgh.pa.us wrote: Pavel Stehule pavel.steh...@gmail.com 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

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 br...@momjian.us 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

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 robertmh...@gmail.com wrote: On Tue, Sep 6, 2011 at 1:43 PM, Bruce Momjian br...@momjian.us wrote: Well, this problem isn't isolated to WITH queries:        test= do        $$begin        perform(        select 1 UNION ALL select 1        );    

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

2011-10-19 Thread Tom Lane
Merlin Moncure mmonc...@gmail.com 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 ...

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

2011-10-19 Thread Kevin Grittner
Tom Lane t...@sss.pgh.pa.us 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

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

2011-10-19 Thread Tom Lane
I wrote: Merlin Moncure mmonc...@gmail.com 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

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 Moncuremmonc...@gmail.com 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.

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

2011-10-19 Thread Pavel Stehule
2011/10/19 Tom Lane t...@sss.pgh.pa.us: I wrote: Merlin Moncure mmonc...@gmail.com 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.

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

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( with A as (select

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-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 subscription:

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 pavel.steh...@gmail.com 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' statement.

[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

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, depst...@alliedtesting.com 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