Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 1/1] Add test and changelog for issue gh-5890
@ 2021-04-16 10:56 Mergen Imeev via Tarantool-patches
  2021-04-16 10:59 ` Mergen Imeev via Tarantool-patches
  0 siblings, 1 reply; 3+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-04-16 10:56 UTC (permalink / raw)
  To: v.shpilevoy; +Cc: tarantool-patches

---
 ...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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-16 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 10:56 [Tarantool-patches] [PATCH 1/1] Add test and changelog for issue gh-5890 Mergen Imeev via Tarantool-patches
2021-04-16 10:59 ` Mergen Imeev via Tarantool-patches
2021-04-16 19:38   ` Vladislav Shpilevoy via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox