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

Commit68a13f2

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 parentacfe139 commit68a13f2

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
@@ -1579,7 +1579,6 @@ contain_leaked_vars_walker(Node *node, void *context)
15791579
caseT_CaseExpr:
15801580
caseT_CaseTestExpr:
15811581
caseT_RowExpr:
1582-
caseT_MinMaxExpr:
15831582
caseT_SQLValueFunction:
15841583
caseT_NullTest:
15851584
caseT_BooleanTest:
@@ -1636,6 +1635,36 @@ contain_leaked_vars_walker(Node *node, void *context)
16361635
}
16371636
break;
16381637

1638+
caseT_MinMaxExpr:
1639+
{
1640+
/*
1641+
* MinMaxExpr is leakproof if the comparison function it calls
1642+
* is leakproof.
1643+
*/
1644+
MinMaxExpr*minmaxexpr= (MinMaxExpr*)node;
1645+
TypeCacheEntry*typentry;
1646+
boolleakproof;
1647+
1648+
/* Look up the btree comparison function for the datatype */
1649+
typentry=lookup_type_cache(minmaxexpr->minmaxtype,
1650+
TYPECACHE_CMP_PROC);
1651+
if (OidIsValid(typentry->cmp_proc))
1652+
leakproof=get_func_leakproof(typentry->cmp_proc);
1653+
else
1654+
{
1655+
/*
1656+
* The executor will throw an error, but here we just
1657+
* treat the missing function as leaky.
1658+
*/
1659+
leakproof= false;
1660+
}
1661+
1662+
if (!leakproof&&
1663+
contain_var_clause((Node*)minmaxexpr->args))
1664+
return true;
1665+
}
1666+
break;
1667+
16391668
caseT_CurrentOfExpr:
16401669

16411670
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp