From a697e30a3aa928d6896a45af4b762737d6906022 Mon Sep 17 00:00:00 2001
From: unknown <sasha@mysql.sashanet.com>
Date: Fri, 22 Jun 2001 15:13:33 -0600
Subject: [PATCH] added test case for the bug in ORDER BY when we fill up sort
 buffer Note that if you change sort buffer to be bigger, the bug will not
 show

---
 mysql-test/r/order_fill_sortbuf.result     |  2 ++
 mysql-test/t/order_fill_sortbuf-master.opt |  1 +
 mysql-test/t/order_fill_sortbuf.test       | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 mysql-test/r/order_fill_sortbuf.result
 create mode 100644 mysql-test/t/order_fill_sortbuf-master.opt
 create mode 100644 mysql-test/t/order_fill_sortbuf.test

diff --git a/mysql-test/r/order_fill_sortbuf.result b/mysql-test/r/order_fill_sortbuf.result
new file mode 100644
index 00000000000..cb3349cc433
--- /dev/null
+++ b/mysql-test/r/order_fill_sortbuf.result
@@ -0,0 +1,2 @@
+count(*)
+4000
diff --git a/mysql-test/t/order_fill_sortbuf-master.opt b/mysql-test/t/order_fill_sortbuf-master.opt
new file mode 100644
index 00000000000..af4e7d33143
--- /dev/null
+++ b/mysql-test/t/order_fill_sortbuf-master.opt
@@ -0,0 +1 @@
+-O sort_buffer=0
diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test
new file mode 100644
index 00000000000..5556834d516
--- /dev/null
+++ b/mysql-test/t/order_fill_sortbuf.test
@@ -0,0 +1,19 @@
+drop table if exists t1,t2;
+CREATE TABLE `t1` (
+  `id` int(11) NOT NULL default '0',
+  `id2` int(11) NOT NULL default '0',
+  `id3` int(11) NOT NULL default '0',
+  `dummy1` char(30) default NULL,
+  PRIMARY KEY  (`id`,`id2`),
+  KEY `index_id3` (`id3`));
+let $1=4000;
+while ($1)
+ {
+   eval insert into t1 (id,id2,id3,dummy1) values ($1,$1,$1,'foobar');
+   dec $1;
+ }
+
+create table t2 (n int);
+insert into t2 select id2 from t1 order by id3;
+select count(*) from t2;
+drop table t1,t2;
-- 
2.30.9