Re: named parameters in SQL functions - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: named parameters in SQL functions
Date
Msg-id 2E8C4D49-15BC-46F6-9305-DC161871C4B4@kineticode.com
Whole thread Raw
In response to Re: named parameters in SQL functions  (Greg Stark <gsstark@mit.edu>)
Responses Re: named parameters in SQL functions
Re: named parameters in SQL functions
Re: named parameters in SQL functions
List pgsql-hackers
On Nov 15, 2009, at 10:19 AM, Greg Stark wrote:

>> I like the special marker idea.  A '$' would be nice because its already in
>> use for similar purposes, but I think that would lead to ambiguity with
>> dollar quoting.
>
> I think that would be a big break with everything else and very
> non-sql-ish. We don't use these in plpgsql and we don't use them
> anywhere else in sql.

*ahem* $1 *ahem*

> Moreover you would still have conflicts possible because sql can quote
> identifiers so people can have columns named "$foo". You would have a
> weird syntactic detail where "$foo" would mean something different
> than $foo even though they're both valid identifiers.

Same with Foo and "Foo", no?

> I'm not sure it wouldn't conflict with some drivers either. DBI uses
> :foo and ? but I have a vague recollection some drivers did use $foo.

I don't think that would come up, because the $vars are in the body of the function, not in a typical driver call.

Personally, I like $var, but @var would be okay, and @@var is acceptable. But I'm JAPH, so my biases should be obvious.

Best,

David

pgsql-hackers by date:

Previous
From: Joachim Wieland
Date:
Subject: Listen / Notify - what to do when the queue is full
Next
From: Heikki Linnakangas
Date:
Subject: Re: Summary and Plan for Hot Standby