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.
pgsql-hackers by date
|Next:||From: Camilo Porto||Date: 2007-10-30 14:16:39|
|Subject: Re: URGENT HELP about 'duration' stats|
|Previous:||From: David Fetter||Date: 2007-10-30 13:15:42|
|Subject: Re: Proposal: real procedures again (8.4)|