]> granicus.if.org Git - postgresql/commitdiff
Fix bogus variable-mangling in security_barrier_replace_vars().
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Sep 2014 19:59:37 +0000 (15:59 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Sep 2014 19:59:37 +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.

src/backend/optimizer/prep/prepsecurity.c
src/test/regress/expected/updatable_views.out

index 2420f97a219e5afea4e2f0247bc7d041579cd179..51f10a488a83ece0b1fb26be35af8ee1a8f0096b 100644 (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,
index 9ed48962b3e4c0055f12207c7879ea15572c7c53..507b6a2a3ee5a694282b47117d6e802f0e9145ca 100644 (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;