summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/mysqltest.result52
-rw-r--r--mysql-test/t/mysqltest.test71
2 files changed, 116 insertions, 7 deletions
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index e460275e758..989792160f0 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -546,6 +546,12 @@ a b c
2 Part 2 2007-04-05 00:00:00
2 Part 3 2007-04-05 00:00:00
select * from t1;
+a b c
+1 Line 1 2007-04-05 00:00:00
+2 Part 2 2007-04-05 00:00:00
+1 Line 1 2007-04-05 00:00:00
+2 Part 3 2007-04-05 00:00:00
+select * from t1;
select '';
@@ -561,4 +567,50 @@ hep
select "hepp";
hepp
hepp
+drop table t1;
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+my_col
+1
+2
+SELECT 2 as "my_col" UNION SELECT 1;
+my_col
+1
+2
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+my_col
+1
+2
+SELECT '2' as "3"
+UNION
+SELECT '1';
+3
+1
+2
+SET @a = 17;
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+my_col
+1
+2
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+my_col
+2
+1
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+my_col
+1
+2
+SELECT '2' as "my_col1",2 as "my_col2"
+UNION
+SELECT '1',1 from t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
End of tests
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index a9ac2ec8a96..99213d47d38 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1693,15 +1693,72 @@ create table t1( a int, b char(255), c timestamp);
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
select * from t1;
-query_sorted select * from t1;
+--sorted_results
+select * from t1;
+# Should not be sorted
+select * from t1;
disable_result_log;
-query_sorted select * from t1;
+sorted_results;
+select * from t1;
enable_result_log;
-query_sorted select '';
-query_sorted select "h";
-query_sorted select "he";
-query_sorted select "hep";
-query_sorted select "hepp";
+--sorted_results
+select '';
+sorted_results;
+select "h";
+--sorted_results
+select "he";
+--sorted_results
+select "hep";
+--sorted_results
+select "hepp";
+drop table t1;
+
+# 1. Assignment of result set sorting
+sorted_results;
+ SELECT 2 as "my_col"
+UNION
+SELECT 1;
+
+--sorted_results
+SELECT 2 as "my_col" UNION SELECT 1;
+--sorted_results
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+
+# 2. Ensure that the table header will be not sorted into the result
+--sorted_results
+SELECT '2' as "3"
+UNION
+SELECT '1';
+
+# 3. "sorted_results" changes nothing when applied to a non query statement.
+sorted_results;
+ SET @a = 17;
+
+# 4. Show that "--sorted_results" affects the next statement only
+--sorted_results
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+SELECT 2 as "my_col"
+UNION
+SELECT 1;
+
+# 5. Ensure that "sorted_results" in combination with $variables works
+let $my_stmt=SELECT 2 as "my_col"
+UNION
+SELECT 1;
+--sorted_results
+eval $my_stmt;
+
+# 6. Ensure that "sorted_results " does not change the semantics of "--error ...."
+# or the protocol output after such an expected failure
+--sorted_results
+--error 1146
+SELECT '2' as "my_col1",2 as "my_col2"
+UNION
+SELECT '1',1 from t2;
--echo End of tests