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

Commit b3e6593

Browse files
committed
Add ANALYZE into regression tests
Looks like we can end up with different plans happening on the buildfarm, which breaks the regression tests when we include EXPLAIN output (which is done in the regression tests for updatable security views, to ensure that the user-defined function isn't pushed down to a level where it could view the rows before the security quals are applied). This adds in ANALYZE to hopefully make the plans consistent. The ANALYZE ends up changing the original plan too, so the update looks bigger than it really is. The new plan looks perfectly valid, of course.
1 parent d95425c commit b3e6593

File tree

2 files changed

+102
-134
lines changed

2 files changed

+102
-134
lines changed

src/test/regress/expected/updatable_views.out

+98-134
Original file line numberDiff line numberDiff line change
@@ -1998,21 +1998,25 @@ CREATE TABLE t1 (a int, b float, c text);
19981998
CREATE INDEX t1_a_idx ON t1(a);
19991999
INSERT INTO t1
20002000
SELECT i,i,'t1' FROM generate_series(1,10) g(i);
2001+
ANALYZE t1;
20012002
CREATE TABLE t11 (d text) INHERITS (t1);
20022003
CREATE INDEX t11_a_idx ON t11(a);
20032004
INSERT INTO t11
20042005
SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i);
2006+
ANALYZE t11;
20052007
CREATE TABLE t12 (e int[]) INHERITS (t1);
20062008
CREATE INDEX t12_a_idx ON t12(a);
20072009
INSERT INTO t12
20082010
SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i);
2011+
ANALYZE t12;
20092012
CREATE TABLE t111 () INHERITS (t11, t12);
20102013
NOTICE: merging multiple inherited definitions of column "a"
20112014
NOTICE: merging multiple inherited definitions of column "b"
20122015
NOTICE: merging multiple inherited definitions of column "c"
20132016
CREATE INDEX t111_a_idx ON t111(a);
20142017
INSERT INTO t111
20152018
SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i);
2019+
ANALYZE t111;
20162020
CREATE VIEW v1 WITH (security_barrier=true) AS
20172021
SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d
20182022
FROM t1
@@ -2033,90 +2037,70 @@ SELECT * FROM v1 WHERE a=8;
20332037

20342038
EXPLAIN (VERBOSE, COSTS OFF)
20352039
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
2036-
QUERY PLAN
2037-
-------------------------------------------------------------------------------------------------
2040+
QUERY PLAN
2041+
-------------------------------------------------------------------------------------------
20382042
Update on public.t1 t1_4
20392043
-> Subquery Scan on t1
20402044
Output: 100, t1.b, t1.c, t1.ctid
20412045
Filter: snoop(t1.a)
2042-
-> Hash Join
2046+
-> Nested Loop Semi Join
20432047
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
20542049
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)
20592058
-> Subquery Scan on t1_1
20602059
Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
20612060
Filter: snoop(t1_1.a)
2062-
-> Hash Join
2061+
-> Nested Loop Semi Join
20632062
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
20742064
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)
20792073
-> Subquery Scan on t1_2
20802074
Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
20812075
Filter: snoop(t1_2.a)
2082-
-> Hash Join
2076+
-> Nested Loop Semi Join
20832077
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
20942079
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)
20992088
-> Subquery Scan on t1_3
21002089
Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
21012090
Filter: snoop(t1_3.a)
2102-
-> Hash Join
2091+
-> Nested Loop Semi Join
21032092
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
21142094
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)
21202104

21212105
UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a = 3;
21222106
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
21312115

21322116
EXPLAIN (VERBOSE, COSTS OFF)
21332117
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
2134-
QUERY PLAN
2135-
-------------------------------------------------------------------------------------------------
2118+
QUERY PLAN
2119+
-------------------------------------------------------------------------------------------
21362120
Update on public.t1 t1_4
21372121
-> Subquery Scan on t1
21382122
Output: (t1.a + 1), t1.b, t1.c, t1.ctid
21392123
Filter: snoop(t1.a)
2140-
-> Hash Join
2124+
-> Nested Loop Semi Join
21412125
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
21522127
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)
21572136
-> Subquery Scan on t1_1
21582137
Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.ctid
21592138
Filter: snoop(t1_1.a)
2160-
-> Hash Join
2139+
-> Nested Loop Semi Join
21612140
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
21722142
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)
21772151
-> Subquery Scan on t1_2
21782152
Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.ctid
21792153
Filter: snoop(t1_2.a)
2180-
-> Hash Join
2154+
-> Nested Loop Semi Join
21812155
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
21922157
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)
21972166
-> Subquery Scan on t1_3
21982167
Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid
21992168
Filter: snoop(t1_3.a)
2200-
-> Hash Join
2169+
-> Nested Loop Semi Join
22012170
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
22122172
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)
22182182

22192183
UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8;
22202184
NOTICE: snooped value: 8
@@ -2224,28 +2188,28 @@ NOTICE: snooped value: 8
22242188
SELECT * FROM v1 WHERE b=8;
22252189
a | b | c | d
22262190
---+---+------+------
2227-
9 | 8 | t111 | t11d
2228-
9 | 8 | t12 | t11d
2229-
9 | 8 | t11 | t11d
22302191
9 | 8 | t1 | t11d
2192+
9 | 8 | t11 | t11d
2193+
9 | 8 | t12 | t11d
2194+
9 | 8 | t111 | t11d
22312195
(4 rows)
22322196

22332197
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
22372198
NOTICE: snooped value: 6
22382199
NOTICE: snooped value: 7
2239-
NOTICE: snooped value: 10
22402200
NOTICE: snooped value: 9
2201+
NOTICE: snooped value: 10
22412202
NOTICE: snooped value: 9
22422203
NOTICE: snooped value: 6
22432204
NOTICE: snooped value: 7
2244-
NOTICE: snooped value: 10
22452205
NOTICE: snooped value: 9
2206+
NOTICE: snooped value: 10
22462207
NOTICE: snooped value: 9
22472208
NOTICE: snooped value: 6
22482209
NOTICE: snooped value: 7
2210+
NOTICE: snooped value: 9
2211+
NOTICE: snooped value: 10
2212+
NOTICE: snooped value: 9
22492213
NOTICE: snooped value: 6
22502214
NOTICE: snooped value: 7
22512215
NOTICE: snooped value: 9

src/test/regress/sql/updatable_views.sql

+4
Original file line numberDiff line numberDiff line change
@@ -944,21 +944,25 @@ CREATE TABLE t1 (a int, b float, c text);
944944
CREATE INDEX t1_a_idx ON t1(a);
945945
INSERT INTO t1
946946
SELECT i,i,'t1' FROM generate_series(1,10) g(i);
947+
ANALYZE t1;
947948

948949
CREATE TABLE t11 (d text) INHERITS (t1);
949950
CREATE INDEX t11_a_idx ON t11(a);
950951
INSERT INTO t11
951952
SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i);
953+
ANALYZE t11;
952954

953955
CREATE TABLE t12 (e int[]) INHERITS (t1);
954956
CREATE INDEX t12_a_idx ON t12(a);
955957
INSERT INTO t12
956958
SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i);
959+
ANALYZE t12;
957960

958961
CREATE TABLE t111 () INHERITS (t11, t12);
959962
CREATE INDEX t111_a_idx ON t111(a);
960963
INSERT INTO t111
961964
SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i);
965+
ANALYZE t111;
962966

963967
CREATE VIEW v1 WITH (security_barrier=true) AS
964968
SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d

0 commit comments

Comments
 (0)