Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3f6f926

Browse files
committed
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.
1 parent b1a5287 commit 3f6f926

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/backend/optimizer/prep/prepsecurity.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ security_barrier_replace_vars_walker(Node *node,
432432

433433
/* New variable for subquery targetlist */
434434
newvar = copyObject(var);
435-
newvar->varno = 1;
435+
newvar->varno = newvar->varnoold = 1;
436436

437437
attno = list_length(context->targetlist) + 1;
438438
tle = makeTargetEntry((Expr *) newvar,

src/test/regress/expected/updatable_views.out

+16-16
Original file line numberDiff line numberDiff line change
@@ -2071,10 +2071,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
20712071
-> Append
20722072
-> Seq Scan on public.t12
20732073
Output: t12.a
2074-
Filter: (t1_5.a = t12.a)
2074+
Filter: (t12.a = 3)
20752075
-> Seq Scan on public.t111
20762076
Output: t111.a
2077-
Filter: (t1_5.a = t111.a)
2077+
Filter: (t111.a = 3)
20782078
-> Subquery Scan on t1_1
20792079
Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
20802080
Filter: snoop(t1_1.a)
@@ -2086,10 +2086,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
20862086
-> Append
20872087
-> Seq Scan on public.t12 t12_1
20882088
Output: t12_1.a
2089-
Filter: (t11.a = t12_1.a)
2089+
Filter: (t12_1.a = 3)
20902090
-> Seq Scan on public.t111 t111_1
20912091
Output: t111_1.a
2092-
Filter: (t11.a = t111_1.a)
2092+
Filter: (t111_1.a = 3)
20932093
-> Subquery Scan on t1_2
20942094
Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
20952095
Filter: snoop(t1_2.a)
@@ -2101,10 +2101,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
21012101
-> Append
21022102
-> Seq Scan on public.t12 t12_3
21032103
Output: t12_3.a
2104-
Filter: (t12_2.a = t12_3.a)
2104+
Filter: (t12_3.a = 3)
21052105
-> Seq Scan on public.t111 t111_2
21062106
Output: t111_2.a
2107-
Filter: (t12_2.a = t111_2.a)
2107+
Filter: (t111_2.a = 3)
21082108
-> Subquery Scan on t1_3
21092109
Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
21102110
Filter: snoop(t1_3.a)
@@ -2116,10 +2116,10 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
21162116
-> Append
21172117
-> Seq Scan on public.t12 t12_4
21182118
Output: t12_4.a
2119-
Filter: (t111_3.a = t12_4.a)
2119+
Filter: (t12_4.a = 3)
21202120
-> Seq Scan on public.t111 t111_4
21212121
Output: t111_4.a
2122-
Filter: (t111_3.a = t111_4.a)
2122+
Filter: (t111_4.a = 3)
21232123
(61 rows)
21242124

21252125
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;
21492149
-> Append
21502150
-> Seq Scan on public.t12
21512151
Output: t12.a
2152-
Filter: (t1_5.a = t12.a)
2152+
Filter: (t12.a = 8)
21532153
-> Seq Scan on public.t111
21542154
Output: t111.a
2155-
Filter: (t1_5.a = t111.a)
2155+
Filter: (t111.a = 8)
21562156
-> Subquery Scan on t1_1
21572157
Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
21582158
Filter: snoop(t1_1.a)
@@ -2164,10 +2164,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
21642164
-> Append
21652165
-> Seq Scan on public.t12 t12_1
21662166
Output: t12_1.a
2167-
Filter: (t11.a = t12_1.a)
2167+
Filter: (t12_1.a = 8)
21682168
-> Seq Scan on public.t111 t111_1
21692169
Output: t111_1.a
2170-
Filter: (t11.a = t111_1.a)
2170+
Filter: (t111_1.a = 8)
21712171
-> Subquery Scan on t1_2
21722172
Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
21732173
Filter: snoop(t1_2.a)
@@ -2179,10 +2179,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
21792179
-> Append
21802180
-> Seq Scan on public.t12 t12_3
21812181
Output: t12_3.a
2182-
Filter: (t12_2.a = t12_3.a)
2182+
Filter: (t12_3.a = 8)
21832183
-> Seq Scan on public.t111 t111_2
21842184
Output: t111_2.a
2185-
Filter: (t12_2.a = t111_2.a)
2185+
Filter: (t111_2.a = 8)
21862186
-> Subquery Scan on t1_3
21872187
Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
21882188
Filter: snoop(t1_3.a)
@@ -2194,10 +2194,10 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
21942194
-> Append
21952195
-> Seq Scan on public.t12 t12_4
21962196
Output: t12_4.a
2197-
Filter: (t111_3.a = t12_4.a)
2197+
Filter: (t12_4.a = 8)
21982198
-> Seq Scan on public.t111 t111_4
21992199
Output: t111_4.a
2200-
Filter: (t111_3.a = t111_4.a)
2200+
Filter: (t111_4.a = 8)
22012201
(61 rows)
22022202

22032203
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;

0 commit comments

Comments
 (0)