diff options
94 files changed, 1495 insertions, 709 deletions
diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am index 3fd61790903..d06106d4431 100644 --- a/BUILD/Makefile.am +++ b/BUILD/Makefile.am @@ -28,6 +28,7 @@ EXTRA_DIST = FINISH.sh \ compile-alpha-debug \ compile-amd64-debug-max \ compile-amd64-max \ + compile-amd64-max-sci \ compile-darwin-mwcc \ compile-dist \ compile-hpux11-parisc2-aCC \ @@ -53,6 +54,7 @@ EXTRA_DIST = FINISH.sh \ compile-pentium-valgrind-max \ compile-pentium64-debug \ compile-pentium64-debug-max \ + compile-pentium64-max-sci \ compile-pentium64-valgrind-max \ compile-ppc \ compile-ppc-debug \ diff --git a/BUILD/compile-amd64-max-sci b/BUILD/compile-amd64-max-sci new file mode 100644 index 00000000000..4afa9004742 --- /dev/null +++ b/BUILD/compile-amd64-max-sci @@ -0,0 +1,8 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" +extra_flags="$amd64_cflags $fast_cflags -g" +extra_configs="$amd64_configs $max_configs --with-ndb-sci=/opt/DIS" + +. "$path/FINISH.sh" diff --git a/BUILD/compile-pentium64-max-sci b/BUILD/compile-pentium64-max-sci new file mode 100644 index 00000000000..9ebb1988475 --- /dev/null +++ b/BUILD/compile-pentium64-max-sci @@ -0,0 +1,9 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium64_cflags $fast_cflags -g" +extra_configs="$pentium_configs $max_configs --with-ndb-sci=/opt/DIS" + +. "$path/FINISH.sh" diff --git a/BitKeeper/triggers/pre-outgoing.crash-protect.pl b/BitKeeper/triggers/pre-outgoing.crash-protect.pl new file mode 100755 index 00000000000..b83e356e3f8 --- /dev/null +++ b/BitKeeper/triggers/pre-outgoing.crash-protect.pl @@ -0,0 +1,82 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +my $event= $ENV{BK_EVENT}; +unless($event eq 'outgoing pull' || $event eq 'outgoing push' || + $event eq 'resolve') { + exit 0; +} + +my @bad_csets= + ( 'monty@mysql.com|ChangeSet|20060418090255|16983', + 'monty@mysql.com|ChangeSet|20060418090458|02628', + 'monty@mysql.com|ChangeSet|20060419084236|49576', + 'monty@mysql.com|ChangeSet|20060503164655|51444', + 'monty@mysql.com|ChangeSet|20060503225814|60133', + 'monty@mysql.com|ChangeSet|20060504033006|54878', + 'monty@mysql.com|ChangeSet|20060504130520|48660', + 'monty@mysql.com|ChangeSet|20060504164102|03511', + 'monty@mysql.com|ChangeSet|20060504193112|04109', + 'monty@mysql.com|ChangeSet|20060505015314|02799', + 'monty@mysql.com|ChangeSet|20060505084007|16704', + 'monty@mysql.com|ChangeSet|20060505104008|16695', + 'monty@mysql.com|ChangeSet|20060505171041|13924', + 'monty@mysql.com|ChangeSet|20060508121933|13866', + 'monty@mysql.com|ChangeSet|20060508160902|15029', + 'monty@mysql.com|ChangeSet|20060509145448|38636', + 'monty@mysql.com|ChangeSet|20060509224111|40037', + 'monty@mysql.com|ChangeSet|20060510090758|40678', + 'monty@mysql.com|ChangeSet|20060515164104|46760', + 'monty@mysql.com|ChangeSet|20060530114549|35852', + 'monty@mysql.com|ChangeSet|20060605032828|23579', + 'monty@mysql.com|ChangeSet|20060605033011|10641', + 'monty@mysql.com|ChangeSet|20060605060652|09843', + 'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838', + 'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800', + 'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772', + 'jmiller@mysql.com|ChangeSet|20060531210831|36442', + 'jmiller@mysql.com|ChangeSet|20060602151941|36118', + 'jmiller@mysql.com|ChangeSet|20060602152136|27762', + 'jmiller@mysql.com|ChangeSet|20060605121748|12864', + 'jmiller@mysql.com|ChangeSet|20060605160304|14798', + 'jimw@mysql.com|ChangeSet|20060605210201|14667', + 'igor@rurik.mysql.com|ChangeSet|20060605220727|15265', + 'igor@rurik.mysql.com|ChangeSet|20060605221206|15134', + 'stewart@mysql.com|ChangeSet|20060525073521|11169', + 'stewart@mysql.com|ChangeSet|20060605154220|12975', + 'stewart@mysql.com|ChangeSet|20060606040001|15337', + 'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289' + ); + +# Read the list of changesets. +my $csetlist = $ENV{BK_CSETLIST}; +if(!defined($csetlist) || !open(FH, '<', $csetlist)) { + die "Failed to open list of incoming changesets '$csetlist': $!.\n"; +} +my @csets = <FH>; +close FH; + +# Reject any attempt to push/pull a bad changeset. +for my $cs (@csets) { + # Do this the raw way, don't want to be bitten by different EOL conventions + # on server and client (Unix/Windows/Mac). + $cs =~ s/\x0d?\x0a?$//s; + if(grep($_ eq $cs, @bad_csets)) { + print <<END; +BAD CHANGESET DETECTED! $event REJECTED! + +The changeset with key '$cs' was detected in the attempted push or pull. +This changeset is from the corrupt part of the crashed mysql-5.1-new tree. +Pushing or pulling this changeset would result in corruption of the new tree, +and therefore the operation has been rejected. + +Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any +questions regarding this. +END + exit 1; + } +} + +exit 0; diff --git a/BitKeeper/triggers/pre-resolve.crash-protect.pl b/BitKeeper/triggers/pre-resolve.crash-protect.pl new file mode 100755 index 00000000000..b83e356e3f8 --- /dev/null +++ b/BitKeeper/triggers/pre-resolve.crash-protect.pl @@ -0,0 +1,82 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +my $event= $ENV{BK_EVENT}; +unless($event eq 'outgoing pull' || $event eq 'outgoing push' || + $event eq 'resolve') { + exit 0; +} + +my @bad_csets= + ( 'monty@mysql.com|ChangeSet|20060418090255|16983', + 'monty@mysql.com|ChangeSet|20060418090458|02628', + 'monty@mysql.com|ChangeSet|20060419084236|49576', + 'monty@mysql.com|ChangeSet|20060503164655|51444', + 'monty@mysql.com|ChangeSet|20060503225814|60133', + 'monty@mysql.com|ChangeSet|20060504033006|54878', + 'monty@mysql.com|ChangeSet|20060504130520|48660', + 'monty@mysql.com|ChangeSet|20060504164102|03511', + 'monty@mysql.com|ChangeSet|20060504193112|04109', + 'monty@mysql.com|ChangeSet|20060505015314|02799', + 'monty@mysql.com|ChangeSet|20060505084007|16704', + 'monty@mysql.com|ChangeSet|20060505104008|16695', + 'monty@mysql.com|ChangeSet|20060505171041|13924', + 'monty@mysql.com|ChangeSet|20060508121933|13866', + 'monty@mysql.com|ChangeSet|20060508160902|15029', + 'monty@mysql.com|ChangeSet|20060509145448|38636', + 'monty@mysql.com|ChangeSet|20060509224111|40037', + 'monty@mysql.com|ChangeSet|20060510090758|40678', + 'monty@mysql.com|ChangeSet|20060515164104|46760', + 'monty@mysql.com|ChangeSet|20060530114549|35852', + 'monty@mysql.com|ChangeSet|20060605032828|23579', + 'monty@mysql.com|ChangeSet|20060605033011|10641', + 'monty@mysql.com|ChangeSet|20060605060652|09843', + 'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838', + 'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800', + 'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772', + 'jmiller@mysql.com|ChangeSet|20060531210831|36442', + 'jmiller@mysql.com|ChangeSet|20060602151941|36118', + 'jmiller@mysql.com|ChangeSet|20060602152136|27762', + 'jmiller@mysql.com|ChangeSet|20060605121748|12864', + 'jmiller@mysql.com|ChangeSet|20060605160304|14798', + 'jimw@mysql.com|ChangeSet|20060605210201|14667', + 'igor@rurik.mysql.com|ChangeSet|20060605220727|15265', + 'igor@rurik.mysql.com|ChangeSet|20060605221206|15134', + 'stewart@mysql.com|ChangeSet|20060525073521|11169', + 'stewart@mysql.com|ChangeSet|20060605154220|12975', + 'stewart@mysql.com|ChangeSet|20060606040001|15337', + 'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289' + ); + +# Read the list of changesets. +my $csetlist = $ENV{BK_CSETLIST}; +if(!defined($csetlist) || !open(FH, '<', $csetlist)) { + die "Failed to open list of incoming changesets '$csetlist': $!.\n"; +} +my @csets = <FH>; +close FH; + +# Reject any attempt to push/pull a bad changeset. +for my $cs (@csets) { + # Do this the raw way, don't want to be bitten by different EOL conventions + # on server and client (Unix/Windows/Mac). + $cs =~ s/\x0d?\x0a?$//s; + if(grep($_ eq $cs, @bad_csets)) { + print <<END; +BAD CHANGESET DETECTED! $event REJECTED! + +The changeset with key '$cs' was detected in the attempted push or pull. +This changeset is from the corrupt part of the crashed mysql-5.1-new tree. +Pushing or pulling this changeset would result in corruption of the new tree, +and therefore the operation has been rejected. + +Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any +questions regarding this. +END + exit 1; + } +} + +exit 0; diff --git a/Makefile.am b/Makefile.am index 992a6f6d755..6cb080aed5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -157,6 +157,8 @@ test-bt: @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 + -cd mysql-test ; MTR_BUILD_THREAD=auto \ + @PERL@ ./mysql-test-run.pl --force --comment=rowlock --suite=row_lock test-bt-debug: -cd mysql-test ; MTR_BUILD_THREAD=auto \ diff --git a/client/mysqldump.c b/client/mysqldump.c index 26235efafce..93b9b373ecb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1456,6 +1456,9 @@ static uint dump_routines_for_db(char *db) if (lock_tables) mysql_query(mysql, "LOCK TABLES mysql.proc READ"); + if (opt_compact) + fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n"); + fprintf(sql_file, "DELIMITER ;;\n"); /* 0, retrieve and dump functions, 1, procedures */ @@ -2106,8 +2109,11 @@ static void dump_triggers_for_table(char *table, DBUG_VOID_RETURN; } if (mysql_num_rows(result)) - fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\ -DELIMITER ;;\n"); + { + if (opt_compact) + fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n"); + fprintf(sql_file, "\nDELIMITER ;;\n"); + } while ((row= mysql_fetch_row(result))) { fprintf(sql_file, diff --git a/client/mysqltest.c b/client/mysqltest.c index 6f6412e1f02..5640d0c24ba 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -271,7 +271,7 @@ enum enum_commands { Q_EXEC, Q_DELIMITER, Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, - Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_QUERY_SORTED, + Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_SORTED_RESULT, Q_START_TIMER, Q_END_TIMER, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, @@ -341,7 +341,7 @@ const char *command_names[]= "horizontal_results", "query_vertical", "query_horizontal", - "query_sorted", + "sorted_result", "start_timer", "end_timer", "character_set", @@ -6040,6 +6040,11 @@ int main(int argc, char **argv) init_dynamic_string(&ds_warning_messages, "", 0, 2048); parse_args(argc, argv); + var_set_int("$PS_PROTOCOL", ps_protocol); + var_set_int("$SP_PROTOCOL", sp_protocol); + var_set_int("$VIEW_PROTOCOL", view_protocol); + var_set_int("$CURSOR_PROTOCOL", cursor_protocol); + DBUG_PRINT("info",("result_file: '%s'", result_file_name ? result_file_name : "")); if (mysql_server_init(embedded_server_arg_count, @@ -6176,13 +6181,19 @@ int main(int argc, char **argv) case Q_DISPLAY_HORIZONTAL_RESULTS: display_result_vertically= FALSE; break; + case Q_SORTED_RESULT: + /* + Turn on sorting of result set, will be reset after next + command + */ + display_result_sorted= TRUE; + break; case Q_LET: do_let(command); break; case Q_EVAL_RESULT: eval_result = 1; break; case Q_EVAL: case Q_QUERY_VERTICAL: case Q_QUERY_HORIZONTAL: - case Q_QUERY_SORTED: if (command->query == command->query_buf) { /* Skip the first part of command, i.e query_xxx */ @@ -6194,7 +6205,6 @@ int main(int argc, char **argv) case Q_REAP: { my_bool old_display_result_vertically= display_result_vertically; - my_bool old_display_result_sorted= display_result_sorted; /* Default is full query, both reap and send */ int flags= QUERY_REAP_FLAG | QUERY_SEND_FLAG; @@ -6211,7 +6221,6 @@ int main(int argc, char **argv) /* Check for special property for this query */ display_result_vertically|= (command->type == Q_QUERY_VERTICAL); - display_result_sorted= (command->type == Q_QUERY_SORTED); if (save_file[0]) { @@ -6224,7 +6233,6 @@ int main(int argc, char **argv) /* Restore settings */ display_result_vertically= old_display_result_vertically; - display_result_sorted= old_display_result_sorted; break; } @@ -6385,6 +6393,9 @@ int main(int argc, char **argv) the replace structures should be cleared */ free_all_replace(); + + /* Also reset "sorted_result" */ + display_result_sorted= FALSE; } last_command_executed= command_executed; diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4 index a4963a5e20e..55fe6ad8350 100644 --- a/config/ac-macros/ha_ndbcluster.m4 +++ b/config/ac-macros/ha_ndbcluster.m4 @@ -22,7 +22,7 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [ if test -f "$mysql_sci_dir/lib/libsisci.a" -a \ -f "$mysql_sci_dir/include/sisci_api.h"; then NDB_SCI_INCLUDES="-I$mysql_sci_dir/include" - NDB_SCI_LIBS="-L$mysql_sci_dir/lib -lsisci" + NDB_SCI_LIBS="$mysql_sci_dir/lib/libsisci.a" AC_MSG_RESULT([-- including sci transporter]) AC_DEFINE([NDB_SCI_TRANSPORTER], [1], [Including Ndb Cluster DB sci transporter]) diff --git a/configure.in b/configure.in index a779ab80ced..989aa978690 100644 --- a/configure.in +++ b/configure.in @@ -2006,12 +2006,20 @@ case "$target" in ;; esac -# isinf() could be a function or a macro (HPUX) -AC_MSG_CHECKING(for isinf with <math.h>) +# Check that isinf() is available in math.h and can be used in both C and C++ +# code +AC_MSG_CHECKING(for isinf in <math.h>) AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r], - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]), - AC_MSG_RESULT(no)) + AC_MSG_RESULT(yes) + AC_MSG_CHECKING(whether isinf() can be used in C++ code) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]), + AC_MSG_RESULT(no)) + AC_LANG_RESTORE, + AC_MSG_RESULT(no)) CFLAGS="$ORG_CFLAGS" diff --git a/include/my_global.h b/include/my_global.h index e9b371d8d30..f32a987ffb1 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -792,12 +792,11 @@ typedef SOCKET_SIZE_TYPE size_socket; #define isnan(x) ((x) != (x)) #endif -#if !defined(HAVE_ISINF) -/* The configure check for "isinf with math.h" has failed */ -#ifdef isinf -#undef isinf -#endif -#define isinf(X) (!finite(X) && !isnan(X)) +#ifdef HAVE_ISINF +/* isinf() can be used in both C and C++ code */ +#define my_isinf(X) isinf(X) +#else +#define my_isinf(X) (!finite(X) && !isnan(X)) #endif /* Define missing math constants. */ diff --git a/include/my_sys.h b/include/my_sys.h index 615a074e814..7df2718c7b1 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -66,8 +66,8 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ -#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ #define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ +#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ diff --git a/include/my_time.h b/include/my_time.h index 0e57b3d4af4..99eb5c36c6b 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -92,6 +92,7 @@ int check_time_range(struct st_mysql_time *, int *warning); long calc_daynr(uint year,uint month,uint day); uint calc_days_in_year(uint year); +uint year_2000_handling(uint year); void init_time(void); diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 647f6bd5e33..3b18531f6c0 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -18,6 +18,10 @@ INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") # storage does not work properly in DLLs. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") +SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 95e3e539eee..81da1e43cc9 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -81,7 +81,7 @@ INC_LIB= $(top_builddir)/regex/libregex.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a \ $(top_builddir)/dbug/libdbug.a \ - $(top_builddir)/vio/libvio.a + $(top_builddir)/vio/libvio.a @NDB_SCI_LIBS@ # diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index f30951a5d81..e0dd8491688 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -35,7 +35,8 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) \ -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \ $(openssl_includes) LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs) -LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) +LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \ + @NDB_SCI_LIBS@ mysqltest_embedded_LINK = $(CXXLINK) mysqltest_embedded_SOURCES = mysqltest.c diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 444dc2a1da9..ed0a84e737d 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -335,7 +335,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_FORCE_WRITE); - size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); + size= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE)); if ((skr=(my_off_t) info->state->key_file_length) != size) { /* Don't give error if file generated by myisampack */ @@ -595,7 +595,8 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, { /* purecov: begin tested */ /* Give it a chance to fit in the real file size. */ - my_off_t max_length= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(0)); + my_off_t max_length= my_seek(info->s->kfile, 0L, MY_SEEK_END, + MYF(MY_THREADSAFE)); mi_check_print_error(param, "Invalid key block position: %s " "key block size: %u file_length: %s", llstr(page, llbuff), keyinfo->block_length, @@ -4052,10 +4053,10 @@ int test_if_almost_full(MI_INFO *info) { if (info->s->options & HA_OPTION_COMPRESS_RECORD) return 0; - return (my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0))/10*9 > - (my_off_t) (info->s->base.max_key_file_length) || - my_seek(info->dfile,0L,MY_SEEK_END,MYF(0))/10*9 > - (my_off_t) info->s->base.max_data_file_length); + return my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE)) / 10 * 9 > + (my_off_t) info->s->base.max_key_file_length || + my_seek(info->dfile, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 > + (my_off_t) info->s->base.max_data_file_length; } /* Recreate table with bigger more alloced record-data */ diff --git a/myisam/sort.c b/myisam/sort.c index e4c01ac939d..f918283503e 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -151,7 +151,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, keys < (uint) maxbuffer) { mi_check_print_error(info->sort_info->param, - "sort_buffer_size is to small"); + "myisam_sort_buffer_size is too small"); goto err; } } @@ -175,7 +175,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, } if (memavl < MIN_SORT_MEMORY) { - mi_check_print_error(info->sort_info->param,"Sort buffer to small"); /* purecov: tested */ + mi_check_print_error(info->sort_info->param,"MyISAM sort buffer too small"); /* purecov: tested */ goto err; /* purecov: tested */ } (*info->lock_in_memory)(info->sort_info->param);/* Everything is allocated */ @@ -369,7 +369,7 @@ pthread_handler_t thr_find_all_keys(void *arg) keys < (uint) maxbuffer) { mi_check_print_error(sort_param->sort_info->param, - "sort_buffer_size is to small"); + "myisam_sort_buffer_size is too small"); goto err; } } @@ -397,7 +397,7 @@ pthread_handler_t thr_find_all_keys(void *arg) if (memavl < MIN_SORT_MEMORY) { mi_check_print_error(sort_param->sort_info->param, - "Sort buffer too small"); + "MyISAM sort buffer too small"); goto err; /* purecov: tested */ } @@ -773,7 +773,7 @@ static int NEAR_F merge_many_buff(MI_SORT_PARAM *info, uint keys, { if (merge_buffers(info,keys,from_file,to_file,sort_keys,lastbuff++, buffpek+i,buffpek+i+MERGEBUFF-1)) - break; /* purecov: inspected */ + goto cleanup; } if (merge_buffers(info,keys,from_file,to_file,sort_keys,lastbuff++, buffpek+i,buffpek+ *maxbuffer)) @@ -783,6 +783,7 @@ static int NEAR_F merge_many_buff(MI_SORT_PARAM *info, uint keys, temp=from_file; from_file=to_file; to_file=temp; *maxbuffer= (int) (lastbuff-buffpek)-1; } +cleanup: close_cached_file(to_file); /* This holds old result */ if (to_file == t_file) *t_file=t_file2; /* Copy result file */ diff --git a/mysql-test/include/have_log_bin.inc b/mysql-test/include/have_log_bin.inc new file mode 100644 index 00000000000..11530dc953e --- /dev/null +++ b/mysql-test/include/have_log_bin.inc @@ -0,0 +1,4 @@ +-- require r/have_log_bin.require +disable_query_log; +show variables like "log_bin"; +enable_query_log; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c494626bbae..f580213cda3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1071,7 +1071,7 @@ sub command_line_setup () { # On some operating systems, there is a limit to the length of a # UNIX domain socket's path far below PATH_MAX, so try to avoid long # socket path names. - $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 80 ); + $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 ); $master->[0]= { diff --git a/mysql-test/r/blackhole.result b/mysql-test/r/blackhole.result index 0ee5f326e0f..5ab4931b53b 100644 --- a/mysql-test/r/blackhole.result +++ b/mysql-test/r/blackhole.result @@ -123,6 +123,10 @@ master-bin.000001 # Query 1 # use `test`; create table t3 like t1 master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t3 master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3 drop table t1,t2,t3; +CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; +INSERT DELAYED INTO t1 VALUES(1); +ERROR HY000: Table storage engine for 't1' doesn't have this option +DROP TABLE t1; CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; DELETE FROM t1 WHERE a=10; ALTER TABLE t1 ADD INDEX(a); diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index f4ec6830cd5..d62c865bb3c 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -88,6 +88,8 @@ create table t1 (date char(30), format char(30) not null); insert into t1 values ('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'), ('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'), +('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'), +('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'), ('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'), ('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'), ('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'), @@ -119,6 +121,8 @@ select date,format,str_to_date(date, format) as str_to_date from t1; date format str_to_date 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 @@ -150,6 +154,8 @@ select date,format,concat('',str_to_date(date, format)) as con from t1; date format con 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 @@ -181,6 +187,8 @@ select date,format,cast(str_to_date(date, format) as datetime) as datetime from date format datetime 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 @@ -212,6 +220,8 @@ select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 @@ -243,6 +253,8 @@ select date,format,TIME(str_to_date(date, format)) as time from t1; date format time 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 @@ -274,6 +286,8 @@ select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 @@ -399,14 +413,14 @@ select date,format,str_to_date(date, format) as str_to_date from t1; date format str_to_date 10:20:10AM %h:%i:%s 0000-00-00 10:20:10 2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 -03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12 +03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 Warnings: Warning 1292 Truncated incorrect datetime value: '10:20:10AM' select date,format,concat(str_to_date(date, format),'') as con from t1; date format con 10:20:10AM %h:%i:%s 0000-00-00 10:20:10 2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 -03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12 +03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 Warnings: Warning 1292 Truncated incorrect datetime value: '10:20:10AM' drop table t1; diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 4a6ec9a7ba0..dbae7e551e5 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -75,6 +75,12 @@ NULL select weekofyear("1997-11-30 23:59:59.000001"); weekofyear("1997-11-30 23:59:59.000001") 48 +select makedate(03,1); +makedate(03,1) +2003-01-01 +select makedate('0003',1); +makedate('0003',1) +2003-01-01 select makedate(1997,1); makedate(1997,1) 1997-01-01 diff --git a/mysql-test/r/have_log_bin.require b/mysql-test/r/have_log_bin.require new file mode 100644 index 00000000000..cacdf8df0ce --- /dev/null +++ b/mysql-test/r/have_log_bin.require @@ -0,0 +1,2 @@ +Variable_name Value +have_log_bin ON diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 0c32f413bd8..b3b606bd1fc 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -60,3 +60,22 @@ DROP USER mysqltest1@'%'; Run mysql_upgrade with a non existing server socket mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect FATAL ERROR: Upgrade failed +set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; +mysql.columns_priv OK +mysql.db OK +mysql.func OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.proc OK +mysql.procs_priv OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +set GLOBAL sql_mode=default; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 25c4199e7a3..7865148905e 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2238,7 +2238,6 @@ INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; /*!50003 SET SESSION SQL_MODE="" */;; /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW begin @@ -2272,7 +2271,6 @@ LOCK TABLES `t2` WRITE; /*!40000 ALTER TABLE `t2` ENABLE KEYS */; UNLOCK TABLES; -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; /*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;; /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW begin @@ -2630,7 +2628,6 @@ INSERT INTO "t1 test" VALUES (1),(2),(3); /*!40000 ALTER TABLE "t1 test" ENABLE KEYS */; UNLOCK TABLES; -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; /*!50003 SET SESSION SQL_MODE="" */;; /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN @@ -2791,7 +2788,6 @@ LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; /*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;; /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN @@ -3293,12 +3289,16 @@ create database mysqldump_test_db; grant all privileges on mysqldump_test_db.* to user1; grant all privileges on mysqldump_test_db.* to user2; create procedure mysqldump_test_db.sp1() select 'hello'; + +/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; -- insufficient privileges to SHOW CREATE PROCEDURE `sp1` -- does user2 have permissions on mysql.proc? DELIMITER ; + +/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER ;; /*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`() diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index c4ed4d8b19d..35dcf9b62d2 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -557,6 +557,12 @@ a b c 2 Part 2 2007-04-05 00:00:00 2 Part 3 2007-04-05 00:00:00 select * from t1; +a b c +1 Line 1 2007-04-05 00:00:00 +2 Part 2 2007-04-05 00:00:00 +1 Line 1 2007-04-05 00:00:00 +2 Part 3 2007-04-05 00:00:00 +select * from t1; select ''; @@ -572,4 +578,92 @@ hep select "hepp"; hepp hepp +drop table t1; +SELECT 2 as "my_col" +UNION +SELECT 1; +my_col +1 +2 +SELECT 2 as "my_col" UNION SELECT 1; +my_col +1 +2 +SELECT 2 as "my_col" +UNION +SELECT 1; +my_col +1 +2 +SELECT '2' as "3" +UNION +SELECT '1'; +3 +1 +2 +CREATE TABLE t1( a CHAR); +SELECT * FROM t1; +a +DROP TABLE t1; +SELECT NULL as "my_col1",2 AS "my_col2" +UNION +SELECT NULL,1; +my_col1 my_col2 +NULL 2 +NULL 1 +SELECT NULL as "my_col1",2 AS "my_col2" +UNION +SELECT NULL,1; +my_col1 my_col2 +NULL 1 +NULL 2 +SELECT 2 as "my_col1",NULL AS "my_col2" +UNION +SELECT 1,NULL; +my_col1 my_col2 +2 NULL +1 NULL +SELECT 2 as "my_col1",NULL AS "my_col2" +UNION +SELECT 1,NULL; +my_col1 my_col2 +1 NULL +2 NULL +SET @a = 17; +SELECT 2 as "my_col" +UNION +SELECT 1; +my_col +2 +1 +SELECT 2 as "my_col" +UNION +SELECT 1; +my_col +1 +2 +SELECT '2' as "my_col1",2 as "my_col2" +UNION +SELECT '1',1 from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +SELECT '1' as "my_col1",2 as "my_col2" +UNION +SELECT '2',1; +my_col1 my_col2 +# 1 +# 2 +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 SET f1 = 1024; +INSERT INTO t1 SELECT f1 - 1 FROM t1; +INSERT INTO t1 SELECT f1 - 2 FROM t1; +INSERT INTO t1 SELECT f1 - 4 FROM t1; +INSERT INTO t1 SELECT f1 - 8 FROM t1; +INSERT INTO t1 SELECT f1 - 16 FROM t1; +INSERT INTO t1 SELECT f1 - 32 FROM t1; +INSERT INTO t1 SELECT f1 - 64 FROM t1; +INSERT INTO t1 SELECT f1 - 128 FROM t1; +INSERT INTO t1 SELECT f1 - 256 FROM t1; +INSERT INTO t1 SELECT f1 - 512 FROM t1; +SELECT * FROM t1; +DROP TABLE t1; End of tests diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index a2f0fff086e..32ed34e1d52 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -2961,20 +2961,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -3005,6 +3011,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 17c83bdc87a..c53056cfa0e 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -2944,20 +2944,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -2988,6 +2994,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 114891f1145..2951ce28fa5 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -2945,20 +2945,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -2989,6 +2995,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 245d5766efd..56ec1e04901 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -2881,20 +2881,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -2925,6 +2931,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 @@ -5895,20 +5902,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -5939,6 +5952,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 6f6ecbb20b8..ed774b202b2 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -2944,20 +2944,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -2988,6 +2994,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 65e9121a35e..ff5ecbb2e9b 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -2944,20 +2944,26 @@ delete from t9 ; test_sequence -- insert into date/time columns -- Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Warning 1264 Out of range value adjusted for column 'c13' at row 1 @@ -2988,6 +2994,7 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value adjusted for column 'c16' at row 1 Warning 1264 Out of range value adjusted for column 'c17' at row 1 diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 54d53299743..417a5e0c990 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -79,12 +79,12 @@ INSERT INTO t1 VALUES ('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), ('0'),('0'),('0'),('0'),('0'),('0'),('0'); Warnings: -Error 1034 sort_buffer_size is to small +Error 1034 myisam_sort_buffer_size is too small Error 1034 Number of rows changed from 0 to 157 SET myisam_repair_threads=2; REPAIR TABLE t1; Table Op Msg_type Msg_text -test.t1 repair error sort_buffer_size is to small +test.t1 repair error myisam_sort_buffer_size is too small test.t1 repair warning Number of rows changed from 0 to 157 test.t1 repair status OK SET myisam_repair_threads=@@global.myisam_repair_threads; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 74bd2a171e3..a3ebd5c86fd 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -206,6 +206,8 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y')); INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); +Warnings: +Note 1265 Data truncated for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 644d4d971c6..9f51fc0371c 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -110,3 +110,29 @@ select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_dat 1 1 drop table t1; +select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date); +@d:=1111 year(@d) month(@d) day(@d) cast(@d as date) +1111 2000 11 11 2000-11-11 +select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date); +@d:=011111 year(@d) month(@d) day(@d) cast(@d as date) +11111 2001 11 11 2001-11-11 +select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date); +@d:=1311 year(@d) month(@d) day(@d) cast(@d as date) +1311 NULL NULL NULL NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '1311' +Warning 1292 Truncated incorrect datetime value: '1311' +Warning 1292 Truncated incorrect datetime value: '1311' +Warning 1292 Truncated incorrect datetime value: '1311' +create table t1 (d date , dt datetime , ts timestamp); +insert into t1 values (9912101,9912101,9912101); +Warnings: +Warning 1264 Out of range value adjusted for column 'd' at row 1 +Warning 1264 Out of range value adjusted for column 'dt' at row 1 +Warning 1265 Data truncated for column 'ts' at row 1 +insert into t1 values (11111,11111,11111); +select * from t1; +d dt ts +0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 +2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00 +drop table t1; diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 48cc54fb3ef..ba02f19712a 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -192,6 +192,41 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)); CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)) 101112.098700 +set @org_mode=@@sql_mode; +create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); +Warnings: +Note 1265 Data truncated for column 'da' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `da` date default '1962-03-03', + `dt` datetime default '1962-03-03 00:00:00' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (); +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1265 Data truncated for column 'da' at row 1 +set @@sql_mode='ansi,traditional'; +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1265 Data truncated for column 'da' at row 1 +insert into t1 set dt='2007-03-23 13:49:38',da=dt; +Warnings: +Note 1265 Data truncated for column 'da' at row 1 +insert into t1 values ('2007-03-32','2007-03-23 13:49:38'); +ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1 +select * from t1; +da dt +1962-03-03 1962-03-03 00:00:00 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +drop table t1; +create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03'); +ERROR 42000: Invalid default value for 'da' +create table t1 (t time default '916:00:00 a'); +ERROR 42000: Invalid default value for 't' +set @@sql_mode= @org_mode; create table t1 (f1 date, f2 datetime, f3 timestamp); insert into t1(f1) values(curdate()); select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1; diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index 4bafad2d777..51cc663d6bc 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -128,6 +128,17 @@ show binlog events; drop table t1,t2,t3; # +# BUG#27998 - mysqld crashed when executing INSERT DELAYED on a BLACKHOLE +# table +# +CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; +--error 1031 +INSERT DELAYED INTO t1 VALUES(1); +DROP TABLE t1; + +# End of 4.1 tests + +# #Bug#19717: DELETE Query Error on BLACKHOLE when using WHERE on column with UNIQUE INDEX # CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; @@ -142,4 +153,4 @@ ALTER TABLE t1 ADD PRIMARY KEY(a); DELETE FROM t1 WHERE a=10; DROP TABLE t1; -# End of 4.1 tests +# End of 5.0 tests diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 3054ec53faa..faa6d4242db 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -129,6 +129,8 @@ create table t1 (date char(30), format char(30) not null); insert into t1 values ('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'), ('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'), +('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'), +('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'), ('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'), ('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'), ('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'), diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test index 77d7366afe6..bb65cbaa774 100644 --- a/mysql-test/t/func_sapdb.test +++ b/mysql-test/t/func_sapdb.test @@ -41,6 +41,8 @@ select datediff("1997-11-30 23:59:59.000001",null); select weekofyear("1997-11-30 23:59:59.000001"); +select makedate(03,1); +select makedate('0003',1); select makedate(1997,1); select makedate(1997,0); select makedate(9999,365); diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 3f9626fcc42..233e8c7c256 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -55,3 +55,16 @@ DROP USER mysqltest1@'%'; --replace_regex /.*mysqlcheck.*: Got/mysqlcheck: Got/ /\([0-9]*\)/(errno)/ --error 1 --exec $MYSQL_UPGRADE --skip-verbose --force --host=not_existing_host 2>&1 + +# +# Bug #28401 mysql_upgrade Failed with STRICT_ALL_TABLES, ANSI_QUOTES and NO_ZERO_DATE +# + +# The SQL commands used by mysql_upgrade are written to be run +# with sql_mode set to '' - thus the scripts should change sql_mode +# for the session to make sure the SQL is legal. + +# Test by setting sql_mode before running mysql_upgrade +set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; +--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +eval set GLOBAL sql_mode=default; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 328206626df..057432d37fd 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1740,23 +1740,130 @@ EOF --exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- -# test for query_sorted +# test for sorted_result # ---------------------------------------------------------------------------- create table t1( a int, b char(255), c timestamp); insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05'); insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05'); select * from t1; -query_sorted select * from t1; +--sorted_result +select * from t1; +# Should not be sorted +select * from t1; disable_result_log; -query_sorted select * from t1; +sorted_result; +select * from t1; enable_result_log; -query_sorted select ''; -query_sorted select "h"; -query_sorted select "he"; -query_sorted select "hep"; -query_sorted select "hepp"; +--sorted_result +select ''; +sorted_result; +select "h"; +--sorted_result +select "he"; +--sorted_result +select "hep"; +--sorted_result +select "hepp"; + +drop table t1; +# 1. Assignment of result set sorting +sorted_result; + SELECT 2 as "my_col" +UNION +SELECT 1; +# +--sorted_result +SELECT 2 as "my_col" UNION SELECT 1; +--sorted_result +SELECT 2 as "my_col" +UNION +SELECT 1; + +# 2. Ensure that the table header will be not sorted into the result +--sorted_result +SELECT '2' as "3" +UNION +SELECT '1'; + +# 3. Ensure that an empty result set does not cause problems +CREATE TABLE t1( a CHAR); +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; + +# 4. Ensure that NULL values within the result set do not cause problems +SELECT NULL as "my_col1",2 AS "my_col2" +UNION +SELECT NULL,1; +--sorted_result +SELECT NULL as "my_col1",2 AS "my_col2" +UNION +SELECT NULL,1; +# +SELECT 2 as "my_col1",NULL AS "my_col2" +UNION +SELECT 1,NULL; +--sorted_result +SELECT 2 as "my_col1",NULL AS "my_col2" +UNION +SELECT 1,NULL; + +# 5. "sorted_result" changes nothing when applied to a non query statement. +sorted_result; + SET @a = 17; +# +# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect +# the now following query. +SELECT 2 as "my_col" +UNION +SELECT 1; + +# 7. Ensure that "sorted_result" in combination with $variables works +let $my_stmt=SELECT 2 as "my_col" +UNION +SELECT 1; +--sorted_result +eval $my_stmt; + +# 8. Ensure that "sorted_result " does not change the semantics of +# "--error ...." or the protocol output after such an expected failure +--sorted_result +--error 1146 +SELECT '2' as "my_col1",2 as "my_col2" +UNION +SELECT '1',1 from t2; + +# 9. Ensure that several result formatting options including "sorted_result" +# - have all an effect +# - "--sorted_result" does not need to be direct before the statement +# - Row sorting is applied after modification of the column content +--sorted_result +--replace_column 1 # +SELECT '1' as "my_col1",2 as "my_col2" +UNION +SELECT '2',1; + +# 10. Ensure that at least 1024 rows within a result set do not cause problems +# +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 SET f1 = 1024; +INSERT INTO t1 SELECT f1 - 1 FROM t1; +INSERT INTO t1 SELECT f1 - 2 FROM t1; +INSERT INTO t1 SELECT f1 - 4 FROM t1; +INSERT INTO t1 SELECT f1 - 8 FROM t1; +INSERT INTO t1 SELECT f1 - 16 FROM t1; +INSERT INTO t1 SELECT f1 - 32 FROM t1; +INSERT INTO t1 SELECT f1 - 64 FROM t1; +INSERT INTO t1 SELECT f1 - 128 FROM t1; +INSERT INTO t1 SELECT f1 - 256 FROM t1; +INSERT INTO t1 SELECT f1 - 512 FROM t1; +--disable_result_log +--sorted_result +SELECT * FROM t1; +--enable_result_log +DROP TABLE t1; # ---------------------------------------------------------------------------- # Some coverage tests # ---------------------------------------------------------------------------- diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index f285407efd4..2b80b0b9d93 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -41,9 +41,9 @@ eval select * into dumpfile "../tmp/outfile-test.2" from t1; eval select * into dumpfile "../tmp/outfile-test.3" from t1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.not-exist")); ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.1 ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.2 ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.3 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.2 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.3 drop table t1; # Bug#8191 @@ -51,7 +51,7 @@ disable_query_log; eval select 1 into outfile "../tmp/outfile-test.4"; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.4")); ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 # # Bug #5382: 'explain select into outfile' crashes the server @@ -75,7 +75,7 @@ eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM information_schema.schemata LIMIT 0, 5; # enable_query_log; ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 use information_schema; # disable_query_log; @@ -83,7 +83,7 @@ eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM schemata LIMIT 0, 5; enable_query_log; ---exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 +--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 use test; # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index c6050753943..02cd07e3c16 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -123,3 +123,16 @@ insert into t1 values ('2000-01-01','2000-01-02'); select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date; drop table t1; # End of 4.1 tests + +# +# Bug #23093: Implicit conversion of 9912101 to date does not match +# cast(9912101 as date) +# +select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date); +select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date); +select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date); +create table t1 (d date , dt datetime , ts timestamp); +insert into t1 values (9912101,9912101,9912101); +insert into t1 values (11111,11111,11111); +select * from t1; +drop table t1; diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index cf512aa3649..d420afbde37 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -141,6 +141,31 @@ SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6)); SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6)); SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)); + +# +# Test of storing datetime into date fields +# + +set @org_mode=@@sql_mode; +create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); +show create table t1; +insert into t1 values (); +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +set @@sql_mode='ansi,traditional'; +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +insert into t1 set dt='2007-03-23 13:49:38',da=dt; +# Test error handling +--error 1292 +insert into t1 values ('2007-03-32','2007-03-23 13:49:38'); +select * from t1; +drop table t1; +--error 1067 +create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03'); +--error 1067 +create table t1 (t time default '916:00:00 a'); +set @@sql_mode= @org_mode; + + # # Bug#27590: Wrong DATE/DATETIME comparison. # diff --git a/mysys/my_seek.c b/mysys/my_seek.c index 2be4812a2bd..3d415400aa2 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -23,7 +23,9 @@ my_off_t pos The expected position (absolute or relative) int whence A direction parameter and one of {SEEK_SET, SEEK_CUR, SEEK_END} - myf MyFlags Not used. + myf MyFlags MY_THREADSAFE must be set in case my_seek may be mixed + with my_pread/my_pwrite calls and fd is shared among + threads. DESCRIPTION The my_seek function is a wrapper around the system call lseek and @@ -54,9 +56,16 @@ my_off_t my_seek(File fd, my_off_t pos, int whence, Make sure we are using a valid file descriptor! */ DBUG_ASSERT(fd != -1); - - newpos= lseek(fd, pos, whence); - +#if defined(THREAD) && !defined(HAVE_PREAD) + if (MyFlags & MY_THREADSAFE) + { + pthread_mutex_lock(&my_file_info[fd].mutex); + newpos= lseek(fd, pos, whence); + pthread_mutex_unlock(&my_file_info[fd].mutex); + } + else +#endif + newpos= lseek(fd, pos, whence); if (newpos == (os_off_t) -1) { my_errno=errno; diff --git a/ndb/include/mgmapi/ndbd_exit_codes.h b/ndb/include/mgmapi/ndbd_exit_codes.h index 874bf0aa253..1051fd9e394 100644 --- a/ndb/include/mgmapi/ndbd_exit_codes.h +++ b/ndb/include/mgmapi/ndbd_exit_codes.h @@ -79,6 +79,8 @@ typedef ndbd_exit_classification_enum ndbd_exit_classification; #define NDBD_EXIT_NO_MORE_UNDOLOG 2312 #define NDBD_EXIT_SR_UNDOLOG 2313 #define NDBD_EXIT_SINGLE_USER_MODE 2314 +#define NDBD_EXIT_NODE_DECLARED_DEAD 2315 +#define NDBD_EXIT_SR_SCHEMAFILE 2316 #define NDBD_EXIT_MEMALLOC 2327 #define NDBD_EXIT_BLOCK_JBUFCONGESTION 2334 #define NDBD_EXIT_TIME_QUEUE_SHORT 2335 diff --git a/ndb/src/common/transporter/Packer.cpp b/ndb/src/common/transporter/Packer.cpp index 66c00b0af89..d471167b0e7 100644 --- a/ndb/src/common/transporter/Packer.cpp +++ b/ndb/src/common/transporter/Packer.cpp @@ -20,7 +20,12 @@ #include <TransporterCallback.hpp> #include <RefConvert.hpp> +#ifdef ERROR_INSERT +Uint32 MAX_RECEIVED_SIGNALS = 1024; +#else #define MAX_RECEIVED_SIGNALS 1024 +#endif + Uint32 TransporterRegistry::unpack(Uint32 * readPtr, Uint32 sizeOfData, diff --git a/ndb/src/common/transporter/SCI_Transporter.cpp b/ndb/src/common/transporter/SCI_Transporter.cpp index 138b79acb51..0720fe84973 100644 --- a/ndb/src/common/transporter/SCI_Transporter.cpp +++ b/ndb/src/common/transporter/SCI_Transporter.cpp @@ -65,13 +65,10 @@ SCI_Transporter::SCI_Transporter(TransporterRegistry &t_reg, m_initLocal=false; - m_swapCounter=0; m_failCounter=0; m_remoteNodes[0]=remoteSciNodeId0; m_remoteNodes[1]=remoteSciNodeId1; m_adapters = nAdapters; - // The maximum number of times to try and create, - // start and destroy a sequence m_ActiveAdapterId=0; m_StandbyAdapterId=1; @@ -102,8 +99,6 @@ SCI_Transporter::SCI_Transporter(TransporterRegistry &t_reg, DBUG_VOID_RETURN; } - - void SCI_Transporter::disconnectImpl() { DBUG_ENTER("SCI_Transporter::disconnectImpl"); @@ -129,7 +124,8 @@ void SCI_Transporter::disconnectImpl() if(err != SCI_ERR_OK) { report_error(TE_SCI_UNABLE_TO_CLOSE_CHANNEL); - DBUG_PRINT("error", ("Cannot close channel to the driver. Error code 0x%x", + DBUG_PRINT("error", + ("Cannot close channel to the driver. Error code 0x%x", err)); } } @@ -164,19 +160,18 @@ bool SCI_Transporter::initTransporter() { m_sendBuffer.m_buffer = new Uint32[m_sendBuffer.m_sendBufferSize / 4]; m_sendBuffer.m_dataSize = 0; - DBUG_PRINT("info", ("Created SCI Send Buffer with buffer size %d and packet size %d", + DBUG_PRINT("info", + ("Created SCI Send Buffer with buffer size %d and packet size %d", m_sendBuffer.m_sendBufferSize, m_PacketSize * 4)); if(!getLinkStatus(m_ActiveAdapterId) || (m_adapters > 1 && !getLinkStatus(m_StandbyAdapterId))) { - DBUG_PRINT("error", ("The link is not fully operational. Check the cables and the switches")); - //reportDisconnect(remoteNodeId, 0); - //doDisconnect(); + DBUG_PRINT("error", + ("The link is not fully operational. Check the cables and the switches")); //NDB should terminate report_error(TE_SCI_LINK_ERROR); DBUG_RETURN(false); } - DBUG_RETURN(true); } // initTransporter() @@ -235,7 +230,8 @@ sci_error_t SCI_Transporter::initLocalSegment() { DBUG_PRINT("info", ("SCInode iD %d adapter %d\n", sciAdapters[i].localSciNodeId, i)); if(err != SCI_ERR_OK) { - DBUG_PRINT("error", ("Cannot open an SCI virtual device. Error code 0x%x", + DBUG_PRINT("error", + ("Cannot open an SCI virtual device. Error code 0x%x", err)); DBUG_RETURN(err); } @@ -269,7 +265,8 @@ sci_error_t SCI_Transporter::initLocalSegment() { &err); if(err != SCI_ERR_OK) { - DBUG_PRINT("error", ("Local Segment is not accessible by an SCI adapter. Error code 0x%x\n", + DBUG_PRINT("error", + ("Local Segment is not accessible by an SCI adapter. Error code 0x%x\n", err)); DBUG_RETURN(err); } @@ -303,15 +300,13 @@ sci_error_t SCI_Transporter::initLocalSegment() { &err); if(err != SCI_ERR_OK) { - DBUG_PRINT("error", ("Local Segment is not available for remote connections. Error code 0x%x\n", + DBUG_PRINT("error", + ("Local Segment is not available for remote connections. Error code 0x%x\n", err)); DBUG_RETURN(err); } } - - setupLocalSegment(); - DBUG_RETURN(err); } // initLocalSegment() @@ -343,12 +338,6 @@ bool SCI_Transporter::doSend() { if(sizeToSend==4097) i4097++; #endif - if(startSequence(m_ActiveAdapterId)!=SCI_ERR_OK) { - DBUG_PRINT("error", ("Start sequence failed")); - report_error(TE_SCI_UNABLE_TO_START_SEQUENCE); - return false; - } - tryagain: retry++; @@ -374,119 +363,36 @@ bool SCI_Transporter::doSend() { SCI_FLAG_ERROR_CHECK, &err); - if (err != SCI_ERR_OK) { - if(err == SCI_ERR_OUT_OF_RANGE) { - DBUG_PRINT("error", ("Data transfer : out of range error")); - goto tryagain; - } - if(err == SCI_ERR_SIZE_ALIGNMENT) { - DBUG_PRINT("error", ("Data transfer : alignment error")); - DBUG_PRINT("info", ("sendPtr 0x%x, sizeToSend = %d", sendPtr, sizeToSend)); - goto tryagain; - } - if(err == SCI_ERR_OFFSET_ALIGNMENT) { - DBUG_PRINT("error", ("Data transfer : offset alignment")); - goto tryagain; - } - if(err == SCI_ERR_TRANSFER_FAILED) { - //(m_TargetSegm[m_StandbyAdapterId].writer)->heavyLock(); - if(getLinkStatus(m_ActiveAdapterId)) { - goto tryagain; - } - if (m_adapters == 1) { - DBUG_PRINT("error", ("SCI Transfer failed")); + if (err == SCI_ERR_OUT_OF_RANGE || + err == SCI_ERR_SIZE_ALIGNMENT || + err == SCI_ERR_OFFSET_ALIGNMENT) { + DBUG_PRINT("error", ("Data transfer error = %d", err)); report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR); return false; - } - m_failCounter++; - Uint32 temp=m_ActiveAdapterId; - switch(m_swapCounter) { - case 0: - /**swap from active (0) to standby (1)*/ - if(getLinkStatus(m_StandbyAdapterId)) { - DBUG_PRINT("error", ("Swapping from adapter 0 to 1")); + } + if(err == SCI_ERR_TRANSFER_FAILED) { + if(getLinkStatus(m_ActiveAdapterId)) + goto tryagain; + if (m_adapters == 1) { + DBUG_PRINT("error", ("SCI Transfer failed")); + report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR); + return false; + } + m_failCounter++; + Uint32 temp=m_ActiveAdapterId; + if (getLinkStatus(m_StandbyAdapterId)) { failoverShmWriter(); SCIStoreBarrier(m_TargetSegm[m_StandbyAdapterId].sequence,0); m_ActiveAdapterId=m_StandbyAdapterId; m_StandbyAdapterId=temp; - SCIRemoveSequence((m_TargetSegm[m_StandbyAdapterId].sequence), - FLAGS, - &err); - if(err!=SCI_ERR_OK) { - report_error(TE_SCI_UNABLE_TO_REMOVE_SEQUENCE); - DBUG_PRINT("error", ("Unable to remove sequence")); - return false; - } - if(startSequence(m_ActiveAdapterId)!=SCI_ERR_OK) { - DBUG_PRINT("error", ("Start sequence failed")); - report_error(TE_SCI_UNABLE_TO_START_SEQUENCE); - return false; - } - m_swapCounter++; - DBUG_PRINT("info", ("failover complete")); - goto tryagain; - } else { - report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR); - DBUG_PRINT("error", ("SCI Transfer failed")); - return false; - } - return false; - break; - case 1: - /** swap back from 1 to 0 - must check that the link is up */ - - if(getLinkStatus(m_StandbyAdapterId)) { - failoverShmWriter(); - m_ActiveAdapterId=m_StandbyAdapterId; - m_StandbyAdapterId=temp; - DBUG_PRINT("info", ("Swapping from 1 to 0")); - if(createSequence(m_ActiveAdapterId)!=SCI_ERR_OK) { - DBUG_PRINT("error", ("Unable to create sequence")); - report_error(TE_SCI_UNABLE_TO_CREATE_SEQUENCE); - return false; - } - if(startSequence(m_ActiveAdapterId)!=SCI_ERR_OK) { - DBUG_PRINT("error", ("startSequence failed... disconnecting")); - report_error(TE_SCI_UNABLE_TO_START_SEQUENCE); - return false; - } - - SCIRemoveSequence((m_TargetSegm[m_StandbyAdapterId].sequence) - , FLAGS, - &err); - if(err!=SCI_ERR_OK) { - DBUG_PRINT("error", ("Unable to remove sequence")); - report_error(TE_SCI_UNABLE_TO_REMOVE_SEQUENCE); - return false; - } - - if(createSequence(m_StandbyAdapterId)!=SCI_ERR_OK) { - DBUG_PRINT("error", ("Unable to create sequence on standby")); - report_error(TE_SCI_UNABLE_TO_CREATE_SEQUENCE); - return false; - } - - m_swapCounter=0; - - DBUG_PRINT("info", ("failover complete..")); - goto tryagain; - + DBUG_PRINT("error", ("Swapping from adapter %u to %u", + m_StandbyAdapterId, m_ActiveAdapterId)); } else { - DBUG_PRINT("error", ("Unrecoverable data transfer error")); report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR); - return false; + DBUG_PRINT("error", ("SCI Transfer failed")); } - - break; - default: - DBUG_PRINT("error", ("Unrecoverable data transfer error")); - report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR); - return false; - break; - } - } + } } else { SHM_Writer * writer = (m_TargetSegm[m_ActiveAdapterId].writer); writer->updateWritePtr(sizeToSend); @@ -497,7 +403,6 @@ bool SCI_Transporter::doSend() { m_sendBuffer.m_dataSize = 0; m_sendBuffer.m_forceSendLimit = sendLimit; } - } else { /** * If we end up here, the SCI segment is full. @@ -552,15 +457,12 @@ void SCI_Transporter::setupLocalSegment() DBUG_VOID_RETURN; } //setupLocalSegment - - void SCI_Transporter::setupRemoteSegment() { DBUG_ENTER("SCI_Transporter::setupRemoteSegment"); Uint32 sharedSize = 0; sharedSize =4096; //start of the buffer is page aligned - Uint32 sizeOfBuffer = m_BufferSize; const Uint32 slack = MAX_MESSAGE_SIZE; sizeOfBuffer -= sharedSize; @@ -666,7 +568,6 @@ SCI_Transporter::init_remote() DBUG_PRINT("error", ("Error connecting segment, err 0x%x", err)); DBUG_RETURN(false); } - } // Map the remote memory segment into program space for(Uint32 i=0; i < m_adapters ; i++) { @@ -679,13 +580,14 @@ SCI_Transporter::init_remote() FLAGS, &err); - - if(err!= SCI_ERR_OK) { - DBUG_PRINT("error", ("Cannot map a segment to the remote node %d. Error code 0x%x",m_RemoteSciNodeId, err)); - //NDB SHOULD TERMINATE AND COMPUTER REBOOTED! - report_error(TE_SCI_CANNOT_MAP_REMOTESEGMENT); - DBUG_RETURN(false); - } + if(err!= SCI_ERR_OK) { + DBUG_PRINT("error", + ("Cannot map a segment to the remote node %d. Error code 0x%x", + m_RemoteSciNodeId, err)); + //NDB SHOULD TERMINATE AND COMPUTER REBOOTED! + report_error(TE_SCI_CANNOT_MAP_REMOTESEGMENT); + DBUG_RETURN(false); + } } m_mapped=true; setupRemoteSegment(); @@ -713,7 +615,6 @@ SCI_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) NDB_CLOSE_SOCKET(sockfd); DBUG_RETURN(false); } - if (!init_local()) { NDB_CLOSE_SOCKET(sockfd); DBUG_RETURN(false); @@ -788,29 +689,9 @@ sci_error_t SCI_Transporter::createSequence(Uint32 adapterid) { &(m_TargetSegm[adapterid].sequence), SCI_FLAG_FAST_BARRIER, &err); - - return err; } // createSequence() - -sci_error_t SCI_Transporter::startSequence(Uint32 adapterid) { - - sci_error_t err; - /** Perform preliminary error check on an SCI adapter before starting a - * sequence of read and write operations on the mapped segment. - */ - m_SequenceStatus = SCIStartSequence( - (m_TargetSegm[adapterid].sequence), - FLAGS, &err); - - - // If there still is an error then data cannot be safely send - return err; -} // startSequence() - - - bool SCI_Transporter::disconnectLocal() { DBUG_ENTER("SCI_Transporter::disconnectLocal"); @@ -878,9 +759,6 @@ SCI_Transporter::~SCI_Transporter() { DBUG_VOID_RETURN; } // ~SCI_Transporter() - - - void SCI_Transporter::closeSCI() { // Termination of SCI sci_error_t err; @@ -897,8 +775,9 @@ void SCI_Transporter::closeSCI() { SCIClose(activeSCIDescriptor, FLAGS, &err); if(err != SCI_ERR_OK) { - DBUG_PRINT("error", ("Cannot close SCI channel to the driver. Error code 0x%x", - err)); + DBUG_PRINT("error", + ("Cannot close SCI channel to the driver. Error code 0x%x", + err)); } SCITerminate(); DBUG_VOID_RETURN; @@ -973,7 +852,6 @@ SCI_Transporter::getConnectionStatus() { return false; } - void SCI_Transporter::setConnected() { *m_remoteStatusFlag = SCICONNECTED; @@ -983,7 +861,6 @@ SCI_Transporter::setConnected() { *m_localStatusFlag = SCICONNECTED; } - void SCI_Transporter::setDisconnect() { if(getLinkStatus(m_ActiveAdapterId)) @@ -994,7 +871,6 @@ SCI_Transporter::setDisconnect() { } } - bool SCI_Transporter::checkConnected() { if (*m_localStatusFlag == SCIDISCONNECT) { @@ -1015,8 +891,9 @@ SCI_Transporter::initSCI() { SCIInitialize(0, &error); if(error != SCI_ERR_OK) { DBUG_PRINT("error", ("Cannot initialize SISCI library.")); - DBUG_PRINT("error", ("Inconsistency between SISCI library and SISCI driver. Error code 0x%x", - error)); + DBUG_PRINT("error", + ("Inconsistency between SISCI library and SISCI driver. Error code 0x%x", + error)); DBUG_RETURN(false); } init = true; @@ -1029,3 +906,4 @@ SCI_Transporter::get_free_buffer() const { return (m_TargetSegm[m_ActiveAdapterId].writer)->get_free_buffer(); } + diff --git a/ndb/src/common/transporter/SCI_Transporter.hpp b/ndb/src/common/transporter/SCI_Transporter.hpp index fbba2ac4516..f774186f238 100644 --- a/ndb/src/common/transporter/SCI_Transporter.hpp +++ b/ndb/src/common/transporter/SCI_Transporter.hpp @@ -54,12 +54,12 @@ * local segment, the SCI transporter connects to a segment created by another * transporter at a remote node, and the maps the remote segment into its * virtual address space. However, since NDB Cluster relies on redundancy - * at the network level, by using dual SCI adapters communica - * + * at the network level, by using dual SCI adapters communication can be + * maintained even if one of the adapter cards fails (or anything on the + * network this adapter card exists in e.g. an SCI switch failure). * */ - /** * class SCITransporter * @brief - main class for the SCI transporter. @@ -84,16 +84,6 @@ public: sci_error_t createSequence(Uint32 adapterid); - /** - * starts a sequence for error checking. - * The actual checking that a sequence is correct is done implicitly - * in SCIMemCpy (in doSend). - * @param adapterid the adapter on which to start the sequence. - * @return SCI_ERR_OK if ok, otherwize something else. - */ - sci_error_t startSequence(Uint32 adapterid); - - /** Initiate Local Segment: create a memory segment, * prepare a memory segment, map the local segment * into memory space and make segment available. @@ -159,7 +149,6 @@ private: bool m_mapped; bool m_initLocal; bool m_sciinit; - Uint32 m_swapCounter; Uint32 m_failCounter; /** * For statistics on transfered packets @@ -195,7 +184,6 @@ private: */ Uint32 m_reportFreq; - Uint32 m_adapters; Uint32 m_numberOfRemoteNodes; diff --git a/ndb/src/common/transporter/TCP_Transporter.hpp b/ndb/src/common/transporter/TCP_Transporter.hpp index 4e0de15bdbe..7b6fd0b2323 100644 --- a/ndb/src/common/transporter/TCP_Transporter.hpp +++ b/ndb/src/common/transporter/TCP_Transporter.hpp @@ -102,6 +102,10 @@ private: virtual void updateReceiveDataPtr(Uint32 bytesRead); virtual Uint32 get_free_buffer() const; + + inline bool hasReceiveData () const { + return receiveBuffer.sizeOfData > 0; + } protected: /** * Setup client/server and perform connect/accept diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index bd2ff0d3062..55b31becd8f 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -841,28 +841,13 @@ TransporterRegistry::poll_OSE(Uint32 timeOutMillis) Uint32 TransporterRegistry::poll_TCP(Uint32 timeOutMillis) { + bool hasdata = false; if (false && nTCPTransporters == 0) { tcpReadSelectReply = 0; return 0; } - struct timeval timeout; -#ifdef NDB_OSE - // Return directly if there are no TCP transporters configured - - if(timeOutMillis <= 1){ - timeout.tv_sec = 0; - timeout.tv_usec = 1025; - } else { - timeout.tv_sec = timeOutMillis / 1000; - timeout.tv_usec = (timeOutMillis % 1000) * 1000; - } -#else - timeout.tv_sec = timeOutMillis / 1000; - timeout.tv_usec = (timeOutMillis % 1000) * 1000; -#endif - NDB_SOCKET_TYPE maxSocketValue = -1; // Needed for TCP/IP connections @@ -885,8 +870,27 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis) // Put the connected transporters in the socket read-set FD_SET(socket, &tcpReadset); } + hasdata |= t->hasReceiveData(); } + timeOutMillis = hasdata ? 0 : timeOutMillis; + + struct timeval timeout; +#ifdef NDB_OSE + // Return directly if there are no TCP transporters configured + + if(timeOutMillis <= 1){ + timeout.tv_sec = 0; + timeout.tv_usec = 1025; + } else { + timeout.tv_sec = timeOutMillis / 1000; + timeout.tv_usec = (timeOutMillis % 1000) * 1000; + } +#else + timeout.tv_sec = timeOutMillis / 1000; + timeout.tv_usec = (timeOutMillis % 1000) * 1000; +#endif + // The highest socket value plus one maxSocketValue++; @@ -901,7 +905,7 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis) } #endif - return tcpReadSelectReply; + return tcpReadSelectReply || hasdata; } #endif @@ -937,26 +941,26 @@ TransporterRegistry::performReceive() #endif #ifdef NDB_TCP_TRANSPORTER - if(tcpReadSelectReply > 0) + for (int i=0; i<nTCPTransporters; i++) { - for (int i=0; i<nTCPTransporters; i++) - { - checkJobBuffer(); - TCP_Transporter *t = theTCPTransporters[i]; - const NodeId nodeId = t->getRemoteNodeId(); - const NDB_SOCKET_TYPE socket = t->getSocket(); - if(is_connected(nodeId)){ - if(t->isConnected() && FD_ISSET(socket, &tcpReadset)) + checkJobBuffer(); + TCP_Transporter *t = theTCPTransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + const NDB_SOCKET_TYPE socket = t->getSocket(); + if(is_connected(nodeId)){ + if(t->isConnected()) + { + if (FD_ISSET(socket, &tcpReadset)) { - const int receiveSize = t->doReceive(); - if(receiveSize > 0) - { - Uint32 * ptr; - Uint32 sz = t->getReceiveData(&ptr); - transporter_recv_from(callbackObj, nodeId); - Uint32 szUsed = unpack(ptr, sz, nodeId, ioStates[nodeId]); - t->updateReceiveDataPtr(szUsed); - } + t->doReceive(); + } + + if (t->hasReceiveData()) + { + Uint32 * ptr; + Uint32 sz = t->getReceiveData(&ptr); + Uint32 szUsed = unpack(ptr, sz, nodeId, ioStates[nodeId]); + t->updateReceiveDataPtr(szUsed); } } } diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 9579700663b..1b5e7a27a0c 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -132,6 +132,7 @@ Cmvmi::~Cmvmi() #ifdef ERROR_INSERT NodeBitmask c_error_9000_nodes_mask; +extern Uint32 MAX_RECEIVED_SIGNALS; #endif void Cmvmi::execNDB_TAMPER(Signal* signal) @@ -161,6 +162,22 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) kill(getpid(), SIGABRT); } #endif + +#ifdef ERROR_INSERT + if (signal->theData[0] == 9003) + { + if (MAX_RECEIVED_SIGNALS < 1024) + { + MAX_RECEIVED_SIGNALS = 1024; + } + else + { + MAX_RECEIVED_SIGNALS = 1 + (rand() % 128); + } + ndbout_c("MAX_RECEIVED_SIGNALS: %d", MAX_RECEIVED_SIGNALS); + CLEAR_ERROR_INSERT_VALUE; + } +#endif }//execNDB_TAMPER() void Cmvmi::execSET_LOGLEVELORD(Signal* signal) diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index a039c1bdbe7..d86f32dc8d1 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -79,6 +79,9 @@ #include <NdbSleep.h> #include <signaldata/ApiBroadcast.hpp> +#include <EventLogger.hpp> +extern EventLogger g_eventLogger; + #define ZNOT_FOUND 626 #define ZALREADYEXIST 630 @@ -1069,17 +1072,36 @@ void Dbdict::readSchemaConf(Signal* signal, for (Uint32 n = 0; n < xsf->noOfPages; n++) { SchemaFile * sf = &xsf->schemaPage[n]; - bool ok = - memcmp(sf->Magic, NDB_SF_MAGIC, sizeof(sf->Magic)) == 0 && - sf->FileSize != 0 && - sf->FileSize % NDB_SF_PAGE_SIZE == 0 && - sf->FileSize == sf0->FileSize && - sf->PageNumber == n && - computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS) == 0; - ndbrequire(ok || !crashInd); - if (! ok) { + bool ok = false; + const char *reason; + if (memcmp(sf->Magic, NDB_SF_MAGIC, sizeof(sf->Magic)) != 0) + { jam(); reason = "magic code"; } + else if (sf->FileSize == 0) + { jam(); reason = "file size == 0"; } + else if (sf->FileSize % NDB_SF_PAGE_SIZE != 0) + { jam(); reason = "invalid size multiple"; } + else if (sf->FileSize != sf0->FileSize) + { jam(); reason = "invalid size"; } + else if (sf->PageNumber != n) + { jam(); reason = "invalid page number"; } + else if (computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS) != 0) + { jam(); reason = "invalid checksum"; } + else + ok = true; + + if (!ok) + { + char reason_msg[128]; + snprintf(reason_msg, sizeof(reason_msg), + "schema file corrupt, page %u (%s, " + "sz=%u sz0=%u pn=%u)", + n, reason, sf->FileSize, sf0->FileSize, sf->PageNumber); + if (crashInd) + progError(__LINE__, NDBD_EXIT_SR_SCHEMAFILE, reason_msg); + ndbrequireErr(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1, + NDBD_EXIT_SR_SCHEMAFILE); jam(); - ndbrequire(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1); + infoEvent("primary %s, trying backup", reason_msg); readSchemaRef(signal, fsPtr); return; } diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index a0a19620a05..a76838f7007 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -2816,7 +2816,7 @@ void Qmgr::failReportLab(Signal* signal, Uint16 aFailedNode, if (failedNodePtr.i == getOwnNodeId()) { jam(); - Uint32 code = 0; + Uint32 code = NDBD_EXIT_NODE_DECLARED_DEAD; const char * msg = 0; char extra[100]; switch(aFailCause){ diff --git a/ndb/src/kernel/error/ndbd_exit_codes.c b/ndb/src/kernel/error/ndbd_exit_codes.c index 37a54e33350..92bee522d24 100644 --- a/ndb/src/kernel/error/ndbd_exit_codes.c +++ b/ndb/src/kernel/error/ndbd_exit_codes.c @@ -57,12 +57,15 @@ static const ErrStruct errArray[] = "error(s) on other node(s)"}, {NDBD_EXIT_PARTITIONED_SHUTDOWN, XAE, "Partitioned cluster detected. " "Please check if cluster is already running"}, + {NDBD_EXIT_NODE_DECLARED_DEAD, XAE, + "Node declared dead. See error log for details"}, {NDBD_EXIT_POINTER_NOTINRANGE, XIE, "Pointer too large"}, {NDBD_EXIT_SR_OTHERNODEFAILED, XRE, "Another node failed during system " "restart, please investigate error(s) on other node(s)"}, {NDBD_EXIT_NODE_NOT_DEAD, XRE, "Internal node state conflict, " "most probably resolved by restarting node again"}, {NDBD_EXIT_SR_REDOLOG, XFI, "Error while reading the REDO log"}, + {NDBD_EXIT_SR_SCHEMAFILE, XFI, "Error while reading the schema file"}, /* Currently unused? */ {2311, XIE, "Conflict when selecting restart type"}, {NDBD_EXIT_NO_MORE_UNDOLOG, XCR, diff --git a/ndb/test/ndbapi/testNdbApi.cpp b/ndb/test/ndbapi/testNdbApi.cpp index aee668039fe..ec510c8b270 100644 --- a/ndb/test/ndbapi/testNdbApi.cpp +++ b/ndb/test/ndbapi/testNdbApi.cpp @@ -1306,6 +1306,36 @@ int runTestExecuteAsynch(NDBT_Context* ctx, NDBT_Step* step){ template class Vector<NdbScanOperation*>; +int +runBug28443(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + int records = ctx->getNumRecords(); + + NdbRestarter restarter; + + restarter.insertErrorInAllNodes(9003); + + for (Uint32 i = 0; i<ctx->getNumLoops(); i++) + { + HugoTransactions hugoTrans(*ctx->getTab()); + if (hugoTrans.loadTable(GETNDB(step), records, 2048) != 0) + { + result = NDBT_FAILED; + goto done; + } + if (runClearTable(ctx, step) != 0) + { + result = NDBT_FAILED; + goto done; + } + } + +done: + restarter.insertErrorInAllNodes(9003); + + return result; +} NDBT_TESTSUITE(testNdbApi); TESTCASE("MaxNdb", @@ -1396,6 +1426,10 @@ TESTCASE("ExecuteAsynch", "Check that executeAsync() works (BUG#27495)\n"){ INITIALIZER(runTestExecuteAsynch); } +TESTCASE("Bug28443", + ""){ + INITIALIZER(runBug28443); +} NDBT_TESTSUITE_END(testNdbApi); int main(int argc, const char** argv){ diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index e1a69d923cb..c40c96209f4 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -629,6 +629,10 @@ max-time: 500 cmd: testNdbApi args: -n ExecuteAsynch T1 +max-time: 1000 +cmd: testNdbApi +args: -n BugBug28443 + #max-time: 500 #cmd: testInterpreter #args: T1 diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index bca0581ecbc..e9113b098da 100755 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -13,20 +13,30 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Build mysql_fix_privilege_tables.sql +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql + COMMAND copy /b + mysql_system_tables.sql + mysql_system_tables_fix.sql + mysql_fix_privilege_tables.sql + DEPENDS + ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables.sql + ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables_fix.sql) +# Build comp_sql - used for embedding SQL in C or C++ programs ADD_EXECUTABLE(comp_sql comp_sql.c) TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings) -# Build comp_sql - used for embedding SQL in C or C++ programs +# Use comp_sql to build mysql_fix_privilege_tables_sql.c GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION) ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c COMMAND ${COMP_SQL_EXE} mysql_fix_privilege_tables mysql_fix_privilege_tables.sql - mysql_fix_privilege_tables_sql.c + mysql_fix_privilege_tables_sql.c DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql) +# Add dummy target for the above to be built ADD_CUSTOM_TARGET(GenFixPrivs ALL DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index e8bf39bd016..77f51c51c19 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -102,11 +102,41 @@ case $system in ;; esac +# This is needed to prefer GNU tar over platform tar because that can't +# always handle long filenames + +PATH_DIRS=`echo $PATH | \ + sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' ` + +which_1 () +{ + for cmd + do + for d in $PATH_DIRS + do + for file in $d/$cmd + do + if [ -x $file -a ! -d $file ] ; then + echo $file + exit 0 + fi + done + done + done + exit 1 +} + +tar=`which_1 gnutar gtar` +if [ "$?" = "1" -o x"$tar" = x"" ] ; then + tar=tar +fi + mkdir $BASE $BASE/bin $BASE/docs \ $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \ $BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \ - $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib + $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib \ + $BASE/mysql-test/suite if [ $BASE_SYSTEM != "netware" ] ; then mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man \ @@ -117,8 +147,8 @@ fi # Copy files if they exists, warn for those that don't. # Note that when listing files to copy, we might list the file name -# twice, once in the directory location where it is build, and a -# second time in the ".libs" location. In the case the firs one +# twice, once in the directory location where it is built, and a +# second time in the ".libs" location. In the case the first one # is a wrapper script, the second one will overwrite it with the # binary file. copyfileto() @@ -274,6 +304,13 @@ $CP mysql-test/t/*.test mysql-test/t/*.imtest \ $CP mysql-test/r/*.result mysql-test/r/*.require \ $BASE/mysql-test/r +# Copy the additional suites "as is", they are in flux +$tar cf - mysql-test/suite | ( cd $BASE ; $tar xf - ) +# Clean up if we did this from a bk tree +if [ -d mysql-test/SCCS ] ; then + find $BASE/mysql-test -name SCCS -print | xargs rm -rf +fi + if [ $BASE_SYSTEM != "netware" ] ; then chmod a+x $BASE/bin/* copyfileto $BASE/bin scripts/* @@ -374,41 +411,12 @@ if [ x$DEBUG = x1 ] ; then exit fi -# This is needed to prefere gnu tar instead of tar because tar can't -# always handle long filenames - -PATH_DIRS=`echo $PATH | \ - sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' ` - -which_1 () -{ - for cmd - do - for d in $PATH_DIRS - do - for file in $d/$cmd - do - if [ -x $file -a ! -d $file ] ; then - echo $file - exit 0 - fi - done - done - done - exit 1 -} - if [ $BASE_SYSTEM != "netware" ] ; then # # Create the result tar file # - tar=`which_1 gnutar gtar` - if [ "$?" = "1" -o x"$tar" = x"" ] ; then - tar=tar - fi - echo "Using $tar to create archive" OPT=cvf diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 205bc93efea..c8334339b32 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -9,6 +9,7 @@ # this sql script. # On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' +set sql_mode=''; set storage_engine=MyISAM; ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 4032c273e35..f5d5828e024 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -727,7 +727,39 @@ void init_time(void) } - /* Calculate nr of day since year 0 in new date-system (from 1615) */ +/* + Handle 2 digit year conversions + + SYNOPSIS + year_2000_handling() + year 2 digit year + + RETURN + Year between 1970-2069 +*/ + +uint year_2000_handling(uint year) +{ + if ((year=year+1900) < 1900+YY_PART_YEAR) + year+=100; + return year; +} + + +/* + Calculate nr of day since year 0 in new date-system (from 1615) + + SYNOPSIS + calc_daynr() + year Year (exact 4 digit year, no year conversions) + month Month + day Day + + NOTES: 0000-00-00 is a valid date, and will return 0 + + RETURN + Days since 0000-00-00 +*/ long calc_daynr(uint year,uint month,uint day) { @@ -1120,6 +1152,7 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, ok: part1=(long) (nr/LL(1000000)); part2=(long) (nr - (longlong) part1*LL(1000000)); + bzero((char*) time_res, sizeof(*time_res)); time_res->year= (int) (part1/10000L); part1%=10000L; time_res->month= (int) part1 / 100; time_res->day= (int) part1 % 100; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index e77b4c5765e..1f02e3afc67 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -86,7 +86,7 @@ TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl taocrypt strings vio regex wsock32) IF(EMBED_MANIFESTS) - MYSQL_EMBED_MANIFEST("mysqld" "requireAdministrator") + MYSQL_EMBED_MANIFEST("mysqld" "asInvoker") ENDIF(EMBED_MANIFESTS) IF(WITH_EXAMPLE_STORAGE_ENGINE) diff --git a/sql/field.cc b/sql/field.cc index d2e72371bc1..8186659ae89 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1550,7 +1550,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy) } -bool Field::get_date(TIME *ltime,uint fuzzydate) +bool Field::get_date(MYSQL_TIME *ltime,uint fuzzydate) { char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; @@ -1561,7 +1561,7 @@ bool Field::get_date(TIME *ltime,uint fuzzydate) return 0; } -bool Field::get_time(TIME *ltime) +bool Field::get_time(MYSQL_TIME *ltime) { char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; @@ -1578,7 +1578,7 @@ bool Field::get_time(TIME *ltime) Needs to be changed if/when we want to support different time formats */ -int Field::store_time(TIME *ltime, timestamp_type type_arg) +int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg) { char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= (uint) my_TIME_to_str(ltime, buff); @@ -2504,7 +2504,7 @@ int Field_new_decimal::store_decimal(const my_decimal *decimal_value) } -int Field_new_decimal::store_time(TIME *ltime, timestamp_type t_type) +int Field_new_decimal::store_time(MYSQL_TIME *ltime, timestamp_type t_type) { my_decimal decimal_value; return store_value(date2my_decimal(ltime, &decimal_value)); @@ -4359,7 +4359,8 @@ timestamp_auto_set_type Field_timestamp::get_auto_set_type() const int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) { - TIME l_time; + + MYSQL_TIME l_time; my_time_t tmp= 0; int error; bool have_smth_to_conv; @@ -4429,7 +4430,7 @@ int Field_timestamp::store(double nr) int Field_timestamp::store(longlong nr, bool unsigned_val) { - TIME l_time; + MYSQL_TIME l_time; my_time_t timestamp= 0; int error; my_bool in_dst_time_gap; @@ -4486,7 +4487,7 @@ double Field_timestamp::val_real(void) longlong Field_timestamp::val_int(void) { uint32 temp; - TIME time_tmp; + MYSQL_TIME time_tmp; THD *thd= table ? table->in_use : current_thd; #ifdef WORDS_BIGENDIAN @@ -4511,7 +4512,7 @@ longlong Field_timestamp::val_int(void) String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) { uint32 temp, temp2; - TIME time_tmp; + MYSQL_TIME time_tmp; THD *thd= table ? table->in_use : current_thd; char *to; @@ -4580,7 +4581,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) } -bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate) +bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) { long temp; THD *thd= table ? table->in_use : current_thd; @@ -4604,7 +4605,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate) return 0; } -bool Field_timestamp::get_time(TIME *ltime) +bool Field_timestamp::get_time(MYSQL_TIME *ltime) { return Field_timestamp::get_date(ltime,0); } @@ -4612,7 +4613,7 @@ bool Field_timestamp::get_time(TIME *ltime) bool Field_timestamp::send_binary(Protocol *protocol) { - TIME tm; + MYSQL_TIME tm; Field_timestamp::get_date(&tm, 0); return protocol->store(&tm); } @@ -4688,7 +4689,7 @@ void Field_timestamp::set_time() int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) { - TIME ltime; + MYSQL_TIME ltime; long tmp; int error= 0; int warning; @@ -4703,9 +4704,12 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) else { if (warning & MYSQL_TIME_WARN_TRUNCATED) - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + { + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_TIME, 1); + error= 1; + } if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE) { set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, @@ -4716,8 +4720,6 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) if (ltime.month) ltime.day=0; tmp=(ltime.day*24L+ltime.hour)*10000L+(ltime.minute*100+ltime.second); - if (error > 1) - error= 2; } if (ltime.neg) @@ -4727,7 +4729,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) } -int Field_time::store_time(TIME *ltime, timestamp_type time_type) +int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type) { long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L + (ltime->minute * 100 + ltime->second); @@ -4831,7 +4833,7 @@ longlong Field_time::val_int(void) String *Field_time::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { - TIME ltime; + MYSQL_TIME ltime; val_buffer->alloc(19); long tmp=(long) sint3korr(ptr); ltime.neg= 0; @@ -4855,7 +4857,7 @@ String *Field_time::val_str(String *val_buffer, DATE_FORMAT(time, "%l.%i %p") */ -bool Field_time::get_date(TIME *ltime, uint fuzzydate) +bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate) { long tmp; THD *thd= table ? table->in_use : current_thd; @@ -4883,7 +4885,7 @@ bool Field_time::get_date(TIME *ltime, uint fuzzydate) } -bool Field_time::get_time(TIME *ltime) +bool Field_time::get_time(MYSQL_TIME *ltime) { long tmp=(long) sint3korr(ptr); ltime->neg=0; @@ -4905,7 +4907,7 @@ bool Field_time::get_time(TIME *ltime) bool Field_time::send_binary(Protocol *protocol) { - TIME tm; + MYSQL_TIME tm; Field_time::get_time(&tm); tm.day= tm.hour/24; // Move hours to days tm.hour-= tm.day*24; @@ -5058,7 +5060,7 @@ void Field_year::sql_type(String &res) const int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) { - TIME l_time; + MYSQL_TIME l_time; uint32 tmp; int error; THD *thd= table ? table->in_use : current_thd; @@ -5114,7 +5116,7 @@ int Field_date::store(double nr) int Field_date::store(longlong nr, bool unsigned_val) { - TIME not_used; + MYSQL_TIME not_used; int error; longlong initial_nr= nr; THD *thd= table ? table->in_use : current_thd; @@ -5155,7 +5157,7 @@ int Field_date::store(longlong nr, bool unsigned_val) bool Field_date::send_binary(Protocol *protocol) { longlong tmp= Field_date::val_int(); - TIME tm; + MYSQL_TIME tm; tm.year= (uint32) tmp/10000L % 10000; tm.month= (uint32) tmp/100 % 100; tm.day= (uint32) tmp % 100; @@ -5192,7 +5194,7 @@ longlong Field_date::val_int(void) String *Field_date::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { - TIME ltime; + MYSQL_TIME ltime; val_buffer->alloc(field_length); int32 tmp; #ifdef WORDS_BIGENDIAN @@ -5261,9 +5263,26 @@ void Field_date::sql_type(String &res) const ** In number context: YYYYMMDD ****************************************************************************/ +/* + Store string into a date field + + SYNOPSIS + Field_newdate::store() + from Date string + len Length of date field + cs Character set (not used) + + RETURN + 0 ok + 1 Value was cut during conversion + 2 Wrong date string + 3 Datetime value that was cut (warning level NOTE) +*/ + int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) { - TIME l_time; + long tmp; + MYSQL_TIME l_time; int error; THD *thd= table ? table->in_use : current_thd; enum enum_mysql_timestamp_type ret; @@ -5274,20 +5293,23 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) MODE_INVALID_DATES))), &error)) <= MYSQL_TIMESTAMP_ERROR) { - int3store(ptr,0L); + tmp= 0; error= 2; } else { - int3store(ptr, l_time.day + l_time.month*32 + l_time.year*16*32); - if(!error && (ret != MYSQL_TIMESTAMP_DATE)) - return 2; + tmp= l_time.day + l_time.month*32 + l_time.year*16*32; + if (!error && (ret != MYSQL_TIMESTAMP_DATE)) + error= 3; // Datetime was cut (note) } if (error) - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, + set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE : + MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_DATE, 1); + int3store(ptr, tmp); return error; } @@ -5307,7 +5329,7 @@ int Field_newdate::store(double nr) int Field_newdate::store(longlong nr, bool unsigned_val) { - TIME l_time; + MYSQL_TIME l_time; longlong tmp; int error; THD *thd= table ? table->in_use : current_thd; @@ -5334,7 +5356,7 @@ int Field_newdate::store(longlong nr, bool unsigned_val) } -int Field_newdate::store_time(TIME *ltime, timestamp_type time_type) +int Field_newdate::store_time(MYSQL_TIME *ltime, timestamp_type time_type) { long tmp; int error= 0; @@ -5368,7 +5390,7 @@ int Field_newdate::store_time(TIME *ltime, timestamp_type time_type) bool Field_newdate::send_binary(Protocol *protocol) { - TIME tm; + MYSQL_TIME tm; Field_newdate::get_date(&tm,0); return protocol->store_date(&tm); } @@ -5416,7 +5438,7 @@ String *Field_newdate::val_str(String *val_buffer, } -bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) +bool Field_newdate::get_date(MYSQL_TIME *ltime,uint fuzzydate) { uint32 tmp=(uint32) uint3korr(ptr); ltime->day= tmp & 31; @@ -5429,7 +5451,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) } -bool Field_newdate::get_time(TIME *ltime) +bool Field_newdate::get_time(MYSQL_TIME *ltime) { return Field_newdate::get_date(ltime,0); } @@ -5467,7 +5489,7 @@ void Field_newdate::sql_type(String &res) const int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs) { - TIME time_tmp; + MYSQL_TIME time_tmp; int error; ulonglong tmp= 0; enum enum_mysql_timestamp_type func_res; @@ -5519,7 +5541,7 @@ int Field_datetime::store(double nr) int Field_datetime::store(longlong nr, bool unsigned_val) { - TIME not_used; + MYSQL_TIME not_used; int error; longlong initial_nr= nr; THD *thd= table ? table->in_use : current_thd; @@ -5554,12 +5576,12 @@ int Field_datetime::store(longlong nr, bool unsigned_val) } -int Field_datetime::store_time(TIME *ltime,timestamp_type time_type) +int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type) { longlong tmp; int error= 0; /* - We don't perform range checking here since values stored in TIME + We don't perform range checking here since values stored in MYSQL_TIME structure always fit into DATETIME range. */ if (time_type == MYSQL_TIMESTAMP_DATE || @@ -5599,7 +5621,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type time_type) bool Field_datetime::send_binary(Protocol *protocol) { - TIME tm; + MYSQL_TIME tm; Field_datetime::get_date(&tm, TIME_FUZZY_DATE); return protocol->store(&tm); } @@ -5671,7 +5693,7 @@ String *Field_datetime::val_str(String *val_buffer, return val_buffer; } -bool Field_datetime::get_date(TIME *ltime, uint fuzzydate) +bool Field_datetime::get_date(MYSQL_TIME *ltime, uint fuzzydate) { longlong tmp=Field_datetime::val_int(); uint32 part1,part2; @@ -5690,7 +5712,7 @@ bool Field_datetime::get_date(TIME *ltime, uint fuzzydate) return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0; } -bool Field_datetime::get_time(TIME *ltime) +bool Field_datetime::get_time(MYSQL_TIME *ltime) { return Field_datetime::get_date(ltime,0); } @@ -9059,10 +9081,13 @@ uint32 Field_blob::max_display_length() NOTE This function won't produce warning and increase cut fields counter - if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. + if count_cuted_fields == CHECK_FIELD_IGNORE for current thread. + + if count_cuted_fields == CHECK_FIELD_IGNORE then we ignore notes. + This allows us to avoid notes in optimisation, like convert_constant_item(). RETURN VALUE - 1 if count_cuted_fields == FIELD_CHECK_IGNORE + 1 if count_cuted_fields == CHECK_FIELD_IGNORE and error level is not NOTE 0 otherwise */ @@ -9082,7 +9107,7 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code, thd->row_count); return 0; } - return 1; + return level >= MYSQL_ERROR::WARN_LEVEL_WARN; } @@ -9110,9 +9135,10 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, timestamp_type ts_type, int cuted_increment) { THD *thd= table ? table->in_use : current_thd; - if (thd->really_abort_on_warning() || + if ((thd->really_abort_on_warning() && + level >= MYSQL_ERROR::WARN_LEVEL_WARN) || set_warning(level, code, cuted_increment)) - make_truncated_value_warning(thd, str, str_length, ts_type, + make_truncated_value_warning(thd, level, str, str_length, ts_type, field_name); } @@ -9145,7 +9171,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, { char str_nr[22]; char *str_end= longlong10_to_str(nr, str_nr, -10); - make_truncated_value_warning(thd, str_nr, (uint) (str_end - str_nr), + make_truncated_value_warning(thd, level, str_nr, (uint) (str_end - str_nr), ts_type, field_name); } } @@ -9178,7 +9204,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, /* DBL_DIG is enough to print '-[digits].E+###' */ char str_nr[DBL_DIG + 8]; uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr)); - make_truncated_value_warning(thd, str_nr, str_len, ts_type, + make_truncated_value_warning(thd, level, str_nr, str_len, ts_type, field_name); } } diff --git a/sql/field.h b/sql/field.h index 0d0b1c93a5b..997ae1f2cd4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -98,7 +98,7 @@ public: virtual int store(double nr)=0; virtual int store(longlong nr, bool unsigned_val)=0; virtual int store_decimal(const my_decimal *d)=0; - virtual int store_time(TIME *ltime, timestamp_type t_type); + virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type); virtual double val_real(void)=0; virtual longlong val_int(void)=0; virtual my_decimal *val_decimal(my_decimal *); @@ -326,8 +326,8 @@ public: uint offset(); // Should be inline ... void copy_from_tmp(int offset); uint fill_cache_field(struct st_cache_field *copy); - virtual bool get_date(TIME *ltime,uint fuzzydate); - virtual bool get_time(TIME *ltime); + virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + virtual bool get_time(MYSQL_TIME *ltime); virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; } virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } @@ -529,7 +529,7 @@ public: int store(const char *to, uint length, CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); - int store_time(TIME *ltime, timestamp_type t_type); + int store_time(MYSQL_TIME *ltime, timestamp_type t_type); int store_decimal(const my_decimal *); double val_real(void); longlong val_int(void); @@ -879,8 +879,8 @@ public: longget(tmp,ptr); return tmp; } - bool get_date(TIME *ltime,uint fuzzydate); - bool get_time(TIME *ltime); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + bool get_time(MYSQL_TIME *ltime); timestamp_auto_set_type get_auto_set_type() const; }; @@ -953,7 +953,7 @@ public: int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); - int store_time(TIME *ltime, timestamp_type type); + int store_time(MYSQL_TIME *ltime, timestamp_type type); int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } double val_real(void); longlong val_int(void); @@ -965,8 +965,8 @@ public: void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } bool zero_pack() const { return 1; } - bool get_date(TIME *ltime,uint fuzzydate); - bool get_time(TIME *ltime); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + bool get_time(MYSQL_TIME *ltime); }; @@ -985,7 +985,7 @@ public: enum_field_types type() const { return FIELD_TYPE_TIME;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } enum Item_result cmp_type () const { return INT_RESULT; } - int store_time(TIME *ltime, timestamp_type type); + int store_time(MYSQL_TIME *ltime, timestamp_type type); int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); @@ -993,9 +993,9 @@ public: double val_real(void); longlong val_int(void); String *val_str(String*,String *); - bool get_date(TIME *ltime, uint fuzzydate); + bool get_date(MYSQL_TIME *ltime, uint fuzzydate); bool send_binary(Protocol *protocol); - bool get_time(TIME *ltime); + bool get_time(MYSQL_TIME *ltime); int cmp(const char *,const char*); void sort_string(char *buff,uint length); uint32 pack_length() const { return 3; } @@ -1026,7 +1026,7 @@ public: int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); - int store_time(TIME *ltime, timestamp_type type); + int store_time(MYSQL_TIME *ltime, timestamp_type type); int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; @@ -1042,8 +1042,8 @@ public: void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } bool zero_pack() const { return 1; } - bool get_date(TIME *ltime,uint fuzzydate); - bool get_time(TIME *ltime); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + bool get_time(MYSQL_TIME *ltime); }; diff --git a/sql/filesort.cc b/sql/filesort.cc index 23d652cb8cc..a4bf04a6786 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -249,7 +249,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER, MYF(MY_WME))) goto err; - reinit_io_cache(outfile,WRITE_CACHE,0L,0,0); + if (reinit_io_cache(outfile,WRITE_CACHE,0L,0,0)) + goto err; /* Use also the space previously used by string pointers in sort_buffer @@ -369,6 +370,8 @@ static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count) ulong length; BUFFPEK *tmp; DBUG_ENTER("read_buffpek_from_file"); + if (count > UINT_MAX/sizeof(BUFFPEK)) + return 0; /* sizeof(BUFFPEK)*count will overflow */ tmp=(BUFFPEK*) my_malloc(length=sizeof(BUFFPEK)*count, MYF(MY_WME)); if (tmp) { @@ -600,6 +603,9 @@ write_keys(SORTPARAM *param, register uchar **sort_keys, uint count, open_cached_file(tempfile, mysql_tmpdir, TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME))) goto err; /* purecov: inspected */ + /* check we won't have more buffpeks than we can possibly keep in memory */ + if (my_b_tell(buffpek_pointers) + sizeof(BUFFPEK) > (ulonglong)UINT_MAX) + goto err; buffpek.file_pos= my_b_tell(tempfile); if ((ha_rows) count > param->max_rows) count=(uint) param->max_rows; /* purecov: inspected */ @@ -907,7 +913,7 @@ static bool save_index(SORTPARAM *param, uchar **sort_keys, uint count, int merge_many_buff(SORTPARAM *param, uchar *sort_buffer, BUFFPEK *buffpek, uint *maxbuffer, IO_CACHE *t_file) { - register int i; + register uint i; IO_CACHE t_file2,*from_file,*to_file,*temp; BUFFPEK *lastbuff; DBUG_ENTER("merge_many_buff"); @@ -922,14 +928,16 @@ int merge_many_buff(SORTPARAM *param, uchar *sort_buffer, from_file= t_file ; to_file= &t_file2; while (*maxbuffer >= MERGEBUFF2) { - reinit_io_cache(from_file,READ_CACHE,0L,0,0); - reinit_io_cache(to_file,WRITE_CACHE,0L,0,0); + if (reinit_io_cache(from_file,READ_CACHE,0L,0,0)) + goto cleanup; + if (reinit_io_cache(to_file,WRITE_CACHE,0L,0,0)) + goto cleanup; lastbuff=buffpek; - for (i=0 ; i <= (int) *maxbuffer-MERGEBUFF*3/2 ; i+=MERGEBUFF) + for (i=0 ; i <= *maxbuffer-MERGEBUFF*3/2 ; i+=MERGEBUFF) { if (merge_buffers(param,from_file,to_file,sort_buffer,lastbuff++, buffpek+i,buffpek+i+MERGEBUFF-1,0)) - break; /* purecov: inspected */ + goto cleanup; } if (merge_buffers(param,from_file,to_file,sort_buffer,lastbuff++, buffpek+i,buffpek+ *maxbuffer,0)) @@ -941,6 +949,7 @@ int merge_many_buff(SORTPARAM *param, uchar *sort_buffer, setup_io_cache(to_file); *maxbuffer= (uint) (lastbuff-buffpek)-1; } +cleanup: close_cached_file(to_file); // This holds old result if (to_file == t_file) { diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h index 0046a57d10a..4dcb37c637d 100644 --- a/sql/ha_blackhole.h +++ b/sql/ha_blackhole.h @@ -43,8 +43,7 @@ public: { return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | - HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME | - HA_CAN_INSERT_DELAYED); + HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME); } ulong index_flags(uint inx, uint part, bool all_parts) const { diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 6d8a770175d..9a397ffbbac 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -956,8 +956,8 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) param.sort_buffer_length= check_opt->sort_buffer_size; if ((error= repair(thd,param,1)) && param.retry_repair) { - sql_print_warning("Warning: Optimize table got errno %d, retrying", - my_errno); + sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying", + my_errno, param.db_name, param.table_name); param.testflag&= ~T_REP_BY_SORT; error= repair(thd,param,1); } @@ -1347,8 +1347,8 @@ int ha_myisam::enable_indexes(uint mode) param.tmpdir=&mysql_tmpdir_list; if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair) { - sql_print_warning("Warning: Enabling keys got errno %d, retrying", - my_errno); + sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, retrying", + my_errno, param.db_name, param.table_name); /* Repairing by sort failed. Now try standard repair method. */ param.testflag&= ~(T_REP_BY_SORT | T_QUICK); error= (repair(thd,param,0) != HA_ADMIN_OK); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9b48e0d4f38..0f3a42bbce7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2309,16 +2309,24 @@ int ha_ndbcluster::write_row(byte *record) { // Table has hidden primary key Ndb *ndb= get_ndb(); - int ret; Uint64 auto_value; uint retries= NDB_AUTO_INCREMENT_RETRIES; - do { - ret= ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, 1); - } while (ret == -1 && - --retries && - ndb->getNdbError().status == NdbError::TemporaryError); - if (ret == -1) - ERR_RETURN(ndb->getNdbError()); + int retry_sleep= 30; /* 30 milliseconds, transaction */ + for (;;) + { + if (ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, 1) == -1) + { + if (--retries && + ndb->getNdbError().status == NdbError::TemporaryError); + { + my_sleep(retry_sleep); + continue; + } + ERR_RETURN(ndb->getNdbError()); + } + break; + } if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } @@ -4855,22 +4863,27 @@ ulonglong ha_ndbcluster::get_auto_increment() m_rows_to_insert - m_rows_inserted : ((m_rows_to_insert > m_autoincrement_prefetch) ? m_rows_to_insert : m_autoincrement_prefetch)); - int ret; uint retries= NDB_AUTO_INCREMENT_RETRIES; - do { - ret= - m_skip_auto_increment ? - ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) : - ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, cache_size); - } while (ret == -1 && - --retries && - ndb->getNdbError().status == NdbError::TemporaryError); - if (ret == -1) - { - const NdbError err= ndb->getNdbError(); - sql_print_error("Error %lu in ::get_auto_increment(): %s", - (ulong) err.code, err.message); - DBUG_RETURN(~(ulonglong) 0); + int retry_sleep= 30; /* 30 milliseconds, transaction */ + for (;;) + { + if (m_skip_auto_increment && + ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) || + ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, cache_size)) + { + if (--retries && + ndb->getNdbError().status == NdbError::TemporaryError); + { + my_sleep(retry_sleep); + continue; + } + const NdbError err= ndb->getNdbError(); + sql_print_error("Error %lu in ::get_auto_increment(): %s", + (ulong) err.code, err.message); + DBUG_RETURN(~(ulonglong) 0); + } + break; } DBUG_RETURN((longlong)auto_value); } @@ -5011,27 +5024,36 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) set_dbname(name); set_tabname(name); - if (check_ndb_connection()) { - free_share(m_share); m_share= 0; - DBUG_RETURN(HA_ERR_NO_CONNECTION); + if ((res= check_ndb_connection()) || + (res= get_metadata(name))) + { + free_share(m_share); + m_share= 0; + DBUG_RETURN(res); } - - res= get_metadata(name); - if (!res) + while (1) { Ndb *ndb= get_ndb(); if (ndb->setDatabaseName(m_dbname)) { - ERR_RETURN(ndb->getNdbError()); + res= ndb_to_mysql_error(&ndb->getNdbError()); + break; } struct Ndb_statistics stat; res= ndb_get_table_statistics(NULL, false, ndb, m_tabname, &stat); records= stat.row_count; if(!res) res= info(HA_STATUS_CONST); + break; } - - DBUG_RETURN(res); + if (res) + { + free_share(m_share); + m_share= 0; + release_metadata(); + DBUG_RETURN(res); + } + DBUG_RETURN(0); } diff --git a/sql/item.cc b/sql/item.cc index 651ab826484..92ea35072f9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -270,7 +270,7 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_date(<ime, TIME_FUZZY_DATE)) { my_decimal_set_zero(decimal_value); @@ -283,7 +283,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_time(<ime)) { my_decimal_set_zero(decimal_value); @@ -318,7 +318,7 @@ longlong Item::val_int_from_decimal() int Item::save_time_in_field(Field *field) { - TIME ltime; + MYSQL_TIME ltime; if (get_time(<ime)) return set_field_to_null(field); field->set_notnull(); @@ -328,7 +328,7 @@ int Item::save_time_in_field(Field *field) int Item::save_date_in_field(Field *field) { - TIME ltime; + MYSQL_TIME ltime; if (get_date(<ime, TIME_FUZZY_DATE)) return set_field_to_null(field); field->set_notnull(); @@ -836,22 +836,40 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const /* - Get the value of the function as a TIME structure. + Get the value of the function as a MYSQL_TIME structure. As a extra convenience the time structure is reset on error! */ -bool Item::get_date(TIME *ltime,uint fuzzydate) +bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) { - char buff[40]; - String tmp(buff,sizeof(buff), &my_charset_bin),*res; - if (!(res=val_str(&tmp)) || - str_to_datetime_with_warn(res->ptr(), res->length(), - ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + if (result_type() == STRING_RESULT) { - bzero((char*) ltime,sizeof(*ltime)); - return 1; + char buff[40]; + String tmp(buff,sizeof(buff), &my_charset_bin),*res; + if (!(res=val_str(&tmp)) || + str_to_datetime_with_warn(res->ptr(), res->length(), + ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) + goto err; + } + else + { + longlong value= val_int(); + int was_cut; + if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1)) + { + char buff[22], *end; + end= longlong10_to_str(value, buff, -10); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE, + NullS); + goto err; + } } return 0; + +err: + bzero((char*) ltime,sizeof(*ltime)); + return 1; } /* @@ -859,7 +877,7 @@ bool Item::get_date(TIME *ltime,uint fuzzydate) As a extra convenience the time structure is reset on error! */ -bool Item::get_time(TIME *ltime) +bool Item::get_time(MYSQL_TIME *ltime) { char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; @@ -1838,7 +1856,7 @@ String *Item_field::str_result(String *str) return result_field->val_str(str,&str_value); } -bool Item_field::get_date(TIME *ltime,uint fuzzydate) +bool Item_field::get_date(MYSQL_TIME *ltime,uint fuzzydate) { if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate)) { @@ -1848,7 +1866,7 @@ bool Item_field::get_date(TIME *ltime,uint fuzzydate) return 0; } -bool Item_field::get_date_result(TIME *ltime,uint fuzzydate) +bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate) { if ((null_value=result_field->is_null()) || result_field->get_date(ltime,fuzzydate)) @@ -1859,7 +1877,7 @@ bool Item_field::get_date_result(TIME *ltime,uint fuzzydate) return 0; } -bool Item_field::get_time(TIME *ltime) +bool Item_field::get_time(MYSQL_TIME *ltime) { if ((null_value=field->is_null()) || field->get_time(ltime)) { @@ -2386,7 +2404,7 @@ void Item_param::set_decimal(const char *str, ulong length) /* - Set parameter value from TIME value. + Set parameter value from MYSQL_TIME value. SYNOPSIS set_time() @@ -2400,7 +2418,7 @@ void Item_param::set_decimal(const char *str, ulong length) the fact that even wrong value sent over binary protocol fits into MAX_DATE_STRING_REP_LENGTH buffer. */ -void Item_param::set_time(TIME *tm, timestamp_type time_type, +void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type, uint32 max_length_arg) { DBUG_ENTER("Item_param::set_time"); @@ -2415,7 +2433,8 @@ void Item_param::set_time(TIME *tm, timestamp_type time_type, { char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= my_TIME_to_str(&value.time, buff); - make_truncated_value_warning(current_thd, buff, length, time_type, 0); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + buff, length, time_type, 0); set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR); } @@ -2616,7 +2635,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions) } -bool Item_param::get_time(TIME *res) +bool Item_param::get_time(MYSQL_TIME *res) { if (state == TIME_VALUE) { @@ -2631,7 +2650,7 @@ bool Item_param::get_time(TIME *res) } -bool Item_param::get_date(TIME *res, uint fuzzydate) +bool Item_param::get_date(MYSQL_TIME *res, uint fuzzydate) { if (state == TIME_VALUE) { @@ -3057,7 +3076,7 @@ String* Item_ref_null_helper::val_str(String* s) } -bool Item_ref_null_helper::get_date(TIME *ltime, uint fuzzydate) +bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, uint fuzzydate) { return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate)); } @@ -4852,7 +4871,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_DATE: case MYSQL_TYPE_TIMESTAMP: { - TIME tm; + MYSQL_TIME tm; get_date(&tm, TIME_FUZZY_DATE); if (!null_value) { @@ -4865,7 +4884,7 @@ bool Item::send(Protocol *protocol, String *buffer) } case MYSQL_TYPE_TIME: { - TIME tm; + MYSQL_TIME tm; get_time(&tm); if (!null_value) result= protocol->store_time(&tm); @@ -5437,7 +5456,7 @@ bool Item_ref::is_null() } -bool Item_ref::get_date(TIME *ltime,uint fuzzydate) +bool Item_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate) { return (null_value=(*ref)->get_date_result(ltime,fuzzydate)); } @@ -5536,7 +5555,7 @@ bool Item_direct_ref::is_null() } -bool Item_direct_ref::get_date(TIME *ltime,uint fuzzydate) +bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate) { return (null_value=(*ref)->get_date(ltime,fuzzydate)); } diff --git a/sql/item.h b/sql/item.h index 18a05b0b4ad..11dce3a7758 100644 --- a/sql/item.h +++ b/sql/item.h @@ -689,9 +689,9 @@ public: /* Called for items that really have to be split */ void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields, Item **ref, bool skip_registered); - virtual bool get_date(TIME *ltime,uint fuzzydate); - virtual bool get_time(TIME *ltime); - virtual bool get_date_result(TIME *ltime,uint fuzzydate) + virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + virtual bool get_time(MYSQL_TIME *ltime); + virtual bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate) { return get_date(ltime,fuzzydate); } /* The method allows to determine nullness of a complex expression @@ -1273,9 +1273,9 @@ public: } Field *get_tmp_table_field() { return result_field; } Field *tmp_table_field(TABLE *t_arg) { return result_field; } - bool get_date(TIME *ltime,uint fuzzydate); - bool get_date_result(TIME *ltime,uint fuzzydate); - bool get_time(TIME *ltime); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); + bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate); + bool get_time(MYSQL_TIME *ltime); bool is_null() { return field->is_null(); } void update_null_value(); Item *get_tmp_table_item(THD *thd); @@ -1402,7 +1402,7 @@ public: */ CHARSET_INFO *final_character_set_of_str_value; } cs_info; - TIME time; + MYSQL_TIME time; } value; /* Cached values for virtual methods to save us one switch. */ @@ -1434,8 +1434,8 @@ public: longlong val_int(); my_decimal *val_decimal(my_decimal*); String *val_str(String*); - bool get_time(TIME *tm); - bool get_date(TIME *tm, uint fuzzydate); + bool get_time(MYSQL_TIME *tm); + bool get_date(MYSQL_TIME *tm, uint fuzzydate); int save_in_field(Field *field, bool no_conversions); void set_null(); @@ -1444,7 +1444,7 @@ public: void set_decimal(const char *str, ulong length); bool set_str(const char *str, ulong length); bool set_longdata(const char *str, ulong length); - void set_time(TIME *tm, timestamp_type type, uint32 max_length_arg); + void set_time(MYSQL_TIME *tm, timestamp_type type, uint32 max_length_arg); bool set_from_user_var(THD *thd, const user_var_entry *entry); void reset(); /* @@ -1877,7 +1877,7 @@ public: bool val_bool(); String *val_str(String* tmp); bool is_null(); - bool get_date(TIME *ltime,uint fuzzydate); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); double val_result(); longlong val_int_result(); String *str_result(String* tmp); @@ -1954,7 +1954,7 @@ public: my_decimal *val_decimal(my_decimal *); bool val_bool(); bool is_null(); - bool get_date(TIME *ltime,uint fuzzydate); + bool get_date(MYSQL_TIME *ltime,uint fuzzydate); virtual Ref_Type ref_type() { return DIRECT_REF; } }; @@ -2059,7 +2059,7 @@ public: String* val_str(String* s); my_decimal *val_decimal(my_decimal *); bool val_bool(); - bool get_date(TIME *ltime, uint fuzzydate); + bool get_date(MYSQL_TIME *ltime, uint fuzzydate); void print(String *str); /* we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3a79940b571..0de9ef3e9ad 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -316,8 +316,10 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item) { /* For comparison purposes allow invalid dates like 2000-01-32 */ ulong orig_sql_mode= thd->variables.sql_mode; + enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields; thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) | MODE_INVALID_DATES; + thd->count_cuted_fields= CHECK_FIELD_IGNORE; if (!(*item)->save_in_field(field, 1) && !((*item)->null_value)) { Item *tmp=new Item_int_with_ref(field->val_int(), *item, @@ -328,6 +330,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item) return 1; // Item was replaced } thd->variables.sql_mode= orig_sql_mode; + thd->count_cuted_fields= orig_count_cuted_fields; } return 0; } @@ -564,8 +567,9 @@ get_date_from_str(THD *thd, String *str, timestamp_type warn_type, if (error || *error_arg) { - make_truncated_value_warning(thd, str->ptr(), str->length(), warn_type, - warn_name); + make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str->ptr(), str->length(), + warn_type, warn_name); *error_arg= TRUE; } return value; diff --git a/sql/item_func.cc b/sql/item_func.cc index 12ec3bd54ac..34f3c2c6add 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2025,9 +2025,9 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, tmp=(abs_dec < array_elements(log_10) ? log_10[abs_dec] : pow(10.0,(double) abs_dec)); - if (dec_negative && isinf(tmp)) + if (dec_negative && my_isinf(tmp)) tmp2= 0; - else if (!dec_negative && isinf(value * tmp)) + else if (!dec_negative && my_isinf(value * tmp)) tmp2= value; else if (truncate) { diff --git a/sql/item_func.h b/sql/item_func.h index 7ec3c0b00c4..1cffe9a934e 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -147,11 +147,11 @@ public: void count_only_length(); void count_real_length(); void count_decimal_length(); - inline bool get_arg0_date(TIME *ltime, uint fuzzy_date) + inline bool get_arg0_date(MYSQL_TIME *ltime, uint fuzzy_date) { return (null_value=args[0]->get_date(ltime, fuzzy_date)); } - inline bool get_arg0_time(TIME *ltime) + inline bool get_arg0_time(MYSQL_TIME *ltime) { return (null_value=args[0]->get_time(ltime)); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 194fb6445fa..f5895369a55 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -46,7 +46,7 @@ the microseconds twice. */ -static bool make_datetime(date_time_format_types format, TIME *ltime, +static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime, String *str) { char *buff; @@ -95,7 +95,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, /* - Wrapper over make_datetime() with validation of the input TIME value + Wrapper over make_datetime() with validation of the input MYSQL_TIME value NOTE see make_datetime() for more information @@ -105,7 +105,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, 0 otherwise */ -static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime, +static bool make_datetime_with_warn(date_time_format_types format, MYSQL_TIME *ltime, String *str) { int warning= 0; @@ -117,14 +117,15 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime, if (!warning) return 0; - make_truncated_value_warning(current_thd, str->ptr(), str->length(), + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str->ptr(), str->length(), MYSQL_TIMESTAMP_TIME, NullS); return make_datetime(format, ltime, str); } /* - Wrapper over make_time() with validation of the input TIME value + Wrapper over make_time() with validation of the input MYSQL_TIME value NOTE see make_time() for more info @@ -135,7 +136,7 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime, */ static bool make_time_with_warn(const DATE_TIME_FORMAT *format, - TIME *l_time, String *str) + MYSQL_TIME *l_time, String *str) { int warning= 0; make_time(format, l_time, str); @@ -143,7 +144,8 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format, return 1; if (warning) { - make_truncated_value_warning(current_thd, str->ptr(), str->length(), + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str->ptr(), str->length(), MYSQL_TIMESTAMP_TIME, NullS); make_time(format, l_time, str); } @@ -153,16 +155,16 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format, /* - Convert seconds to TIME value with overflow checking + Convert seconds to MYSQL_TIME value with overflow checking SYNOPSIS: sec_to_time() seconds number of seconds unsigned_flag 1, if 'seconds' is unsigned, 0, otherwise - ltime output TIME value + ltime output MYSQL_TIME value DESCRIPTION - If the 'seconds' argument is inside TIME data range, convert it to a + If the 'seconds' argument is inside MYSQL_TIME data range, convert it to a corresponding value. Otherwise, truncate the resulting value to the nearest endpoint, and produce a warning message. @@ -172,7 +174,7 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format, 0 otherwise */ -static bool sec_to_time(longlong seconds, bool unsigned_flag, TIME *ltime) +static bool sec_to_time(longlong seconds, bool unsigned_flag, MYSQL_TIME *ltime) { uint sec; @@ -205,7 +207,8 @@ overflow: char buf[22]; int len= (int)(longlong10_to_str(seconds, buf, unsigned_flag ? 10 : -10) - buf); - make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME, + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + buf, len, MYSQL_TIMESTAMP_TIME, NullS); return 1; @@ -224,7 +227,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0, {(char *)"%H:%i:%S", 8}}; /* - Extract datetime value to TIME struct from string value + Extract datetime value to MYSQL_TIME struct from string value according to format string. SYNOPSIS @@ -257,7 +260,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0, */ static bool extract_date_time(DATE_TIME_FORMAT *format, - const char *val, uint length, TIME *l_time, + const char *val, uint length, MYSQL_TIME *l_time, timestamp_type cached_timestamp_type, const char **sub_pattern_end, const char *date_time_type) @@ -305,13 +308,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, case 'Y': tmp= (char*) val + min(4, val_len); l_time->year= (int) my_strtoll10(val, &tmp, &error); + if ((int) (tmp-val) <= 2) + l_time->year= year_2000_handling(l_time->year); val= tmp; break; case 'y': tmp= (char*) val + min(2, val_len); l_time->year= (int) my_strtoll10(val, &tmp, &error); val= tmp; - l_time->year+= (l_time->year < YY_PART_YEAR ? 2000 : 1900); + l_time->year= year_2000_handling(l_time->year); break; /* Month */ @@ -514,7 +519,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, if (yearday > 0) { - uint days= calc_daynr(l_time->year,1,1) + yearday - 1; + uint days; + days= calc_daynr(l_time->year,1,1) + yearday - 1; if (days <= 0 || days > MAX_DAY_NUMBER) goto err; get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day); @@ -576,7 +582,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, { if (!my_isspace(&my_charset_latin1,*val)) { - make_truncated_value_warning(current_thd, val_begin, length, + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + val_begin, length, cached_timestamp_type, NullS); break; } @@ -600,7 +607,7 @@ err: Create a formated date/time value in a string */ -bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, +bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, timestamp_type type, String *str) { char intbuff[15]; @@ -915,8 +922,8 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, */ -static bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, - longlong *seconds_out, long *microseconds_out) +bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, + longlong *seconds_out, long *microseconds_out) { long days; bool neg; @@ -996,7 +1003,7 @@ longlong Item_func_period_diff::val_int() longlong Item_func_to_days::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) return 0; return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day); @@ -1005,7 +1012,7 @@ longlong Item_func_to_days::val_int() longlong Item_func_dayofyear::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime,TIME_NO_ZERO_DATE)) return 0; return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day) - @@ -1015,7 +1022,7 @@ longlong Item_func_dayofyear::val_int() longlong Item_func_dayofmonth::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_date(<ime, TIME_FUZZY_DATE); return (longlong) ltime.day; } @@ -1023,7 +1030,7 @@ longlong Item_func_dayofmonth::val_int() longlong Item_func_month::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_date(<ime, TIME_FUZZY_DATE); return (longlong) ltime.month; } @@ -1053,7 +1060,7 @@ String* Item_func_monthname::val_str(String* str) longlong Item_func_quarter::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime, TIME_FUZZY_DATE)) return 0; return (longlong) ((ltime.month+2)/3); @@ -1062,7 +1069,7 @@ longlong Item_func_quarter::val_int() longlong Item_func_hour::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_time(<ime); return ltime.hour; } @@ -1070,7 +1077,7 @@ longlong Item_func_hour::val_int() longlong Item_func_minute::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_time(<ime); return ltime.minute; } @@ -1079,7 +1086,7 @@ longlong Item_func_minute::val_int() longlong Item_func_second::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_time(<ime); return ltime.second; } @@ -1126,7 +1133,7 @@ longlong Item_func_week::val_int() { DBUG_ASSERT(fixed == 1); uint year; - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) return 0; return (longlong) calc_week(<ime, @@ -1139,7 +1146,7 @@ longlong Item_func_yearweek::val_int() { DBUG_ASSERT(fixed == 1); uint year,week; - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) return 0; week= calc_week(<ime, @@ -1152,7 +1159,7 @@ longlong Item_func_yearweek::val_int() longlong Item_func_weekday::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) return 0; @@ -1182,7 +1189,7 @@ String* Item_func_dayname::val_str(String* str) longlong Item_func_year::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; (void) get_arg0_date(<ime, TIME_FUZZY_DATE); return (longlong) ltime.year; } @@ -1190,7 +1197,7 @@ longlong Item_func_year::val_int() longlong Item_func_unix_timestamp::val_int() { - TIME ltime; + MYSQL_TIME ltime; my_bool not_used; DBUG_ASSERT(fixed == 1); @@ -1221,7 +1228,7 @@ longlong Item_func_unix_timestamp::val_int() longlong Item_func_time_to_sec::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; longlong seconds; (void) get_arg0_time(<ime); seconds=ltime.hour*3600L+ltime.minute*60+ltime.second; @@ -1390,7 +1397,7 @@ static bool get_interval_value(Item *args,interval_type int_type, String *Item_date::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_date(<ime, TIME_FUZZY_DATE)) return (String *) 0; if (str->alloc(11)) @@ -1406,19 +1413,19 @@ String *Item_date::val_str(String *str) longlong Item_date::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_date(<ime, TIME_FUZZY_DATE)) return 0; return (longlong) (ltime.year*10000L+ltime.month*100+ltime.day); } -bool Item_func_from_days::get_date(TIME *ltime, uint fuzzy_date) +bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { longlong value=args[0]->val_int(); if ((null_value=args[0]->null_value)) return 1; - bzero(ltime, sizeof(TIME)); + bzero(ltime, sizeof(MYSQL_TIME)); get_date_from_daynr((long) value, <ime->year, <ime->month, <ime->day); ltime->time_type= MYSQL_TIMESTAMP_DATE; return 0; @@ -1452,10 +1459,10 @@ String *Item_func_curdate::val_str(String *str) } /* - Converts current time in my_time_t to TIME represenatation for local + Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole CURDATE function. */ -void Item_func_curdate_local::store_now_in_TIME(TIME *now_time) +void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time) { THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, @@ -1465,10 +1472,10 @@ void Item_func_curdate_local::store_now_in_TIME(TIME *now_time) /* - Converts current time in my_time_t to TIME represenatation for UTC + Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_DATE function. */ -void Item_func_curdate_utc::store_now_in_TIME(TIME *now_time) +void Item_func_curdate_utc::store_now_in_TIME(MYSQL_TIME *now_time) { my_tz_UTC->gmt_sec_to_TIME(now_time, (my_time_t)(current_thd->query_start())); @@ -1479,7 +1486,7 @@ void Item_func_curdate_utc::store_now_in_TIME(TIME *now_time) } -bool Item_func_curdate::get_date(TIME *res, +bool Item_func_curdate::get_date(MYSQL_TIME *res, uint fuzzy_date __attribute__((unused))) { *res=ltime; @@ -1497,7 +1504,7 @@ String *Item_func_curtime::val_str(String *str) void Item_func_curtime::fix_length_and_dec() { - TIME ltime; + MYSQL_TIME ltime; decimals= DATETIME_DEC; collation.set(&my_charset_bin); @@ -1509,10 +1516,10 @@ void Item_func_curtime::fix_length_and_dec() /* - Converts current time in my_time_t to TIME represenatation for local + Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole CURTIME function. */ -void Item_func_curtime_local::store_now_in_TIME(TIME *now_time) +void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time) { THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, @@ -1522,10 +1529,10 @@ void Item_func_curtime_local::store_now_in_TIME(TIME *now_time) /* - Converts current time in my_time_t to TIME represenatation for UTC + Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_TIME function. */ -void Item_func_curtime_utc::store_now_in_TIME(TIME *now_time) +void Item_func_curtime_utc::store_now_in_TIME(MYSQL_TIME *now_time) { my_tz_UTC->gmt_sec_to_TIME(now_time, (my_time_t)(current_thd->query_start())); @@ -1558,10 +1565,10 @@ void Item_func_now::fix_length_and_dec() /* - Converts current time in my_time_t to TIME represenatation for local + Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole NOW function. */ -void Item_func_now_local::store_now_in_TIME(TIME *now_time) +void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time) { THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, @@ -1571,10 +1578,10 @@ void Item_func_now_local::store_now_in_TIME(TIME *now_time) /* - Converts current time in my_time_t to TIME represenatation for UTC + Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function. */ -void Item_func_now_utc::store_now_in_TIME(TIME *now_time) +void Item_func_now_utc::store_now_in_TIME(MYSQL_TIME *now_time) { my_tz_UTC->gmt_sec_to_TIME(now_time, (my_time_t)(current_thd->query_start())); @@ -1585,7 +1592,7 @@ void Item_func_now_utc::store_now_in_TIME(TIME *now_time) } -bool Item_func_now::get_date(TIME *res, +bool Item_func_now::get_date(MYSQL_TIME *res, uint fuzzy_date __attribute__((unused))) { *res= ltime; @@ -1602,10 +1609,10 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions) /* - Converts current time in my_time_t to TIME represenatation for local + Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole SYSDATE function. */ -void Item_func_sysdate_local::store_now_in_TIME(TIME *now_time) +void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time) { THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL)); @@ -1647,7 +1654,7 @@ void Item_func_sysdate_local::fix_length_and_dec() } -bool Item_func_sysdate_local::get_date(TIME *res, +bool Item_func_sysdate_local::get_date(MYSQL_TIME *res, uint fuzzy_date __attribute__((unused))) { store_now_in_TIME(<ime); @@ -1668,7 +1675,7 @@ int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions) String *Item_func_sec_to_time::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; longlong arg_val= args[0]->val_int(); if ((null_value=args[0]->null_value) || str->alloc(19)) @@ -1687,7 +1694,7 @@ String *Item_func_sec_to_time::val_str(String *str) longlong Item_func_sec_to_time::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; longlong arg_val= args[0]->val_int(); if ((null_value=args[0]->null_value)) @@ -1829,7 +1836,7 @@ uint Item_func_date_format::format_length(const String *format) String *Item_func_date_format::val_str(String *str) { String *format; - TIME l_time; + MYSQL_TIME l_time; uint size; DBUG_ASSERT(fixed == 1); @@ -1892,7 +1899,7 @@ void Item_func_from_unixtime::fix_length_and_dec() String *Item_func_from_unixtime::val_str(String *str) { - TIME time_tmp; + MYSQL_TIME time_tmp; DBUG_ASSERT(fixed == 1); @@ -1912,7 +1919,7 @@ String *Item_func_from_unixtime::val_str(String *str) longlong Item_func_from_unixtime::val_int() { - TIME time_tmp; + MYSQL_TIME time_tmp; DBUG_ASSERT(fixed == 1); @@ -1922,7 +1929,7 @@ longlong Item_func_from_unixtime::val_int() return (longlong) TIME_to_ulonglong_datetime(&time_tmp); } -bool Item_func_from_unixtime::get_date(TIME *ltime, +bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((unused))) { ulonglong tmp= (ulonglong)(args[0]->val_int()); @@ -1963,7 +1970,7 @@ Item_func_convert_tz::fix_fields(THD *thd_arg, Item **ref) String *Item_func_convert_tz::val_str(String *str) { - TIME time_tmp; + MYSQL_TIME time_tmp; if (get_date(&time_tmp, 0)) return 0; @@ -1981,7 +1988,7 @@ String *Item_func_convert_tz::val_str(String *str) longlong Item_func_convert_tz::val_int() { - TIME time_tmp; + MYSQL_TIME time_tmp; if (get_date(&time_tmp, 0)) return 0; @@ -1990,7 +1997,7 @@ longlong Item_func_convert_tz::val_int() } -bool Item_func_convert_tz::get_date(TIME *ltime, +bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((unused))) { my_time_t my_time_tmp; @@ -2051,7 +2058,7 @@ void Item_date_add_interval::fix_length_and_dec() - If first arg is a MYSQL_TYPE_DATE and the interval type uses hours, minutes or seconds then type is MYSQL_TYPE_DATETIME. - Otherwise the result is MYSQL_TYPE_STRING - (This is because you can't know if the string contains a DATE, TIME or + (This is because you can't know if the string contains a DATE, MYSQL_TIME or DATETIME argument) */ cached_field_type= MYSQL_TYPE_STRING; @@ -2071,7 +2078,7 @@ void Item_date_add_interval::fix_length_and_dec() /* Here arg[1] is a Item_interval object */ -bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date) +bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { long period,sign; INTERVAL interval; @@ -2209,7 +2216,7 @@ invalid_date: String *Item_date_add_interval::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; enum date_time_format_types format; if (Item_date_add_interval::get_date(<ime, TIME_NO_ZERO_DATE)) @@ -2233,7 +2240,7 @@ String *Item_date_add_interval::val_str(String *str) longlong Item_date_add_interval::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; longlong date; if (Item_date_add_interval::get_date(<ime, TIME_NO_ZERO_DATE)) return (longlong) 0; @@ -2322,7 +2329,7 @@ void Item_extract::fix_length_and_dec() longlong Item_extract::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; uint year; ulong week_format; long neg; @@ -2574,7 +2581,7 @@ void Item_char_typecast::fix_length_and_dec() String *Item_datetime_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (!get_arg0_date(<ime, TIME_FUZZY_DATE) && !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, <ime, str)) @@ -2588,7 +2595,7 @@ String *Item_datetime_typecast::val_str(String *str) longlong Item_datetime_typecast::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (get_arg0_date(<ime,1)) { null_value= 1; @@ -2599,7 +2606,7 @@ longlong Item_datetime_typecast::val_int() } -bool Item_time_typecast::get_time(TIME *ltime) +bool Item_time_typecast::get_time(MYSQL_TIME *ltime) { bool res= get_arg0_time(ltime); /* @@ -2615,7 +2622,7 @@ bool Item_time_typecast::get_time(TIME *ltime) longlong Item_time_typecast::val_int() { - TIME ltime; + MYSQL_TIME ltime; if (get_time(<ime)) { null_value= 1; @@ -2627,7 +2634,7 @@ longlong Item_time_typecast::val_int() String *Item_time_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (!get_arg0_time(<ime) && !make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY, @@ -2639,7 +2646,7 @@ String *Item_time_typecast::val_str(String *str) } -bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date) +bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { bool res= get_arg0_date(ltime, TIME_FUZZY_DATE); ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; @@ -2651,7 +2658,7 @@ bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date) String *Item_date_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (!get_arg0_date(<ime, TIME_FUZZY_DATE) && !str->alloc(11)) { @@ -2666,7 +2673,7 @@ String *Item_date_typecast::val_str(String *str) longlong Item_date_typecast::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (args[0]->get_date(<ime, TIME_FUZZY_DATE)) { null_value= 1; @@ -2678,21 +2685,29 @@ longlong Item_date_typecast::val_int() /* MAKEDATE(a,b) is a date function that creates a date value from a year and day value. + + NOTES: + As arguments are integers, we can't know if the year is a 2 digit or 4 digit year. + In this case we treat all years < 100 as 2 digit years. Ie, this is not safe + for dates between 0000-01-01 and 0099-12-31 */ String *Item_func_makedate::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME l_time; + MYSQL_TIME l_time; long daynr= (long) args[1]->val_int(); - long yearnr= (long) args[0]->val_int(); + long year= (long) args[0]->val_int(); long days; if (args[0]->null_value || args[1]->null_value || - yearnr < 0 || daynr <= 0) + year < 0 || daynr <= 0) goto err; - days= calc_daynr(yearnr,1,1) + daynr - 1; + if (year < 100) + year= year_2000_handling(year); + + days= calc_daynr(year,1,1) + daynr - 1; /* Day number from year 0 to 9999-12-31 */ if (days >= 0 && days <= MAX_DAY_NUMBER) { @@ -2710,19 +2725,32 @@ err: } +/* + MAKEDATE(a,b) is a date function that creates a date value + from a year and day value. + + NOTES: + As arguments are integers, we can't know if the year is a 2 digit or 4 digit year. + In this case we treat all years < 100 as 2 digit years. Ie, this is not safe + for dates between 0000-01-01 and 0099-12-31 +*/ + longlong Item_func_makedate::val_int() { DBUG_ASSERT(fixed == 1); - TIME l_time; + MYSQL_TIME l_time; long daynr= (long) args[1]->val_int(); - long yearnr= (long) args[0]->val_int(); + long year= (long) args[0]->val_int(); long days; if (args[0]->null_value || args[1]->null_value || - yearnr < 0 || daynr <= 0) + year < 0 || daynr <= 0) goto err; - days= calc_daynr(yearnr,1,1) + daynr - 1; + if (year < 100) + year= year_2000_handling(year); + + days= calc_daynr(year,1,1) + daynr - 1; /* Day number from year 0 to 9999-12-31 */ if (days >= 0 && days < MAX_DAY_NUMBER) { @@ -2777,7 +2805,7 @@ void Item_func_add_time::fix_length_and_dec() String *Item_func_add_time::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME l_time1, l_time2, l_time3; + MYSQL_TIME l_time1, l_time2, l_time3; bool is_time= 0; long days, microseconds; longlong seconds; @@ -2879,7 +2907,7 @@ String *Item_func_timediff::val_str(String *str) longlong seconds; long microseconds; int l_sign= 1; - TIME l_time1 ,l_time2, l_time3; + MYSQL_TIME l_time1 ,l_time2, l_time3; null_value= 0; if (args[0]->get_time(&l_time1) || @@ -2924,7 +2952,7 @@ null_date: String *Item_func_maketime::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; bool overflow= 0; longlong hour= args[0]->val_int(); @@ -2968,7 +2996,8 @@ String *Item_func_maketime::val_str(String *str) char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10); int len = (int)(ptr - buf) + my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second)); - make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME, + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + buf, len, MYSQL_TIMESTAMP_TIME, NullS); } @@ -2992,7 +3021,7 @@ String *Item_func_maketime::val_str(String *str) longlong Item_func_microsecond::val_int() { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (!get_arg0_time(<ime)) return ltime.second_part; return 0; @@ -3001,7 +3030,7 @@ longlong Item_func_microsecond::val_int() longlong Item_func_timestamp_diff::val_int() { - TIME ltime1, ltime2; + MYSQL_TIME ltime1, ltime2; longlong seconds; long microseconds; long months= 0; @@ -3319,7 +3348,7 @@ void Item_func_str_to_date::fix_length_and_dec() } } -bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date) +bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { DATE_TIME_FORMAT date_time_format; char val_buff[64], format_buff[64]; @@ -3360,7 +3389,7 @@ null_date: String *Item_func_str_to_date::val_str(String *str) { DBUG_ASSERT(fixed == 1); - TIME ltime; + MYSQL_TIME ltime; if (Item_func_str_to_date::get_date(<ime, TIME_FUZZY_DATE)) return 0; @@ -3373,7 +3402,7 @@ String *Item_func_str_to_date::val_str(String *str) } -bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date) +bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date) { if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) || (ltime->month == 0)) diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 14ceb8dcb28..8e925a0156f 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -432,9 +432,9 @@ public: /* Abstract method that defines which time zone is used for conversion. Converts time current time in my_time_t representation to broken-down - TIME representation using UTC-SYSTEM or per-thread time zone. + MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone. */ - virtual void store_now_in_TIME(TIME *now_time)=0; + virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; bool result_as_longlong() { return TRUE; } }; @@ -445,7 +445,7 @@ public: Item_func_curtime_local() :Item_func_curtime() {} Item_func_curtime_local(Item *a) :Item_func_curtime(a) {} const char *func_name() const { return "curtime"; } - virtual void store_now_in_TIME(TIME *now_time); + virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -455,7 +455,7 @@ public: Item_func_curtime_utc() :Item_func_curtime() {} Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {} const char *func_name() const { return "utc_time"; } - virtual void store_now_in_TIME(TIME *now_time); + virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -464,14 +464,14 @@ public: class Item_func_curdate :public Item_date { longlong value; - TIME ltime; + MYSQL_TIME ltime; public: Item_func_curdate() :Item_date() {} longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; } String *val_str(String *str); void fix_length_and_dec(); - bool get_date(TIME *res, uint fuzzy_date); - virtual void store_now_in_TIME(TIME *now_time)=0; + bool get_date(MYSQL_TIME *res, uint fuzzy_date); + virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; }; @@ -480,7 +480,7 @@ class Item_func_curdate_local :public Item_func_curdate public: Item_func_curdate_local() :Item_func_curdate() {} const char *func_name() const { return "curdate"; } - void store_now_in_TIME(TIME *now_time); + void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -489,7 +489,7 @@ class Item_func_curdate_utc :public Item_func_curdate public: Item_func_curdate_utc() :Item_func_curdate() {} const char *func_name() const { return "utc_date"; } - void store_now_in_TIME(TIME *now_time); + void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -501,7 +501,7 @@ protected: longlong value; char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy uint buff_length; - TIME ltime; + MYSQL_TIME ltime; public: Item_func_now() :Item_date_func() {} Item_func_now(Item *a) :Item_date_func(a) {} @@ -510,8 +510,8 @@ public: int save_in_field(Field *to, bool no_conversions); String *val_str(String *str); void fix_length_and_dec(); - bool get_date(TIME *res, uint fuzzy_date); - virtual void store_now_in_TIME(TIME *now_time)=0; + bool get_date(MYSQL_TIME *res, uint fuzzy_date); + virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; }; @@ -521,7 +521,7 @@ public: Item_func_now_local() :Item_func_now() {} Item_func_now_local(Item *a) :Item_func_now(a) {} const char *func_name() const { return "now"; } - virtual void store_now_in_TIME(TIME *now_time); + virtual void store_now_in_TIME(MYSQL_TIME *now_time); virtual enum Functype functype() const { return NOW_FUNC; } }; @@ -532,7 +532,7 @@ public: Item_func_now_utc() :Item_func_now() {} Item_func_now_utc(Item *a) :Item_func_now(a) {} const char *func_name() const { return "utc_timestamp"; } - virtual void store_now_in_TIME(TIME *now_time); + virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -547,13 +547,13 @@ public: Item_func_sysdate_local(Item *a) :Item_func_now(a) {} bool const_item() const { return 0; } const char *func_name() const { return "sysdate"; } - void store_now_in_TIME(TIME *now_time); + void store_now_in_TIME(MYSQL_TIME *now_time); double val_real(); longlong val_int(); int save_in_field(Field *to, bool no_conversions); String *val_str(String *str); void fix_length_and_dec(); - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); void update_used_tables() { Item_func_now::update_used_tables(); @@ -567,7 +567,7 @@ class Item_func_from_days :public Item_date public: Item_func_from_days(Item *a) :Item_date(a) {} const char *func_name() const { return "from_days"; } - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); }; @@ -597,7 +597,7 @@ class Item_func_from_unixtime :public Item_date_func String *val_str(String *str); const char *func_name() const { return "from_unixtime"; } void fix_length_and_dec(); - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); }; @@ -635,7 +635,7 @@ class Item_func_convert_tz :public Item_date_func const char *func_name() const { return "convert_tz"; } bool fix_fields(THD *, Item **); void fix_length_and_dec(); - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); void cleanup(); }; @@ -694,7 +694,7 @@ public: void fix_length_and_dec(); enum_field_types field_type() const { return cached_field_type; } longlong val_int(); - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); bool eq(const Item *item, bool binary_cmp) const; void print(String *str); }; @@ -778,7 +778,7 @@ public: Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {} const char *func_name() const { return "cast_as_date"; } String *val_str(String *str); - bool get_date(TIME *ltime, uint fuzzy_date); + bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); const char *cast_type() const { return "date"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } Field *tmp_table_field(TABLE *t_arg) @@ -812,7 +812,7 @@ public: Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {} const char *func_name() const { return "cast_as_time"; } String *val_str(String *str); - bool get_time(TIME *ltime); + bool get_time(MYSQL_TIME *ltime); const char *cast_type() const { return "time"; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; } Field *tmp_table_field(TABLE *t_arg) @@ -1033,7 +1033,7 @@ public: :Item_str_func(a, b) {} String *val_str(String *str); - bool get_date(TIME *ltime, uint fuzzy_date); + bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); const char *func_name() const { return "str_to_date"; } enum_field_types field_type() const { return cached_field_type; } void fix_length_and_dec(); @@ -1046,5 +1046,5 @@ class Item_func_last_day :public Item_date public: Item_func_last_day(Item *a) :Item_date(a) {} const char *func_name() const { return "last_day"; } - bool get_date(TIME *res, uint fuzzy_date); + bool get_date(MYSQL_TIME *res, uint fuzzy_date); }; diff --git a/sql/log.cc b/sql/log.cc index 7563d754556..818828f9557 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1784,7 +1784,7 @@ void MYSQL_LOG::rotate_and_purge(uint flags) #ifdef HAVE_REPLICATION if (expire_logs_days) { - long purge_time= (long) (time(0) - expire_logs_days*24*60*60); + time_t purge_time= time(0) - expire_logs_days*24*60*60; if (purge_time >= 0) purge_logs_before_date(purge_time); } diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 0ef1f9794ba..4ef2ae5cf95 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -191,7 +191,7 @@ int str2my_decimal(uint mask, const char *from, uint length, } -my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec) +my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec) { longlong date; date = (ltime->year*100L + ltime->month)*100L + ltime->day; diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 0affa07557e..c661579ea66 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -300,7 +300,7 @@ int string2my_decimal(uint mask, const String *str, my_decimal *d) } -my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec); +my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec); #endif /*defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f03ef487154..ea472691760 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1510,16 +1510,22 @@ ulong convert_period_to_month(ulong period); ulong convert_month_to_period(ulong month); void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day); -my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *not_exist); -bool str_to_time_with_warn(const char *str,uint length,TIME *l_time); +my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist); +bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time); timestamp_type str_to_datetime_with_warn(const char *str, uint length, - TIME *l_time, uint flags); -void localtime_to_TIME(TIME *to, struct tm *from); -void calc_time_from_sec(TIME *to, long seconds, long microseconds); + MYSQL_TIME *l_time, uint flags); +void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); +void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds); + +void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, + const char *str_val, + uint str_length, timestamp_type time_type, + const char *field_name); + +bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval); +bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, + longlong *seconds_out, long *microseconds_out); -void make_truncated_value_warning(THD *thd, const char *str_val, - uint str_length, timestamp_type time_type, - const char *field_name); extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type, const char *format_str, uint format_length); @@ -1527,13 +1533,13 @@ extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd, DATE_TIME_FORMAT *format); const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, timestamp_type type); -extern bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, +extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, timestamp_type type, String *str); -void make_datetime(const DATE_TIME_FORMAT *format, const TIME *l_time, +void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time, String *str); -void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time, +void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time, String *str); -void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time, +void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time, String *str); ulonglong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, Item *warn_item, bool *is_null); @@ -1555,7 +1561,7 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, bool truncate); int get_quick_record(SQL_SELECT *select); int calc_weekday(long daynr,bool sunday_first_day_of_week); -uint calc_week(TIME *l_time, uint week_behaviour, uint *year); +uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year); void find_date(char *pos,uint *vek,uint flag); TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end); TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5abef25b62..051bad5b310 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3271,7 +3271,7 @@ server."); #ifdef HAVE_REPLICATION if (opt_bin_log && expire_logs_days) { - long purge_time= (long) (time(0) - expire_logs_days*24*60*60); + time_t purge_time= time(0) - expire_logs_days*24*60*60; if (purge_time >= 0) mysql_bin_log.purge_logs_before_date(purge_time); } @@ -6185,6 +6185,7 @@ struct show_var_st status_vars[]= { {"Com_analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS}, {"Com_backup_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BACKUP_TABLE]), SHOW_LONG_STATUS}, {"Com_begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS}, + {"Com_call_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CALL]), SHOW_LONG_STATUS}, {"Com_change_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS}, {"Com_change_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHANGE_MASTER]), SHOW_LONG_STATUS}, {"Com_check", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS}, diff --git a/sql/protocol.cc b/sql/protocol.cc index f9ba734a48d..ced6d78519a 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -948,7 +948,7 @@ bool Protocol_simple::store(Field *field) */ -bool Protocol_simple::store(TIME *tm) +bool Protocol_simple::store(MYSQL_TIME *tm) { #ifndef DBUG_OFF DBUG_ASSERT(field_types == 0 || @@ -971,7 +971,7 @@ bool Protocol_simple::store(TIME *tm) } -bool Protocol_simple::store_date(TIME *tm) +bool Protocol_simple::store_date(MYSQL_TIME *tm) { #ifndef DBUG_OFF DBUG_ASSERT(field_types == 0 || @@ -990,7 +990,7 @@ bool Protocol_simple::store_date(TIME *tm) we support 0-6 decimals for time. */ -bool Protocol_simple::store_time(TIME *tm) +bool Protocol_simple::store_time(MYSQL_TIME *tm) { #ifndef DBUG_OFF DBUG_ASSERT(field_types == 0 || @@ -1162,7 +1162,7 @@ bool Protocol_prep::store(Field *field) } -bool Protocol_prep::store(TIME *tm) +bool Protocol_prep::store(MYSQL_TIME *tm) { char buff[12],*pos; uint length; @@ -1188,7 +1188,7 @@ bool Protocol_prep::store(TIME *tm) return packet->append(buff, length+1, PACKET_BUFFER_EXTRA_ALLOC); } -bool Protocol_prep::store_date(TIME *tm) +bool Protocol_prep::store_date(MYSQL_TIME *tm) { tm->hour= tm->minute= tm->second=0; tm->second_part= 0; @@ -1196,7 +1196,7 @@ bool Protocol_prep::store_date(TIME *tm) } -bool Protocol_prep::store_time(TIME *tm) +bool Protocol_prep::store_time(MYSQL_TIME *tm) { char buff[13], *pos; uint length; diff --git a/sql/protocol.h b/sql/protocol.h index 0e00a7c21e0..f8e7f490d1b 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -86,9 +86,9 @@ public: CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0; virtual bool store(float from, uint32 decimals, String *buffer)=0; virtual bool store(double from, uint32 decimals, String *buffer)=0; - virtual bool store(TIME *time)=0; - virtual bool store_date(TIME *time)=0; - virtual bool store_time(TIME *time)=0; + virtual bool store(MYSQL_TIME *time)=0; + virtual bool store_date(MYSQL_TIME *time)=0; + virtual bool store_time(MYSQL_TIME *time)=0; virtual bool store(Field *field)=0; #ifdef EMBEDDED_LIBRARY int begin_dataset(); @@ -116,9 +116,9 @@ public: virtual bool store(const char *from, uint length, CHARSET_INFO *cs); virtual bool store(const char *from, uint length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); - virtual bool store(TIME *time); - virtual bool store_date(TIME *time); - virtual bool store_time(TIME *time); + virtual bool store(MYSQL_TIME *time); + virtual bool store_date(MYSQL_TIME *time); + virtual bool store_time(MYSQL_TIME *time); virtual bool store(float nr, uint32 decimals, String *buffer); virtual bool store(double from, uint32 decimals, String *buffer); virtual bool store(Field *field); @@ -150,9 +150,9 @@ public: virtual bool store(const char *from,uint length, CHARSET_INFO *cs); virtual bool store(const char *from, uint length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); - virtual bool store(TIME *time); - virtual bool store_date(TIME *time); - virtual bool store_time(TIME *time); + virtual bool store(MYSQL_TIME *time); + virtual bool store_date(MYSQL_TIME *time); + virtual bool store_time(MYSQL_TIME *time); virtual bool store(float nr, uint32 decimals, String *buffer); virtual bool store(double from, uint32 decimals, String *buffer); virtual bool store(Field *field); diff --git a/sql/sp.cc b/sql/sp.cc index 976bb1911b2..de786a77275 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -757,7 +757,7 @@ print_field_values(THD *thd, TABLE *table, switch (used_field->field_type) { case MYSQL_TYPE_TIMESTAMP: { - TIME tmp_time; + MYSQL_TIME tmp_time; bzero((char *)&tmp_time, sizeof(tmp_time)); ((Field_timestamp *) used_field->field)->get_time(&tmp_time); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8c7627d9fe4..999a05ca616 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5811,7 +5811,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors) table= field->table; if (field == table->next_number_field) table->auto_increment_field_not_null= TRUE; - if (value->save_in_field(field, 0) == -1) + if (value->save_in_field(field, 0) < 0) goto err; } DBUG_RETURN(thd->net.report_error); diff --git a/sql/sql_class.h b/sql/sql_class.h index 5f813e82307..bef679806d0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -594,7 +594,7 @@ struct system_variables Time_zone *time_zone; - /* DATE, DATETIME and TIME formats */ + /* DATE, DATETIME and MYSQL_TIME formats */ DATE_TIME_FORMAT *date_format; DATE_TIME_FORMAT *datetime_format; DATE_TIME_FORMAT *time_format; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index be1355699ba..16ed20cd479 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2433,7 +2433,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, const char *file_name) { const char *tmp_buff; - TIME time; + MYSQL_TIME time; CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_tables_record"); @@ -2939,7 +2939,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, { String tmp_string; String sp_db, sp_name, definer; - TIME time; + MYSQL_TIME time; LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; get_field(thd->mem_root, proc_table->field[0], &sp_db); diff --git a/sql/structs.h b/sql/structs.h index 2dcafdef615..de4cc25db9f 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -142,12 +142,11 @@ typedef struct st_read_record { /* Parameter to read_record */ /* - Originally MySQL used TIME structure inside server only, but since + Originally MySQL used MYSQL_TIME structure inside server only, but since 4.1 it's exported to user in the new client API. Define aliases for new names to keep existing code simple. */ -typedef struct st_mysql_time TIME; typedef enum enum_mysql_timestamp_type timestamp_type; diff --git a/sql/time.cc b/sql/time.cc index a46f2fc237d..b4a8b047998 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -61,7 +61,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week) next week is week 1. */ -uint calc_week(TIME *l_time, uint week_behaviour, uint *year) +uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) { uint days; ulong daynr=calc_daynr(l_time->year,l_time->month,l_time->day); @@ -179,7 +179,7 @@ ulong convert_month_to_period(ulong month) /* - Convert a timestamp string to a TIME value and produce a warning + Convert a timestamp string to a MYSQL_TIME value and produce a warning if string was truncated during conversion. NOTE @@ -187,7 +187,7 @@ ulong convert_month_to_period(ulong month) */ timestamp_type -str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, +str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time, uint flags) { int was_cut; @@ -200,13 +200,14 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, MODE_NO_ZERO_DATE))), &was_cut); if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR) - make_truncated_value_warning(current_thd, str, length, ts_type, NullS); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str, length, ts_type, NullS); return ts_type; } /* - Convert a datetime from broken-down TIME representation to corresponding + Convert a datetime from broken-down MYSQL_TIME representation to corresponding TIMESTAMP value. SYNOPSIS @@ -222,7 +223,7 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, 0 - t contains datetime value which is out of TIMESTAMP range. */ -my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap) +my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_gap) { my_time_t timestamp; @@ -241,20 +242,20 @@ my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap) /* - Convert a time string to a TIME struct and produce a warning + Convert a time string to a MYSQL_TIME struct and produce a warning if string was cut during conversion. NOTE See str_to_time() for more info. */ bool -str_to_time_with_warn(const char *str, uint length, TIME *l_time) +str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time) { int warning; bool ret_val= str_to_time(str, length, l_time, &warning); if (ret_val || warning) - make_truncated_value_warning(current_thd, str, length, - MYSQL_TIMESTAMP_TIME, NullS); + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str, length, MYSQL_TIMESTAMP_TIME, NullS); return ret_val; } @@ -263,7 +264,7 @@ str_to_time_with_warn(const char *str, uint length, TIME *l_time) Convert a system time structure to TIME */ -void localtime_to_TIME(TIME *to, struct tm *from) +void localtime_to_TIME(MYSQL_TIME *to, struct tm *from) { to->neg=0; to->second_part=0; @@ -275,7 +276,7 @@ void localtime_to_TIME(TIME *to, struct tm *from) to->second= (int) from->tm_sec; } -void calc_time_from_sec(TIME *to, long seconds, long microseconds) +void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds) { long t_seconds; to->hour= seconds/3600L; @@ -644,7 +645,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, MySQL doesn't support comparing of date/time/datetime strings that are not in arbutary order as dates are compared as strings in some context) - This functions don't check that given TIME structure members are + This functions don't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. Additionally, make_time doesn't take into account time->day member: it's assumed that days have been converted @@ -652,7 +653,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, ****************************************************************************/ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_time_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -661,7 +662,7 @@ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)), void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_date_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -670,7 +671,7 @@ void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)), void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)), - const TIME *l_time, String *str) + const MYSQL_TIME *l_time, String *str) { uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr()); str->length(length); @@ -678,7 +679,8 @@ void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)), } -void make_truncated_value_warning(THD *thd, const char *str_val, +void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, + const char *str_val, uint str_length, timestamp_type time_type, const char *field_name) { @@ -710,7 +712,7 @@ void make_truncated_value_warning(THD *thd, const char *str_val, cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER(ER_TRUNCATED_WRONG_VALUE), type_str, str.c_ptr()); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning(thd, level, ER_TRUNCATED_WRONG_VALUE, warn_buff); } diff --git a/sql/tztime.cc b/sql/tztime.cc index 70f7cc5ea86..bedbf921cae 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -77,7 +77,7 @@ typedef struct lsinfo /* Structure with information describing ranges of my_time_t shifted to local - time (my_time_t + offset). Used for local TIME -> my_time_t conversion. + time (my_time_t + offset). Used for local MYSQL_TIME -> my_time_t conversion. See comments for TIME_to_gmt_sec() for more info. */ typedef struct revtinfo @@ -292,9 +292,9 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage) be used if there are no transitions or we have moment in time before any transitions. Second task is to build "shifted my_time_t" -> my_time_t map used in - TIME -> my_time_t conversion. + MYSQL_TIME -> my_time_t conversion. Note: See description of TIME_to_gmt_sec() function first. - In order to perform TIME -> my_time_t conversion we need to build table + In order to perform MYSQL_TIME -> my_time_t conversion we need to build table which defines "shifted by tz offset and leap seconds my_time_t" -> my_time_t function wich is almost the same (except ranges of ambiguity) as reverse function to piecewise linear function used for my_time_t -> @@ -531,14 +531,14 @@ static const uint year_lengths[2]= offset - local time zone offset DESCRIPTION - Convert my_time_t with offset to TIME struct. Differs from timesub + Convert my_time_t with offset to MYSQL_TIME struct. Differs from timesub (from elsie code) because doesn't contain any leap correction and TM_GMTOFF and is_dst setting and contains some MySQL specific initialization. Funny but with removing of these we almost have glibc's offtime function. */ static void -sec_to_TIME(TIME * tmp, my_time_t t, long offset) +sec_to_TIME(MYSQL_TIME * tmp, my_time_t t, long offset) { long days; long rem; @@ -594,7 +594,7 @@ sec_to_TIME(TIME * tmp, my_time_t t, long offset) tmp->month++; tmp->day= (uint)(days + 1); - /* filling MySQL specific TIME members */ + /* filling MySQL specific MYSQL_TIME members */ tmp->neg= 0; tmp->second_part= 0; tmp->time_type= MYSQL_TIMESTAMP_DATETIME; } @@ -686,7 +686,7 @@ find_transition_type(my_time_t t, const TIME_ZONE_INFO *sp) /* Converts time in my_time_t representation (seconds in UTC since Epoch) to - broken down TIME representation in local time zone. + broken down MYSQL_TIME representation in local time zone. SYNOPSIS gmt_sec_to_TIME() @@ -701,12 +701,12 @@ find_transition_type(my_time_t t, const TIME_ZONE_INFO *sp) (60th and 61st second, look how we calculate them as "hit" in this function). Under realistic assumptions about frequency of transitions the same array - can be used fot TIME -> my_time_t conversion. For this we need to + can be used fot MYSQL_TIME -> my_time_t conversion. For this we need to implement tweaked binary search which will take into account that some - TIME has two matching my_time_t ranges and some of them have none. + MYSQL_TIME has two matching my_time_t ranges and some of them have none. */ static void -gmt_sec_to_TIME(TIME *tmp, my_time_t sec_in_utc, const TIME_ZONE_INFO *sp) +gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t sec_in_utc, const TIME_ZONE_INFO *sp) { const TRAN_TYPE_INFO *ttisp; const LS_INFO *lp; @@ -809,7 +809,7 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec) /* - Converts local time in broken down TIME representation to my_time_t + Converts local time in broken down MYSQL_TIME representation to my_time_t representation. SYNOPSIS @@ -851,7 +851,7 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec) We use completely different approach. It is better since it is both faster than iterative implementations and fully determenistic. If you - look at my_time_t to TIME conversion then you'll find that it consist + look at my_time_t to MYSQL_TIME conversion then you'll find that it consist of two steps: The first is calculating shifted my_time_t value and the second - TIME calculation from shifted my_time_t value (well it is a bit simplified @@ -881,7 +881,7 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec) 0 in case of error. */ static my_time_t -TIME_to_gmt_sec(const TIME *t, const TIME_ZONE_INFO *sp, +TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp, my_bool *in_dst_time_gap) { my_time_t local_t; @@ -1008,20 +1008,20 @@ class Time_zone_system : public Time_zone { public: Time_zone_system() {} /* Remove gcc warning */ - virtual my_time_t TIME_to_gmt_sec(const TIME *t, + virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const; - virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const; + virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; }; /* - Converts local time in system time zone in TIME representation + Converts local time in system time zone in MYSQL_TIME representation to its my_time_t representation. SYNOPSIS TIME_to_gmt_sec() - t - pointer to TIME structure with local time in + t - pointer to MYSQL_TIME structure with local time in broken-down representation. in_dst_time_gap - pointer to bool which is set to true if datetime value passed doesn't really exist (i.e. falls into @@ -1029,7 +1029,7 @@ public: DESCRIPTION This method uses system function (localtime_r()) for conversion - local time in system time zone in TIME structure to its my_time_t + local time in system time zone in MYSQL_TIME structure to its my_time_t representation. Unlike the same function for Time_zone_db class it it won't handle unnormalized input properly. Still it will return lowest possible my_time_t in case of ambiguity or if we @@ -1041,7 +1041,7 @@ public: Corresponding my_time_t value or 0 in case of error */ my_time_t -Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const +Time_zone_system::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const { long not_used; return my_system_gmt_sec(t, ¬_used, in_dst_time_gap); @@ -1054,7 +1054,7 @@ Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const SYNOPSIS gmt_sec_to_TIME() - tmp - pointer to TIME structure to fill-in + tmp - pointer to MYSQL_TIME structure to fill-in t - my_time_t value to be converted NOTE @@ -1065,7 +1065,7 @@ Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const the 1902 easily. */ void -Time_zone_system::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const +Time_zone_system::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const { struct tm tmp_tm; time_t tmp_t= (time_t)t; @@ -1095,26 +1095,26 @@ Time_zone_system::get_name() const /* Instance of this class represents UTC time zone. It uses system gmtime_r function for conversions and is always available. It is used only for - my_time_t -> TIME conversions in various UTC_... functions, it is not - intended for TIME -> my_time_t conversions and shouldn't be exposed to user. + my_time_t -> MYSQL_TIME conversions in various UTC_... functions, it is not + intended for MYSQL_TIME -> my_time_t conversions and shouldn't be exposed to user. */ class Time_zone_utc : public Time_zone { public: Time_zone_utc() {} /* Remove gcc warning */ - virtual my_time_t TIME_to_gmt_sec(const TIME *t, + virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const; - virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const; + virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; }; /* - Convert UTC time from TIME representation to its my_time_t representation. + Convert UTC time from MYSQL_TIME representation to its my_time_t representation. SYNOPSIS TIME_to_gmt_sec() - t - pointer to TIME structure with local time + t - pointer to MYSQL_TIME structure with local time in broken-down representation. in_dst_time_gap - pointer to bool which is set to true if datetime value passed doesn't really exist (i.e. falls into @@ -1129,7 +1129,7 @@ public: 0 */ my_time_t -Time_zone_utc::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const +Time_zone_utc::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const { /* Should be never called */ DBUG_ASSERT(0); @@ -1143,14 +1143,14 @@ Time_zone_utc::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const SYNOPSIS gmt_sec_to_TIME() - tmp - pointer to TIME structure to fill-in + tmp - pointer to MYSQL_TIME structure to fill-in t - my_time_t value to be converted NOTE See note for apropriate Time_zone_system method. */ void -Time_zone_utc::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const +Time_zone_utc::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const { struct tm tmp_tm; time_t tmp_t= (time_t)t; @@ -1191,9 +1191,9 @@ class Time_zone_db : public Time_zone { public: Time_zone_db(TIME_ZONE_INFO *tz_info_arg, const String * tz_name_arg); - virtual my_time_t TIME_to_gmt_sec(const TIME *t, + virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const; - virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const; + virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; private: TIME_ZONE_INFO *tz_info; @@ -1227,7 +1227,7 @@ Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg, SYNOPSIS TIME_to_gmt_sec() - t - pointer to TIME structure with local time + t - pointer to MYSQL_TIME structure with local time in broken-down representation. in_dst_time_gap - pointer to bool which is set to true if datetime value passed doesn't really exist (i.e. falls into @@ -1241,7 +1241,7 @@ Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg, Corresponding my_time_t value or 0 in case of error */ my_time_t -Time_zone_db::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const +Time_zone_db::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const { return ::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap); } @@ -1253,11 +1253,11 @@ Time_zone_db::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const SYNOPSIS gmt_sec_to_TIME() - tmp - pointer to TIME structure to fill-in + tmp - pointer to MYSQL_TIME structure to fill-in t - my_time_t value to be converted */ void -Time_zone_db::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const +Time_zone_db::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const { ::gmt_sec_to_TIME(tmp, t, tz_info); } @@ -1287,9 +1287,9 @@ class Time_zone_offset : public Time_zone { public: Time_zone_offset(long tz_offset_arg); - virtual my_time_t TIME_to_gmt_sec(const TIME *t, + virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const; - virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const; + virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; /* This have to be public because we want to be able to access it from @@ -1324,11 +1324,11 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg): /* Converts local time in time zone described as offset from UTC - from TIME representation to its my_time_t representation. + from MYSQL_TIME representation to its my_time_t representation. SYNOPSIS TIME_to_gmt_sec() - t - pointer to TIME structure with local time + t - pointer to MYSQL_TIME structure with local time in broken-down representation. in_dst_time_gap - pointer to bool which should be set to true if datetime value passed doesn't really exist @@ -1340,7 +1340,7 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg): Corresponding my_time_t value or 0 in case of error */ my_time_t -Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const +Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const { my_time_t local_t; int shift= 0; @@ -1385,11 +1385,11 @@ Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const SYNOPSIS gmt_sec_to_TIME() - tmp - pointer to TIME structure to fill-in + tmp - pointer to MYSQL_TIME structure to fill-in t - my_time_t value to be converted */ void -Time_zone_offset::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const +Time_zone_offset::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const { sec_to_TIME(tmp, t, offset); } @@ -2651,7 +2651,7 @@ main(int argc, char **argv) my_bool localtime_negative; TIME_ZONE_INFO tz_info; struct tm tmp; - TIME time_tmp; + MYSQL_TIME time_tmp; time_t t, t1, t2; char fullname[FN_REFLEN+1]; char *str_end; diff --git a/sql/tztime.h b/sql/tztime.h index d1f33843810..32a942a26e1 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -22,7 +22,7 @@ /* This class represents abstract time zone and provides - basic interface for TIME <-> my_time_t conversion. + basic interface for MYSQL_TIME <-> my_time_t conversion. Actual time zones which are specified by DB, or via offset or use system functions are its descendants. */ @@ -31,18 +31,18 @@ class Time_zone: public Sql_alloc public: Time_zone() {} /* Remove gcc warning */ /* - Converts local time in broken down TIME representation to + Converts local time in broken down MYSQL_TIME representation to my_time_t (UTC seconds since Epoch) represenation. Returns 0 in case of error. Sets in_dst_time_gap to true if date provided falls into spring time-gap (or lefts it untouched otherwise). */ - virtual my_time_t TIME_to_gmt_sec(const TIME *t, + virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const = 0; /* Converts time in my_time_t representation to local time in - broken down TIME representation. + broken down MYSQL_TIME representation. */ - virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const = 0; + virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const = 0; /* Because of constness of String returned by get_name() time zone name have to be already zeroended to be able to use String::ptr() instead diff --git a/sql/unireg.cc b/sql/unireg.cc index 06b2e0c10a2..c01e6a0f00c 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -859,7 +859,9 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, (regfield->real_type() != FIELD_TYPE_YEAR || field->def->val_int() != 0)) { - if (field->def->save_in_field(regfield, 1)) + int res= field->def->save_in_field(regfield, 1); + /* If not ok or warning of level 'note' */ + if (res != 0 && res != 3) { my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name); error= 1; diff --git a/strings/strtod.c b/strings/strtod.c index 15707a9b944..7196cafb2c9 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -194,7 +194,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) done: *end_ptr= (char*) str; /* end of number */ - if (overflow || isinf(result)) + if (overflow || my_isinf(result)) { result= DBL_MAX; *error= EOVERFLOW; diff --git a/win/create_manifest.js b/win/create_manifest.js index 5605f57ef74..ac62cb2a8c2 100755 --- a/win/create_manifest.js +++ b/win/create_manifest.js @@ -28,6 +28,7 @@ try break; case "version": var app_version= parts[1]; + app_version+= ".0"; break; case "arch": var app_arch= parts[1]; |