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

Commit8834b71

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_expressions
2 parentse299b75 +3a60edb commit8834b71

10 files changed

+97
-140
lines changed

‎expected/pathman_basic.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel;
450450
-> Seq Scan on hash_rel_2
451451
(4 rows)
452452

453+
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = NULL;
454+
QUERY PLAN
455+
--------------------------
456+
Result
457+
One-Time Filter: false
458+
(2 rows)
459+
453460
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2;
454461
QUERY PLAN
455462
------------------------------
@@ -602,6 +609,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel;
602609
-> Seq Scan on hash_rel_2
603610
(4 rows)
604611

612+
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = NULL;
613+
QUERY PLAN
614+
--------------------------
615+
Result
616+
One-Time Filter: false
617+
(2 rows)
618+
605619
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2;
606620
QUERY PLAN
607621
------------------------------

‎expected/pathman_utility_stmt.out

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,33 @@ SELECT * FROM copy_stmt_hooking.test ORDER BY val;
256256
6 | hash_2 | 0 | 0
257257
(2 rows)
258258

259+
/* Check dropped colums before partitioning */
260+
CREATE TABLE copy_stmt_hooking.test2 (
261+
a varchar(50),
262+
b varchar(50),
263+
t timestamp without time zone not null
264+
);
265+
ALTER TABLE copy_stmt_hooking.test2 DROP COLUMN a;
266+
SELECT create_range_partitions('copy_stmt_hooking.test2',
267+
't',
268+
'2017-01-01 00:00:00'::timestamp,
269+
interval '1 hour', 5, false
270+
);
271+
NOTICE: sequence "test2_seq" does not exist, skipping
272+
create_range_partitions
273+
-------------------------
274+
5
275+
(1 row)
276+
277+
COPY copy_stmt_hooking.test2(t) FROM stdin;
278+
SELECT COUNT(*) FROM copy_stmt_hooking.test2;
279+
count
280+
-------
281+
1
282+
(1 row)
283+
259284
DROP SCHEMA copy_stmt_hooking CASCADE;
260-
NOTICE: drop cascades to7 other objects
285+
NOTICE: drop cascades to798 other objects
261286
/*
262287
* Test auto check constraint renaming
263288
*/

‎hash.sql

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ BEGIN
4444
partition_names,
4545
tablespaces);
4646

47-
/* Notify backend about changes*/
48-
PERFORM @extschema@.on_create_partitions(parent_relid);
49-
5047
/* Copy data*/
5148
IF partition_data= true THEN
5249
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -153,9 +150,6 @@ BEGIN
153150
new_partition,
154151
p_init_callback);
155152

156-
/* Invalidate cache*/
157-
PERFORM @extschema@.on_update_partitions(parent_relid);
158-
159153
RETURN new_partition;
160154
END
161155
$$

‎init.sql

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,6 @@ BEGIN
433433

434434
/* Drop triggers on update*/
435435
PERFORM @extschema@.drop_triggers(parent_relid);
436-
437-
/* Notify backend about changes*/
438-
PERFORM @extschema@.on_remove_partitions(parent_relid);
439436
END
440437
$$
441438
LANGUAGE plpgsql STRICT;
@@ -581,23 +578,22 @@ DECLARE
581578
v_recRECORD;
582579
v_rowsBIGINT;
583580
v_part_countINTEGER :=0;
584-
conf_num_delINTEGER;
581+
conf_numINTEGER;
585582
v_relkindCHAR;
586583

587584
BEGIN
588585
PERFORM @extschema@.validate_relname(parent_relid);
589586

590-
/* Drop trigger first*/
587+
/* Acquire data modification lock*/
588+
PERFORM @extschema@.prevent_relation_modification(parent_relid);
589+
590+
/* First, drop all triggers*/
591591
PERFORM @extschema@.drop_triggers(parent_relid);
592592

593-
WITH config_num_deletedAS (DELETEFROM @extschema@.pathman_config
594-
WHERE partrel= parent_relid
595-
RETURNING*)
596-
SELECTcount(*)from config_num_deleted INTO conf_num_del;
593+
SELECTcount(*)FROM @extschema@.pathman_config
594+
WHERE partrel= parent_relid INTO conf_num;
597595

598-
DELETEFROM @extschema@.pathman_config_paramsWHERE partrel= parent_relid;
599-
600-
IF conf_num_del=0 THEN
596+
IF conf_num=0 THEN
601597
RAISE EXCEPTION'relation "%" has no partitions', parent_relid::TEXT;
602598
END IF;
603599

@@ -621,8 +617,8 @@ BEGIN
621617
INTO v_relkind;
622618

623619
/*
624-
* Determine the kind of child relation. It can be either regular
625-
* table (r) or foreign table (f). Depending on relkind we use
620+
* Determine the kind of child relation. It can be eitheraregular
621+
* table (r) oraforeign table (f). Depending on relkind we use
626622
* DROP TABLE or DROP FOREIGN TABLE.
627623
*/
628624
IF v_relkind='f' THEN
@@ -634,8 +630,9 @@ BEGIN
634630
v_part_count := v_part_count+1;
635631
END LOOP;
636632

637-
/* Notify backend about changes*/
638-
PERFORM @extschema@.on_remove_partitions(parent_relid);
633+
/* Finally delete both config entries*/
634+
DELETEFROM @extschema@.pathman_configWHERE partrel= parent_relid;
635+
DELETEFROM @extschema@.pathman_config_paramsWHERE partrel= parent_relid;
639636

640637
RETURN v_part_count;
641638
END
@@ -759,23 +756,6 @@ ON sql_drop
759756
EXECUTE PROCEDURE @extschema@.pathman_ddl_trigger_func();
760757

761758

762-
763-
CREATEOR REPLACE FUNCTION @extschema@.on_create_partitions(
764-
relidREGCLASS)
765-
RETURNS VOIDAS'pg_pathman','on_partitions_created'
766-
LANGUAGE C STRICT;
767-
768-
CREATEOR REPLACE FUNCTION @extschema@.on_update_partitions(
769-
relidREGCLASS)
770-
RETURNS VOIDAS'pg_pathman','on_partitions_updated'
771-
LANGUAGE C STRICT;
772-
773-
CREATEOR REPLACE FUNCTION @extschema@.on_remove_partitions(
774-
relidREGCLASS)
775-
RETURNS VOIDAS'pg_pathman','on_partitions_removed'
776-
LANGUAGE C STRICT;
777-
778-
779759
/*
780760
* Get number of partitions managed by pg_pathman.
781761
*/

‎range.sql

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ BEGIN
170170
NULL);
171171
END IF;
172172

173-
/* Notify backend about changes*/
174-
PERFORM @extschema@.on_create_partitions(parent_relid);
175-
176173
/* Relocate data if asked to*/
177174
IF partition_data= true THEN
178175
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -268,9 +265,6 @@ BEGIN
268265
NULL);
269266
END IF;
270267

271-
/* Notify backend about changes*/
272-
PERFORM @extschema@.on_create_partitions(parent_relid);
273-
274268
/* Relocate data if asked to*/
275269
IF partition_data= true THEN
276270
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -327,9 +321,6 @@ BEGIN
327321
partition_names,
328322
tablespaces);
329323

330-
/* Notify backend about changes*/
331-
PERFORM @extschema@.on_create_partitions(parent_relid);
332-
333324
/* Relocate data if asked to*/
334325
IF partition_data= true THEN
335326
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -387,9 +378,6 @@ BEGIN
387378
part_count := part_count+1;
388379
END LOOP;
389380

390-
/* Notify backend about changes*/
391-
PERFORM @extschema@.on_create_partitions(parent_relid);
392-
393381
/* Relocate data if asked to*/
394382
IF partition_data= true THEN
395383
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -450,9 +438,6 @@ BEGIN
450438
part_count := part_count+1;
451439
END LOOP;
452440

453-
/* Notify backend about changes*/
454-
PERFORM @extschema@.on_create_partitions(parent_relid);
455-
456441
/* Relocate data if asked to*/
457442
IF partition_data= true THEN
458443
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -553,9 +538,6 @@ BEGIN
553538
partition_relid::TEXT,
554539
v_check_name,
555540
v_cond);
556-
557-
/* Tell backend to reload configuration*/
558-
PERFORM @extschema@.on_update_partitions(v_parent);
559541
END
560542
$$
561543
LANGUAGE plpgsql;
@@ -617,8 +599,6 @@ BEGIN
617599
INTO
618600
v_part_name;
619601

620-
/* Invalidate cache*/
621-
PERFORM @extschema@.on_update_partitions(parent_relid);
622602
RETURN v_part_name;
623603
END
624604
$$
@@ -727,8 +707,6 @@ BEGIN
727707
INTO
728708
v_part_name;
729709

730-
/* Invalidate cache*/
731-
PERFORM @extschema@.on_update_partitions(parent_relid);
732710
RETURN v_part_name;
733711
END
734712
$$
@@ -830,7 +808,6 @@ BEGIN
830808
end_value,
831809
partition_name,
832810
tablespace);
833-
PERFORM @extschema@.on_update_partitions(parent_relid);
834811

835812
RETURN v_part_name;
836813
END
@@ -895,9 +872,6 @@ BEGIN
895872
EXECUTE format('DROP TABLE %s', partition_relid::TEXT);
896873
END IF;
897874

898-
/* Invalidate cache*/
899-
PERFORM @extschema@.on_update_partitions(parent_relid);
900-
901875
RETURN part_name;
902876
END
903877
$$
@@ -980,9 +954,6 @@ BEGIN
980954
start_value,
981955
end_value);
982956

983-
/* Invalidate cache*/
984-
PERFORM @extschema@.on_update_partitions(parent_relid);
985-
986957
RETURN partition_relid;
987958
END
988959
$$
@@ -1028,9 +999,6 @@ BEGIN
1028999
@extschema@.build_update_trigger_name(parent_relid),
10291000
partition_relid::TEXT);
10301001

1031-
/* Invalidate cache*/
1032-
PERFORM @extschema@.on_update_partitions(parent_relid);
1033-
10341002
RETURN partition_relid;
10351003
END
10361004
$$

‎sql/pathman_basic.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ SET enable_bitmapscan = OFF;
165165
SET enable_seqscan=ON;
166166

167167
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_rel;
168+
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=NULL;
168169
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=2;
169170
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=2OR value=1;
170171

@@ -188,6 +189,7 @@ SET enable_bitmapscan = OFF;
188189
SET enable_seqscan= OFF;
189190

190191
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_rel;
192+
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=NULL;
191193
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=2;
192194
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE value=2OR value=1;
193195
EXPLAIN (COSTS OFF)SELECT*FROMtest.hash_relWHERE valueIN (2);

‎sql/pathman_utility_stmt.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ COPY copy_stmt_hooking.test FROM stdin;
139139
SELECTcount(*)FROM ONLYcopy_stmt_hooking.test;
140140
SELECT*FROMcopy_stmt_hooking.testORDER BY val;
141141

142+
/* Check dropped colums before partitioning*/
143+
CREATETABLEcopy_stmt_hooking.test2 (
144+
avarchar(50),
145+
bvarchar(50),
146+
ttimestamp without time zonenot null
147+
);
148+
ALTERTABLEcopy_stmt_hooking.test2 DROP COLUMN a;
149+
SELECT create_range_partitions('copy_stmt_hooking.test2',
150+
't',
151+
'2017-01-01 00:00:00'::timestamp,
152+
interval'1 hour',5, false
153+
);
154+
COPYcopy_stmt_hooking.test2(t)FROM stdin;
155+
2017-02-0220:00:00
156+
\.
157+
SELECTCOUNT(*)FROMcopy_stmt_hooking.test2;
158+
142159
DROPSCHEMA copy_stmt_hooking CASCADE;
143160

144161

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp