Fix pg_get_ruledef() so that negative numeric constants are parenthesized.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: c760d70af47d648833c03d764255c31b8d554ee3
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2008-06-06T18:00:09Z
Releases: 7.4.21
Fix pg_get_ruledef() so that negative numeric constants are parenthesized.
This is needed because :: casting binds more tightly than minus, so for
example -1::integer is not the same as (-1)::integer, and there are cases
where the difference is important.  In particular this caused a failure
in SELECT DISTINCT ... ORDER BY ... where expressions that should have
matched were seen as different by the parser; but I suspect that there
could be other cases where failure to parenthesize leads to subtler
semantic differences in reloaded rules.  Per report from Alexandr Popov.

Files

PathChange+/−
src/backend/utils/adt/ruleutils.c modified +11 −2