pg.ddx.io pgsql-testers@postgresql.org mailing list archive
help / color / mirror / Atom feedNamed parameter notation in Postgresql 9.0
2+ messages / 2 participants
[nested] [flat]
* Named parameter notation in Postgresql 9.0
@ 2010-04-22 16:27 Ingmar Brouns <swingi@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Ingmar Brouns @ 2010-04-22 16:27 UTC (permalink / raw)
To: pgsql-testers
Hi,
I was testing the new named parameter notation for calling functions in 9.0
http://developer.postgresql.org/pgdocs/postgres/sql-syntax-calling-funcs.html
Named parameter notation is really nice, however, it is still enforced
that all parameters after the first parameter with a default value
must also have a default value in the function declaration.
so the following function will fail to compile:
FUNCTION foo(a INTEGER DEFAULT 0, b INTEGER)
ERROR: input parameters after one with a default value must also have defaults
As the developer documentation states (35.4.6):
---------------
Although the use of named argument notation could allow this
restriction to be relaxed, it's still enforced so that positional
argument notation works sensibly.
---------------
One of the main benefits of named notation is that it offers clarity
when you have a large number of parameters. When a function has a
large number of parameters, then it is often desirable to logically
group the parameters together at the function declaration, instead of
having to move some of them to the end because they have a default
value.
Wouldn't it be better to relax this constraint, and instead check that
when a function is being called using positional notation, that all
parameters must have been provided until (including) the last
parameter that has no default value.
Kind regards,
Ingmar Brouns
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Named parameter notation in Postgresql 9.0
@ 2010-04-22 22:22 Josh Berkus <josh@agliodbs.com>
parent: Ingmar Brouns <swingi@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2010-04-22 22:22 UTC (permalink / raw)
To: Ingmar Brouns <swingi@gmail.com>; +Cc: pgsql-testers
On 4/22/10 9:27 AM, Ingmar Brouns wrote:
> Wouldn't it be better to relax this constraint, and instead check that
> when a function is being called using positional notation, that all
> parameters must have been provided until (including) the last
> parameter that has no default value.
The problem is that you can't know how the function is going to be
called in the future. That is, regardless of how you create the proc,
it could be called either named or positionally. Checking it at calling
time doesn't work because we need to create the "fingerprint" of a proc
when it's created, not when it's called.
So, potentially solvable but will require a lot more mucking around with
function call code to make it work. You're welcome to hack on it.
--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-04-22 22:22 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-04-22 16:27 Named parameter notation in Postgresql 9.0 Ingmar Brouns <swingi@gmail.com>
2010-04-22 22:22 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox