From: digoal@126.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13699: float type bug
Date: Thu, 22 Oct 2015 08:23:34 +0000
Message-ID: <20151022082334.3033.31583@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 13699
Logged by: digoal
Email address: digoal@126.com
PostgreSQL version: 9.4.5
Operating system: CentOS 6.x x64
Description:
postgres=# create table t3(c1 float, c2 numeric);
CREATE TABLE
postgres=# \d t3
Table "public.t3"
Column | Type | Modifiers
--------+------------------+-----------
c1 | double precision |
c2 | numeric |
postgres=# insert into t3 values (1.55555555555555555555555555555555555,
1.55555555555555555555555555555555555);
INSERT 0 1
postgres=# select * from t3;
c1 | c2
------------------+---------------------------------------
1.55555555555556 | 1.55555555555555555555555555555555555
(1 row)
but:
postgres=# select * from t3 where c1>=1.55555555555556;
c1 | c2
----+----
(0 rows)
when we use logical decoding there will replace the real value with
1.55555555555556.
postgres=# SELECT * FROM
pg_create_logical_replication_slot('regression_slot', 'test_decoding');
slot_name | xlog_position
-----------------+---------------
regression_slot | 0/4C4A260
(1 row)
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot',
NULL, NULL);
location | xid | data
----------+-----+------
(0 rows)
postgres=# create table test(c1 float);
CREATE TABLE
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot',
NULL, NULL);
location | xid | data
-----------+------+-------------
0/4C4A2F0 | 9723 | BEGIN 9723
0/4C5A6D0 | 9723 | COMMIT 9723
(2 rows)
postgres=# insert into test values (1.5555555555555555555555);
INSERT 0 1
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot',
NULL, NULL);
location | xid | data
-----------+------+------------------------------------------------------------------
0/4C5A6D0 | 9724 | BEGIN 9724
0/4C5A6D0 | 9724 | table public.test: INSERT: c1[double
precision]:1.55555555555556
0/4C5A758 | 9724 | COMMIT 9724
(3 rows)
and pg_dump use this code resolve the problem.
if (AH->remoteVersion >= 90000)
ExecuteSqlStatement(AH, "SET extra_float_digits TO 3");
else if (AH->remoteVersion >= 70400)
ExecuteSqlStatement(AH, "SET extra_float_digits TO 2");
in logical decoding , when we use cstring as the output , what we can do?
or we must use bytea output?
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: digoal@126.com
Subject: Re: BUG #13699: float type bug
In-Reply-To: <20151022082334.3033.31583@wrigleys.postgresql.org>
References: <20151022082334.3033.31583@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox