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

Commit1d8c48b

Browse files
committed
improve regression tests for COPY, fix relcache reference leaks in COPY, allow partition creation in COPY
1 parentfce7945 commit1d8c48b

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

‎expected/pathman_copy_stmt_hooking.out

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CREATE EXTENSION pg_pathman;
33
CREATE SCHEMA copy_stmt_hooking;
44
CREATE TABLE copy_stmt_hooking.test(val int not null, comment text);
55
INSERT INTO copy_stmt_hooking.test SELECT generate_series(1, 20), 'comment';
6+
CREATE INDEX ON copy_stmt_hooking.test(val);
67
/* test for RANGE partitioning */
78
SELECT create_range_partitions('copy_stmt_hooking.test', 'val', 1, 5);
89
NOTICE: sequence "test_seq" does not exist, skipping
@@ -12,6 +13,7 @@ NOTICE: sequence "test_seq" does not exist, skipping
1213
(1 row)
1314

1415
/* perform VACUUM */
16+
VACUUM FULL copy_stmt_hooking.test;
1517
VACUUM FULL copy_stmt_hooking.test_1;
1618
VACUUM FULL copy_stmt_hooking.test_2;
1719
VACUUM FULL copy_stmt_hooking.test_3;
@@ -99,17 +101,33 @@ SELECT *, tableoid::REGCLASS FROM copy_stmt_hooking.test ORDER BY val;
99101
16 | test_4 | copy_stmt_hooking.test_4
100102
(5 rows)
101103

102-
/* COPY TO (partition does not exist) */
104+
/* COPY TO (partition does not exist, NOT allowed to create partitions) */
105+
SET pg_pathman.enable_auto_partition = OFF;
103106
COPY copy_stmt_hooking.test FROM stdin;
104107
ERROR: no suitable partition for key '21'
108+
SELECT * FROM copy_stmt_hooking.test WHERE val > 20;
109+
val | comment
110+
-----+---------
111+
(0 rows)
112+
113+
/* COPY TO (partition does not exist, allowed to create partitions) */
114+
SET pg_pathman.enable_auto_partition = ON;
115+
COPY copy_stmt_hooking.test FROM stdin;
116+
SELECT * FROM copy_stmt_hooking.test WHERE val > 20;
117+
val | comment
118+
-----+--------------
119+
21 | test_no_part
120+
(1 row)
121+
122+
/* COPY TO (partitioned column is not specified) */
105123
COPY copy_stmt_hooking.test(comment) FROM stdin;
106124
ERROR: partitioned column's value should not be NULL
107125
/* delete all data */
108126
SELECT drop_partitions('copy_stmt_hooking.test', true);
109127
NOTICE: function copy_stmt_hooking.test_upd_trig_func() does not exist, skipping
110128
drop_partitions
111129
-----------------
112-
4
130+
5
113131
(1 row)
114132

115133
/* test for HASH partitioning */

‎sql/pathman_copy_stmt_hooking.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ CREATE SCHEMA copy_stmt_hooking;
66

77
CREATETABLEcopy_stmt_hooking.test(valintnot null, commenttext);
88
INSERT INTOcopy_stmt_hooking.testSELECT generate_series(1,20),'comment';
9+
CREATEINDEXONcopy_stmt_hooking.test(val);
910

1011

1112
/* test for RANGE partitioning*/
1213
SELECT create_range_partitions('copy_stmt_hooking.test','val',1,5);
1314

1415
/* perform VACUUM*/
16+
VACUUM FULLcopy_stmt_hooking.test;
1517
VACUUM FULLcopy_stmt_hooking.test_1;
1618
VACUUM FULLcopy_stmt_hooking.test_2;
1719
VACUUM FULLcopy_stmt_hooking.test_3;
@@ -34,10 +36,21 @@ COPY copy_stmt_hooking.test FROM stdin;
3436
SELECTcount(*)FROM ONLYcopy_stmt_hooking.test;
3537
SELECT*, tableoid::REGCLASSFROMcopy_stmt_hooking.testORDER BY val;
3638

37-
/* COPY TO (partition does not exist)*/
39+
/* COPY TO (partition does not exist, NOT allowed to create partitions)*/
40+
SETpg_pathman.enable_auto_partition= OFF;
3841
COPYcopy_stmt_hooking.testFROM stdin;
3942
21test_no_part
4043
\.
44+
SELECT*FROMcopy_stmt_hooking.testWHERE val>20;
45+
46+
/* COPY TO (partition does not exist, allowed to create partitions)*/
47+
SETpg_pathman.enable_auto_partition=ON;
48+
COPYcopy_stmt_hooking.testFROM stdin;
49+
21test_no_part
50+
\.
51+
SELECT*FROMcopy_stmt_hooking.testWHERE val>20;
52+
53+
/* COPY TO (partitioned column is not specified)*/
4154
COPYcopy_stmt_hooking.test(comment)FROM stdin;
4255
test_no_part
4356
\.

‎src/copy_stmt_hooking.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
466466
/* Search for a matching partition */
467467
rri_holder_child=select_partition_for_insert(prel,&parts_storage,
468468
values[prel->attnum-1],
469-
estate,false);
469+
estate,true);
470470
child_result_rel=rri_holder_child->result_rel_info;
471471
estate->es_result_relation_info=child_result_rel;
472472

@@ -556,6 +556,9 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
556556
/* Close partitions and destroy hash table */
557557
fini_result_parts_storage(&parts_storage, true);
558558

559+
/* Close parent's indices */
560+
ExecCloseIndices(parent_result_rel);
561+
559562
FreeExecutorState(estate);
560563

561564
returnprocessed;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp