diff options
author | unknown <marko@hundin.mysql.fi> | 2004-05-07 12:48:01 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-05-07 12:48:01 +0300 |
commit | 6b313c6998c7db489d5e6eabb11c6951a908b6fc (patch) | |
tree | fe6dae678493a5e02087332ba4ea17a93f2dfc37 | |
parent | f1a2e925629b6a2c54d8955af2f5b6c15aca8b8e (diff) | |
parent | e3211fbd6a59c3dc6a97066c97ab86bfc67d382f (diff) | |
download | mariadb-git-6b313c6998c7db489d5e6eabb11c6951a908b6fc.tar.gz |
Merge marko@build.mysql.com:/home/bk/mysql-4.1
into hundin.mysql.fi:/home/marko/j/mysql-4.1
sql/sql_table.cc:
Auto merged
41 files changed, 266 insertions, 137 deletions
diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index b93eab53f23..09a06982842 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -160,6 +160,10 @@ SOURCE="..\strings\ctype-tis620.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-uca.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-ucs2.c" # End Source File # Begin Source File @@ -510,10 +514,6 @@ SOURCE=..\strings\strxnmov.c # End Source File # Begin Source File -SOURCE=..\strings\strxnmov.c -# End Source File -# Begin Source File - SOURCE=..\mysys\thr_mutex.c # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 8b36016f8c1..6a91414a45c 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -179,6 +179,10 @@ SOURCE="..\strings\ctype-tis620.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-uca.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-ucs2.c" # End Source File # Begin Source File diff --git a/VC++Files/myisam_ftdump/myisam_ftdump.dsp b/VC++Files/myisam_ftdump/myisam_ftdump.dsp index 71701f3c656..12a629091e0 100755 --- a/VC++Files/myisam_ftdump/myisam_ftdump.dsp +++ b/VC++Files/myisam_ftdump/myisam_ftdump.dsp @@ -50,7 +50,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/myisam_ftdump.exe" +# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj ..\lib_release\zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/myisam_ftdump.exe" !ELSEIF "$(CFG)" == "myisam_ftdump - Win32 Debug" @@ -75,7 +75,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/myisam_ftdump.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj ..\lib_debug\zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/myisam_ftdump.exe" /pdbtype:sept !ENDIF diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index af75cfa84aa..73c08a8fca0 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -218,6 +218,10 @@ SOURCE=.\derror.cpp # End Source File # Begin Source File +SOURCE=.\discover.cpp +# End Source File +# Begin Source File + SOURCE=..\libmysql\errmsg.c # End Source File # Begin Source File diff --git a/VC++Files/strings/strings.dsp b/VC++Files/strings/strings.dsp index 5755d5d4c99..31d548ed59f 100644 --- a/VC++Files/strings/strings.dsp +++ b/VC++Files/strings/strings.dsp @@ -151,6 +151,10 @@ SOURCE=".\ctype-sjis.c" SOURCE=".\ctype-tis620.c" # End Source File # Begin Source File + +SOURCE=".\ctype-uca.c" +# End Source File +# Begin Source File SOURCE=".\ctype-ucs2.c" # End Source File diff --git a/configure.in b/configure.in index c9738ed63a3..7d7c477e0f2 100644 --- a/configure.in +++ b/configure.in @@ -1851,7 +1851,8 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bzero chsize cuserid fchmod fcntl \ # isinf() could be a function or a macro (HPUX) AC_MSG_CHECKING(for isinf with <math.h>) AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)], - AC_MSG_RESULT(yes) AC_DEFINE(HAVE_ISINF,,[isinf() macro or function]), + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ISINF,,[isinf() macro or function]), AC_MSG_RESULT(no)) CFLAGS="$ORG_CFLAGS" diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index e580603bcb8..f4da839f8e2 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -49,7 +49,7 @@ static struct my_option my_long_options[] = {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Increase the output level", - 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} diff --git a/include/my_global.h b/include/my_global.h index 7540897e6f4..e7d924eb0ca 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -674,7 +674,7 @@ typedef SOCKET_SIZE_TYPE size_socket; #define FLT_MAX ((float)3.40282346638528860e+38) #endif -#ifndef HAVE_ISINF +#if !defined(HAVE_ISINF) && !defined(isinf) #define isinf(X) 0 #endif diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 263142db74f..3eccfcd3be5 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -358,6 +358,14 @@ os_file_set_size( size */ ulint size_high);/* in: most significant 32 bits of size */ /*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file); /* in: file to be truncated */ +/*************************************************************************** Flushes the write buffers of a given file to the disk. */ ibool diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index ff5b30bec0d..3f14a2158ed 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1583,6 +1583,23 @@ error_handling: } /*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file) /* in: file to be truncated */ +{ +#ifdef __WIN__ + HANDLE h = (HANDLE) _get_osfhandle(fileno(file)); + return(SetEndOfFile(h)); +#else /* __WIN__ */ + return(!ftruncate(fileno(file), ftell(file))); +#endif /* __WIN__ */ +} + +/*************************************************************************** Flushes the write buffers of a given file to the disk. */ ibool diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 9dffdbf2f9f..7194dfc1d2f 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -1655,11 +1655,7 @@ loop: mutex_enter(&srv_monitor_file_mutex); rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); -#ifdef __WIN__ - chsize(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#else /* __WIN__ */ - ftruncate(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#endif /* __WIN__ */ + os_file_set_eof(srv_monitor_file); mutex_exit(&srv_monitor_file_mutex); if (srv_print_innodb_tablespace_monitor diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index a9695801e65..1c1ff9bac10 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -62,10 +62,4 @@ int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd); #ifdef EMBEDDED_LIBRARY int init_embedded_server(int argc, char **argv, char **groups); void end_embedded_server(); - -#else -/* Prevent warnings of unused parameters */ -#define init_embedded_server(a,b,c) ((void)a, (void)b, (void)c, 0) -#define end_embedded_server() #endif /*EMBEDDED_LIBRARY*/ - diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6ee2ba438bd..4ecc1bd0584 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -113,7 +113,9 @@ static my_bool org_my_init_done= 0; 1 could not initialize environment (out of memory or thread keys) */ -int STDCALL mysql_server_init(int argc, char **argv, char **groups) +int STDCALL mysql_server_init(int argc __attribute__((unused)), + char **argv __attribute__((unused)), + char **groups __attribute__((unused))) { int result= 0; if (!mysql_client_init) @@ -152,7 +154,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) #if defined(SIGPIPE) && !defined(__WIN__) (void) signal(SIGPIPE, SIG_IGN); #endif +#ifdef EMBEDDED_LIBRARY result= init_embedded_server(argc, argv, groups); +#endif } #ifdef THREAD else @@ -164,7 +168,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) void STDCALL mysql_server_end() { +#ifdef EMBEDDED_LIBRARY end_embedded_server(); +#endif /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) { @@ -3992,7 +3998,8 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) mysql= stmt->mysql->last_used_con; int4store(buff, stmt->stmt_id); /* Send stmt id to server */ - if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT,buff,MYSQL_STMT_HEADER,0,0,1)) + if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff, + MYSQL_STMT_HEADER,0,0,0)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -4054,7 +4061,9 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data) MYSQL_FIELD *field; uchar *null_ptr, bit; uchar *row= (uchar*) data->data; +#ifndef DBUG_OFF uchar *row_end= row + data->length; +#endif null_ptr= row; row+= (stmt->field_count+9)/8; /* skip null bits */ diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 9904242b3e0..216e2ed26f2 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -639,14 +639,21 @@ name aaaaaaaaaaccccc bbbbbbbbbbddddd drop table t1, t2; -create table t1 (c1 INT); -insert into t1 (c1) values ('21474836461'); +create table t1 (c1 INT, c2 INT UNSIGNED); +insert into t1 values ('21474836461','21474836461'); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 +Warning 1265 Data truncated for column 'c2' at row 1 +insert into t1 values ('-21474836461','-21474836461'); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +Warning 1265 Data truncated for column 'c2' at row 1 show warnings; Level Code Message Warning 1265 Data truncated for column 'c1' at row 1 +Warning 1265 Data truncated for column 'c2' at row 1 select * from t1; -c1 -2147483647 +c1 c2 +2147483647 4294967295 +-2147483648 0 drop table t1; diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index eeb838dc72c..1580f51975e 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -88,11 +88,9 @@ create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)); show status like 'key_blocks_used'; Variable_name Value Key_blocks_used 0 -show status like 'The below may fail on 64-bit systems (ingo)'; -Variable_name Value show status like 'key_blocks_unused'; Variable_name Value -Key_blocks_unused 1812 +Key_blocks_unused KEY_BLOCKS_UNUSED insert into t1 values (1, 'qqqq'), (11, 'yyyy'); insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), (3, 1, 'yyyy'), (4, 3, 'zzzz'); @@ -111,11 +109,9 @@ update t2 set i=2 where i=1; show status like 'key_blocks_used'; Variable_name Value Key_blocks_used 4 -show status like 'The below may fail on 64-bit systems (ingo)'; -Variable_name Value show status like 'key_blocks_unused'; Variable_name Value -Key_blocks_unused 1808 +Key_blocks_unused KEY_BLOCKS_UNUSED cache index t1 key (`primary`) in keycache1; Table Op Msg_type Msg_text test.t1 assign_to_keycache status OK @@ -275,11 +271,9 @@ drop table t1,t2,t3; show status like 'key_blocks_used'; Variable_name Value Key_blocks_used 4 -show status like 'The below may fail on 64-bit systems (ingo)'; -Variable_name Value show status like 'key_blocks_unused'; Variable_name Value -Key_blocks_unused 1812 +Key_blocks_unused KEY_BLOCKS_UNUSED set global keycache2.key_buffer_size=0; set global keycache3.key_buffer_size=100; set global keycache3.key_buffer_size=0; diff --git a/mysql-test/r/rpl_server_id2.result b/mysql-test/r/rpl_server_id2.result index d8d805fc0d2..fde7251497a 100644 --- a/mysql-test/r/rpl_server_id2.result +++ b/mysql-test/r/rpl_server_id2.result @@ -20,4 +20,5 @@ select * from t1; n 1 1 +stop slave; drop table t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 24753c28073..c4413c3ef3f 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -385,8 +385,9 @@ drop table t1, t2; # Test case for conversion of long string value to integer (Bug #3472) # -create table t1 (c1 INT); -insert into t1 (c1) values ('21474836461'); +create table t1 (c1 INT, c2 INT UNSIGNED); +insert into t1 values ('21474836461','21474836461'); +insert into t1 values ('-21474836461','-21474836461'); show warnings; select * from t1; drop table t1; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index ca846a31def..b45df8eb58e 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -67,8 +67,12 @@ create table t1 (p int primary key, a char(10)) delay_key_write=1; create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)); show status like 'key_blocks_used'; -show status like 'The below may fail on 64-bit systems (ingo)'; -show status like 'key_blocks_unused'; # This may fail on 64-bit systems (ingo) + +# Following results differs on 64 and 32 bit systems because of different +# pointer sizes, which takes up different amount of space in key cache + +--replace_result 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED +show status like 'key_blocks_unused'; insert into t1 values (1, 'qqqq'), (11, 'yyyy'); insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), @@ -80,8 +84,8 @@ update t1 set p=2 where p=1; update t2 set i=2 where i=1; show status like 'key_blocks_used'; -show status like 'The below may fail on 64-bit systems (ingo)'; -show status like 'key_blocks_unused'; # This may fail on 64-bit systems (ingo) +--replace_result 1808 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED +show status like 'key_blocks_unused'; cache index t1 key (`primary`) in keycache1; @@ -142,8 +146,8 @@ cache index t1,t2 in default; drop table t1,t2,t3; show status like 'key_blocks_used'; -show status like 'The below may fail on 64-bit systems (ingo)'; -show status like 'key_blocks_unused'; # This may fail on 64-bit systems (ingo) +--replace_result 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED +show status like 'key_blocks_unused'; # Cleanup # We don't reset keycache2 as we want to ensure that mysqld will reset it diff --git a/mysql-test/t/rpl_server_id2.test b/mysql-test/t/rpl_server_id2.test index f022ab13188..dc8f733b7ed 100644 --- a/mysql-test/t/rpl_server_id2.test +++ b/mysql-test/t/rpl_server_id2.test @@ -18,4 +18,8 @@ insert into t1 values (1); save_master_pos; sync_with_master; select * from t1; # check that indeed 2 were inserted +# We stop the slave before cleaning up otherwise we'll get +# 'drop table t1' executed twice, so an error in the slave.err +# (not critical). +stop slave; drop table t1; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index adf3ac0d6a0..201ec8f183f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4817,7 +4817,7 @@ innodb_show_status( rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); flen = ftell(srv_monitor_file); - my_chsize(fileno(srv_monitor_file), flen, 0, MYF(0)); + os_file_set_eof(srv_monitor_file); if(flen > 64000 - 1) { flen = 64000 - 1; } diff --git a/sql/handler.h b/sql/handler.h index ac5dceba8ab..27ef0e263b6 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -322,11 +322,11 @@ public: { return (my_errno=HA_ERR_WRONG_COMMAND); } - virtual int handler::read_range_first(const key_range *start_key, + virtual int read_range_first(const key_range *start_key, const key_range *end_key, bool sorted); - virtual int handler::read_range_next(bool eq_range); - int handler::compare_key(key_range *range); + virtual int read_range_next(bool eq_range); + int compare_key(key_range *range); virtual int ft_init() { return -1; } virtual FT_INFO *ft_init_ext(uint flags,uint inx,const byte *key, uint keylen) diff --git a/sql/item.cc b/sql/item.cc index 2dabb8e26ef..11a9e88bdd6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -503,6 +503,22 @@ Item *Item_field::get_tmp_table_item(THD *thd) } +/* + Create an item from a string we KNOW points to a valid longlong/ulonglong + end \0 terminated number string +*/ + +Item_int::Item_int(const char *str_arg, uint length) +{ + char *end_ptr= (char*) str_arg + length; + int error; + value= my_strtoll10(str_arg, &end_ptr, &error); + max_length= (uint) (end_ptr - str_arg); + name= (char*) str_arg; + fixed= 1; +} + + String *Item_int::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor @@ -519,6 +535,13 @@ void Item_int::print(String *str) } +Item_uint::Item_uint(const char *str_arg, uint length): + Item_int(str_arg, length) +{ + unsigned_flag= 1; +} + + String *Item_uint::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor diff --git a/sql/item.h b/sql/item.h index 780e2fcadac..99a0516e439 100644 --- a/sql/item.h +++ b/sql/item.h @@ -456,10 +456,7 @@ public: #endif Item_int(const char *str_arg,longlong i,uint length) :value(i) { max_length=length; name=(char*) str_arg; fixed= 1; } - Item_int(const char *str_arg) : - value(str_arg[0] == '-' ? strtoll(str_arg,(char**) 0,10) : - (longlong) strtoull(str_arg,(char**) 0,10)) - { max_length= (uint) strlen(str_arg); name=(char*) str_arg; fixed= 1; } + Item_int(const char *str_arg, uint length=64); enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } @@ -479,9 +476,7 @@ public: class Item_uint :public Item_int { public: - Item_uint(const char *str_arg, uint length) : - Item_int(str_arg, (longlong) strtoull(str_arg, (char**) 0,10), length) - { unsigned_flag= 1; } + Item_uint(const char *str_arg, uint length); Item_uint(uint32 i) :Item_int((longlong) i, 10) { unsigned_flag= 1; } double val() diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index d654bec4f4e..ef80c060c03 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -96,7 +96,8 @@ protected: bool save_cache; public: Item_in_optimizer(Item *a, Item_in_subselect *b): - Item_bool_func(a, (Item *)b), cache(0), save_cache(0) {} + Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0), save_cache(0) + {} bool fix_fields(THD *, struct st_table_list *, Item **); bool fix_left(THD *thd, struct st_table_list *tables, Item **ref); bool is_null(); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index e68c882ba3e..6d8f5353695 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -140,7 +140,7 @@ public: void fix_length_and_dec(); uint cols(); - Item* el(uint i) { return (Item*)row[i]; } + Item* el(uint i) { return my_reinterpret_cast(Item*)(row[i]); } Item** addr(uint i) { return (Item**)row + i; } bool check_cols(uint c); bool null_inside(); diff --git a/sql/item_sum.h b/sql/item_sum.h index d7753303f55..4cded41a9f6 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -735,8 +735,12 @@ class Item_func_group_concat : public Item_sum } longlong val_int() { - String *res; res=val_str(&str_value); - return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0; + String *res; + char *end_ptr; + int error; + res= val_str(&str_value); + end_ptr= (char*) res->ptr()+ res->length(); + return res ? my_strtoll10(res->ptr(), &end_ptr, &error) : (longlong) 0; } String* val_str(String* str); Item *copy_or_same(THD* thd); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0c0b5265db7..e8848243812 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1666,7 +1666,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date) days--; sec+= 3600*LL(24); } - ltime->second_part= microseconds; + ltime->second_part= (uint) microseconds; ltime->second= (uint) (sec % 60); ltime->minute= (uint) (sec/60 % 60); ltime->hour= (uint) (sec/3600); diff --git a/sql/set_var.cc b/sql/set_var.cc index 1233d860885..1205eb17357 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -853,7 +853,7 @@ bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex, uint new_length= (var ? var->value->str_value.length() : 0); if (!old_value) old_value= (char*) ""; - if (!(res= my_strdup_with_length(old_value, new_length, MYF(0)))) + if (!(res= my_strdup_with_length((byte*)old_value, new_length, MYF(0)))) return 1; /* Replace the old value in such a way that the any thread using diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml index bb4b6bd24af..44eb6f386d4 100644 --- a/sql/share/charsets/Index.xml +++ b/sql/share/charsets/Index.xml @@ -36,7 +36,7 @@ To make maintaining easier please: <alias>iso_8859-2</alias> <alias>iso_8859-2:1987</alias> <alias>l2</alias> - <collation name="latin2_czech_ci" id="2" order="Czech" flag="compiled"/> + <collation name="latin2_czech_cs" id="2" order="Czech" flag="compiled"/> <collation name="latin2_general_ci" id="9" flag="primary"> <order>Hungarian</order> <order>Polish</order> @@ -349,7 +349,7 @@ To make maintaining easier please: <order>Slovenian</order> <order>Sorbian</order> </collation> - <collation name="cp1250_czech_ci" id="34" order="Czech"> + <collation name="cp1250_czech_cs" id="34" order="Czech"> <flag>compiled</flag> </collation> <collation name="cp1250_bin" id="66" order="Binary" flag="binary"/> diff --git a/sql/spatial.h b/sql/spatial.h index cf07b364bb3..cc1cc70f1bc 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -217,7 +217,7 @@ public: if (!(ci= find_class((int) type_id))) return NULL; (*ci->m_create_func)((void *)buffer); - return (Geometry *)buffer; + return my_reinterpret_cast(Geometry *)(buffer); } static Geometry *create_from_wkb(Geometry_buffer *buffer, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 27aaf06d872..b2d030b523d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2764,9 +2764,9 @@ bool check_grant_column(THD *thd,TABLE *table, const char *name, if (table->grant.version != grant_version) { table->grant.grant_table= - table_hash_search(thd->host,thd->ip,thd->db, + table_hash_search(thd->host, thd->ip, table->table_cache_key, thd->priv_user, - table->real_name,0); /* purecov: inspected */ + table->real_name, 0); /* purecov: inspected */ table->grant.version=grant_version; /* purecov: inspected */ } if (!(grant_table=table->grant.grant_table)) @@ -3161,7 +3161,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) /* Add database access */ for (counter=0 ; counter < acl_dbs.elements ; counter++) { - const char *user,*host; + const char *user, *host; acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*); if (!(user=acl_db->user)) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 359150cf716..d7d4219c7fd 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -661,7 +661,7 @@ void query_cache_end_of_result(THD *thd) if (thd->net.query_cache_query != 0) // Quick check on unlocked structure { #ifdef EMBEDDED_LIBRARY - query_cache_insert(&thd->net, (byte*)thd, + query_cache_insert(&thd->net, (char*)thd, emb_count_querycache_size(thd)); #endif STRUCT_LOCK(&query_cache.structure_guard_mutex); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 50f13a0391c..aa3e81fd9c9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -332,7 +332,10 @@ public: Item_subselect *item; /* thread handler */ THD *thd; - /* fake SELECT_LEX for union processing */ + /* + SELECT_LEX for hidden SELECT in onion which process global + ORDER BY and LIMIT + */ st_select_lex *fake_select_lex; st_select_lex *union_distinct; /* pointer to the last UNION DISTINCT */ @@ -341,12 +344,18 @@ public: bool create_total_list(THD *thd, st_lex *lex, TABLE_LIST **result); st_select_lex_unit* master_unit(); st_select_lex* outer_select(); - st_select_lex* first_select() { return (st_select_lex*) slave; } + st_select_lex* first_select() + { + return my_reinterpret_cast(st_select_lex*)(slave); + } st_select_lex* first_select_in_union() { - return (st_select_lex*) slave; + return my_reinterpret_cast(st_select_lex*)(slave); + } + st_select_lex_unit* next_unit() + { + return my_reinterpret_cast(st_select_lex_unit*)(next); } - st_select_lex_unit* next_unit() { return (st_select_lex_unit*) next; } st_select_lex* return_after_parsing() { return return_to; } void exclude_level(); void exclude_tree(); @@ -360,7 +369,8 @@ public: bool check_updateable(char *db, char *table); void print(String *str); - + + ulong init_prepare_fake_select_lex(THD *thd); friend void mysql_init_query(THD *thd); friend int subselect_union_engine::exec(); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 951f92011ca..61e5b778b64 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1555,18 +1555,20 @@ set_params_data_err: /* - Reset a prepared statement, in case there was an error in send_longdata. - Note: we don't send any reply to that command. + Reset a prepared statement in case there was a recoverable error. SYNOPSIS mysql_stmt_reset() thd Thread handle packet Packet with stmt id DESCRIPTION - This function is useful when one gets an error after calling - mysql_stmt_getlongdata() and wants to reset the handle - so that one can call execute again. - See also bug #1664 + This function resets statement to the state it was right after prepare. + It can be used to: + - clear an error happened during mysql_stmt_send_long_data + - cancel long data stream for all placeholders without + having to call mysql_stmt_execute. + Sends 'OK' packet in case of success (statement was reset) + or 'ERROR' packet (unrecoverable error/statement not found/etc). */ void mysql_stmt_reset(THD *thd, char *packet) @@ -1577,7 +1579,7 @@ void mysql_stmt_reset(THD *thd, char *packet) DBUG_ENTER("mysql_stmt_reset"); - if (!(stmt= find_prepared_statement(thd, stmt_id, "reset", DONT_SEND_ERROR))) + if (!(stmt= find_prepared_statement(thd, stmt_id, "reset", SEND_ERROR))) DBUG_VOID_RETURN; stmt->get_longdata_error= 0; @@ -1587,6 +1589,8 @@ void mysql_stmt_reset(THD *thd, char *packet) mysql_stmt_send_long_data() call. */ reset_stmt_params(stmt); + + send_ok(thd); DBUG_VOID_RETURN; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 156c2692488..057c06d6ad3 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2855,6 +2855,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, db_create_options=table->db_create_options & ~(HA_OPTION_PACK_RECORD); my_snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%lx", tmp_file_prefix, current_pid, thd->thread_id); + /* Safety fix for innodb */ + if (lower_case_table_names) + my_casedn_str(system_charset_info, tmp_name); create_info->db_type=new_db_type; if (!create_info->comment) create_info->comment=table->comment; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index e5649192fe5..63638b618d9 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -106,6 +106,41 @@ bool select_union::flush() } +/* + initialization procedures before fake_select_lex preparation() + + SYNOPSIS + st_select_lex_unit::init_prepare_fake_select_lex() + thd - thread handler + + RETURN + options of SELECT +*/ + +ulong +st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) +{ + ulong options_tmp= thd->options; + thd->lex->current_select= fake_select_lex; + offset_limit_cnt= global_parameters->offset_limit; + select_limit_cnt= global_parameters->select_limit + + global_parameters->offset_limit; + + if (select_limit_cnt < global_parameters->select_limit) + select_limit_cnt= HA_POS_ERROR; // no limit + if (select_limit_cnt == HA_POS_ERROR) + options_tmp&= ~OPTION_FOUND_ROWS; + else if (found_rows_for_union && !thd->lex->describe) + options_tmp|= OPTION_FOUND_ROWS; + fake_select_lex->ftfunc_list_alloc.empty(); + fake_select_lex->ftfunc_list= &fake_select_lex->ftfunc_list_alloc; + fake_select_lex->table_list.link_in_list((byte *)&result_table_list, + (byte **) + &result_table_list.next); + return options_tmp; +} + + int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, ulong additional_options) { @@ -207,7 +242,6 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, } } - item_list.empty(); // it is not single select if (first_select->next_select()) { @@ -229,6 +263,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, union_result->set_table(table); thd_arg->lex->current_select= lex_select_save; + if (!item_list.elements) { Statement *stmt= thd->current_statement; Statement backup; @@ -246,7 +281,30 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, } } if (stmt) + { thd->restore_backup_item_arena(stmt, &backup); + + /* prepare fake select to initialize it correctly */ + ulong options_tmp= init_prepare_fake_select_lex(thd); + if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->options, + result))) + { + fake_select_lex->table_list.empty(); + DBUG_RETURN(-1); + } + fake_select_lex->item_list= item_list; + + thd_arg->lex->current_select= fake_select_lex; + res= fake_select_lex->join-> + prepare(&fake_select_lex->ref_pointer_array, + (TABLE_LIST*) fake_select_lex->table_list.first, + 0, 0, + fake_select_lex->order_list.elements, + (ORDER*) fake_select_lex->order_list.first, + (ORDER*) NULL, NULL, (ORDER*) NULL, + fake_select_lex, this); + fake_select_lex->table_list.empty(); + } } } else @@ -373,22 +431,7 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options_tmp= thd->options; - thd->lex->current_select= fake_select_lex; - offset_limit_cnt= global_parameters->offset_limit; - select_limit_cnt= global_parameters->select_limit + - global_parameters->offset_limit; - - if (select_limit_cnt < global_parameters->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR) - options_tmp&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union && !thd->lex->describe) - options_tmp|= OPTION_FOUND_ROWS; - fake_select_lex->ftfunc_list= &empty_list; - fake_select_lex->table_list.link_in_list((byte *)&result_table_list, - (byte **) - &result_table_list.next); + ulong options_tmp= init_prepare_fake_select_lex(thd); JOIN *join= fake_select_lex->join; if (!join) { diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 5094a7c45da..f4350f87153 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -587,7 +587,7 @@ CHARSET_INFO my_charset_latin2_czech_ci = 2,0,0, /* number */ MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ "latin2", /* cs name */ - "latin2_czech_ci", /* name */ + "latin2_czech_cs", /* name */ "", /* comment */ ctype_czech, to_lower_czech, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index c8eb3c07a3f..ba1fc1c424a 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -235,9 +235,9 @@ long my_strntol_8bit(CHARSET_INFO *cs, char **endptr, int *err) { int negative; - register ulong cutoff; + register uint32 cutoff; register unsigned int cutlim; - register ulong i; + register uint32 i; register const char *s; register unsigned char c; const char *save, *e; @@ -297,8 +297,8 @@ long my_strntol_8bit(CHARSET_INFO *cs, #endif save = s; - cutoff = ((ulong)~0L) / (unsigned long int) base; - cutlim = (uint) (((ulong)~0L) % (unsigned long int) base); + cutoff = ((uint32)~0L) / (uint32) base; + cutlim = (uint) (((uint32)~0L) % (uint32) base); overflow = 0; i = 0; @@ -318,7 +318,7 @@ long my_strntol_8bit(CHARSET_INFO *cs, overflow = 1; else { - i *= (ulong) base; + i *= (uint32) base; i += c; } } @@ -331,16 +331,16 @@ long my_strntol_8bit(CHARSET_INFO *cs, if (negative) { - if (i > (ulong) LONG_MIN) + if (i > (uint32) INT_MIN32) overflow = 1; } - else if (i > (ulong) LONG_MAX) + else if (i > INT_MAX32) overflow = 1; if (overflow) { err[0]= ERANGE; - return negative ? LONG_MIN : LONG_MAX; + return negative ? INT_MIN32 : INT_MAX32; } return (negative ? -((long) i) : (long) i); @@ -358,9 +358,9 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, char **endptr, int *err) { int negative; - register ulong cutoff; + register uint32 cutoff; register unsigned int cutlim; - register ulong i; + register uint32 i; register const char *s; register unsigned char c; const char *save, *e; @@ -419,8 +419,8 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, #endif save = s; - cutoff = ((ulong)~0L) / (unsigned long int) base; - cutlim = (uint) (((ulong)~0L) % (unsigned long int) base); + cutoff = ((uint32)~0L) / (uint32) base; + cutlim = (uint) (((uint32)~0L) % (uint32) base); overflow = 0; i = 0; @@ -440,7 +440,7 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, overflow = 1; else { - i *= (ulong) base; + i *= (uint32) base; i += c; } } @@ -454,7 +454,7 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, if (overflow) { err[0]= ERANGE; - return ((ulong)~0L); + return (~(uint32) 0); } return (negative ? -((long) i) : (long) i); diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 99d97a9614b..59c1706fd26 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -406,8 +406,8 @@ long my_strntol_ucs2(CHARSET_INFO *cs, int cnv; my_wc_t wc; register unsigned int cutlim; - register ulong cutoff; - register ulong res; + register uint32 cutoff; + register uint32 res; register const uchar *s= (const uchar*) nptr; register const uchar *e= (const uchar*) nptr+l; const uchar *save; @@ -446,8 +446,8 @@ bs: overflow = 0; res = 0; save = s; - cutoff = ((ulong)~0L) / (unsigned long int) base; - cutlim = (uint) (((ulong)~0L) % (unsigned long int) base); + cutoff = ((uint32)~0L) / (uint32) base; + cutlim = (uint) (((uint32)~0L) % (uint32) base); do { if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) @@ -467,7 +467,7 @@ bs: overflow = 1; else { - res *= (ulong) base; + res *= (uint32) base; res += wc; } } @@ -496,16 +496,16 @@ bs: if (negative) { - if (res > (ulong) LONG_MIN) + if (res > (uint32) INT_MIN32) overflow = 1; } - else if (res > (ulong) LONG_MAX) + else if (res > INT_MAX32) overflow = 1; if (overflow) { err[0]=ERANGE; - return negative ? LONG_MIN : LONG_MAX; + return negative ? INT_MIN32 : INT_MAX32; } return (negative ? -((long) res) : (long) res); @@ -521,8 +521,8 @@ ulong my_strntoul_ucs2(CHARSET_INFO *cs, int cnv; my_wc_t wc; register unsigned int cutlim; - register ulong cutoff; - register ulong res; + register uint32 cutoff; + register uint32 res; register const uchar *s= (const uchar*) nptr; register const uchar *e= (const uchar*) nptr+l; const uchar *save; @@ -561,8 +561,8 @@ bs: overflow = 0; res = 0; save = s; - cutoff = ((ulong)~0L) / (unsigned long int) base; - cutlim = (uint) (((ulong)~0L) % (unsigned long int) base); + cutoff = ((uint32)~0L) / (uint32) base; + cutlim = (uint) (((uint32)~0L) % (uint32) base); do { @@ -583,7 +583,7 @@ bs: overflow = 1; else { - res *= (ulong) base; + res *= (uint32) base; res += wc; } } @@ -613,11 +613,10 @@ bs: if (overflow) { err[0]=(ERANGE); - return ((ulong)~0L); + return (~(uint32) 0); } return (negative ? -((long) res) : (long) res); - } diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index 8fd4e612713..ed6bb877dc8 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -621,7 +621,7 @@ CHARSET_INFO my_charset_cp1250_czech_ci = 34,0,0, /* number */ MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ "cp1250", /* cs name */ - "cp1250_czech_ci", /* name */ + "cp1250_czech_cs", /* name */ "", /* comment */ ctype_win1250ch, to_lower_win1250ch, diff --git a/tests/client_test.c b/tests/client_test.c index 30caa5f1505..d382377fe49 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -163,8 +163,11 @@ MYSQL_STMT *STDCALL mysql_simple_prepare(MYSQL *mysql, const char *query) { MYSQL_STMT *stmt= mysql_stmt_init(mysql); - if (mysql_stmt_prepare(stmt, query, strlen(query))) + if (stmt && mysql_stmt_prepare(stmt, query, strlen(query))) + { + mysql_stmt_close(stmt); return 0; + } return stmt; } @@ -8189,10 +8192,6 @@ static void test_ts() /* Test for bug #1500. - XXX: despite that this bug is fixed, it spots mysqld code which is not - working correctly yet: to fix all things properly we need to implement - Item::cleanup() method for all items (as described in bugs #1663 and - #1749). So don't be surprised in case valgrind barks on it. */ static void test_bug1500() @@ -8238,7 +8237,6 @@ static void test_bug1500() assert(1 == my_process_stmt_result(stmt)); - /* FIXME If we comment out next string server will crash :( */ mysql_stmt_close(stmt); rc= mysql_query(mysql,"DROP TABLE test_bg1500"); @@ -9351,16 +9349,17 @@ static void test_bug3035() int64_val= int64_max; uint64_val= uint64_max; - mysql_stmt_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - stmt_text= "SELECT i8, ui8, i16, ui16, i32, ui32, i64, ui64, ui64, cast(ui64 as signed),ui64, cast(ui64 as signed)" + stmt_text= "SELECT i8, ui8, i16, ui16, i32, ui32, i64, ui64, ui64, " + "cast(ui64 as signed),ui64, cast(ui64 as signed)" "FROM t1 ORDER BY id ASC"; - mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - mysql_stmt_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind_array[8].buffer_type= MYSQL_TYPE_DOUBLE; |