From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | WIP: convert plpgsql to using parser hooks |
Date: | 2009-11-06 14:43:17 |
Message-ID: | 7827.1257518597@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
The attached patch makes the basic cutover from inserting plpgsql
variables into SQL expressions by textual substitution, to handling
them via parser hooks. Currently I only have the pre_columnref hook
written, so only the "backwards compatible" semantics are available.
However this already makes two significant changes compared to before:
1. plpgsql will no longer attempt to substitute variables where they
can't sensibly go, such as table names or column aliases.
2. variable names can't match reserved words unless quoted (notice
the one necessary change in the regression tests).
I realized though that the namespace mechanism needs further adjustment.
As-is, the scope of a variable declaration is its whole block, which
is wrong. Consider
declare x int;
begin
...
declare y int := x+1;
x int := 4;
The second declaration of x will probably capture the "x" reference
in y's default, which it should not. What I think I will do about
this is to abandon the notion of an array-per-namespace altogether,
and turn the namespace data structure into simple chains of individual
names. Instead of linking SQL expressions to the topmost visible
namespace, they'll link to the last-added variable that they can see.
This gives per-variable granularity of visibility, which is what we
need to make this type of thing work as expected.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
plpgsql-uses-hooks-1.patch | text/x-patch | 38.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2009-11-06 15:04:46 | Re: "ERROR: could not read block 6 ...: read only 0 of 8192 bytes" after autovacuum cancelled |
Previous Message | Robert Haas | 2009-11-06 12:22:55 | Re: Why do OLD and NEW have special internal names? |