@@ -1998,21 +1998,25 @@ CREATE TABLE t1 (a int, b float, c text);
1998
1998
CREATE INDEX t1_a_idx ON t1(a);
1999
1999
INSERT INTO t1
2000
2000
SELECT i,i,'t1' FROM generate_series(1,10) g(i);
2001
+ ANALYZE t1;
2001
2002
CREATE TABLE t11 (d text) INHERITS (t1);
2002
2003
CREATE INDEX t11_a_idx ON t11(a);
2003
2004
INSERT INTO t11
2004
2005
SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i);
2006
+ ANALYZE t11;
2005
2007
CREATE TABLE t12 (e int[]) INHERITS (t1);
2006
2008
CREATE INDEX t12_a_idx ON t12(a);
2007
2009
INSERT INTO t12
2008
2010
SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i);
2011
+ ANALYZE t12;
2009
2012
CREATE TABLE t111 () INHERITS (t11, t12);
2010
2013
NOTICE: merging multiple inherited definitions of column "a"
2011
2014
NOTICE: merging multiple inherited definitions of column "b"
2012
2015
NOTICE: merging multiple inherited definitions of column "c"
2013
2016
CREATE INDEX t111_a_idx ON t111(a);
2014
2017
INSERT INTO t111
2015
2018
SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i);
2019
+ ANALYZE t111;
2016
2020
CREATE VIEW v1 WITH (security_barrier=true) AS
2017
2021
SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d
2018
2022
FROM t1
@@ -2033,90 +2037,70 @@ SELECT * FROM v1 WHERE a=8;
2033
2037
2034
2038
EXPLAIN (VERBOSE, COSTS OFF)
2035
2039
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
2036
- QUERY PLAN
2037
- -------------------------------------------------------------------------------------------------
2040
+ QUERY PLAN
2041
+ -------------------------------------------------------------------------------------------
2038
2042
Update on public.t1 t1_4
2039
2043
-> Subquery Scan on t1
2040
2044
Output: 100, t1.b, t1.c, t1.ctid
2041
2045
Filter: snoop(t1.a)
2042
- -> Hash Join
2046
+ -> Nested Loop Semi Join
2043
2047
Output: t1_5.ctid, t1_5.a, t1_5.b, t1_5.c
2044
- Hash Cond: (t12.a = t1_5.a)
2045
- -> HashAggregate
2046
- Output: t12.a
2047
- Group Key: t12.a
2048
- -> Append
2049
- -> Seq Scan on public.t12
2050
- Output: t12.a
2051
- -> Seq Scan on public.t111
2052
- Output: t111.a
2053
- -> Hash
2048
+ -> Seq Scan on public.t1 t1_5
2054
2049
Output: t1_5.ctid, t1_5.a, t1_5.b, t1_5.c
2055
- -> Index Scan using t1_a_idx on public.t1 t1_5
2056
- Output: t1_5.ctid, t1_5.a, t1_5.b, t1_5.c
2057
- Index Cond: ((t1_5.a > 5) AND (t1_5.a = 3))
2058
- Filter: leakproof(t1_5.a)
2050
+ Filter: ((t1_5.a > 5) AND (t1_5.a = 3) AND leakproof(t1_5.a))
2051
+ -> Append
2052
+ -> Seq Scan on public.t12
2053
+ Output: t12.a
2054
+ Filter: (t1_5.a = t12.a)
2055
+ -> Seq Scan on public.t111
2056
+ Output: t111.a
2057
+ Filter: (t1_5.a = t111.a)
2059
2058
-> Subquery Scan on t1_1
2060
2059
Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
2061
2060
Filter: snoop(t1_1.a)
2062
- -> Hash Join
2061
+ -> Nested Loop Semi Join
2063
2062
Output: t11.ctid, t11.a, t11.b, t11.c, t11.d
2064
- Hash Cond: (t12_1.a = t11.a)
2065
- -> HashAggregate
2066
- Output: t12_1.a
2067
- Group Key: t12_1.a
2068
- -> Append
2069
- -> Seq Scan on public.t12 t12_1
2070
- Output: t12_1.a
2071
- -> Seq Scan on public.t111 t111_1
2072
- Output: t111_1.a
2073
- -> Hash
2063
+ -> Seq Scan on public.t11
2074
2064
Output: t11.ctid, t11.a, t11.b, t11.c, t11.d
2075
- -> Index Scan using t11_a_idx on public.t11
2076
- Output: t11.ctid, t11.a, t11.b, t11.c, t11.d
2077
- Index Cond: ((t11.a > 5) AND (t11.a = 3))
2078
- Filter: leakproof(t11.a)
2065
+ Filter: ((t11.a > 5) AND (t11.a = 3) AND leakproof(t11.a))
2066
+ -> Append
2067
+ -> Seq Scan on public.t12 t12_1
2068
+ Output: t12_1.a
2069
+ Filter: (t11.a = t12_1.a)
2070
+ -> Seq Scan on public.t111 t111_1
2071
+ Output: t111_1.a
2072
+ Filter: (t11.a = t111_1.a)
2079
2073
-> Subquery Scan on t1_2
2080
2074
Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
2081
2075
Filter: snoop(t1_2.a)
2082
- -> Hash Join
2076
+ -> Nested Loop Semi Join
2083
2077
Output: t12_2.ctid, t12_2.a, t12_2.b, t12_2.c, t12_2.e
2084
- Hash Cond: (t12_3.a = t12_2.a)
2085
- -> HashAggregate
2086
- Output: t12_3.a
2087
- Group Key: t12_3.a
2088
- -> Append
2089
- -> Seq Scan on public.t12 t12_3
2090
- Output: t12_3.a
2091
- -> Seq Scan on public.t111 t111_2
2092
- Output: t111_2.a
2093
- -> Hash
2078
+ -> Seq Scan on public.t12 t12_2
2094
2079
Output: t12_2.ctid, t12_2.a, t12_2.b, t12_2.c, t12_2.e
2095
- -> Index Scan using t12_a_idx on public.t12 t12_2
2096
- Output: t12_2.ctid, t12_2.a, t12_2.b, t12_2.c, t12_2.e
2097
- Index Cond: ((t12_2.a > 5) AND (t12_2.a = 3))
2098
- Filter: leakproof(t12_2.a)
2080
+ Filter: ((t12_2.a > 5) AND (t12_2.a = 3) AND leakproof(t12_2.a))
2081
+ -> Append
2082
+ -> Seq Scan on public.t12 t12_3
2083
+ Output: t12_3.a
2084
+ Filter: (t12_2.a = t12_3.a)
2085
+ -> Seq Scan on public.t111 t111_2
2086
+ Output: t111_2.a
2087
+ Filter: (t12_2.a = t111_2.a)
2099
2088
-> Subquery Scan on t1_3
2100
2089
Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
2101
2090
Filter: snoop(t1_3.a)
2102
- -> Hash Join
2091
+ -> Nested Loop Semi Join
2103
2092
Output: t111_3.ctid, t111_3.a, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2104
- Hash Cond: (t12_4.a = t111_3.a)
2105
- -> HashAggregate
2106
- Output: t12_4.a
2107
- Group Key: t12_4.a
2108
- -> Append
2109
- -> Seq Scan on public.t12 t12_4
2110
- Output: t12_4.a
2111
- -> Seq Scan on public.t111 t111_4
2112
- Output: t111_4.a
2113
- -> Hash
2093
+ -> Seq Scan on public.t111 t111_3
2114
2094
Output: t111_3.ctid, t111_3.a, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2115
- -> Index Scan using t111_a_idx on public.t111 t111_3
2116
- Output: t111_3.ctid, t111_3.a, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2117
- Index Cond: ((t111_3.a > 5) AND (t111_3.a = 3))
2118
- Filter: leakproof(t111_3.a)
2119
- (81 rows)
2095
+ Filter: ((t111_3.a > 5) AND (t111_3.a = 3) AND leakproof(t111_3.a))
2096
+ -> Append
2097
+ -> Seq Scan on public.t12 t12_4
2098
+ Output: t12_4.a
2099
+ Filter: (t111_3.a = t12_4.a)
2100
+ -> Seq Scan on public.t111 t111_4
2101
+ Output: t111_4.a
2102
+ Filter: (t111_3.a = t111_4.a)
2103
+ (61 rows)
2120
2104
2121
2105
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
2122
2106
SELECT * FROM v1 WHERE a=100; -- Nothing should have been changed to 100
@@ -2131,90 +2115,70 @@ SELECT * FROM t1 WHERE a=100; -- Nothing should have been changed to 100
2131
2115
2132
2116
EXPLAIN (VERBOSE, COSTS OFF)
2133
2117
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
2134
- QUERY PLAN
2135
- -------------------------------------------------------------------------------------------------
2118
+ QUERY PLAN
2119
+ -------------------------------------------------------------------------------------------
2136
2120
Update on public.t1 t1_4
2137
2121
-> Subquery Scan on t1
2138
2122
Output: (t1.a + 1), t1.b, t1.c, t1.ctid
2139
2123
Filter: snoop(t1.a)
2140
- -> Hash Join
2124
+ -> Nested Loop Semi Join
2141
2125
Output: t1_5.a, t1_5.ctid, t1_5.b, t1_5.c
2142
- Hash Cond: (t12.a = t1_5.a)
2143
- -> HashAggregate
2144
- Output: t12.a
2145
- Group Key: t12.a
2146
- -> Append
2147
- -> Seq Scan on public.t12
2148
- Output: t12.a
2149
- -> Seq Scan on public.t111
2150
- Output: t111.a
2151
- -> Hash
2126
+ -> Seq Scan on public.t1 t1_5
2152
2127
Output: t1_5.a, t1_5.ctid, t1_5.b, t1_5.c
2153
- -> Index Scan using t1_a_idx on public.t1 t1_5
2154
- Output: t1_5.a, t1_5.ctid, t1_5.b, t1_5.c
2155
- Index Cond: ((t1_5.a > 5) AND (t1_5.a = 8))
2156
- Filter: leakproof(t1_5.a)
2128
+ Filter: ((t1_5.a > 5) AND (t1_5.a = 8) AND leakproof(t1_5.a))
2129
+ -> Append
2130
+ -> Seq Scan on public.t12
2131
+ Output: t12.a
2132
+ Filter: (t1_5.a = t12.a)
2133
+ -> Seq Scan on public.t111
2134
+ Output: t111.a
2135
+ Filter: (t1_5.a = t111.a)
2157
2136
-> Subquery Scan on t1_1
2158
2137
Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
2159
2138
Filter: snoop(t1_1.a)
2160
- -> Hash Join
2139
+ -> Nested Loop Semi Join
2161
2140
Output: t11.a, t11.ctid, t11.b, t11.c, t11.d
2162
- Hash Cond: (t12_1.a = t11.a)
2163
- -> HashAggregate
2164
- Output: t12_1.a
2165
- Group Key: t12_1.a
2166
- -> Append
2167
- -> Seq Scan on public.t12 t12_1
2168
- Output: t12_1.a
2169
- -> Seq Scan on public.t111 t111_1
2170
- Output: t111_1.a
2171
- -> Hash
2141
+ -> Seq Scan on public.t11
2172
2142
Output: t11.a, t11.ctid, t11.b, t11.c, t11.d
2173
- -> Index Scan using t11_a_idx on public.t11
2174
- Output: t11.a, t11.ctid, t11.b, t11.c, t11.d
2175
- Index Cond: ((t11.a > 5) AND (t11.a = 8))
2176
- Filter: leakproof(t11.a)
2143
+ Filter: ((t11.a > 5) AND (t11.a = 8) AND leakproof(t11.a))
2144
+ -> Append
2145
+ -> Seq Scan on public.t12 t12_1
2146
+ Output: t12_1.a
2147
+ Filter: (t11.a = t12_1.a)
2148
+ -> Seq Scan on public.t111 t111_1
2149
+ Output: t111_1.a
2150
+ Filter: (t11.a = t111_1.a)
2177
2151
-> Subquery Scan on t1_2
2178
2152
Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
2179
2153
Filter: snoop(t1_2.a)
2180
- -> Hash Join
2154
+ -> Nested Loop Semi Join
2181
2155
Output: t12_2.a, t12_2.ctid, t12_2.b, t12_2.c, t12_2.e
2182
- Hash Cond: (t12_3.a = t12_2.a)
2183
- -> HashAggregate
2184
- Output: t12_3.a
2185
- Group Key: t12_3.a
2186
- -> Append
2187
- -> Seq Scan on public.t12 t12_3
2188
- Output: t12_3.a
2189
- -> Seq Scan on public.t111 t111_2
2190
- Output: t111_2.a
2191
- -> Hash
2156
+ -> Seq Scan on public.t12 t12_2
2192
2157
Output: t12_2.a, t12_2.ctid, t12_2.b, t12_2.c, t12_2.e
2193
- -> Index Scan using t12_a_idx on public.t12 t12_2
2194
- Output: t12_2.a, t12_2.ctid, t12_2.b, t12_2.c, t12_2.e
2195
- Index Cond: ((t12_2.a > 5) AND (t12_2.a = 8))
2196
- Filter: leakproof(t12_2.a)
2158
+ Filter: ((t12_2.a > 5) AND (t12_2.a = 8) AND leakproof(t12_2.a))
2159
+ -> Append
2160
+ -> Seq Scan on public.t12 t12_3
2161
+ Output: t12_3.a
2162
+ Filter: (t12_2.a = t12_3.a)
2163
+ -> Seq Scan on public.t111 t111_2
2164
+ Output: t111_2.a
2165
+ Filter: (t12_2.a = t111_2.a)
2197
2166
-> Subquery Scan on t1_3
2198
2167
Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
2199
2168
Filter: snoop(t1_3.a)
2200
- -> Hash Join
2169
+ -> Nested Loop Semi Join
2201
2170
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2202
- Hash Cond: (t12_4.a = t111_3.a)
2203
- -> HashAggregate
2204
- Output: t12_4.a
2205
- Group Key: t12_4.a
2206
- -> Append
2207
- -> Seq Scan on public.t12 t12_4
2208
- Output: t12_4.a
2209
- -> Seq Scan on public.t111 t111_4
2210
- Output: t111_4.a
2211
- -> Hash
2171
+ -> Seq Scan on public.t111 t111_3
2212
2172
Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2213
- -> Index Scan using t111_a_idx on public.t111 t111_3
2214
- Output: t111_3.a, t111_3.ctid, t111_3.b, t111_3.c, t111_3.d, t111_3.e
2215
- Index Cond: ((t111_3.a > 5) AND (t111_3.a = 8))
2216
- Filter: leakproof(t111_3.a)
2217
- (81 rows)
2173
+ Filter: ((t111_3.a > 5) AND (t111_3.a = 8) AND leakproof(t111_3.a))
2174
+ -> Append
2175
+ -> Seq Scan on public.t12 t12_4
2176
+ Output: t12_4.a
2177
+ Filter: (t111_3.a = t12_4.a)
2178
+ -> Seq Scan on public.t111 t111_4
2179
+ Output: t111_4.a
2180
+ Filter: (t111_3.a = t111_4.a)
2181
+ (61 rows)
2218
2182
2219
2183
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
2220
2184
NOTICE: snooped value: 8
@@ -2224,28 +2188,28 @@ NOTICE: snooped value: 8
2224
2188
SELECT * FROM v1 WHERE b=8;
2225
2189
a | b | c | d
2226
2190
---+---+------+------
2227
- 9 | 8 | t111 | t11d
2228
- 9 | 8 | t12 | t11d
2229
- 9 | 8 | t11 | t11d
2230
2191
9 | 8 | t1 | t11d
2192
+ 9 | 8 | t11 | t11d
2193
+ 9 | 8 | t12 | t11d
2194
+ 9 | 8 | t111 | t11d
2231
2195
(4 rows)
2232
2196
2233
2197
DELETE FROM v1 WHERE snoop(a) AND leakproof(a); -- should not delete everything, just where a>5
2234
- NOTICE: snooped value: 10
2235
- NOTICE: snooped value: 9
2236
- NOTICE: snooped value: 9
2237
2198
NOTICE: snooped value: 6
2238
2199
NOTICE: snooped value: 7
2239
- NOTICE: snooped value: 10
2240
2200
NOTICE: snooped value: 9
2201
+ NOTICE: snooped value: 10
2241
2202
NOTICE: snooped value: 9
2242
2203
NOTICE: snooped value: 6
2243
2204
NOTICE: snooped value: 7
2244
- NOTICE: snooped value: 10
2245
2205
NOTICE: snooped value: 9
2206
+ NOTICE: snooped value: 10
2246
2207
NOTICE: snooped value: 9
2247
2208
NOTICE: snooped value: 6
2248
2209
NOTICE: snooped value: 7
2210
+ NOTICE: snooped value: 9
2211
+ NOTICE: snooped value: 10
2212
+ NOTICE: snooped value: 9
2249
2213
NOTICE: snooped value: 6
2250
2214
NOTICE: snooped value: 7
2251
2215
NOTICE: snooped value: 9
0 commit comments