Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit867b37f

Browse files
committed
Merge commit '15e574e73d70cf959447f7b12a6b600d1b3bc937' into PGPRO9_6_pathman
2 parentsf1861df +15e574e commit867b37f

27 files changed

+1172
-630
lines changed

‎contrib/pg_pathman/Makefile

Lines changed: 13 additions & 4 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,32 @@ 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\
24+
pathman_cte\
25+
pathman_bgw\
1926
pathman_inserts\
20-
pathman_runtime_nodes\
21-
pathman_callbacks\
2227
pathman_domains\
28+
pathman_interval\
29+
pathman_callbacks\
2330
pathman_foreign_keys\
2431
pathman_permissions\
2532
pathman_rowmarks\
33+
pathman_runtime_nodes\
2634
pathman_utility_stmt_hooking\
27-
pathman_calamity\
28-
pathman_interval
35+
pathman_calamity
36+
2937
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
38+
3039
EXTRA_CLEAN = pg_pathman--$(EXTVERSION).sql ./isolation_output
3140

3241
ifdefUSE_PGXS

‎contrib/pg_pathman/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ Done! Now it's time to setup your partitioning schemes.
8484
create_hash_partitions(relation REGCLASS,
8585
attributeTEXT,
8686
partitions_countINTEGER,
87-
partition_dataBOOLEAN DEFAULT TRUE)
87+
partition_dataBOOLEAN DEFAULT TRUE,
88+
partition_namesTEXT[] DEFAULTNULL,
89+
tablespacesTEXT[] DEFAULTNULL)
8890
```
8991
Performs HASH partitioning for`relation` by integer key`attribute`. The`partitions_count` parameter specifies the number of partitions to create; it cannot be changed afterwards. If`partition_data` is`true` then all the data will be automatically copied from the parent table to partitions. Note that data migration may took a while to finish and the table will be locked until transaction commits. See`partition_table_concurrently()` for a lock-free way to migrate data. Partition creation callback is invoked for each partition if set beforehand (see`set_init_callback()`).
9092

@@ -148,9 +150,9 @@ Same as above, but for a RANGE-partitioned table.
148150

149151
###Post-creation partition management
150152
```plpgsql
151-
replace_hash_partition(old_partitionREGCLASS,
152-
new_partitionREGCLASS,
153-
lock_parentBOOL DEFAULT TRUE)
153+
replace_hash_partition(old_partition REGCLASS,
154+
new_partition REGCLASS,
155+
lock_parent BOOL DEFAULT TRUE)
154156
```
155157
Replaces specified partition of HASH-partitioned table with another table. The`lock_parent` parameter will prevent any INSERT/UPDATE/ALTER TABLE queries to parent table.
156158

@@ -168,7 +170,7 @@ merge_range_partitions(partition1 REGCLASS, partition2 REGCLASS)
168170
Merge two adjacent RANGE partitions. First, data from`partition2` is copied to`partition1`, then`partition2` is removed.
169171

170172
```plpgsql
171-
merge_range_partitions(partitionsREGCLASS[])
173+
merge_range_partitions(partitions REGCLASS[])
172174
```
173175
Merge several adjacent RANGE partitions (partitions must be specified in ascending or descending order). All the data will be accumulated in the first partition.
174176

‎contrib/pg_pathman/expected/pathman_basic.out

Lines changed: 3 additions & 261 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,52 +2175,11 @@ 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-
2433-
/* Test create_range_partitions() + relnames */
2178+
/* Test create_range_partitions() + partition_names */
24342179
CREATE TABLE test.provided_part_names(id INT NOT NULL);
24352180
INSERT INTO test.provided_part_names SELECT generate_series(1, 10);
24362181
SELECT create_hash_partitions('test.provided_part_names', 'id', 2,
2437-
relnames := ARRAY[]::TEXT[]);/* not ok */
2438-
ERROR: size of array 'relnames' must be equal to 'partitions_count'
2439-
SELECT create_hash_partitions('test.provided_part_names', 'id', 2,
2440-
relnames := ARRAY['p1', 'p2']::TEXT[]);/* ok */
2182+
partition_names := ARRAY['p1', 'p2']::TEXT[]); /* ok */
24412183
create_hash_partitions
24422184
------------------------
24432185
2
@@ -2456,6 +2198,6 @@ ORDER BY partition;
24562198
DROP TABLE test.provided_part_names CASCADE;
24572199
NOTICE: drop cascades to 2 other objects
24582200
DROP SCHEMA test CASCADE;
2459-
NOTICE: drop cascades to54 other objects
2201+
NOTICE: drop cascades to49 other objects
24602202
DROP EXTENSION pg_pathman CASCADE;
24612203
DROP SCHEMA pathman CASCADE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp