Re: [HACKERS] Out parameters handling

2009-03-13 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: How much of this pain would go away if we changed over to the arguably correct (as in Or*cle does it that way) scoping for names, wherein the parser first tries to match a name against column names of tables of the current SQL statement, and only failing

Re: [HACKERS] Out parameters handling

2009-03-12 Thread Josh Berkus
How much of this pain would go away if we changed over to the arguably correct (as in Or*cle does it that way) scoping for names, wherein the parser first tries to match a name against column names of tables of the current SQL statement, and only failing that looks to see if they are

Re: [HACKERS] Out parameters handling

2009-03-11 Thread Marko Kreen
On 3/7/09, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. This is a good point. Uglifying the parameter

Re: [HACKERS] Out parameters handling

2009-03-09 Thread Ryan Bradetich
On Sun, Mar 8, 2009 at 4:36 PM, Tom Lane t...@sss.pgh.pa.us wrote: Ryan Bradetich rbradet...@gmail.com writes: This is one of the things I wanted to start looking at for 8.5. My idea was to optionally use : or @ (not sure which is more popular) to specify this token is only a variable. This

Re: [HACKERS] Out parameters handling

2009-03-09 Thread Pavel Stehule
2009/3/9 Ryan Bradetich rbradet...@gmail.com: On Sun, Mar 8, 2009 at 4:36 PM, Tom Lane t...@sss.pgh.pa.us wrote: Ryan Bradetich rbradet...@gmail.com writes: This is one of the things I wanted to start looking at for 8.5. My idea was to optionally use : or @ (not sure which is more popular) to

Re: [HACKERS] Out parameters handling

2009-03-08 Thread Asko Oja
On Sat, Mar 7, 2009 at 9:29 PM, Dimitri Fontaine dfonta...@hi-media.comwrote: In fact, maybe a new option to set the OUT parameters prefix to use from within the function body would do? Le 7 mars 09 à 19:56, Dimitri Fontaine a écrit : CREATE OR REPLACE FUNCTION test_out ( IN a integer,

Re: [HACKERS] Out parameters handling

2009-03-08 Thread Ryan Bradetich
Hello Robert, I have been bitten by this problem many times as well. I wonder whether it would be possible to make PL/pgsql take :foo to mean the parameter named foo, and then provide an option to make that THE ONLY WAY to refer to the parameter foo.  For backward-compatibility, and

Re: [HACKERS] Out parameters handling

2009-03-08 Thread Tom Lane
Ryan Bradetich rbradet...@gmail.com writes: This is one of the things I wanted to start looking at for 8.5. My idea was to optionally use : or @ (not sure which is more popular) to specify this token is only a variable. This whole line of thought is really a terrible idea IMHO. plpgsql is

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Robert Haas
On Fri, Mar 6, 2009 at 8:44 PM, Josh Berkus j...@agliodbs.com wrote: Robert, Thing is, anybody can institute their own naming convention.  I've long used v_ as a prefix.  Allowing : would save me some keystrokes, but that's about it. --Josh True... but there doesn't seem to be any shortage

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Rod Taylor
It wouldn't be so bad if you could assign internal and external column names. Within the function you call the column v_foo but the caller of the function receives column foo instead. OUT v_foo varchar AS foo Another alternative is requiring a prefix like plout for the replacement to occur: (

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Robert Haas
On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. Within the function you call the column v_foo but the caller of the function receives column foo instead. OUT v_foo varchar AS foo Another

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. This is a good point. Uglifying the parameter names is sort of OK for input parameters, but is much

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Pavel Stehule
2009/3/7 Robert Haas robertmh...@gmail.com: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. Within the function you call the column v_foo but the caller of the function receives column foo

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Gregory Stark
Tom Lane t...@sss.pgh.pa.us writes: Robert Haas robertmh...@gmail.com writes: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. This is a good point. Uglifying the parameter names is sort of

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Tom Lane
Gregory Stark st...@enterprisedb.com writes: I'm not sure that's any better. The case where I've run into this is when I have something like: balance := new value UPDATE tab SET balance = balance In that case the only way we could get it right is if we default to the local variable but

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Rod Taylor
actually - function name should be used as label now. This code is working: Not helpful for me. The most typical conflict I have is actually the OUT parameter and table name, not a column of the table. Really don't want to prefix all tables with a hardcoded schema or do variable substitution

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Pavel Stehule
Hello 2009/3/7 Tom Lane t...@sss.pgh.pa.us: Gregory Stark st...@enterprisedb.com writes: I'm not sure that's any better. The case where I've run into this is when I have something like:  balance := new value  UPDATE tab SET balance = balance In that case the only way we could get it right

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Rod Taylor
On Sat, Mar 7, 2009 at 11:32 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. This is a good point.  Uglifying

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Pavel Stehule
Hello 2009/3/7 Rod Taylor rod.tay...@gmail.com: actually - function name should be used as label now. This code is working: Not helpful for me. The most typical conflict I have is actually the OUT parameter and table name, not a column of the table. This conflict I never meet. And I afraid

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Dimitri Fontaine
Hi, Le 7 mars 09 à 02:44, Josh Berkus a écrit : Thing is, anybody can institute their own naming convention. I've long used v_ as a prefix. Allowing : would save me some keystrokes, but that's about it. What I usually do in those cases is abusing the ALIAS option of DECLARE (because as

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Dimitri Fontaine
In fact, maybe a new option to set the OUT parameters prefix to use from within the function body would do? Le 7 mars 09 à 19:56, Dimitri Fontaine a écrit : CREATE OR REPLACE FUNCTION test_out ( IN a integer, IN b integer, OUT s integer ) RETURNS setof integer SET out_prefix TO 'v_'

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Tom Lane
Dimitri Fontaine dfonta...@hi-media.com writes: I'd sure be happy not having to do it explicitly, but schema-style prefixing has the drawback of needing to avoid any user defined schema. No, not really, because it'd be the wrong number of naming levels. Assuming that we were to switch to

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Robert Haas
On Sat, Mar 7, 2009 at 11:32 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor rod.tay...@gmail.com wrote: It wouldn't be so bad if you could assign internal and external column names. This is a good point.  Uglifying

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: I think that would definitely be an improvement. Would that mean that in a query like the following: SELECT t.id FROM test t WHERE t.id = 17 ...it wouldn't consider replacing t? That all by itself would be an improvement... It's already the case

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Robert Haas
On Sat, Mar 7, 2009 at 5:08 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: I think that would definitely be an improvement.  Would that mean that in a query like the following: SELECT t.id FROM test t WHERE t.id = 17 ...it wouldn't consider replacing t?  

Re: [HACKERS] Out parameters handling

2009-03-07 Thread Pavel Stehule
2009/3/7 Dimitri Fontaine dfonta...@hi-media.com: In fact, maybe a new option to set the OUT parameters prefix to use from within the function body would do? Le 7 mars 09 à 19:56, Dimitri Fontaine a écrit : CREATE OR REPLACE FUNCTION test_out (  IN  a integer,  IN  b integer,  OUT s

[HACKERS] Out parameters handling

2009-03-06 Thread Asko Oja
Hi It was one of my worst Friday's finding out that this brain dead implementation of out parameters had been part of fuck up again. This time we did notice it two days too late. I wish for a way to use out parameters in functions only through some predefined prefix like in triggers new and old.

Re: [HACKERS] Out parameters handling

2009-03-06 Thread Jonah H. Harris
On Fri, Mar 6, 2009 at 4:29 PM, Asko Oja asc...@gmail.com wrote: It was one of my worst Friday's finding out that this brain dead implementation of out parameters had been part of fuck up again. :) This time we did notice it two days too late. I wish for a way to use out parameters in

Re: [HACKERS] Out parameters handling

2009-03-06 Thread Kevin Grittner
Jonah H. Harris jonah.har...@gmail.com wrote: On Fri, Mar 6, 2009 at 4:29 PM, Asko Oja asc...@gmail.com wrote: It really sucks what kind of mistakes you can pass to production unknowingly. I would much prefer a way to prevent such nonsense. Here was the case where out parameters were with

Re: [HACKERS] Out parameters handling

2009-03-06 Thread Alvaro Herrera
Kevin Grittner escribió: I find the PostgreSQL implementation of OUT parameters, well, surprising. I've used databases where stored procedures can have a RETURN value, OUT parameters, and result streams as three discreet things which can't be mistaken for one another -- which seems more

Re: [HACKERS] Out parameters handling

2009-03-06 Thread Robert Haas
On Fri, Mar 6, 2009 at 4:29 PM, Asko Oja asc...@gmail.com wrote: It was one of my worst Friday's finding out that this brain dead implementation of out parameters had been part of fuck up again. This time we did notice it two days too late. I wish for a way to use out parameters in functions

Re: [HACKERS] Out parameters handling

2009-03-06 Thread Josh Berkus
Robert, I wonder whether it would be possible to make PL/pgsql take :foo to mean the parameter named foo, and then provide an option to make that THE ONLY WAY to refer to the parameter foo. For backward-compatibility, and compatibility with (ahem) other database products, we probably don't