Re: proposal sql: labeled function params
От | Pavel Stehule |
---|---|
Тема | Re: proposal sql: labeled function params |
Дата | |
Msg-id | 162867790808171150x6920767wb683d88c7cb19789@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: proposal sql: labeled function params ("Asko Oja" <ascoja@gmail.com>) |
Список | pgsql-hackers |
2008/8/17 Asko Oja <ascoja@gmail.com>: > Not able to means not implementable o not implemented ? Almost not implementable - plpgsql is too static language. > > On Sun, Aug 17, 2008 at 6:59 PM, Pavel Stehule <pavel.stehule@gmail.com> > wrote: >> >> Hannu >> >> it's not possible inNot able to plpgsql, because we are not able iterate >> via record. >> >> Pavel >> >> 2008/8/17 Hannu Krosing <hannu@2ndquadrant.com>: >> > On Sun, 2008-08-17 at 11:08 -0400, Tom Lane wrote: >> >> Hannu Krosing <hannu@2ndQuadrant.com> writes: >> >> > Actually the most "natural" syntax to me is just f(name=value) >> >> > similar >> >> > to how UPDATE does it. It has the added benefit of _not_ forcing us >> >> > to >> >> > make a operator reserved (AFAIK "=" can't be used to define new ops) >> >> >> >> *What* are you thinking? >> > >> > I think that we could achieve what Pavel was after by allowing one to >> > define something similar to keyword arguments in python. >> > >> > maybe allow input RECORD type, which is instantiated at call time by >> > giving extra arguments to function call: >> > >> > CREATE FUNCTION f_kw(r record) .... >> > >> > and then if you call it like this: >> > >> > SELECT ... f_kw(name='bob', age=7::int) >> > >> > then function gets as its input a record >> > which can be accessed in pl/pgsql like >> > >> > r.name r.age >> > >> > and if terseness is really appreciated then the it could also be called >> > like this >> > >> > SELECT ... f_kw(name, age) from people where name='bob'; >> > >> > which is rewritten to >> > >> > SELECT ... f_kw(name=name, age=age) from people where name='bob'; >> > >> > >> > not sure if we should allow defining SETOF RECORD and then enable >> > calling it with >> > >> > SELECT * >> > FROM f_kw( >> > VALUES(name='bob', age=7::int), >> > VALUES(name='bill', age=42::int >> > ); >> > >> > or somesuch >> > >> > ------------------ >> > Hannu >> > >> > >> > >> >> -- >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-hackers > >
В списке pgsql-hackers по дате отправления: