From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "Andrew Dunstan" <andrew(at)dunslane(dot)net> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: idea: simple variadic functions in SQL and PL/pgSQL |
Date: | 2008-02-27 14:20:10 |
Message-ID: | 162867790802270620w5312d94ev16bc773be41e5dcc@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
On 26/02/2008, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>
> Pavel Stehule wrote:
> > Hello,
> >
> > I found easy implementation of variadic functions. It's based on
> > adapation FuncnameGetCandidates. When I found variadic function, then
> > I should create accurate number of last arguments (diff between
> > pronargs and nargs). Variadic function can be signed via flag or via
> > some pseudotype. Flag is better - allows variadic arguments of any
> > type. In static languages (like SQL or PL/pgSQL) variadic variables
> > can ba accessed via array (variadic arguments can be only nonarray).
> > This isn't problem in C language, there are arguments available
> > directly.
> >
>
>
> There are a whole slew of questions around this, ISTM.
sure. It's time to thing about it.
>
> For example: What will be the type inferred for the array of variadic
> args in plpgsql?
SQL and PL/SQL should be limited. In my prototype I use fragment:
/* replace ANYNONARRAYS argument with ARRAY OF some */
argtype = get_array_type(argtype);
if (!OidIsValid(argtype))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("could not determine
actual array type for variadic argument")));
SPI is unlimited (C language). I can use list of arrays in perl or
python - there I don't see complications too. Domains and arrays can
be problem. Using variadic array variables isn't typical. So I will to
solve only domains. But it's more general problem. Maybe 8.4 can
support array of domains.
>
> If we are going to do this I think we need some discussion on design
> before we rush into it.
>
yes, I agree. Variadic functions are simple. And I belive it can
simplify life to some programmers that have to manage functions like:
foo(int),
foo(int, int)
foo(int, int, int)...
regards
Pavel
> cheers
>
>
> andrew
>
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2008-02-27 14:24:55 | proposal: plpgsql return execute ... |
Previous Message | Florian G. Pflug | 2008-02-27 14:11:10 | Re: An idea for parallelizing COPY within one backend |