Re: V0.1 patch for TODO Item: SQL-language reference parameters by name.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
Cc: "'Pavel Stehule'" <pavel(dot)stehule(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: V0.1 patch for TODO Item: SQL-language reference parameters by name.
Date: 2007-11-02 16:17:04
Message-ID: 6960.1194020224@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Gevik Babakhani" <pgdev(at)xs4all(dot)nl> writes:
>> what about name's collision? Maybe is better use some prefix,
>> like $ or :. Without it we only propagate one problem from
>> plpgsql to others languages.

> Please explain.
> Perhaps I am wrong, but plpgsql handles arsgument names before it
> passes the query to be executed.

Which is actually the Wrong Thing to do: really the parameters should be
seen as being in a name scope that's outside that of the query (and thus
ambiguous names should be resolved first as column names of the query).
The proposed patch does this in the right order and so I think that
Pavel's concern is without foundation.

One point here is that it would be good to be able to qualify the
argument names with the function name, for example

create function myfunc(x int) ...
select ... from t where t.x = myfunc.x

If t has a column named x then this will be the only way that the
function parameter x can be referenced within that query. We are
partway to that point with plpgsql but haven't bitten the bullet
of changing the lookup order.

Note that this consideration is another reason for having a callback
function that's responsible for trying to resolve unresolved names.
I certainly wouldn't like to have a notion of "function name" wired
into the parser API, and if we did do that it still wouldn't be
sufficient for plpgsql which can have multiple block-label namespaces
accessible at once.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2007-11-02 16:21:38 Re: Clarification about HOT
Previous Message Gokulakannan Somasundaram 2007-11-02 16:14:30 Re: Clarification about HOT

Browse pgsql-patches by date

  From Date Subject
Next Message Pavel Stehule 2007-11-02 17:24:53 Re: V0.1 patch for TODO Item: SQL-language reference parameters by name.
Previous Message Tom Lane 2007-11-02 16:06:11 Re: V0.1 patch for TODO Item: SQL-language reference parameters by name.