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

Commit5edd21d

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 parent490cb05 commit5edd21d

File tree

3 files changed

+57
-127
lines changed

3 files changed

+57
-127
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,6 @@ match_special_index_operator(Expr *clause, Oid opfamily,
22192219
Oidexpr_op;
22202220
Const*patt;
22212221
Const*prefix=NULL;
2222-
Const*rest=NULL;
22232222
Pattern_Prefix_Statuspstatus=Pattern_Prefix_None;
22242223

22252224
/*
@@ -2247,13 +2246,13 @@ match_special_index_operator(Expr *clause, Oid opfamily,
22472246
caseOID_NAME_LIKE_OP:
22482247
/* the right-hand const is type text for all of these */
22492248
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,
2250-
&prefix,&rest);
2249+
&prefix,NULL);
22512250
isIndexable= (pstatus!=Pattern_Prefix_None);
22522251
break;
22532252

22542253
caseOID_BYTEA_LIKE_OP:
22552254
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,
2256-
&prefix,&rest);
2255+
&prefix,NULL);
22572256
isIndexable= (pstatus!=Pattern_Prefix_None);
22582257
break;
22592258

@@ -2262,7 +2261,7 @@ match_special_index_operator(Expr *clause, Oid opfamily,
22622261
caseOID_NAME_ICLIKE_OP:
22632262
/* the right-hand const is type text for all of these */
22642263
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like_IC,
2265-
&prefix,&rest);
2264+
&prefix,NULL);
22662265
isIndexable= (pstatus!=Pattern_Prefix_None);
22672266
break;
22682267

@@ -2271,7 +2270,7 @@ match_special_index_operator(Expr *clause, Oid opfamily,
22712270
caseOID_NAME_REGEXEQ_OP:
22722271
/* the right-hand const is type text for all of these */
22732272
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex,
2274-
&prefix,&rest);
2273+
&prefix,NULL);
22752274
isIndexable= (pstatus!=Pattern_Prefix_None);
22762275
break;
22772276

@@ -2280,7 +2279,7 @@ match_special_index_operator(Expr *clause, Oid opfamily,
22802279
caseOID_NAME_ICREGEXEQ_OP:
22812280
/* the right-hand const is type text for all of these */
22822281
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex_IC,
2283-
&prefix,&rest);
2282+
&prefix,NULL);
22842283
isIndexable= (pstatus!=Pattern_Prefix_None);
22852284
break;
22862285

@@ -2536,7 +2535,6 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily)
25362535
Oidexpr_op= ((OpExpr*)clause)->opno;
25372536
Const*patt= (Const*)rightop;
25382537
Const*prefix=NULL;
2539-
Const*rest=NULL;
25402538
Pattern_Prefix_Statuspstatus;
25412539

25422540
/*
@@ -2556,7 +2554,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily)
25562554
if (!op_in_opfamily(expr_op,opfamily))
25572555
{
25582556
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like,
2559-
&prefix,&rest);
2557+
&prefix,NULL);
25602558
returnprefix_quals(leftop,opfamily,prefix,pstatus);
25612559
}
25622560
break;
@@ -2568,7 +2566,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily)
25682566
{
25692567
/* the right-hand const is type text for all of these */
25702568
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Like_IC,
2571-
&prefix,&rest);
2569+
&prefix,NULL);
25722570
returnprefix_quals(leftop,opfamily,prefix,pstatus);
25732571
}
25742572
break;
@@ -2580,7 +2578,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily)
25802578
{
25812579
/* the right-hand const is type text for all of these */
25822580
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex,
2583-
&prefix,&rest);
2581+
&prefix,NULL);
25842582
returnprefix_quals(leftop,opfamily,prefix,pstatus);
25852583
}
25862584
break;
@@ -2592,7 +2590,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opfamily)
25922590
{
25932591
/* the right-hand const is type text for all of these */
25942592
pstatus=pattern_fixed_prefix(patt,Pattern_Type_Regex_IC,
2595-
&prefix,&rest);
2593+
&prefix,NULL);
25962594
returnprefix_quals(leftop,opfamily,prefix,pstatus);
25972595
}
25982596
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp