Commit 421d8ca9 authored by unknown's avatar unknown

WL#2247 mysqltest: add option for sorting results

 - Final touchups


client/mysqltest.c:
  Final touch ups, rename sorted_results to sorted_result
mysql-test/r/mysqltest.result:
  Update test result
mysql-test/t/mysqltest.test:
  Update results with additional subtests for empty result set,
  NULL values and 1024 rows
parent f106d396
...@@ -271,7 +271,7 @@ enum enum_commands { ...@@ -271,7 +271,7 @@ enum enum_commands {
Q_EXEC, Q_DELIMITER, Q_EXEC, Q_DELIMITER,
Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_SORTED_RESULTS, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_SORTED_RESULT,
Q_START_TIMER, Q_END_TIMER, Q_START_TIMER, Q_END_TIMER,
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
...@@ -341,7 +341,7 @@ const char *command_names[]= ...@@ -341,7 +341,7 @@ const char *command_names[]=
"horizontal_results", "horizontal_results",
"query_vertical", "query_vertical",
"query_horizontal", "query_horizontal",
"sorted_results", "sorted_result",
"start_timer", "start_timer",
"end_timer", "end_timer",
"character_set", "character_set",
...@@ -6161,7 +6161,7 @@ int main(int argc, char **argv) ...@@ -6161,7 +6161,7 @@ int main(int argc, char **argv)
case Q_DISPLAY_HORIZONTAL_RESULTS: case Q_DISPLAY_HORIZONTAL_RESULTS:
display_result_vertically= FALSE; display_result_vertically= FALSE;
break; break;
case Q_SORTED_RESULTS: case Q_SORTED_RESULT:
/* /*
Turn on sorting of result set, will be reset after next Turn on sorting of result set, will be reset after next
command command
...@@ -6370,7 +6370,7 @@ int main(int argc, char **argv) ...@@ -6370,7 +6370,7 @@ int main(int argc, char **argv)
*/ */
free_all_replace(); free_all_replace();
/* Also reset "sorted_results" */ /* Also reset "sorted_result" */
display_result_sorted= FALSE; display_result_sorted= FALSE;
} }
last_command_executed= command_executed; last_command_executed= command_executed;
......
...@@ -590,13 +590,35 @@ SELECT '1'; ...@@ -590,13 +590,35 @@ SELECT '1';
3 3
1 1
2 2
SET @a = 17; CREATE TABLE t1( a CHAR);
SELECT 2 as "my_col" SELECT * FROM t1;
a
DROP TABLE t1;
SELECT NULL as "my_col1",2 AS "my_col2"
UNION UNION
SELECT 1; SELECT NULL,1;
my_col my_col1 my_col2
1 NULL 2
2 NULL 1
SELECT NULL as "my_col1",2 AS "my_col2"
UNION
SELECT NULL,1;
my_col1 my_col2
NULL 1
NULL 2
SELECT 2 as "my_col1",NULL AS "my_col2"
UNION
SELECT 1,NULL;
my_col1 my_col2
2 NULL
1 NULL
SELECT 2 as "my_col1",NULL AS "my_col2"
UNION
SELECT 1,NULL;
my_col1 my_col2
1 NULL
2 NULL
SET @a = 17;
SELECT 2 as "my_col" SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT 1;
...@@ -613,4 +635,24 @@ SELECT '2' as "my_col1",2 as "my_col2" ...@@ -613,4 +635,24 @@ SELECT '2' as "my_col1",2 as "my_col2"
UNION UNION
SELECT '1',1 from t2; SELECT '1',1 from t2;
ERROR 42S02: Table 'test.t2' doesn't exist ERROR 42S02: Table 'test.t2' doesn't exist
SELECT '1' as "my_col1",2 as "my_col2"
UNION
SELECT '2',1;
my_col1 my_col2
# 1
# 2
CREATE TABLE t1 (f1 INT);
INSERT INTO t1 SET f1 = 1024;
INSERT INTO t1 SELECT f1 - 1 FROM t1;
INSERT INTO t1 SELECT f1 - 2 FROM t1;
INSERT INTO t1 SELECT f1 - 4 FROM t1;
INSERT INTO t1 SELECT f1 - 8 FROM t1;
INSERT INTO t1 SELECT f1 - 16 FROM t1;
INSERT INTO t1 SELECT f1 - 32 FROM t1;
INSERT INTO t1 SELECT f1 - 64 FROM t1;
INSERT INTO t1 SELECT f1 - 128 FROM t1;
INSERT INTO t1 SELECT f1 - 256 FROM t1;
INSERT INTO t1 SELECT f1 - 512 FROM t1;
SELECT * FROM t1;
DROP TABLE t1;
End of tests End of tests
...@@ -1686,79 +1686,129 @@ EOF ...@@ -1686,79 +1686,129 @@ EOF
--exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1 --exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# test for query_sorted # test for sorted_result
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
create table t1( a int, b char(255), c timestamp); 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 2", '2007-04-05');
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05'); insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
select * from t1; select * from t1;
--sorted_results --sorted_result
select * from t1; select * from t1;
# Should not be sorted # Should not be sorted
select * from t1; select * from t1;
disable_result_log; disable_result_log;
sorted_results; sorted_result;
select * from t1; select * from t1;
enable_result_log; enable_result_log;
--sorted_results --sorted_result
select ''; select '';
sorted_results; sorted_result;
select "h"; select "h";
--sorted_results --sorted_result
select "he"; select "he";
--sorted_results --sorted_result
select "hep"; select "hep";
--sorted_results --sorted_result
select "hepp"; select "hepp";
drop table t1; drop table t1;
# 1. Assignment of result set sorting # 1. Assignment of result set sorting
sorted_results; sorted_result;
SELECT 2 as "my_col" SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT 1;
#
--sorted_results --sorted_result
SELECT 2 as "my_col" UNION SELECT 1; SELECT 2 as "my_col" UNION SELECT 1;
--sorted_results --sorted_result
SELECT 2 as "my_col" SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT 1;
# 2. Ensure that the table header will be not sorted into the result # 2. Ensure that the table header will be not sorted into the result
--sorted_results --sorted_result
SELECT '2' as "3" SELECT '2' as "3"
UNION UNION
SELECT '1'; SELECT '1';
# 3. "sorted_results" changes nothing when applied to a non query statement. # 3. Ensure that an empty result set does not cause problems
sorted_results; CREATE TABLE t1( a CHAR);
SET @a = 17; --sorted_result
SELECT * FROM t1;
DROP TABLE t1;
# 4. Show that "--sorted_results" affects the next statement only # 4. Ensure that NULL values within the result set do not cause problems
--sorted_results SELECT NULL as "my_col1",2 AS "my_col2"
SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT NULL,1;
--sorted_result
SELECT NULL as "my_col1",2 AS "my_col2"
UNION
SELECT NULL,1;
#
SELECT 2 as "my_col1",NULL AS "my_col2"
UNION
SELECT 1,NULL;
--sorted_result
SELECT 2 as "my_col1",NULL AS "my_col2"
UNION
SELECT 1,NULL;
# 5. "sorted_result" changes nothing when applied to a non query statement.
sorted_result;
SET @a = 17;
#
# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect
# the now following query.
SELECT 2 as "my_col" SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT 1;
# 5. Ensure that "sorted_results" in combination with $variables works # 7. Ensure that "sorted_result" in combination with $variables works
let $my_stmt=SELECT 2 as "my_col" let $my_stmt=SELECT 2 as "my_col"
UNION UNION
SELECT 1; SELECT 1;
--sorted_results --sorted_result
eval $my_stmt; eval $my_stmt;
# 6. Ensure that "sorted_results " does not change the semantics of "--error ...." # 8. Ensure that "sorted_result " does not change the semantics of
# or the protocol output after such an expected failure # "--error ...." or the protocol output after such an expected failure
--sorted_results --sorted_result
--error 1146 --error 1146
SELECT '2' as "my_col1",2 as "my_col2" SELECT '2' as "my_col1",2 as "my_col2"
UNION UNION
SELECT '1',1 from t2; SELECT '1',1 from t2;
# 9. Ensure that several result formatting options including "sorted_result"
# - have all an effect
# - "--sorted_result" does not need to be direct before the statement
# - Row sorting is applied after modification of the column content
--sorted_result
--replace_column 1 #
SELECT '1' as "my_col1",2 as "my_col2"
UNION
SELECT '2',1;
# 10. Ensure that at least 1024 rows within a result set do not cause problems
#
CREATE TABLE t1 (f1 INT);
INSERT INTO t1 SET f1 = 1024;
INSERT INTO t1 SELECT f1 - 1 FROM t1;
INSERT INTO t1 SELECT f1 - 2 FROM t1;
INSERT INTO t1 SELECT f1 - 4 FROM t1;
INSERT INTO t1 SELECT f1 - 8 FROM t1;
INSERT INTO t1 SELECT f1 - 16 FROM t1;
INSERT INTO t1 SELECT f1 - 32 FROM t1;
INSERT INTO t1 SELECT f1 - 64 FROM t1;
INSERT INTO t1 SELECT f1 - 128 FROM t1;
INSERT INTO t1 SELECT f1 - 256 FROM t1;
INSERT INTO t1 SELECT f1 - 512 FROM t1;
--disable_result_log
--sorted_result
SELECT * FROM t1;
--enable_result_log
DROP TABLE t1;
--echo End of tests --echo End of tests
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment