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

Commit62b9045

Browse files
committed
Refactor pattern_fixed_prefix() to avoid dealing in incomplete patterns.
Previously, pattern_fixed_prefix() was defined to return whatever fixedprefix it could extract from the pattern, plus the "rest" of the pattern.That definition was sensible for LIKE patterns, but not so much forregexes, where reconstituting a valid pattern minus the prefix could bequite tricky (certainly the existing code wasn't doing that correctly).Since the only thing that callers ever did with the "rest" of the patternwas to pass it to like_selectivity() or regex_selectivity(), let's cut outthe middle-man and just have pattern_fixed_prefix's subroutines do thisdirectly. Then pattern_fixed_prefix can return a simple selectivitynumber, and the question of how to cope with partial patterns is removedfrom its API specification.While at it, adjust the API spec so that callers who don't actually careabout the pattern's selectivity (which is a lot of them) can pass NULL forthe selectivity pointer to skip doing the work of computing a selectivityestimate.This patch is only an API refactoring that doesn't actually change anyprocessing, other than allowing a little bit of useless work to be skipped.However, it's necessary infrastructure for my upcoming fix to regex prefixextraction, because after that change there won't be any simple way toidentify the "rest" of the regex, not even to the low level of fidelityneeded by regex_selectivity. We can cope with that if regex_fixed_prefixand regex_selectivity communicate directly, but not if we have to workwithin the old API. Hence, back-patch to all active branches.
1 parentb6108fe commit62b9045

File tree

3 files changed

+60
-128
lines changed

3 files changed

+60
-128
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,6 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
24672467
Oidexpr_coll;
24682468
Const*patt;
24692469
Const*prefix=NULL;
2470-
Const*rest=NULL;
24712470
Pattern_Prefix_Statuspstatus=Pattern_Prefix_None;
24722471

24732472
/*
@@ -2496,13 +2495,13 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
24962495
caseOID_NAME_LIKE_OP:
24972496
/* the right-hand const is type text for all of these */
24982497
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,expr_coll,
2499-
&prefix,&rest);
2498+
&prefix,NULL);
25002499
isIndexable= (pstatus!=Pattern_Prefix_None);
25012500
break;
25022501

25032502
caseOID_BYTEA_LIKE_OP:
25042503
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,expr_coll,
2505-
&prefix,&rest);
2504+
&prefix,NULL);
25062505
isIndexable= (pstatus!=Pattern_Prefix_None);
25072506
break;
25082507

@@ -2511,7 +2510,7 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
25112510
caseOID_NAME_ICLIKE_OP:
25122511
/* the right-hand const is type text for all of these */
25132512
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like_IC,expr_coll,
2514-
&prefix,&rest);
2513+
&prefix,NULL);
25152514
isIndexable= (pstatus!=Pattern_Prefix_None);
25162515
break;
25172516

@@ -2520,7 +2519,7 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
25202519
caseOID_NAME_REGEXEQ_OP:
25212520
/* the right-hand const is type text for all of these */
25222521
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex,expr_coll,
2523-
&prefix,&rest);
2522+
&prefix,NULL);
25242523
isIndexable= (pstatus!=Pattern_Prefix_None);
25252524
break;
25262525

@@ -2529,7 +2528,7 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
25292528
caseOID_NAME_ICREGEXEQ_OP:
25302529
/* the right-hand const is type text for all of these */
25312530
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex_IC,expr_coll,
2532-
&prefix,&rest);
2531+
&prefix,NULL);
25332532
isIndexable= (pstatus!=Pattern_Prefix_None);
25342533
break;
25352534

@@ -2794,7 +2793,6 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily, Oid idxcollation)
27942793
Oidexpr_coll= ((OpExpr*)clause)->inputcollid;
27952794
Const*patt= (Const*)rightop;
27962795
Const*prefix=NULL;
2797-
Const*rest=NULL;
27982796
Pattern_Prefix_Statuspstatus;
27992797

28002798
/*
@@ -2814,7 +2812,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily, Oid idxcollation)
28142812
if (!op_in_opfamily(expr_op,opfamily))
28152813
{
28162814
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,expr_coll,
2817-
&prefix,&rest);
2815+
&prefix,NULL);
28182816
returnprefix_quals(leftop,opfamily,idxcollation,prefix,pstatus);
28192817
}
28202818
break;
@@ -2826,7 +2824,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily, Oid idxcollation)
28262824
{
28272825
/* the right-hand const is type text for all of these */
28282826
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like_IC,expr_coll,
2829-
&prefix,&rest);
2827+
&prefix,NULL);
28302828
returnprefix_quals(leftop,opfamily,idxcollation,prefix,pstatus);
28312829
}
28322830
break;
@@ -2838,7 +2836,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily, Oid idxcollation)
28382836
{
28392837
/* the right-hand const is type text for all of these */
28402838
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex,expr_coll,
2841-
&prefix,&rest);
2839+
&prefix,NULL);
28422840
returnprefix_quals(leftop,opfamily,idxcollation,prefix,pstatus);
28432841
}
28442842
break;
@@ -2850,7 +2848,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily, Oid idxcollation)
28502848
{
28512849
/* the right-hand const is type text for all of these */
28522850
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex_IC,expr_coll,
2853-
&prefix,&rest);
2851+
&prefix,NULL);
28542852
returnprefix_quals(leftop,opfamily,idxcollation,prefix,pstatus);
28552853
}
28562854
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp