git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b1a5287)
Fix bogus variable-mangling in security_barrier_replace_vars().
2014年9月24日 19:59:34 +0000 (15:59 -0400)
2014年9月24日 19:59:34 +0000 (15:59 -0400)
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.


diff --git a/src/backend/optimizer/prep/prepsecurity.c b/src/backend/optimizer/prep/prepsecurity.c
index 2420f97a219e5afea4e2f0247bc7d041579cd179..51f10a488a83ece0b1fb26be35af8ee1a8f0096b 100644 (file)
--- a/src/backend/optimizer/prep/prepsecurity.c
+++ b/src/backend/optimizer/prep/prepsecurity.c
@@ -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,
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 8a81251288f0661c4c2de0681b2736f099e0a741..80c5706b0b65979026012c63b17be4a3228df9fc 100644 (file)
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -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;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /