Re: [Bug Fix]ECPG: cancellation of significant digits on ECPG
Dmitry Dolgov <9erthalion6@gmail.com>
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: higuchi.daisuke@jp.fujitsu.com
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-11-06T14:03:03Z
Lists: pgsql-hackers
> On Tue, 6 Nov 2018 at 10:19, Higuchi, Daisuke <higuchi.daisuke@jp.fujitsu.com> wrote:
>
> Thank you for checking!
> I rebased patches on the current master, so I attach them.
After adding 'EXEC SQL ALLOCATE DESCRIPTOR sqlda' I've managed to reproduce the
problem you're talking about, and indeed it looks strange:
=# table testtab ;
c1
---------
1.23456
0.12345
0.01234
(3 rows)
but in ecpg program we've got from gdb:
# for the second record 0.12345
$$1 = {
ndigits = 5,
weight = -1,
rscale = 5,
dscale = 5,
sign = 0,
buf = 0x5555557636d8 "",
digits = 0x5555557636da "\001\002\003\004"
}
# for the third record 0.01234
$$0 = {
ndigits = 4,
weight = -2,
rscale = 5,
dscale = 5,
sign = 0,
buf = 0x555555763578 "",
digits = 0x55555576357b "\001\002"
}
Also what's strange for me is that after applying your patches I still got the
same output, not sure why:
./numeric_test
ndigits :6
buf :0 1 2 3 4 5 6
digits :1 2 3 4 5 6
numeric :1.23456
----------------------------
ndigits :5
buf :0 0 1 2 3 4 0
digits :1 2 3 4 0
numeric :0.12340
----------------------------
ndigits :4
buf :0 0 0 1 2 0 0
digits :1 2 0 0
numeric :0.01200
----------------------------
Commits
-
Second try at fixing numeric data passed through an ECPG SQLDA.
- 06c723447b6b 12.0 landed
- f9e25ba14077 9.6.12 landed
- 68f30638a050 9.5.16 landed
- 41609776f2c2 9.4.21 landed
- 4618fdd67412 11.2 landed
- 2e8ed4659972 10.7 landed
-
Fix incorrect results for numeric data passed through an ECPG SQLDA.
- ecfd5579561c 12.0 landed
- e1f25901268c 9.6.12 landed
- be38945c6e66 9.5.16 landed
- 9e5e3861c782 9.4.21 landed
- 68393f3fd6b9 11.2 landed
- 32060f6780bc 10.7 landed