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

From: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: V0.1 patch for TODO Item: SQL-language reference parameters by name.
Date: 2007-11-02 14:58:58
Message-ID: 003001c81d60$e5c5a3a0$0a01a8c0@gevmus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Hello all,

Hereby an alpha version regarding the:

TODO Item: SQL-language reference parameters by name.

I am sending this patch to check if I am on the right track.

So please take a look at this if possible.

What does this patch do?

As discussed in thread:
http://archives.postgresql.org/pgsql-hackers/2007-10/msg01490.php,

this patch adds an additional parameter (char **argnames) to
pg_parse_and_rewrite and

pg_analyze_and_rewrite and ParseState.

When transformColumnRef is about to report an error for a non existing
column,a final match is

performed to see if the non existing column is a parameter name. (argnames)

If true, then a new node is created by transformParamRef

NOTE:

- This patch is created using MSVC++ !

- Nothing is done yet for polymorphic arguments.

My test where:

create table tbl1(id serial,field1 integer,field2 varchar);

insert into tbl1 (field1,field2) values(11,'zzzz');

insert into tbl1 (field1,field2) values(22,'yyyy');

create or replace function func1(par1 integer,par2 integer,par3 varchar)
returns setof record as

$$

select

par1::text,

par2,

par1+par2,

par2+par1,

par1+field1,

(field1+par2)::varchar,

par3,

field2 || ' ' || par3

from

tbl1;

$$ language sql;

select func1(2,4,'aaaa');

select * from func1(5,16,'bbbb') as (a text ,b int ,c int, e int, f int,g
varchar,h varchar,i text);

results:

"(2,4,6,6,13,15,aaaa,"zzzz aaaa")"

"(2,4,6,6,24,26,aaaa,"yyyy aaaa")"

And

"5";16;21;21;16;"27";"bbbb";"zzzz bbbb"

"5";16;21;21;27;"38";"bbbb";"yyyy bbbb"

Regards,

Gevik

Attachment Content-Type Size
func-name-args-v0.1.patch application/octet-stream 15.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-11-02 15:17:34 Re: Intel x64 vs AMD x64 pgdata
Previous Message Martijn van Oosterhout 2007-11-02 13:38:16 Re: Clarification about HOT

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2007-11-02 15:19:19 Re: V0.1 patch for TODO Item: SQL-language reference parameters by name.
Previous Message Henry B. Hotz 2007-11-01 23:14:56 Re: krb_match_realm