[Tarantool-patches] [PATCH 1/1] Add test and changelog for issue gh-5890
imeevma at tarantool.org
imeevma at tarantool.org
Fri Apr 16 13:56:40 MSK 2021
---
...fix-wrong-result-on-select-with-groupby.md | 4 +++
...gh-5890-wrong-select-with-groupby.test.lua | 28 +++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100644 changelogs/unreleased/fix-wrong-result-on-select-with-groupby.md
create mode 100755 test/sql-tap/gh-5890-wrong-select-with-groupby.test.lua
diff --git a/changelogs/unreleased/fix-wrong-result-on-select-with-groupby.md b/changelogs/unreleased/fix-wrong-result-on-select-with-groupby.md
new file mode 100644
index 000000000..1ed39ccce
--- /dev/null
+++ b/changelogs/unreleased/fix-wrong-result-on-select-with-groupby.md
@@ -0,0 +1,4 @@
+## bugfix/sql
+
+* Fix wrong result of SELECT with GROUP BY in case one of selected values is
+ VARBINARY, which is not directly obtained from a space (gh-5890).
diff --git a/test/sql-tap/gh-5890-wrong-select-with-groupby.test.lua b/test/sql-tap/gh-5890-wrong-select-with-groupby.test.lua
new file mode 100755
index 000000000..2b7e19862
--- /dev/null
+++ b/test/sql-tap/gh-5890-wrong-select-with-groupby.test.lua
@@ -0,0 +1,28 @@
+#!/usr/bin/env tarantool
+local test = require("sqltester")
+test:plan(2)
+
+--
+-- Make sure the SELECT result does not change if GROUP BY is used in case one of
+-- selected values is also used in GROUP BY and is a VARBINARY that is not
+-- directly received from space.
+--
+test:do_execsql_test(
+ "gh-5890-1",
+ [[
+ CREATE TABLE t(i INT PRIMARY KEY, v VARBINARY);
+ INSERT INTO t VALUES(1, x'6178'), (2, x'6278'), (3, x'6379');
+ SELECT count(*), substr(v,2,1) AS m FROM t GROUP BY m;
+ ]], {
+ 2, 'x', 1, 'y'
+ })
+
+test:do_execsql_test(
+ "gh-5890-2",
+ [[
+ SELECT count(*), v || v AS m FROM t GROUP BY m;
+ ]], {
+ 1, 'axax', 1, 'bxbx', 1, 'cycy'
+ })
+
+test:finish_test()
--
2.25.1
More information about the Tarantool-patches
mailing list