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

Commit053ad1c

Browse files
committed
Merge branch 'rel_future_bounds_cache' into rel_future_beta
2 parents8c14547 +dcc08d8 commit053ad1c

19 files changed

+1084
-355
lines changed

‎expected/pathman_calamity.out

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ SELECT create_hash_partitions('calamity.part_ok', 'val', 4);
510510
CREATE TABLE calamity.wrong_partition (LIKE calamity.part_test) INHERITS (calamity.part_test); /* wrong partition w\o constraints */
511511
NOTICE: merging column "val" with inherited definition
512512
SELECT add_to_pathman_config('calamity.part_test', 'val');
513-
ERROR: constraint "pathman_wrong_partition_1_check"for partition "wrong_partition" does not exist
513+
ERROR: constraint "pathman_wrong_partition_1_check"of partition "wrong_partition" does not exist
514514
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is enabled */
515515
QUERY PLAN
516516
-----------------------------
@@ -522,7 +522,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is ena
522522
(5 rows)
523523

524524
SELECT add_to_pathman_config('calamity.part_test', 'val', '10');
525-
ERROR: constraint "pathman_wrong_partition_1_check"for partition "wrong_partition" does not exist
525+
ERROR: constraint "pathman_wrong_partition_1_check"of partition "wrong_partition" does not exist
526526
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is enabled */
527527
QUERY PLAN
528528
-----------------------------
@@ -670,6 +670,109 @@ NOTICE: drop cascades to table calamity.test_range_oid_1
670670
DROP SCHEMA calamity CASCADE;
671671
NOTICE: drop cascades to 18 other objects
672672
DROP EXTENSION pg_pathman;
673+
/*
674+
* -------------------------------------
675+
* Special tests (pathman_cache_stats)
676+
* -------------------------------------
677+
*/
678+
CREATE SCHEMA calamity;
679+
CREATE EXTENSION pg_pathman;
680+
/* Change this setting for code coverage */
681+
SET pg_pathman.enable_bounds_cache = false;
682+
/* check view pathman_cache_stats */
683+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
684+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
685+
NOTICE: sequence "test_pathman_cache_stats_seq" does not exist, skipping
686+
create_range_partitions
687+
-------------------------
688+
10
689+
(1 row)
690+
691+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
692+
context | entries
693+
--------------------------+---------
694+
maintenance | 0
695+
partition bounds cache | 0
696+
partition dispatch cache | 1
697+
partition parents cache | 10
698+
(4 rows)
699+
700+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
701+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
702+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
703+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
704+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
705+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
706+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
707+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
708+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
709+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
710+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
711+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
712+
drop_partitions
713+
-----------------
714+
10
715+
(1 row)
716+
717+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
718+
context | entries
719+
--------------------------+---------
720+
maintenance | 0
721+
partition bounds cache | 0
722+
partition dispatch cache | 0
723+
partition parents cache | 0
724+
(4 rows)
725+
726+
DROP TABLE calamity.test_pathman_cache_stats;
727+
/* Restore this GUC */
728+
SET pg_pathman.enable_bounds_cache = true;
729+
/* check view pathman_cache_stats (one more time) */
730+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
731+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
732+
create_range_partitions
733+
-------------------------
734+
10
735+
(1 row)
736+
737+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
738+
context | entries
739+
--------------------------+---------
740+
maintenance | 0
741+
partition bounds cache | 10
742+
partition dispatch cache | 1
743+
partition parents cache | 10
744+
(4 rows)
745+
746+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
747+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
748+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
749+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
750+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
751+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
752+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
753+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
754+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
755+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
756+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
757+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
758+
drop_partitions
759+
-----------------
760+
10
761+
(1 row)
762+
763+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
764+
context | entries
765+
--------------------------+---------
766+
maintenance | 0
767+
partition bounds cache | 0
768+
partition dispatch cache | 0
769+
partition parents cache | 0
770+
(4 rows)
771+
772+
DROP TABLE calamity.test_pathman_cache_stats;
773+
DROP SCHEMA calamity CASCADE;
774+
NOTICE: drop cascades to sequence calamity.test_pathman_cache_stats_seq
775+
DROP EXTENSION pg_pathman;
673776
/*
674777
* ------------------------------------------
675778
* Special tests (uninitialized pg_pathman)

‎init.sql

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ LANGUAGE plpgsql;
250250
*/
251251
CREATEOR REPLACE FUNCTION @extschema@.show_partition_list()
252252
RETURNS TABLE (
253-
parentREGCLASS,
254-
partitionREGCLASS,
255-
parttypeINT4,
256-
partattrTEXT,
257-
range_minTEXT,
258-
range_maxTEXT)
253+
parentREGCLASS,
254+
partitionREGCLASS,
255+
parttypeINT4,
256+
partattrTEXT,
257+
range_minTEXT,
258+
range_maxTEXT)
259259
AS'pg_pathman','show_partition_list_internal'
260260
LANGUAGE C STRICT;
261261

@@ -267,6 +267,24 @@ AS SELECT * FROM @extschema@.show_partition_list();
267267

268268
GRANTSELECTON @extschema@.pathman_partition_list TO PUBLIC;
269269

270+
/*
271+
* Show memory usage of pg_pathman's caches.
272+
*/
273+
CREATEOR REPLACE FUNCTION @extschema@.show_cache_stats()
274+
RETURNS TABLE (
275+
contextTEXT,
276+
sizeINT8,
277+
usedINT8,
278+
entriesINT8)
279+
AS'pg_pathman','show_cache_stats_internal'
280+
LANGUAGE C STRICT;
281+
282+
/*
283+
* View for show_cache_stats().
284+
*/
285+
CREATEOR REPLACE VIEW @extschema@.pathman_cache_stats
286+
ASSELECT*FROM @extschema@.show_cache_stats();
287+
270288
/*
271289
* Show all existing concurrent partitioning tasks.
272290
*/

‎sql/pathman_calamity.sql

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,41 @@ SELECT get_part_range('calamity.test_range_oid_1', NULL::INT4);/* OK */
260260

261261
DROPTABLEcalamity.test_range_oid CASCADE;
262262

263+
DROPSCHEMA calamity CASCADE;
264+
DROP EXTENSION pg_pathman;
265+
266+
267+
268+
/*
269+
* -------------------------------------
270+
* Special tests (pathman_cache_stats)
271+
* -------------------------------------
272+
*/
273+
274+
CREATESCHEMAcalamity;
275+
CREATE EXTENSION pg_pathman;
276+
277+
/* Change this setting for code coverage*/
278+
SETpg_pathman.enable_bounds_cache= false;
279+
280+
/* check view pathman_cache_stats*/
281+
CREATETABLEcalamity.test_pathman_cache_stats(valNUMERICNOT NULL);
282+
SELECT create_range_partitions('calamity.test_pathman_cache_stats','val',1,10,10);
283+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
284+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
285+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
286+
DROPTABLEcalamity.test_pathman_cache_stats;
287+
288+
/* Restore this GUC*/
289+
SETpg_pathman.enable_bounds_cache= true;
290+
291+
/* check view pathman_cache_stats (one more time)*/
292+
CREATETABLEcalamity.test_pathman_cache_stats(valNUMERICNOT NULL);
293+
SELECT create_range_partitions('calamity.test_pathman_cache_stats','val',1,10,10);
294+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
295+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
296+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
297+
DROPTABLEcalamity.test_pathman_cache_stats;
263298

264299
DROPSCHEMA calamity CASCADE;
265300
DROP EXTENSION pg_pathman;

‎src/compat/pg_compat.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,45 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
268268
add_partial_path(rel,create_seqscan_path(root,rel,NULL,parallel_workers));
269269
}
270270

271+
/*
272+
* Examine contents of MemoryContext.
273+
*/
274+
void
275+
McxtStatsInternal(MemoryContextcontext,intlevel,
276+
boolexamine_children,
277+
MemoryContextCounters*totals)
278+
{
279+
MemoryContextCounterslocal_totals;
280+
MemoryContextchild;
281+
282+
AssertArg(MemoryContextIsValid(context));
283+
284+
/* Examine the context itself */
285+
(*context->methods->stats) (context,level, false,totals);
286+
287+
memset(&local_totals,0,sizeof(local_totals));
288+
289+
if (!examine_children)
290+
return;
291+
292+
/* Examine children */
293+
for (child=context->firstchild;
294+
child!=NULL;
295+
child=child->nextchild)
296+
{
297+
298+
McxtStatsInternal(child,level+1,
299+
examine_children,
300+
&local_totals);
301+
}
302+
303+
/* Save children stats */
304+
totals->nblocks+=local_totals.nblocks;
305+
totals->freechunks+=local_totals.freechunks;
306+
totals->totalspace+=local_totals.totalspace;
307+
totals->freespace+=local_totals.freespace;
308+
}
309+
271310

272311
#else/* PG_VERSION_NUM >= 90500 */
273312

‎src/compat/relation_tags.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ rte_attach_tag(const uint32 query_id,
110110

111111
per_table_relation_tags=hash_create("Custom tags for RangeTblEntry",
112112
start_elems,&hashctl,
113-
HASH_ELEM |HASH_BLOBS);
113+
HASH_ELEM |HASH_BLOBS |HASH_CONTEXT);
114114
}
115115

116116
/* Search by 'htab_key' */

‎src/hooks.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,16 @@ pg_pathman_enable_assign_hook(bool newval, void *extra)
447447
pg_pathman_init_state.override_copy&&
448448
pg_pathman_enable_runtimeappend&&
449449
pg_pathman_enable_runtime_merge_append&&
450-
pg_pathman_enable_partition_filter))
450+
pg_pathman_enable_partition_filter&&
451+
pg_pathman_enable_bounds_cache))
451452
return;
452453

453-
pg_pathman_init_state.auto_partition=newval;
454-
pg_pathman_init_state.override_copy=newval;
455-
pg_pathman_enable_runtime_merge_append=newval;
456-
pg_pathman_enable_runtimeappend=newval;
457-
pg_pathman_enable_partition_filter=newval;
454+
pg_pathman_init_state.auto_partition=newval;
455+
pg_pathman_init_state.override_copy=newval;
456+
pg_pathman_enable_runtimeappend=newval;
457+
pg_pathman_enable_runtime_merge_append=newval;
458+
pg_pathman_enable_partition_filter=newval;
459+
pg_pathman_enable_bounds_cache=newval;
458460

459461
elog(NOTICE,
460462
"RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes "
@@ -646,6 +648,9 @@ pathman_relcache_hook(Datum arg, Oid relid)
646648
if (relid==get_pathman_config_relid(false))
647649
delay_pathman_shutdown();
648650

651+
/* Invalidate PartBoundInfo cache if needed */
652+
forget_bounds_of_partition(relid);
653+
649654
/* Invalidate PartParentInfo cache if needed */
650655
partitioned_table=forget_parent_of_partition(relid,&search);
651656

‎src/include/compat/pg_compat.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
#include"compat/debug_compat_features.h"
1515

1616
#include"postgres.h"
17+
#include"nodes/memnodes.h"
1718
#include"nodes/relation.h"
1819
#include"nodes/pg_list.h"
1920
#include"optimizer/cost.h"
2021
#include"optimizer/paths.h"
22+
#include"utils/memutils.h"
23+
24+
/* Define ALLOCSET_DEFAULT_SIZES for our precious MemoryContexts */
25+
#ifPG_VERSION_NUM<90600
26+
#defineALLOCSET_DEFAULT_SIZES \
27+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
28+
#endif
2129

2230

2331
/*
@@ -78,6 +86,12 @@ extern Result *make_result(List *tlist,
7886
make_result((tlist), (resconstantqual), (subplan))
7987

8088

89+
/* McxtStatsInternal() */
90+
voidMcxtStatsInternal(MemoryContextcontext,intlevel,
91+
boolexamine_children,
92+
MemoryContextCounters*totals);
93+
94+
8195
/* pull_var_clause() */
8296
#definepull_var_clause_compat(node,aggbehavior,phbehavior) \
8397
pull_var_clause((node), (aggbehavior) | (phbehavior))
@@ -93,6 +107,9 @@ extern void set_rel_consider_parallel(PlannerInfo *root,
93107

94108
#else/* PG_VERSION_NUM >= 90500 */
95109

110+
#defineALLOCSET_DEFAULT_SIZES \
111+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
112+
96113
/* adjust_appendrel_attrs() */
97114
#defineadjust_rel_targetlist_compat(root,dst_rel,src_rel,appinfo) \
98115
do { \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp