Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 1/1] Add test and changelog for issue gh-5890
Date: Fri, 16 Apr 2021 13:56:40 +0300	[thread overview]
Message-ID: <93f9710b8ee9b17b023b18dfa09da7e1d566340b.1618570487.git.imeevma@gmail.com> (raw)

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


             reply	other threads:[~2021-04-16 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 10:56 Mergen Imeev via Tarantool-patches [this message]
2021-04-16 10:59 ` Mergen Imeev via Tarantool-patches
2021-04-16 19:38   ` Vladislav Shpilevoy via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93f9710b8ee9b17b023b18dfa09da7e1d566340b.1618570487.git.imeevma@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/1] Add test and changelog for issue gh-5890' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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