]> granicus.if.org Git - postgresql/commit
Teach eval_const_expressions to constant-fold LEAST/GREATEST expressions.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2018 18:42:04 +0000 (13:42 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2018 18:42:04 +0000 (13:42 -0500)
commit6f19a8c41f976236310a272bb646d3411759e18d
tree092758c479f96c39dee58b0f355e7c5fe2c931a5
parente0ef136d5235f39f5652c209c08a5d4322560e9c
Teach eval_const_expressions to constant-fold LEAST/GREATEST expressions.

Doing this requires an assumption that the invoked btree comparison
function is immutable.  We could check that explicitly, but in other
places such as contain_mutable_functions we just assume that it's true,
so we may as well do likewise here.  (If the comparison function's
behavior isn't immutable, the sort order in indexes built with it would
be unstable, so it seems certainly wrong for it not to be so.)

Vik Fearing

Discussion: https://postgr.es/m/c6e8504c-4c43-35fa-6c8f-3c0b80a912cc@2ndquadrant.com
src/backend/optimizer/util/clauses.c