Proposal TODO Item: SQL-language reference parameters by name

From: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Proposal TODO Item: SQL-language reference parameters by name
Date: 2007-10-30 13:31:52
Message-ID: 001001c81af9$3b7c9b60$0a01a8c0@gevmus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I am working a lot with custom procedures/functions which are implemented in "language sql". At the moment function parameter refs cannot work with parameter names. I would like to try to implement this. The actual TODO item is:

Allow SQL-language functions to reference parameters by parameter name

Currently SQL-language functions can only refer to dollar parameters, e.g. $1

After a quick look at how ref parameters in plpgsql and sql function are handled, I would like to start a discussion about the following implementation plan.

Implementation of the name parameter parsing in scan.l/gram.y can be achieved by adopting the same mechanism as plpgsql does. If I am not mistaking plpgsql parser creates a stack to store parameter identifiers.

Correct me if this would be wrong or not possible, but I am thinking of mapping the name references to the parameter numbers (par2 => $2) this way I hope to keep the implementation small and perhaps extend "struct ParamRef" to hold a possible parameter name.

Then there is the issue of error reporting for ambiguous parameter names (non existing parameter names and names which conflict with actual column names). I guess this can be handeled in "fmgr_sql_validator"

Please let me know your opinion.

Regards,

Gevik.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Camilo Porto 2007-10-30 14:16:39 Re: URGENT HELP about 'duration' stats
Previous Message David Fetter 2007-10-30 13:15:42 Re: Proposal: real procedures again (8.4)