]> granicus.if.org Git - postgresql/commit
Be more careful about printing constants in ruleutils.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Mar 2015 18:59:49 +0000 (14:59 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Mar 2015 18:59:49 +0000 (14:59 -0400)
commit542320c2bd0b3796a8a9a4617cdb23fbad473390
tree38a517f89bfa0098960d44fae94829a3b86ce3bd
parent701dcc983eb4d08dd36bb3a0ddba255819797760
Be more careful about printing constants in ruleutils.c.

The previous coding in get_const_expr() tried to avoid quoting integer,
float, and numeric literals if at all possible.  While that looks nice,
it means that dumped expressions might re-parse to something that's
semantically equivalent but not the exact same parsetree; for example
a FLOAT8 constant would re-parse as a NUMERIC constant with a cast to
FLOAT8.  Though the result would be the same after constant-folding,
this is problematic in certain contexts.  In particular, Jeff Davis
pointed out that this could cause unexpected failures in ALTER INHERIT
operations because of child tables having not-exactly-equivalent CHECK
expressions.  Therefore, favor correctness over legibility and dump
such constants in quotes except in the limited cases where they'll
be interpreted as the same type even without any casting.

This results in assorted small changes in the regression test outputs,
and will affect display of user-defined views and rules similarly.
The odds of that causing problems in the field seem non-negligible;
given the lack of previous complaints, it seems best not to change
this in the back branches.
12 files changed:
contrib/btree_gist/expected/float4.out
contrib/btree_gist/expected/float8.out
contrib/btree_gist/expected/int2.out
contrib/btree_gist/expected/int8.out
contrib/btree_gist/expected/numeric.out
contrib/postgres_fdw/expected/postgres_fdw.out
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/equivclass.out
src/test/regress/expected/join.out
src/test/regress/expected/rowtypes.out
src/test/regress/expected/union.out
src/test/regress/expected/with.out