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

Commita2a475b

Browse files
committed
Replace get_equal_strategy_number_for_am() by get_equal_strategy_number()
get_equal_strategy_number_for_am() gets the equal strategy number foran AM. This currently only supports btree and hash. In the moregeneral case, this also depends on the operator class (see for exampleGistTranslateStratnum()). To support that, replace this function withget_equal_strategy_number() that takes an opclass and derives it fromthere. (This function already existed before as a static function, sothe signature is kept for simplicity.)This patch is only a refactoring, it doesn't add support for otherindex AMs such as gist. This will be done separately.Reviewed-by: Paul Jungwirth <pj@illuminatedcomputing.com>Reviewed-by: vignesh C <vignesh21@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com
1 parent321c287 commita2a475b

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ static bool tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
3939

4040
/*
4141
* Returns the fixed strategy number, if any, of the equality operator for the
42-
* givenindex access method, otherwise, InvalidStrategy.
42+
* givenoperator class, otherwise, InvalidStrategy.
4343
*
4444
* Currently, only Btree and Hash indexes are supported. The other index access
4545
* methods don't have a fixed strategy for equality operation - instead, the
4646
* support routines of each operator class interpret the strategy numbers
4747
* according to the operator class's definition.
4848
*/
4949
StrategyNumber
50-
get_equal_strategy_number_for_am(Oidam)
50+
get_equal_strategy_number(Oidopclass)
5151
{
52+
Oidam=get_opclass_method(opclass);
5253
intret;
5354

5455
switch (am)
@@ -68,18 +69,6 @@ get_equal_strategy_number_for_am(Oid am)
6869
returnret;
6970
}
7071

71-
/*
72-
* Return the appropriate strategy number which corresponds to the equality
73-
* operator.
74-
*/
75-
staticStrategyNumber
76-
get_equal_strategy_number(Oidopclass)
77-
{
78-
Oidam=get_opclass_method(opclass);
79-
80-
returnget_equal_strategy_number_for_am(am);
81-
}
82-
8372
/*
8473
* Setup a ScanKey for a search in the relation 'rel' for a tuple 'key' that
8574
* is setup to match 'rel' (*NOT* idxrel!).

‎src/backend/replication/logical/relation.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include"replication/logicalrelation.h"
3030
#include"replication/worker_internal.h"
3131
#include"utils/inval.h"
32+
#include"utils/syscache.h"
3233

3334

3435
staticMemoryContextLogicalRepRelMapContext=NULL;
@@ -815,7 +816,7 @@ FindUsableIndexForReplicaIdentityFull(Relation localrel, AttrMap *attrmap)
815816
* The reasons why only Btree and Hash indexes can be considered as usable are:
816817
*
817818
* 1) Other index access methods don't have a fixed strategy for equality
818-
* operation. Referget_equal_strategy_number_for_am().
819+
* operation. Referget_equal_strategy_number().
819820
*
820821
* 2) For indexes other than PK and REPLICA IDENTITY, we need to match the
821822
* local and remote tuples. The equality routine tuples_equal() cannot accept
@@ -833,17 +834,25 @@ bool
833834
IsIndexUsableForReplicaIdentityFull(Relationidxrel,AttrMap*attrmap)
834835
{
835836
AttrNumberkeycol;
836-
837-
/* Ensure that the index access method has a valid equal strategy */
838-
if (get_equal_strategy_number_for_am(idxrel->rd_rel->relam)==InvalidStrategy)
839-
return false;
837+
oidvector*indclass;
840838

841839
/* The index must not be a partial index */
842840
if (!heap_attisnull(idxrel->rd_indextuple,Anum_pg_index_indpred,NULL))
843841
return false;
844842

845843
Assert(idxrel->rd_index->indnatts >=1);
846844

845+
indclass= (oidvector*)DatumGetPointer(SysCacheGetAttrNotNull(INDEXRELID,
846+
idxrel->rd_indextuple,
847+
Anum_pg_index_indclass));
848+
849+
/* Ensure that the index has a valid equal strategy for each key column */
850+
for (inti=0;i<idxrel->rd_index->indnkeyatts;i++)
851+
{
852+
if (get_equal_strategy_number(indclass->values[i])==InvalidStrategy)
853+
return false;
854+
}
855+
847856
/* The leftmost index field must not be an expression */
848857
keycol=idxrel->rd_index->indkey.values[0];
849858
if (!AttributeNumberIsValid(keycol))

‎src/include/executor/executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ extern void check_exclusion_constraint(Relation heap, Relation index,
657657
/*
658658
* prototypes from functions in execReplication.c
659659
*/
660-
externStrategyNumberget_equal_strategy_number_for_am(Oidam);
660+
externStrategyNumberget_equal_strategy_number(Oidopclass);
661661
externboolRelationFindReplTupleByIndex(Relationrel,Oididxoid,
662662
LockTupleModelockmode,
663663
TupleTableSlot*searchslot,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp