* [tarantool-patches] [PATCH] sql: fix decoding data of type BOOLEAN
@ 2018-12-29 9:07 Nikita Pettik
2018-12-29 15:06 ` [tarantool-patches] " Kirill Yukhin
0 siblings, 1 reply; 2+ messages in thread
From: Nikita Pettik @ 2018-12-29 9:07 UTC (permalink / raw)
To: tarantool-patches; +Cc: kyukhin, Nikita Pettik
Closes #3906
---
Branch: https://github.com/tarantool/tarantool/tree/np/gh-3906-fix-displaying-bool
Issue: https://github.com/tarantool/tarantool/issues/3906
src/box/sql/vdbeaux.c | 2 +-
test/sql-tap/autoinc.test.lua | 2 +-
test/sql/types.result | 28 ++++++++++++++++++++++++++++
test/sql/types.test.lua | 11 +++++++++++
4 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index fc805e3aa..76bddf2ce 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -3780,7 +3780,7 @@ sqlite3VdbeMsgpackGet(const unsigned char *buf, /* Buffer to deserialize from */
case MP_BOOL:{
assert((unsigned char)*zParse == 0xc2
|| (unsigned char)*zParse == 0xc3);
- pMem->u.i = (unsigned)*zParse - 0xc2; /* bool -> Integer {0,1} */
+ pMem->u.i = (unsigned char)*zParse - 0xc2;
pMem->flags = MEM_Int;
break;
}
diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua
index 3ac9a856a..3becc342a 100755
--- a/test/sql-tap/autoinc.test.lua
+++ b/test/sql-tap/autoinc.test.lua
@@ -43,7 +43,7 @@ test:do_execsql_test(
SELECT * FROM "_sequence";
]], {
-- <autoinc-1.3>
- 1,1,"T1",1,0,9223372036854775807LL,1,0,4294967041
+ 1,1,"T1",1,0,9223372036854775807LL,1,0,0
-- </autoinc-1.3>
})
diff --git a/test/sql/types.result b/test/sql/types.result
index 1daeb7a8c..1ac599ad5 100644
--- a/test/sql/types.result
+++ b/test/sql/types.result
@@ -104,3 +104,31 @@ box.sql.execute("DROP VIEW v1;")
box.sql.execute("DROP TABLE t1;")
---
...
+-- gh-3906: data of type BOOL is displayed as should
+-- during SQL SELECT.
+--
+format = {{ name = 'ID', type = 'unsigned' }, { name = 'A', type = 'boolean' }}
+---
+...
+sp = box.schema.space.create("TEST", { format = format } )
+---
+...
+i = sp:create_index('primary', {parts = {1, 'unsigned' }})
+---
+...
+sp:insert({1, true})
+---
+- [1, true]
+...
+sp:insert({2, false})
+---
+- [2, false]
+...
+box.sql.execute("SELECT * FROM test")
+---
+- - [1, 1]
+ - [2, 0]
+...
+sp:drop()
+---
+...
diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua
index 5f6b4dc49..8eda36159 100644
--- a/test/sql/types.test.lua
+++ b/test/sql/types.test.lua
@@ -29,3 +29,14 @@ box.space.T1.index.I4.parts
box.sql.execute("DROP VIEW v1;")
box.sql.execute("DROP TABLE t1;")
+
+-- gh-3906: data of type BOOL is displayed as should
+-- during SQL SELECT.
+--
+format = {{ name = 'ID', type = 'unsigned' }, { name = 'A', type = 'boolean' }}
+sp = box.schema.space.create("TEST", { format = format } )
+i = sp:create_index('primary', {parts = {1, 'unsigned' }})
+sp:insert({1, true})
+sp:insert({2, false})
+box.sql.execute("SELECT * FROM test")
+sp:drop()
--
2.15.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tarantool-patches] Re: [PATCH] sql: fix decoding data of type BOOLEAN
2018-12-29 9:07 [tarantool-patches] [PATCH] sql: fix decoding data of type BOOLEAN Nikita Pettik
@ 2018-12-29 15:06 ` Kirill Yukhin
0 siblings, 0 replies; 2+ messages in thread
From: Kirill Yukhin @ 2018-12-29 15:06 UTC (permalink / raw)
To: Nikita Pettik; +Cc: tarantool-patches
Hello,
On 29 Dec 11:07, Nikita Pettik wrote:
> Closes #3906
> ---
> Branch: https://github.com/tarantool/tarantool/tree/np/gh-3906-fix-displaying-bool
> Issue: https://github.com/tarantool/tarantool/issues/3906
>
> src/box/sql/vdbeaux.c | 2 +-
> test/sql-tap/autoinc.test.lua | 2 +-
> test/sql/types.result | 28 ++++++++++++++++++++++++++++
> test/sql/types.test.lua | 11 +++++++++++
> 4 files changed, 41 insertions(+), 2 deletions(-)
I've committed your patch into 2.1. It is pretty much straightforward.
--
Regards, Kirill Yukhin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-29 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-29 9:07 [tarantool-patches] [PATCH] sql: fix decoding data of type BOOLEAN Nikita Pettik
2018-12-29 15:06 ` [tarantool-patches] " Kirill Yukhin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox