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

Commitc27c399

Browse files
committed
Don't believe MinMaxExpr is leakproof without checking.
MinMaxExpr invokes the btree comparison function for its input datatype,so it's only leakproof if that function is. Many such functions areindeed leakproof, but others are not, and we should not just assume thatthey are. Hence, adjust contain_leaked_vars to verify the leakproofnessof the referenced function explicitly.I didn't add a regression test because it would need to depend onsome particular comparison function being leaky, and that's a movingtarget, per discussion.This has been wrong all along, so back-patch to supported branches.Discussion:https://postgr.es/m/31042.1546194242@sss.pgh.pa.us
1 parentb66a074 commitc27c399

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,6 @@ contain_leaked_vars_walker(Node *node, void *context)
14811481
caseT_CaseExpr:
14821482
caseT_CaseTestExpr:
14831483
caseT_RowExpr:
1484-
caseT_MinMaxExpr:
14851484
caseT_NullTest:
14861485
caseT_BooleanTest:
14871486
caseT_List:
@@ -1536,6 +1535,36 @@ contain_leaked_vars_walker(Node *node, void *context)
15361535
}
15371536
break;
15381537

1538+
caseT_MinMaxExpr:
1539+
{
1540+
/*
1541+
* MinMaxExpr is leakproof if the comparison function it calls
1542+
* is leakproof.
1543+
*/
1544+
MinMaxExpr*minmaxexpr= (MinMaxExpr*)node;
1545+
TypeCacheEntry*typentry;
1546+
boolleakproof;
1547+
1548+
/* Look up the btree comparison function for the datatype */
1549+
typentry=lookup_type_cache(minmaxexpr->minmaxtype,
1550+
TYPECACHE_CMP_PROC);
1551+
if (OidIsValid(typentry->cmp_proc))
1552+
leakproof=get_func_leakproof(typentry->cmp_proc);
1553+
else
1554+
{
1555+
/*
1556+
* The executor will throw an error, but here we just
1557+
* treat the missing function as leaky.
1558+
*/
1559+
leakproof= false;
1560+
}
1561+
1562+
if (!leakproof&&
1563+
contain_var_clause((Node*)minmaxexpr->args))
1564+
return true;
1565+
}
1566+
break;
1567+
15391568
caseT_CurrentOfExpr:
15401569

15411570
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp