Re: [PATCHES] variadic function support

2008-07-15 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > this version is WIP - I have to clean comments, and will do some > documentation. But I am sure, I am not able explain this feature in > english well. Please, can some body help me with documentation? So > now, plpgsql is more/less ruby :) Applied with

Re: [PATCHES] variadic function support

2008-07-14 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > sample: select mleast(variadic array[1,2,3,4,5]); One other point here: in the patch as presently submitted, VARIADIC can't be an unreserved keyword, but it seems to be enough to make it a col_name_keyword. Some preliminary testing says that that does

Re: [PATCHES] variadic function support

2008-07-14 Thread Pavel Stehule
2008/7/14 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> 2008/7/14 Tom Lane <[EMAIL PROTECTED]>: >>> Are you intending to change this right now and resubmit, or is it >>> work for later? > >> I prefer separate it to other patch. > > It seems a fairly important part o

Re: [PATCHES] variadic function support

2008-07-14 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > 2008/7/14 Tom Lane <[EMAIL PROTECTED]>: >> Are you intending to change this right now and resubmit, or is it >> work for later? > I prefer separate it to other patch. It seems a fairly important part of the feature, especially given the connection to

Re: [PATCHES] variadic function support

2008-07-14 Thread Pavel Stehule
2008/7/14 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> sample: select mleast(variadic array[1,2,3,4,5]); > > Note this would also address Jeff's complaint about not being able to > pass zero variadic parameters: > > select mleast(variadic array[]::int[]); > > Looks

Re: [PATCHES] variadic function support

2008-07-14 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> writes: > I don't have a strong opinion, but allowing zero-argument variadic > function calls -- and therefore causing foo(variadic int[]) and > foo(variadic text[]) to conflict -- makes more sense than requiring one > argument. I hadn't even thought about that point

Re: [PATCHES] variadic function support

2008-07-14 Thread Jeff Davis
On Sun, 2008-07-13 at 12:32 -0400, Tom Lane wrote: > >> Also, it doesn't seem to allow calls to a variadic function with zero > >> arguments, e.g. "mleast()". I think this should be allowed. > > > It's not possible for all cases, because empty array have be typed > > array still. But for non polym

Re: [PATCHES] variadic function support

2008-07-14 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > sample: select mleast(variadic array[1,2,3,4,5]); Note this would also address Jeff's complaint about not being able to pass zero variadic parameters: select mleast(variadic array[]::int[]); Looks a bit ugly but the type is specified, so it would wor

Re: [PATCHES] variadic function support

2008-07-14 Thread Pavel Stehule
2008/7/14 Florian G. Pflug <[EMAIL PROTECTED]>: > Pavel Stehule wrote: >>> >>> One issue that just occurred to me: what if a variadic function wants to >>> turn around and call another variadic function, passing the same array >>> argument on to the second one? This is closely akin >>> to the pro

Re: [PATCHES] variadic function support

2008-07-14 Thread Florian G. Pflug
Pavel Stehule wrote: One issue that just occurred to me: what if a variadic function wants to turn around and call another variadic function, passing the same array argument on to the second one? This is closely akin to the problem faced by C "..." functions, and the solutions are pretty ugly

Re: [PATCHES] variadic function support

2008-07-14 Thread Pavel Stehule
2008/7/13 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> 2008/7/13 Jeff Davis <[EMAIL PROTECTED]>: >>> Also, it doesn't seem to allow calls to a variadic function with zero >>> arguments, e.g. "mleast()". I think this should be allowed. > >> It's not possible for all

Re: [PATCHES] variadic function support

2008-07-14 Thread Pavel Stehule
> > As far as the "variadic int" versus "variadic int[]" business, I'm > starting to agree with Pavel that "variadic int[]" offers less potential > for confusion. In particular, it seems to make it more obvious for the > function author that the argument he receives is an array. Also, the > other

Re: [PATCHES] variadic function support

2008-07-13 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > 2008/7/13 Jeff Davis <[EMAIL PROTECTED]>: >> Also, it doesn't seem to allow calls to a variadic function with zero >> arguments, e.g. "mleast()". I think this should be allowed. > It's not possible for all cases, because empty array have be typed > arr

Re: [PATCHES] variadic function support

2008-07-12 Thread Pavel Stehule
2008/7/13 Jeff Davis <[EMAIL PROTECTED]>: > On Sun, 2008-07-13 at 07:52 +0200, Pavel Stehule wrote: >> you checked second or third variant? There are two variants still. > > Sorry for being unclear. Those comments regarded patch v2.2.1. The bug > is in pg_function_is_visible(). it's bug, I'll fix i

Re: [PATCHES] variadic function support

2008-07-12 Thread Pavel Stehule
2008/7/13 Jeff Davis <[EMAIL PROTECTED]>: > On Tue, 2008-06-24 at 17:10 +0200, Pavel Stehule wrote: >> Hello >> >> this version implements syntax based on argmodes. >> >> >> CREATE FUNCTION mleast(variadic numeric[]) RETURNS numeric AS $$ >> SELECT min($1[i]) >>FROM generate_subscripts(

Re: [PATCHES] variadic function support

2008-07-12 Thread Jeff Davis
On Tue, 2008-06-24 at 17:10 +0200, Pavel Stehule wrote: > Hello > > this version implements syntax based on argmodes. > > > CREATE FUNCTION mleast(variadic numeric[]) RETURNS numeric AS $$ > SELECT min($1[i]) >FROM generate_subscripts($1,1) g(i); > $$ LANGUAGE SQL; > I don't have a

Re: [PATCHES] variadic function support

2008-07-12 Thread Jeff Davis
On Sat, 2008-07-12 at 23:06 -0700, Jeff Davis wrote: > I don't have a strong opinion about whether the variadic argument is > declared as an array or scalar, so I am posting my comments about this > version of the patch as well. > > This version also has a problem when declaring two functions "foo

Re: [PATCHES] variadic function support

2008-07-12 Thread Jeff Davis
On Sun, 2008-07-13 at 07:52 +0200, Pavel Stehule wrote: > you checked second or third variant? There are two variants still. Sorry for being unclear. Those comments regarded patch v2.2.1. The bug is in pg_function_is_visible(). Additionally, I'd like to see support for calling variadic functions

Re: [PATCHES] variadic function support

2008-07-12 Thread Pavel Stehule
Hello 2008/7/13 Jeff Davis <[EMAIL PROTECTED]>: > On Thu, 2008-06-26 at 17:03 +0200, Pavel Stehule wrote: >> this is third variant with variadic argumen as scalar. But I still >> strongly prefer second variant with conformance declared variadic >> array with used array variable. > you checked sec

Re: [PATCHES] variadic function support

2008-07-12 Thread Jeff Davis
On Thu, 2008-06-26 at 17:03 +0200, Pavel Stehule wrote: > this is third variant with variadic argumen as scalar. But I still > strongly prefer second variant with conformance declared variadic > array with used array variable. This version allows you to declare two functions "foo(variadic numeric)

Re: [PATCHES] variadic function support

2008-07-04 Thread Pavel Stehule
2008/7/4 Simon Riggs <[EMAIL PROTECTED]>: > > On Mon, 2008-06-23 at 15:13 +0200, Pavel Stehule wrote: > >> this patch enhance current syntax of CREATE FUNCTION statement. It >> allows creating functions with variable number of arguments. This >> version is different than last my patches. It doesn't

Re: [PATCHES] variadic function support

2008-07-04 Thread Simon Riggs
On Mon, 2008-06-23 at 15:13 +0200, Pavel Stehule wrote: > this patch enhance current syntax of CREATE FUNCTION statement. It > allows creating functions with variable number of arguments. This > version is different than last my patches. It doesn't need patching > PL. Basic idea is transformation

Re: [PATCHES] variadic function support

2008-06-26 Thread Pavel Stehule
2008/6/25 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >>> Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create funct

Re: [PATCHES] variadic function support

2008-06-25 Thread Pavel Stehule
2008/6/25 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >>> Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create funct

Re: [PATCHES] variadic function support

2008-06-25 Thread Andrew Dunstan
Pavel Stehule wrote: I afraid so Java syntax isn't good inspiration http://www.java-tips.org/java-se-tips/java.lang/using-the-varargs-language-feature.html http://www.clanproductions.com/java5.html they use symbol ... like specific synonym to []. public Method getMethod(String name, Class...

Re: [PATCHES] variadic function support

2008-06-25 Thread Pavel Stehule
2008/6/25 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >>> Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create funct

Re: [PATCHES] variadic function support

2008-06-25 Thread Pavel Stehule
2008/6/25 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >>> Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create funct

Re: [PATCHES] variadic function support

2008-06-25 Thread Pavel Stehule
2008/6/25 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >>> Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create funct

Re: [PATCHES] variadic function support

2008-06-24 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: >> Tom Lane wrote: >>> Your point about the syntax is good though. It would be better if >>> the syntax were like >>> create function foo (a text, variadic b int[]) >>> or maybe even better >>> create function foo (a text, variadic b int) > I don't see

Re: [PATCHES] variadic function support

2008-06-24 Thread Pavel Stehule
Hello this version implements syntax based on argmodes. CREATE FUNCTION mleast(variadic numeric[]) RETURNS numeric AS $$ SELECT min($1[i]) FROM generate_subscripts($1,1) g(i); $$ LANGUAGE SQL; Regards Pavel Stehule 2008/6/24 Tom Lane <[EMAIL PROTECTED]>: > Andrew Dunstan <[EMAIL PRO

Re: [PATCHES] variadic function support

2008-06-23 Thread Pavel Stehule
2008/6/24 Tom Lane <[EMAIL PROTECTED]>: > Andrew Dunstan <[EMAIL PROTECTED]> writes: >> But if I have >> foo( a text, b int[]) >> it looks odd if both these calls are legal: >> foo('a',1,2,3,) >> foo('a',ARRAY[1,2,3]) >> which I understand would be the case with the current patch. > > Maybe I

Re: [PATCHES] variadic function support

2008-06-23 Thread Pavel Stehule
2008/6/23 Andrew Dunstan <[EMAIL PROTECTED]>: > > > And what about a function that takes 2 arrays as arguments? only last argument is evaluated as variadic so function create or replace function foo(a int[], b int[]) ... variadic is called select foo(array[1,2,3], 1,2,3,4,5,6) > > This propos

Re: [PATCHES] variadic function support

2008-06-23 Thread Pavel Stehule
2008/6/24 Andrew Dunstan <[EMAIL PROTECTED]>: > > > Tom Lane wrote: >> >> Your point about the syntax is good though. It would be better if >> the syntax were like >> >>create function foo (a text, variadic b int[]) >> >> or maybe even better >> >>create function foo (a text, varia

Re: [PATCHES] variadic function support

2008-06-23 Thread Andrew Dunstan
Tom Lane wrote: Your point about the syntax is good though. It would be better if the syntax were like create function foo (a text, variadic b int[]) or maybe even better create function foo (a text, variadic b int) since (a) this makes it much more obvious to the reader wh

Re: [PATCHES] variadic function support

2008-06-23 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > But if I have > foo( a text, b int[]) > it looks odd if both these calls are legal: > foo('a',1,2,3,) > foo('a',ARRAY[1,2,3]) > which I understand would be the case with the current patch. Maybe I misunderstand what is supposed to happen, but I be

Re: [PATCHES] variadic function support

2008-06-23 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan <[EMAIL PROTECTED]> writes: Tom Lane wrote: What would you consider "proper and full support"? I don't know. But this doesn't feel like it. That's a fairly weak argument for rejecting a patch that provides a feature many people have asked

Re: [PATCHES] variadic function support

2008-06-23 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> What would you consider "proper and full support"? > > I don't know. But this doesn't feel like it. That's a fairly weak argument for rejecting a patch that provides a feature many people have asked for. I thought the patch was pret

Re: [PATCHES] variadic function support

2008-06-23 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan <[EMAIL PROTECTED]> writes: This proposal strikes me as half-baked. Either we need proper and full support for variadic functions, or we don't, but I don't think we need syntactic sugar like the above (or maybe in this case it's really syntactic saccharine).

Re: [PATCHES] variadic function support

2008-06-23 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > This proposal strikes me as half-baked. Either we need proper and full > support for variadic functions, or we don't, but I don't think we need > syntactic sugar like the above (or maybe in this case it's really > syntactic saccharine). What would yo

Re: [PATCHES] variadic function support

2008-06-23 Thread Andrew Dunstan
Pavel Stehule wrote: Hello this patch enhance current syntax of CREATE FUNCTION statement. It allows creating functions with variable number of arguments. This version is different than last my patches. It doesn't need patching PL. Basic idea is transformation of real arguments (related to dec