Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c80097

Browse files
committed
Merge branch 'rel_future_beta' of github.com:postgrespro/pg_pathman into rel_future_beta
2 parents 77d4164 + fce742d commit 7c80097

File tree

7 files changed

+49
-139
lines changed

7 files changed

+49
-139
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
------------------------------

hash.sql

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

48-
/* Notify backend about changes */
49-
PERFORM @extschema@.on_create_partitions(parent_relid);
50-
5148
/* Copy data */
5249
IF partition_data = true THEN
5350
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -156,9 +153,6 @@ BEGIN
156153
new_partition,
157154
p_init_callback);
158155

159-
/* Invalidate cache */
160-
PERFORM @extschema@.on_update_partitions(parent_relid);
161-
162156
RETURN new_partition;
163157
END
164158
$$

init.sql

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

433433
/* Drop triggers on update */
434434
PERFORM @extschema@.drop_triggers(parent_relid);
435-
436-
/* Notify backend about changes */
437-
PERFORM @extschema@.on_remove_partitions(parent_relid);
438435
END
439436
$$
440437
LANGUAGE plpgsql STRICT;
@@ -584,23 +581,22 @@ DECLARE
584581
v_rec RECORD;
585582
v_rows BIGINT;
586583
v_part_count INTEGER := 0;
587-
conf_num_del INTEGER;
584+
conf_num INTEGER;
588585
v_relkind CHAR;
589586

590587
BEGIN
591588
PERFORM @extschema@.validate_relname(parent_relid);
592589

593-
/* Drop trigger first */
590+
/* Acquire data modification lock */
591+
PERFORM @extschema@.prevent_relation_modification(parent_relid);
592+
593+
/* First, drop all triggers */
594594
PERFORM @extschema@.drop_triggers(parent_relid);
595595

596-
WITH config_num_deleted AS (DELETE FROM @extschema@.pathman_config
597-
WHERE partrel = parent_relid
598-
RETURNING *)
599-
SELECT count(*) from config_num_deleted INTO conf_num_del;
596+
SELECT count(*) FROM @extschema@.pathman_config
597+
WHERE partrel = parent_relid INTO conf_num;
600598

601-
DELETE FROM @extschema@.pathman_config_params WHERE partrel = parent_relid;
602-
603-
IF conf_num_del = 0 THEN
599+
IF conf_num = 0 THEN
604600
RAISE EXCEPTION 'relation "%" has no partitions', parent_relid::TEXT;
605601
END IF;
606602

@@ -624,8 +620,8 @@ BEGIN
624620
INTO v_relkind;
625621

626622
/*
627-
* Determine the kind of child relation. It can be either regular
628-
* table (r) or foreign table (f). Depending on relkind we use
623+
* Determine the kind of child relation. It can be either a regular
624+
* table (r) or a foreign table (f). Depending on relkind we use
629625
* DROP TABLE or DROP FOREIGN TABLE.
630626
*/
631627
IF v_relkind = 'f' THEN
@@ -637,8 +633,9 @@ BEGIN
637633
v_part_count := v_part_count + 1;
638634
END LOOP;
639635

640-
/* Notify backend about changes */
641-
PERFORM @extschema@.on_remove_partitions(parent_relid);
636+
/* Finally delete both config entries */
637+
DELETE FROM @extschema@.pathman_config WHERE partrel = parent_relid;
638+
DELETE FROM @extschema@.pathman_config_params WHERE partrel = parent_relid;
642639

643640
RETURN v_part_count;
644641
END
@@ -762,23 +759,6 @@ ON sql_drop
762759
EXECUTE PROCEDURE @extschema@.pathman_ddl_trigger_func();
763760

764761

765-
766-
CREATE OR REPLACE FUNCTION @extschema@.on_create_partitions(
767-
relid REGCLASS)
768-
RETURNS VOID AS 'pg_pathman', 'on_partitions_created'
769-
LANGUAGE C STRICT;
770-
771-
CREATE OR REPLACE FUNCTION @extschema@.on_update_partitions(
772-
relid REGCLASS)
773-
RETURNS VOID AS 'pg_pathman', 'on_partitions_updated'
774-
LANGUAGE C STRICT;
775-
776-
CREATE OR REPLACE FUNCTION @extschema@.on_remove_partitions(
777-
relid REGCLASS)
778-
RETURNS VOID AS 'pg_pathman', 'on_partitions_removed'
779-
LANGUAGE C STRICT;
780-
781-
782762
/*
783763
* Get number of partitions managed by pg_pathman.
784764
*/

range.sql

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

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

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

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

389-
/* Notify backend about changes */
390-
PERFORM @extschema@.on_create_partitions(parent_relid);
391-
392380
/* Relocate data if asked to */
393381
IF partition_data = true THEN
394382
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -448,9 +436,6 @@ BEGIN
448436
part_count := part_count + 1;
449437
END LOOP;
450438

451-
/* Notify backend about changes */
452-
PERFORM @extschema@.on_create_partitions(parent_relid);
453-
454439
/* Relocate data if asked to */
455440
IF partition_data = true THEN
456441
PERFORM @extschema@.set_enable_parent(parent_relid, false);
@@ -551,9 +536,6 @@ BEGIN
551536
partition_relid::TEXT,
552537
v_check_name,
553538
v_cond);
554-
555-
/* Tell backend to reload configuration */
556-
PERFORM @extschema@.on_update_partitions(v_parent);
557539
END
558540
$$
559541
LANGUAGE plpgsql;
@@ -615,8 +597,6 @@ BEGIN
615597
INTO
616598
v_part_name;
617599

618-
/* Invalidate cache */
619-
PERFORM @extschema@.on_update_partitions(parent_relid);
620600
RETURN v_part_name;
621601
END
622602
$$
@@ -725,8 +705,6 @@ BEGIN
725705
INTO
726706
v_part_name;
727707

728-
/* Invalidate cache */
729-
PERFORM @extschema@.on_update_partitions(parent_relid);
730708
RETURN v_part_name;
731709
END
732710
$$
@@ -828,7 +806,6 @@ BEGIN
828806
end_value,
829807
partition_name,
830808
tablespace);
831-
PERFORM @extschema@.on_update_partitions(parent_relid);
832809

833810
RETURN v_part_name;
834811
END
@@ -893,9 +870,6 @@ BEGIN
893870
EXECUTE format('DROP TABLE %s', partition_relid::TEXT);
894871
END IF;
895872

896-
/* Invalidate cache */
897-
PERFORM @extschema@.on_update_partitions(parent_relid);
898-
899873
RETURN part_name;
900874
END
901875
$$
@@ -978,9 +952,6 @@ BEGIN
978952
start_value,
979953
end_value);
980954

981-
/* Invalidate cache */
982-
PERFORM @extschema@.on_update_partitions(parent_relid);
983-
984955
RETURN partition_relid;
985956
END
986957
$$
@@ -1026,9 +997,6 @@ BEGIN
1026997
@extschema@.build_update_trigger_name(parent_relid),
1027998
partition_relid::TEXT);
1028999

1029-
/* Invalidate cache */
1030-
PERFORM @extschema@.on_update_partitions(parent_relid);
1031-
10321000
RETURN partition_relid;
10331001
END
10341002
$$

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 * FROM test.hash_rel;
168+
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = NULL;
168169
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2;
169170
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2 OR value = 1;
170171

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

190191
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel;
192+
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = NULL;
191193
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2;
192194
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value = 2 OR value = 1;
193195
EXPLAIN (COSTS OFF) SELECT * FROM test.hash_rel WHERE value IN (2);

src/pl_funcs.c

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838

3939
/* Function declarations */
4040

41-
PG_FUNCTION_INFO_V1( on_partitions_created );
42-
PG_FUNCTION_INFO_V1( on_partitions_updated );
43-
PG_FUNCTION_INFO_V1( on_partitions_removed );
44-
4541
PG_FUNCTION_INFO_V1( get_number_of_partitions_pl );
4642
PG_FUNCTION_INFO_V1( get_parent_of_partition_pl );
4743
PG_FUNCTION_INFO_V1( get_base_type_pl );
@@ -103,10 +99,6 @@ typedef struct
10399
} show_cache_stats_cxt;
104100

105101

106-
static void on_partitions_created_internal(Oid partitioned_table, bool add_callbacks);
107-
static void on_partitions_updated_internal(Oid partitioned_table, bool add_callbacks);
108-
static void on_partitions_removed_internal(Oid partitioned_table, bool add_callbacks);
109-
110102
static void pathman_update_trigger_func_move_tuple(Relation source_rel,
111103
Relation target_rel,
112104
HeapTuple old_tuple,
@@ -120,63 +112,6 @@ check_relation_exists(Oid relid)
120112
}
121113

122114

123-
/*
124-
* ----------------------------
125-
* Partition events callbacks
126-
* ----------------------------
127-
*/
128-
129-
static void
130-
on_partitions_created_internal(Oid partitioned_table, bool add_callbacks)
131-
{
132-
elog(DEBUG2, "on_partitions_created() [add_callbacks = %s] "
133-
"triggered for relation %u",
134-
(add_callbacks ? "true" : "false"), partitioned_table);
135-
}
136-
137-
static void
138-
on_partitions_updated_internal(Oid partitioned_table, bool add_callbacks)
139-
{
140-
bool entry_found;
141-
142-
elog(DEBUG2, "on_partitions_updated() [add_callbacks = %s] "
143-
"triggered for relation %u",
144-
(add_callbacks ? "true" : "false"), partitioned_table);
145-
146-
invalidate_pathman_relation_info(partitioned_table, &entry_found);
147-
}
148-
149-
static void
150-
on_partitions_removed_internal(Oid partitioned_table, bool add_callbacks)
151-
{
152-
elog(DEBUG2, "on_partitions_removed() [add_callbacks = %s] "
153-
"triggered for relation %u",
154-
(add_callbacks ? "true" : "false"), partitioned_table);
155-
}
156-
157-
158-
Datum
159-
on_partitions_created(PG_FUNCTION_ARGS)
160-
{
161-
on_partitions_created_internal(PG_GETARG_OID(0), true);
162-
PG_RETURN_NULL();
163-
}
164-
165-
Datum
166-
on_partitions_updated(PG_FUNCTION_ARGS)
167-
{
168-
on_partitions_updated_internal(PG_GETARG_OID(0), true);
169-
PG_RETURN_NULL();
170-
}
171-
172-
Datum
173-
on_partitions_removed(PG_FUNCTION_ARGS)
174-
{
175-
on_partitions_removed_internal(PG_GETARG_OID(0), true);
176-
PG_RETURN_NULL();
177-
}
178-
179-
180115
/*
181116
* ------------------------
182117
* Various useful getters

0 commit comments

Comments
 (0)