Skip to content

Commit 2f7af48

Browse files
committed
Merged newer pathman
2 parents f04468f + 485f025 commit 2f7af48

39 files changed

+2903
-605
lines changed

contrib/pg_pathman/META.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pg_pathman",
33
"abstract": "Partitioning tool",
44
"description": "The `pg_pathman` module provides optimized partitioning mechanism and functions to manage partitions.",
5-
"version": "1.4.3",
5+
"version": "1.4.6",
66
"maintainer": [
77
"Ildar Musin <i.musin@postgrespro.ru>",
88
"Dmitry Ivanov <d.ivanov@postgrespro.ru>",
@@ -24,7 +24,7 @@
2424
"pg_pathman": {
2525
"file": "pg_pathman--1.4.sql",
2626
"docfile": "README.md",
27-
"version": "1.4.3",
27+
"version": "1.4.6",
2828
"abstract": "Partitioning tool"
2929
}
3030
},

contrib/pg_pathman/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
1010
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/rowmarks_fix.o \
1111
$(WIN32RES)
1212

13+
ifdef USE_PGXS
14+
override PG_CPPFLAGS += -I$(CURDIR)/src/include
15+
else
1316
override PG_CPPFLAGS += -I$(top_srcdir)/$(subdir)/src/include
17+
endif
1418

1519
EXTENSION = pg_pathman
1620

@@ -35,6 +39,7 @@ REGRESS = pathman_array_qual \
3539
pathman_domains \
3640
pathman_expressions \
3741
pathman_foreign_keys \
42+
pathman_gaps \
3843
pathman_inserts \
3944
pathman_interval \
4045
pathman_join_clause \
@@ -48,7 +53,8 @@ REGRESS = pathman_array_qual \
4853
pathman_runtime_nodes \
4954
pathman_update_trigger \
5055
pathman_upd_del \
51-
pathman_utility_stmt
56+
pathman_utility_stmt \
57+
pathman_views
5258

5359
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
5460

contrib/pg_pathman/expected/pathman_bgw.out

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ SELECT set_init_callback('test_bgw.test_5', 'test_bgw.abort_xact(jsonb)');
132132
(1 row)
133133

134134
INSERT INTO test_bgw.test_5 VALUES (-100);
135-
ERROR: Attempt to spawn new partitions of relation "test_5" failed
135+
ERROR: attempt to spawn new partitions of relation "test_5" failed
136136
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
137137
parent | partition | parttype | expr | range_min | range_max
138138
-----------------+-------------------+----------+------+-----------+-----------
@@ -143,5 +143,80 @@ SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 par
143143
DROP FUNCTION test_bgw.abort_xact(args JSONB);
144144
DROP TABLE test_bgw.test_5 CASCADE;
145145
NOTICE: drop cascades to 3 other objects
146+
/*
147+
* Tests for ConcurrentPartWorker
148+
*/
149+
CREATE TABLE test_bgw.conc_part(id INT4 NOT NULL);
150+
INSERT INTO test_bgw.conc_part SELECT generate_series(1, 500);
151+
SELECT create_hash_partitions('test_bgw.conc_part', 'id', 5, false);
152+
create_hash_partitions
153+
------------------------
154+
5
155+
(1 row)
156+
157+
BEGIN;
158+
/* Also test FOR SHARE/UPDATE conflicts in BGW */
159+
SELECT * FROM test_bgw.conc_part ORDER BY id LIMIT 1 FOR SHARE;
160+
id
161+
----
162+
1
163+
(1 row)
164+
165+
/* Run partitioning bgworker */
166+
SELECT partition_table_concurrently('test_bgw.conc_part', 10, 1);
167+
NOTICE: worker started, you can stop it with the following command: select public.stop_concurrent_part_task('conc_part');
168+
partition_table_concurrently
169+
------------------------------
170+
171+
(1 row)
172+
173+
/* Wait until bgworker starts */
174+
SELECT pg_sleep(1);
175+
pg_sleep
176+
----------
177+
178+
(1 row)
179+
180+
ROLLBACK;
181+
/* Wait until it finises */
182+
DO $$
183+
DECLARE
184+
ops int8;
185+
BEGIN
186+
LOOP
187+
SELECT count(*)
188+
FROM pathman_concurrent_part_tasks
189+
WHERE processed < 500 -- protect from endless loops
190+
INTO ops;
191+
192+
IF ops > 0 THEN
193+
PERFORM pg_sleep(0.2);
194+
ELSE
195+
EXIT;
196+
END IF;
197+
END LOOP;
198+
END
199+
$$ LANGUAGE plpgsql;
200+
/* Check amount of tasks and rows in parent and partitions */
201+
SELECT count(*) FROM pathman_concurrent_part_tasks;
202+
count
203+
-------
204+
0
205+
(1 row)
206+
207+
SELECT count(*) FROM ONLY test_bgw.conc_part;
208+
count
209+
-------
210+
0
211+
(1 row)
212+
213+
SELECT count(*) FROM test_bgw.conc_part;
214+
count
215+
-------
216+
500
217+
(1 row)
218+
219+
DROP TABLE test_bgw.conc_part CASCADE;
220+
NOTICE: drop cascades to 5 other objects
146221
DROP SCHEMA test_bgw CASCADE;
147222
DROP EXTENSION pg_pathman;

contrib/pg_pathman/expected/pathman_calamity.out

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SELECT debug_capture();
1212
SELECT get_pathman_lib_version();
1313
get_pathman_lib_version
1414
-------------------------
15-
10403
15+
10406
1616
(1 row)
1717

1818
set client_min_messages = NOTICE;
@@ -855,6 +855,25 @@ NOTICE: drop cascades to 2 other objects
855855
DROP SCHEMA calamity CASCADE;
856856
NOTICE: drop cascades to 15 other objects
857857
DROP EXTENSION pg_pathman;
858+
/*
859+
* -------------------------------
860+
* Special tests (SET statement)
861+
* -------------------------------
862+
*/
863+
CREATE EXTENSION pg_pathman;
864+
SET pg_pathman.enable = false;
865+
NOTICE: RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes and some other options have been disabled
866+
SET pg_pathman.enable = true;
867+
NOTICE: RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes and some other options have been enabled
868+
SET pg_pathman.enable = false;
869+
NOTICE: RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes and some other options have been disabled
870+
RESET pg_pathman.enable;
871+
NOTICE: RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes and some other options have been enabled
872+
RESET ALL;
873+
BEGIN; ROLLBACK;
874+
BEGIN ISOLATION LEVEL SERIALIZABLE; ROLLBACK;
875+
BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; ROLLBACK;
876+
DROP EXTENSION pg_pathman;
858877
/*
859878
* -------------------------------------
860879
* Special tests (pathman_cache_stats)

0 commit comments

Comments
 (0)