mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-23 03:00:41 +02:00
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.
92 lines
1.7 KiB
Plaintext
92 lines
1.7 KiB
Plaintext
-- float4 check
|
|
CREATE TABLE float4tmp (a float4);
|
|
\copy float4tmp from 'data/float4.data'
|
|
SET enable_seqscan=on;
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0;
|
|
count
|
|
-------
|
|
244
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0;
|
|
count
|
|
-------
|
|
245
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0;
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0;
|
|
count
|
|
-------
|
|
303
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
a | ?column?
|
|
----------+----------
|
|
-179 | 0
|
|
-189.024 | 10.0239
|
|
-158.177 | 20.8226
|
|
(3 rows)
|
|
|
|
CREATE INDEX float4idx ON float4tmp USING gist ( a );
|
|
SET enable_seqscan=off;
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0::float4;
|
|
count
|
|
-------
|
|
244
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0::float4;
|
|
count
|
|
-------
|
|
245
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0::float4;
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0::float4;
|
|
count
|
|
-------
|
|
303
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0::float4;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
QUERY PLAN
|
|
----------------------------------------------------
|
|
Limit
|
|
-> Index Only Scan using float4idx on float4tmp
|
|
Order By: (a <-> '-179'::real)
|
|
(3 rows)
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
a | ?column?
|
|
----------+----------
|
|
-179 | 0
|
|
-189.024 | 10.0239
|
|
-158.177 | 20.8226
|
|
(3 rows)
|
|
|