summaryrefslogtreecommitdiff
path: root/mysql-test/main/order_by.test
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2020-06-10 18:42:47 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2020-06-11 12:04:21 +0530
commitade0f40ff14a52cfb0dbf400096353e0bef9488a (patch)
tree7e4915696dbacbf7faed1a0baa3ded382177103e /mysql-test/main/order_by.test
parentba2c2cfb20e1ddc7c9d50e635baaead12b88bd13 (diff)
downloadmariadb-git-ade0f40ff14a52cfb0dbf400096353e0bef9488a.tar.gz
MDEV-22819: Wrong result or Assertion `ix > 0' failed in read_to_buffer upon select with GROUP BY and GROUP_CONCAT
In the merge_buffers phase for sorting, the sort buffer size is divided between the number of chunks. The chunks have a start and end position (m_buffer_start and m_buffer_end). Then we read the as many records that fit in this buffer for a chunk of the file. The issue here was we were resetting the end of buffer(m_buffer_end) to the number of bytes that was read, this was causing a problem because with dynamic size of sort keys it is possible that later we would not be able to accommodate even one key inside a chunk of file. So the fix was to not reset the end of buffer for a chunk of file.
Diffstat (limited to 'mysql-test/main/order_by.test')
-rw-r--r--mysql-test/main/order_by.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test
index c78add674ba..be4a3e4253e 100644
--- a/mysql-test/main/order_by.test
+++ b/mysql-test/main/order_by.test
@@ -2465,4 +2465,40 @@ SELECT * FROM t1 ORDER BY CONVERT(AES_ENCRYPT(1,a), CHAR(4));
--enable_warnings
DROP TABLE t1;
+--echo #
+--echo # MDEV-22819:Wrong result or Assertion `ix > 0' failed in read_to_buffer upon select
+--echo # with GROUP BY and GROUP_CONCAT
+--echo #
+
+CREATE TABLE t1 (a VARCHAR(1000), b CHAR(1));
+
+INSERT INTO t1 VALUES
+ (REPEAT('a',1000),'a'),(REPEAT('t',932),'t'),('x',NULL),('x',NULL),
+ (REPEAT('z',298),'z'),(REPEAT('p',1000),'p'),(REPEAT('k',468),'k'),
+ (REPEAT('c',1000),'c'),(REPEAT('o',648),'o'),('x',NULL),('x',NULL),
+ (REPEAT('c',258),'c'),(REPEAT('t',414),'t'),(REPEAT('f',966),'f'),
+ (REPEAT('y',746),'y'),(REPEAT('f',1000),'f');
+
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+
+SET @save_sort_buffer_size= @@sort_buffer_size;
+SET sort_buffer_size= 16384;
+SELECT LEFT(a,1), GROUP_CONCAT(b) FROM t1 GROUP BY a;
+SELECT SUBSTR(a,1,1), LENGTH(a), GROUP_CONCAT(b), COUNT(*) FROM t1 GROUP BY a;
+
+SET @@sort_buffer_size= @save_sort_buffer_size;
+DROP TABLE t1;
+
+CREATE TABLE t1(a VARCHAR(1027), b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_34;
+SET @save_tmp_memory_table_size= @@tmp_memory_table_size;
+SET tmp_memory_table_size= 1056*2;
+SELECT COUNT(DISTINCT a) FROM t1;
+SET @@tmp_memory_table_size= @save_tmp_memory_table_size;
+DROP TABLE t1;
+
+
--echo # End of 10.5 tests