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

Commit64edc78

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 parentafd090a commit64edc78

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
@@ -1529,7 +1529,6 @@ contain_leaked_vars_walker(Node *node, void *context)
15291529
caseT_CaseExpr:
15301530
caseT_CaseTestExpr:
15311531
caseT_RowExpr:
1532-
caseT_MinMaxExpr:
15331532
caseT_SQLValueFunction:
15341533
caseT_NullTest:
15351534
caseT_BooleanTest:
@@ -1586,6 +1585,36 @@ contain_leaked_vars_walker(Node *node, void *context)
15861585
}
15871586
break;
15881587

1588+
caseT_MinMaxExpr:
1589+
{
1590+
/*
1591+
* MinMaxExpr is leakproof if the comparison function it calls
1592+
* is leakproof.
1593+
*/
1594+
MinMaxExpr*minmaxexpr= (MinMaxExpr*)node;
1595+
TypeCacheEntry*typentry;
1596+
boolleakproof;
1597+
1598+
/* Look up the btree comparison function for the datatype */
1599+
typentry=lookup_type_cache(minmaxexpr->minmaxtype,
1600+
TYPECACHE_CMP_PROC);
1601+
if (OidIsValid(typentry->cmp_proc))
1602+
leakproof=get_func_leakproof(typentry->cmp_proc);
1603+
else
1604+
{
1605+
/*
1606+
* The executor will throw an error, but here we just
1607+
* treat the missing function as leaky.
1608+
*/
1609+
leakproof= false;
1610+
}
1611+
1612+
if (!leakproof&&
1613+
contain_var_clause((Node*)minmaxexpr->args))
1614+
return true;
1615+
}
1616+
break;
1617+
15891618
caseT_CurrentOfExpr:
15901619

15911620
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp