Skip to content

Commit abfb6a6

Browse files
committed
Merge tag 'mysql-5.1.77' into mysql-5.1-telco-7.1
2 parents 245f948 + 557a57f commit abfb6a6

File tree

17 files changed

+303
-80
lines changed

17 files changed

+303
-80
lines changed

client/mysqlslap.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -242,7 +242,7 @@ void print_conclusions_csv(conclusions *con);
242242
void generate_stats(conclusions *con, option_string *eng, stats *sptr);
243243
uint parse_comma(const char *string, uint **range);
244244
uint parse_delimiter(const char *script, statement **stmt, char delm);
245-
uint parse_option(const char *origin, option_string **stmt, char delm);
245+
int parse_option(const char *origin, option_string **stmt, char delm);
246246
static int drop_schema(MYSQL *mysql, const char *db);
247247
uint get_random_string(char *buf);
248248
static statement *build_table_string(void);
@@ -1224,7 +1224,13 @@ get_options(int *argc,char ***argv)
12241224
if (num_int_cols_opt)
12251225
{
12261226
option_string *str;
1227-
parse_option(num_int_cols_opt, &str, ',');
1227+
if(parse_option(num_int_cols_opt, &str, ',') == -1)
1228+
{
1229+
fprintf(stderr, "Invalid value specified for the option "
1230+
"'number-int-cols'\n");
1231+
option_cleanup(str);
1232+
return 1;
1233+
}
12281234
num_int_cols= atoi(str->string);
12291235
if (str->option)
12301236
num_int_cols_index= atoi(str->option);
@@ -1234,7 +1240,13 @@ get_options(int *argc,char ***argv)
12341240
if (num_char_cols_opt)
12351241
{
12361242
option_string *str;
1237-
parse_option(num_char_cols_opt, &str, ',');
1243+
if(parse_option(num_char_cols_opt, &str, ',') == -1)
1244+
{
1245+
fprintf(stderr, "Invalid value specified for the option "
1246+
"'number-char-cols'\n");
1247+
option_cleanup(str);
1248+
return 1;
1249+
}
12381250
num_char_cols= atoi(str->string);
12391251
if (str->option)
12401252
num_char_cols_index= atoi(str->option);
@@ -1470,7 +1482,13 @@ get_options(int *argc,char ***argv)
14701482
printf("Parsing engines to use.\n");
14711483

14721484
if (default_engine)
1473-
parse_option(default_engine, &engine_options, ',');
1485+
{
1486+
if(parse_option(default_engine, &engine_options, ',') == -1)
1487+
{
1488+
fprintf(stderr, "Invalid value specified for the option 'engine'\n");
1489+
return 1;
1490+
}
1491+
}
14741492

14751493
if (tty_password)
14761494
opt_password= get_tty_password(NullS);
@@ -1943,7 +1961,7 @@ pthread_handler_t run_task(void *p)
19431961
DBUG_RETURN(0);
19441962
}
19451963

1946-
uint
1964+
int
19471965
parse_option(const char *origin, option_string **stmt, char delm)
19481966
{
19491967
char *retstr;
@@ -1963,6 +1981,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
19631981
char buffer[HUGE_STRING_LENGTH];
19641982
char *buffer_ptr;
19651983

1984+
/*
1985+
Return an error if the length of the any of the comma seprated value
1986+
exceeds HUGE_STRING_LENGTH.
1987+
*/
1988+
if ((size_t)(retstr - ptr) > HUGE_STRING_LENGTH)
1989+
return -1;
1990+
19661991
count++;
19671992
strncpy(buffer, ptr, (size_t)(retstr - ptr));
19681993
if ((buffer_ptr= strchr(buffer, ':')))
@@ -1995,6 +2020,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
19952020
{
19962021
char *origin_ptr;
19972022

2023+
/*
2024+
Return an error if the length of the any of the comma seprated value
2025+
exceeds HUGE_STRING_LENGTH.
2026+
*/
2027+
if (strlen(ptr) > HUGE_STRING_LENGTH)
2028+
return -1;
2029+
19982030
if ((origin_ptr= strchr(ptr, ':')))
19992031
{
20002032
char *option_ptr;
@@ -2005,13 +2037,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
20052037
option_ptr= (char *)ptr + 1 + tmp->length;
20062038

20072039
/* Move past the : and the first string */
2008-
tmp->option_length= (size_t)((ptr + length) - option_ptr);
2040+
tmp->option_length= strlen(option_ptr);
20092041
tmp->option= my_strndup(option_ptr, tmp->option_length,
20102042
MYF(MY_FAE));
20112043
}
20122044
else
20132045
{
2014-
tmp->length= (size_t)((ptr + length) - ptr);
2046+
tmp->length= strlen(ptr);
20152047
tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE));
20162048
}
20172049

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dnl
4545
dnl When changing the major version number please also check the switch
4646
dnl statement in mysqlbinlog::check_master_version(). You may also need
4747
dnl to update version.c in ndb.
48-
AC_INIT([MySQL Server], [5.1.75-ndb-7.1.37], [], [mysql])
48+
AC_INIT([MySQL Server], [5.1.77-ndb-7.1.37], [], [mysql])
4949

5050
AC_CONFIG_SRCDIR([sql/mysqld.cc])
5151
AC_CANONICAL_SYSTEM

mysql-test/r/subselect.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
7575
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
7676
ERROR HY000: Incorrect usage of PROCEDURE and subquery
7777
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
78-
ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
78+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1))' at line 1
7979
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
8080
ERROR 42S22: Unknown column 'a' in 'field list'
8181
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
Binary file not shown.

mysql-test/suite/sys_vars/r/character_set_connection_func.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ SET @@session.character_set_connection = latin1;
2323
SELECT 'ЁЂЃЄ' AS utf_text;
2424
utf_text
2525
????
26+
Warnings:
27+
Warning 1105 Can't convert the character string from utf8 to latin1: '\xD0\x81\xD0\x82\xD0\x83...'
2628
SET @@session.character_set_connection = utf8;
2729
SELECT 'ЁЂЃЄ' AS utf_text;
2830
utf_text
2931
ЁЂЃЄ
3032
'---now inserting utf8 string with different character_set_connection--'
3133
SET @@session.character_set_connection = ascii;
3234
INSERT INTO t1 VALUES('ЁЂЃЄ');
35+
Warnings:
36+
Warning 1105 Can't convert the character string from utf8 to ascii: '\xD0\x81\xD0\x82\xD0\x83...'
3337
SELECT * FROM t1;
3438
b
3539
????
@@ -39,6 +43,8 @@ SET @@session.character_set_connection = ascii;
3943
SET @@session.character_set_client = latin1;
4044
SET @@session.character_set_results = latin1;
4145
INSERT INTO t1 VALUES('ЁЂЃЄ');
46+
Warnings:
47+
Warning 1105 Can't convert the character string from latin1 to ascii: '\xD0\x81\xD0\x82\xD0\x83...'
4248
SELECT * FROM t1;
4349
b
4450
????????

mysql-test/t/subselect.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SELECT 1 IN (SELECT 1);
3030
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
3131
-- error ER_WRONG_USAGE
3232
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
33-
-- error ER_WRONG_PARAMETERS_TO_PROCEDURE
33+
-- error ER_PARSE_ERROR
3434
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
3535
-- error ER_BAD_FIELD_ERROR
3636
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

sql/item.cc

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -4807,39 +4807,60 @@ bool Item::is_datetime()
48074807
}
48084808

48094809

4810-
String *Item::check_well_formed_result(String *str, bool send_error)
4810+
/**
4811+
Verifies that the input string is well-formed according to its character set.
4812+
@param send_error If true, call my_error if string is not well-formed.
4813+
@param truncate If true, set to null/truncate if not well-formed.
4814+
4815+
@return
4816+
If well-formed: input string.
4817+
If not well-formed:
4818+
if truncate is true and strict mode: NULL pointer and we set this
4819+
Item's value to NULL.
4820+
if truncate is true and not strict mode: input string truncated up to
4821+
last good character.
4822+
if truncate is false: input string is returned.
4823+
*/
4824+
String *Item::check_well_formed_result(String *str,
4825+
bool send_error,
4826+
bool truncate)
48114827
{
48124828
/* Check whether we got a well-formed string */
48134829
CHARSET_INFO *cs= str->charset();
4814-
int well_formed_error;
4815-
uint wlen= cs->cset->well_formed_len(cs,
4816-
str->ptr(), str->ptr() + str->length(),
4817-
str->length(), &well_formed_error);
4818-
if (wlen < str->length())
4830+
4831+
size_t valid_length;
4832+
bool length_error;
4833+
4834+
if (validate_string(cs, str->ptr(), str->length(),
4835+
&valid_length, &length_error))
48194836
{
4837+
const char *str_end= str->ptr() + str->length();
4838+
const char *print_byte= str->ptr() + valid_length;
48204839
THD *thd= current_thd;
48214840
char hexbuf[7];
4822-
enum MYSQL_ERROR::enum_warning_level level;
4823-
uint diff= str->length() - wlen;
4841+
enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN;
4842+
uint diff= str_end - print_byte;
48244843
set_if_smaller(diff, 3);
4825-
octet2hex(hexbuf, str->ptr() + wlen, diff);
4826-
if (send_error)
4844+
octet2hex(hexbuf, print_byte, diff);
4845+
if (send_error && length_error)
48274846
{
48284847
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
48294848
cs->csname, hexbuf);
48304849
return 0;
48314850
}
4832-
if ((thd->variables.sql_mode &
4833-
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
4851+
if (truncate && length_error)
48344852
{
4835-
level= MYSQL_ERROR::WARN_LEVEL_ERROR;
4836-
null_value= 1;
4837-
str= 0;
4838-
}
4839-
else
4840-
{
4841-
level= MYSQL_ERROR::WARN_LEVEL_WARN;
4842-
str->length(wlen);
4853+
if ((thd->variables.sql_mode &
4854+
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
4855+
{
4856+
level= MYSQL_ERROR::WARN_LEVEL_ERROR;
4857+
null_value= 1;
4858+
str= 0;
4859+
}
4860+
else
4861+
{
4862+
str->length(valid_length);
4863+
}
48434864
}
48444865
push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING,
48454866
ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);

sql/item.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,9 @@ class Item {
10541054
bool is_datetime();
10551055
virtual Field::geometry_type get_geometry_type() const
10561056
{ return Field::GEOM_GEOMETRY; };
1057-
String *check_well_formed_result(String *str, bool send_error= 0);
1057+
String *check_well_formed_result(String *str,
1058+
bool send_error,
1059+
bool truncate);
10581060
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
10591061

10601062
/**
@@ -1931,6 +1933,11 @@ class Item_string :public Item_basic_constant
19311933
decimals=NOT_FIXED_DEC;
19321934
// it is constant => can be used without fix_fields (and frequently used)
19331935
fixed= 1;
1936+
/*
1937+
Check if the string has any character that can't be
1938+
interpreted using the relevant charset.
1939+
*/
1940+
check_well_formed_result(&str_value, false, false);
19341941
}
19351942
/* Just create an item and do not fill string representation */
19361943
Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)

sql/item_strfunc.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -2373,7 +2373,9 @@ String *Item_func_char::val_str(String *str)
23732373
}
23742374
}
23752375
str->realloc(str->length()); // Add end 0 (for Purify)
2376-
return check_well_formed_result(str);
2376+
return check_well_formed_result(str,
2377+
false, // send warning
2378+
true); // truncate
23772379
}
23782380

23792381

@@ -2773,7 +2775,9 @@ String *Item_func_conv_charset::val_str(String *str)
27732775
}
27742776
null_value= tmp_value.copy(arg->ptr(), arg->length(), arg->charset(),
27752777
conv_charset, &dummy_errors);
2776-
return null_value ? 0 : check_well_formed_result(&tmp_value);
2778+
return null_value ? 0 : check_well_formed_result(&tmp_value,
2779+
false, // send warning
2780+
true); // truncate
27772781
}
27782782

27792783
void Item_func_conv_charset::fix_length_and_dec()

sql/opt_range.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -3150,10 +3150,19 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
31503150
key_tree->max_value,
31513151
key_tree->min_flag | key_tree->max_flag,
31523152
&subpart_iter);
3153-
DBUG_ASSERT(res); /* We can't get "no satisfying subpartitions" */
3153+
if (res == 0)
3154+
{
3155+
/*
3156+
The only case where we can get "no satisfying subpartitions"
3157+
returned from the above call is when an error has occurred.
3158+
*/
3159+
DBUG_ASSERT(ppar->range_param.thd->is_error());
3160+
return 0;
3161+
}
3162+
31543163
if (res == -1)
31553164
return -1; /* all subpartitions satisfy */
3156-
3165+
31573166
uint32 subpart_id;
31583167
bitmap_clear_all(&ppar->subparts_bitmap);
31593168
while ((subpart_id= subpart_iter.get_next(&subpart_iter)) !=

0 commit comments

Comments
 (0)