Commit 2ec01d90 authored by Bjorn Munch's avatar Bjorn Munch

Bug #48863 mysql test: enable and disable case insensitive compare mode

Implemented --lowercase_result which lower cases next result
parent eec8deed
...@@ -97,7 +97,7 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; ...@@ -97,7 +97,7 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0;
static my_bool view_protocol= 0, view_protocol_enabled= 0; static my_bool view_protocol= 0, view_protocol_enabled= 0;
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
static my_bool parsing_disabled= 0; static my_bool parsing_disabled= 0;
static my_bool display_result_vertically= FALSE, static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
display_metadata= FALSE, display_result_sorted= FALSE; display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0; static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_warnings= 0; static my_bool disable_warnings= 0;
...@@ -272,6 +272,7 @@ enum enum_commands { ...@@ -272,6 +272,7 @@ enum enum_commands {
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_RESULT, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_SORTED_RESULT,
Q_LOWERCASE,
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,
...@@ -346,6 +347,7 @@ const char *command_names[]= ...@@ -346,6 +347,7 @@ const char *command_names[]=
"query_vertical", "query_vertical",
"query_horizontal", "query_horizontal",
"sorted_result", "sorted_result",
"lowercase_result",
"start_timer", "start_timer",
"end_timer", "end_timer",
"character_set", "character_set",
...@@ -7876,6 +7878,13 @@ int main(int argc, char **argv) ...@@ -7876,6 +7878,13 @@ int main(int argc, char **argv)
*/ */
display_result_sorted= TRUE; display_result_sorted= TRUE;
break; break;
case Q_LOWERCASE:
/*
Turn on lowercasing of result, will be reset after next
command
*/
display_result_lower= TRUE;
break;
case Q_LET: do_let(command); break; case Q_LET: do_let(command); break;
case Q_EVAL_RESULT: case Q_EVAL_RESULT:
die("'eval_result' command is deprecated"); die("'eval_result' command is deprecated");
...@@ -8091,8 +8100,9 @@ int main(int argc, char **argv) ...@@ -8091,8 +8100,9 @@ int main(int argc, char **argv)
*/ */
free_all_replace(); free_all_replace();
/* Also reset "sorted_result" */ /* Also reset "sorted_result" and "lowercase"*/
display_result_sorted= FALSE; display_result_sorted= FALSE;
display_result_lower= FALSE;
} }
last_command_executed= command_executed; last_command_executed= command_executed;
...@@ -9496,6 +9506,18 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, ...@@ -9496,6 +9506,18 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
fix_win_paths(val, len); fix_win_paths(val, len);
#endif #endif
if (display_result_lower)
{
/* Convert to lower case, and do this first */
char lower[512];
char *c= lower;
for (const char *v= val; *v; v++)
*c++= my_tolower(charset_info, *v);
*c= '\0';
/* Copy from this buffer instead */
val= lower;
}
if (glob_replace_regex) if (glob_replace_regex)
{ {
/* Regex replace */ /* Regex replace */
......
...@@ -682,6 +682,29 @@ INSERT INTO t1 SELECT f1 - 256 FROM t1; ...@@ -682,6 +682,29 @@ INSERT INTO t1 SELECT f1 - 256 FROM t1;
INSERT INTO t1 SELECT f1 - 512 FROM t1; INSERT INTO t1 SELECT f1 - 512 FROM t1;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
select "500g blåbærsyltetøy" as "will be lower cased";
will be lower cased
500g blåbærsyltetøy
SELECT "UPPER" AS "WILL NOT BE lower cased";
WILL NOT BE lower cased
UPPER
UP
SELECT 0 as "UP AGAIN";
UP AGAIN
0
select "abcdef" as "uvwxyz";
uvwxyz
abcdef
select "xyz" as name union select "abc" as name order by name desc;
name
abc
xyz
select 1 as "some new text";
some new text
1
select 0 as "will not lower case ÄËÐ";
will not lower case ÄËÐ
0
CREATE TABLE t1( CREATE TABLE t1(
a int, b varchar(255), c datetime a int, b varchar(255), c datetime
); );
......
...@@ -2059,6 +2059,44 @@ INSERT INTO t1 SELECT f1 - 512 FROM t1; ...@@ -2059,6 +2059,44 @@ INSERT INTO t1 SELECT f1 - 512 FROM t1;
SELECT * FROM t1; SELECT * FROM t1;
--enable_result_log --enable_result_log
DROP TABLE t1; DROP TABLE t1;
# ----------------------------------------------------------------------------
# test for lowercase_result
# ----------------------------------------------------------------------------
# 1. Basic test
--lowercase_result
SELECT "500g BLBRSYLTETY" AS "WILL BE lower cased";
# 2. test that it does not apply to next statement
SELECT "UPPER" AS "WILL NOT BE lower cased";
# 3. test that it does not affect non-SQL or the following statement
--lowercase_result
--echo UP
SELECT 0 as "UP AGAIN";
# 4. test that it works with eval and variables
let $lower_stmt=SELECT "ABCdef" AS "uvwXYZ";
--lowercase_result
eval $lower_stmt;
# 5. test that it works in combination with sort
sorted_result;
lowercase_result;
SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC;
# 6. Test combination with replace, and that lower casing is done first
--lowercase_result
--replace_result old new
SELECT 1 as "SOME OLD TEXT";
# 7. Test missing lower casing of "unknown" characters
--character_set utf8
--lowercase_result
SELECT 0 as "WILL NOT lower case ";
--character_set latin1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Some coverage tests # Some coverage 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