-
Notifications
You must be signed in to change notification settings - Fork 11
[u]int64_t parameters; decimal->number cast removed in favor of original textual representation #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Patch breaks tests: Logsergeyb@pony:~/sources/MRG/pg$ git describe
2.0.2-7-g4043e43
sergeyb@pony:~/sources/MRG/pg$ curl -O https://patch-diff.githubusercontent.com/raw/tarantool/pg/pull/28.patch
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1694 0 1694 0 0 3948 0 --:--:-- --:--:-- --:--:-- 3948
sergeyb@pony:~/sources/MRG/pg$ patch -p1 < 28.patch
patching file pg/driver.c
sergeyb@pony:~/sources/MRG/pg$ make
[100%] Built target driver
sergeyb@pony:~/sources/MRG/pg$ tarantool --version
Tarantool 2.8.3-0-g01023dbc2
sergeyb@pony:~/sources/MRG/pg$ pg_config --version
PostgreSQL 14.2 (Ubuntu 14.2-1.pgdg20.04+1)
sergeyb@pony:~/sources/MRG/pg$ sudo -u postgres tarantool test/pg.test.lua
TAP version 13
# connection old api
1..15
ok - connection
ok - ping
ok - SELECT 123::text AS bla, 345
ok - SELECT -1 AS neg, NULL AS abc
not ok - SELECT -1.1 AS neg, 1.2 AS pos
---
path: //1/1/1/neg
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: -1.1
got: '-1.1'
...
not ok - SELECT ARRAY[1,2] AS arr, 1.2 AS pos
---
path: //1/1/1/pos
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 1.2
got: '1.2'
...
ok - SELECT $1 AS val % ["abc"]
not ok - SELECT $1 AS val % [123]
---
path: //1/1/1/val
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 123
got: '123'
...
ok - SELECT $1 AS val % [true]
ok - SELECT $1 AS val % [false]
not ok - SELECT $1 AS val, $2 AS num, $3 AS str % [false,123,"abc"]
---
path: //1/1/1/num
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 123
got: '123'
...
ok - SELECT * FROM (VALUES (1,2), (2,3)) t
# tx
1..7
ok - begin
ok - SELECT * FROM _tx_test
ok - roolback
ok - SELECT * FROM _tx_test
ok - begin
ok - commit
ok - SELECT * FROM _tx_test
# tx: end
ok - tx
# numeric string binding
1..1
ok - SELECT TEST1_REQUESTID FROM TEST1;
# numeric string binding: end
ok - numeric string binding
ok - error
# connection old api: end
# failed subtest: 4
TAP version 13
# connection old api via pool
1..15
ok - connection
ok - ping
ok - SELECT 123::text AS bla, 345
ok - SELECT -1 AS neg, NULL AS abc
not ok - SELECT -1.1 AS neg, 1.2 AS pos
---
path: //1/1/1/neg
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: -1.1
got: '-1.1'
...
not ok - SELECT ARRAY[1,2] AS arr, 1.2 AS pos
---
path: //1/1/1/pos
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 1.2
got: '1.2'
...
ok - SELECT $1 AS val % ["abc"]
not ok - SELECT $1 AS val % [123]
---
path: //1/1/1/val
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 123
got: '123'
...
ok - SELECT $1 AS val % [true]
ok - SELECT $1 AS val % [false]
not ok - SELECT $1 AS val, $2 AS num, $3 AS str % [false,123,"abc"]
---
path: //1/1/1/num
line: 0
strict: false
filename: test/pg.test.lua
trace:
- line: 26
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: method
name: q
src: test/pg.test.lua
- line: 22
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: Lua
namewhat: local
name: fun
src: test/pg.test.lua
- line: 218
source: '@builtin/tap.lua'
filename: builtin/tap.lua
what: Lua
namewhat: field
name: test
src: builtin/tap.lua
- line: 0
source: '@test/pg.test.lua'
filename: test/pg.test.lua
what: main
namewhat:
src: test/pg.test.lua
expected: 123
got: '123'
...
ok - SELECT * FROM (VALUES (1,2), (2,3)) t
# tx
1..7
ok - begin
ok - SELECT * FROM _tx_test
ok - roolback
ok - SELECT * FROM _tx_test
ok - begin
ok - commit
ok - SELECT * FROM _tx_test
# tx: end
ok - tx
# numeric string binding
1..1
ok - SELECT TEST1_REQUESTID FROM TEST1;
# numeric string binding: end
ok - numeric string binding
ok - error
# connection old api via pool: end
# failed subtest: 4
TAP version 13
# test collection connections
1..1
ok - gc connections
# test collection connections: end
TAP version 13
# connection concurrent
1..1
ok - concurrent connections
# connection concurrent: end
TAP version 13
# int64
1..1
ok - int64 test
# int64: end |
Because client-side decimal->number cast is a faulty one. Take a look at Qt's NumericalPrecisionPolicy. If a user has no choice then we should preserve original precision. |
Patch cannot be merged if it makes CI red. Please fix tests. |
Thanks for the patch! The idea looks right for me. My doubts are about backward compatibility. I would prefer a safe way and keep everything as before if no new options are passed. So existing applications will not need to update its code if everything works for them. We'll suggest to enable the new (more correct) behaviour in README and release notes, but we should not make it the only option. I see that (comparing to the first version) you added ability to pass an option, but:
Also I would split the changes into two commits (one regarding numeric decoding, one about cdata numbers encoding), because now it is not quite obvious what actually is changed. |
No, this is not connection's execute() - it's internal one. Everything is absolutely backward compatible. Previous behaviour is the default one. |
NB: link #26, check whether we should copy the static buffer before passing it to libpq (in binding parameters handling) |
@Totktonada Ъ? |
Sorry, I'm on finishing my current quarter tasks. Hopefully I'll end on this week. |
6141671
to
792fc4c
Compare
[REMOVE BEFORE MERGE] Changes proposed in fixup commit: documentation, regression tests, code style. Patch adds support of PostgreSQL decimal numbers - it is possible to choose a Lua/Tarantool type that will be used for casting values with NUMERIC type [1]. By default Lua "number" type is used, the same behaviour was used before changes. Additionally user could choose two other types: Lua "string" and Tarantool's decimal type [2], [3]. Fixes tarantool#26 Fixes tarantool#25 1. https://www.postgresql.org/docs/current/datatype-oid.html 2. https://www.tarantool.io/en/doc/latest/reference/reference_lua/decimal/ 3. https://www.tarantool.io/en/doc/latest/book/box/data_model/#data-types Co-authored-by: Sergey Bronnikov <sergeyb@tarantool.org>
@Totktonada Ъ? |
No description provided.