Commit 58df2097 authored by Dave Gosselin's avatar Dave Gosselin Committed by Daniel Black

MDEV-33460 select '123' 'x'; unexpected result

Queries that select concatenated constant strings now have
colname and value that match.  For example,
  SELECT '123' 'x';
will return a result where the column name and value both
are '123x'.

Review: Daniel Black
parent 76a27155
......@@ -64,7 +64,7 @@ SET sql_mode=@mode;
# Test litteral concat
#
SELECT 'a' 'b';
a
ab
ab
SELECT 'a' '';
a
......@@ -76,13 +76,13 @@ SELECT '' '';
NULL
NULL
SELECT '' 'b' 'c';
b
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
a
ac
ac
SELECT 'a' '' '';
a
......@@ -208,3 +208,22 @@ t1 CREATE TABLE `t1` (
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
#
# MDEV-33460 select '123' 'x'; unexpected result
#
SELECT '';
NULL
NULL
SELECT '' 'b' 'c';
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
ac
ac
SELECT 'a' '' '';
a
a
# End of 10.5 test
......@@ -25,3 +25,15 @@ flush tables;
update t1 set a = 2;
show create table t1;
drop table t1;
--echo #
--echo # MDEV-33460 select '123' 'x'; unexpected result
--echo #
SELECT '';
SELECT '' 'b' 'c';
SELECT '' '' 'c';
SELECT 'a' '' 'c';
SELECT 'a' '' '';
--echo # End of 10.5 test
......@@ -8,7 +8,7 @@ select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
select 'hello' 'monty';
hello
hellomonty
hellomonty
select length('\n\t\r\b\0\_\%\\');
length('\n\t\r\b\0\_\%\\')
......
......@@ -894,7 +894,7 @@ show status like '%cost%';
Variable_name Value
Last_query_cost 4.016090
select 'The cost of accessing t1 (dont care if it changes' '^';
The cost of accessing t1 (dont care if it changes
The cost of accessing t1 (dont care if it changes^
The cost of accessing t1 (dont care if it changes^
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
Z
......
......@@ -64,7 +64,7 @@ SET sql_mode=@mode;
# Test litteral concat
#
SELECT 'a' 'b';
a
ab
ab
SELECT 'a' '';
a
......@@ -76,13 +76,13 @@ SELECT '' '';
NULL
NULL
SELECT '' 'b' 'c';
b
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
a
ac
ac
SELECT 'a' '' '';
a
......
......@@ -6943,6 +6943,7 @@ Item_basic_constant *
Item_string::make_string_literal_concat(THD *thd, const LEX_CSTRING *str)
{
append(str->str, (uint32) str->length);
set_name(thd, &str_value);
if (!(collation.repertoire & MY_REPERTOIRE_EXTENDED))
{
// If the string has been pure ASCII so far, check the new part.
......
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