Fix bogus variable-mangling in security_barrier_replace_vars().

This function created new Vars with varno different from varnoold, which
is a condition that should never prevail before setrefs.c does the final
variable-renumbering pass.  The created Vars could not be seen as equal()
to normal Vars, which among other things broke equivalence-class processing
for them.  The consequences of this were indeed visible in the regression
tests, in the form of failure to propagate constants as one would expect.
I stumbled across it while poking at bug #11457 --- after intentionally
disabling join equivalence processing, the security-barrier regression
tests started falling over with fun errors like "could not find pathkey
item to sort", because of failure to match the corrupted Vars to normal
ones.
This commit is contained in:
Tom Lane 2014-09-24 15:59:34 -04:00
parent b1a52872ae
commit 3f6f9260e3
2 changed files with 17 additions and 17 deletions

View File

@ -432,7 +432,7 @@ security_barrier_replace_vars_walker(Node *node,
/* New variable for subquery targetlist */
newvar = copyObject(var);
newvar->varno = 1;
newvar->varno = newvar->varnoold = 1;
attno = list_length(context->targetlist) + 1;
tle = makeTargetEntry((Expr *) newvar,

View File

@ -2071,10 +2071,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
-> Append
-> Seq Scan on public.t12
Output: t12.a
Filter: (t1_5.a = t12.a)
Filter: (t12.a = 3)
-> Seq Scan on public.t111
Output: t111.a
Filter: (t1_5.a = t111.a)
Filter: (t111.a = 3)
-> Subquery Scan on t1_1
Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
Filter: snoop(t1_1.a)
@ -2086,10 +2086,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
-> Append
-> Seq Scan on public.t12 t12_1
Output: t12_1.a
Filter: (t11.a = t12_1.a)
Filter: (t12_1.a = 3)
-> Seq Scan on public.t111 t111_1
Output: t111_1.a
Filter: (t11.a = t111_1.a)
Filter: (t111_1.a = 3)
-> Subquery Scan on t1_2
Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
Filter: snoop(t1_2.a)
@ -2101,10 +2101,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
-> Append
-> Seq Scan on public.t12 t12_3
Output: t12_3.a
Filter: (t12_2.a = t12_3.a)
Filter: (t12_3.a = 3)
-> Seq Scan on public.t111 t111_2
Output: t111_2.a
Filter: (t12_2.a = t111_2.a)
Filter: (t111_2.a = 3)
-> Subquery Scan on t1_3
Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
Filter: snoop(t1_3.a)
@ -2116,10 +2116,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
-> Append
-> Seq Scan on public.t12 t12_4
Output: t12_4.a
Filter: (t111_3.a = t12_4.a)
Filter: (t12_4.a = 3)
-> Seq Scan on public.t111 t111_4
Output: t111_4.a
Filter: (t111_3.a = t111_4.a)
Filter: (t111_4.a = 3)
(61 rows)
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
@ -2149,10 +2149,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
-> Append
-> Seq Scan on public.t12
Output: t12.a
Filter: (t1_5.a = t12.a)
Filter: (t12.a = 8)
-> Seq Scan on public.t111
Output: t111.a
Filter: (t1_5.a = t111.a)
Filter: (t111.a = 8)
-> Subquery Scan on t1_1
Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
Filter: snoop(t1_1.a)
@ -2164,10 +2164,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
-> Append
-> Seq Scan on public.t12 t12_1
Output: t12_1.a
Filter: (t11.a = t12_1.a)
Filter: (t12_1.a = 8)
-> Seq Scan on public.t111 t111_1
Output: t111_1.a
Filter: (t11.a = t111_1.a)
Filter: (t111_1.a = 8)
-> Subquery Scan on t1_2
Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
Filter: snoop(t1_2.a)
@ -2179,10 +2179,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
-> Append
-> Seq Scan on public.t12 t12_3
Output: t12_3.a
Filter: (t12_2.a = t12_3.a)
Filter: (t12_3.a = 8)
-> Seq Scan on public.t111 t111_2
Output: t111_2.a
Filter: (t12_2.a = t111_2.a)
Filter: (t111_2.a = 8)
-> Subquery Scan on t1_3
Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
Filter: snoop(t1_3.a)
@ -2194,10 +2194,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
-> Append
-> Seq Scan on public.t12 t12_4
Output: t12_4.a
Filter: (t111_3.a = t12_4.a)
Filter: (t12_4.a = 8)
-> Seq Scan on public.t111 t111_4
Output: t111_4.a
Filter: (t111_3.a = t111_4.a)
Filter: (t111_4.a = 8)
(61 rows)
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;