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

Commitf89f606

Browse files
committed
Merge branch 'rel_1_3_beta' into fix_flag_IsBgWorker
2 parentsb0e32cd +29806bc commitf89f606

10 files changed

+311
-92
lines changed

‎expected/pathman_calamity.out

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ SELECT debug_capture();
99

1010
(1 row)
1111

12+
SELECT get_pathman_lib_version();
13+
get_pathman_lib_version
14+
-------------------------
15+
10300
16+
(1 row)
17+
1218
set client_min_messages = NOTICE;
1319
/* create table to be partitioned */
1420
CREATE TABLE calamity.part_test(val serial);
@@ -396,30 +402,69 @@ SELECT drop_range_partition_expand_next(NULL) IS NULL;
396402
t
397403
(1 row)
398404

399-
/* check invoke_on_partition_created_callback() for RANGE */
400-
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, NULL, NULL::int);
401-
ERROR: both bounds must be provided for RANGE partition
402-
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, 1, NULL);
403-
ERROR: both bounds must be provided for RANGE partition
404-
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, NULL, 1);
405-
ERROR: both bounds must be provided for RANGE partition
406-
/* check invoke_on_partition_created_callback() for HASH */
405+
/* check invoke_on_partition_created_callback() */
406+
CREATE FUNCTION calamity.dummy_cb(arg jsonb) RETURNS void AS $$
407+
begin
408+
raise warning 'arg: %', arg::text;
409+
end
410+
$$ LANGUAGE plpgsql;
411+
/* Invalid args */
412+
SELECT invoke_on_partition_created_callback(NULL, 'calamity.part_test', 1);
413+
ERROR: 'parent_relid' should not be NULL
414+
SELECT invoke_on_partition_created_callback('calamity.part_test', NULL, 1);
415+
ERROR: 'partition' should not be NULL
416+
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 0);
417+
invoke_on_partition_created_callback
418+
--------------------------------------
419+
420+
(1 row)
421+
422+
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1);
423+
ERROR: callback function 1 does not exist
407424
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', NULL);
408425
invoke_on_partition_created_callback
409426
--------------------------------------
410427

411428
(1 row)
412429

413-
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 0);
430+
/* HASH */
431+
SELECT invoke_on_partition_created_callback(0::regclass, 1::regclass, 'calamity.dummy_cb(jsonb)'::regprocedure);
432+
WARNING: arg: {"parent": null, "parttype": "1", "partition": null, "parent_schema": null, "partition_schema": null}
414433
invoke_on_partition_created_callback
415434
--------------------------------------
416435

417436
(1 row)
418437

419-
SELECT invoke_on_partition_created_callback(NULL, 'calamity.part_test', 1);
420-
ERROR: 'parent_relid' should not be NULL
421-
SELECT invoke_on_partition_created_callback('calamity.part_test', NULL, 1);
422-
ERROR: 'partition' should not be NULL
438+
/* RANGE */
439+
SELECT invoke_on_partition_created_callback('calamity.part_test'::regclass, 'pg_class'::regclass, 'calamity.dummy_cb(jsonb)'::regprocedure, NULL::int, NULL);
440+
WARNING: arg: {"parent": "part_test", "parttype": "2", "partition": "pg_class", "range_max": null, "range_min": null, "parent_schema": "calamity", "partition_schema": "pg_catalog"}
441+
invoke_on_partition_created_callback
442+
--------------------------------------
443+
444+
(1 row)
445+
446+
SELECT invoke_on_partition_created_callback(0::regclass, 1::regclass, 'calamity.dummy_cb(jsonb)'::regprocedure, NULL::int, NULL);
447+
WARNING: arg: {"parent": null, "parttype": "2", "partition": null, "range_max": null, "range_min": null, "parent_schema": null, "partition_schema": null}
448+
invoke_on_partition_created_callback
449+
--------------------------------------
450+
451+
(1 row)
452+
453+
SELECT invoke_on_partition_created_callback(0::regclass, 1::regclass, 'calamity.dummy_cb(jsonb)'::regprocedure, 1, NULL);
454+
WARNING: arg: {"parent": null, "parttype": "2", "partition": null, "range_max": null, "range_min": "1", "parent_schema": null, "partition_schema": null}
455+
invoke_on_partition_created_callback
456+
--------------------------------------
457+
458+
(1 row)
459+
460+
SELECT invoke_on_partition_created_callback(0::regclass, 1::regclass, 'calamity.dummy_cb(jsonb)'::regprocedure, NULL, 1);
461+
WARNING: arg: {"parent": null, "parttype": "2", "partition": null, "range_max": "1", "range_min": null, "parent_schema": null, "partition_schema": null}
462+
invoke_on_partition_created_callback
463+
--------------------------------------
464+
465+
(1 row)
466+
467+
DROP FUNCTION calamity.dummy_cb(arg jsonb);
423468
/* check function add_to_pathman_config() -- PHASE #1 */
424469
SELECT add_to_pathman_config(NULL, 'val');/* no table */
425470
ERROR: 'parent_relid' should not be NULL

‎expected/pathman_utility_stmt_hooking.out

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,82 @@ SELECT * FROM copy_stmt_hooking.test WHERE val > 20;
157157
21 | test_no_part | 0 | 0
158158
(1 row)
159159

160-
/* COPYTO (partitioned column is not specified) */
160+
/* COPYFROM (partitioned column is not specified) */
161161
COPY copy_stmt_hooking.test(comment) FROM stdin;
162162
ERROR: partitioned column's value should not be NULL
163-
/* delete all data */
164-
SELECT drop_partitions('copy_stmt_hooking.test', true);
165-
NOTICE: function copy_stmt_hooking.test_upd_trig_func() does not exist, skipping
166-
drop_partitions
167-
-----------------
168-
5
163+
/* COPY FROM (we don't support FREEZE) */
164+
COPY copy_stmt_hooking.test FROM stdin WITH (FREEZE);
165+
ERROR: freeze is not supported for partitioned tables
166+
/* Drop column (make use of 'tuple_map') */
167+
ALTER TABLE copy_stmt_hooking.test DROP COLUMN comment;
168+
/* create new partition */
169+
SELECT get_number_of_partitions('copy_stmt_hooking.test');
170+
get_number_of_partitions
171+
--------------------------
172+
5
169173
(1 row)
170174

175+
INSERT INTO copy_stmt_hooking.test (val, c3, c4) VALUES (26, 1, 2);
176+
SELECT get_number_of_partitions('copy_stmt_hooking.test');
177+
get_number_of_partitions
178+
--------------------------
179+
6
180+
(1 row)
181+
182+
/* check number of columns in 'test' */
183+
SELECT count(*) FROM pg_attribute
184+
WHERE attnum > 0 AND attrelid = 'copy_stmt_hooking.test'::REGCLASS;
185+
count
186+
-------
187+
4
188+
(1 row)
189+
190+
/* check number of columns in 'test_6' */
191+
SELECT count(*) FROM pg_attribute
192+
WHERE attnum > 0 AND attrelid = 'copy_stmt_hooking.test_6'::REGCLASS;
193+
count
194+
-------
195+
3
196+
(1 row)
197+
198+
/* COPY FROM (test transformed tuples) */
199+
COPY copy_stmt_hooking.test (val, c3, c4) TO stdout;
200+
100
201+
600
202+
700
203+
1100
204+
1600
205+
2100
206+
2612
207+
/* COPY TO (insert into table with dropped column) */
208+
COPY copy_stmt_hooking.test(val, c3, c4) FROM stdin;
209+
/* COPY TO (insert into table without dropped column) */
210+
COPY copy_stmt_hooking.test(val, c3, c4) FROM stdin;
211+
/* check tuples from last partition (without dropped column) */
212+
SELECT *, tableoid::REGCLASS FROM copy_stmt_hooking.test ORDER BY val;
213+
val | c3 | c4 | tableoid
214+
-----+----+----+--------------------------
215+
1 | 0 | 0 | copy_stmt_hooking.test_1
216+
2 | 1 | 2 | copy_stmt_hooking.test_1
217+
6 | 0 | 0 | copy_stmt_hooking.test_2
218+
7 | 0 | 0 | copy_stmt_hooking.test_2
219+
11 | 0 | 0 | copy_stmt_hooking.test_3
220+
16 | 0 | 0 | copy_stmt_hooking.test_4
221+
21 | 0 | 0 | copy_stmt_hooking.test_5
222+
26 | 1 | 2 | copy_stmt_hooking.test_6
223+
27 | 1 | 2 | copy_stmt_hooking.test_6
224+
(9 rows)
225+
226+
/* drop modified table */
227+
DROP TABLE copy_stmt_hooking.test CASCADE;
228+
NOTICE: drop cascades to 6 other objects
229+
/* create table again */
230+
CREATE TABLE copy_stmt_hooking.test(
231+
val int not null,
232+
comment text,
233+
c3 int,
234+
c4 int);
235+
CREATE INDEX ON copy_stmt_hooking.test(val);
171236
/* test for HASH partitioning */
172237
SELECT create_hash_partitions('copy_stmt_hooking.test', 'val', 5);
173238
create_hash_partitions

‎sql/pathman_calamity.sql

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CREATE SCHEMA calamity;
77
/* call for coverage test*/
88
set client_min_messages= ERROR;
99
SELECT debug_capture();
10+
SELECT get_pathman_lib_version();
1011
set client_min_messages= NOTICE;
1112

1213

@@ -153,16 +154,32 @@ SELECT stop_concurrent_part_task(1::regclass);
153154
SELECT drop_range_partition_expand_next('pg_class');
154155
SELECT drop_range_partition_expand_next(NULL) ISNULL;
155156

156-
/* check invoke_on_partition_created_callback() for RANGE*/
157-
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',1,NULL,NULL::int);
158-
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',1,1,NULL);
159-
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',1,NULL,1);
160157

161-
/* check invoke_on_partition_created_callback() for HASH*/
162-
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',NULL);
163-
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',0);
158+
/* check invoke_on_partition_created_callback()*/
159+
CREATEFUNCTIONcalamity.dummy_cb(arg jsonb) RETURNS voidAS $$
160+
begin
161+
raise warning'arg: %', arg::text;
162+
end
163+
$$ LANGUAGE plpgsql;
164+
165+
/* Invalid args*/
164166
SELECT invoke_on_partition_created_callback(NULL,'calamity.part_test',1);
165167
SELECT invoke_on_partition_created_callback('calamity.part_test',NULL,1);
168+
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',0);
169+
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',1);
170+
SELECT invoke_on_partition_created_callback('calamity.part_test','calamity.part_test',NULL);
171+
172+
/* HASH*/
173+
SELECT invoke_on_partition_created_callback(0::regclass,1::regclass,'calamity.dummy_cb(jsonb)'::regprocedure);
174+
175+
/* RANGE*/
176+
SELECT invoke_on_partition_created_callback('calamity.part_test'::regclass,'pg_class'::regclass,'calamity.dummy_cb(jsonb)'::regprocedure,NULL::int,NULL);
177+
SELECT invoke_on_partition_created_callback(0::regclass,1::regclass,'calamity.dummy_cb(jsonb)'::regprocedure,NULL::int,NULL);
178+
SELECT invoke_on_partition_created_callback(0::regclass,1::regclass,'calamity.dummy_cb(jsonb)'::regprocedure,1,NULL);
179+
SELECT invoke_on_partition_created_callback(0::regclass,1::regclass,'calamity.dummy_cb(jsonb)'::regprocedure,NULL,1);
180+
181+
DROPFUNCTIONcalamity.dummy_cb(arg jsonb);
182+
166183

167184
/* check function add_to_pathman_config() -- PHASE #1*/
168185
SELECT add_to_pathman_config(NULL,'val');/* no table*/

‎sql/pathman_utility_stmt_hooking.sql

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CREATE EXTENSION pg_pathman;
66
* Test COPY
77
*/
88
CREATESCHEMAcopy_stmt_hooking;
9+
910
CREATETABLEcopy_stmt_hooking.test(
1011
valintnot null,
1112
commenttext,
@@ -69,14 +70,61 @@ COPY copy_stmt_hooking.test FROM stdin;
6970
\.
7071
SELECT*FROMcopy_stmt_hooking.testWHERE val>20;
7172

72-
/* COPYTO (partitioned column is not specified)*/
73+
/* COPYFROM (partitioned column is not specified)*/
7374
COPYcopy_stmt_hooking.test(comment)FROM stdin;
7475
test_no_part
7576
\.
7677

78+
/* COPY FROM (we don't support FREEZE)*/
79+
COPYcopy_stmt_hooking.testFROM stdin WITH (FREEZE);
80+
81+
82+
/* Drop column (make use of 'tuple_map')*/
83+
ALTERTABLEcopy_stmt_hooking.test DROP COLUMN comment;
84+
85+
86+
/* create new partition*/
87+
SELECT get_number_of_partitions('copy_stmt_hooking.test');
88+
INSERT INTOcopy_stmt_hooking.test (val, c3, c4)VALUES (26,1,2);
89+
SELECT get_number_of_partitions('copy_stmt_hooking.test');
90+
91+
/* check number of columns in 'test'*/
92+
SELECTcount(*)FROM pg_attribute
93+
WHERE attnum>0AND attrelid='copy_stmt_hooking.test'::REGCLASS;
94+
95+
/* check number of columns in 'test_6'*/
96+
SELECTcount(*)FROM pg_attribute
97+
WHERE attnum>0AND attrelid='copy_stmt_hooking.test_6'::REGCLASS;
98+
99+
100+
/* COPY FROM (test transformed tuples)*/
101+
COPYcopy_stmt_hooking.test (val, c3, c4) TO stdout;
102+
103+
/* COPY TO (insert into table with dropped column)*/
104+
COPYcopy_stmt_hooking.test(val, c3, c4)FROM stdin;
105+
212
106+
\.
107+
108+
/* COPY TO (insert into table without dropped column)*/
109+
COPYcopy_stmt_hooking.test(val, c3, c4)FROM stdin;
110+
2712
111+
\.
112+
113+
/* check tuples from last partition (without dropped column)*/
114+
SELECT*, tableoid::REGCLASSFROMcopy_stmt_hooking.testORDER BY val;
115+
116+
117+
/* drop modified table*/
118+
DROPTABLEcopy_stmt_hooking.test CASCADE;
119+
77120

78-
/* delete all data*/
79-
SELECT drop_partitions('copy_stmt_hooking.test', true);
121+
/* create table again*/
122+
CREATETABLEcopy_stmt_hooking.test(
123+
valintnot null,
124+
commenttext,
125+
c3int,
126+
c4int);
127+
CREATEINDEXONcopy_stmt_hooking.test(val);
80128

81129

82130
/* test for HASH partitioning*/

‎src/hooks.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,11 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
468468

469469
PlannedStmt*result;
470470
uint32query_id=parse->queryId;
471+
boolpathman_ready=IsPathmanReady();/* in case it changes */
471472

472473
PG_TRY();
473474
{
474-
if (IsPathmanReady())
475+
if (pathman_ready)
475476
{
476477
/* Increment parenthood_statuses refcount */
477478
incr_refcount_parenthood_statuses();
@@ -486,7 +487,7 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
486487
else
487488
result=standard_planner(parse,cursorOptions,boundParams);
488489

489-
if (IsPathmanReady())
490+
if (pathman_ready)
490491
{
491492
/* Give rowmark-related attributes correct names */
492493
ExecuteForPlanTree(result,postprocess_lock_rows);
@@ -504,9 +505,13 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
504505
/* We must decrease parenthood statuses refcount on ERROR */
505506
PG_CATCH();
506507
{
507-
/* Caught an ERROR, decrease refcount */
508-
decr_refcount_parenthood_statuses();
508+
if (pathman_ready)
509+
{
510+
/* Caught an ERROR, decrease refcount */
511+
decr_refcount_parenthood_statuses();
512+
}
509513

514+
/* Rethrow ERROR further */
510515
PG_RE_THROW();
511516
}
512517
PG_END_TRY();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp