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

Commit6339f64

Browse files
committed
Rename RowCompareType to CompareType
RowCompareType served as a way to describe the fundamental meaning ofan operator, notionally independent of an operator class (although sofar this was only really supported for btrees). Its original purposewas for use inside RowCompareExpr, and it has also found some smalluse outside, such as for get_op_btree_interpretation().We want to expand this now, as a more general way to describe operatorsemantics for other index access methods, including gist (to improveGistTranslateStratnum()) and others not written yet. To avoid futureconfusion, we rename the type to CompareType and the symbols fromROWCOMPARE_XXX to COMPARE_XXX to reflect their more general purpose.Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com>Discussion:https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
1 parent9a45a89 commit6339f64

File tree

11 files changed

+55
-42
lines changed

11 files changed

+55
-42
lines changed

‎src/backend/executor/execExpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ ExecInitExprRec(Expr *node, ExprState *state,
21022102

21032103
/* Finally, examine the last comparison result */
21042104
scratch.opcode=EEOP_ROWCOMPARE_FINAL;
2105-
scratch.d.rowcompare_final.rctype=rcexpr->rctype;
2105+
scratch.d.rowcompare_final.cmptype=rcexpr->cmptype;
21062106
ExprEvalPushStep(state,&scratch);
21072107

21082108
/* adjust jump targets */

‎src/backend/executor/execExprInterp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,22 +1500,22 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
15001500
EEO_CASE(EEOP_ROWCOMPARE_FINAL)
15011501
{
15021502
int32cmpresult=DatumGetInt32(*op->resvalue);
1503-
RowCompareTyperctype=op->d.rowcompare_final.rctype;
1503+
CompareTypecmptype=op->d.rowcompare_final.cmptype;
15041504

15051505
*op->resnull= false;
1506-
switch (rctype)
1506+
switch (cmptype)
15071507
{
15081508
/* EQ and NE cases aren't allowed here */
1509-
caseROWCOMPARE_LT:
1509+
caseCOMPARE_LT:
15101510
*op->resvalue=BoolGetDatum(cmpresult<0);
15111511
break;
1512-
caseROWCOMPARE_LE:
1512+
caseCOMPARE_LE:
15131513
*op->resvalue=BoolGetDatum(cmpresult <=0);
15141514
break;
1515-
caseROWCOMPARE_GE:
1515+
caseCOMPARE_GE:
15161516
*op->resvalue=BoolGetDatum(cmpresult >=0);
15171517
break;
1518-
caseROWCOMPARE_GT:
1518+
caseCOMPARE_GT:
15191519
*op->resvalue=BoolGetDatum(cmpresult>0);
15201520
break;
15211521
default:

‎src/backend/executor/nodeIndexscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
13441344
&op_lefttype,
13451345
&op_righttype);
13461346

1347-
if (op_strategy!=rc->rctype)
1347+
if (op_strategy!=rc->cmptype)
13481348
elog(ERROR,"RowCompare index qualification contains wrong operator");
13491349

13501350
opfuncid=get_opfamily_proc(opfamily,
@@ -1421,7 +1421,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
14211421
MemSet(this_scan_key,0,sizeof(ScanKeyData));
14221422
this_scan_key->sk_flags=SK_ROW_HEADER;
14231423
this_scan_key->sk_attno=first_sub_key->sk_attno;
1424-
this_scan_key->sk_strategy=rc->rctype;
1424+
this_scan_key->sk_strategy=rc->cmptype;
14251425
/* sk_subtype, sk_collation, sk_func not used in a header */
14261426
this_scan_key->sk_argument=PointerGetDatum(first_sub_key);
14271427
}

‎src/backend/jit/llvm/llvmjit_expr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ llvm_compile_expr(ExprState *state)
17701770

17711771
caseEEOP_ROWCOMPARE_FINAL:
17721772
{
1773-
RowCompareTyperctype=op->d.rowcompare_final.rctype;
1773+
CompareTypecmptype=op->d.rowcompare_final.cmptype;
17741774

17751775
LLVMValueRefv_cmpresult;
17761776
LLVMValueRefv_result;
@@ -1786,18 +1786,18 @@ llvm_compile_expr(ExprState *state)
17861786
l_load(b,TypeSizeT,v_resvaluep,""),
17871787
LLVMInt32TypeInContext(lc),"");
17881788

1789-
switch (rctype)
1789+
switch (cmptype)
17901790
{
1791-
caseROWCOMPARE_LT:
1791+
caseCOMPARE_LT:
17921792
predicate=LLVMIntSLT;
17931793
break;
1794-
caseROWCOMPARE_LE:
1794+
caseCOMPARE_LE:
17951795
predicate=LLVMIntSLE;
17961796
break;
1797-
caseROWCOMPARE_GT:
1797+
caseCOMPARE_GT:
17981798
predicate=LLVMIntSGT;
17991799
break;
1800-
caseROWCOMPARE_GE:
1800+
caseCOMPARE_GE:
18011801
predicate=LLVMIntSGE;
18021802
break;
18031803
default:

‎src/backend/optimizer/path/indxpath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3675,7 +3675,7 @@ expand_indexqual_rowcompare(PlannerInfo *root,
36753675
{
36763676
RowCompareExpr*rc=makeNode(RowCompareExpr);
36773677

3678-
rc->rctype= (RowCompareType)op_strategy;
3678+
rc->cmptype= (CompareType)op_strategy;
36793679
rc->opnos=new_ops;
36803680
rc->opfamilies=list_copy_head(clause->opfamilies,
36813681
matching_cols);

‎src/backend/optimizer/util/predtest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ clause_is_strict_for(Node *clause, Node *subexpr, bool allow_false)
16641664
#defineBTEQ BTEqualStrategyNumber
16651665
#defineBTGE BTGreaterEqualStrategyNumber
16661666
#defineBTGT BTGreaterStrategyNumber
1667-
#defineBTNEROWCOMPARE_NE
1667+
#defineBTNECOMPARE_NE
16681668

16691669
/* We use "none" for 0/false to make the tables align nicely */
16701670
#definenone 0

‎src/backend/parser/parse_expr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
28072807
List*largs,List*rargs,intlocation)
28082808
{
28092809
RowCompareExpr*rcexpr;
2810-
RowCompareTyperctype;
2810+
CompareTypecmptype;
28112811
List*opexprs;
28122812
List*opnos;
28132813
List*opfamilies;
@@ -2928,15 +2928,15 @@ make_row_comparison_op(ParseState *pstate, List *opname,
29282928
errhint("Row comparison operators must be associated with btree operator families."),
29292929
parser_errposition(pstate,location)));
29302930
}
2931-
rctype= (RowCompareType)i;
2931+
cmptype= (CompareType)i;
29322932

29332933
/*
29342934
* For = and <> cases, we just combine the pairwise operators with AND or
29352935
* OR respectively.
29362936
*/
2937-
if (rctype==ROWCOMPARE_EQ)
2937+
if (cmptype==COMPARE_EQ)
29382938
return (Node*)makeBoolExpr(AND_EXPR,opexprs,location);
2939-
if (rctype==ROWCOMPARE_NE)
2939+
if (cmptype==COMPARE_NE)
29402940
return (Node*)makeBoolExpr(OR_EXPR,opexprs,location);
29412941

29422942
/*
@@ -2953,7 +2953,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
29532953
{
29542954
OpBtreeInterpretation*opinfo=lfirst(j);
29552955

2956-
if (opinfo->strategy==rctype)
2956+
if (opinfo->strategy==cmptype)
29572957
{
29582958
opfamily=opinfo->opfamily_id;
29592959
break;
@@ -2989,7 +2989,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
29892989
}
29902990

29912991
rcexpr=makeNode(RowCompareExpr);
2992-
rcexpr->rctype=rctype;
2992+
rcexpr->cmptype=cmptype;
29932993
rcexpr->opnos=opnos;
29942994
rcexpr->opfamilies=opfamilies;
29952995
rcexpr->inputcollids=NIL;/* assign_expr_collations will fix this */

‎src/backend/utils/cache/lsyscache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ get_op_hash_functions(Oid opno,
595595
*
596596
* In addition to the normal btree operators, we consider a <> operator to be
597597
* a "member" of an opfamily if its negator is an equality operator of the
598-
* opfamily.ROWCOMPARE_NE is returned as the strategy number for this case.
598+
* opfamily.COMPARE_NE is returned as the strategy number for this case.
599599
*/
600600
List*
601601
get_op_btree_interpretation(Oidopno)
@@ -666,11 +666,11 @@ get_op_btree_interpretation(Oid opno)
666666
if (op_strategy!=BTEqualStrategyNumber)
667667
continue;
668668

669-
/* OK, report it with "strategy"ROWCOMPARE_NE */
669+
/* OK, report it with "strategy"COMPARE_NE */
670670
thisresult= (OpBtreeInterpretation*)
671671
palloc(sizeof(OpBtreeInterpretation));
672672
thisresult->opfamily_id=op_form->amopfamily;
673-
thisresult->strategy=ROWCOMPARE_NE;
673+
thisresult->strategy=COMPARE_NE;
674674
thisresult->oplefttype=op_form->amoplefttype;
675675
thisresult->oprighttype=op_form->amoprighttype;
676676
result=lappend(result,thisresult);

‎src/include/executor/execExpr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ typedef struct ExprEvalStep
494494
/* for EEOP_ROWCOMPARE_FINAL */
495495
struct
496496
{
497-
RowCompareTyperctype;
497+
CompareTypecmptype;
498498
}rowcompare_final;
499499

500500
/* for EEOP_MINMAX */

‎src/include/nodes/primnodes.h

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,31 @@ typedef struct RowExpr
14351435
ParseLoclocation;/* token location, or -1 if unknown */
14361436
}RowExpr;
14371437

1438+
/*
1439+
* CompareType - fundamental semantics of certain operators
1440+
*
1441+
* These enum symbols represent the fundamental semantics of certain operators
1442+
* that the system needs to have some hardcoded knowledge about. (For
1443+
* example, RowCompareExpr needs to know which operators can be determined to
1444+
* act like =, <>, <, etc.) Index access methods map (some of) strategy
1445+
* numbers to these values so that the system can know about the meaning of
1446+
* (some of) the operators without needing hardcoded knowledge of index AM's
1447+
* strategy numbering.
1448+
*
1449+
* XXX Currently, this mapping is not fully developed and the values are
1450+
* chosen to match btree strategy numbers, which is not going to work very
1451+
* well for other access methods.
1452+
*/
1453+
typedefenumCompareType
1454+
{
1455+
COMPARE_LT=1,/* BTLessStrategyNumber */
1456+
COMPARE_LE=2,/* BTLessEqualStrategyNumber */
1457+
COMPARE_EQ=3,/* BTEqualStrategyNumber */
1458+
COMPARE_GE=4,/* BTGreaterEqualStrategyNumber */
1459+
COMPARE_GT=5,/* BTGreaterStrategyNumber */
1460+
COMPARE_NE=6,/* no such btree strategy */
1461+
}CompareType;
1462+
14381463
/*
14391464
* RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
14401465
*
@@ -1446,26 +1471,14 @@ typedef struct RowExpr
14461471
*
14471472
* A RowCompareExpr node is only generated for the < <= > >= cases;
14481473
* the = and <> cases are translated to simple AND or OR combinations
1449-
* of the pairwise comparisons. However, we include = and <> in the
1450-
* RowCompareType enum for the convenience of parser logic.
1474+
* of the pairwise comparisons.
14511475
*/
1452-
typedefenumRowCompareType
1453-
{
1454-
/* Values of this enum are chosen to match btree strategy numbers */
1455-
ROWCOMPARE_LT=1,/* BTLessStrategyNumber */
1456-
ROWCOMPARE_LE=2,/* BTLessEqualStrategyNumber */
1457-
ROWCOMPARE_EQ=3,/* BTEqualStrategyNumber */
1458-
ROWCOMPARE_GE=4,/* BTGreaterEqualStrategyNumber */
1459-
ROWCOMPARE_GT=5,/* BTGreaterStrategyNumber */
1460-
ROWCOMPARE_NE=6,/* no such btree strategy */
1461-
}RowCompareType;
1462-
14631476
typedefstructRowCompareExpr
14641477
{
14651478
Exprxpr;
14661479

14671480
/* LT LE GE or GT, never EQ or NE */
1468-
RowCompareTyperctype;
1481+
CompareTypecmptype;
14691482
/* OID list of pairwise comparison ops */
14701483
List*opnospg_node_attr(query_jumble_ignore);
14711484
/* OID list of containing operator families */

‎src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ CommonEntry
458458
CommonTableExpr
459459
CompactAttribute
460460
CompareScalarsContext
461+
CompareType
461462
CompiledExprState
462463
CompositeIOData
463464
CompositeTypeStmt
@@ -2494,7 +2495,6 @@ RoleSpecType
24942495
RoleStmtType
24952496
RollupData
24962497
RowCompareExpr
2497-
RowCompareType
24982498
RowExpr
24992499
RowIdentityVarInfo
25002500
RowMarkClause

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp