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

Commit36ac4bf

Browse files
committed
fix regression tests, fix pathman_relcache_hook(), simplify forget_constraint_of_partition()
1 parent0e24f25 commit36ac4bf

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

‎expected/pathman_calamity.out

Lines changed: 2 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
-----------------------------

‎src/hooks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ pathman_relcache_hook(Datum arg, Oid relid)
624624
if (relid==get_pathman_config_relid(false))
625625
delay_pathman_shutdown();
626626

627+
/* Invalidate PartConstraintInfo cache if needed */
628+
forget_constraint_of_partition(relid);
629+
627630
/* Invalidate PartParentInfo cache if needed */
628631
partitioned_table=forget_parent_of_partition(relid,&search);
629632

‎src/include/relation_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Oid forget_parent_of_partition(Oid partition, PartParentSearch *status);
221221
Oidget_parent_of_partition(Oidpartition,PartParentSearch*status);
222222

223223
/* Constraint cache */
224-
Oidforget_constraint_of_partition(Oidpartition);
224+
voidforget_constraint_of_partition(Oidpartition);
225225
Expr*get_constraint_of_partition(Oidpartition,AttrNumberpart_attno);
226226

227227
/* Safe casts for PartType */

‎src/relation_info.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -698,34 +698,24 @@ try_perform_parent_refresh(Oid parent)
698698
* forget\get constraint functions.
699699
*/
700700

701-
Oid
701+
/* Remove partition's constraint from cache */
702+
void
702703
forget_constraint_of_partition(Oidpartition)
703704
{
704-
PartConstraintInfo*pcon=pathman_cache_search_relid(constraint_cache,
705-
partition,
706-
HASH_FIND,NULL);
707-
if (pcon)
708-
{
709-
Oidconid=pcon->conid;
710-
711-
/* TODO: implement pfree(constraint) logc */
712-
713-
pathman_cache_search_relid(constraint_cache,
714-
partition,
715-
HASH_REMOVE,NULL);
716-
717-
returnconid;
718-
}
719-
720-
returnInvalidOid;
705+
pathman_cache_search_relid(constraint_cache,
706+
partition,
707+
HASH_REMOVE,
708+
NULL);
721709
}
722710

711+
/* Return partition's constraint as expression tree */
723712
Expr*
724713
get_constraint_of_partition(Oidpartition,AttrNumberpart_attno)
725714
{
726715
PartConstraintInfo*pcon=pathman_cache_search_relid(constraint_cache,
727716
partition,
728-
HASH_FIND,NULL);
717+
HASH_FIND,
718+
NULL);
729719
if (!pcon)
730720
{
731721
Oidconid;
@@ -738,7 +728,8 @@ get_constraint_of_partition(Oid partition, AttrNumber part_attno)
738728
/* Create new entry for this constraint */
739729
pcon=pathman_cache_search_relid(constraint_cache,
740730
partition,
741-
HASH_ENTER,NULL);
731+
HASH_ENTER,
732+
NULL);
742733

743734
/* Copy constraint's data to the persistent mcxt */
744735
old_mcxt=MemoryContextSwitchTo(TopMemoryContext);
@@ -751,7 +742,7 @@ get_constraint_of_partition(Oid partition, AttrNumber part_attno)
751742
}
752743

753744
/*
754-
* Get constraint expression treefor a partition.
745+
* Get constraint expression treeof a partition.
755746
*
756747
* build_check_constraint_name_internal() is used to build conname.
757748
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp