Proposal TODO Item: SQL-language reference parameters by name

Поиск
Список
Период
Сортировка
От Gevik Babakhani
Тема Proposal TODO Item: SQL-language reference parameters by name
Дата
Msg-id 001001c81af9$3b7c9b60$0a01a8c0@gevmus
обсуждение исходный текст
Ответы Re: Proposal TODO Item: SQL-language reference parameters by name  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Proposal TODO Item: SQL-language reference parameters by name  (David Fetter <david@fetter.org>)
Список 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.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: Proposal: real procedures again (8.4)
Следующее
От: Camilo Porto
Дата:
Сообщение: Re: URGENT HELP about 'duration' stats