Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group