pgsql: Be more careful about printing constants in ruleutils.c.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Be more careful about printing constants in ruleutils.c.
Date: 2015-03-30 18:59:55
Message-ID: E1Yceuh-0008PI-6p@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/542320c2bd0b3796a8a9a4617cdb23fbad473390

Modified Files
--------------
contrib/btree_gist/expected/float4.out | 2 +-
contrib/btree_gist/expected/float8.out | 2 +-
contrib/btree_gist/expected/int2.out | 2 +-
contrib/btree_gist/expected/int8.out | 6 +-
contrib/btree_gist/expected/numeric.out | 6 +-
contrib/postgres_fdw/expected/postgres_fdw.out | 2 +-
src/backend/utils/adt/ruleutils.c | 91 ++++++++++++++----------
src/test/regress/expected/equivclass.out | 44 ++++++------
src/test/regress/expected/join.out | 42 +++++------
src/test/regress/expected/rowtypes.out | 6 +-
src/test/regress/expected/union.out | 6 +-
src/test/regress/expected/with.out | 6 +-
12 files changed, 114 insertions(+), 101 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2015-03-30 19:03:16 pgsql: Fix lost persistence setting during REINDEX INDEX
Previous Message Tom Lane 2015-03-30 17:05:42 pgsql: Fix rare core dump in BackendIdGetTransactionIds().