Skip to content

Commit 4468ae8

Browse files
committed
small regression tests refactoring (+pathman_cte)
1 parent 819c07e commit 4468ae8

13 files changed

+698
-517
lines changed

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# contrib/pg_pathman/Makefile
22

33
MODULE_big = pg_pathman
4+
45
OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
56
src/runtimeappend.o src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o \
67
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o \
@@ -9,24 +10,31 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
910
src/partition_creation.o $(WIN32RES)
1011

1112
EXTENSION = pg_pathman
13+
1214
EXTVERSION = 1.3
15+
1316
DATA_built = pg_pathman--$(EXTVERSION).sql
17+
1418
DATA = pg_pathman--1.0--1.1.sql \
1519
pg_pathman--1.1--1.2.sql
20+
1621
PGFILEDESC = "pg_pathman - partitioning tool"
1722

1823
REGRESS = pathman_basic \
19-
pathman_inserts \
20-
pathman_runtime_nodes \
21-
pathman_callbacks \
24+
pathman_cte \
2225
pathman_domains \
26+
pathman_interval \
27+
pathman_callbacks \
2328
pathman_foreign_keys \
2429
pathman_permissions \
2530
pathman_rowmarks \
31+
pathman_inserts \
32+
pathman_runtime_nodes \
2633
pathman_utility_stmt_hooking \
27-
pathman_calamity \
28-
pathman_interval
34+
pathman_calamity
35+
2936
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
37+
3038
EXTRA_CLEAN = pg_pathman--$(EXTVERSION).sql ./isolation_output
3139

3240
ifdef USE_PGXS

expected/pathman_basic.out

Lines changed: 1 addition & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,197 +1138,6 @@ SELECT * FROM test.hash_varchar WHERE val = '12'::TEXT;
11381138

11391139
DROP TABLE test.hash_varchar CASCADE;
11401140
NOTICE: drop cascades to 4 other objects
1141-
/*
1142-
* Test CTE query
1143-
*/
1144-
EXPLAIN (COSTS OFF)
1145-
WITH ttt AS (SELECT * FROM test.range_rel WHERE dt >= '2015-02-01' AND dt < '2015-03-15')
1146-
SELECT * FROM ttt;
1147-
QUERY PLAN
1148-
--------------------------------------------------------------------------------------------
1149-
CTE Scan on ttt
1150-
CTE ttt
1151-
-> Append
1152-
-> Seq Scan on range_rel_2
1153-
-> Index Scan using range_rel_3_dt_idx on range_rel_3
1154-
Index Cond: (dt < 'Sun Mar 15 00:00:00 2015'::timestamp without time zone)
1155-
(6 rows)
1156-
1157-
EXPLAIN (COSTS OFF)
1158-
WITH ttt AS (SELECT * FROM test.hash_rel WHERE value = 2)
1159-
SELECT * FROM ttt;
1160-
QUERY PLAN
1161-
--------------------------------------
1162-
CTE Scan on ttt
1163-
CTE ttt
1164-
-> Append
1165-
-> Seq Scan on hash_rel_1
1166-
Filter: (value = 2)
1167-
(5 rows)
1168-
1169-
/*
1170-
* Test CTE query - by @parihaaraka (add varno to WalkerContext)
1171-
*/
1172-
CREATE TABLE test.cte_del_xacts (id BIGSERIAL PRIMARY KEY, pdate DATE NOT NULL);
1173-
INSERT INTO test.cte_del_xacts (pdate) SELECT gen_date FROM generate_series('2016-01-01'::date, '2016-04-9'::date, '1 day') AS gen_date;
1174-
create table test.cte_del_xacts_specdata
1175-
(
1176-
tid BIGINT PRIMARY KEY,
1177-
test_mode SMALLINT,
1178-
state_code SMALLINT NOT NULL DEFAULT 8,
1179-
regtime TIMESTAMP WITHOUT TIME ZONE NOT NULL
1180-
);
1181-
INSERT INTO test.cte_del_xacts_specdata VALUES(1, 1, 1, current_timestamp); /* for subquery test */
1182-
/* create 2 partitions */
1183-
SELECT pathman.create_range_partitions('test.cte_del_xacts'::regclass, 'pdate', '2016-01-01'::date, '50 days'::interval);
1184-
NOTICE: sequence "cte_del_xacts_seq" does not exist, skipping
1185-
create_range_partitions
1186-
-------------------------
1187-
2
1188-
(1 row)
1189-
1190-
EXPLAIN (COSTS OFF)
1191-
WITH tmp AS (
1192-
SELECT tid, test_mode, regtime::DATE AS pdate, state_code
1193-
FROM test.cte_del_xacts_specdata)
1194-
DELETE FROM test.cte_del_xacts t USING tmp
1195-
WHERE t.id = tmp.tid AND t.pdate = tmp.pdate AND tmp.test_mode > 0;
1196-
QUERY PLAN
1197-
--------------------------------------------------------------------------------
1198-
Delete on cte_del_xacts t
1199-
Delete on cte_del_xacts t
1200-
Delete on cte_del_xacts_1 t_1
1201-
Delete on cte_del_xacts_2 t_2
1202-
CTE tmp
1203-
-> Seq Scan on cte_del_xacts_specdata
1204-
-> Hash Join
1205-
Hash Cond: ((tmp.tid = t.id) AND (tmp.pdate = t.pdate))
1206-
-> CTE Scan on tmp
1207-
Filter: (test_mode > 0)
1208-
-> Hash
1209-
-> Index Scan using cte_del_xacts_pkey on cte_del_xacts t
1210-
-> Hash Join
1211-
Hash Cond: ((tmp.tid = t_1.id) AND (tmp.pdate = t_1.pdate))
1212-
-> CTE Scan on tmp
1213-
Filter: (test_mode > 0)
1214-
-> Hash
1215-
-> Index Scan using cte_del_xacts_1_pkey on cte_del_xacts_1 t_1
1216-
-> Hash Join
1217-
Hash Cond: ((tmp.tid = t_2.id) AND (tmp.pdate = t_2.pdate))
1218-
-> CTE Scan on tmp
1219-
Filter: (test_mode > 0)
1220-
-> Hash
1221-
-> Index Scan using cte_del_xacts_2_pkey on cte_del_xacts_2 t_2
1222-
(24 rows)
1223-
1224-
SELECT pathman.drop_partitions('test.cte_del_xacts'); /* now drop partitions */
1225-
NOTICE: function test.cte_del_xacts_upd_trig_func() does not exist, skipping
1226-
NOTICE: 50 rows copied from test.cte_del_xacts_1
1227-
NOTICE: 50 rows copied from test.cte_del_xacts_2
1228-
drop_partitions
1229-
-----------------
1230-
2
1231-
(1 row)
1232-
1233-
/* create 1 partition */
1234-
SELECT pathman.create_range_partitions('test.cte_del_xacts'::regclass, 'pdate', '2016-01-01'::date, '1 year'::interval);
1235-
create_range_partitions
1236-
-------------------------
1237-
1
1238-
(1 row)
1239-
1240-
/* parent enabled! */
1241-
SELECT pathman.set_enable_parent('test.cte_del_xacts', true);
1242-
set_enable_parent
1243-
-------------------
1244-
1245-
(1 row)
1246-
1247-
EXPLAIN (COSTS OFF)
1248-
WITH tmp AS (
1249-
SELECT tid, test_mode, regtime::DATE AS pdate, state_code
1250-
FROM test.cte_del_xacts_specdata)
1251-
DELETE FROM test.cte_del_xacts t USING tmp
1252-
WHERE t.id = tmp.tid AND t.pdate = tmp.pdate AND tmp.test_mode > 0;
1253-
QUERY PLAN
1254-
--------------------------------------------------------------------------------
1255-
Delete on cte_del_xacts t
1256-
Delete on cte_del_xacts t
1257-
Delete on cte_del_xacts_1 t_1
1258-
CTE tmp
1259-
-> Seq Scan on cte_del_xacts_specdata
1260-
-> Hash Join
1261-
Hash Cond: ((tmp.tid = t.id) AND (tmp.pdate = t.pdate))
1262-
-> CTE Scan on tmp
1263-
Filter: (test_mode > 0)
1264-
-> Hash
1265-
-> Index Scan using cte_del_xacts_pkey on cte_del_xacts t
1266-
-> Hash Join
1267-
Hash Cond: ((tmp.tid = t_1.id) AND (tmp.pdate = t_1.pdate))
1268-
-> CTE Scan on tmp
1269-
Filter: (test_mode > 0)
1270-
-> Hash
1271-
-> Index Scan using cte_del_xacts_1_pkey on cte_del_xacts_1 t_1
1272-
(17 rows)
1273-
1274-
/* parent disabled! */
1275-
SELECT pathman.set_enable_parent('test.cte_del_xacts', false);
1276-
set_enable_parent
1277-
-------------------
1278-
1279-
(1 row)
1280-
1281-
EXPLAIN (COSTS OFF)
1282-
WITH tmp AS (
1283-
SELECT tid, test_mode, regtime::DATE AS pdate, state_code
1284-
FROM test.cte_del_xacts_specdata)
1285-
DELETE FROM test.cte_del_xacts t USING tmp
1286-
WHERE t.id = tmp.tid AND t.pdate = tmp.pdate AND tmp.test_mode > 0;
1287-
QUERY PLAN
1288-
------------------------------------------------------------------------------
1289-
Delete on cte_del_xacts_1 t
1290-
CTE tmp
1291-
-> Seq Scan on cte_del_xacts_specdata
1292-
-> Hash Join
1293-
Hash Cond: ((tmp.tid = t.id) AND (tmp.pdate = t.pdate))
1294-
-> CTE Scan on tmp
1295-
Filter: (test_mode > 0)
1296-
-> Hash
1297-
-> Index Scan using cte_del_xacts_1_pkey on cte_del_xacts_1 t
1298-
(9 rows)
1299-
1300-
/* create stub pl/PgSQL function */
1301-
CREATE OR REPLACE FUNCTION test.cte_del_xacts_stab(name TEXT)
1302-
RETURNS smallint AS
1303-
$$
1304-
begin
1305-
return 2::smallint;
1306-
end
1307-
$$
1308-
LANGUAGE plpgsql STABLE;
1309-
/* test subquery planning */
1310-
WITH tmp AS (
1311-
SELECT tid FROM test.cte_del_xacts_specdata
1312-
WHERE state_code != test.cte_del_xacts_stab('test'))
1313-
SELECT * FROM test.cte_del_xacts t JOIN tmp ON t.id = tmp.tid;
1314-
id | pdate | tid
1315-
----+------------+-----
1316-
1 | 01-01-2016 | 1
1317-
(1 row)
1318-
1319-
/* test subquery planning (one more time) */
1320-
WITH tmp AS (
1321-
SELECT tid FROM test.cte_del_xacts_specdata
1322-
WHERE state_code != test.cte_del_xacts_stab('test'))
1323-
SELECT * FROM test.cte_del_xacts t JOIN tmp ON t.id = tmp.tid;
1324-
id | pdate | tid
1325-
----+------------+-----
1326-
1 | 01-01-2016 | 1
1327-
(1 row)
1328-
1329-
DROP FUNCTION test.cte_del_xacts_stab(TEXT);
1330-
DROP TABLE test.cte_del_xacts, test.cte_del_xacts_specdata CASCADE;
1331-
NOTICE: drop cascades to table test.cte_del_xacts_1
13321141
/*
13331142
* Test split and merge
13341143
*/
@@ -2244,32 +2053,6 @@ SELECT count(*) FROM bool_test WHERE b = true; /* 25 values */
22442053

22452054
DROP TABLE bool_test CASCADE;
22462055
NOTICE: drop cascades to 3 other objects
2247-
/* Test foreign keys */
2248-
CREATE TABLE test.messages(id SERIAL PRIMARY KEY, msg TEXT);
2249-
CREATE TABLE test.replies(id SERIAL PRIMARY KEY, message_id INTEGER REFERENCES test.messages(id), msg TEXT);
2250-
INSERT INTO test.messages SELECT g, md5(g::text) FROM generate_series(1, 10) as g;
2251-
INSERT INTO test.replies SELECT g, g, md5(g::text) FROM generate_series(1, 10) as g;
2252-
SELECT create_range_partitions('test.messages', 'id', 1, 100, 2);
2253-
WARNING: foreign key "replies_message_id_fkey" references relation "test.messages"
2254-
ERROR: relation "test.messages" is referenced from other relations
2255-
ALTER TABLE test.replies DROP CONSTRAINT replies_message_id_fkey;
2256-
SELECT create_range_partitions('test.messages', 'id', 1, 100, 2);
2257-
NOTICE: sequence "messages_seq" does not exist, skipping
2258-
create_range_partitions
2259-
-------------------------
2260-
2
2261-
(1 row)
2262-
2263-
EXPLAIN (COSTS OFF) SELECT * FROM test.messages;
2264-
QUERY PLAN
2265-
------------------------------
2266-
Append
2267-
-> Seq Scan on messages_1
2268-
-> Seq Scan on messages_2
2269-
(3 rows)
2270-
2271-
DROP TABLE test.messages, test.replies CASCADE;
2272-
NOTICE: drop cascades to 2 other objects
22732056
/* Special test case (quals generation) -- fixing commit f603e6c5 */
22742057
CREATE TABLE test.special_case_1_ind_o_s(val serial, comment text);
22752058
INSERT INTO test.special_case_1_ind_o_s SELECT generate_series(1, 200), NULL;
@@ -2392,44 +2175,6 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.index_on_childs WHERE c1 > 100 AND c1 < 2
23922175
Filter: (c1 < 2500)
23932176
(12 rows)
23942177

2395-
/* Test recursive CTE */
2396-
CREATE TABLE test.recursive_cte_test_tbl(id INT NOT NULL, name TEXT NOT NULL);
2397-
SELECT * FROM create_hash_partitions('test.recursive_cte_test_tbl', 'id', 2);
2398-
create_hash_partitions
2399-
------------------------
2400-
2
2401-
(1 row)
2402-
2403-
INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||id FROM generate_series(1,100) f(id);
2404-
INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||(id + 1) FROM generate_series(1,100) f(id);
2405-
INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||(id + 2) FROM generate_series(1,100) f(id);
2406-
SELECT * FROM test.recursive_cte_test_tbl WHERE id = 5;
2407-
id | name
2408-
----+-------
2409-
5 | name5
2410-
5 | name6
2411-
5 | name7
2412-
(3 rows)
2413-
2414-
WITH RECURSIVE test AS (
2415-
SELECT min(name) AS name
2416-
FROM test.recursive_cte_test_tbl
2417-
WHERE id = 5
2418-
UNION ALL
2419-
SELECT (SELECT min(name)
2420-
FROM test.recursive_cte_test_tbl
2421-
WHERE id = 5 AND name > test.name)
2422-
FROM test
2423-
WHERE name IS NOT NULL)
2424-
SELECT * FROM test;
2425-
name
2426-
-------
2427-
name5
2428-
name6
2429-
name7
2430-
2431-
(4 rows)
2432-
24332178
/* Test create_range_partitions() + relnames */
24342179
CREATE TABLE test.provided_part_names(id INT NOT NULL);
24352180
INSERT INTO test.provided_part_names SELECT generate_series(1, 10);
@@ -2456,6 +2201,6 @@ ORDER BY partition;
24562201
DROP TABLE test.provided_part_names CASCADE;
24572202
NOTICE: drop cascades to 2 other objects
24582203
DROP SCHEMA test CASCADE;
2459-
NOTICE: drop cascades to 54 other objects
2204+
NOTICE: drop cascades to 49 other objects
24602205
DROP EXTENSION pg_pathman CASCADE;
24612206
DROP SCHEMA pathman CASCADE;

0 commit comments

Comments
 (0)