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

Commitda8aba6

Browse files
committed
introduce view 'pathman_partition_list', pl/pgSQL refactoring, extract pl_range_funcs.c & pl_hash_funcs.c from pl_funcs.c
1 parent56bfc94 commitda8aba6

File tree

9 files changed

+691
-361
lines changed

9 files changed

+691
-361
lines changed

‎Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# contrib/pg_pathman/Makefile
22

33
MODULE_big = pg_pathman
4-
OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o src/runtimeappend.o\
5-
src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o src/pl_funcs.o\
6-
src/pathman_workers.o src/hooks.o src/nodes_common.o src/xact_handling.o\
7-
src/copy_stmt_hooking.o src/pg_compat.o$(WIN32RES)
4+
OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o\
5+
src/runtimeappend.o src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o\
6+
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o\
7+
src/hooks.o src/nodes_common.o src/xact_handling.o src/copy_stmt_hooking.o\
8+
src/pg_compat.o$(WIN32RES)
89

910
EXTENSION = pg_pathman
1011
EXTVERSION = 1.0

‎init.sql

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ SELECT pg_catalog.pg_extension_config_dump('@extschema@.pathman_config', '');
7777
SELECTpg_catalog.pg_extension_config_dump('@extschema@.pathman_config_params','');
7878

7979

80-
CREATEOR REPLACE FUNCTION @extschema@.invalidate_relcache(relidOID)
81-
RETURNS VOIDAS'pg_pathman' LANGUAGE C STRICT;
82-
8380
CREATEOR REPLACE FUNCTION @extschema@.partitions_count(relation REGCLASS)
8481
RETURNSINTAS
8582
$$
@@ -150,6 +147,25 @@ END
150147
$$
151148
LANGUAGE plpgsql;
152149

150+
/*
151+
* Show all existing parents and partitions.
152+
*/
153+
CREATEOR REPLACE FUNCTION @extschema@.show_partition_list()
154+
RETURNS TABLE (
155+
parentREGCLASS,
156+
partitionREGCLASS,
157+
parttypeINT4,
158+
partattrTEXT,
159+
range_minTEXT,
160+
range_maxTEXT)
161+
AS'pg_pathman','show_partition_list_internal' LANGUAGE C STRICT;
162+
163+
/*
164+
* View for show_partition_list().
165+
*/
166+
CREATEOR REPLACE VIEW @extschema@.pathman_partition_list
167+
ASSELECT*FROM @extschema@.show_partition_list();
168+
153169
/*
154170
* Show all existing concurrent partitioning tasks.
155171
*/
@@ -160,8 +176,8 @@ RETURNS TABLE (
160176
dbidOID,
161177
relidREGCLASS,
162178
processedINT,
163-
statusTEXT
164-
)AS'pg_pathman','show_concurrent_part_tasks_internal' LANGUAGE C STRICT;
179+
statusTEXT)
180+
AS'pg_pathman','show_concurrent_part_tasks_internal' LANGUAGE C STRICT;
165181

166182
/*
167183
* View for show_concurrent_part_tasks().
@@ -348,7 +364,7 @@ $$
348364
LANGUAGE plpgsql;
349365

350366
/*
351-
* Returns relname without quotes or something
367+
* Returns relname without quotes or something.
352368
*/
353369
CREATEOR REPLACE FUNCTION @extschema@.get_plain_schema_and_relname(
354370
clsREGCLASS,
@@ -366,7 +382,7 @@ $$
366382
LANGUAGE plpgsql STRICT;
367383

368384
/*
369-
* Returns schema-qualified namefor table
385+
* Returnstheschema-qualified nameof table.
370386
*/
371387
CREATEOR REPLACE FUNCTION @extschema@.get_schema_qualified_name(
372388
clsREGCLASS,
@@ -385,7 +401,7 @@ $$
385401
LANGUAGE plpgsql STRICT;
386402

387403
/*
388-
* Validates relation name. It must be schema qualified
404+
* Validates relation name. It must be schema qualified.
389405
*/
390406
CREATEOR REPLACE FUNCTION @extschema@.validate_relname(
391407
clsREGCLASS)
@@ -407,7 +423,7 @@ $$
407423
LANGUAGE plpgsql;
408424

409425
/*
410-
* Check if two relations have equal structures
426+
* Check if two relations have equal structures.
411427
*/
412428
CREATEOR REPLACE FUNCTION @extschema@.validate_relations_equality(
413429
relation1OID, relation2OID)
@@ -439,7 +455,7 @@ $$
439455
LANGUAGE plpgsql;
440456

441457
/*
442-
* DDL trigger that deletes entry from pathman_config table
458+
* DDL trigger that deletes entry from pathman_config table.
443459
*/
444460
CREATEOR REPLACE FUNCTION @extschema@.pathman_ddl_trigger_func()
445461
RETURNS event_triggerAS
@@ -472,7 +488,7 @@ $$
472488
LANGUAGE plpgsql;
473489

474490
/*
475-
* Droptrigger
491+
* Droptriggers.
476492
*/
477493
CREATEOR REPLACE FUNCTION @extschema@.drop_triggers(
478494
parent_relidREGCLASS)
@@ -485,8 +501,8 @@ END
485501
$$ LANGUAGE plpgsql STRICT;
486502

487503
/*
488-
* Drop partitions
489-
*If delete_data set to TRUE then partitionswill be dropped with all the data
504+
* Drop partitions. If delete_data set to TRUE, partitions
505+
* will be dropped with all the data.
490506
*/
491507
CREATEOR REPLACE FUNCTION @extschema@.drop_partitions(
492508
parent_relidREGCLASS,
@@ -578,16 +594,6 @@ ON sql_drop
578594
EXECUTE PROCEDURE @extschema@.pathman_ddl_trigger_func();
579595

580596

581-
/*
582-
* Attach a previously partitioned table
583-
*/
584-
CREATEOR REPLACE FUNCTION @extschema@.add_to_pathman_config(
585-
parent_relidREGCLASS,
586-
attnameTEXT,
587-
range_intervalTEXT DEFAULTNULL)
588-
RETURNSBOOLEANAS'pg_pathman','add_to_pathman_config'
589-
LANGUAGE C;
590-
591597

592598
CREATEOR REPLACE FUNCTION @extschema@.on_create_partitions(
593599
relidREGCLASS)
@@ -619,40 +625,41 @@ CREATE OR REPLACE FUNCTION @extschema@.get_base_type(REGTYPE)
619625
RETURNS REGTYPEAS'pg_pathman','get_base_type_pl'
620626
LANGUAGE C STRICT;
621627

622-
623628
/*
624-
*Checks ifattributeis nullable
629+
*Returnsattributetype name for relation.
625630
*/
626-
CREATEOR REPLACE FUNCTION @extschema@.is_attribute_nullable(
631+
CREATEOR REPLACE FUNCTION @extschema@.get_attribute_type(
627632
REGCLASS,TEXT)
628-
RETURNSBOOLEANAS'pg_pathman','is_attribute_nullable'
633+
RETURNSREGTYPEAS'pg_pathman','get_attribute_type_pl'
629634
LANGUAGE C STRICT;
630635

631636
/*
632-
*Check if regclass is date or timestamp
637+
*Return tablespace name for specified relation.
633638
*/
634-
CREATEOR REPLACE FUNCTION @extschema@.is_date_type(
635-
typidREGTYPE)
636-
RETURNSBOOLEANAS'pg_pathman','is_date_type'
639+
CREATEOR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(relation REGCLASS)
640+
RETURNSTEXTAS'pg_pathman','get_rel_tablespace_name'
637641
LANGUAGE C STRICT;
638642

643+
639644
/*
640-
*Returnsattributetype name for relation
645+
*Checks ifattributeis nullable
641646
*/
642-
CREATEOR REPLACE FUNCTION @extschema@.get_attribute_type(
647+
CREATEOR REPLACE FUNCTION @extschema@.is_attribute_nullable(
643648
REGCLASS,TEXT)
644-
RETURNSREGTYPEAS'pg_pathman','get_attribute_type_pl'
649+
RETURNSBOOLEANAS'pg_pathman','is_attribute_nullable'
645650
LANGUAGE C STRICT;
646651

647652
/*
648-
*Get parent of pg_pathman's partition.
653+
*Check if regclass is date or timestamp.
649654
*/
650-
CREATEOR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
651-
RETURNS REGCLASSAS'pg_pathman','get_parent_of_partition_pl'
655+
CREATEOR REPLACE FUNCTION @extschema@.is_date_type(
656+
typidREGTYPE)
657+
RETURNSBOOLEANAS'pg_pathman','is_date_type'
652658
LANGUAGE C STRICT;
653659

660+
654661
/*
655-
* Build check constraint name for a specified relation's column
662+
* Build check constraint name for a specified relation's column.
656663
*/
657664
CREATEOR REPLACE FUNCTION @extschema@.build_check_constraint_name(
658665
REGCLASS, INT2)
@@ -679,7 +686,22 @@ LANGUAGE C STRICT;
679686

680687

681688
/*
682-
* Lock partitioned relation to restrict concurrent modification of partitioning scheme.
689+
* Attach a previously partitioned table.
690+
*/
691+
CREATEOR REPLACE FUNCTION @extschema@.add_to_pathman_config(
692+
parent_relidREGCLASS,
693+
attnameTEXT,
694+
range_intervalTEXT DEFAULTNULL)
695+
RETURNSBOOLEANAS'pg_pathman','add_to_pathman_config'
696+
LANGUAGE C;
697+
698+
CREATEOR REPLACE FUNCTION @extschema@.invalidate_relcache(relidOID)
699+
RETURNS VOIDAS'pg_pathman' LANGUAGE C STRICT;
700+
701+
702+
/*
703+
* Lock partitioned relation to restrict concurrent
704+
* modification of partitioning scheme.
683705
*/
684706
CREATEOR REPLACE FUNCTION @extschema@.lock_partitioned_relation(
685707
REGCLASS)
@@ -702,18 +724,12 @@ CREATE OR REPLACE FUNCTION @extschema@.debug_capture()
702724
RETURNS VOIDAS'pg_pathman','debug_capture'
703725
LANGUAGE C STRICT;
704726

705-
/*
706-
* Return tablespace name for specified relation.
707-
*/
708-
CREATEOR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(relation REGCLASS)
709-
RETURNSTEXTAS'pg_pathman','get_rel_tablespace_name'
710-
LANGUAGE C STRICT;
711-
712727
/*
713728
* Checks that callback function meets specific requirements. Particularly it
714729
* must have the only JSONB argument and VOID return type.
715730
*/
716-
CREATEOR REPLACE FUNCTION @extschema@.validate_on_partition_created_callback(callback REGPROC)
731+
CREATEOR REPLACE FUNCTION @extschema@.validate_on_partition_created_callback(
732+
callbackREGPROC)
717733
RETURNS VOIDAS'pg_pathman','validate_on_part_init_callback_pl'
718734
LANGUAGE C STRICT;
719735

‎src/pathman.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#definePATHMAN_CONFIG_interval_typmod-1
5353

5454
/*
55-
* Definitions for the "pathman_config_params" table
55+
* Definitions for the "pathman_config_params" table.
5656
*/
5757
#definePATHMAN_CONFIG_PARAMS"pathman_config_params"
5858
#defineNatts_pathman_config_params4
@@ -61,6 +61,19 @@
6161
#defineAnum_pathman_config_params_auto3/* auto partitions creation */
6262
#defineAnum_pathman_config_params_init_callback4/* partition action callback */
6363

64+
/*
65+
* Definitions for the "pathman_partition_list" view.
66+
*/
67+
#definePATHMAN_PARTITION_LIST"pathman_partition_list"
68+
#defineNatts_pathman_partition_list6
69+
#defineAnum_pathman_pl_parent1
70+
#defineAnum_pathman_pl_partition2
71+
#defineAnum_pathman_pl_parttype3
72+
#defineAnum_pathman_pl_partattr4
73+
#defineAnum_pathman_pl_range_min5
74+
#defineAnum_pathman_pl_range_max6
75+
76+
6477
/*
6578
* Cache current PATHMAN_CONFIG relid (set during load_config()).
6679
*/

‎src/pathman_workers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ cps_set_status(ConcurrentPartSlot *slot, ConcurrentPartSlotStatus status)
111111

112112

113113
/*
114-
* Definitions for the "pathman_concurrent_part_tasks" view
114+
* Definitions for the "pathman_concurrent_part_tasks" view.
115115
*/
116116
#definePATHMAN_CONCURRENT_PART_TASKS"pathman_concurrent_part_tasks"
117117
#defineNatts_pathman_cp_tasks6

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp