mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-12143 sql_mode=ORACLE: make the CONCAT function ignore NULL arguments
This commit is contained in:
@ -4,6 +4,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select 'a' || 'b' || 'c' AS "'a'||'b'||'c'"
|
Note 1003 select 'a' || 'b' || 'c' AS "'a'||'b'||'c'"
|
||||||
|
EXPLAIN EXTENDED SELECT CONCAT('a'||'b'||'c');
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
|
Warnings:
|
||||||
|
Note 1003 select 'a' || 'b' || 'c' AS "CONCAT('a'||'b'||'c')"
|
||||||
SELECT '' || '';
|
SELECT '' || '';
|
||||||
'' || ''
|
'' || ''
|
||||||
|
|
||||||
@ -169,4 +174,33 @@ NULL NULL
|
|||||||
2 ab
|
2 ab
|
||||||
2 ab
|
2 ab
|
||||||
3 abc
|
3 abc
|
||||||
|
SELECT LENGTH(CONCAT(a||b||c)), CONCAT(a||b||c) FROM t1 ORDER BY a,b,c;
|
||||||
|
LENGTH(CONCAT(a||b||c)) CONCAT(a||b||c)
|
||||||
|
NULL NULL
|
||||||
|
0
|
||||||
|
1 c
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1 c
|
||||||
|
1 b
|
||||||
|
1 b
|
||||||
|
2 bc
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1 c
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1 c
|
||||||
|
1 b
|
||||||
|
1 b
|
||||||
|
2 bc
|
||||||
|
1 a
|
||||||
|
1 a
|
||||||
|
2 ac
|
||||||
|
1 a
|
||||||
|
1 a
|
||||||
|
2 ac
|
||||||
|
2 ab
|
||||||
|
2 ab
|
||||||
|
3 abc
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
SET sql_mode=ORACLE;
|
SET sql_mode=ORACLE;
|
||||||
|
|
||||||
EXPLAIN EXTENDED SELECT 'a'||'b'||'c';
|
EXPLAIN EXTENDED SELECT 'a'||'b'||'c';
|
||||||
|
EXPLAIN EXTENDED SELECT CONCAT('a'||'b'||'c');
|
||||||
|
|
||||||
SELECT '' || '';
|
SELECT '' || '';
|
||||||
SELECT '' || 'b';
|
SELECT '' || 'b';
|
||||||
@ -79,5 +80,6 @@ INSERT INTO t1 VALUES (NULL, NULL, 'c');
|
|||||||
INSERT INTO t1 VALUES (NULL, NULL, NULL);
|
INSERT INTO t1 VALUES (NULL, NULL, NULL);
|
||||||
|
|
||||||
SELECT LENGTH(a||b||c), a||b||c FROM t1 ORDER BY a,b,c;
|
SELECT LENGTH(a||b||c), a||b||c FROM t1 ORDER BY a,b,c;
|
||||||
|
SELECT LENGTH(CONCAT(a||b||c)), CONCAT(a||b||c) FROM t1 ORDER BY a,b,c;
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -3857,7 +3857,9 @@ Create_func_concat::create_native(THD *thd, LEX_STRING name,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new (thd->mem_root) Item_func_concat(thd, *item_list);
|
return thd->variables.sql_mode & MODE_ORACLE ?
|
||||||
|
new (thd->mem_root) Item_func_concat_operator_oracle(thd, *item_list) :
|
||||||
|
new (thd->mem_root) Item_func_concat(thd, *item_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
Create_func_decode_histogram Create_func_decode_histogram::s_singleton;
|
Create_func_decode_histogram Create_func_decode_histogram::s_singleton;
|
||||||
|
@ -297,6 +297,9 @@ public:
|
|||||||
class Item_func_concat_operator_oracle :public Item_func_concat
|
class Item_func_concat_operator_oracle :public Item_func_concat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Item_func_concat_operator_oracle(THD *thd, List<Item> &list)
|
||||||
|
:Item_func_concat(thd, list)
|
||||||
|
{ }
|
||||||
Item_func_concat_operator_oracle(THD *thd, Item *a, Item *b)
|
Item_func_concat_operator_oracle(THD *thd, Item *a, Item *b)
|
||||||
:Item_func_concat(thd, a, b)
|
:Item_func_concat(thd, a, b)
|
||||||
{ }
|
{ }
|
||||||
|
Reference in New Issue
Block a user