[Tarantool-patches] [PATCH 1/3] sql: LENGTH function accepts boolean
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon Oct 28 00:35:07 MSK 2019
Before the patch LENGTH didn't take boolean argument
into account. Now it does and treats like any other
non-string argument - stringify and calculate length.
It is worth mentioning, that in future LENGTH will
discard any non-string argument, see #3929.
Part of #4462
---
src/box/sql/func.c | 1 +
test/sql/boolean.result | 5 +++--
test/sql/boolean.test.sql | 1 +
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index d5ea0fe6a..12a4bee04 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -458,6 +458,7 @@ lengthFunc(sql_context * context, int argc, sql_value ** argv)
case MP_BIN:
case MP_INT:
case MP_UINT:
+ case MP_BOOL:
case MP_DOUBLE:{
sql_result_uint(context, sql_value_bytes(argv[0]));
break;
diff --git a/test/sql/boolean.result b/test/sql/boolean.result
index 352649136..ac9f7fcaf 100644
--- a/test/sql/boolean.result
+++ b/test/sql/boolean.result
@@ -311,14 +311,15 @@ SELECT quote(a) FROM t0;
| - ['NULL']
| - ['NULL']
| ...
+-- gh-4462: LENGTH didn't take BOOLEAN arguments.
SELECT length(a) FROM t0;
| ---
| - metadata:
| - name: length(a)
| type: integer
| rows:
- | - [null]
- | - [null]
+ | - [5]
+ | - [4]
| - [null]
| - [null]
| ...
diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql
index 9d71139fd..68a05852f 100644
--- a/test/sql/boolean.test.sql
+++ b/test/sql/boolean.test.sql
@@ -82,6 +82,7 @@ SELECT abs(a) FROM t0;
SELECT lower(a) FROM t0;
SELECT upper(a) FROM t0;
SELECT quote(a) FROM t0;
+-- gh-4462: LENGTH didn't take BOOLEAN arguments.
SELECT length(a) FROM t0;
SELECT typeof(a) FROM t0;
--
2.21.0 (Apple Git-122)
More information about the Tarantool-patches
mailing list