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

Commit1f194ed

Browse files
committed
Fix incorrect hash equality operator bug in Memoize
In v14, because we don't have a field in RestrictInfo to cache both theleft and right type's hash equality operator, we just restrict the scopeof Memoize to only when the left and right types of a RestrictInfo are thesame.In master we add another field to RestrictInfo and cache both hashequality operators.Reported-by: Jaime CasanovaAuthor: David RowleyDiscussion:https://postgr.es/m/20210929185544.GB24346%40ahch-toBackpatch-through: 14
1 parentbb003ed commit1f194ed

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/backend/optimizer/plan/initsplan.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,8 @@ check_memoizable(RestrictInfo *restrictinfo)
27192719
{
27202720
TypeCacheEntry*typentry;
27212721
Expr*clause=restrictinfo->clause;
2722-
Node*leftarg;
2722+
Oidlefttype;
2723+
Oidrighttype;
27232724

27242725
if (restrictinfo->pseudoconstant)
27252726
return;
@@ -2728,10 +2729,20 @@ check_memoizable(RestrictInfo *restrictinfo)
27282729
if (list_length(((OpExpr*)clause)->args)!=2)
27292730
return;
27302731

2731-
leftarg=linitial(((OpExpr*)clause)->args);
2732+
lefttype=exprType(linitial(((OpExpr*)clause)->args));
2733+
righttype=exprType(lsecond(((OpExpr*)clause)->args));
2734+
2735+
/*
2736+
* Really there should be a field for both the left and right hash
2737+
* equality operator, however, in v14, there's only a single field in
2738+
* RestrictInfo to record the operator in, so we must insist that the left
2739+
* and right types match.
2740+
*/
2741+
if (lefttype!=righttype)
2742+
return;
27322743

2733-
typentry=lookup_type_cache(exprType(leftarg),TYPECACHE_HASH_PROC |
2734-
TYPECACHE_EQ_OPR);
2744+
typentry=lookup_type_cache(lefttype,TYPECACHE_HASH_PROC |
2745+
TYPECACHE_EQ_OPR);
27352746

27362747
if (!OidIsValid(typentry->hash_proc)|| !OidIsValid(typentry->eq_opr))
27372748
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp