Skip to content

Commit 6346f64

Browse files
committed
merge
2 parents d8e1e18 + 95ddb0f commit 6346f64

25 files changed

+307
-602
lines changed

client/mysqltest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8076,6 +8076,7 @@ void free_re(void)
80768076
my_regfree(&sp_re);
80778077
my_regfree(&view_re);
80788078
my_regfree(&opt_trace_re);
8079+
my_regfree(&explain_re);
80798080
my_regex_end();
80808081
}
80818082

extra/perror.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static my_bool verbose;
3434

3535
#include "../include/my_base.h"
3636
#include "../mysys/my_handler_errors.h"
37-
// #include "../include/my_compare.h"
3837

3938
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
4039
static my_bool ndb_code;

mysql-test/r/ctype_utf16.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second));
11311131
space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second))
11321132
NULL
11331133
Warnings:
1134-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
1134+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
11351135
#
11361136
# End of 5.5 tests
11371137
#

mysql-test/r/func_str.result

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ explain extended select concat('*',space(5),'*');
845845
id select_type table type possible_keys key key_len ref rows filtered Extra
846846
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
847847
Warnings:
848-
Note 1003 /* select#1 */ select concat('*',repeat(' ',5),'*') AS `concat('*',space(5),'*')`
848+
Note 1003 /* select#1 */ select concat('*',space(5),'*') AS `concat('*',space(5),'*')`
849849
explain extended select reverse('abc');
850850
id select_type table type possible_keys key key_len ref rows filtered Extra
851851
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -2084,23 +2084,23 @@ select space(4294967295);
20842084
space(4294967295)
20852085
NULL
20862086
Warnings:
2087-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2087+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
20882088
select space(-4294967296);
20892089
space(-4294967296)
20902090

20912091
select space(4294967296);
20922092
space(4294967296)
20932093
NULL
20942094
Warnings:
2095-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2095+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
20962096
select space(-4294967297);
20972097
space(-4294967297)
20982098

20992099
select space(4294967297);
21002100
space(4294967297)
21012101
NULL
21022102
Warnings:
2103-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2103+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
21042104
select space(-18446744073709551615);
21052105
space(-18446744073709551615)
21062106

@@ -2111,7 +2111,7 @@ select space(18446744073709551615);
21112111
space(18446744073709551615)
21122112
NULL
21132113
Warnings:
2114-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2114+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
21152115
select space(-18446744073709551616);
21162116
space(-18446744073709551616)
21172117

@@ -2124,7 +2124,7 @@ NULL
21242124
Warnings:
21252125
Warning 1292 Truncated incorrect DECIMAL value: ''
21262126
Warning 1292 Truncated incorrect DECIMAL value: ''
2127-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2127+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
21282128
select space(-18446744073709551617);
21292129
space(-18446744073709551617)
21302130

@@ -2137,7 +2137,7 @@ NULL
21372137
Warnings:
21382138
Warning 1292 Truncated incorrect DECIMAL value: ''
21392139
Warning 1292 Truncated incorrect DECIMAL value: ''
2140-
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2140+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
21412141
select rpad('hello', -1, '1');
21422142
rpad('hello', -1, '1')
21432143
NULL
@@ -4407,6 +4407,20 @@ NULL
44074407
Warnings:
44084408
Warning 1301 Result of export_set() was larger than max_allowed_packet (1073741824) - truncated
44094409
SET @@global.max_allowed_packet:= @tmp_max;
4410+
SELECT SPACE(@@global.max_allowed_packet*2);
4411+
SPACE(@@global.max_allowed_packet*2)
4412+
NULL
4413+
Warnings:
4414+
Warning 1301 Result of space() was larger than max_allowed_packet (1048576) - truncated
4415+
SET NAMES latin1;
4416+
PREPARE stmt FROM "SELECT COLLATION(space(2))";
4417+
EXECUTE stmt;
4418+
COLLATION(space(2))
4419+
latin1_swedish_ci
4420+
SET NAMES latin2;
4421+
EXECUTE stmt;
4422+
COLLATION(space(2))
4423+
latin2_general_ci
44104424
#
44114425
# End of 5.6 tests
44124426
#

mysql-test/t/func_str.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,23 @@ SET @@global.max_allowed_packet:= @tmp_max;
16261626
--disconnect newconn
16271627

16281628

1629+
#
1630+
# BUG #12735829: SPACE() FUNCTION WARNING REFERS TO REPEAT() IN ER_WARN_ALLOWED_PACKET_OVERFLOWED
1631+
#
1632+
1633+
SELECT SPACE(@@global.max_allowed_packet*2);
1634+
1635+
1636+
#
1637+
# BUG #11746123-23637: CHARSET AND COLLATION OF THE FUNCTION SPACE()
1638+
#
1639+
1640+
SET NAMES latin1;
1641+
PREPARE stmt FROM "SELECT COLLATION(space(2))";
1642+
EXECUTE stmt;
1643+
SET NAMES latin2;
1644+
EXECUTE stmt;
1645+
16291646
--echo #
16301647
--echo # End of 5.6 tests
16311648
--echo #

plugin/auth/qa_auth_interface.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *inf
6161
err= CR_ERROR;
6262
if (info->auth_string_length != 14)
6363
err= CR_ERROR;
64-
/* To be set by the plugin */
65-
// if (strcmp(info->authenticated_as, "qa_test_1_user"))
66-
// err= CR_ERROR;
67-
/* To be set by the plugin */
68-
// if (strcmp(info->external_user, ""))
69-
// err= CR_ERROR;
64+
/*
65+
To be set by the plugin
66+
if (strcmp(info->authenticated_as, "qa_test_1_user"))
67+
err= CR_ERROR;
68+
if (strcmp(info->external_user, ""))
69+
err= CR_ERROR;
70+
*/
7071
if (info->password_used != PASSWORD_USED_YES)
7172
err= CR_ERROR;
7273
if (strcmp(info->host_or_ip, "localhost"))
@@ -87,9 +88,11 @@ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *inf
8788
strcpy(info->authenticated_as, "authenticated_as");
8889
/* Assign with an external account, effect on @@local.EXTERNAL_USER */
8990
strcpy(info->external_user, "externaluser");
90-
/* Overwriting will cause a core dump */
91-
// strcpy(info->host_or_ip, "host_or_ip");
92-
// info->host_or_ip_length= 10;
91+
/*
92+
Overwriting will cause a core dump
93+
strcpy(info->host_or_ip, "host_or_ip");
94+
info->host_or_ip_length= 10;
95+
*/
9396
}
9497
/* Invalid, means too high values for length */
9598
else if (strcmp(info->user_name, "qa_test_3_user")== 0)
@@ -126,9 +129,11 @@ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *inf
126129
strcpy(info->authenticated_as, "");
127130
/* This assignment has no effect.*/
128131
strcpy(info->external_user, "");
129-
/* Overwriting will cause a core dump */
130-
// strcpy(info->host_or_ip, "");
131-
// info->host_or_ip_length= 0;
132+
/*
133+
Overwriting will cause a core dump
134+
strcpy(info->host_or_ip, "");
135+
info->host_or_ip_length= 0;
136+
*/
132137
}
133138
/* Set to 'root' */
134139
else if (strcmp(info->user_name, "qa_test_6_user")== 0)

sql/item_create.cc

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4909,26 +4909,7 @@ Create_func_space Create_func_space::s_singleton;
49094909
Item*
49104910
Create_func_space::create(THD *thd, Item *arg1)
49114911
{
4912-
/**
4913-
TODO: Fix Bug#23637
4914-
The parsed item tree should not depend on
4915-
<code>thd->variables.collation_connection</code>.
4916-
*/
4917-
const CHARSET_INFO *cs= thd->variables.collation_connection;
4918-
Item *sp;
4919-
4920-
if (cs->mbminlen > 1)
4921-
{
4922-
uint dummy_errors;
4923-
sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
4924-
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
4925-
}
4926-
else
4927-
{
4928-
sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
4929-
}
4930-
4931-
return new (thd->mem_root) Item_func_repeat(sp, arg1);
4912+
return new (thd->mem_root) Item_func_space(arg1);
49324913
}
49334914

49344915

sql/item_strfunc.cc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,6 +2817,76 @@ String *Item_func_repeat::val_str(String *str)
28172817
}
28182818

28192819

2820+
2821+
void Item_func_space::fix_length_and_dec()
2822+
{
2823+
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2824+
if (args[0]->const_item())
2825+
{
2826+
/* must be longlong to avoid truncation */
2827+
longlong count= args[0]->val_int();
2828+
if (args[0]->null_value)
2829+
goto end;
2830+
/*
2831+
Assumes that the maximum length of a String is < INT_MAX32.
2832+
Set here so that rest of code sees out-of-bound value as such.
2833+
*/
2834+
if (count > INT_MAX32)
2835+
count= INT_MAX32;
2836+
fix_char_length_ulonglong(count);
2837+
return;
2838+
}
2839+
2840+
end:
2841+
max_length= MAX_BLOB_WIDTH;
2842+
maybe_null= 1;
2843+
}
2844+
2845+
2846+
String *Item_func_space::val_str(String *str)
2847+
{
2848+
uint tot_length;
2849+
longlong count= args[0]->val_int();
2850+
const CHARSET_INFO *cs= collation.collation;
2851+
2852+
if (args[0]->null_value)
2853+
goto err; // string and/or delim are null
2854+
null_value= 0;
2855+
2856+
if (count <= 0 && (count == 0 || !args[0]->unsigned_flag))
2857+
return make_empty_result();
2858+
/*
2859+
Assumes that the maximum length of a String is < INT_MAX32.
2860+
Bounds check on count: If this is triggered, we will error.
2861+
*/
2862+
if ((ulonglong) count > INT_MAX32)
2863+
count= INT_MAX32;
2864+
2865+
// Safe length check
2866+
tot_length= (uint) count * cs->mbminlen;
2867+
if (tot_length > current_thd->variables.max_allowed_packet)
2868+
{
2869+
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
2870+
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
2871+
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
2872+
func_name(),
2873+
current_thd->variables.max_allowed_packet);
2874+
goto err;
2875+
}
2876+
2877+
if (str->alloc(tot_length))
2878+
goto err;
2879+
str->length(tot_length);
2880+
str->set_charset(cs);
2881+
cs->cset->fill(cs, (char*) str->ptr(), tot_length, ' ');
2882+
return str;
2883+
2884+
err:
2885+
null_value= 1;
2886+
return 0;
2887+
}
2888+
2889+
28202890
void Item_func_rpad::fix_length_and_dec()
28212891
{
28222892
// Handle character set for args[0] and args[2].

sql/item_strfunc.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,16 @@ class Item_func_repeat :public Item_str_func
617617
};
618618

619619

620+
class Item_func_space :public Item_str_func
621+
{
622+
public:
623+
Item_func_space(Item *arg1):Item_str_func(arg1) {}
624+
String *val_str(String *);
625+
void fix_length_and_dec();
626+
const char *func_name() const { return "space"; }
627+
};
628+
629+
620630
class Item_func_rpad :public Item_str_func
621631
{
622632
String tmp_value, rpad_str;

sql/share/errmsg-utf8.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5130,11 +5130,11 @@ ER_SP_BADSTATEMENT 0A000
51305130
eng "%s is not allowed in stored procedures"
51315131
ger "%s ist in gespeicherten Prozeduren nicht erlaubt"
51325132
ER_UPDATE_LOG_DEPRECATED_IGNORED 42000
5133-
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored. This option will be removed in MySQL 5.6."
5134-
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wird ignoriert. Diese Option wird in MySQL 5.6 entfernt."
5133+
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored."
5134+
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wird ignoriert."
51355135
ER_UPDATE_LOG_DEPRECATED_TRANSLATED 42000
5136-
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN. This option will be removed in MySQL 5.6."
5137-
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wurde in SET SQL_LOG_BIN übersetzt. Diese Option wird in MySQL 5.6 entfernt."
5136+
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
5137+
ger "Das Update-Log ist veraltet und wurde durch das Binär-Log ersetzt. SET SQL_LOG_UPDATE wurde in SET SQL_LOG_BIN übersetzt."
51385138
ER_QUERY_INTERRUPTED 70100
51395139
eng "Query execution was interrupted"
51405140
ger "Ausführung der Abfrage wurde unterbrochen"

0 commit comments

Comments
 (0)