summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am36
-rw-r--r--client/mysqlcheck.c52
-rw-r--r--client/mysqldump.c8
-rw-r--r--client/mysqltest.c2
-rw-r--r--include/my_base.h2
-rw-r--r--include/my_sys.h6
-rw-r--r--include/mysql.h10
-rw-r--r--include/mysql_h.ic468
-rwxr-xr-xlibmysql/CMakeLists.txt2
-rw-r--r--libmysql/Makefile.shared2
-rw-r--r--libmysql/libmysql.c72
-rw-r--r--libmysql/libmysql.def1
-rw-r--r--libmysqld/libmysqld.def1
-rw-r--r--myisam/ft_boolean_search.c4
-rw-r--r--myisam/ft_nlq_search.c3
-rw-r--r--myisam/myisampack.c2
-rw-r--r--myisam/sort.c12
-rw-r--r--mysql-test/include/ctype_common.inc2
-rw-r--r--mysql-test/lib/mtr_cases.pl10
-rwxr-xr-xmysql-test/mysql-test-run.pl78
-rw-r--r--mysql-test/r/case.result20
-rw-r--r--mysql-test/r/ctype_big5.result4
-rwxr-xr-xmysql-test/r/ctype_cp932.result74
-rw-r--r--mysql-test/r/ctype_euckr.result4
-rw-r--r--mysql-test/r/ctype_gb2312.result4
-rw-r--r--mysql-test/r/ctype_gbk.result4
-rw-r--r--mysql-test/r/ctype_uca.result4
-rw-r--r--mysql-test/r/ctype_ucs.result8
-rw-r--r--mysql-test/r/delayed.result5
-rw-r--r--mysql-test/r/flush.result17
-rw-r--r--mysql-test/r/func_misc.result13
-rw-r--r--mysql-test/r/grant.result2
-rw-r--r--mysql-test/r/innodb_mysql.result15
-rw-r--r--mysql-test/r/insert.result134
-rw-r--r--mysql-test/r/key.result44
-rw-r--r--mysql-test/r/lock_multi.result11
-rw-r--r--mysql-test/r/mysqlcheck.result7
-rw-r--r--mysql-test/r/ps.result5
-rw-r--r--mysql-test/r/type_newdecimal.result20
-rw-r--r--mysql-test/t/case.test21
-rw-r--r--mysql-test/t/ctype_cp932.test4
-rw-r--r--mysql-test/t/ctype_ucs.test12
-rw-r--r--mysql-test/t/delayed.test9
-rw-r--r--mysql-test/t/flush.test31
-rw-r--r--mysql-test/t/func_misc.test20
-rw-r--r--mysql-test/t/grant.test2
-rw-r--r--mysql-test/t/innodb_mysql.test9
-rw-r--r--mysql-test/t/insert.test101
-rw-r--r--mysql-test/t/key.test18
-rw-r--r--mysql-test/t/lock_multi.test32
-rw-r--r--mysql-test/t/merge.test2
-rw-r--r--mysql-test/t/mysqlcheck.test11
-rw-r--r--mysql-test/t/ps.test10
-rw-r--r--mysql-test/t/type_float.test5
-rw-r--r--mysql-test/t/type_newdecimal.test21
-rw-r--r--mysys/mf_keycache.c2
-rw-r--r--mysys/mf_qsort.c4
-rw-r--r--mysys/mf_sort.c2
-rw-r--r--mysys/my_lib.c6
-rw-r--r--mysys/my_write.c4
-rw-r--r--mysys/queues.c4
-rw-r--r--scripts/mysql_install_db.sh66
-rw-r--r--scripts/mysql_system_tables_data.sql11
-rw-r--r--sql-common/client.c5
-rw-r--r--sql/examples/ha_tina.cc2
-rw-r--r--sql/field.cc80
-rw-r--r--sql/ha_myisam.cc2
-rw-r--r--sql/item.cc12
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_cmpfunc.cc38
-rw-r--r--sql/item_cmpfunc.h4
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_strfunc.h7
-rw-r--r--sql/item_timefunc.cc48
-rw-r--r--sql/mysqld.cc14
-rw-r--r--sql/opt_range.cc8
-rw-r--r--sql/records.cc3
-rw-r--r--sql/set_var.cc22
-rw-r--r--sql/set_var.h1
-rw-r--r--sql/sp_head.cc38
-rw-r--r--sql/sp_head.h6
-rw-r--r--sql/sql_acl.cc20
-rw-r--r--sql/sql_array.h2
-rw-r--r--sql/sql_base.cc3
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_lex.h5
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc56
-rw-r--r--sql/sql_table.cc30
-rw-r--r--sql/sql_yacc.yy151
-rw-r--r--sql/structs.h2
-rw-r--r--sql/unireg.cc2
-rw-r--r--strings/ctype-cp932.c4
-rw-r--r--strings/ctype-simple.c38
-rw-r--r--strings/ctype-ucs2.c24
-rw-r--r--strings/int2str.c16
-rw-r--r--strings/longlong2str.c32
99 files changed, 1633 insertions, 634 deletions
diff --git a/Makefile.am b/Makefile.am
index c1bdbb22e8e..eb837b1fdd4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,7 +102,7 @@ dist-hook:
rm -rf `find $(distdir) -type d -name SCCS -print`
rm -f `find $(distdir) -type l -print`
mkdir -p $(distdir)/win
- scripts/mysql_install_db --no-defaults --windows \
+ scripts/mysql_install_db --no-defaults --cross-bootstrap \
--basedir=$(top_builddir) \
--datadir=$(distdir)/win/data \
--srcdir=$(top_srcdir)
@@ -127,11 +127,11 @@ tags:
test-ps:
cd mysql-test ; \
- @PERL@ ./mysql-test-run.pl $(force) $(mem) --ps-protocol
+ @PERL@ ./mysql-test-run.pl $(force) $(mem) --ps-protocol
test-ns:
cd mysql-test ; \
- @PERL@ ./mysql-test-run.pl $(force) $(mem)
+ @PERL@ ./mysql-test-run.pl $(force) $(mem)
test: test-ns test-ps
@@ -150,25 +150,25 @@ test-force-mem:
test-bt:
-cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --force --comment=normal --report-features
+ @PERL@ ./mysql-test-run.pl --force --comment=normal --report-features
-cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --force --comment=ps --ps-protocol
+ @PERL@ ./mysql-test-run.pl --force --comment=ps --ps-protocol
-cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1
+ @PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1
-cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2
+ @PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2
-if [ -d mysql-test/suite/nist ] ; then \
- cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \
+ cd mysql-test ; MTR_BUILD_THREAD=auto \
+ @PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \
fi
-if [ -d mysql-test/suite/nist ] ; then \
- cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --comment=NIST+ps --force --suite=nist --ps-protocol ; \
+ cd mysql-test ; MTR_BUILD_THREAD=auto \
+ @PERL@ ./mysql-test-run.pl --comment=NIST+ps --force --suite=nist --ps-protocol ; \
fi
test-bt-debug:
-cd mysql-test ; MTR_BUILD_THREAD=auto \
- @PERL@ ./mysql-test-run.pl --force --comment=debug --report-features
+ @PERL@ ./mysql-test-run.pl --force --comment=debug --report-features
# Keep these for a while
test-pl: test
@@ -179,15 +179,15 @@ test-force-full-pl: test-force-full
test-ext-funcs:
cd mysql-test ; \
- @PERL@ ./mysql-test-run.pl --force --suite=funcs_1 ; \
- @PERL@ ./mysql-test-run.pl --force --suite=funcs_2
+ @PERL@ ./mysql-test-run.pl --force --suite=funcs_1 ; \
+ @PERL@ ./mysql-test-run.pl --force --suite=funcs_2
test-ext: test-ext-funcs
test-fast:
cd mysql-test ; \
- @PERL@ ./mysql-test-run.pl $(subset) --force --skip-ndb --skip-innodb --skip-im --skip-rpl ; \
- @PERL@ ./mysql-test-run.pl $(subset) --force --suite=funcs_1 --do-test=myisam
+ @PERL@ ./mysql-test-run.pl $(subset) --force --skip-ndb --skip-innodb --skip-im --skip-rpl ; \
+ @PERL@ ./mysql-test-run.pl $(subset) --force --suite=funcs_1 --do-test=myisam
test-fast-view:
$(MAKE) subset=--view-protocol test-fast
@@ -200,8 +200,8 @@ test-fast-prepare:
test-full-qa:
$(MAKE) force=--force test-pl \
- test-ext test-fast-view \
- test-fast-cursor
+ test-ext test-fast-view \
+ test-fast-cursor
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 8205a83fdf4..3b504eb50b0 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -186,6 +186,7 @@ static void dbDisconnect(char *host);
static void DBerror(MYSQL *mysql, const char *when);
static void safe_exit(int error);
static void print_result();
+static uint fixed_name_length(const char *name);
static char *fix_table_name(char *dest, char *src);
int what_to_do = 0;
@@ -409,14 +410,14 @@ static int process_selected_tables(char *db, char **table_names, int tables)
{
/*
We need table list in form `a`, `b`, `c`
- that's why we need 4 more chars added to to each table name
+ that's why we need 2 more chars added to to each table name
space is for more readable output in logs and in case of error
*/
char *table_names_comma_sep, *end;
int i, tot_length = 0;
for (i = 0; i < tables; i++)
- tot_length += strlen(*(table_names + i)) + 4;
+ tot_length+= fixed_name_length(*(table_names + i)) + 2;
if (!(table_names_comma_sep = (char *)
my_malloc((sizeof(char) * tot_length) + 4, MYF(MY_WME))))
@@ -434,23 +435,46 @@ static int process_selected_tables(char *db, char **table_names, int tables)
}
else
for (; tables > 0; tables--, table_names++)
- handle_request_for_tables(*table_names, strlen(*table_names));
+ handle_request_for_tables(*table_names, fixed_name_length(*table_names));
return 0;
} /* process_selected_tables */
-static char *fix_table_name(char *dest, char *src)
+static uint fixed_name_length(const char *name)
{
- char *db_sep;
+ const char *p;
+ uint extra_length= 2; /* count the first/last backticks */
+
+ for (p= name; *p; p++)
+ {
+ if (*p == '`')
+ extra_length++;
+ else if (*p == '.')
+ extra_length+= 2;
+ }
+ return (p - name) + extra_length;
+}
+
+static char *fix_table_name(char *dest, char *src)
+{
*dest++= '`';
- if ((db_sep= strchr(src, '.')))
+ for (; *src; src++)
{
- dest= strmake(dest, src, (uint) (db_sep - src));
- dest= strmov(dest, "`.`");
- src= db_sep + 1;
+ switch (*src) {
+ case '.': /* add backticks around '.' */
+ *dest++= '`';
+ *dest++= '.';
+ *dest++= '`';
+ break;
+ case '`': /* escape backtick character */
+ *dest++= '`';
+ /* fall through */
+ default:
+ *dest++= *src;
+ }
}
- dest= strxmov(dest, src, "`", NullS);
+ *dest++= '`';
return dest;
}
@@ -471,7 +495,7 @@ static int process_all_tables_in_db(char *database)
{
/*
We need table list in form `a`, `b`, `c`
- that's why we need 4 more chars added to to each table name
+ that's why we need 2 more chars added to to each table name
space is for more readable output in logs and in case of error
*/
@@ -479,7 +503,7 @@ static int process_all_tables_in_db(char *database)
uint tot_length = 0;
while ((row = mysql_fetch_row(res)))
- tot_length += strlen(row[0]) + 4;
+ tot_length+= fixed_name_length(row[0]) + 2;
mysql_data_seek(res, 0);
if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
@@ -507,7 +531,7 @@ static int process_all_tables_in_db(char *database)
/* Skip tables with an engine of NULL (probably a view). */
if (row[1])
{
- handle_request_for_tables(row[0], strlen(row[0]));
+ handle_request_for_tables(row[0], fixed_name_length(row[0]));
}
}
mysql_free_result(res);
@@ -741,7 +765,7 @@ int main(int argc, char **argv)
for (i = 0; i < tables4repair.elements ; i++)
{
char *name= (char*) dynamic_array_ptr(&tables4repair, i);
- handle_request_for_tables(name, strlen(name));
+ handle_request_for_tables(name, fixed_name_length(name));
}
}
end:
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 48145019446..980013d539a 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -404,8 +404,12 @@ static struct my_option my_long_options[] =
"Creates a consistent snapshot by dumping all tables in a single "
"transaction. Works ONLY for tables stored in storage engines which "
"support multiversioning (currently only InnoDB does); the dump is NOT "
- "guaranteed to be consistent for other storage engines. Option "
- "automatically turns off --lock-tables.",
+ "guaranteed to be consistent for other storage engines. "
+ "While a --single-transaction dump is in process, to ensure a valid "
+ "dump file (correct table contents and binary log position), no other "
+ "connection should use the following statements: ALTER TABLE, DROP "
+ "TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not "
+ "isolated from them. Option automatically turns off --lock-tables.",
(gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.",
diff --git a/client/mysqltest.c b/client/mysqltest.c
index eae3b05f61a..e5ae9e80a88 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2675,7 +2675,7 @@ void do_copy_file(struct st_command *command)
command command handle
DESCRIPTION
- chmod_file <octal> <file_name>
+ chmod <octal> <file_name>
Change file permission of <file_name>
*/
diff --git a/include/my_base.h b/include/my_base.h
index ef5ac364fed..9240b01a9f1 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -224,7 +224,7 @@ enum ha_base_keytype {
#define HA_SPATIAL 1024 /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
-
+#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
/* Automatic bits in key-flag */
#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
diff --git a/include/my_sys.h b/include/my_sys.h
index d1f8283947b..f72aef13989 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -711,8 +711,10 @@ extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
size_s size_of_element,uchar *buffer[]);
-extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
- qsort2_cmp cmp, void *cmp_argument);
+extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size,
+ qsort_cmp cmp);
+extern qsort_t my_qsort2(void *base_ptr, size_t total_elems, size_t size,
+ qsort2_cmp cmp, void *cmp_argument);
extern qsort2_cmp get_ptr_compare(uint);
void my_store_ptr(byte *buff, uint pack_length, my_off_t pos);
my_off_t my_get_ptr(byte *ptr, uint pack_length);
diff --git a/include/mysql.h b/include/mysql.h
index b3e0dc45496..f2303abb241 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -550,16 +550,6 @@ unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
char *to,const char *from,
unsigned long length);
void STDCALL mysql_debug(const char *debug);
-char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
- char *to,
- unsigned long to_length,
- const char *from,
- unsigned long from_length,
- void *param,
- char *
- (*extend_buffer)
- (void *, char *to,
- unsigned long *length));
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
my_bool STDCALL mysql_embedded(void);
diff --git a/include/mysql_h.ic b/include/mysql_h.ic
index 5a9daee6f9f..1d4f3ce2758 100644
--- a/include/mysql_h.ic
+++ b/include/mysql_h.ic
@@ -32,65 +32,65 @@ enum mysql_option;
enum mysql_protocol_type;
enum mysql_rpl_type;
enum mysql_status;
-# 134 "mysql.h"
+# 138 "mysql.h"
typedef struct st_mysql_rows MYSQL_ROWS;
-# 24 "my_list.h"
+# 23 "my_list.h"
typedef struct st_list LIST;
-# 35 "my_alloc.h"
+# 34 "my_alloc.h"
typedef struct st_mem_root MEM_ROOT;
-# 251 "mysql.h"
+# 255 "mysql.h"
typedef struct st_mysql MYSQL;
-# 653 "mysql.h"
+# 647 "mysql.h"
typedef struct st_mysql_bind MYSQL_BIND;
-# 93 "mysql.h"
+# 97 "mysql.h"
typedef struct st_mysql_field MYSQL_FIELD;
-# 117 "mysql.h"
+# 121 "mysql.h"
typedef unsigned int MYSQL_FIELD_OFFSET;
-# 340 "mysql.h"
+# 344 "mysql.h"
typedef struct st_mysql_manager MYSQL_MANAGER;
-# 354 "mysql.h"
+# 358 "mysql.h"
typedef struct st_mysql_parameters MYSQL_PARAMETERS;
-# 309 "mysql.h"
+# 313 "mysql.h"
typedef struct st_mysql_res MYSQL_RES;
-# 116 "mysql.h"
+# 120 "mysql.h"
typedef char * * MYSQL_ROW;
-# 140 "mysql.h"
+# 144 "mysql.h"
typedef MYSQL_ROWS * MYSQL_ROW_OFFSET;
-# 681 "mysql.h"
+# 675 "mysql.h"
typedef struct st_mysql_stmt MYSQL_STMT;
-# 236 "mysql.h"
+# 240 "mysql.h"
typedef struct character_set MY_CHARSET_INFO;
-# 180 "mysql_com.h"
+# 179 "mysql_com.h"
typedef struct st_net NET;
-# 23 "typelib.h"
+# 22 "typelib.h"
typedef struct st_typelib TYPELIB;
-# 170 "mysql_com.h"
+# 169 "mysql_com.h"
typedef struct st_vio Vio;
-# 57 "mysql.h"
+# 60 "mysql.h"
typedef char * gptr;
-# 29 "my_list.h"
+# 28 "my_list.h"
typedef int (* list_walk_action)(void *, void *);
-# 48 "mysql.h"
+# 51 "mysql.h"
typedef char my_bool;
-# 63 "mysql.h"
+# 66 "mysql.h"
typedef int my_socket;
-# 125 "mysql.h"
+# 129 "mysql.h"
typedef unsigned long long int my_ulonglong;
-# 144 "mysql.h"
+# 148 "mysql.h"
typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
-# 145 "mysql.h"
+# 149 "mysql.h"
typedef struct st_mysql_data MYSQL_DATA;
-# 750 "mysql.h"
+# 744 "mysql.h"
typedef struct st_mysql_methods MYSQL_METHODS;
-# 48 "mysql_time.h"
+# 47 "mysql_time.h"
typedef struct st_mysql_time MYSQL_TIME;
-# 371 "mysql_com.h"
+# 375 "mysql_com.h"
typedef struct st_udf_args UDF_ARGS;
-# 384 "mysql_com.h"
+# 388 "mysql_com.h"
typedef struct st_udf_init UDF_INIT;
-# 27 "my_alloc.h"
+# 26 "my_alloc.h"
typedef struct st_used_mem USED_MEM;
-# 236 "mysql.h"
+# 240 "mysql.h"
struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) character_set
{
unsigned int number;
@@ -102,7 +102,7 @@ struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(vo
unsigned int mbminlen;
unsigned int mbmaxlen;
};
-# 357 "mysql_com.h"
+# 361 "mysql_com.h"
struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(double)))) rand_struct
{
unsigned long int seed1;
@@ -110,14 +110,14 @@ struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof
unsigned long int max_value;
double max_value_dbl;
};
-# 24 "my_list.h"
+# 23 "my_list.h"
struct __attribute__((aligned(__alignof__(void *)))) st_list
{
struct st_list * prev;
struct st_list * next;
void * data;
};
-# 35 "my_alloc.h"
+# 34 "my_alloc.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_mem_root
{
USED_MEM * free;
@@ -129,7 +129,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
unsigned int first_block_usage;
void (* error_handler)(void);
};
-# 251 "mysql.h"
+# 255 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql
{
NET net;
@@ -173,7 +173,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
void * thd;
my_bool * unbuffered_fetch_owner;
};
-# 653 "mysql.h"
+# 647 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind
{
unsigned long int * length;
@@ -195,7 +195,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
void (* fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char * * row);
void (* skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char * * row);
};
-# 145 "mysql.h"
+# 149 "mysql.h"
struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_data
{
my_ulonglong rows;
@@ -204,7 +204,7 @@ struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__al
MEM_ROOT alloc;
struct embedded_query_result * embedded_info;
};
-# 93 "mysql.h"
+# 97 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_field
{
char * name;
@@ -228,7 +228,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
unsigned int charsetnr;
enum enum_field_types type;
};
-# 340 "mysql.h"
+# 344 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_manager
{
NET net;
@@ -246,7 +246,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
int net_buf_size;
char last_error[256];
};
-# 750 "mysql.h"
+# 744 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)))) st_mysql_methods
{
my_bool (* read_query_result)(MYSQL * mysql);
@@ -266,7 +266,7 @@ struct __attribute__((aligned(__alignof__(void *)))) st_mysql_methods
int (* read_change_user_result)(MYSQL * mysql, char * buff, char const * passwd);
int (* read_rows_from_cursor)(MYSQL_STMT * stmt);
};
-# 167 "mysql.h"
+# 171 "mysql.h"
struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_mysql_options
{
unsigned int connect_timeout;
@@ -309,13 +309,13 @@ struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof
int (* local_infile_error)(void *, char *, unsigned int);
void * local_infile_userdata;
};
-# 354 "mysql.h"
+# 358 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)))) st_mysql_parameters
{
unsigned long int * p_max_allowed_packet;
unsigned long int * p_net_buffer_length;
};
-# 309 "mysql.h"
+# 313 "mysql.h"
struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_res
{
my_ulonglong row_count;
@@ -333,14 +333,14 @@ struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__al
my_bool unbuffered_fetch_cancelled;
struct st_mysql_methods const * methods;
};
-# 134 "mysql.h"
+# 138 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_rows
{
struct st_mysql_rows * next;
MYSQL_ROW data;
unsigned long int length;
};
-# 681 "mysql.h"
+# 675 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql_stmt
{
MEM_ROOT mem_root;
@@ -370,7 +370,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
my_bool unbuffered_fetch_cancelled;
my_bool update_max_length;
};
-# 48 "mysql_time.h"
+# 47 "mysql_time.h"
struct __attribute__((aligned(__alignof__(unsigned long int)))) st_mysql_time
{
unsigned int year;
@@ -383,7 +383,7 @@ struct __attribute__((aligned(__alignof__(unsigned long int)))) st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
};
-# 180 "mysql_com.h"
+# 179 "mysql_com.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_net
{
Vio * vio;
@@ -419,7 +419,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
my_bool report_error;
my_bool return_errno;
};
-# 23 "typelib.h"
+# 22 "typelib.h"
struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib
{
unsigned int count;
@@ -427,7 +427,7 @@ struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(vo
char const * * type_names;
unsigned int * type_lengths;
};
-# 371 "mysql_com.h"
+# 375 "mysql_com.h"
struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_udf_args
{
unsigned int arg_count;
@@ -438,7 +438,7 @@ struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(vo
char * * attributes;
unsigned long int * attribute_lengths;
};
-# 384 "mysql_com.h"
+# 388 "mysql_com.h"
struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_udf_init
{
my_bool maybe_null;
@@ -447,14 +447,14 @@ struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof
char * ptr;
my_bool const_item;
};
-# 27 "my_alloc.h"
+# 26 "my_alloc.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_used_mem
{
struct st_used_mem * next;
unsigned int left;
unsigned int size;
};
-# 368 "mysql_com.h"
+# 372 "mysql_com.h"
enum Item_result
{
STRING_RESULT = 0,
@@ -463,7 +463,7 @@ enum Item_result
ROW_RESULT = 3,
DECIMAL_RESULT = 4,
};
-# 314 "mysql_com.h"
+# 313 "mysql_com.h"
enum enum_cursor_type
{
CURSOR_TYPE_NO_CURSOR = 0,
@@ -471,7 +471,7 @@ enum enum_cursor_type
CURSOR_TYPE_FOR_UPDATE = 2,
CURSOR_TYPE_SCROLLABLE = 4,
};
-# 227 "mysql_com.h"
+# 226 "mysql_com.h"
enum enum_field_types
{
MYSQL_TYPE_DECIMAL = 0,
@@ -502,13 +502,13 @@ enum enum_field_types
MYSQL_TYPE_STRING = 254,
MYSQL_TYPE_GEOMETRY = 255,
};
-# 324 "mysql_com.h"
+# 323 "mysql_com.h"
enum enum_mysql_set_option
{
MYSQL_OPTION_MULTI_STATEMENTS_ON = 0,
MYSQL_OPTION_MULTI_STATEMENTS_OFF = 1,
};
-# 583 "mysql.h"
+# 577 "mysql.h"
enum enum_mysql_stmt_state
{
MYSQL_STMT_INIT_DONE = 1,
@@ -516,7 +516,7 @@ enum enum_mysql_stmt_state
MYSQL_STMT_EXECUTE_DONE = 3,
MYSQL_STMT_FETCH_DONE = 4,
};
-# 29 "mysql_time.h"
+# 28 "mysql_time.h"
enum enum_mysql_timestamp_type
{
MYSQL_TIMESTAMP_NONE = -(2),
@@ -525,7 +525,7 @@ enum enum_mysql_timestamp_type
MYSQL_TIMESTAMP_DATETIME = 1,
MYSQL_TIMESTAMP_TIME = 2,
};
-# 52 "mysql_com.h"
+# 51 "mysql_com.h"
enum enum_server_command
{
COM_SLEEP = 0,
@@ -559,14 +559,14 @@ enum enum_server_command
COM_STMT_FETCH = 28,
COM_END = 29,
};
-# 727 "mysql.h"
+# 721 "mysql.h"
enum enum_stmt_attr_type
{
STMT_ATTR_UPDATE_MAX_LENGTH = 0,
STMT_ATTR_CURSOR_TYPE = 1,
STMT_ATTR_PREFETCH_ROWS = 2,
};
-# 289 "mysql_com.h"
+# 288 "mysql_com.h"
enum mysql_enum_shutdown_level
{
SHUTDOWN_DEFAULT = 0,
@@ -578,7 +578,7 @@ enum mysql_enum_shutdown_level
KILL_QUERY = 254,
KILL_CONNECTION = 255,
};
-# 154 "mysql.h"
+# 158 "mysql.h"
enum mysql_option
{
MYSQL_OPT_CONNECT_TIMEOUT = 0,
@@ -604,7 +604,7 @@ enum mysql_option
MYSQL_OPT_RECONNECT = 20,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT = 21,
};
-# 221 "mysql.h"
+# 225 "mysql.h"
enum mysql_protocol_type
{
MYSQL_PROTOCOL_DEFAULT = 0,
@@ -613,357 +613,355 @@ enum mysql_protocol_type
MYSQL_PROTOCOL_PIPE = 3,
MYSQL_PROTOCOL_MEMORY = 4,
};
-# 231 "mysql.h"
+# 235 "mysql.h"
enum mysql_rpl_type
{
MYSQL_RPL_MASTER = 0,
MYSQL_RPL_SLAVE = 1,
MYSQL_RPL_ADMIN = 2,
};
-# 216 "mysql.h"
+# 220 "mysql.h"
enum mysql_status
{
MYSQL_STATUS_READY = 0,
MYSQL_STATUS_GET_RESULT = 1,
MYSQL_STATUS_USE_RESULT = 2,
};
-# 423 "mysql_com.h"
+# 427 "mysql_com.h"
extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2);
-# 416 "mysql_com.h"
+# 420 "mysql_com.h"
extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt);
-# 33 "typelib.h"
+# 32 "typelib.h"
extern TYPELIB * copy_typelib(MEM_ROOT * root, TYPELIB * from);
-# 411 "mysql_com.h"
+# 415 "mysql_com.h"
extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st);
-# 30 "typelib.h"
+# 29 "typelib.h"
extern int find_type(char * x, TYPELIB * typelib, unsigned int);
-# 425 "mysql_com.h"
+# 429 "mysql_com.h"
extern void get_salt_from_password(unsigned char * res, char const * password);
-# 418 "mysql_com.h"
+# 422 "mysql_com.h"
extern void get_salt_from_password_323(unsigned long int * res, char const * password);
-# 431 "mysql_com.h"
+# 435 "mysql_com.h"
extern char * get_tty_password(char * opt_message);
-# 32 "typelib.h"
+# 31 "typelib.h"
extern char const * get_type(TYPELIB * typelib, unsigned int);
-# 413 "mysql_com.h"
+# 417 "mysql_com.h"
extern void hash_password(unsigned long int * to, char const * password, unsigned int);
-# 31 "my_list.h"
+# 30 "my_list.h"
extern LIST * list_add(LIST * root, LIST * element);
-# 33 "my_list.h"
-extern LIST * list_cons(void * data, LIST * root);
# 32 "my_list.h"
+extern LIST * list_cons(void * data, LIST * root);
+# 31 "my_list.h"
extern LIST * list_delete(LIST * root, LIST * element);
-# 35 "my_list.h"
+# 34 "my_list.h"
extern void list_free(LIST * root, unsigned int);
-# 36 "my_list.h"
+# 35 "my_list.h"
extern unsigned int list_length(LIST *);
-# 34 "my_list.h"
+# 33 "my_list.h"
extern LIST * list_reverse(LIST * root);
-# 37 "my_list.h"
+# 36 "my_list.h"
extern int list_walk(LIST *, list_walk_action, gptr);
-# 440 "mysql_com.h"
+# 444 "mysql_com.h"
extern int load_defaults(char const * conf_file, char const * * groups, int * argc, char * * * argv);
-# 426 "mysql_com.h"
+# 430 "mysql_com.h"
extern void make_password_from_salt(char * to, unsigned char const * hash_stage2);
-# 419 "mysql_com.h"
+# 423 "mysql_com.h"
extern void make_password_from_salt_323(char * to, unsigned long int const * salt);
-# 421 "mysql_com.h"
+# 425 "mysql_com.h"
extern void make_scrambled_password(char * to, char const * password);
-# 414 "mysql_com.h"
+# 418 "mysql_com.h"
extern void make_scrambled_password_323(char * to, char const * password);
-# 31 "typelib.h"
+# 30 "typelib.h"
extern void make_type(char * to, unsigned int, TYPELIB * typelib);
-# 437 "mysql_com.h"
+# 441 "mysql_com.h"
extern int modify_defaults_file(char const * file_location, char const * option, char const * option_value, char const * section_name, int);
-# 354 "mysql_com.h"
+# 358 "mysql_com.h"
extern int my_connect(my_socket, struct sockaddr const * name, unsigned int, unsigned int);
-# 436 "mysql_com.h"
+# 440 "mysql_com.h"
extern my_bool my_init(void);
-# 336 "mysql_com.h"
+# 335 "mysql_com.h"
extern my_bool my_net_init(NET * net, Vio * vio);
-# 337 "mysql_com.h"
+# 336 "mysql_com.h"
extern void my_net_local_init(NET * net);
-# 347 "mysql_com.h"
+# 346 "mysql_com.h"
extern unsigned long int my_net_read(NET * net);
-# 342 "mysql_com.h"
+# 341 "mysql_com.h"
extern my_bool my_net_write(NET * net, char const * packet, unsigned long int);
-# 410 "mysql_com.h"
+# 414 "mysql_com.h"
extern double my_rnd(struct rand_struct *);
-# 443 "mysql_com.h"
+# 447 "mysql_com.h"
extern void my_thread_end(void);
-# 442 "mysql_com.h"
+# 446 "mysql_com.h"
extern my_bool my_thread_init(void);
-# 559 "mysql.h"
+# 553 "mysql.h"
extern void myodbc_remove_escape(MYSQL * mysql, char * name);
-# 501 "mysql.h"
+# 505 "mysql.h"
extern int mysql_add_slave(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd);
-# 410 "mysql.h"
+# 414 "mysql.h"
extern my_ulonglong mysql_affected_rows(MYSQL * mysql);
-# 823 "mysql.h"
+# 817 "mysql.h"
extern my_bool mysql_autocommit(MYSQL * mysql, my_bool);
-# 426 "mysql.h"
+# 430 "mysql.h"
extern my_bool mysql_change_user(MYSQL * mysql, char const * user, char const * passwd, char const * db);
-# 418 "mysql.h"
+# 422 "mysql.h"
extern char const * mysql_character_set_name(MYSQL * mysql);
-# 826 "mysql.h"
+# 820 "mysql.h"
extern void mysql_close(MYSQL * sock);
-# 821 "mysql.h"
+# 815 "mysql.h"
extern my_bool mysql_commit(MYSQL * mysql);
-# 530 "mysql.h"
+# 534 "mysql.h"
extern void mysql_data_seek(MYSQL_RES * result, my_ulonglong);
-# 548 "mysql.h"
+# 552 "mysql.h"
extern void mysql_debug(char const * debug);
-# 487 "mysql.h"
+# 491 "mysql.h"
extern void mysql_disable_reads_from_master(MYSQL * mysql);
-# 481 "mysql.h"
+# 485 "mysql.h"
extern void mysql_disable_rpl_parse(MYSQL * mysql);
-# 509 "mysql.h"
+# 513 "mysql.h"
extern int mysql_dump_debug_info(MYSQL * mysql);
-# 561 "mysql.h"
+# 555 "mysql.h"
extern my_bool mysql_embedded(void);
-# 486 "mysql.h"
+# 490 "mysql.h"
extern void mysql_enable_reads_from_master(MYSQL * mysql);
-# 480 "mysql.h"
+# 484 "mysql.h"
extern void mysql_enable_rpl_parse(MYSQL * mysql);
-# 402 "mysql.h"
+# 406 "mysql.h"
extern my_bool mysql_eof(MYSQL_RES * res);
-# 412 "mysql.h"
+# 416 "mysql.h"
extern unsigned int mysql_errno(MYSQL * mysql);
-# 432 "mysql_com.h"
+# 436 "mysql_com.h"
extern char const * mysql_errno_to_sqlstate(unsigned int);
-# 413 "mysql.h"
+# 417 "mysql.h"
extern char const * mysql_error(MYSQL * mysql);
-# 541 "mysql.h"
+# 545 "mysql.h"
extern unsigned long int mysql_escape_string(char * to, char const * from, unsigned long int);
-# 538 "mysql.h"
+# 542 "mysql.h"
extern MYSQL_FIELD * mysql_fetch_field(MYSQL_RES * result);
-# 403 "mysql.h"
+# 407 "mysql.h"
extern MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES * res, unsigned int);
-# 405 "mysql.h"
+# 409 "mysql.h"
extern MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES * res);
-# 537 "mysql.h"
+# 541 "mysql.h"
extern unsigned long int * mysql_fetch_lengths(MYSQL_RES * result);
-# 536 "mysql.h"
+# 540 "mysql.h"
extern MYSQL_ROW mysql_fetch_row(MYSQL_RES * result);
-# 409 "mysql.h"
+# 413 "mysql.h"
extern unsigned int mysql_field_count(MYSQL * mysql);
-# 534 "mysql.h"
+# 538 "mysql.h"
extern MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES * result, MYSQL_FIELD_OFFSET);
-# 407 "mysql.h"
+# 411 "mysql.h"
extern MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES * res);
-# 529 "mysql.h"
+# 533 "mysql.h"
extern void mysql_free_result(MYSQL_RES * result);
-# 454 "mysql.h"
+# 458 "mysql.h"
extern void mysql_get_character_set_info(MYSQL * mysql, MY_CHARSET_INFO * charset);
-# 519 "mysql.h"
+# 523 "mysql.h"
extern char const * mysql_get_client_info(void);
-# 520 "mysql.h"
+# 524 "mysql.h"
extern unsigned long int mysql_get_client_version(void);
-# 521 "mysql.h"
+# 525 "mysql.h"
extern char const * mysql_get_host_info(MYSQL * mysql);
-# 384 "mysql.h"
+# 388 "mysql.h"
extern MYSQL_PARAMETERS * mysql_get_parameters(void);
-# 523 "mysql.h"
+# 527 "mysql.h"
extern unsigned int mysql_get_proto_info(MYSQL * mysql);
-# 518 "mysql.h"
-extern char const * mysql_get_server_info(MYSQL * mysql);
# 522 "mysql.h"
+extern char const * mysql_get_server_info(MYSQL * mysql);
+# 526 "mysql.h"
extern unsigned long int mysql_get_server_version(MYSQL * mysql);
-# 425 "mysql.h"
+# 429 "mysql.h"
extern char const * mysql_get_ssl_cipher(MYSQL * mysql);
-# 543 "mysql.h"
+# 547 "mysql.h"
extern unsigned long int mysql_hex_string(char * to, char const * from, unsigned long int);
-# 416 "mysql.h"
+# 420 "mysql.h"
extern char const * mysql_info(MYSQL * mysql);
-# 421 "mysql.h"
+# 425 "mysql.h"
extern MYSQL * mysql_init(MYSQL * mysql);
-# 411 "mysql.h"
+# 415 "mysql.h"
extern my_ulonglong mysql_insert_id(MYSQL * mysql);
-# 512 "mysql.h"
+# 516 "mysql.h"
extern int mysql_kill(MYSQL * mysql, unsigned long int);
-# 524 "mysql.h"
+# 528 "mysql.h"
extern MYSQL_RES * mysql_list_dbs(MYSQL * mysql, char const * wild);
-# 539 "mysql.h"
+# 543 "mysql.h"
extern MYSQL_RES * mysql_list_fields(MYSQL * mysql, char const * table, char const * wild);
-# 526 "mysql.h"
+# 530 "mysql.h"
extern MYSQL_RES * mysql_list_processes(MYSQL * mysql);
-# 525 "mysql.h"
+# 529 "mysql.h"
extern MYSQL_RES * mysql_list_tables(MYSQL * mysql, char const * wild);
-# 568 "mysql.h"
+# 562 "mysql.h"
extern void mysql_manager_close(MYSQL_MANAGER * con);
-# 569 "mysql.h"
-extern int mysql_manager_command(MYSQL_MANAGER * con, char const * cmd, int);
# 563 "mysql.h"
+extern int mysql_manager_command(MYSQL_MANAGER * con, char const * cmd, int);
+# 557 "mysql.h"
extern MYSQL_MANAGER * mysql_manager_connect(MYSQL_MANAGER * con, char const * host, char const * user, char const * passwd, unsigned int);
-# 571 "mysql.h"
+# 565 "mysql.h"
extern int mysql_manager_fetch_line(MYSQL_MANAGER * con, char * res_buf, int);
-# 562 "mysql.h"
+# 556 "mysql.h"
extern MYSQL_MANAGER * mysql_manager_init(MYSQL_MANAGER * con);
-# 445 "mysql.h"
+# 449 "mysql.h"
extern my_bool mysql_master_query(MYSQL * mysql, char const * q, unsigned long int);
-# 447 "mysql.h"
+# 451 "mysql.h"
extern my_bool mysql_master_send_query(MYSQL * mysql, char const * q, unsigned long int);
-# 824 "mysql.h"
+# 818 "mysql.h"
extern my_bool mysql_more_results(MYSQL * mysql);
-# 825 "mysql.h"
+# 819 "mysql.h"
extern int mysql_next_result(MYSQL * mysql);
-# 401 "mysql.h"
+# 405 "mysql.h"
extern unsigned int mysql_num_fields(MYSQL_RES * res);
-# 400 "mysql.h"
+# 404 "mysql.h"
extern my_ulonglong mysql_num_rows(MYSQL_RES * res);
-# 549 "mysql.h"
-extern char * mysql_odbc_escape_string(MYSQL * mysql, char * to, unsigned long int, char const * from, unsigned long int, void * param, char * (* extend_buffer)(void *, char * to, unsigned long int * length));
-# 527 "mysql.h"
+# 531 "mysql.h"
extern int mysql_options(MYSQL * mysql, enum mysql_option, char const * arg);
-# 516 "mysql.h"
+# 520 "mysql.h"
extern int mysql_ping(MYSQL * mysql);
-# 75 "mysql.h"
+# 78 "mysql.h"
extern unsigned int mysql_port;
-# 436 "mysql.h"
+# 440 "mysql.h"
extern int mysql_query(MYSQL * mysql, char const * q);
-# 574 "mysql.h"
+# 568 "mysql.h"
extern my_bool mysql_read_query_result(MYSQL * mysql);
-# 489 "mysql.h"
+# 493 "mysql.h"
extern my_bool mysql_reads_from_master_enabled(MYSQL * mysql);
-# 428 "mysql.h"
+# 432 "mysql.h"
extern MYSQL * mysql_real_connect(MYSQL * mysql, char const * host, char const * user, char const * passwd, char const * db, unsigned int, char const * unix_socket, unsigned long int);
-# 545 "mysql.h"
+# 549 "mysql.h"
extern unsigned long int mysql_real_escape_string(MYSQL * mysql, char * to, char const * from, unsigned long int);
-# 439 "mysql.h"
+# 443 "mysql.h"
extern int mysql_real_query(MYSQL * mysql, char const * q, unsigned long int);
-# 510 "mysql.h"
+# 514 "mysql.h"
extern int mysql_refresh(MYSQL * mysql, unsigned int);
-# 822 "mysql.h"
+# 816 "mysql.h"
extern my_bool mysql_rollback(MYSQL * mysql);
-# 532 "mysql.h"
+# 536 "mysql.h"
extern MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES * result, MYSQL_ROW_OFFSET);
-# 406 "mysql.h"
+# 410 "mysql.h"
extern MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES * res);
-# 483 "mysql.h"
+# 487 "mysql.h"
extern int mysql_rpl_parse_enabled(MYSQL * mysql);
-# 494 "mysql.h"
+# 498 "mysql.h"
extern my_bool mysql_rpl_probe(MYSQL * mysql);
-# 491 "mysql.h"
+# 495 "mysql.h"
extern enum mysql_rpl_type mysql_rpl_query_type(char const * q, int);
-# 435 "mysql.h"
+# 439 "mysql.h"
extern int mysql_select_db(MYSQL * mysql, char const * db);
-# 437 "mysql.h"
+# 441 "mysql.h"
extern int mysql_send_query(MYSQL * mysql, char const * q, unsigned long int);
-# 371 "mysql.h"
+# 375 "mysql.h"
extern void mysql_server_end(void);
-# 370 "mysql.h"
+# 374 "mysql.h"
extern int mysql_server_init(int, char * * argv, char * * groups);
-# 419 "mysql.h"
+# 423 "mysql.h"
extern int mysql_set_character_set(MYSQL * mysql, char const * csname);
-# 472 "mysql.h"
+# 476 "mysql.h"
extern void mysql_set_local_infile_default(MYSQL * mysql);
-# 461 "mysql.h"
+# 465 "mysql.h"
extern void mysql_set_local_infile_handler(MYSQL * mysql, int (* local_infile_init)(void * *, char const *, void *), int (* local_infile_read)(void *, char *, unsigned int), void (* local_infile_end)(void), int (* local_infile_error)(void *, char *, unsigned int), void *);
-# 497 "mysql.h"
+# 501 "mysql.h"
extern int mysql_set_master(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd);
-# 513 "mysql.h"
+# 517 "mysql.h"
extern int mysql_set_server_option(MYSQL * mysql, enum enum_mysql_set_option);
-# 506 "mysql.h"
+# 510 "mysql.h"
extern int mysql_shutdown(MYSQL * mysql, enum mysql_enum_shutdown_level);
-# 450 "mysql.h"
+# 454 "mysql.h"
extern my_bool mysql_slave_query(MYSQL * mysql, char const * q, unsigned long int);
-# 452 "mysql.h"
+# 456 "mysql.h"
extern my_bool mysql_slave_send_query(MYSQL * mysql, char const * q, unsigned long int);
-# 414 "mysql.h"
+# 418 "mysql.h"
extern char const * mysql_sqlstate(MYSQL * mysql);
-# 422 "mysql.h"
+# 426 "mysql.h"
extern my_bool mysql_ssl_set(MYSQL * mysql, char const * key, char const * cert, char const * ca, char const * capath, char const * cipher);
-# 517 "mysql.h"
+# 521 "mysql.h"
extern char const * mysql_stat(MYSQL * mysql);
-# 817 "mysql.h"
+# 811 "mysql.h"
extern my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT * stmt);
-# 795 "mysql.h"
+# 789 "mysql.h"
extern my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void * attr);
-# 792 "mysql.h"
+# 786 "mysql.h"
extern my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void const * attr);
-# 798 "mysql.h"
+# 792 "mysql.h"
extern my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
-# 799 "mysql.h"
+# 793 "mysql.h"
extern my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
-# 800 "mysql.h"
+# 794 "mysql.h"
extern my_bool mysql_stmt_close(MYSQL_STMT * stmt);
-# 815 "mysql.h"
-extern void mysql_stmt_data_seek(MYSQL_STMT * stmt, my_ulonglong);
# 809 "mysql.h"
+extern void mysql_stmt_data_seek(MYSQL_STMT * stmt, my_ulonglong);
+# 803 "mysql.h"
extern unsigned int mysql_stmt_errno(MYSQL_STMT * stmt);
-# 810 "mysql.h"
+# 804 "mysql.h"
extern char const * mysql_stmt_error(MYSQL_STMT * stmt);
-# 785 "mysql.h"
+# 779 "mysql.h"
extern int mysql_stmt_execute(MYSQL_STMT * stmt);
-# 786 "mysql.h"
+# 780 "mysql.h"
extern int mysql_stmt_fetch(MYSQL_STMT * stmt);
-# 787 "mysql.h"
-extern int mysql_stmt_fetch_column(MYSQL_STMT * stmt, MYSQL_BIND * bind, unsigned int, unsigned long int);
-# 819 "mysql.h"
+# 781 "mysql.h"
+extern int mysql_stmt_fetch_column(MYSQL_STMT * stmt, MYSQL_BIND * bind_arg, unsigned int, unsigned long int);
+# 813 "mysql.h"
extern unsigned int mysql_stmt_field_count(MYSQL_STMT * stmt);
-# 802 "mysql.h"
+# 796 "mysql.h"
extern my_bool mysql_stmt_free_result(MYSQL_STMT * stmt);
-# 782 "mysql.h"
+# 776 "mysql.h"
extern MYSQL_STMT * mysql_stmt_init(MYSQL * mysql);
-# 818 "mysql.h"
+# 812 "mysql.h"
extern my_ulonglong mysql_stmt_insert_id(MYSQL_STMT * stmt);
-# 816 "mysql.h"
+# 810 "mysql.h"
extern my_ulonglong mysql_stmt_num_rows(MYSQL_STMT * stmt);
-# 791 "mysql.h"
+# 785 "mysql.h"
extern unsigned long int mysql_stmt_param_count(MYSQL_STMT * stmt);
-# 808 "mysql.h"
+# 802 "mysql.h"
extern MYSQL_RES * mysql_stmt_param_metadata(MYSQL_STMT * stmt);
-# 783 "mysql.h"
+# 777 "mysql.h"
extern int mysql_stmt_prepare(MYSQL_STMT * stmt, char const * query, unsigned long int);
-# 801 "mysql.h"
+# 795 "mysql.h"
extern my_bool mysql_stmt_reset(MYSQL_STMT * stmt);
-# 807 "mysql.h"
+# 801 "mysql.h"
extern MYSQL_RES * mysql_stmt_result_metadata(MYSQL_STMT * stmt);
-# 812 "mysql.h"
+# 806 "mysql.h"
extern MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT * stmt, MYSQL_ROW_OFFSET);
-# 814 "mysql.h"
+# 808 "mysql.h"
extern MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT * stmt);
-# 803 "mysql.h"
+# 797 "mysql.h"
extern my_bool mysql_stmt_send_long_data(MYSQL_STMT * stmt, unsigned int, char const * data, unsigned long int);
-# 811 "mysql.h"
+# 805 "mysql.h"
extern char const * mysql_stmt_sqlstate(MYSQL_STMT * stmt);
-# 790 "mysql.h"
+# 784 "mysql.h"
extern int mysql_stmt_store_result(MYSQL_STMT * stmt);
-# 441 "mysql.h"
+# 445 "mysql.h"
extern MYSQL_RES * mysql_store_result(MYSQL * mysql);
-# 393 "mysql.h"
+# 397 "mysql.h"
extern void mysql_thread_end(void);
-# 417 "mysql.h"
+# 421 "mysql.h"
extern unsigned long int mysql_thread_id(MYSQL * mysql);
-# 392 "mysql.h"
+# 396 "mysql.h"
extern my_bool mysql_thread_init(void);
-# 560 "mysql.h"
+# 554 "mysql.h"
extern unsigned int mysql_thread_safe(void);
-# 76 "mysql.h"
+# 79 "mysql.h"
extern char * mysql_unix_port;
-# 442 "mysql.h"
+# 446 "mysql.h"
extern MYSQL_RES * mysql_use_result(MYSQL * mysql);
-# 415 "mysql.h"
+# 419 "mysql.h"
extern unsigned int mysql_warning_count(MYSQL * mysql);
-# 339 "mysql_com.h"
-extern void net_clear(NET * net);
# 338 "mysql_com.h"
+extern void net_clear(NET * net);
+# 337 "mysql_com.h"
extern void net_end(NET * net);
-# 341 "mysql_com.h"
+# 340 "mysql_com.h"
extern my_bool net_flush(NET * net);
-# 346 "mysql_com.h"
+# 345 "mysql_com.h"
extern int net_real_write(NET * net, char const * packet, unsigned long int);
-# 340 "mysql_com.h"
+# 339 "mysql_com.h"
extern my_bool net_realloc(NET * net, unsigned long int);
-# 343 "mysql_com.h"
+# 342 "mysql_com.h"
extern my_bool net_write_command(NET * net, unsigned char, char const * header, unsigned long int, char const * packet, unsigned long int);
-# 427 "mysql_com.h"
+# 431 "mysql_com.h"
extern char * octet2hex(char * to, char const * str, unsigned int);
-# 408 "mysql_com.h"
+# 412 "mysql_com.h"
extern void randominit(struct rand_struct *, unsigned long int, unsigned long int);
-# 422 "mysql_com.h"
+# 426 "mysql_com.h"
extern void scramble(char * to, char const * message, char const * password);
-# 415 "mysql_com.h"
+# 419 "mysql_com.h"
extern void scramble_323(char * to, char const * message, char const * password);
-# 35 "typelib.h"
+# 34 "typelib.h"
extern TYPELIB sql_protocol_typelib;
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 0e332d77259..6efdd4afb90 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -96,7 +96,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
- ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c
+ ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
${LIB_SOURCES})
# Need to set USE_TLS for building the DLL, since __declspec(thread)
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 7839c117432..ad0ac53cfba 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -73,7 +73,7 @@ sqlobjects = net.lo
sql_cmn_objects = pack.lo client.lo my_time.lo
# Not needed in the minimum library
-mysysobjects2 = my_lib.lo
+mysysobjects2 = my_lib.lo mf_qsort.lo
mysysobjects = $(mysysobjects1) $(mysysobjects2)
target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \
$(sql_cmn_objects) $(vio_objects) $(sqlobjects)
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 85509b49fdd..4afc3ec5925 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1617,78 +1617,6 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
return escape_string_for_mysql(mysql->charset, to, 0, from, length);
}
-
-char * STDCALL
-mysql_odbc_escape_string(MYSQL *mysql,
- char *to, ulong to_length,
- const char *from, ulong from_length,
- void *param,
- char * (*extend_buffer)
- (void *, char *, ulong *))
-{
- char *to_end=to+to_length-5;
- const char *end;
-#ifdef USE_MB
- my_bool use_mb_flag=use_mb(mysql->charset);
-#endif
-
- for (end=from+from_length; from != end ; from++)
- {
- if (to >= to_end)
- {
- to_length = (ulong) (end-from)+512; /* We want this much more */
- if (!(to=(*extend_buffer)(param, to, &to_length)))
- return to;
- to_end=to+to_length-5;
- }
-#ifdef USE_MB
- {
- int l;
- if (use_mb_flag && (l = my_ismbchar(mysql->charset, from, end)))
- {
- while (l--)
- *to++ = *from++;
- from--;
- continue;
- }
- }
-#endif
- switch (*from) {
- case 0: /* Must be escaped for 'mysql' */
- *to++= '\\';
- *to++= '0';
- break;
- case '\n': /* Must be escaped for logs */
- *to++= '\\';
- *to++= 'n';
- break;
- case '\r':
- *to++= '\\';
- *to++= 'r';
- break;
- case '\\':
- *to++= '\\';
- *to++= '\\';
- break;
- case '\'':
- *to++= '\\';
- *to++= '\'';
- break;
- case '"': /* Better safe than sorry */
- *to++= '\\';
- *to++= '"';
- break;
- case '\032': /* This gives problems on Win32 */
- *to++= '\\';
- *to++= 'Z';
- break;
- default:
- *to++= *from;
- }
- }
- return to;
-}
-
void STDCALL
myodbc_remove_escape(MYSQL *mysql,char *name)
{
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index 8c6b71d9553..81f86dc8726 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -78,7 +78,6 @@ EXPORTS
mysql_next_result
mysql_num_fields
mysql_num_rows
- mysql_odbc_escape_string
mysql_options
mysql_stmt_param_count
mysql_stmt_param_metadata
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index 8829112fefd..8aed164a30e 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -71,7 +71,6 @@ EXPORTS
mysql_next_result
mysql_num_fields
mysql_num_rows
- mysql_odbc_escape_string
mysql_options
mysql_ping
mysql_query
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c
index 9f442148069..57de75ee4be 100644
--- a/myisam/ft_boolean_search.c
+++ b/myisam/ft_boolean_search.c
@@ -430,8 +430,8 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root,
sizeof(FTB_WORD *)*ftb->queue.elements);
memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements);
- qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *),
- (qsort2_cmp)FTB_WORD_cmp_list, ftb->charset);
+ my_qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *),
+ (qsort2_cmp)FTB_WORD_cmp_list, ftb->charset);
if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC;
ftb->state=READY;
return ftb;
diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c
index f63735b7e68..41d145c070f 100644
--- a/myisam/ft_nlq_search.c
+++ b/myisam/ft_nlq_search.c
@@ -281,7 +281,8 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query,
&dptr, left_root_right);
if (flags & FT_SORTED)
- qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC), (qsort2_cmp)&FT_DOC_cmp, 0);
+ my_qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC), (qsort2_cmp)&FT_DOC_cmp,
+ 0);
err:
delete_tree(&aio.dtree);
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 4ead51639f3..fa58211ea88 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -3148,7 +3148,7 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count)
cur_sort_p= sort_counts;
while (cur_count_p < end_count_p)
*(cur_sort_p++)= cur_count_p++;
- (void) qsort(sort_counts, 256, sizeof(my_off_t*), (qsort_cmp) fakecmp);
+ (void) my_qsort(sort_counts, 256, sizeof(my_off_t*), (qsort_cmp) fakecmp);
/*
Assign faked counts.
diff --git a/myisam/sort.c b/myisam/sort.c
index 839d46b4aee..2465227a449 100644
--- a/myisam/sort.c
+++ b/myisam/sort.c
@@ -650,8 +650,8 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
uint sort_length=info->key_length;
DBUG_ENTER("write_keys");
- qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
- info);
+ my_qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
+ info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@@ -693,8 +693,8 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info,
int err;
DBUG_ENTER("write_keys_varlen");
- qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
- info);
+ my_qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
+ info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@@ -736,8 +736,8 @@ static int NEAR_F write_index(MI_SORT_PARAM *info, register uchar **sort_keys,
{
DBUG_ENTER("write_index");
- qsort2((gptr) sort_keys,(size_t) count,sizeof(byte*),
- (qsort2_cmp) info->key_cmp,info);
+ my_qsort2((gptr) sort_keys,(size_t) count,sizeof(byte*),
+ (qsort2_cmp) info->key_cmp,info);
while (count--)
{
if ((*info->key_write)(info,*sort_keys++))
diff --git a/mysql-test/include/ctype_common.inc b/mysql-test/include/ctype_common.inc
index 9ee0a40c8ce..89b7ceb0c72 100644
--- a/mysql-test/include/ctype_common.inc
+++ b/mysql-test/include/ctype_common.inc
@@ -53,11 +53,13 @@ DROP TABLE t1;
#
# Bug #31070: crash during conversion of charsets
+# Bug #32726: crash with cast in order by clause and cp932 charset
#
create table t1 (a set('a') not null);
insert into t1 values (),();
select cast(a as char(1)) from t1;
select a sounds like a from t1;
+select 1 from t1 order by cast(a as char(1));
drop table t1;
DROP DATABASE d1;
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 5aabb7f8863..b9943fb6cfa 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -32,16 +32,14 @@ my $skip_test;
sub init_pattern {
my ($from, $what)= @_;
- if ( $from =~ /[a-z0-9]/ ) {
+ if ( $from =~ /^[a-z0-9]$/ ) {
# Does not contain any regex, make the pattern match
# beginning of string
$from= "^$from";
}
- else {
- # Check that pattern is a valid regex
- eval { "" =~/$from/; 1 } or
- mtr_error("Invalid regex '$from' passed to $what\nPerl says: $@");
- }
+ # Check that pattern is a valid regex
+ eval { "" =~/$from/; 1 } or
+ mtr_error("Invalid regex '$from' passed to $what\nPerl says: $@");
return $from;
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index d97dd2d99bf..42298d635e7 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -255,13 +255,13 @@ our $opt_timer= 1;
our $opt_user;
-our $opt_valgrind= 0;
-our $opt_valgrind_mysqld= 0;
-our $opt_valgrind_mysqltest= 0;
-our $default_valgrind_options= "--show-reachable=yes";
-our $opt_valgrind_options;
-our $opt_valgrind_path;
-our $opt_callgrind;
+my $opt_valgrind= 0;
+my $opt_valgrind_mysqld= 0;
+my $opt_valgrind_mysqltest= 0;
+my @default_valgrind_args= ("--show-reachable=yes");
+my @valgrind_args;
+my $opt_valgrind_path;
+my $opt_callgrind;
our $opt_stress= "";
our $opt_stress_suite= "main";
@@ -461,6 +461,19 @@ sub main () {
#
##############################################################################
+#
+# When an option is no longer used by this program, it must be explicitly
+# ignored or else it will be passed through to mysqld. GetOptions will call
+# this subroutine once for each such option on the command line. See
+# Getopt::Long documentation.
+#
+
+sub warn_about_removed_option {
+ my ($option, $value, $hash_value) = @_;
+
+ warn "WARNING: This option is no longer used, and is ignored: --$option\n";
+}
+
sub command_line_setup () {
# These are defaults for things that are set on the command line
@@ -498,6 +511,15 @@ sub command_line_setup () {
# Read the command line
# Note: Keep list, and the order, in sync with usage at end of this file
+ # Options that are no longer used must still be processed, because all
+ # unprocessed options are passed directly to mysqld. The user will be
+ # warned that the option is being ignored.
+ #
+ # Put the complete option string here. For example, to remove the --suite
+ # option, remove it from GetOptions() below and put 'suite|suites=s' here.
+ my @removed_options = (
+ );
+
Getopt::Long::Configure("pass_through");
GetOptions(
# Control what engine/variation to run
@@ -575,7 +597,18 @@ sub command_line_setup () {
'valgrind|valgrind-all' => \$opt_valgrind,
'valgrind-mysqltest' => \$opt_valgrind_mysqltest,
'valgrind-mysqld' => \$opt_valgrind_mysqld,
- 'valgrind-options=s' => \$opt_valgrind_options,
+ 'valgrind-options=s' => sub {
+ my ($opt, $value)= @_;
+ # Deprecated option unless it's what we know pushbuild uses
+ if ($value eq "--gen-suppressions=all --show-reachable=yes") {
+ push(@valgrind_args, $_) for (split(' ', $value));
+ return;
+ }
+ die("--valgrind-options=s is deprecated. Use ",
+ "--valgrind-option=s, to be specified several",
+ " times if necessary");
+ },
+ 'valgrind-option=s' => \@valgrind_args,
'valgrind-path=s' => \$opt_valgrind_path,
'callgrind' => \$opt_callgrind,
@@ -615,6 +648,9 @@ sub command_line_setup () {
'suite-timeout=i' => \$opt_suite_timeout,
'warnings|log-warnings' => \$opt_warnings,
+ # Options which are no longer used
+ (map { $_ => \&warn_about_removed_option } @removed_options),
+
'help|h' => \$opt_usage,
) or usage("Can't read options");
@@ -992,7 +1028,7 @@ sub command_line_setup () {
# --------------------------------------------------------------------------
# Check valgrind arguments
# --------------------------------------------------------------------------
- if ( $opt_valgrind or $opt_valgrind_path or defined $opt_valgrind_options)
+ if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
{
mtr_report("Turning on valgrind for all executables");
$opt_valgrind= 1;
@@ -1017,17 +1053,18 @@ sub command_line_setup () {
$opt_valgrind_mysqld= 1;
# Set special valgrind options unless options passed on command line
- $opt_valgrind_options="--trace-children=yes"
- unless defined $opt_valgrind_options;
+ push(@valgrind_args, "--trace-children=yes")
+ unless @valgrind_args;
}
if ( $opt_valgrind )
{
# Set valgrind_options to default unless already defined
- $opt_valgrind_options=$default_valgrind_options
- unless defined $opt_valgrind_options;
+ push(@valgrind_args, @default_valgrind_args)
+ unless @valgrind_args;
- mtr_report("Running valgrind with options \"$opt_valgrind_options\"");
+ mtr_report("Running valgrind with options \"",
+ join(" ", @valgrind_args), "\"");
}
if ( ! $opt_testcase_timeout )
@@ -3730,10 +3767,13 @@ sub mysqld_arguments ($$$$) {
# see BUG#28359
mtr_add_arg($args, "%s--connect-timeout=60", $prefix);
+
# When mysqld is run by a root user(euid is 0), it will fail
# to start unless we specify what user to run as. If not running
# as root it will be ignored, see BUG#30630
- if (!(grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt))) {
+ my $euid= $>;
+ if (!$glob_win32 and $euid == 0 and
+ grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
mtr_add_arg($args, "%s--user=root");
}
@@ -5030,7 +5070,7 @@ sub valgrind_arguments {
}
# Add valgrind options, can be overriden by user
- mtr_add_arg($args, '%s', $opt_valgrind_options);
+ mtr_add_arg($args, '%s', $_) for (@valgrind_args);
mtr_add_arg($args, $$exe);
@@ -5170,12 +5210,14 @@ Options for coverage, profiling etc
gcov FIXME
gprof FIXME
valgrind Run the "mysqltest" and "mysqld" executables using
- valgrind with options($default_valgrind_options)
+ valgrind with default options
valgrind-all Synonym for --valgrind
valgrind-mysqltest Run the "mysqltest" and "mysql_client_test" executable
with valgrind
valgrind-mysqld Run the "mysqld" executable with valgrind
- valgrind-options=ARGS Options to give valgrind, replaces default options
+ valgrind-options=ARGS Deprecated, use --valgrind-option
+ valgrind-option=ARGS Option to give valgrind, replaces default option(s),
+ can be specified more then once
valgrind-path=[EXE] Path to the valgrind executable
callgrind Instruct valgrind to use callgrind
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result
index cf358e6a404..bc05edcfac1 100644
--- a/mysql-test/r/case.result
+++ b/mysql-test/r/case.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1, t2;
select CASE "b" when "a" then 1 when "b" then 2 END;
CASE "b" when "a" then 1 when "b" then 2 END
2
@@ -200,3 +200,21 @@ CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
DROP TABLE t1,t2;
+End of 4.1 tests
+create table t1 (a int, b bigint unsigned);
+create table t2 (c int);
+insert into t1 (a, b) values (1,4572794622775114594), (2,18196094287899841997),
+(3,11120436154190595086);
+insert into t2 (c) values (1), (2), (3);
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+join t2 on t1.a=t2.c order by d;
+a d
+1 4572794622775114594
+3 11120436154190595086
+2 18196094287899841997
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+join t2 on t1.a=t2.c where b=11120436154190595086 order by d;
+a d
+3 11120436154190595086
+drop table t1, t2;
+End of 5.0 tests
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index b190273cc64..8103e9b856f 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -64,6 +64,10 @@ select a sounds like a from t1;
a sounds like a
1
1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
drop table t1;
DROP DATABASE d1;
USE test;
diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result
index e3598f00777..8974a6a8594 100755
--- a/mysql-test/r/ctype_cp932.result
+++ b/mysql-test/r/ctype_cp932.result
@@ -2,6 +2,80 @@ drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
+SET @test_character_set= 'cp932';
+SET @test_collation= 'cp932_japanese_ci';
+SET @safe_character_set_server= @@character_set_server;
+SET @safe_collation_server= @@collation_server;
+SET character_set_server= @test_character_set;
+SET collation_server= @test_collation;
+CREATE DATABASE d1;
+USE d1;
+CREATE TABLE t1 (c CHAR(10), KEY(c));
+SHOW FULL COLUMNS FROM t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+c char(10) cp932_japanese_ci YES MUL NULL
+INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
+SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
+want3results
+aaa
+aaaa
+aaaaa
+DROP TABLE t1;
+CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
+SHOW FULL COLUMNS FROM t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+c1 varchar(15) cp932_japanese_ci YES MUL NULL
+INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
+SELECT c1 as want3results from t1 where c1 like 'l%';
+want3results
+location
+loberge
+lotre
+SELECT c1 as want3results from t1 where c1 like 'lo%';
+want3results
+location
+loberge
+lotre
+SELECT c1 as want1result from t1 where c1 like 'loc%';
+want1result
+location
+SELECT c1 as want1result from t1 where c1 like 'loca%';
+want1result
+location
+SELECT c1 as want1result from t1 where c1 like 'locat%';
+want1result
+location
+SELECT c1 as want1result from t1 where c1 like 'locati%';
+want1result
+location
+SELECT c1 as want1result from t1 where c1 like 'locatio%';
+want1result
+location
+SELECT c1 as want1result from t1 where c1 like 'location%';
+want1result
+location
+DROP TABLE t1;
+create table t1 (a set('a') not null);
+insert into t1 values (),();
+Warnings:
+Warning 1364 Field 'a' doesn't have a default value
+select cast(a as char(1)) from t1;
+cast(a as char(1))
+
+
+select a sounds like a from t1;
+a sounds like a
+1
+1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
+drop table t1;
+DROP DATABASE d1;
+USE test;
+SET character_set_server= @safe_character_set_server;
+SET collation_server= @safe_collation_server;
set names cp932;
set character_set_database = cp932;
CREATE TABLE t1(c1 CHAR(1)) DEFAULT CHARACTER SET = cp932;
diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result
index ee786202c01..bb1b3f5995b 100644
--- a/mysql-test/r/ctype_euckr.result
+++ b/mysql-test/r/ctype_euckr.result
@@ -64,6 +64,10 @@ select a sounds like a from t1;
a sounds like a
1
1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
drop table t1;
DROP DATABASE d1;
USE test;
diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result
index 90c94c3b299..95246525368 100644
--- a/mysql-test/r/ctype_gb2312.result
+++ b/mysql-test/r/ctype_gb2312.result
@@ -64,6 +64,10 @@ select a sounds like a from t1;
a sounds like a
1
1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
drop table t1;
DROP DATABASE d1;
USE test;
diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result
index fe90c7bff29..8437e34be1e 100644
--- a/mysql-test/r/ctype_gbk.result
+++ b/mysql-test/r/ctype_gbk.result
@@ -64,6 +64,10 @@ select a sounds like a from t1;
a sounds like a
1
1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
drop table t1;
DROP DATABASE d1;
USE test;
diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result
index ae9146fc9db..50be0ca53b2 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -2599,6 +2599,10 @@ select a sounds like a from t1;
a sounds like a
1
1
+select 1 from t1 order by cast(a as char(1));
+1
+1
+1
drop table t1;
DROP DATABASE d1;
USE test;
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 82e4c346f30..a6d6c604b9b 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -811,6 +811,14 @@ quote(name)
????????
????????????????
drop table bug20536;
+set names ucs2;
+ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2'
+set names ucs2 collate ucs2_bin;
+ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2'
+set character_set_client= ucs2;
+ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2'
+set character_set_client= concat('ucs', substr('2', 1));
+ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2'
CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci);
INSERT INTO t1 VALUES('abcd');
SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE);
diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
index ff333d88fef..9f6ebea7e1b 100644
--- a/mysql-test/r/delayed.result
+++ b/mysql-test/r/delayed.result
@@ -255,3 +255,8 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1);
INSERT DELAYED INTO t2 VALUES(1);
ERROR HY000: Table storage engine for 't2' doesn't have this option
DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT);
+INSERT DELAYED INTO t1 SET b= b();
+ERROR 42S22: Unknown column 'b' in 'field list'
+DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result
index 7eb7fd16edb..ce64e09c1d3 100644
--- a/mysql-test/r/flush.result
+++ b/mysql-test/r/flush.result
@@ -55,3 +55,20 @@ flush tables with read lock;
insert into t2 values(1);
unlock tables;
drop table t1, t2;
+drop table if exists t1, t2;
+set session low_priority_updates=1;
+create table t1 (a int);
+create table t2 (b int);
+lock tables t1 write;
+flush tables with read lock;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+unlock tables;
+lock tables t1 read, t2 write;
+flush tables with read lock;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+unlock tables;
+lock tables t1 read;
+flush tables with read lock;
+unlock tables;
+drop table t1, t2;
+set session low_priority_updates=default;
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index c941790c35b..c0b666dbc79 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -207,4 +207,17 @@ test
SELECT NAME_CONST('test', 'test');
test
test
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (), (), ();
+SELECT NAME_CONST(a, '1') FROM t1;
+ERROR HY000: Incorrect arguments to NAME_CONST
+SET INSERT_ID= NAME_CONST(a, a);
+ERROR HY000: Incorrect arguments to NAME_CONST
+DROP TABLE t1;
+create table t1 (a int not null);
+insert into t1 values (-1), (-2);
+select min(a) from t1 group by inet_ntoa(a);
+min(a)
+-2
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 855352a2195..e27ef64af43 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1105,6 +1105,7 @@ ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table '
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
+DROP USER mysqltest_2@localhost;
use test;
CREATE TABLE t1 (f1 int, f2 int);
INSERT INTO t1 VALUES(1,1), (2,2);
@@ -1124,6 +1125,7 @@ f1 f2
REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost';
REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
+DROP USER mysqltest_1@localhost;
DROP DATABASE db27878;
use test;
DROP TABLE t1;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index d5f014b6840..5a85df76347 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -1211,4 +1211,19 @@ a b
3 2
1 1
DROP TABLE t1;
+create table t1(a char(10) not null, unique key aa(a(1)),
+b char(4) not null, unique key bb(b(4))) engine=innodb;
+desc t1;
+Field Type Null Key Default Extra
+a char(10) NO UNI NULL
+b char(4) NO PRI NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) NOT NULL,
+ `b` char(4) NOT NULL,
+ UNIQUE KEY `bb` (`b`),
+ UNIQUE KEY `aa` (`a`(1))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 8a0a3ba848c..2e49bd373d6 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -461,4 +461,138 @@ i
2
2
DROP TABLE t1, t2;
+CREATE TABLE t1 (
+a char(20) NOT NULL,
+b char(7) DEFAULT NULL,
+c char(4) DEFAULT NULL
+);
+INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
+INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
+INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
+INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
+INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
+INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
+INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
+INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
+INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
+INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
+INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
+INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
+INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
+INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
+INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
+INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT * FROM t1;
+a b c
+9.999999 10 10
+1.225e-05 1.2e-05 1e-0
+0.0001225 0.00012 NULL
+0.1225 0.1225 NULL
+0.1225877 0.12259 NULL
+12.25 12.25 NULL
+12.25 12.25 12.2
+122500 122500 NULL
+12250000000 1.2e+10 NULL
+1.225e+15 1.2e+15 NULL
+5000000 5000000 NULL
+1.25e+78 1.2e+78 NULL
+1.25e-94 1.2e-94 NULL
+1.25e+203 1e+203 NULL
+1.25e-175 1e-175 NULL
+1.225 NULL 1.23
+1.37 NULL 1.37
+-1.37 NULL -1.3
+0.00187 NULL 0.00
+-0.0187 NULL -0.0
+5000 NULL 5000
+-5000 NULL -500
+DROP TABLE t1;
+CREATE TABLE t1 (
+a char(20) NOT NULL,
+b char(7) DEFAULT NULL,
+c char(5)
+);
+INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
+INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
+INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
+INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
+INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
+INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
+INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
+INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
+INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
+INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
+INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
+INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
+INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
+INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
+INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
+INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
+INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
+INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
+INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
+SELECT * FROM t1;
+a b c
+9.999999 10 9.999
+1.225e-05 1.2e-05 1e-05
+0.0001225 0.00012 NULL
+0.1225 0.1225 NULL
+0.1225877 0.12259 NULL
+12.25 12.25 NULL
+12.25 12.25 12.25
+122500 122500 NULL
+12250000000 1.2e+10 NULL
+1.225e+15 1.2e+15 NULL
+5000000 5000000 NULL
+1.25e+78 1.2e+78 NULL
+1.25e-94 1.2e-94 NULL
+1.25e+203 1e+203 NULL
+1.25e-175 1e-175 NULL
+1.225 NULL 1.225
+1.37 NULL 1.37
+-1.37 NULL -1.37
+0.00187 NULL 0.002
+-0.0187 NULL -0.01
+5000 NULL 5000
+-5000 NULL -5000
+DROP TABLE t1;
+CREATE TABLE t (a CHAR(10),b INT);
+INSERT INTO t VALUES (),(),();
+INSERT INTO t(a) SELECT rand() FROM t;
+DROP TABLE t;
+CREATE TABLE t1 (c1 INT NOT NULL);
+INSERT INTO t1 VALUES(4188.32999999999992724042385816574096679687500),
+('4188.32999999999992724042385816574096679687500'), (4188);
+SELECT * FROM t1;
+c1
+4188
+4188
+4188
+CREATE TABLE t2 (c1 BIGINT);
+INSERT INTO t2 VALUES('15449237462.0000000000');
+SELECT * FROM t2;
+c1
+15449237462
+DROP TABLE t1, t2;
End of 5.0 tests.
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index 2fc751c63bf..0f1ea46bd61 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -462,4 +462,48 @@ EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
DROP TABLE t1;
+create table t1(a int not null, key aa(a),
+b char(10) not null, unique key bb(b(1)),
+c char(4) not null, unique key cc(c));
+desc t1;
+Field Type Null Key Default Extra
+a int(11) NO MUL NULL
+b char(10) NO UNI NULL
+c char(4) NO PRI NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(10) NOT NULL,
+ `c` char(4) NOT NULL,
+ UNIQUE KEY `cc` (`c`),
+ UNIQUE KEY `bb` (`b`(1)),
+ KEY `aa` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, key aa(a),
+b char(10) not null, unique key bb(b(1)),
+c char(4) not null);
+desc t1;
+Field Type Null Key Default Extra
+a int(11) NO MUL NULL
+b char(10) NO UNI NULL
+c char(4) NO NULL
+alter table t1 add unique key cc(c);
+desc t1;
+Field Type Null Key Default Extra
+a int(11) NO MUL NULL
+b char(10) NO UNI NULL
+c char(4) NO PRI NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(10) NOT NULL,
+ `c` char(4) NOT NULL,
+ UNIQUE KEY `cc` (`c`),
+ UNIQUE KEY `bb` (`b`(1)),
+ KEY `aa` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
End of 5.0 tests.
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index af49e1a27dc..079f92ca420 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -88,3 +88,14 @@ alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
unlock tables;
drop table t1;
+drop table if exists t1;
+create table t1 (a int);
+connection: locker
+lock tables t1 read;
+connection: writer
+create table t2 like t1;;
+connection: default
+kill query
+ERROR 70100: Query execution was interrupted
+unlock tables;
+drop table t1;
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index b2820df8f4c..f8a28009c42 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
drop view if exists v1;
drop database if exists client_test_db;
mysql.columns_priv OK
@@ -41,4 +41,9 @@ test.t1 OK
test.t1 OK
drop view v1;
drop table t1;
+create table `t``1`(a int);
+create table `t 1`(a int);
+test.t 1 OK
+test.t`1 OK
+drop table `t``1`, `t 1`;
End of 5.0 tests
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 4db588e5cac..0682cae5c80 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1136,6 +1136,11 @@ a
13
DEALLOCATE PREPARE st1;
DROP TABLE t1;
+create table t1 (a int, b tinyint);
+prepare st1 from 'update t1 set b= (str_to_date(a, a))';
+execute st1;
+deallocate prepare st1;
+drop table t1;
End of 4.1 tests.
create table t1 (a varchar(20));
insert into t1 values ('foo');
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 75d9582a23c..b53b49bd0dd 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1499,4 +1499,24 @@ SELECT 1 FROM t1 GROUP BY @b := @a, @b;
1
1
DROP TABLE t1;
+CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
+Warnings:
+Note 1265 Data truncated for column 'f1' at row 1
+DESC t1;
+Field Type Null Key Default Extra
+f1 decimal(31,30) NO 0.000000000000000000000000000000
+SELECT f1 FROM t1;
+f1
+0.123456789012345678901234567890
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
+Warnings:
+Warning 1264 Out of range value adjusted for column 'f1' at row 1
+DESC t1;
+Field Type Null Key Default Extra
+f1 decimal(59,30) NO 0.000000000000000000000000000000
+SELECT f1 FROM t1;
+f1
+99999999999999999999999999999.999999999999999999999999999999
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 0e9e141f6d8..b6654df4ecb 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -3,7 +3,7 @@
#
--disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
--enable_warnings
select CASE "b" when "a" then 1 when "b" then 2 END;
@@ -152,4 +152,21 @@ SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
DROP TABLE t1,t2;
-# End of 4.1 tests
+
+--echo End of 4.1 tests
+
+#
+# #30782: Truncated UNSIGNED BIGINT columns
+#
+create table t1 (a int, b bigint unsigned);
+create table t2 (c int);
+insert into t1 (a, b) values (1,4572794622775114594), (2,18196094287899841997),
+ (3,11120436154190595086);
+insert into t2 (c) values (1), (2), (3);
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+ join t2 on t1.a=t2.c order by d;
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+ join t2 on t1.a=t2.c where b=11120436154190595086 order by d;
+drop table t1, t2;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test
index 633f3af0d2b..3521a6fc91e 100644
--- a/mysql-test/t/ctype_cp932.test
+++ b/mysql-test/t/ctype_cp932.test
@@ -8,6 +8,10 @@ drop table if exists t3;
drop table if exists t4;
--enable_warnings
+SET @test_character_set= 'cp932';
+SET @test_collation= 'cp932_japanese_ci';
+-- source include/ctype_common.inc
+
set names cp932;
set character_set_database = cp932;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index de2033321b9..3af5bfa54f9 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -548,6 +548,18 @@ select quote(name) from bug20536;
drop table bug20536;
#
+# Bug #31615: crash after set names ucs2 collate xxx
+#
+--error 1231
+set names ucs2;
+--error 1231
+set names ucs2 collate ucs2_bin;
+--error 1231
+set character_set_client= ucs2;
+--error 1231
+set character_set_client= concat('ucs', substr('2', 1));
+
+#
# BUG#31159 - fulltext search on ucs2 column crashes server
#
CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci);
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index b09472d3485..db01aade3ca 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -252,3 +252,12 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1);
INSERT DELAYED INTO t2 VALUES(1);
DROP TABLE t1, t2;
+#
+# Bug #32676: insert delayed crash with wrong column and function specified
+#
+CREATE TABLE t1 (a INT);
+--error ER_BAD_FIELD_ERROR
+INSERT DELAYED INTO t1 SET b= b();
+DROP TABLE t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index 3a4f2f2f5f2..72efa8a2ee6 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -133,4 +133,35 @@ disconnect con3;
connection default;
drop table t1, t2;
+#
+# Bug#32528 Global read lock with a low priority write lock causes a server crash
+#
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+set session low_priority_updates=1;
+
+create table t1 (a int);
+create table t2 (b int);
+
+lock tables t1 write;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+unlock tables;
+
+lock tables t1 read, t2 write;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+unlock tables;
+
+lock tables t1 read;
+flush tables with read lock;
+unlock tables;
+
+drop table t1, t2;
+
+set session low_priority_updates=default;
+
# End of 5.0 tests
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 2c34f77b1ff..844e60ab7ae 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -204,5 +204,23 @@ SELECT NAME_CONST('test', 1.0);
SELECT NAME_CONST('test', -1.0);
SELECT NAME_CONST('test', 'test');
---echo End of 5.0 tests
+#
+# Bug #32559: connection hangs on query with name_const
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (), (), ();
+--error ER_WRONG_ARGUMENTS
+SELECT NAME_CONST(a, '1') FROM t1;
+--error ER_WRONG_ARGUMENTS
+SET INSERT_ID= NAME_CONST(a, a);
+DROP TABLE t1;
+#
+# Bug #31349: ERROR 1062 (23000): Duplicate entry '' for key 'group_key'
+#
+create table t1 (a int not null);
+insert into t1 values (-1), (-2);
+select min(a) from t1 group by inet_ntoa(a);
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 1d11a669811..ed95d90c8f8 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -1122,6 +1122,7 @@ DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
+DROP USER mysqltest_2@localhost;
#
# Bug#27878: Unchecked privileges on a view referring to a table from another
@@ -1147,6 +1148,7 @@ connection default;
REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost';
REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
+DROP USER mysqltest_1@localhost;
DROP DATABASE db27878;
use test;
DROP TABLE t1;
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index f64efd600c5..13aa6afd701 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -960,4 +960,13 @@ SELECT * FROM t1 ORDER BY b DESC, a ASC;
DROP TABLE t1;
+#
+# Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0
+#
+create table t1(a char(10) not null, unique key aa(a(1)),
+ b char(4) not null, unique key bb(b(4))) engine=innodb;
+desc t1;
+show create table t1;
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 76177403bd0..0b5a12fa523 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -353,5 +353,106 @@ SELECT * FROM t2;
DROP TABLE t1, t2;
+#
+# Bug #26788: mysqld (debug) aborts when inserting specific numbers into char
+# fields
+#
+
+CREATE TABLE t1 (
+ a char(20) NOT NULL,
+ b char(7) DEFAULT NULL,
+ c char(4) DEFAULT NULL
+);
+
+INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
+INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
+INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
+INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
+INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
+INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
+INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
+INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
+INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
+INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
+INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
+INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
+INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
+INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
+INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
+INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
+INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
+INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
+INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
+INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
+# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
+# "1.3e+78" due to different rounding rules
+--replace_result 12.3 12.2 1.3e+78 1.2e+78
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a char(20) NOT NULL,
+ b char(7) DEFAULT NULL,
+ c char(5)
+);
+
+
+INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
+INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
+INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
+INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
+INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
+INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
+INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
+INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
+INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
+INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
+INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
+INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
+INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
+INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
+INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
+INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
+INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
+INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
+INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
+INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
+INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
+
+# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
+# "1.3e+78" due to different rounding rules
+--replace_result 12.3 12.2 1.3e+78 1.2e+78
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+#
+# Bug #31152: assertion in Field_str::store(double)
+#
+
+CREATE TABLE t (a CHAR(10),b INT);
+INSERT INTO t VALUES (),(),();
+INSERT INTO t(a) SELECT rand() FROM t;
+DROP TABLE t;
+
+#
+# Bug #30453: String not cast to int correctly
+#
+
+CREATE TABLE t1 (c1 INT NOT NULL);
+INSERT INTO t1 VALUES(4188.32999999999992724042385816574096679687500),
+('4188.32999999999992724042385816574096679687500'), (4188);
+SELECT * FROM t1;
+
+CREATE TABLE t2 (c1 BIGINT);
+INSERT INTO t2 VALUES('15449237462.0000000000');
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index 3d0e68dc0f3..f63336a9864 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -443,4 +443,22 @@ ALTER TABLE t1 DISABLE KEYS;
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
DROP TABLE t1;
+#
+# Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0
+#
+create table t1(a int not null, key aa(a),
+ b char(10) not null, unique key bb(b(1)),
+ c char(4) not null, unique key cc(c));
+desc t1;
+show create table t1;
+drop table t1;
+create table t1(a int not null, key aa(a),
+ b char(10) not null, unique key bb(b(1)),
+ c char(4) not null);
+desc t1;
+alter table t1 add unique key cc(c);
+desc t1;
+show create table t1;
+drop table t1;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index d670bb55a18..649c1a4efbd 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -249,4 +249,36 @@ reap;
connection locker;
drop table t1;
+#
+# Bug#31479 Bad lock interaction if CREATE TABLE LIKE is killed
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+--echo connection: locker
+connection locker;
+lock tables t1 read;
+--echo connection: writer
+connection writer;
+let $ID= `select connection_id()`;
+--send create table t2 like t1;
+--echo connection: default
+connection default;
+let $show_type= open tables where in_use=2 and name_locked=1;
+let $show_pattern= '%t1%2%1';
+--source include/wait_show_pattern.inc
+--echo kill query
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection writer;
+--error ER_QUERY_INTERRUPTED
+--reap
+connection locker;
+unlock tables;
+connection default;
+drop table t1;
+
# End of 5.0 tests
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index b5c1a01fe8e..b6debadcc94 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -1,5 +1,5 @@
#
-# test of MERGE TABLES
+# Test of MERGE TABLES
#
--disable_warnings
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index f4e18d4004f..04e7b6b4bdb 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -2,7 +2,7 @@
#
--disable_warnings
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
drop view if exists v1;
drop database if exists client_test_db;
--enable_warnings
@@ -31,4 +31,13 @@ create view v1 as select * from t1;
drop view v1;
drop table t1;
+#
+# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
+#
+create table `t``1`(a int);
+create table `t 1`(a int);
+--replace_result 'Table is already up to date' OK
+--exec $MYSQL_CHECK --databases test
+drop table `t``1`, `t 1`;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index cd2fc44e3ce..c1505ffd645 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -1210,6 +1210,16 @@ EXECUTE st1;
DEALLOCATE PREPARE st1;
DROP TABLE t1;
+
+#
+# Bug #32137: prepared statement crash with str_to_date in update clause
+#
+create table t1 (a int, b tinyint);
+prepare st1 from 'update t1 set b= (str_to_date(a, a))';
+execute st1;
+deallocate prepare st1;
+drop table t1;
+
--echo End of 4.1 tests.
############################# 5.0 tests start ################################
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index ed3abb12140..9aa8c00d24a 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -116,15 +116,10 @@ drop table if exists t1;
# Check conversion of floats to character field (Bug #7774)
create table t1 (c char(20));
insert into t1 values (5e-28);
-# Expected result is "5e-28", but windows returns "5e-028"
---replace_result 5e-028 5e-28
select * from t1;
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
-# Expected result is "2e+06", but windows returns "2e+006"
-# Expected result is "2e-05", but windows returns "2e-005"
---replace_result 2e+006 2e+06 2e-005 2e-05
select * from t1;
drop table t1;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 5a631b6163e..cb7e0c4163a 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1195,6 +1195,25 @@ SELECT 1 FROM t1 GROUP BY @b := @a, @b;
DROP TABLE t1;
---echo End of 5.0 tests
+#
+# Bug #24907: unpredictable (display) precission, if input precission
+# increases
+#
+# As per 10.1.1. Overview of Numeric Types, type (new) DECIMAL has a
+# maxmimum precision of 30 places after the decimal point. Show that
+# temp field creation beyond that works and throws a truncation warning.
+# DECIMAL(37,36) should be adjusted to DECIMAL(31,30).
+CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
+DESC t1;
+SELECT f1 FROM t1;
+DROP TABLE t1;
+# too many decimal places, AND too many digits altogether (90 = 45+45).
+# should preserve integers (65 = 45+20)
+CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
+DESC t1;
+SELECT f1 FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.0 tests
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 83363e6960d..baf3bffccb8 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -2268,7 +2268,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
As all blocks referred in 'cache' are marked by BLOCK_IN_FLUSH
we are guarunteed no thread will change them
*/
- qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
+ my_qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
keycache_pthread_mutex_lock(&keycache->cache_lock);
for ( ; cache != end ; cache++)
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 3d52d56c952..4b3ecb603a6 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -91,10 +91,10 @@ typedef struct st_stack
*****************************************************************************/
#ifdef QSORT_EXTRA_CMP_ARGUMENT
-qsort_t qsort2(void *base_ptr, size_t count, size_t size, qsort2_cmp cmp,
+qsort_t my_qsort2(void *base_ptr, size_t count, size_t size, qsort2_cmp cmp,
void *cmp_argument)
#else
-qsort_t qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
+qsort_t my_qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
#endif
{
char *low, *high, *pivot;
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index e7fd6873eee..a0c74642cb0 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -35,7 +35,7 @@ void my_string_ptr_sort(void *base, uint items, size_s size)
if (size && items)
{
uint size_arg=size;
- qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
+ my_qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
}
}
}
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 61de4ff9065..a076a0c971d 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -187,7 +187,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_RETURN(result);
@@ -498,7 +498,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_PRINT("exit", ("found %d files", result->number_off_files));
DBUG_RETURN(result);
@@ -605,7 +605,7 @@ MY_DIR *my_dir(const char* path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_RETURN(result);
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 4c3d187e4e8..9ff7babab31 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -29,6 +29,10 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
Filedes, (long) Buffer, Count, MyFlags));
errors=0; written=0L;
+ /* The behavior of write(fd, buf, 0) is not portable */
+ if (unlikely(!Count))
+ DBUG_RETURN(0);
+
for (;;)
{
if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == Count)
diff --git a/mysys/queues.c b/mysys/queues.c
index 7809c97131c..6b88420a1cd 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -250,6 +250,6 @@ static int queue_fix_cmp(QUEUE *queue, void **a, void **b)
void queue_fix(QUEUE *queue)
{
- qsort2(queue->root+1,queue->elements, sizeof(void *),
- (qsort2_cmp)queue_fix_cmp, queue);
+ my_qsort2(queue->root+1,queue->elements, sizeof(void *),
+ (qsort2_cmp)queue_fix_cmp, queue);
}
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 257deed3d28..bc887c83088 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -30,13 +30,15 @@ user=""
force=0
in_rpm=0
ip_only=0
-windows=0
+cross_bootstrap=0
usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
--basedir=path The path to the MySQL installation directory.
+ --cross-bootstrap For internal use. Used when building the MySQL system
+ tables on a different host than the target.
--datadir=path The path to the MySQL data directory.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
@@ -56,8 +58,6 @@ Usage: $0 [OPTIONS]
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
- --windows For internal use. This option is used for creating
- Windows distributions.
All other options are passed to the mysqld program
@@ -67,7 +67,7 @@ EOF
s_echo()
{
- if test "$in_rpm" -eq 0 -a "$windows" -eq 0
+ if test "$in_rpm" -eq 0 -a "$cross_bootstrap" -eq 0
then
echo "$1"
fi
@@ -109,16 +109,17 @@ parse_arguments()
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$arg" ;;
- --windows)
- # This is actually a "cross bootstrap" argument used when
- # building the MySQL system tables on a different host
- # than the target. The platform independent
- # files that are created in --datadir on the host can
- # be copied to the target system, the most common use for
- # this feature is in the windows installer which will take
- # the files from datadir and include them as part of the install
- # package.
- windows=1 ;;
+ --cross-bootstrap|--windows)
+ # Used when building the MySQL system tables on a different host than
+ # the target. The platform-independent files that are created in
+ # --datadir on the host can be copied to the target system.
+ #
+ # The most common use for this feature is in the Windows installer
+ # which will take the files from datadir and include them as part of
+ # the install package. See top-level 'dist-hook' make target.
+ #
+ # --windows is a deprecated alias
+ cross_bootstrap=1 ;;
*)
if test -n "$pick_args"
@@ -213,8 +214,8 @@ then
pkgdatadir="@pkgdatadir@"
else
bindir="$basedir/bin"
- # We set up bootstrap-specific paths later, so skip this for --windows
- if test "$windows" -eq 0
+ # We set up bootstrap-specific paths later, so skip this for now
+ if test "$cross_bootstrap" -eq 0
then
pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
if test -z "$pkgdatadir"
@@ -256,8 +257,8 @@ do
fi
done
-# Set up Windows-specific paths
-if test "$windows" -eq 1
+# Set up bootstrap-specific paths
+if test "$cross_bootstrap" -eq 1
then
mysqld="./sql/mysqld"
if test -n "$srcdir" -a -f "$srcdir/sql/share/english/errmsg.sys"
@@ -280,7 +281,7 @@ fi
hostname=`@HOSTNAME@`
# Check if hostname is valid
-if test "$windows" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
+if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then
resolved=`$bindir/resolveip $hostname 2>&1`
if [ $? -ne 0 ]
@@ -329,6 +330,16 @@ then
args="$args --user=$user"
fi
+# When doing a "cross bootstrap" install, no reference to the current
+# host should be added to the system tables. So we filter out any
+# lines which contain the current host name.
+if test $cross_bootstrap -eq 1
+then
+ filter_cmd_line="sed -e '/@current_hostname/d'"
+else
+ filter_cmd_line="cat"
+fi
+
# Peform the install of system tables
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
@@ -337,15 +348,14 @@ mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
# Pipe mysql_system_tables.sql to "mysqld --bootstrap"
s_echo "Installing MySQL system tables..."
-if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld_install_cmd_line`
+if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/null
then
s_echo "OK"
s_echo "Filling help tables..."
# Pipe fill_help_tables.sql to "mysqld --bootstrap"
- if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line`
+ if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null
then
- # Fill suceeded
s_echo "OK"
else
echo
@@ -359,14 +369,12 @@ then
s_echo "support-files/mysql.server to the right place for your system"
s_echo
- if test "$windows" -eq 0
+ if test "$cross_bootstrap" -eq 0
then
- # A root password should of course also be set on Windows!
- # The reason for not displaying these prompts here is that when
- # executing this script with the --windows argument the script
- # is used to generate system tables mainly used by the
- # windows installer. And thus the password should not be set until
- # those files has been copied to the target system
+ # This is not a true installation on a running system. The end user must
+ # set a password after installing the data files on the real host system.
+ # At this point, there is no end user, so it does not make sense to print
+ # this reminder.
echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
echo "To do so, start the server, then issue the following commands:"
echo "$bindir/mysqladmin -u root password 'new-password'"
diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql
index 47d4ea5d950..ce23953a1a5 100644
--- a/scripts/mysql_system_tables_data.sql
+++ b/scripts/mysql_system_tables_data.sql
@@ -2,6 +2,12 @@
-- The inital data for system tables of MySQL Server
--
+-- When setting up a "cross bootstrap" database (e.g., creating data on a Unix
+-- host which will later be included in a Windows zip file), any lines
+-- containing "@current_hostname" are filtered out by mysql_install_db.
+set @current_hostname= @@hostname;
+
+
-- Fill "db" table with default grants for anyone to
-- access database 'test' and 'test_%' if "db" table didn't exist
CREATE TEMPORARY TABLE tmp_db LIKE db;
@@ -15,10 +21,9 @@ DROP TABLE tmp_db;
-- from local machine if "users" table didn't exist before
CREATE TEMPORARY TABLE tmp_user LIKE user;
INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
-set @hostname= @@hostname;
-REPLACE INTO tmp_user VALUES (@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+REPLACE INTO tmp_user VALUES (@current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO tmp_user (host,user) VALUES ('localhost','');
-INSERT INTO tmp_user (host,user) VALUES (@@hostname,'');
+INSERT INTO tmp_user (host,user) VALUES (@current_hostname,'');
INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
DROP TABLE tmp_user;
diff --git a/sql-common/client.c b/sql-common/client.c
index cb1d224ef2e..1fc73549520 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1085,11 +1085,16 @@ void mysql_read_default_options(struct st_mysql_options *options,
my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME));
break;
+ case 26: /* ssl_cipher */
+ my_free(options->ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
+ options->ssl_cipher= my_strdup(opt_arg, MYF(MY_WME));
+ break;
#else
case 13: /* Ignore SSL options */
case 14:
case 15:
case 16:
+ case 26:
break;
#endif /* HAVE_OPENSSL */
case 17: /* charset-lib */
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc
index 2c5226222e2..0d1d821cf17 100644
--- a/sql/examples/ha_tina.cc
+++ b/sql/examples/ha_tina.cc
@@ -852,7 +852,7 @@ int ha_tina::rnd_end()
It also sorts so that we move the final blocks to the
beginning so that we move the smallest amount of data possible.
*/
- qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set);
+ my_qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set);
for (ptr= chain; ptr < chain_ptr; ptr++)
{
memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end,
diff --git a/sql/field.cc b/sql/field.cc
index 86853389c64..0a7c6a04f39 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5934,24 +5934,74 @@ int Field_str::store(double nr)
{
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
uint length;
- bool use_scientific_notation= TRUE;
uint local_char_length= field_length / charset()->mbmaxlen;
- /*
- Check fabs(nr) against longest value that can be stored in field,
- which depends on whether the value is < 1 or not, and negative or not
- */
double anr= fabs(nr);
+ bool fractional= (anr != floor(anr));
int neg= (nr < 0.0) ? 1 : 0;
- if (local_char_length > 4 && local_char_length < 32 &&
- (anr < 1.0 ? anr > 1/(log_10[max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
- : anr < log_10[local_char_length-neg]-1))
- use_scientific_notation= FALSE;
-
- length= (uint) my_sprintf(buff, (buff, "%-.*g",
- (use_scientific_notation ?
- max(0, (int)local_char_length-neg-5) :
- local_char_length),
- nr));
+ uint max_length;
+ int exp;
+ uint digits;
+ uint i;
+
+ /* Calculate the exponent from the 'e'-format conversion */
+ if (anr < 1.0 && anr > 0)
+ {
+ for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100);
+ for (; anr < 1e-10; exp-= 10, anr*= 1e10);
+ for (i= 1; anr < 1 / log_10[i]; exp--, i++);
+ exp--;
+ }
+ else
+ {
+ for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100);
+ for (; anr > 1e10; exp+= 10, anr/= 1e10);
+ for (i= 1; anr > log_10[i]; exp++, i++);
+ }
+
+ max_length= local_char_length - neg;
+
+ /*
+ Since in sprintf("%g") precision means the number of significant digits,
+ calculate the maximum number of significant digits if the 'f'-format
+ would be used (+1 for decimal point if the number has a fractional part).
+ */
+ digits= max(0, (int) max_length - fractional);
+ /*
+ If the exponent is negative, decrease digits by the number of leading zeros
+ after the decimal point that do not count as significant digits.
+ */
+ if (exp < 0)
+ digits= max(0, (int) digits + exp);
+ /*
+ 'e'-format is used only if the exponent is less than -4 or greater than or
+ equal to the precision. In this case we need to adjust the number of
+ significant digits to take "e+NN" + decimal point into account (hence -5).
+ We also have to reserve one additional character if abs(exp) >= 100.
+ */
+ if (exp >= (int) digits || exp < -4)
+ digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
+
+ /* Limit precision to DBL_DIG to avoid garbage past significant digits */
+ set_if_smaller(digits, DBL_DIG);
+
+ length= (uint) my_sprintf(buff, (buff, "%-.*g", digits, nr));
+
+#ifdef __WIN__
+ /*
+ Windows always zero-pads the exponent to 3 digits, we want to remove the
+ leading 0 to match the sprintf() output on other platforms.
+ */
+ if ((exp >= (int) digits || exp < -4) && exp > -100 && exp < 100)
+ {
+ DBUG_ASSERT(length >= 6); /* 1e+NNN */
+ uint tmp= length - 3;
+ buff[tmp]= buff[tmp + 1];
+ tmp++;
+ buff[tmp]= buff[tmp + 1];
+ length--;
+ }
+#endif
+
/*
+1 below is because "precision" in %g above means the
max. number of significant digits, not the output width.
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index ae0284fb202..a24486385fd 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -173,7 +173,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
pos= table_arg->key_info;
for (i= 0; i < share->keys; i++, pos++)
{
- keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
+ keydef[i].flag= ((uint16) pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
diff --git a/sql/item.cc b/sql/item.cc
index 431d82af331..a75d0159848 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1209,7 +1209,17 @@ bool Item_name_const::is_null()
Item::Type Item_name_const::type() const
{
- return value_item->type();
+ /*
+ As
+ 1. one can try to create the Item_name_const passing non-constant
+ arguments, although it's incorrect and
+ 2. the type() method can be called before the fix_fields() to get
+ type information for a further type cast, e.g.
+ if (item->type() == FIELD_ITEM)
+ ((Item_field *) item)->...
+ we return NULL_ITEM in the case to avoid wrong casting.
+ */
+ return valid_args ? value_item->type() : NULL_ITEM;
}
diff --git a/sql/item.h b/sql/item.h
index a1135c2c725..fbf4b94b276 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1111,11 +1111,13 @@ class Item_name_const : public Item
{
Item *value_item;
Item *name_item;
+ bool valid_args;
public:
Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
- if(!value_item->basic_const_item())
+ if (!(valid_args= name_item->basic_const_item() &
+ value_item->basic_const_item()))
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index d244aadf5b4..ee7a929024e 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2597,6 +2597,23 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
}
+void Item_func_case::agg_str_lengths(Item* arg)
+{
+ set_if_bigger(max_length, arg->max_length);
+ set_if_bigger(decimals, arg->decimals);
+ unsigned_flag= unsigned_flag && arg->unsigned_flag;
+}
+
+
+void Item_func_case::agg_num_lengths(Item *arg)
+{
+ uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
+ arg->unsigned_flag) - arg->decimals;
+ set_if_bigger(max_length, len);
+ set_if_bigger(decimals, arg->decimals);
+ unsigned_flag= unsigned_flag && arg->unsigned_flag;
+}
+
void Item_func_case::fix_length_and_dec()
{
@@ -2646,15 +2663,22 @@ void Item_func_case::fix_length_and_dec()
max_length=0;
decimals=0;
- for (uint i=0 ; i < ncases ; i+=2)
+ unsigned_flag= TRUE;
+ if (cached_result_type == STRING_RESULT)
{
- set_if_bigger(max_length,args[i+1]->max_length);
- set_if_bigger(decimals,args[i+1]->decimals);
+ for (uint i= 0; i < ncases; i+= 2)
+ agg_str_lengths(args[i + 1]);
+ if (else_expr_num != -1)
+ agg_str_lengths(args[else_expr_num]);
}
- if (else_expr_num != -1)
+ else
{
- set_if_bigger(max_length,args[else_expr_num]->max_length);
- set_if_bigger(decimals,args[else_expr_num]->decimals);
+ for (uint i= 0; i < ncases; i+= 2)
+ agg_num_lengths(args[i + 1]);
+ if (else_expr_num != -1)
+ agg_num_lengths(args[else_expr_num]);
+ max_length= my_decimal_precision_to_length(max_length + decimals, decimals,
+ unsigned_flag);
}
}
@@ -2843,7 +2867,7 @@ static inline int cmp_ulongs (ulonglong a_val, ulonglong b_val)
SYNOPSIS
cmp_longlong()
- cmp_arg an argument passed to the calling function (qsort2)
+ cmp_arg an argument passed to the calling function (my_qsort2)
a left argument
b right argument
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 735081d931f..d250e1b366a 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -758,6 +758,8 @@ public:
void print(String *str);
Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
+ void agg_str_lengths(Item *arg);
+ void agg_num_lengths(Item *arg);
};
@@ -786,7 +788,7 @@ public:
virtual byte *get_value(Item *item)=0;
void sort()
{
- qsort2(base,used_count,size,compare,collation);
+ my_qsort2(base,used_count,size,compare,collation);
}
int find(Item *item);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 264d9265bca..fa7821b589c 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3739,13 +3739,12 @@ longlong Item_func_sleep::val_int()
break;
error= 0;
}
-
+ pthread_mutex_unlock(&LOCK_user_locks);
pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
pthread_mutex_unlock(&thd->mysys_var->mutex);
- pthread_mutex_unlock(&LOCK_user_locks);
pthread_cond_destroy(&cond);
return test(!error); // Return 1 killed
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 7607ebfc761..3648438a69b 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -683,7 +683,12 @@ public:
}
String* val_str(String* str);
const char *func_name() const { return "inet_ntoa"; }
- void fix_length_and_dec() { decimals = 0; max_length=3*8+7; maybe_null=1;}
+ void fix_length_and_dec()
+ {
+ decimals= 0;
+ max_length= 3 * 8 + 7;
+ maybe_null= 1;
+ }
};
class Item_func_quote :public Item_str_func
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 7ed5e375f5b..4ddc788b182 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -3312,38 +3312,42 @@ Field *Item_func_str_to_date::tmp_table_field(TABLE *t_arg)
void Item_func_str_to_date::fix_length_and_dec()
{
- char format_buff[64];
- String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format;
maybe_null= 1;
decimals=0;
cached_field_type= MYSQL_TYPE_DATETIME;
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
- format= args[1]->val_str(&format_str);
- if (!args[1]->null_value && (const_item= args[1]->const_item()))
+ if ((const_item= args[1]->const_item()))
{
- cached_format_type= get_date_time_result_type(format->ptr(),
- format->length());
- switch (cached_format_type) {
- case DATE_ONLY:
- cached_timestamp_type= MYSQL_TIMESTAMP_DATE;
- cached_field_type= MYSQL_TYPE_DATE;
- max_length= MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- break;
- case TIME_ONLY:
- case TIME_MICROSECOND:
- cached_timestamp_type= MYSQL_TIMESTAMP_TIME;
- cached_field_type= MYSQL_TYPE_TIME;
- max_length= MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- break;
- default:
- cached_timestamp_type= MYSQL_TIMESTAMP_DATETIME;
- cached_field_type= MYSQL_TYPE_DATETIME;
- break;
+ char format_buff[64];
+ String format_str(format_buff, sizeof(format_buff), &my_charset_bin);
+ String *format= args[1]->val_str(&format_str);
+ if (!args[1]->null_value)
+ {
+ cached_format_type= get_date_time_result_type(format->ptr(),
+ format->length());
+ switch (cached_format_type) {
+ case DATE_ONLY:
+ cached_timestamp_type= MYSQL_TIMESTAMP_DATE;
+ cached_field_type= MYSQL_TYPE_DATE;
+ max_length= MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
+ break;
+ case TIME_ONLY:
+ case TIME_MICROSECOND:
+ cached_timestamp_type= MYSQL_TIMESTAMP_TIME;
+ cached_field_type= MYSQL_TYPE_TIME;
+ max_length= MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
+ break;
+ default:
+ cached_timestamp_type= MYSQL_TIMESTAMP_DATETIME;
+ cached_field_type= MYSQL_TYPE_DATETIME;
+ break;
+ }
}
}
}
+
bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DATE_TIME_FORMAT date_time_format;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f8705a773c6..2e1b56431a4 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2502,7 +2502,12 @@ static int my_message_sql(uint error, const char *str, myf MyFlags)
thd->query_error= 1; // needed to catch query errors during replication
if (!thd->no_warnings_for_error)
+ {
+ thd->no_warnings_for_error= TRUE;
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
+ thd->no_warnings_for_error= FALSE;
+ }
+
/*
thd->lex->current_select == 0 if lex structure is not inited
(not query command (COM_QUERY))
@@ -4307,8 +4312,13 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
sock == unix_sock ? VIO_LOCALHOST: 0)) ||
my_net_init(&thd->net,vio_tmp))
{
- if (vio_tmp)
- vio_delete(vio_tmp);
+ /*
+ Only delete the temporary vio if we didn't already attach it to the
+ NET object. The destructor in THD will delete any initialized net
+ structure.
+ */
+ if (vio_tmp && thd->net.vio != vio_tmp)
+ vio_delete(vio_tmp);
else
{
(void) shutdown(new_sock, SHUT_RDWR);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 969777d4792..facc8e09c27 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3159,8 +3159,8 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
ROR_SCAN_INFO's.
Step 2: Get best ROR-intersection using an approximate algorithm.
*/
- qsort(tree->ror_scans, tree->n_ror_scans, sizeof(ROR_SCAN_INFO*),
- (qsort_cmp)cmp_ror_scan_info);
+ my_qsort(tree->ror_scans, tree->n_ror_scans, sizeof(ROR_SCAN_INFO*),
+ (qsort_cmp)cmp_ror_scan_info);
DBUG_EXECUTE("info",print_ror_scans_arr(param->table, "ordered",
tree->ror_scans,
tree->ror_scans_end););
@@ -3349,8 +3349,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
bitmap_get_first(&(*scan)->covered_fields);
}
- qsort(ror_scan_mark, ror_scans_end-ror_scan_mark, sizeof(ROR_SCAN_INFO*),
- (qsort_cmp)cmp_ror_scan_info_covering);
+ my_qsort(ror_scan_mark, ror_scans_end-ror_scan_mark, sizeof(ROR_SCAN_INFO*),
+ (qsort_cmp)cmp_ror_scan_info_covering);
DBUG_EXECUTE("info", print_ror_scans_arr(param->table,
"remaining scans",
diff --git a/sql/records.cc b/sql/records.cc
index 3a833c87b7b..f61efc13034 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -497,7 +497,8 @@ static int rr_from_cache(READ_RECORD *info)
int3store(ref_position,(long) i);
ref_position+=3;
}
- qsort(info->read_positions,length,info->struct_length,(qsort_cmp) rr_cmp);
+ my_qsort(info->read_positions, length, info->struct_length,
+ (qsort_cmp) rr_cmp);
position=info->read_positions;
for (i=0 ; i < length ; i++)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 066b879fa6b..1f88509d1b6 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -2229,6 +2229,21 @@ sys_var_character_set_filesystem::set_default(THD *thd, enum_var_type type)
}
+bool sys_var_character_set_client::check(THD *thd, set_var *var)
+{
+ if (sys_var_character_set::check(thd, var))
+ return 1;
+ /* Currently, UCS-2 cannot be used as a client character set */
+ if (var->save_result.charset->mbminlen > 1)
+ {
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
+ var->save_result.charset->csname);
+ return 1;
+ }
+ return 0;
+}
+
+
CHARSET_INFO **
sys_var_character_set_results::ci_ptr(THD *thd, enum_var_type type)
{
@@ -2568,6 +2583,13 @@ end:
int set_var_collation_client::check(THD *thd)
{
+ /* Currently, UCS-2 cannot be used as a client character set */
+ if (character_set_client->mbminlen > 1)
+ {
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
+ character_set_client->csname);
+ return 1;
+ }
return 0;
}
diff --git a/sql/set_var.h b/sql/set_var.h
index 7b3f864f44c..99db38933c2 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -635,6 +635,7 @@ public:
sys_var_character_set(name_arg) {}
void set_default(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
+ bool check(THD *thd, set_var *var);
};
class sys_var_character_set_results :public sys_var_character_set
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 5759d619e7e..e55ba81b117 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -437,14 +437,16 @@ check_routine_name(LEX_STRING ident)
*/
void *
-sp_head::operator new(size_t size)
+sp_head::operator new(size_t size) throw()
{
DBUG_ENTER("sp_head::operator new");
MEM_ROOT own_root;
sp_head *sp;
- init_alloc_root(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
+ init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
sp= (sp_head *) alloc_root(&own_root, size);
+ if (sp == NULL)
+ return NULL;
sp->main_mem_root= own_root;
DBUG_PRINT("info", ("mem_root 0x%lx", (ulong) &sp->mem_root));
DBUG_RETURN(sp);
@@ -455,6 +457,10 @@ sp_head::operator delete(void *ptr, size_t size)
{
DBUG_ENTER("sp_head::operator delete");
MEM_ROOT own_root;
+
+ if (ptr == NULL)
+ DBUG_VOID_RETURN;
+
sp_head *sp= (sp_head *) ptr;
/* Make a copy of main_mem_root as free_root will free the sp */
@@ -498,6 +504,9 @@ sp_head::init(LEX *lex)
lex->spcont= m_pcont= new sp_pcontext();
+ if (!lex->spcont)
+ DBUG_VOID_RETURN;
+
/*
Altough trg_table_fields list is used only in triggers we init for all
types of stored procedures to simplify reset_lex()/restore_lex() code.
@@ -999,7 +1008,7 @@ sp_head::execute(THD *thd)
DBUG_RETURN(TRUE);
/* init per-instruction memroot */
- init_alloc_root(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
+ init_sql_alloc(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
DBUG_ASSERT(!(m_flags & IS_INVOKED));
m_flags|= IS_INVOKED;
@@ -1821,16 +1830,29 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
}
-// Reset lex during parsing, before we parse a sub statement.
-void
+/**
+ @brief Reset lex during parsing, before we parse a sub statement.
+
+ @param thd Thread handler.
+
+ @return Error state
+ @retval true An error occurred.
+ @retval false Success.
+*/
+
+bool
sp_head::reset_lex(THD *thd)
{
DBUG_ENTER("sp_head::reset_lex");
LEX *sublex;
LEX *oldlex= thd->lex;
+ sublex= new (thd->mem_root)st_lex_local;
+ if (sublex == 0)
+ DBUG_RETURN(TRUE);
+
+ thd->lex= sublex;
(void)m_lex.push_front(oldlex);
- thd->lex= sublex= new st_lex;
/* Reset most stuff. */
lex_start(thd);
@@ -1853,7 +1875,7 @@ sp_head::reset_lex(THD *thd)
sublex->interval_list.empty();
sublex->type= 0;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
// Restore lex during parsing, after we have parsed a sub statement.
@@ -3729,7 +3751,7 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
{
- my_error(ER_OUTOFMEMORY, MYF(0), sizeof(TABLE_LIST));
+ thd->fatal_error();
return NULL;
}
table->db_length= strlen(db);
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 7d042367985..a46ec9433d7 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -182,10 +182,10 @@ public:
Security_context m_security_ctx;
static void *
- operator new(size_t size);
+ operator new(size_t size) throw ();
static void
- operator delete(void *ptr, size_t size);
+ operator delete(void *ptr, size_t size) throw ();
sp_head();
@@ -245,7 +245,7 @@ public:
}
// Resets lex in 'thd' and keeps a copy of the old one.
- void
+ bool
reset_lex(THD *thd);
// Restores lex in 'thd' from our copy, but keeps some status from the
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 1850821a287..134541368e9 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -248,8 +248,8 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
#endif
VOID(push_dynamic(&acl_hosts,(gptr) &host));
}
- qsort((gptr) dynamic_element(&acl_hosts,0,ACL_HOST*),acl_hosts.elements,
- sizeof(ACL_HOST),(qsort_cmp) acl_compare);
+ my_qsort((gptr) dynamic_element(&acl_hosts,0,ACL_HOST*),acl_hosts.elements,
+ sizeof(ACL_HOST),(qsort_cmp) acl_compare);
end_read_record(&read_record_info);
freeze_size(&acl_hosts);
@@ -421,8 +421,8 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
allow_all_hosts=1; // Anyone can connect
}
}
- qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements,
- sizeof(ACL_USER),(qsort_cmp) acl_compare);
+ my_qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements,
+ sizeof(ACL_USER),(qsort_cmp) acl_compare);
end_read_record(&read_record_info);
freeze_size(&acl_users);
@@ -479,8 +479,8 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
#endif
VOID(push_dynamic(&acl_dbs,(gptr) &db));
}
- qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
- sizeof(ACL_DB),(qsort_cmp) acl_compare);
+ my_qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
+ sizeof(ACL_DB),(qsort_cmp) acl_compare);
end_read_record(&read_record_info);
freeze_size(&acl_dbs);
init_check_host();
@@ -1110,8 +1110,8 @@ static void acl_insert_user(const char *user, const char *host,
if (!acl_user.host.hostname ||
(acl_user.host.hostname[0] == wild_many && !acl_user.host.hostname[1]))
allow_all_hosts=1; // Anyone can connect /* purecov: tested */
- qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements,
- sizeof(ACL_USER),(qsort_cmp) acl_compare);
+ my_qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements,
+ sizeof(ACL_USER),(qsort_cmp) acl_compare);
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host();
@@ -1173,8 +1173,8 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
acl_db.access=privileges;
acl_db.sort=get_sort(3,acl_db.host.hostname,acl_db.db,acl_db.user);
VOID(push_dynamic(&acl_dbs,(gptr) &acl_db));
- qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
- sizeof(ACL_DB),(qsort_cmp) acl_compare);
+ my_qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements,
+ sizeof(ACL_DB),(qsort_cmp) acl_compare);
}
diff --git a/sql/sql_array.h b/sql/sql_array.h
index e2e12bee241..dcef457dce7 100644
--- a/sql/sql_array.h
+++ b/sql/sql_array.h
@@ -62,7 +62,7 @@ public:
void sort(CMP_FUNC cmp_func)
{
- qsort(array.buffer, array.elements, sizeof(Elem), (qsort_cmp)cmp_func);
+ my_qsort(array.buffer, array.elements, sizeof(Elem), (qsort_cmp)cmp_func);
}
};
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fd921be1ecf..e79e4db31d2 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -80,7 +80,6 @@ bool Prelock_error_handler::safely_trapped_errors()
return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
}
-
TABLE *unused_tables; /* Used by mysql_test */
HASH open_cache; /* Used by mysql_test */
@@ -2653,7 +2652,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
temporary mem_root for new .frm parsing.
TODO: variables for size
*/
- init_alloc_root(&new_frm_mem, 8024, 8024);
+ init_sql_alloc(&new_frm_mem, 8024, 8024);
thd->current_tablenr= 0;
restart:
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index ba7f1a534ea..69a257a9d37 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -524,7 +524,7 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol,
List_iterator<String> it(*names);
for (pos= pointers; pos!=end; (*pos++= it++));
- qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp);
+ my_qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp);
for (pos= pointers; pos!=end; pos++)
{
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 65d8bb23706..7273fbf74e3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -585,7 +585,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
bool log_on= (thd->options & OPTION_BIN_LOG) ||
(!(thd->security_ctx->master_access & SUPER_ACL));
#endif
- thr_lock_type lock_type = table_list->lock_type;
+ thr_lock_type lock_type;
Item *unused_conds= 0;
DBUG_ENTER("mysql_insert");
@@ -620,6 +620,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
}
+ lock_type= table_list->lock_type;
thd->proc_info="init";
thd->used_tables=0;
@@ -637,7 +638,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
/* mysql_prepare_insert set table_list->table if it was not set */
table= table_list->table;
- lock_type= table_list->lock_type;
context= &thd->lex->select_lex.context;
/*
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index ce56be79744..f216f51b0e4 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1283,11 +1283,11 @@ typedef struct st_lex : public Query_tables_list
struct st_lex_local: public st_lex
{
- static void *operator new(size_t size)
+ static void *operator new(size_t size) throw()
{
return (void*) sql_alloc((uint) size);
}
- static void *operator new(size_t size, MEM_ROOT *mem_root)
+ static void *operator new(size_t size, MEM_ROOT *mem_root) throw()
{
return (void*) alloc_root(mem_root, (uint) size);
}
@@ -1303,3 +1303,4 @@ extern void lex_start(THD *thd);
extern void lex_end(LEX *lex);
extern int MYSQLlex(void *arg, void *yythd);
extern char *skip_rear_comments(CHARSET_INFO *cs, char *begin, char *end);
+
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 16a64c48cdd..fc134cad297 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7070,7 +7070,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
for (; lock_p < end_p; lock_p++)
{
- if ((*lock_p)->type == TL_WRITE)
+ if ((*lock_p)->type >= TL_WRITE_ALLOW_WRITE)
{
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
return 1;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index af3da834a7a..74cbd2c5505 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2659,7 +2659,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg, Protocol *protocol_arg)
last_errno(0),
flags((uint) IS_IN_USE)
{
- init_alloc_root(&main_mem_root, thd_arg->variables.query_alloc_block_size,
+ init_sql_alloc(&main_mem_root, thd_arg->variables.query_alloc_block_size,
thd_arg->variables.query_prealloc_size);
*last_error= '\0';
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f8cbaee0b89..5699f1d1868 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3675,7 +3675,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
{
KEYUSE key_end,*prev,*save_pos,*use;
- qsort(keyuse->buffer,keyuse->elements,sizeof(KEYUSE),
+ my_qsort(keyuse->buffer,keyuse->elements,sizeof(KEYUSE),
(qsort_cmp) sort_keyuse);
bzero((char*) &key_end,sizeof(key_end)); /* Add for easy testing */
@@ -4388,8 +4388,9 @@ choose_plan(JOIN *join, table_map join_tables)
Apply heuristic: pre-sort all access plans with respect to the number of
records accessed.
*/
- qsort(join->best_ref + join->const_tables, join->tables - join->const_tables,
- sizeof(JOIN_TAB*), straight_join?join_tab_cmp_straight:join_tab_cmp);
+ my_qsort(join->best_ref + join->const_tables,
+ join->tables - join->const_tables, sizeof(JOIN_TAB*),
+ straight_join ? join_tab_cmp_straight : join_tab_cmp);
if (straight_join)
{
@@ -4438,6 +4439,17 @@ choose_plan(JOIN *join, table_map join_tables)
ptr1 pointer to first JOIN_TAB object
ptr2 pointer to second JOIN_TAB object
+ NOTES
+ The order relation implemented by join_tab_cmp() is not transitive,
+ i.e. it is possible to choose such a, b and c that (a < b) && (b < c)
+ but (c < a). This implies that result of a sort using the relation
+ implemented by join_tab_cmp() depends on the order in which
+ elements are compared, i.e. the result is implementation-specific.
+ Example:
+ a: dependent = 0x0 table->map = 0x1 found_records = 3 ptr = 0x907e6b0
+ b: dependent = 0x0 table->map = 0x2 found_records = 3 ptr = 0x907e838
+ c: dependent = 0x6 table->map = 0x10 found_records = 2 ptr = 0x907ecd0
+
RETURN
1 if first is bigger
-1 if second is bigger
@@ -8976,9 +8988,43 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
new_field->set_derivation(item->collation.derivation);
break;
case DECIMAL_RESULT:
- new_field= new Field_new_decimal(item->max_length, maybe_null, item->name,
- table, item->decimals, item->unsigned_flag);
+ {
+ uint8 dec= item->decimals;
+ uint8 intg= ((Item_decimal *) item)->decimal_precision() - dec;
+ uint32 len= item->max_length;
+
+ /*
+ Trying to put too many digits overall in a DECIMAL(prec,dec)
+ will always throw a warning. We must limit dec to
+ DECIMAL_MAX_SCALE however to prevent an assert() later.
+ */
+
+ if (dec > 0)
+ {
+ signed int overflow;
+
+ dec= min(dec, DECIMAL_MAX_SCALE);
+
+ /*
+ If the value still overflows the field with the corrected dec,
+ we'll throw out decimals rather than integers. This is still
+ bad and of course throws a truncation warning.
+ +1: for decimal point
+ */
+
+ overflow= my_decimal_precision_to_length(intg + dec, dec,
+ item->unsigned_flag) - len;
+
+ if (overflow > 0)
+ dec= max(0, dec - overflow); // too long, discard fract
+ else
+ len -= item->decimals - dec; // corrected value fits
+ }
+
+ new_field= new Field_new_decimal(len, maybe_null, item->name,
+ table, dec, item->unsigned_flag);
break;
+ }
case ROW_RESULT:
default:
// This case should never be choosen
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0838b805b35..0f4abb48f33 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -361,7 +361,8 @@ int quick_rm_table(enum db_type base,const char *db,
/*
Sort keys in the following order:
- PRIMARY KEY
- - UNIQUE keyws where all column are NOT NULL
+ - UNIQUE keys where all column are NOT NULL
+ - UNIQUE keys that don't contain partial segments
- Other UNIQUE keys
- Normal keys
- Fulltext keys
@@ -372,26 +373,31 @@ int quick_rm_table(enum db_type base,const char *db,
static int sort_keys(KEY *a, KEY *b)
{
- if (a->flags & HA_NOSAME)
+ ulong a_flags= a->flags, b_flags= b->flags;
+
+ if (a_flags & HA_NOSAME)
{
- if (!(b->flags & HA_NOSAME))
+ if (!(b_flags & HA_NOSAME))
return -1;
- if ((a->flags ^ b->flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))
+ if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))
{
/* Sort NOT NULL keys before other keys */
- return (a->flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;
+ return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;
}
if (a->name == primary_key_name)
return -1;
if (b->name == primary_key_name)
return 1;
+ /* Sort keys don't containing partial segments before others */
+ if ((a_flags ^ b_flags) & HA_KEY_HAS_PART_KEY_SEG)
+ return (a_flags & HA_KEY_HAS_PART_KEY_SEG) ? 1 : -1;
}
- else if (b->flags & HA_NOSAME)
+ else if (b_flags & HA_NOSAME)
return 1; // Prefer b
- if ((a->flags ^ b->flags) & HA_FULLTEXT)
+ if ((a_flags ^ b_flags) & HA_FULLTEXT)
{
- return (a->flags & HA_FULLTEXT) ? 1 : -1;
+ return (a_flags & HA_FULLTEXT) ? 1 : -1;
}
/*
Prefer original key order. usable_key_parts contains here
@@ -1421,6 +1427,10 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
else
key_info->flags|= HA_PACK_KEY;
}
+ /* Check if the key segment is partial, set the key flag accordingly */
+ if (length != sql_field->key_length)
+ key_info->flags|= HA_KEY_HAS_PART_KEY_SEG;
+
key_length+=length;
key_part_info++;
@@ -1476,7 +1486,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1);
}
/* Sort keys in optimized order */
- qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY),
+ my_qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY),
(qsort_cmp) sort_keys);
create_info->null_bits= null_fields;
@@ -2761,7 +2771,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
operations on the target table.
*/
if (lock_and_wait_for_table_name(thd, src_table))
- goto err;
+ DBUG_RETURN(res);
pthread_mutex_lock(&LOCK_open);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 92b8b96378f..6e231ef2447 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1582,8 +1582,8 @@ sp_name:
if ($$)
$$->init_qname(YYTHD);
}
- ;
-
+ ;
+
sp_a_chistics:
/* Empty */ {}
| sp_a_chistics sp_chistic {}
@@ -1811,7 +1811,8 @@ sp_decl:
{
LEX *lex= Lex;
- lex->sphead->reset_lex(YYTHD);
+ if (lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
lex->spcont->declare_var_boundary($2);
}
type
@@ -1819,6 +1820,10 @@ sp_decl:
{
LEX *lex= Lex;
sp_pcontext *pctx= lex->spcont;
+ if (pctx == 0)
+ {
+ MYSQL_YYABORT;
+ }
uint num_vars= pctx->context_var_count();
enum enum_field_types var_type= (enum enum_field_types) $4;
Item *dflt_value_item= $5;
@@ -1904,12 +1909,15 @@ sp_decl:
{
i= new sp_instr_hreturn(sp->instructions(), ctx,
ctx->current_var_count());
+ if (i == NULL )
+ MYSQL_YYABORT;
sp->add_instr(i);
}
else
{ /* EXIT or UNDO handler, just jump to the end of the block */
i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
}
@@ -1937,7 +1945,9 @@ sp_decl:
}
i= new sp_instr_cpush(sp->instructions(), ctx, $5,
ctx->current_cursor_count());
- sp->add_instr(i);
+ if ( i==NULL )
+ MYSQL_YYABORT;
+ sp->add_instr(i);
ctx->push_cursor(&$2);
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
@@ -1946,7 +1956,8 @@ sp_decl:
sp_cursor_stmt:
{
- Lex->sphead->reset_lex(YYTHD);
+ if(Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
/* We use statement here just be able to get a better
error message. Using 'select' works too, but will then
@@ -2112,7 +2123,8 @@ sp_proc_stmt:
LEX *lex= thd->lex;
Lex_input_stream *lip= thd->m_lip;
- lex->sphead->reset_lex(thd);
+ if (lex->sphead->reset_lex(thd))
+ MYSQL_YYABORT;
lex->sphead->m_tmp_query= lip->tok_start;
}
statement
@@ -2137,9 +2149,10 @@ sp_proc_stmt:
lex->var_list.is_empty());
if (lex->sql_command != SQLCOM_SET_OPTION)
{
- sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
+ sp_instr_stmt *i= new sp_instr_stmt(sp->instructions(),
lex->spcont, lex);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
/*
Extract the query statement from the tokenizer. The
end is either lex->ptr, if there was no lookahead,
@@ -2157,7 +2170,10 @@ sp_proc_stmt:
sp->restore_lex(thd);
}
| RETURN_SYM
- { Lex->sphead->reset_lex(YYTHD); }
+ {
+ if(Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
+ }
expr
{
LEX *lex= Lex;
@@ -2174,6 +2190,8 @@ sp_proc_stmt:
i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
sp->m_return_field_def.sql_type, lex);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
sp->m_flags|= sp_head::HAS_RETURN;
}
@@ -2216,12 +2234,23 @@ sp_proc_stmt:
uint n;
n= ctx->diff_handlers(lab->ctx, TRUE); /* Exclusive the dest. */
+
if (n)
- sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
+ {
+ sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
+ if (hpop == NULL)
+ MYSQL_YYABORT;
+ sp->add_instr(hpop);
+ }
n= ctx->diff_cursors(lab->ctx, TRUE); /* Exclusive the dest. */
if (n)
- sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
+ {
+ sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
+ sp->add_instr(cpop);
+ }
i= new sp_instr_jump(ip, ctx);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->push_backpatch(i, lab); /* Jumping forward */
sp->add_instr(i);
}
@@ -2246,11 +2275,19 @@ sp_proc_stmt:
n= ctx->diff_handlers(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
- sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
+ {
+ sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
+ sp->add_instr(hpop);
+ }
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
- sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
+ {
+ sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
+ sp->add_instr(cpop);
+ }
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
}
}
@@ -2267,6 +2304,8 @@ sp_proc_stmt:
MYSQL_YYABORT;
}
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
}
| FETCH_SYM sp_opt_fetch_noise ident INTO
@@ -2282,6 +2321,8 @@ sp_proc_stmt:
MYSQL_YYABORT;
}
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
}
sp_fetch_list
@@ -2299,6 +2340,8 @@ sp_proc_stmt:
MYSQL_YYABORT;
}
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
}
;
@@ -2354,7 +2397,10 @@ sp_fetch_list:
;
sp_if:
- { Lex->sphead->reset_lex(YYTHD); }
+ {
+ if (Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
+ }
expr THEN_SYM
{
LEX *lex= Lex;
@@ -2363,7 +2409,8 @@ sp_if:
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
$2, lex);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->add_cont_backpatch(i);
sp->add_instr(i);
@@ -2375,7 +2422,8 @@ sp_if:
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
sp->backpatch(ctx->pop_label());
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
@@ -2404,7 +2452,8 @@ simple_case_stmt:
{
LEX *lex= Lex;
case_stmt_action_case(lex);
- lex->sphead->reset_lex(YYTHD); /* For expr $3 */
+ if (lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT; /* For expr $3 */
}
expr
{
@@ -2453,7 +2502,8 @@ searched_when_clause_list:
simple_when_clause:
WHEN_SYM
{
- Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
+ if (Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT; /* For expr $3 */
}
expr
{
@@ -2474,7 +2524,8 @@ simple_when_clause:
searched_when_clause:
WHEN_SYM
{
- Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
+ if (Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT; /* For expr $3 */
}
expr
{
@@ -2498,6 +2549,8 @@ else_clause_opt:
uint ip= sp->instructions();
sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
ER_SP_CASE_NOT_FOUND);
+ if (i == NULL)
+ MYSQL_YYABORT;
sp->add_instr(i);
}
| ELSE sp_proc_stmts1
@@ -2567,11 +2620,21 @@ sp_unlabeled_control:
sp->backpatch(ctx->last_label()); /* We always have a label */
if ($3.hndlrs)
- sp->add_instr(new sp_instr_hpop(sp->instructions(), ctx,
- $3.hndlrs));
+ {
+ sp_instr_hpop *hpop= new sp_instr_hpop(sp->instructions(), ctx,
+ $3.hndlrs);
+ if (hpop == NULL)
+ MYSQL_YYABORT;
+ sp->add_instr(hpop);
+ }
if ($3.curs)
- sp->add_instr(new sp_instr_cpop(sp->instructions(), ctx,
- $3.curs));
+ {
+ sp_instr_cpop *cpop= new sp_instr_cpop(sp->instructions(), ctx,
+ $3.curs);
+ if (cpop == NULL)
+ MYSQL_YYABORT;
+ sp->add_instr(cpop);
+ }
lex->spcont= ctx->pop_context();
}
| LOOP_SYM
@@ -2581,11 +2644,15 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
lex->sphead->add_instr(i);
}
| WHILE_SYM
- { Lex->sphead->reset_lex(YYTHD); }
+ {
+ if (Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
+ }
expr DO_SYM
{
LEX *lex= Lex;
@@ -2593,7 +2660,8 @@ sp_unlabeled_control:
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$3, lex);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
/* Jumping forward */
sp->push_backpatch(i, lex->spcont->last_label());
sp->new_cont_backpatch(i);
@@ -2606,12 +2674,16 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
-
+ if (i == NULL)
+ MYSQL_YYABORT;
lex->sphead->add_instr(i);
lex->sphead->do_cont_backpatch();
}
| REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
- { Lex->sphead->reset_lex(YYTHD); }
+ {
+ if (Lex->sphead->reset_lex(YYTHD))
+ MYSQL_YYABORT;
+ }
expr END REPEAT_SYM
{
LEX *lex= Lex;
@@ -2620,6 +2692,8 @@ sp_unlabeled_control:
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$5, lab->ip,
lex);
+ if (i == NULL)
+ MYSQL_YYABORT;
lex->sphead->add_instr(i);
lex->sphead->restore_lex(YYTHD);
/* We can shortcut the cont_backpatch here */
@@ -4149,6 +4223,8 @@ select_init2:
select_part2
{
LEX *lex= Lex;
+ if (lex == NULL)
+ MYSQL_YYABORT;
SELECT_LEX * sel= lex->current_select;
if (lex->current_select->set_braces(0))
{
@@ -4508,6 +4584,8 @@ predicate:
$7->push_front($5);
$7->push_front($1);
Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7);
+ if (item == NULL)
+ MYSQL_YYABORT;
item->negate();
$$= item;
}
@@ -4968,7 +5046,8 @@ simple_expr:
{
LEX *lex= Lex;
sp_name *name= new sp_name($1, $3, true);
-
+ if (name == NULL)
+ MYSQL_YYABORT;
name->init_qname(YYTHD);
sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
if ($5)
@@ -5105,8 +5184,9 @@ simple_expr:
as a last choice. This later can lead to ER_SP_DOES_NOT_EXIST.
*/
sp_name *name= new sp_name(db, $1, false);
- if (name)
- name->init_qname(thd);
+ if (name == NULL)
+ MYSQL_YYABORT;
+ name->init_qname(thd);
sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
if ($4)
@@ -8360,7 +8440,8 @@ option_type_value:
QQ: May be we should simply prohibit group assignments in SP?
*/
- Lex->sphead->reset_lex(thd);
+ if (Lex->sphead->reset_lex(thd))
+ MYSQL_YYABORT;
lex= thd->lex;
/* Set new LEX as if we at start of set rule. */
@@ -8525,6 +8606,8 @@ sys_option_value:
it= spv->dflt;
else
it= new Item_null();
+ if (it == NULL)
+ MYSQL_YYABORT;
sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex, TRUE);
lex->sphead->add_instr(sp_set);
@@ -9900,6 +9983,8 @@ sp_tail:
/* Order is important here: new - reset - init */
sp= new sp_head();
+ if (sp == NULL)
+ MYSQL_YYABORT;
sp->reset_thd_mem_root(YYTHD);
sp->init(lex);
sp->m_type= TYPE_ENUM_PROCEDURE;
diff --git a/sql/structs.h b/sql/structs.h
index 28bdd8c1519..bc373fe4b52 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -87,7 +87,7 @@ typedef struct st_key_part_info { /* Info about a key part */
typedef struct st_key {
uint key_length; /* Tot length of key */
- uint flags; /* dupp key and pack flags */
+ ulong flags; /* dupp key and pack flags */
uint key_parts; /* How many key_parts */
uint extra_length;
uint usable_key_parts; /* Should normally be = key_parts */
diff --git a/sql/unireg.cc b/sql/unireg.cc
index d8e63bb78e1..9e6c77d7b62 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -394,7 +394,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
pos[6]=pos[7]=0; // For the future
pos+=8;
key_parts+=key->key_parts;
- DBUG_PRINT("loop", ("flags: %d key_parts: %d at 0x%lx",
+ DBUG_PRINT("loop", ("flags: %lu key_parts: %d at 0x%lx",
key->flags, key->key_parts,
(long) key->key_part));
for (key_part=key->key_part,key_part_end=key_part+key->key_parts ;
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index 42325648037..48c217921b1 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -5359,12 +5359,12 @@ my_wc_mb_cp932(CHARSET_INFO *cs __attribute__((unused)),
static int
my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc, const uchar *s, const uchar *e){
- int hi=s[0];
+ int hi;
if (s >= e)
return MY_CS_TOOSMALL;
- if (hi < 0x80)
+ if ((hi= s[0]) < 0x80)
{
pwc[0]=hi;
return 1;
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 9f5c993dfa0..99e02e02014 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -837,6 +837,7 @@ int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
register char *p, *e;
long int new_val;
uint sign=0;
+ unsigned long int uval = (unsigned long int) val;
e = p = &buffer[sizeof(buffer)-1];
*p= 0;
@@ -845,15 +846,16 @@ int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
{
if (val < 0)
{
- val= -(unsigned long int)val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval= (unsigned long int)0 - uval;
*dst++= '-';
len--;
sign= 1;
}
}
- new_val = (long) ((unsigned long int) val / 10);
- *--p = '0'+ (char) ((unsigned long int) val - (unsigned long) new_val * 10);
+ new_val = (long) (uval / 10);
+ *--p = '0'+ (char) (uval - (unsigned long) new_val * 10);
val = new_val;
while (val != 0)
@@ -876,12 +878,14 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
register char *p, *e;
long long_val;
uint sign= 0;
+ ulonglong uval = (ulonglong)val;
if (radix < 0)
{
if (val < 0)
{
- val = -(ulonglong)val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (ulonglong)0 - uval;
*dst++= '-';
len--;
sign= 1;
@@ -891,22 +895,22 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
e = p = &buffer[sizeof(buffer)-1];
*p= 0;
- if (val == 0)
+ if (uval == 0)
{
*--p= '0';
len= 1;
goto cnv;
}
- while ((ulonglong) val > (ulonglong) LONG_MAX)
+ while (uval > (ulonglong) LONG_MAX)
{
- ulonglong quo=(ulonglong) val/(uint) 10;
- uint rem= (uint) (val- quo* (uint) 10);
+ ulonglong quo= uval/(uint) 10;
+ uint rem= (uint) (uval- quo* (uint) 10);
*--p = '0' + rem;
- val= quo;
+ uval= quo;
}
- long_val= (long) val;
+ long_val= (long) uval;
while (long_val != 0)
{
long quo= long_val/10;
@@ -1538,14 +1542,18 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
else
addon= (*str >= '5');
- for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++)
+ if (!dot)
{
- if (!dot)
- shift++;
+ for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; shift++, str++);
+ if (str < end && *str == '.')
+ {
+ str++;
+ for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
+ }
}
- if (str < end && *str == '.' && !dot)
+ else
{
- str++;
+ shift= dot - str;
for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
}
goto exp;
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index b5353c55e4c..97e5defdec1 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1018,6 +1018,7 @@ int my_l10tostr_ucs2(CHARSET_INFO *cs,
register char *p, *db, *de;
long int new_val;
int sl=0;
+ unsigned long int uval = (unsigned long int) val;
p = &buffer[sizeof(buffer)-1];
*p='\0';
@@ -1027,12 +1028,13 @@ int my_l10tostr_ucs2(CHARSET_INFO *cs,
if (val < 0)
{
sl = 1;
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (unsigned long int)0 - uval;
}
}
- new_val = (long) ((unsigned long int) val / 10);
- *--p = '0'+ (char) ((unsigned long int) val - (unsigned long) new_val * 10);
+ new_val = (long) (uval / 10);
+ *--p = '0'+ (char) (uval - (unsigned long) new_val * 10);
val = new_val;
while (val != 0)
@@ -1065,34 +1067,36 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)),
register char *p, *db, *de;
long long_val;
int sl=0;
+ ulonglong uval= (ulonglong) val;
if (radix < 0)
{
if (val < 0)
{
sl=1;
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (ulonglong)0 - uval;
}
}
p = &buffer[sizeof(buffer)-1];
*p='\0';
- if (val == 0)
+ if (uval == 0)
{
*--p='0';
goto cnv;
}
- while ((ulonglong) val > (ulonglong) LONG_MAX)
+ while (uval > (ulonglong) LONG_MAX)
{
- ulonglong quo=(ulonglong) val/(uint) 10;
- uint rem= (uint) (val- quo* (uint) 10);
+ ulonglong quo= uval/(uint) 10;
+ uint rem= (uint) (uval- quo* (uint) 10);
*--p = '0' + rem;
- val= quo;
+ uval= quo;
}
- long_val= (long) val;
+ long_val= (long) uval;
while (long_val != 0)
{
long quo= long_val/10;
diff --git a/strings/int2str.c b/strings/int2str.c
index 9fc53032819..fba98aac3f1 100644
--- a/strings/int2str.c
+++ b/strings/int2str.c
@@ -57,6 +57,7 @@ int2str(register long int val, register char *dst, register int radix,
register char *p;
long int new_val;
char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;
+ ulong uval= (ulong) val;
if (radix < 0)
{
@@ -65,7 +66,8 @@ int2str(register long int val, register char *dst, register int radix,
if (val < 0)
{
*dst++ = '-';
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (ulong)0 - uval;
}
radix = -radix;
}
@@ -86,8 +88,8 @@ int2str(register long int val, register char *dst, register int radix,
*/
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- new_val=(ulong) val / (ulong) radix;
- *--p = dig_vec[(uchar) ((ulong) val- (ulong) new_val*(ulong) radix)];
+ new_val= uval / (ulong) radix;
+ *--p = dig_vec[(uchar) (uval- (ulong) new_val*(ulong) radix)];
val = new_val;
#ifdef HAVE_LDIV
while (val != 0)
@@ -133,20 +135,22 @@ char *int10_to_str(long int val,char *dst,int radix)
char buffer[65];
register char *p;
long int new_val;
+ unsigned long int uval = (unsigned long int) val;
if (radix < 0) /* -10 */
{
if (val < 0)
{
*dst++ = '-';
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (unsigned long int)0 - uval;
}
}
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- new_val= (long) ((unsigned long int) val / 10);
- *--p = '0'+ (char) ((unsigned long int) val - (unsigned long) new_val * 10);
+ new_val= (long) (uval / 10);
+ *--p = '0'+ (char) (uval - (unsigned long) new_val * 10);
val = new_val;
while (val != 0)
diff --git a/strings/longlong2str.c b/strings/longlong2str.c
index c464abcfccd..d7de5bb0f7c 100644
--- a/strings/longlong2str.c
+++ b/strings/longlong2str.c
@@ -51,13 +51,15 @@ char *longlong2str(longlong val,char *dst,int radix)
char buffer[65];
register char *p;
long long_val;
+ ulonglong uval= (ulonglong) val;
if (radix < 0)
{
if (radix < -36 || radix > -2) return (char*) 0;
if (val < 0) {
*dst++ = '-';
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (ulonglong)0 - uval;
}
radix = -radix;
}
@@ -65,7 +67,7 @@ char *longlong2str(longlong val,char *dst,int radix)
{
if (radix > 36 || radix < 2) return (char*) 0;
}
- if (val == 0)
+ if (uval == 0)
{
*dst++='0';
*dst='\0';
@@ -74,14 +76,14 @@ char *longlong2str(longlong val,char *dst,int radix)
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- while ((ulonglong) val > (ulonglong) LONG_MAX)
+ while (uval > (ulonglong) LONG_MAX)
{
- ulonglong quo=(ulonglong) val/(uint) radix;
- uint rem= (uint) (val- quo* (uint) radix);
+ ulonglong quo= uval/(uint) radix;
+ uint rem= (uint) (uval- quo* (uint) radix);
*--p = _dig_vec_upper[rem];
- val= quo;
+ uval= quo;
}
- long_val= (long) val;
+ long_val= (long) uval;
while (long_val != 0)
{
long quo= long_val/radix;
@@ -100,17 +102,19 @@ char *longlong10_to_str(longlong val,char *dst,int radix)
char buffer[65];
register char *p;
long long_val;
+ ulonglong uval= (ulonglong) val;
if (radix < 0)
{
if (val < 0)
{
*dst++ = '-';
- val = -val;
+ /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
+ uval = (ulonglong)0 - uval;
}
}
- if (val == 0)
+ if (uval == 0)
{
*dst++='0';
*dst='\0';
@@ -119,14 +123,14 @@ char *longlong10_to_str(longlong val,char *dst,int radix)
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- while ((ulonglong) val > (ulonglong) LONG_MAX)
+ while (uval > (ulonglong) LONG_MAX)
{
- ulonglong quo=(ulonglong) val/(uint) 10;
- uint rem= (uint) (val- quo* (uint) 10);
+ ulonglong quo= uval/(uint) 10;
+ uint rem= (uint) (uval- quo* (uint) 10);
*--p = _dig_vec_upper[rem];
- val= quo;
+ uval= quo;
}
- long_val= (long) val;
+ long_val= (long) uval;
while (long_val != 0)
{
long quo= long_val/10;