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

Commit3d50c79

Browse files
committed
Merge branch 'PGPRO_EE' ofhttps://github.com/postgrespro/pg_pathman into PGPRO_EE
2 parents456de9c +526fe9d commit3d50c79

30 files changed

+923
-233
lines changed

‎.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*]
2+
indent_style =tab
3+
indent_size =4

‎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.1",
5+
"version":"1.4.2",
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.1",
27+
"version":"1.4.2",
2828
"abstract":"Partitioning tool"
2929
}
3030
},

‎Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
77
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o\
88
src/hooks.o src/nodes_common.o src/xact_handling.o src/utility_stmt_hooking.o\
99
src/planner_tree_modification.o src/debug_print.o src/partition_creation.o\
10-
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/expand_rte_hook.o\
11-
src/compat/rowmarks_fix.o$(WIN32RES)
10+
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/rowmarks_fix.o\
11+
$(WIN32RES)
1212

1313
overridePG_CPPFLAGS += -I$(CURDIR)/src/include
1414

‎expected/pathman_basic.out

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PL/pgSQL function pathman.prepare_for_partitioning(regclass,text,boolean) line 9
1818
SQL statement "SELECT pathman.prepare_for_partitioning(parent_relid,
1919
expression,
2020
partition_data)"
21-
PL/pgSQL function pathman.create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
21+
PL/pgSQL function pathman.create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
2222
\set VERBOSITY terse
2323
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
2424
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3, partition_data:=false);
@@ -1657,7 +1657,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt > '2010-12-15';
16571657
CREATE TABLE test.tmp (id INTEGER NOT NULL, value INTEGER NOT NULL);
16581658
INSERT INTO test.tmp VALUES (1, 1), (2, 2);
16591659
/* Test UPDATE and DELETE */
1660-
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 111 WHERE dt = '2010-06-15';
1660+
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 111 WHERE dt = '2010-06-15';/* have partitions for this 'dt' */
16611661
QUERY PLAN
16621662
--------------------------------------------------------------------------------
16631663
Update on range_rel_6
@@ -1672,7 +1672,7 @@ SELECT * FROM test.range_rel WHERE dt = '2010-06-15';
16721672
166 | Tue Jun 15 00:00:00 2010 | 111
16731673
(1 row)
16741674

1675-
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt = '2010-06-15';
1675+
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt = '2010-06-15';/* have partitions for this 'dt' */
16761676
QUERY PLAN
16771677
--------------------------------------------------------------------------------
16781678
Delete on range_rel_6
@@ -1686,6 +1686,34 @@ SELECT * FROM test.range_rel WHERE dt = '2010-06-15';
16861686
----+----+-------
16871687
(0 rows)
16881688

1689+
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 222 WHERE dt = '1990-01-01';/* no partitions for this 'dt' */
1690+
QUERY PLAN
1691+
--------------------------------------------------------------------------------
1692+
Update on range_rel
1693+
-> Seq Scan on range_rel
1694+
Filter: (dt = 'Mon Jan 01 00:00:00 1990'::timestamp without time zone)
1695+
(3 rows)
1696+
1697+
UPDATE test.range_rel SET value = 111 WHERE dt = '1990-01-01';
1698+
SELECT * FROM test.range_rel WHERE dt = '1990-01-01';
1699+
id | dt | value
1700+
----+----+-------
1701+
(0 rows)
1702+
1703+
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt < '1990-01-01';/* no partitions for this 'dt' */
1704+
QUERY PLAN
1705+
--------------------------------------------------------------------------------
1706+
Delete on range_rel
1707+
-> Seq Scan on range_rel
1708+
Filter: (dt < 'Mon Jan 01 00:00:00 1990'::timestamp without time zone)
1709+
(3 rows)
1710+
1711+
DELETE FROM test.range_rel WHERE dt < '1990-01-01';
1712+
SELECT * FROM test.range_rel WHERE dt < '1990-01-01';
1713+
id | dt | value
1714+
----+----+-------
1715+
(0 rows)
1716+
16891717
EXPLAIN (COSTS OFF) UPDATE test.range_rel r SET value = t.value FROM test.tmp t WHERE r.dt = '2010-01-01' AND r.id = t.id;
16901718
QUERY PLAN
16911719
--------------------------------------------------------------------------------------------

‎expected/pathman_bgw.out

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,43 @@ SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 par
105105

106106
DROP TABLE test_bgw.test_4 CASCADE;
107107
NOTICE: drop cascades to 4 other objects
108+
/* test error handling in BGW */
109+
CREATE TABLE test_bgw.test_5(val INT4 NOT NULL);
110+
SELECT create_range_partitions('test_bgw.test_5', 'val', 1, 10, 2);
111+
create_range_partitions
112+
-------------------------
113+
2
114+
(1 row)
115+
116+
CREATE OR REPLACE FUNCTION test_bgw.abort_xact(args JSONB)
117+
RETURNS VOID AS $$
118+
BEGIN
119+
RAISE EXCEPTION 'aborting xact!';
120+
END
121+
$$ language plpgsql;
122+
SELECT set_spawn_using_bgw('test_bgw.test_5', true);
123+
set_spawn_using_bgw
124+
---------------------
125+
126+
(1 row)
127+
128+
SELECT set_init_callback('test_bgw.test_5', 'test_bgw.abort_xact(jsonb)');
129+
set_init_callback
130+
-------------------
131+
132+
(1 row)
133+
134+
INSERT INTO test_bgw.test_5 VALUES (-100);
135+
ERROR: Attempt to spawn new partitions of relation "test_5" failed
136+
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
137+
parent | partition | parttype | expr | range_min | range_max
138+
-----------------+-------------------+----------+------+-----------+-----------
139+
test_bgw.test_5 | test_bgw.test_5_1 | 2 | val | 1 | 11
140+
test_bgw.test_5 | test_bgw.test_5_2 | 2 | val | 11 | 21
141+
(2 rows)
142+
143+
DROP FUNCTION test_bgw.abort_xact(args JSONB);
144+
DROP TABLE test_bgw.test_5 CASCADE;
145+
NOTICE: drop cascades to 3 other objects
108146
DROP SCHEMA test_bgw CASCADE;
109147
DROP EXTENSION pg_pathman;

‎expected/pathman_calamity.out

Lines changed: 1 addition & 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-
10401
15+
10402
1616
(1 row)
1717

1818
set client_min_messages = NOTICE;

‎expected/pathman_callbacks.out

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
\set VERBOSITY terse
22
CREATE EXTENSION pg_pathman;
33
CREATE SCHEMA callbacks;
4-
/*Check callbacks */
4+
/*callback #1 */
55
CREATE OR REPLACE FUNCTION callbacks.abc_on_part_created_callback(args JSONB)
66
RETURNS VOID AS $$
77
BEGIN
88
RAISE WARNING 'callback arg: %', args::TEXT;
99
END
1010
$$ language plpgsql;
11-
/* callbackis in public namespace, must be schema-qualified */
11+
/* callback#2 */
1212
CREATE OR REPLACE FUNCTION public.dummy_cb(args JSONB)
1313
RETURNS VOID AS $$
1414
BEGIN
@@ -184,15 +184,11 @@ WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_2",
184184

185185
INSERT INTO callbacks.abc VALUES (201, 0); /* +1 new partition */
186186
WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_3", "range_max": "301", "range_min": "201", "parent_schema": "callbacks", "partition_schema": "callbacks"}
187+
BEGIN;
187188
DROP FUNCTION callbacks.abc_on_part_created_callback(jsonb);
188189
INSERT INTO callbacks.abc VALUES (301, 0); /* +0 new partitions (ERROR) */
189190
ERROR: callback function "callbacks.abc_on_part_created_callback(jsonb)" does not exist
190-
CREATE OR REPLACE FUNCTION callbacks.abc_on_part_created_callback(args JSONB)
191-
RETURNS VOID AS $$
192-
BEGIN
193-
RAISE WARNING 'callback arg: %', args::TEXT;
194-
END
195-
$$ language plpgsql;
191+
ROLLBACK;
196192
INSERT INTO callbacks.abc VALUES (301, 0); /* +1 new partition */
197193
WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_5", "range_max": "401", "range_min": "301", "parent_schema": "callbacks", "partition_schema": "callbacks"}
198194
DROP TABLE callbacks.abc CASCADE;
@@ -211,22 +207,22 @@ CREATE OR REPLACE FUNCTION callbacks.rotation_callback(params jsonb)
211207
RETURNS VOID AS
212208
$$
213209
DECLARE
214-
relationregclass;
210+
relationregclass;
215211
parent_relregclass;
216212
BEGIN
217213
parent_rel := concat(params->>'partition_schema', '.', params->>'parent')::regclass;
218214

219-
-- drop "old" partitions
220-
FOR relation IN (SELECT partition FROM
215+
-- drop "old" partitions
216+
FOR relation IN (SELECT partition FROM
221217
(SELECT partition, range_min::INT4 FROM pathman_partition_list
222218
WHERE parent = parent_rel
223219
ORDER BY range_min::INT4 DESC
224220
OFFSET 4) t -- remain 4 last partitions
225221
ORDER BY range_min)
226-
LOOP
227-
RAISE NOTICE 'dropping partition %', relation;
228-
PERFORM drop_range_partition(relation);
229-
END LOOP;
222+
LOOP
223+
RAISE NOTICE 'dropping partition %', relation;
224+
PERFORM drop_range_partition(relation);
225+
END LOOP;
230226
END
231227
$$ LANGUAGE plpgsql;
232228
SELECT * FROM pathman_partition_list

‎expected/pathman_expressions.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
234234
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
235235
expression,
236236
partition_data)"
237-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
237+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
238238
/* Try using system attributes */
239239
SELECT create_hash_partitions('test_exprs.hash_rel', 'xmin', 4);
240240
ERROR: failed to analyze partitioning expression "xmin"
@@ -244,7 +244,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
244244
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
245245
expression,
246246
partition_data)"
247-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
247+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
248248
/* Try using subqueries */
249249
SELECT create_hash_partitions('test_exprs.hash_rel',
250250
'value, (select oid from pg_class limit 1)',
@@ -256,7 +256,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
256256
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
257257
expression,
258258
partition_data)"
259-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
259+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
260260
/* Try using mutable expression */
261261
SELECT create_hash_partitions('test_exprs.hash_rel', 'random()', 4);
262262
ERROR: failed to analyze partitioning expression "random()"
@@ -266,7 +266,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
266266
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
267267
expression,
268268
partition_data)"
269-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
269+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
270270
/* Try using broken parentheses */
271271
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value2))', 4);
272272
ERROR: failed to parse partitioning expression "value * value2))"
@@ -276,7 +276,7 @@ CONTEXT: PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line
276276
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
277277
expression,
278278
partition_data)"
279-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
279+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
280280
/* Try using missing columns */
281281
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value3', 4);
282282
ERROR: failed to analyze partitioning expression "value * value3"
@@ -287,7 +287,7 @@ CONTEXT: PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line
287287
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
288288
expression,
289289
partition_data)"
290-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line4 at PERFORM
290+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line3 at PERFORM
291291
/* Check that 'pathman_hooks_enabled' is true (1 partition in plan) */
292292
EXPLAIN (COSTS OFF) INSERT INTO test_exprs.canary_copy
293293
SELECT * FROM test_exprs.canary WHERE val = 1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp