Commit 732cfaba authored by Alexander Barkov's avatar Alexander Barkov

Merge branch 'halfspawn-bb-10.2-ext' into bb-10.2-ext

parents 5b034f1c 87d95274
...@@ -4876,5 +4876,16 @@ IF(a<' ',HEX(a),a) ...@@ -4876,5 +4876,16 @@ IF(a<' ',HEX(a),a)
a a
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-12783 sql_mode=ORACLE: Functions LENGTH() and LENGTHB()
#
SELECT LENGTHB('a'), LENGTHB(_utf8 0xC39F), LENGTHB(123), LENGTH(null);
LENGTHB('a') LENGTHB(_utf8 0xC39F) LENGTHB(123) LENGTH(null)
1 2 3 NULL
EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a');
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 octet_length('a') AS `LENGTH('a')`,octet_length('a') AS `LENGTHB('a')`
#
# End of 10.3 tests # End of 10.3 tests
# #
SET sql_mode=ORACLE;
#
# MDEV-12783 sql_mode=ORACLE: Functions LENGTH() and LENGTHB()
#
SELECT LENGTH(null), LENGTH('a'), LENGTH(123);
LENGTH(null) LENGTH('a') LENGTH(123)
NULL 1 3
SELECT LENGTHB(null), LENGTHB('a'), LENGTHB(123);
LENGTHB(null) LENGTHB('a') LENGTHB(123)
NULL 1 3
SELECT LENGTH(_utf8 0xC39F), LENGTH(CHAR(14844588 USING utf8));
LENGTH(_utf8 0xC39F) LENGTH(CHAR(14844588 USING utf8))
1 1
SELECT LENGTHB(_utf8 0xC39F), LENGTHB(CHAR(14844588 USING utf8));
LENGTHB(_utf8 0xC39F) LENGTHB(CHAR(14844588 USING utf8))
2 3
EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a');
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 char_length('a') AS "LENGTH('a')",octet_length('a') AS "LENGTHB('a')"
SET sql_mode=ORACLE;
--echo #
--echo # MDEV-12783 sql_mode=ORACLE: Functions LENGTH() and LENGTHB()
--echo #
#
# Testing LENGTH / LENGTHB
#
# LENGTH : return the length of char
# LENGTHB : return the length of byte
SELECT LENGTH(null), LENGTH('a'), LENGTH(123);
SELECT LENGTHB(null), LENGTHB('a'), LENGTHB(123);
SELECT LENGTH(_utf8 0xC39F), LENGTH(CHAR(14844588 USING utf8));
SELECT LENGTHB(_utf8 0xC39F), LENGTHB(CHAR(14844588 USING utf8));
EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a');
...@@ -1883,6 +1883,11 @@ INSERT INTO t1 VALUES (0x09),('a'); ...@@ -1883,6 +1883,11 @@ INSERT INTO t1 VALUES (0x09),('a');
SELECT IF(a<' ',HEX(a),a) FROM t1 ORDER BY a; SELECT IF(a<' ',HEX(a),a) FROM t1 ORDER BY a;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-12783 sql_mode=ORACLE: Functions LENGTH() and LENGTHB()
--echo #
SELECT LENGTHB('a'), LENGTHB(_utf8 0xC39F), LENGTHB(123), LENGTH(null);
EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a');
--echo # --echo #
--echo # End of 10.3 tests --echo # End of 10.3 tests
......
...@@ -5684,11 +5684,9 @@ Create_func_length Create_func_length::s_singleton; ...@@ -5684,11 +5684,9 @@ Create_func_length Create_func_length::s_singleton;
Item* Item*
Create_func_length::create_1_arg(THD *thd, Item *arg1) Create_func_length::create_1_arg(THD *thd, Item *arg1)
{ {
#if 0 // Not yet
if (thd->variables.sql_mode & MODE_ORACLE) if (thd->variables.sql_mode & MODE_ORACLE)
return new (thd->mem_root) Item_func_char_length(thd, arg1); return new (thd->mem_root) Item_func_char_length(thd, arg1);
else else
#endif
return new (thd->mem_root) Item_func_octet_length(thd, arg1); return new (thd->mem_root) Item_func_octet_length(thd, arg1);
} }
...@@ -6978,6 +6976,7 @@ static Native_func_registry func_array[] = ...@@ -6978,6 +6976,7 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)}, { { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
{ { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)}, { { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
{ { C_STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)}, { { C_STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)},
{ { C_STRING_WITH_LEN("LENGTHB") }, BUILDER(Create_func_octet_length)},
#ifndef DBUG_OFF #ifndef DBUG_OFF
{ { C_STRING_WITH_LEN("LIKE_RANGE_MIN") }, BUILDER(Create_func_like_range_min)}, { { C_STRING_WITH_LEN("LIKE_RANGE_MIN") }, BUILDER(Create_func_like_range_min)},
{ { C_STRING_WITH_LEN("LIKE_RANGE_MAX") }, BUILDER(Create_func_like_range_max)}, { { C_STRING_WITH_LEN("LIKE_RANGE_MAX") }, BUILDER(Create_func_like_range_max)},
......
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