diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-06-27 20:35:26 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-06-27 20:35:26 +0200 |
commit | 658992699b204da04382142e77af042c8a33a334 (patch) | |
tree | 464bc87eae9ffb0fd1a7ba6fa11148b50a295d6b | |
parent | fe7e334f3e238368e18fc2ccb98b3357ecb1e03e (diff) | |
parent | a6087e7dc1ef3561d8189c8db15e9591d0f9b520 (diff) | |
download | mariadb-git-658992699b204da04382142e77af042c8a33a334.tar.gz |
Merge tag 'mariadb-10.0.20' into 10.1
390 files changed, 7196 insertions, 4464 deletions
diff --git a/.gitattributes b/.gitattributes index 2e238207619..b62a174c5e5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,12 +12,16 @@ # These files should be checked out as is *.result -text -whitespace +*.dat -text -whitespace + storage/connect/mysql-test/connect/std_data/*.txt -text -storage/connect/mysql-test/connect/std_data/*.dat -text # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary +*.frm binary +*.MYD binary +*.MYI binary *.c diff=cpp *.h diff=cpp diff --git a/.gitignore b/.gitignore index e7871c66357..f32a60fcfde 100644 --- a/.gitignore +++ b/.gitignore @@ -175,7 +175,6 @@ storage/tokudb/ft-index/ft/log_print.cc storage/tokudb/ft-index/ft/logformat storage/tokudb/ft-index/ft/ftverify storage/tokudb/ft-index/ft/tdb-recover -storage/tokudb/ft-index/ft/tdb_logprint storage/tokudb/ft-index/ft/tokuftdump storage/tokudb/ft-index/portability/merge_archives_tokuportability_static.cmake storage/tokudb/ft-index/portability/toku_config.h @@ -186,11 +185,11 @@ storage/tokudb/ft-index/toku_include/toku_config.h storage/tokudb/ft-index/tools/ba_replay storage/tokudb/ft-index/tools/ftverify storage/tokudb/ft-index/tools/tdb-recover -storage/tokudb/ft-index/tools/tdb_logprint storage/tokudb/ft-index/tools/tokudb_dump storage/tokudb/ft-index/tools/tokudb_gen storage/tokudb/ft-index/tools/tokudb_load storage/tokudb/ft-index/tools/tokuftdump +storage/tokudb/ft-index/tools/tokuft_logprint storage/tokudb/ft-index/xz/ support-files/MySQL-shared-compat.spec support-files/binary-configure @@ -234,6 +233,9 @@ storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result *.ko *.obj *.elf +*.exp +*.dep +*.idb # Precompiled Headers *.gch diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 777790696ba..7fe38fba53e 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -54,6 +54,7 @@ static char *opt_plugin_dir= 0, *opt_default_auth= 0; static int first_error = 0; static char *opt_skip_database; DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds; +DYNAMIC_ARRAY views4repair; static char *shared_memory_base_name=0; static uint opt_protocol=0; @@ -878,11 +879,19 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view) switch (what_to_do) { case DO_CHECK: op = "CHECK"; - if (opt_quick) end = strmov(end, " QUICK"); - if (opt_fast) end = strmov(end, " FAST"); - if (opt_medium_check) end = strmov(end, " MEDIUM"); /* Default */ - if (opt_extended) end = strmov(end, " EXTENDED"); - if (opt_check_only_changed) end = strmov(end, " CHANGED"); + if (view) + { + if (opt_fast || opt_check_only_changed) + DBUG_RETURN(0); + } + else + { + if (opt_quick) end = strmov(end, " QUICK"); + if (opt_fast) end = strmov(end, " FAST"); + if (opt_extended) end = strmov(end, " EXTENDED"); + if (opt_medium_check) end = strmov(end, " MEDIUM"); /* Default */ + if (opt_check_only_changed) end = strmov(end, " CHANGED"); + } if (opt_upgrade) end = strmov(end, " FOR UPGRADE"); break; case DO_REPAIR: @@ -967,6 +976,7 @@ static void print_result() uint length_of_db; uint i; my_bool found_error=0, table_rebuild=0; + DYNAMIC_ARRAY *array4repair= &tables4repair; DBUG_ENTER("print_result"); res = mysql_use_result(sock); @@ -1003,9 +1013,10 @@ static void print_result() else { char *table_name= prev + (length_of_db+1); - insert_dynamic(&tables4repair, table_name); + insert_dynamic(array4repair, table_name); } } + array4repair= &tables4repair; found_error=0; table_rebuild=0; prev_alter[0]= 0; @@ -1021,8 +1032,11 @@ static void print_result() we have to run upgrade on it. In this case we write a nicer message than "Please do "REPAIR TABLE""... */ - if (!strcmp(row[2],"error") && strstr(row[3],"REPAIR TABLE")) + if (!strcmp(row[2],"error") && strstr(row[3],"REPAIR ")) + { printf("%-50s %s", row[0], "Needs upgrade"); + array4repair= strstr(row[3], "VIEW") ? &views4repair : &tables4repair; + } else printf("%s\n%-9s: %s", row[0], row[2], row[3]); if (opt_auto_repair && strcmp(row[2],"note")) @@ -1053,7 +1067,7 @@ static void print_result() else { char *table_name= prev + (length_of_db+1); - insert_dynamic(&tables4repair, table_name); + insert_dynamic(array4repair, table_name); } } mysql_free_result(res); @@ -1173,6 +1187,8 @@ int main(int argc, char **argv) if (opt_auto_repair && (my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16, 64, MYF(0)) || + my_init_dynamic_array(&views4repair, sizeof(char)*(NAME_LEN*2+2),16, + 64, MYF(0)) || my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16, 64, MYF(0)) || my_init_dynamic_array(&alter_table_cmds, MAX_ALTER_STR_SIZE, 0, 1, @@ -1203,6 +1219,13 @@ int main(int argc, char **argv) rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i)); for (i = 0; i < alter_table_cmds.elements ; i++) run_query((char*) dynamic_array_ptr(&alter_table_cmds, i), 1); + if (!opt_silent && views4repair.elements) + puts("\nRepairing views"); + for (i = 0; i < views4repair.elements ; i++) + { + char *name= (char*) dynamic_array_ptr(&views4repair, i); + handle_request_for_tables(name, fixed_name_length(name), TRUE); + } } ret= MY_TEST(first_error); @@ -1210,8 +1233,10 @@ int main(int argc, char **argv) dbDisconnect(current_host); if (opt_auto_repair) { + delete_dynamic(&views4repair); delete_dynamic(&tables4repair); delete_dynamic(&tables4rebuild); + delete_dynamic(&alter_table_cmds); } end1: my_free(opt_password); diff --git a/client/mysqldump.c b/client/mysqldump.c index 62515161e30..05ef70a9fa4 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -97,7 +97,7 @@ static ulong find_set(TYPELIB *lib, const char *x, uint length, static char *alloc_query_str(ulong size); static void field_escape(DYNAMIC_STRING* in, const char *from); -static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, +static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_med= 1, quick= 1, extended_insert= 1, lock_tables=1,ignore_errors=0,flush_logs=0,flush_privileges=0, opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0, @@ -203,6 +203,8 @@ const char *compatible_mode_names[]= TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, "", compatible_mode_names, NULL}; +#define MED_ENGINES "MRG_MyISAM, MRG_ISAM, CONNECT, OQGRAPH, SPIDER, VP, FEDERATED" + HASH ignore_table; static struct my_option my_long_options[] = @@ -431,6 +433,9 @@ static struct my_option my_long_options[] = NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-data", 'd', "No row information.", &opt_no_data, &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-data-med", 0, "No row information for engines that " + "Manage External Data (" MED_ENGINES ").", &opt_no_data_med, + &opt_no_data_med, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"no-set-names", 'N', "Same as --skip-set-charset.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"opt", OPT_OPTIMIZE, @@ -5506,12 +5511,12 @@ char check_if_ignore_table(const char *table_name, char *table_type) /* If these two types, we do want to skip dumping the table */ - if (!opt_no_data && - (!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") || - !strcmp(table_type,"MRG_ISAM") || - !strcmp(table_type,"CONNECT") || - !strcmp(table_type,"FEDERATED"))) - result= IGNORE_DATA; + if (!opt_no_data && opt_no_data_med) + { + const char *found= strstr(" " MED_ENGINES ",", table_type); + if (found && found[-1] == ' ' && found[strlen(table_type)] == ',') + result= IGNORE_DATA; + } } mysql_free_result(res); DBUG_RETURN(result); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index cc4f32c9370..6d9261fe906 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -839,6 +839,7 @@ static void handle_no_active_connection(struct st_command* command, #define EMB_END_CONNECTION 3 #define EMB_PREPARE_STMT 4 #define EMB_EXECUTE_STMT 5 +#define EMB_CLOSE_STMT 6 /* workaround for MySQL BUG#57491 */ #undef MY_WME @@ -887,6 +888,9 @@ pthread_handler_t connection_thread(void *arg) case EMB_EXECUTE_STMT: cn->result= mysql_stmt_execute(cn->stmt); break; + case EMB_CLOSE_STMT: + cn->result= mysql_stmt_close(cn->stmt); + break; default: DBUG_ASSERT(0); } @@ -984,6 +988,17 @@ static int do_stmt_execute(struct st_connection *cn) } +static int do_stmt_close(struct st_connection *cn) +{ + /* The cn->stmt is already set. */ + if (!cn->has_thread) + return mysql_stmt_close(cn->stmt); + signal_connection_thd(cn, EMB_CLOSE_STMT); + wait_query_thread_done(cn); + return cn->result; +} + + static void emb_close_connection(struct st_connection *cn) { if (!cn->has_thread) @@ -1019,6 +1034,7 @@ static void init_connection_thd(struct st_connection *cn) #define do_read_query_result(cn) mysql_read_query_result(cn->mysql) #define do_stmt_prepare(cn, q, q_len) mysql_stmt_prepare(cn->stmt, q, q_len) #define do_stmt_execute(cn) mysql_stmt_execute(cn->stmt) +#define do_stmt_close(cn) mysql_stmt_close(cn->stmt) #endif /*EMBEDDED_LIBRARY*/ @@ -1378,11 +1394,11 @@ void close_connections() DBUG_ENTER("close_connections"); for (--next_con; next_con >= connections; --next_con) { + if (next_con->stmt) + do_stmt_close(next_con); #ifdef EMBEDDED_LIBRARY emb_close_connection(next_con); #endif - if (next_con->stmt) - mysql_stmt_close(next_con->stmt); next_con->stmt= 0; mysql_close(next_con->mysql); next_con->mysql= 0; @@ -5491,7 +5507,11 @@ void do_close_connection(struct st_command *command) con->mysql->net.vio = 0; } } -#else +#endif /*!EMBEDDED_LIBRARY*/ + if (con->stmt) + do_stmt_close(con); + con->stmt= 0; +#ifdef EMBEDDED_LIBRARY /* As query could be still executed in a separate theread we need to check if the query's thread was finished and probably wait @@ -5499,9 +5519,6 @@ void do_close_connection(struct st_command *command) */ emb_close_connection(con); #endif /*EMBEDDED_LIBRARY*/ - if (con->stmt) - mysql_stmt_close(con->stmt); - con->stmt= 0; mysql_close(con->mysql); con->mysql= 0; diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake index 8a7e14b6f2d..02124ae7ba1 100644 --- a/cmake/abi_check.cmake +++ b/cmake/abi_check.cmake @@ -28,7 +28,7 @@ ELSE() SET(RUN_ABI_CHECK 0) ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC AND RUN_ABI_CHECK) +IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND RUN_ABI_CHECK) IF(CMAKE_C_COMPILER MATCHES "ccache$") SET(COMPILER ${CMAKE_C_COMPILER_ARG1}) STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER}) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 4ca5863c6a7..1b5183345f6 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -21,11 +21,12 @@ SET(CPACK_COMPONENT_MANPAGESCLIENT_GROUP "client") SET(CPACK_COMPONENT_README_GROUP "server") SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "shared") SET(CPACK_COMPONENT_COMMON_GROUP "common") +SET(CPACK_COMPONENT_CLIENTPLUGINS_GROUP "common") SET(CPACK_COMPONENT_COMPAT_GROUP "compat") SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts SupportFiles Development ManPagesDevelopment ManPagesTest Readme ManPagesClient Test - Common Client SharedLibraries) + Common Client SharedLibraries ClientPlugins) SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake index c831aaf8b52..c0ffce353f3 100644 --- a/cmake/do_abi_check.cmake +++ b/cmake/do_abi_check.cmake @@ -58,7 +58,7 @@ FOREACH(file ${ABI_HEADERS}) EXECUTE_PROCESS( COMMAND ${COMPILER} - -E -nostdinc -dI -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include + -E -nostdinc -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include -I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql ${file} ERROR_QUIET OUTPUT_FILE ${tmpfile}) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 8fcfe294f17..636737b2083 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -308,17 +308,15 @@ INCLUDE(CheckCCompilerFlag) SET(VISIBILITY_HIDDEN_FLAG) -IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX) +IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") + SET(VISIBILITY_HIDDEN_FLAG "-xldscope=hidden") +ELSEIF(UNIX) CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN) IF(HAVE_VISIBILITY_HIDDEN) SET(VISIBILITY_HIDDEN_FLAG "-fvisibility=hidden") ENDIF() ENDIF() -IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") - SET(VISIBILITY_HIDDEN_FLAG "-xldscope=hidden") -ENDIF() - # We try to hide the symbols in yassl/zlib to avoid name clashes with # other libraries like openssl. FUNCTION(RESTRICT_SYMBOL_EXPORTS target) diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index d905ec189ae..5e9d0d3ad99 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -41,11 +41,11 @@ IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") ENDIF() # Set warning flags for GCC/Clang -IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") +IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}") ENDIF() # Set warning flags for G++/Clang++ -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}") ENDIF() diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in index c561baaa415..f35d16834b6 100644 --- a/cmake/make_dist.cmake.in +++ b/cmake/make_dist.cmake.in @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2015, Oracle and/or its affiliates. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,9 +60,9 @@ IF(NOT GIT_EXECUTABLE) # Save bison output first. CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc - ${CMAKE_BINARY_DIR}/sql_yacc.cc COPY_ONLY) + ${CMAKE_BINARY_DIR}/sql_yacc.cc COPYONLY) CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h - ${CMAKE_BINARY_DIR}/sql_yacc.h COPY_ONLY) + ${CMAKE_BINARY_DIR}/sql_yacc.h COPYONLY) IF(CMAKE_GENERATOR MATCHES "Makefiles") # make clean @@ -74,9 +74,9 @@ IF(NOT GIT_EXECUTABLE) # Restore bison output CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc - ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPY_ONLY) + ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPYONLY) CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.h - ${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPY_ONLY) + ${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPYONLY) FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc) FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.h) ENDIF() diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index c47cacbd9a5..b043b174e78 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -352,7 +352,6 @@ SET(C_HAS___inline 1 CACHE INTERNAL "") SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "") SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "") SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "") -SET(HAVE_CXXABI_H CACHE INTERNAL "") SET(HAVE_NDIR_H CACHE INTERNAL "") SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") @@ -371,4 +370,8 @@ SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "") SET(HAVE_UCONTEXT_H CACHE INTERNAL "") SET(HAVE_SOCKPEERCRED CACHE INTERNAL "") +SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "") +SET(HAVE_GCC_ATOMIC_BUILTINS CACHE INTERNAL "") +SET(HAVE_GCC_C11_ATOMICS CACHE INTERNAL "") +SET(HAVE_VISIBILITY_HIDDEN CACHE INTERNAL "") ENDIF(MSVC) diff --git a/config.h.cmake b/config.h.cmake index 6d90bf565c6..5f5cd30dc19 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -27,7 +27,6 @@ #cmakedefine HAVE_BSEARCH 1 #cmakedefine HAVE_CRYPT_H 1 #cmakedefine HAVE_CURSES_H 1 -#cmakedefine HAVE_CXXABI_H 1 #cmakedefine HAVE_BFD_H 1 #cmakedefine HAVE_NCURSES_H 1 #cmakedefine HAVE_NDIR_H 1 @@ -205,7 +204,7 @@ #cmakedefine HAVE_MADVISE 1 #cmakedefine HAVE_DECL_MADVISE 1 #cmakedefine HAVE_DECL_TGOTO 1 -#cmakedefine HAVE_DECL_MHA_MAPSIZE_VA +#cmakedefine HAVE_DECL_MHA_MAPSIZE_VA 1 #cmakedefine HAVE_MALLINFO 1 #cmakedefine HAVE_MEMCPY 1 #cmakedefine HAVE_MEMMOVE 1 @@ -400,7 +399,7 @@ #cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@ -#cmakedefine HAVE_MBSTATE_T +#cmakedefine HAVE_MBSTATE_T 1 #define MAX_INDEXES 64 @@ -435,15 +434,15 @@ #cmakedefine HAVE_WCTYPE_H 1 #cmakedefine HAVE_WCHAR_H 1 #cmakedefine HAVE_LANGINFO_H 1 -#cmakedefine HAVE_MBRLEN -#cmakedefine HAVE_MBSCMP -#cmakedefine HAVE_MBSRTOWCS -#cmakedefine HAVE_WCRTOMB -#cmakedefine HAVE_MBRTOWC -#cmakedefine HAVE_WCSCOLL -#cmakedefine HAVE_WCSDUP -#cmakedefine HAVE_WCWIDTH -#cmakedefine HAVE_WCTYPE +#cmakedefine HAVE_MBRLEN 1 +#cmakedefine HAVE_MBSCMP 1 +#cmakedefine HAVE_MBSRTOWCS 1 +#cmakedefine HAVE_WCRTOMB 1 +#cmakedefine HAVE_MBRTOWC 1 +#cmakedefine HAVE_WCSCOLL 1 +#cmakedefine HAVE_WCSDUP 1 +#cmakedefine HAVE_WCWIDTH 1 +#cmakedefine HAVE_WCTYPE 1 #cmakedefine HAVE_ISWLOWER 1 #cmakedefine HAVE_ISWUPPER 1 #cmakedefine HAVE_TOWLOWER 1 @@ -457,7 +456,7 @@ #cmakedefine HAVE_STRCASECMP 1 #cmakedefine HAVE_STRNCASECMP 1 #cmakedefine HAVE_STRDUP 1 -#cmakedefine HAVE_LANGINFO_CODESET +#cmakedefine HAVE_LANGINFO_CODESET 1 #cmakedefine HAVE_TCGETATTR 1 #cmakedefine HAVE_FLOCKFILE 1 @@ -475,6 +474,7 @@ #cmakedefine MY_ATOMIC_MODE_DUMMY 1 #cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1 +#cmakedefine HAVE_GCC_C11_ATOMICS 1 #cmakedefine HAVE_SOLARIS_ATOMIC 1 #cmakedefine HAVE_DECL_SHM_HUGETLB 1 #cmakedefine HAVE_LARGE_PAGES 1 diff --git a/configure.cmake b/configure.cmake index 22a5d59bfb1..e3d7ed49a2e 100644 --- a/configure.cmake +++ b/configure.cmake @@ -52,7 +52,7 @@ IF(NOT SYSTEM_TYPE) ENDIF() ENDIF() -IF(CMAKE_COMPILER_IS_GNUCXX) +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") # MySQL "canonical" GCC flags. At least -fno-rtti flag affects # ABI and cannot be simply removed. SET(CMAKE_CXX_FLAGS @@ -175,7 +175,6 @@ CHECK_INCLUDE_FILES (alloca.h HAVE_ALLOCA_H) CHECK_INCLUDE_FILES (aio.h HAVE_AIO_H) CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H) CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H) -CHECK_INCLUDE_FILE_CXX (cxxabi.h HAVE_CXXABI_H) CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H) CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H) CHECK_INCLUDE_FILES (execinfo.h HAVE_EXECINFO_H) @@ -880,7 +879,7 @@ ENDIF(NOT HAVE_POSIX_SIGNALS) # Assume regular sprintf SET(SPRINTFS_RETURNS_INT 1) -IF(CMAKE_COMPILER_IS_GNUCXX AND HAVE_CXXABI_H) +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") CHECK_CXX_SOURCE_COMPILES(" #include <cxxabi.h> int main(int argc, char **argv) @@ -952,7 +951,6 @@ SET(SIGNAL_WITH_VIO_CLOSE 1) MARK_AS_ADVANCED(NO_ALARM) -IF(CMAKE_COMPILER_IS_GNUCXX) IF(WITH_ATOMIC_OPS STREQUAL "up") SET(MY_ATOMIC_MODE_DUMMY 1 CACHE BOOL "Assume single-CPU mode, no concurrency") ELSEIF(WITH_ATOMIC_OPS STREQUAL "smp") @@ -981,10 +979,17 @@ ELSEIF(NOT WITH_ATOMIC_OPS) return 0; }" HAVE_GCC_ATOMIC_BUILTINS) + CHECK_CXX_SOURCE_COMPILES(" + int main() + { + long long int var= 1; + long long int *ptr= &var; + return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); + }" + HAVE_GCC_C11_ATOMICS) ELSE() MESSAGE(FATAL_ERROR "${WITH_ATOMIC_OPS} is not a valid value for WITH_ATOMIC_OPS!") ENDIF() -ENDIF() SET(WITH_ATOMIC_OPS "${WITH_ATOMIC_OPS}" CACHE STRING "Implement atomic operations using atomic CPU instructions for multi-processor (smp) or uniprocessor (up) configuration. By default gcc built-in sync functions are used, if available and 'smp' configuration otherwise.") MARK_AS_ADVANCED(WITH_ATOMIC_OPS MY_ATOMIC_MODE_DUMMY) diff --git a/debian/dist/Debian/control b/debian/dist/Debian/control index 9e8091f7158..3c481a2ac61 100644 --- a/debian/dist/Debian/control +++ b/debian/dist/Debian/control @@ -4,7 +4,13 @@ Priority: optional Maintainer: MariaDB Developers <maria-developers@lists.launchpad.net> XSBC-Original-Maintainer: Maria Developers <maria-developers@lists.launchpad.net> Uploaders: MariaDB Developers <maria-developers@lists.launchpad.net> -Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper, cmake (>= 2.7), libaio-dev, ${MAYBE_LIBCRACK} libjemalloc-dev (>= 3.0.0) +Build-Depends: procps | hurd, debhelper, libncurses5-dev (>= 5.0-6), + perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), + zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libssl-dev, + libpam0g-dev, psmisc, po-debconf, chrpath, + dpatch, gawk, bison, lsb-release, hardening-wrapper, + cmake (>= 2.7), libaio-dev, ${MAYBE_LIBCRACK} + libjemalloc-dev (>= 3.0.0) Standards-Version: 3.8.3 Homepage: http://mariadb.org/ Vcs-Browser: https://github.com/MariaDB/server/tree/10.1/ @@ -16,7 +22,9 @@ Architecture: any Depends: mariadb-common, libmysqlclient18 (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends} Conflicts: mariadb-server-10.0 (<< 10.0.5), mariadb-galera-server-10.0 (<< 10.0.5), mariadb-server-5.5 (<< 5.5.33), mariadb-galera-server-5.5 (<< 5.5.33), - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3 + mariadb-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3 Description: MariaDB database client library MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -105,13 +113,15 @@ Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-core-5.1, mysql-client-core-5.5, mariadb-client-5.1, mariadb-client-core-5.1, mariadb-client-5.2, mariadb-client-core-5.2, - mariadb-client-5.3, mariadb-client-core-5.3 + mariadb-client-5.3, mariadb-client-core-5.3, + mariadb-client-5.5, mariadb-client-core-5.5 Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, mysql-client-5.5, mysql-client-core-5.1, mysql-client-core-5.5, mariadb-client-5.1, mariadb-client-core-5.1, mariadb-client-5.2, mariadb-client-core-5.2, - mariadb-client-5.3, mariadb-client-core-5.3 + mariadb-client-5.3, mariadb-client-core-5.3, + mariadb-client-5.5, mariadb-client-core-5.5 Description: MariaDB database core client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -131,11 +141,16 @@ Provides: virtual-mysql-client, mysql-client, mysql-client-4.1, mysql-client-5.1, mysql-client-5.5 Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, mariadb-client (<< ${source:Version}), - mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3, mysql-client-5.5 + mariadb-client-5.1, + mariadb-client-5.2, + mariadb-client-5.3, + mariadb-client-5.5, mysql-client-5.5 Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, - mysql-client-5.5, mariadb-client (<< ${source:Version}), - mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3 + mariadb-client-5.1, + mariadb-client-5.2, + mariadb-client-5.3, + mariadb-client-5.5, mysql-client-5.5 Description: MariaDB database client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -149,18 +164,16 @@ Package: mariadb-server-core-10.1 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libmariadbclient18 (>= ${binary:Version}) Provides: mysql-server-core, mysql-server-core-5.1, mysql-server-core-5.5 -Conflicts: mariadb-server-5.1 (<< 5.1.60), - mariadb-server-5.2 (<< 5.2.10), - mariadb-server-5.3 (<< 5.3.3), - mysql-server-5.0, - mysql-server-core-5.0, mysql-server-core-5.1, mysql-server-core-5.5, - mariadb-server-core-5.1, mariadb-server-core-5.2, mariadb-server-core-5.5 -Replaces: mariadb-server-5.1 (<< 5.1.60), - mariadb-server-5.2 (<< 5.2.10), - mariadb-server-5.3 (<< 5.3.3), - mysql-server-5.0, - mysql-server-core-5.0, mysql-server-core-5.1, mysql-server-core-5.5, - mariadb-server-core-5.1, mariadb-server-core-5.2, mariadb-server-core-5.5 +Conflicts: mysql-server-5.0, mysql-server-core-5.0, + mariadb-server-core-5.1, mysql-server-core-5.1, + mariadb-server-core-5.2, + mariadb-server-core-5.3, + mariadb-server-core-5.5, mysql-server-core-5.5 +Replaces: mysql-server-5.0, mysql-server-core-5.0, + mariadb-server-core-5.1, mysql-server-core-5.1, + mariadb-server-core-5.2, + mariadb-server-core-5.3, + mariadb-server-core-5.5, mysql-server-core-5.5 Description: MariaDB database core server files MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -173,10 +186,10 @@ Package: mariadb-test-10.1 Section: database Architecture: any Depends: mariadb-server-10.1 (= ${source:Version}), mariadb-client-10.1 (= ${source:Version}) +Suggests: patch Conflicts: mariadb-test (<< ${source:Version}), mariadb-test-5.1, mariadb-test-5.2, mariadb-test-5.3, mariadb-server-5.5 (<< 5.5.33), mariadb-galera-server-5.5 (<< 5.5.33) -Suggests: patch Replaces: mariadb-test (<< ${source:Version}), mariadb-test-5.1, mariadb-test-5.2, mariadb-test-5.3 Description: MariaDB database regression test suite @@ -199,12 +212,18 @@ Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl, coreutils, bsdutils, findutils, tar Provides: mariadb-server, mysql-server, virtual-mysql-server Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), - mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mysql-server-4.1, mysql-server-5.0, + mariadb-server-5.1, mysql-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3, + mariadb-server-5.5, mysql-server-5.5, mariadb-tokudb-engine-5.5, mariadb-tokudb-engine-10.0 Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), - mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mysql-server-4.1, mysql-server-5.0, + mariadb-server-5.1, mysql-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3, + mariadb-server-5.5, mysql-server-5.5, libmariadbclient16 (<< 5.3.4), libmariadbclient-dev (<< 5.5.0), mariadb-tokudb-engine-5.5, mariadb-tokudb-engine-10.0 Description: MariaDB database server binaries diff --git a/debian/dist/Ubuntu/control b/debian/dist/Ubuntu/control index 1c555ecef30..ebb34de1761 100644 --- a/debian/dist/Ubuntu/control +++ b/debian/dist/Ubuntu/control @@ -4,7 +4,13 @@ Priority: optional Maintainer: MariaDB Developers <maria-developers@lists.launchpad.net> XSBC-Original-Maintainer: Maria Developers <maria-developers@lists.launchpad.net> Uploaders: MariaDB Developers <maria-developers@lists.launchpad.net> -Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper, cmake (>= 2.7), libaio-dev, ${MAYBE_LIBCRACK} libjemalloc-dev (>= 3.0.0) +Build-Depends: procps | hurd, debhelper, libncurses5-dev (>= 5.0-6), + perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), + zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libssl-dev, + libpam0g-dev, psmisc, po-debconf, chrpath, + dpatch, gawk, bison, lsb-release, hardening-wrapper, + cmake (>= 2.7), libaio-dev, ${MAYBE_LIBCRACK} + libjemalloc-dev (>= 3.0.0) Standards-Version: 3.8.2 Homepage: http://mariadb.org/ Vcs-Browser: http://bazaar.launchpad.net/~maria-captains/maria/10.1/files @@ -16,7 +22,9 @@ Architecture: any Depends: mariadb-common, libmysqlclient18 (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends} Conflicts: mariadb-server-10.0 (<< 10.0.5), mariadb-galera-server-10.0 (<< 10.0.5), mariadb-server-5.5 (<< 5.5.33), mariadb-galera-server-5.5 (<< 5.5.33), - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3 + mariadb-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3 Description: MariaDB database client library MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -105,13 +113,15 @@ Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-core-5.1, mysql-client-core-5.5, mariadb-client-5.1, mariadb-client-core-5.1, mariadb-client-5.2, mariadb-client-core-5.2, - mariadb-client-5.3, mariadb-client-core-5.3 + mariadb-client-5.3, mariadb-client-core-5.3, + mariadb-client-5.5, mariadb-client-core-5.5 Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, mysql-client-5.5, mysql-client-core-5.1, mysql-client-core-5.5, mariadb-client-5.1, mariadb-client-core-5.1, mariadb-client-5.2, mariadb-client-core-5.2, - mariadb-client-5.3, mariadb-client-core-5.3 + mariadb-client-5.3, mariadb-client-core-5.3, + mariadb-client-5.5, mariadb-client-core-5.5 Description: MariaDB database core client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -131,11 +141,16 @@ Provides: virtual-mysql-client, mysql-client, mysql-client-4.1, mysql-client-5.1, mysql-client-5.5 Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, mariadb-client (<< ${source:Version}), - mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3, mysql-client-5.5 + mariadb-client-5.1, + mariadb-client-5.2, + mariadb-client-5.3, + mariadb-client-5.5, mysql-client-5.5 Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1, - mysql-client-5.5, mariadb-client (<< ${source:Version}), - mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3 + mariadb-client-5.1, + mariadb-client-5.2, + mariadb-client-5.3, + mariadb-client-5.5, mysql-client-5.5 Description: MariaDB database client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -149,12 +164,16 @@ Package: mariadb-server-core-10.1 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libmariadbclient18 (>= ${binary:Version}) Provides: mysql-server-core, mysql-server-core-5.1, mysql-server-core-5.5 -Conflicts: mysql-server-5.0, - mysql-server-core-5.0, mysql-server-core-5.1, mysql-server-core-5.5, - mariadb-server-core-5.1, mariadb-server-core-5.2, mariadb-server-core-5.5 -Replaces: mysql-server-5.0, - mysql-server-core-5.0, mysql-server-core-5.1, mysql-server-core-5.5, - mariadb-server-core-5.1, mariadb-server-core-5.2, mariadb-server-core-5.5 +Conflicts: mysql-server-5.0, mysql-server-core-5.0, + mariadb-server-core-5.1, mysql-server-core-5.1, + mariadb-server-core-5.2, + mariadb-server-core-5.3, + mariadb-server-core-5.5, mysql-server-core-5.5 +Replaces: mysql-server-5.0, mysql-server-core-5.0, + mariadb-server-core-5.1, mysql-server-core-5.1, + mariadb-server-core-5.2, + mariadb-server-core-5.3, + mariadb-server-core-5.5, mysql-server-core-5.5 Description: MariaDB database core server files MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -193,12 +212,18 @@ Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl, coreutils, bsdutils, findutils, tar Provides: mariadb-server, mysql-server, virtual-mysql-server Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), - mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mysql-server-4.1, mysql-server-5.0, + mariadb-server-5.1, mysql-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3, + mariadb-server-5.5, mysql-server-5.5, mariadb-tokudb-engine-5.5, mariadb-tokudb-engine-10.0 Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), - mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mysql-server-4.1, mysql-server-5.0, + mariadb-server-5.1, mysql-server-5.1, + mariadb-server-5.2, + mariadb-server-5.3, + mariadb-server-5.5, mysql-server-5.5, libmariadbclient16 (<< 5.3.4), libmariadbclient-dev (<< 5.5.0), mariadb-tokudb-engine-5.5, mariadb-tokudb-engine-10.0 Description: MariaDB database server binaries diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt index 23404a661d6..f3232896c6a 100644 --- a/extra/yassl/CMakeLists.txt +++ b/extra/yassl/CMakeLists.txt @@ -20,12 +20,9 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL) ADD_DEFINITIONS(${SSL_DEFINES}) -IF(CMAKE_COMPILER_IS_GNUXX) - #Remove -fno-implicit-templates - #(yassl sources cannot be compiled with it) - STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS -${CMAKE_CXX_FLAGS}) -ENDIF() +#Remove -fno-implicit-templates +#(yassl sources cannot be compiled with it) +STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp src/yassl_imp.cpp src/yassl_int.cpp) diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h index 6e807b3c51c..56a0323aedf 100644 --- a/include/atomic/gcc_builtins.h +++ b/include/atomic/gcc_builtins.h @@ -31,8 +31,8 @@ #define make_atomic_store_body(S) *a= v #define MY_ATOMIC_MODE "gcc-builtins-up" -#elif defined(__ATOMIC_SEQ_CST) -#define MY_ATOMIC_MODE "gcc-builtins-smp" +#elif defined(HAVE_GCC_C11_ATOMICS) +#define MY_ATOMIC_MODE "gcc-atomics-smp" #define make_atomic_load_body(S) \ ret= __atomic_load_n(a, __ATOMIC_SEQ_CST) #define make_atomic_store_body(S) \ diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index ad05a7df9ab..fb2525e3a12 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -35,8 +35,7 @@ #define HAVE_WRITE_CORE -#if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && \ - HAVE_CXXABI_H && HAVE_ABI_CXA_DEMANGLE && \ +#if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && HAVE_ABI_CXA_DEMANGLE && \ HAVE_WEAK_SYMBOL #define BACKTRACE_DEMANGLE 1 #endif diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 8ad94a03056..8bd5aa61209 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -1,7 +1,5 @@ typedef char my_bool; typedef int my_socket; -#include "mysql_version.h" -#include "mysql_com.h" enum enum_server_command { COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, @@ -143,7 +141,6 @@ void get_tty_password_buff(const char *opt_message, char *to, size_t length); const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); my_bool my_thread_init(void); void my_thread_end(void); -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -157,7 +154,6 @@ typedef struct st_mysql_time my_bool neg; enum enum_mysql_timestamp_type time_type; } MYSQL_TIME; -#include "my_list.h" typedef struct st_list { struct st_list *prev,*next; void *data; @@ -199,8 +195,6 @@ typedef struct st_mysql_field { typedef char **MYSQL_ROW; typedef unsigned int MYSQL_FIELD_OFFSET; typedef unsigned long long my_ulonglong; -#include "typelib.h" -#include "my_alloc.h" typedef struct st_used_mem { struct st_used_mem *next; @@ -244,7 +238,6 @@ typedef struct st_mysql_rows { unsigned long length; } MYSQL_ROWS; typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; -#include "my_alloc.h" typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; typedef struct st_mysql_data { MYSQL_ROWS *data; diff --git a/include/mysql/client_plugin.h.pp b/include/mysql/client_plugin.h.pp index f3a0b5769df..b6ba9cf08ad 100644 --- a/include/mysql/client_plugin.h.pp +++ b/include/mysql/client_plugin.h.pp @@ -3,7 +3,6 @@ struct st_mysql_client_plugin int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(); int (*options)(const char *option, const void *); }; struct st_mysql; -#include <mysql/plugin_auth_common.h> typedef struct st_plugin_vio_info { enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, @@ -24,7 +23,6 @@ struct st_mysql_client_plugin_AUTHENTICATION int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(); int (*options)(const char *option, const void *); int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); }; -#include <mysql/auth_dialog_client.h> struct st_mysql; typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql, int type, const char *prompt, char *buf, int buf_len); diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 669be094542..5a10835be56 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -1,15 +1,11 @@ -#include "plugin.h" typedef char my_bool; typedef void * MYSQL_PLUGIN; -#include <mysql/services.h> -#include <mysql/service_my_snprintf.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); } *my_snprintf_service; size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); -#include <mysql/service_thd_alloc.h> struct st_mysql_lex_string { char *str; @@ -33,7 +29,6 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); -#include <mysql/service_thd_wait.h> typedef enum _thd_wait_type_e { THD_WAIT_SLEEP= 1, THD_WAIT_DISKIO= 2, @@ -54,7 +49,6 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); -#include <mysql/service_progress_report.h> extern struct progress_report_service_st { void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_report_func)(void* thd, @@ -75,9 +69,7 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); -#include <mysql/service_kill_statement.h> enum thd_kill_levels { THD_IS_NOT_KILLED=0, THD_ABORT_SOFTLY=50, @@ -87,8 +79,6 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); -#include <mysql/service_thd_timezone.h> -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -108,7 +98,6 @@ extern struct thd_timezone_service_st { } *thd_timezone_service; my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); -#include <mysql/service_sha1.h> extern struct my_sha1_service_st { void (*my_sha1_type)(unsigned char*, const char*, size_t); void (*my_sha1_multi_type)(unsigned char*, ...); @@ -123,7 +112,6 @@ size_t my_sha1_context_size(); void my_sha1_init(void *context); void my_sha1_input(void *context, const unsigned char *buf, size_t len); void my_sha1_result(void *context, unsigned char *digest); -#include <mysql/service_md5.h> extern struct my_md5_service_st { void (*my_md5_type)(unsigned char*, const char*, size_t); void (*my_md5_multi_type)(unsigned char*, ...); @@ -138,7 +126,6 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); -#include <mysql/service_logger.h> typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); @@ -160,14 +147,12 @@ extern struct logger_service_st { int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size); int logger_rotate(LOGGER_HANDLE *log); -#include <mysql/service_thd_autoinc.h> extern struct thd_autoinc_service_st { void (*thd_get_autoinc_func)(const void* thd, unsigned long* off, unsigned long* inc); } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); -#include <mysql/service_thd_error_context.h> extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); @@ -185,7 +170,6 @@ void thd_inc_error_row(void* thd); char *thd_get_error_context_description(void* thd, char *buffer, unsigned int length, unsigned int max_query_length); -#include <mysql/service_thd_specifics.h> typedef int MYSQL_THD_KEY_T; extern struct thd_specifics_service_st { int (*thd_key_create_func)(MYSQL_THD_KEY_T *key); @@ -197,7 +181,6 @@ int thd_key_create(MYSQL_THD_KEY_T *key); void thd_key_delete(MYSQL_THD_KEY_T *key); void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key); int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value); -#include <mysql/service_encryption.h> typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, unsigned char* dst, unsigned int* dlen, const unsigned char* key, unsigned int klen, @@ -213,7 +196,6 @@ struct encryption_service_st { encrypt_decrypt_func encryption_decrypt_func; }; extern struct encryption_service_st encryption_handler; -#include <mysql/service_encryption_scheme.h> struct st_encryption_scheme_key { unsigned int version; unsigned char key[16]; @@ -315,8 +297,6 @@ struct st_maria_plugin const char *version_info; unsigned int maturity; }; -#include "plugin_ftparser.h" -#include "plugin.h" enum enum_ftparser_mode { MYSQL_FTPARSER_SIMPLE_MODE= 0, diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 1b795079c22..97aca99b257 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -1,15 +1,11 @@ -#include <mysql/plugin.h> typedef char my_bool; typedef void * MYSQL_PLUGIN; -#include <mysql/services.h> -#include <mysql/service_my_snprintf.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); } *my_snprintf_service; size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); -#include <mysql/service_thd_alloc.h> struct st_mysql_lex_string { char *str; @@ -33,7 +29,6 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); -#include <mysql/service_thd_wait.h> typedef enum _thd_wait_type_e { THD_WAIT_SLEEP= 1, THD_WAIT_DISKIO= 2, @@ -54,7 +49,6 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); -#include <mysql/service_progress_report.h> extern struct progress_report_service_st { void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_report_func)(void* thd, @@ -75,9 +69,7 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); -#include <mysql/service_kill_statement.h> enum thd_kill_levels { THD_IS_NOT_KILLED=0, THD_ABORT_SOFTLY=50, @@ -87,8 +79,6 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); -#include <mysql/service_thd_timezone.h> -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -108,7 +98,6 @@ extern struct thd_timezone_service_st { } *thd_timezone_service; my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); -#include <mysql/service_sha1.h> extern struct my_sha1_service_st { void (*my_sha1_type)(unsigned char*, const char*, size_t); void (*my_sha1_multi_type)(unsigned char*, ...); @@ -123,7 +112,6 @@ size_t my_sha1_context_size(); void my_sha1_init(void *context); void my_sha1_input(void *context, const unsigned char *buf, size_t len); void my_sha1_result(void *context, unsigned char *digest); -#include <mysql/service_md5.h> extern struct my_md5_service_st { void (*my_md5_type)(unsigned char*, const char*, size_t); void (*my_md5_multi_type)(unsigned char*, ...); @@ -138,7 +126,6 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); -#include <mysql/service_logger.h> typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); @@ -160,14 +147,12 @@ extern struct logger_service_st { int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size); int logger_rotate(LOGGER_HANDLE *log); -#include <mysql/service_thd_autoinc.h> extern struct thd_autoinc_service_st { void (*thd_get_autoinc_func)(const void* thd, unsigned long* off, unsigned long* inc); } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); -#include <mysql/service_thd_error_context.h> extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); @@ -185,7 +170,6 @@ void thd_inc_error_row(void* thd); char *thd_get_error_context_description(void* thd, char *buffer, unsigned int length, unsigned int max_query_length); -#include <mysql/service_thd_specifics.h> typedef int MYSQL_THD_KEY_T; extern struct thd_specifics_service_st { int (*thd_key_create_func)(MYSQL_THD_KEY_T *key); @@ -197,7 +181,6 @@ int thd_key_create(MYSQL_THD_KEY_T *key); void thd_key_delete(MYSQL_THD_KEY_T *key); void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key); int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value); -#include <mysql/service_encryption.h> typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, unsigned char* dst, unsigned int* dlen, const unsigned char* key, unsigned int klen, @@ -213,7 +196,6 @@ struct encryption_service_st { encrypt_decrypt_func encryption_decrypt_func; }; extern struct encryption_service_st encryption_handler; -#include <mysql/service_encryption_scheme.h> struct st_encryption_scheme_key { unsigned int version; unsigned char key[16]; @@ -315,8 +297,6 @@ struct st_maria_plugin const char *version_info; unsigned int maturity; }; -#include "plugin_ftparser.h" -#include "plugin.h" enum enum_ftparser_mode { MYSQL_FTPARSER_SIMPLE_MODE= 0, @@ -406,7 +386,6 @@ void *thd_get_ha_data(const void* thd, const struct handlerton *hton); void thd_set_ha_data(void* thd, const struct handlerton *hton, const void *ha_data); void thd_wakeup_subsequent_commits(void* thd, int wakeup_error); -#include <mysql/plugin_auth_common.h> typedef struct st_plugin_vio_info { enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 56cad7ab716..36b4eca0473 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -1,15 +1,11 @@ -#include <mysql/plugin.h> typedef char my_bool; typedef void * MYSQL_PLUGIN; -#include <mysql/services.h> -#include <mysql/service_my_snprintf.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); } *my_snprintf_service; size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); -#include <mysql/service_thd_alloc.h> struct st_mysql_lex_string { char *str; @@ -33,7 +29,6 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); -#include <mysql/service_thd_wait.h> typedef enum _thd_wait_type_e { THD_WAIT_SLEEP= 1, THD_WAIT_DISKIO= 2, @@ -54,7 +49,6 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); -#include <mysql/service_progress_report.h> extern struct progress_report_service_st { void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_report_func)(void* thd, @@ -75,9 +69,7 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); -#include <mysql/service_kill_statement.h> enum thd_kill_levels { THD_IS_NOT_KILLED=0, THD_ABORT_SOFTLY=50, @@ -87,8 +79,6 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); -#include <mysql/service_thd_timezone.h> -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -108,7 +98,6 @@ extern struct thd_timezone_service_st { } *thd_timezone_service; my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); -#include <mysql/service_sha1.h> extern struct my_sha1_service_st { void (*my_sha1_type)(unsigned char*, const char*, size_t); void (*my_sha1_multi_type)(unsigned char*, ...); @@ -123,7 +112,6 @@ size_t my_sha1_context_size(); void my_sha1_init(void *context); void my_sha1_input(void *context, const unsigned char *buf, size_t len); void my_sha1_result(void *context, unsigned char *digest); -#include <mysql/service_md5.h> extern struct my_md5_service_st { void (*my_md5_type)(unsigned char*, const char*, size_t); void (*my_md5_multi_type)(unsigned char*, ...); @@ -138,7 +126,6 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); -#include <mysql/service_logger.h> typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); @@ -160,14 +147,12 @@ extern struct logger_service_st { int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size); int logger_rotate(LOGGER_HANDLE *log); -#include <mysql/service_thd_autoinc.h> extern struct thd_autoinc_service_st { void (*thd_get_autoinc_func)(const void* thd, unsigned long* off, unsigned long* inc); } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); -#include <mysql/service_thd_error_context.h> extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); @@ -185,7 +170,6 @@ void thd_inc_error_row(void* thd); char *thd_get_error_context_description(void* thd, char *buffer, unsigned int length, unsigned int max_query_length); -#include <mysql/service_thd_specifics.h> typedef int MYSQL_THD_KEY_T; extern struct thd_specifics_service_st { int (*thd_key_create_func)(MYSQL_THD_KEY_T *key); @@ -197,7 +181,6 @@ int thd_key_create(MYSQL_THD_KEY_T *key); void thd_key_delete(MYSQL_THD_KEY_T *key); void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key); int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value); -#include <mysql/service_encryption.h> typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, unsigned char* dst, unsigned int* dlen, const unsigned char* key, unsigned int klen, @@ -213,7 +196,6 @@ struct encryption_service_st { encrypt_decrypt_func encryption_decrypt_func; }; extern struct encryption_service_st encryption_handler; -#include <mysql/service_encryption_scheme.h> struct st_encryption_scheme_key { unsigned int version; unsigned char key[16]; @@ -315,8 +297,6 @@ struct st_maria_plugin const char *version_info; unsigned int maturity; }; -#include "plugin_ftparser.h" -#include "plugin.h" enum enum_ftparser_mode { MYSQL_FTPARSER_SIMPLE_MODE= 0, diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 3c07800a656..29b24c0fafa 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -1,15 +1,11 @@ -#include "plugin.h" typedef char my_bool; typedef void * MYSQL_PLUGIN; -#include <mysql/services.h> -#include <mysql/service_my_snprintf.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); } *my_snprintf_service; size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); -#include <mysql/service_thd_alloc.h> struct st_mysql_lex_string { char *str; @@ -33,7 +29,6 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); -#include <mysql/service_thd_wait.h> typedef enum _thd_wait_type_e { THD_WAIT_SLEEP= 1, THD_WAIT_DISKIO= 2, @@ -54,7 +49,6 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); -#include <mysql/service_progress_report.h> extern struct progress_report_service_st { void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_report_func)(void* thd, @@ -75,9 +69,7 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); -#include <mysql/service_kill_statement.h> enum thd_kill_levels { THD_IS_NOT_KILLED=0, THD_ABORT_SOFTLY=50, @@ -87,8 +79,6 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); -#include <mysql/service_thd_timezone.h> -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -108,7 +98,6 @@ extern struct thd_timezone_service_st { } *thd_timezone_service; my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); -#include <mysql/service_sha1.h> extern struct my_sha1_service_st { void (*my_sha1_type)(unsigned char*, const char*, size_t); void (*my_sha1_multi_type)(unsigned char*, ...); @@ -123,7 +112,6 @@ size_t my_sha1_context_size(); void my_sha1_init(void *context); void my_sha1_input(void *context, const unsigned char *buf, size_t len); void my_sha1_result(void *context, unsigned char *digest); -#include <mysql/service_md5.h> extern struct my_md5_service_st { void (*my_md5_type)(unsigned char*, const char*, size_t); void (*my_md5_multi_type)(unsigned char*, ...); @@ -138,7 +126,6 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); -#include <mysql/service_logger.h> typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); @@ -160,14 +147,12 @@ extern struct logger_service_st { int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size); int logger_rotate(LOGGER_HANDLE *log); -#include <mysql/service_thd_autoinc.h> extern struct thd_autoinc_service_st { void (*thd_get_autoinc_func)(const void* thd, unsigned long* off, unsigned long* inc); } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); -#include <mysql/service_thd_error_context.h> extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); @@ -185,7 +170,6 @@ void thd_inc_error_row(void* thd); char *thd_get_error_context_description(void* thd, char *buffer, unsigned int length, unsigned int max_query_length); -#include <mysql/service_thd_specifics.h> typedef int MYSQL_THD_KEY_T; extern struct thd_specifics_service_st { int (*thd_key_create_func)(MYSQL_THD_KEY_T *key); @@ -197,7 +181,6 @@ int thd_key_create(MYSQL_THD_KEY_T *key); void thd_key_delete(MYSQL_THD_KEY_T *key); void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key); int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value); -#include <mysql/service_encryption.h> typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, unsigned char* dst, unsigned int* dlen, const unsigned char* key, unsigned int klen, @@ -213,7 +196,6 @@ struct encryption_service_st { encrypt_decrypt_func encryption_decrypt_func; }; extern struct encryption_service_st encryption_handler; -#include <mysql/service_encryption_scheme.h> struct st_encryption_scheme_key { unsigned int version; unsigned char key[16]; @@ -315,7 +297,6 @@ struct st_maria_plugin const char *version_info; unsigned int maturity; }; -#include "plugin_ftparser.h" struct st_mysql_daemon { int interface_version; diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 6b8a886dc25..8d3a300f02c 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -1,15 +1,11 @@ -#include <mysql/plugin.h> typedef char my_bool; typedef void * MYSQL_PLUGIN; -#include <mysql/services.h> -#include <mysql/service_my_snprintf.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); } *my_snprintf_service; size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); -#include <mysql/service_thd_alloc.h> struct st_mysql_lex_string { char *str; @@ -33,7 +29,6 @@ void *thd_memdup(void* thd, const void* str, unsigned int size); MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, const char *str, unsigned int size, int allocate_lex_string); -#include <mysql/service_thd_wait.h> typedef enum _thd_wait_type_e { THD_WAIT_SLEEP= 1, THD_WAIT_DISKIO= 2, @@ -54,7 +49,6 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); -#include <mysql/service_progress_report.h> extern struct progress_report_service_st { void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_report_func)(void* thd, @@ -75,9 +69,7 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); -#include <mysql/service_kill_statement.h> enum thd_kill_levels { THD_IS_NOT_KILLED=0, THD_ABORT_SOFTLY=50, @@ -87,8 +79,6 @@ extern struct kill_statement_service_st { enum thd_kill_levels (*thd_kill_level_func)(const void*); } *thd_kill_statement_service; enum thd_kill_levels thd_kill_level(const void*); -#include <mysql/service_thd_timezone.h> -#include "mysql_time.h" typedef long my_time_t; enum enum_mysql_timestamp_type { @@ -108,7 +98,6 @@ extern struct thd_timezone_service_st { } *thd_timezone_service; my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode); void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t); -#include <mysql/service_sha1.h> extern struct my_sha1_service_st { void (*my_sha1_type)(unsigned char*, const char*, size_t); void (*my_sha1_multi_type)(unsigned char*, ...); @@ -123,7 +112,6 @@ size_t my_sha1_context_size(); void my_sha1_init(void *context); void my_sha1_input(void *context, const unsigned char *buf, size_t len); void my_sha1_result(void *context, unsigned char *digest); -#include <mysql/service_md5.h> extern struct my_md5_service_st { void (*my_md5_type)(unsigned char*, const char*, size_t); void (*my_md5_multi_type)(unsigned char*, ...); @@ -138,7 +126,6 @@ size_t my_md5_context_size(); void my_md5_init(void *context); void my_md5_input(void *context, const unsigned char *buf, size_t len); void my_md5_result(void *context, unsigned char *digest); -#include <mysql/service_logger.h> typedef struct logger_handle_st LOGGER_HANDLE; extern struct logger_service_st { void (*logger_init_mutexes)(); @@ -160,14 +147,12 @@ extern struct logger_service_st { int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size); int logger_rotate(LOGGER_HANDLE *log); -#include <mysql/service_thd_autoinc.h> extern struct thd_autoinc_service_st { void (*thd_get_autoinc_func)(const void* thd, unsigned long* off, unsigned long* inc); } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); -#include <mysql/service_thd_error_context.h> extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); @@ -185,7 +170,6 @@ void thd_inc_error_row(void* thd); char *thd_get_error_context_description(void* thd, char *buffer, unsigned int length, unsigned int max_query_length); -#include <mysql/service_thd_specifics.h> typedef int MYSQL_THD_KEY_T; extern struct thd_specifics_service_st { int (*thd_key_create_func)(MYSQL_THD_KEY_T *key); @@ -197,7 +181,6 @@ int thd_key_create(MYSQL_THD_KEY_T *key); void thd_key_delete(MYSQL_THD_KEY_T *key); void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key); int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value); -#include <mysql/service_encryption.h> typedef int (*encrypt_decrypt_func)(const unsigned char* src, unsigned int slen, unsigned char* dst, unsigned int* dlen, const unsigned char* key, unsigned int klen, @@ -213,7 +196,6 @@ struct encryption_service_st { encrypt_decrypt_func encryption_decrypt_func; }; extern struct encryption_service_st encryption_handler; -#include <mysql/service_encryption_scheme.h> struct st_encryption_scheme_key { unsigned int version; unsigned char key[16]; @@ -315,8 +297,6 @@ struct st_maria_plugin const char *version_info; unsigned int maturity; }; -#include "plugin_ftparser.h" -#include "plugin.h" enum enum_ftparser_mode { MYSQL_FTPARSER_SIMPLE_MODE= 0, diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index 898b9871d2e..e9b514feb8a 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -1,4 +1,3 @@ -#include "mysql/psi/psi.h" C_MODE_START struct TABLE_SHARE; struct sql_digest_storage; diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp index c3dba0a9b76..4e81fd66ca4 100644 --- a/include/mysql/psi/psi_abi_v2.h.pp +++ b/include/mysql/psi/psi_abi_v2.h.pp @@ -1,4 +1,3 @@ -#include "mysql/psi/psi.h" C_MODE_START struct TABLE_SHARE; struct sql_digest_storage; diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 9dd58bebbbe..7dfc572b281 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -381,7 +381,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") CONFIGURE_FILE( ${VERSION_SCRIPT_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld - @ONLY@ + @ONLY ) SET(VERSION_SCRIPT_LINK_FLAGS "-Wl,${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld") diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index caf0309710e..8af5a284b9a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1507,6 +1507,12 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) memory */ +#ifdef EMBEDDED_LIBRARY +#define STMT_INIT_PREALLOC(S) 0 +#else +#define STMT_INIT_PREALLOC(S) S +#endif /*EMBEDDED_LIBRARY*/ + MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql) { @@ -1525,8 +1531,10 @@ mysql_stmt_init(MYSQL *mysql) DBUG_RETURN(NULL); } - init_alloc_root(&stmt->mem_root, 2048, 2048, MYF(MY_THREAD_SPECIFIC)); - init_alloc_root(&stmt->result.alloc, 4096, 4096, MYF(MY_THREAD_SPECIFIC)); + init_alloc_root(&stmt->mem_root, 2048, STMT_INIT_PREALLOC(2048), + MYF(MY_THREAD_SPECIFIC)); + init_alloc_root(&stmt->result.alloc, 4096, STMT_INIT_PREALLOC(4096), + MYF(MY_THREAD_SPECIFIC)); stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS); mysql->stmts= list_add(mysql->stmts, &stmt->list); stmt->list.data= stmt; @@ -1543,6 +1551,8 @@ mysql_stmt_init(MYSQL *mysql) DBUG_RETURN(stmt); } +#undef STMT_INIT_PREALLOC + /* Prepare server side statement with query. diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 1ab9cd9b1e7..a16e82f2364 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -33,6 +33,7 @@ debug-no-sync # Retry bind as this may fail on busy server port-open-timeout=10 +bind-address=127.0.0.1 log-bin-trust-function-creators=1 key_buffer_size= 1M diff --git a/mysql-test/include/have_ipv6.inc b/mysql-test/include/have_ipv6.inc deleted file mode 100644 index 752dd0db53e..00000000000 --- a/mysql-test/include/have_ipv6.inc +++ /dev/null @@ -1,20 +0,0 @@ -# Check if ipv6 is available. -# ---disable_query_log ---disable_result_log ---disable_abort_on_error -connect (checkcon123456789,::1,root,,test); -if($mysql_errno) -{ - skip No IPv6 support; -} -connection default; -if(!$mysql_errno) -{ - disconnect checkcon123456789; -} ---enable_abort_on_error ---enable_result_log ---enable_query_log -# end check - diff --git a/mysql-test/suite/perfschema/include/no_protocol.inc b/mysql-test/include/no_protocol.inc index 451c22f62e3..8ffd3509afc 100644 --- a/mysql-test/suite/perfschema/include/no_protocol.inc +++ b/mysql-test/include/no_protocol.inc @@ -1,5 +1,3 @@ -# Tests for the performance schema - # The file with expected results fits only to a run without # ps-protocol/sp-protocol/cursor-protocol/view-protocol. if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 6dae1c2838d..43d0ace3d96 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -1488,6 +1488,17 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t2; DROP TABLE t1; +CREATE TABLE t1 ( +`transaction_id` int(11) NOT NULL DEFAULT '0', +KEY `transaction_id` (`transaction_id`)); +ALTER TABLE t1 DROP KEY IF EXISTS transaction_id, ADD PRIMARY KEY IF NOT EXISTS (transaction_id); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `transaction_id` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`transaction_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; # Bug#11748057 (formerly known as 34972): ALTER TABLE statement doesn't # identify correct column name. # diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 5a990fda971..4b519e213ef 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -6040,6 +6040,21 @@ DROP TABLE t1; # End of ctype_utf8_ilseq.inc # # +# MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8); +CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('aaa'); +INSERT INTO t2 VALUES ('aaa'); +SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2); +(SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2) +1 +INSERT INTO t1 VALUES ('aaa'); +INSERT INTO t2 VALUES ('aaa'); +SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2; +# # End of 5.5 tests # # diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index cc4e8074395..04ab385bca6 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -1455,6 +1455,12 @@ Warnings: Warning 1918 Encountered illegal value '18446744073709552001' when converting to INT Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement # +# MDEV-7505 - Too large scale in DECIMAL dynamic column getter crashes +# mysqld +# +SELECT COLUMN_GET(`x`, 'y' AS DECIMAL(5,34)); +ERROR 42000: Too big scale 34 specified for ''y''. Maximum is 30. +# # test of symbolic names # # creation test (names) diff --git a/mysql-test/r/empty_server_name-8224.result b/mysql-test/r/empty_server_name-8224.result new file mode 100644 index 00000000000..6423114470d --- /dev/null +++ b/mysql-test/r/empty_server_name-8224.result @@ -0,0 +1 @@ +create server '' foreign data wrapper w2 options (host '127.0.0.1'); diff --git a/mysql-test/r/func_regexp_pcre.result b/mysql-test/r/func_regexp_pcre.result index 641c4fddbf7..aa090c9faf6 100644 --- a/mysql-test/r/func_regexp_pcre.result +++ b/mysql-test/r/func_regexp_pcre.result @@ -845,3 +845,32 @@ SET default_regex_flags=DEFAULT; SELECT REGEXP_REPLACE('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that'); REGEXP_REPLACE('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that') 1 this and that +# +# MDEV-8102 REGEXP function fails to match hex values when expression is stored as a variable +# +# Testing a warning +SET NAMES latin1; +SET @regCheck= '\\xE0\\x01'; +SELECT 0xE001 REGEXP @regCheck; +0xE001 REGEXP @regCheck +0 +Warnings: +Warning 1139 Got error 'pcre_exec: Invalid utf8 byte sequence in the subject string' from regexp +# Testing workaround N1: This makes the pattern to be a binary string: +SET NAMES latin1; +SET @regCheck= X'E001'; +SELECT 0xE001 REGEXP @regCheck; +0xE001 REGEXP @regCheck +1 +# Testing workaround N2: This also makes the pattern to be a binary string, using a different syntax: +SET NAMES latin1; +SET @regCheck= _binary '\\xE0\\x01'; +SELECT 0xE001 REGEXP @regCheck; +0xE001 REGEXP @regCheck +1 +# Testing workarond N3: This makes derivation of the subject string stronger (IMLICIT instead of COERCIBLE) +SET NAMES latin1; +SET @regCheck= '\\xE0\\x01'; +SELECT CAST(0xE001 AS BINARY) REGEXP @regCheck; +CAST(0xE001 AS BINARY) REGEXP @regCheck +1 diff --git a/mysql-test/r/func_regexp_pcre_debug.result b/mysql-test/r/func_regexp_pcre_debug.result new file mode 100644 index 00000000000..e44492fca72 --- /dev/null +++ b/mysql-test/r/func_regexp_pcre_debug.result @@ -0,0 +1,10 @@ +SET debug_dbug='+d,pcre_exec_error_123'; +SELECT 'a' RLIKE 'a'; +'a' RLIKE 'a' +0 +Warnings: +Warning 1139 Got error 'pcre_exec: Internal error (-123)' from regexp +SET debug_dbug=''; +SELECT 'a' RLIKE 'a'; +'a' RLIKE 'a' +1 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 1943c511853..0a2bbc97e25 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2701,3 +2701,45 @@ id date1 date2 DATE_ADD(a.date1,INTERVAL -10 DAY) TO_DAYS(a.date1)-10 17 NULL NULL NULL NULL 18 2010-10-13 2010-10-03 2010-10-03 734413 DROP TABLE t1; +# +# Start of 10.0 tests +# +# +# MDEV-8205 timediff returns null when comparing decimal time to time string value +# +SELECT +TIMEDIFF('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ) AS str_str, +TIMEDIFF('2014-01-01 00:00:00' , 20140101010000.000 ) AS str_dec, +TIMEDIFF(20140101000000.000 , 20140101010000.000 ) AS dec_dec, +TIMEDIFF(20140101000000.000 , '2014-01-01 01:00:00' ) AS dec_str; +str_str str_dec dec_dec dec_str +-01:00:00 -01:00:00.000 -01:00:00.000 -01:00:00.000 +SELECT +TIMEDIFF('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ) AS str_str, +TIMEDIFF('2014-01-01 00:00:00' , 20140102010000.000 ) AS str_dec, +TIMEDIFF(20140101000000.000 , 20140102010000.000 ) AS dec_dec, +TIMEDIFF(20140101000000.000 , '2014-01-02 01:00:00' ) AS dec_str; +str_str str_dec dec_dec dec_str +-25:00:00 -25:00:00.000 -25:00:00.000 -25:00:00.000 +SELECT +TIMEDIFF('2014-01-01 00:00:00' , '2014-02-02 01:00:00' ) AS str_str, +TIMEDIFF('2014-01-01 00:00:00' , 20140202010000.000 ) AS str_dec, +TIMEDIFF(20140101000000.000 , 20140202010000.000 ) AS dec_dec, +TIMEDIFF(20140101000000.000 , '2014-02-02 01:00:00' ) AS dec_str; +str_str str_dec dec_dec dec_str +-769:00:00 -769:00:00.000 -769:00:00.000 -769:00:00.000 +SELECT +TIMEDIFF('2014-01-01 00:00:00' , '2014-03-02 01:00:00' ) AS str_str, +TIMEDIFF('2014-01-01 00:00:00' , 20140302010000.000 ) AS str_dec, +TIMEDIFF(20140101000000.000 , 20140302010000.000 ) AS dec_dec, +TIMEDIFF(20140101000000.000 , '2014-03-02 01:00:00' ) AS dec_str; +str_str str_dec dec_dec dec_str +-838:59:59 -838:59:59.999 -838:59:59.999 -838:59:59.999 +Warnings: +Warning 1292 Truncated incorrect time value: '-1441:00:00' +Warning 1292 Truncated incorrect time value: '-1441:00:00' +Warning 1292 Truncated incorrect time value: '-1441:00:00' +Warning 1292 Truncated incorrect time value: '-1441:00:00' +# +# End of 10.0 tests +# diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 9f5eb053cb7..38abbfef261 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2342,7 +2342,7 @@ DROP TABLE t1; create table t1 (a int, b int); insert into t1 values (1,11), (1,12), (2,22),(2,23), (4,44),(4,45); create table t2 (c int, d int); -insert into t2 values (1,11), (1,12), (2,22),(2,23), (4,44),(4,45); +insert into t2 values (1,11), (2,22), (4,44); select distinct a,sum(b), (select d from t2 where c=a order by max(b) limit 1) from t1 group by a order by max(b); a sum(b) (select d from t2 where c=a order by max(b) limit 1) 1 23 11 diff --git a/mysql-test/r/information_schema2.result b/mysql-test/r/information_schema2.result index 60a20944839..f82301699a7 100644 --- a/mysql-test/r/information_schema2.result +++ b/mysql-test/r/information_schema2.result @@ -6,3 +6,15 @@ select variable_name from information_schema.session_variables where variable_na (select variable_name from information_schema.session_variables where variable_name = 'basedir'); variable_name BASEDIR +create table t1 (a char); +insert t1 values ('a'),('t'),('z'); +flush status; +select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1; +a exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) +a 0 +t 1 +z 0 +show status like 'created_tmp_tables'; +Variable_name Value +Created_tmp_tables 43 +drop table t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index a99aed61cd9..093de1339f3 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2527,6 +2527,17 @@ test.t1 check error Size of indexfile is: 1024 Should be: 2048 test.t1 check warning Size of datafile is: 14 Should be: 7 test.t1 check error Corrupt DROP TABLE t1; +# +# MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +# disabled keys +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; show variables like 'myisam_block_size'; Variable_name Value myisam_block_size 1024 diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result index c00a0c73ce3..03543244105 100644 --- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result @@ -76,3 +76,16 @@ set @toggle=1; execute set_wsrep_myisam using @toggle; TRUNCATE TABLE time_zone_leap_second; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; set @toggle=0; execute set_wsrep_myisam using @toggle; +# +# MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL +# +set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); +prepare set_wsrep_myisam from @prep; +set @toggle=1; execute set_wsrep_myisam using @toggle; +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; +set @toggle=0; execute set_wsrep_myisam using @toggle; diff --git a/mysql-test/r/mysql_upgrade_view.result b/mysql-test/r/mysql_upgrade_view.result index 9490544e4d5..ef54ab6c9a5 100644 --- a/mysql-test/r/mysql_upgrade_view.result +++ b/mysql-test/r/mysql_upgrade_view.result @@ -3,6 +3,41 @@ drop table if exists t1,v1,v2,v3,v4,v1badcheck; drop view if exists t1,v1,v2,v3,v4,v1badcheck; create table t1(a int); create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50)); +create view v1 as select 1; +repair table t1 quick; +Table Op Msg_type Msg_text +test.t1 repair status OK +repair table t1 extended; +Table Op Msg_type Msg_text +test.t1 repair status OK +repair table t1 use_frm; +Table Op Msg_type Msg_text +test.t1 repair status OK +repair table t1 from mysql; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from mysql' at line 1 +repair view v1 quick; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'quick' at line 1 +repair view v1 extended; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'extended' at line 1 +repair view v1 use_frm; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'use_frm' at line 1 +repair view v1 from mysql; +Table Op Msg_type Msg_text +test.v1 repair status OK +check view v1 quick; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'quick' at line 1 +check view v1 fast; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'fast' at line 1 +check view v1 medium; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'medium' at line 1 +check view v1 extended; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'extended' at line 1 +check view v1 changed; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'changed' at line 1 +check view v1 for upgrade; +Table Op Msg_type Msg_text +test.v1 check status OK +drop view v1; flush tables; check view v1; Table Op Msg_type Msg_text diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index adfc56fcd69..7d646dce596 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -347,3 +347,26 @@ CREATE TABLE test.`t.1` (id int); mysqlcheck test t.1 test.t.1 OK drop table test.`t.1`; +create view v1 as select 1; +mysqlcheck --process-views test +test.v1 OK +mysqlcheck --process-views --extended test +test.v1 OK +mysqlcheck --process-views --fast test +mysqlcheck --process-views --quick test +test.v1 OK +mysqlcheck --process-views --check-only-changed test +mysqlcheck --process-views --medium-check test +test.v1 OK +mysqlcheck --process-views --check-upgrade test +test.v1 OK +drop view v1; +create table t1(a int); +mysqlcheck --process-views --check-upgrade --auto-repair test +test.t1 OK +test.v1 Needs upgrade + +Repairing views +test.v1 OK +drop view v1; +drop table t1; diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 92c9c01db2d..798e3b9a6bf 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -380,33 +380,33 @@ DROP TABLE t1; create table t1 (a int) engine=innodb partition by hash(a) ; show table status like 't1'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int) engine = innodb partition by key (a); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned insert into t1 values (0), (1), (2), (3); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 4 4096 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 4 4096 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int auto_increment primary key) engine = innodb partition by key (a); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 2 8192 16384 0 0 # 1 NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 2 8192 16384 0 0 # 1 # NULL NULL latin1_swedish_ci NULL partitioned insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 4 4096 16384 0 0 # 5 NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 4 4096 16384 0 0 # 5 # NULL NULL latin1_swedish_ci NULL partitioned insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Compact 8 2048 16384 0 0 # 9 NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Compact 8 2048 16384 0 0 # 9 # NULL NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int) partition by key (a) @@ -588,6 +588,17 @@ a b 0 1 DROP TABLE t1; # +# Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE +# WRONG FOR PARTITIONED TABLES +# +CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB +PARTITION BY HASH (a) PARTITIONS 2; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE +CREATE_TIME IS NOT NULL AND TABLE_NAME='t1'; +COUNT(*) +1 +DROP TABLE t1; +# # BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == # SAVE_READ_SET # diff --git a/mysql-test/r/partition_myisam.result b/mysql-test/r/partition_myisam.result index 80b3a9511ea..bb1a7b19a9d 100644 --- a/mysql-test/r/partition_myisam.result +++ b/mysql-test/r/partition_myisam.result @@ -90,7 +90,7 @@ ERROR HY000: Failed to read from the .par file # Note that it is currently impossible to drop a partitioned table # without the .par file DROP TABLE t1; -ERROR 42S02: Unknown table 'test.t1' +ERROR HY000: Got error 1 "Operation not permitted" from storage engine partition # # Bug#50392: insert_id is not reset for partitioned tables # auto_increment on duplicate entry diff --git a/mysql-test/r/partition_not_blackhole.result b/mysql-test/r/partition_not_blackhole.result index c5832d66da4..ff1e51df892 100644 --- a/mysql-test/r/partition_not_blackhole.result +++ b/mysql-test/r/partition_not_blackhole.result @@ -11,6 +11,6 @@ t1 SHOW CREATE TABLE t1; ERROR HY000: Failed to read from the .par file DROP TABLE t1; -ERROR 42S02: Unknown table 'test.t1' +ERROR HY000: Got error 1 "Operation not permitted" from storage engine partition t1.frm t1.par diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 42a29f25432..74b312359a8 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -321,3 +321,16 @@ UNUSABLE uninstall soname 'ha_example'; select plugin_name from information_schema.plugins where plugin_library like 'ha_example%'; plugin_name +# +# MDEV-5309 - RENAME TABLE does not check for existence of the table's +# engine +# +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TABLE t1(a INT) ENGINE=EXAMPLE; +SELECT * FROM t1; +a +FLUSH TABLES; +UNINSTALL PLUGIN example; +RENAME TABLE t1 TO t2; +ERROR 42S02: Table 'test.t1' doesn't exist +DROP TABLE t1; diff --git a/mysql-test/r/range_innodb.result b/mysql-test/r/range_innodb.result new file mode 100644 index 00000000000..794e6c7b3cc --- /dev/null +++ b/mysql-test/r/range_innodb.result @@ -0,0 +1,39 @@ +# +# Range optimizer (and related) tests that need InnoDB. +# +drop table if exists t0, t1, t2; +# +# MDEV-6735: Range checked for each record used with key +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 + D.a * 1000 +from t0 A, t0 B, t0 C, t0 D; +create table t2 ( +a int, +b int, +filler1 char(100), +filler2 char(100), +filler3 char(100), +filler4 char(100), +key(a), +key(b) +) engine=innodb; +insert into t2 +select +a,a, +repeat('0123456789', 10), +repeat('0123456789', 10), +repeat('0123456789', 10), +repeat('0123456789', 10) +from t1; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +# The following must not use "Range checked for each record": +explain select * from t0 left join t2 on t2.a <t0.a and t2.b between 50 and 250; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 +1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join) +drop table t0,t1,t2; diff --git a/mysql-test/r/ssl_7937,nossl.result b/mysql-test/r/ssl_7937,nossl.result new file mode 100644 index 00000000000..72693233bc8 --- /dev/null +++ b/mysql-test/r/ssl_7937,nossl.result @@ -0,0 +1,15 @@ +create procedure have_ssl() +select if(variable_value > '','yes','no') as 'have_ssl' + from information_schema.session_status +where variable_name='ssl_cipher'; +mysql --ssl-ca=cacert.pem -e "call test.have_ssl()" +have_ssl +no +mysql --ssl -e "call test.have_ssl()" +have_ssl +no +mysql --ssl-ca=cacert.pem --ssl-verify-server-cert -e "call test.have_ssl()" +ERROR 2026 (HY000): SSL connection error: SSL is required, but the server does not support it +mysql --ssl --ssl-verify-server-cert -e "call test.have_ssl()" +ERROR 2026 (HY000): SSL connection error: SSL is required, but the server does not support it +drop procedure have_ssl; diff --git a/mysql-test/r/ssl_7937.result b/mysql-test/r/ssl_7937.result new file mode 100644 index 00000000000..a94ca3b3529 --- /dev/null +++ b/mysql-test/r/ssl_7937.result @@ -0,0 +1,16 @@ +create procedure have_ssl() +select if(variable_value > '','yes','no') as 'have_ssl' + from information_schema.session_status +where variable_name='ssl_cipher'; +mysql --ssl-ca=cacert.pem -e "call test.have_ssl()" +have_ssl +yes +mysql --ssl -e "call test.have_ssl()" +have_ssl +yes +mysql --ssl-ca=cacert.pem --ssl-verify-server-cert -e "call test.have_ssl()" +have_ssl +yes +mysql --ssl --ssl-verify-server-cert -e "call test.have_ssl()" +ERROR 2026 (HY000): SSL connection error: Failed to verify the server certificate +drop procedure have_ssl; diff --git a/mysql-test/r/truncate-stale-6500.result b/mysql-test/r/truncate-stale-6500.result new file mode 100644 index 00000000000..b6222716953 --- /dev/null +++ b/mysql-test/r/truncate-stale-6500.result @@ -0,0 +1,33 @@ +SET GLOBAL query_cache_size=1024*1024*8; +CREATE TABLE `test` ( +`uniqueId` INT NOT NULL, +`partitionId` INT NOT NULL, +PRIMARY KEY (`uniqueId`,`partitionId`) +) ENGINE=InnoDB PARTITION BY LIST (partitionId) ( +PARTITION p01 VALUES IN (1), +PARTITION p02 VALUES IN (2) +); +INSERT INTO `test`(`uniqueId`,`partitionId`) VALUES(407237055, 2); +SELECT * FROM `test`; +uniqueId partitionId +407237055 2 +#Confirms 1 row in partition 'p02' +SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test'; +TABLE_NAME PARTITION_NAME TABLE_ROWS +test p01 0 +test p02 1 +ALTER TABLE `test` TRUNCATE PARTITION `p02`; +#Confirms no more rows in partition 'p02' +SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test'; +TABLE_NAME PARTITION_NAME TABLE_ROWS +test p01 0 +test p02 0 +#Before the patch, this returned the previously existing values. +SELECT * FROM `test`; +uniqueId partitionId +SELECT SQL_CACHE * FROM `test`; +uniqueId partitionId +SELECT SQL_NO_CACHE * FROM `test`; +uniqueId partitionId +DROP TABLE test; +SET GLOBAL query_cache_size=DEFAULT; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index f8649f030bb..cde8816dee4 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -994,3 +994,24 @@ GROUP BY t2.col0 WHERE CONCAT(t1.col1, CAST(subq.col0 AS DECIMAL)); 1 DROP TABLE t1, t2; +# +# Start of 5.5 tests +# +# +# MDEV-8267 Add /*old*/ comment into I_S.COLUMN_TYPE for old DECIMAL +# +SHOW CREATE TABLE t1dec102; +Table Create Table +t1dec102 CREATE TABLE `t1dec102` ( + `a` decimal(10,2)/*old*/ DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SHOW COLUMNS FROM t1dec102; +Field Type Null Key Default Extra +a decimal(10,2)/*old*/ YES NULL +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1dec102'; +COLUMN_NAME DATA_TYPE COLUMN_TYPE +a decimal decimal(10,2)/*old*/ +DROP TABLE t1dec102; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/type_time_hires.result b/mysql-test/r/type_time_hires.result index 8096785dcc1..2620dac0794 100644 --- a/mysql-test/r/type_time_hires.result +++ b/mysql-test/r/type_time_hires.result @@ -115,7 +115,6 @@ NULL delete from t1 where a < 20110101; select * from t1; a -01:02:13.3332 NULL create table t2 select * from t1; create table t3 like t1; @@ -135,12 +134,11 @@ Warnings: Note 1265 Data truncated for column 'a' at row 1 select a, a+0, a-1, a*1, a/2 from t1; a a+0 a-1 a*1 a/2 -01:02:13.3332 10213.3332 10212.3332 10213.3332 5106.66660000 NULL NULL NULL NULL NULL 14:15:16.2222 141516.2222 141515.2222 141516.2222 70758.11110000 select max(a), min(a), sum(a), avg(a) from t1; max(a) min(a) sum(a) avg(a) -14:15:16.2222 01:02:13.3332 151729.5554 75864.77770000 +14:15:16.2222 14:15:16.2222 141516.2222 141516.22220000 create table t2 select a, a+0, a-1, a*1, a/2 from t1; create table t3 select max(a), min(a), sum(a), avg(a) from t1; show create table t2; diff --git a/mysql-test/r/update_innodb.result b/mysql-test/r/update_innodb.result new file mode 100644 index 00000000000..88c86c50625 --- /dev/null +++ b/mysql-test/r/update_innodb.result @@ -0,0 +1,31 @@ +CREATE TABLE `t1` ( +`c1` int(11) NOT NULL, +`c2` datetime DEFAULT NULL, +PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE `t2` ( +`c0` varchar(10) NOT NULL, +`c1` int(11) NOT NULL, +`c2` int(11) NOT NULL, +PRIMARY KEY (`c0`,`c1`), +KEY `c1` (`c1`), +KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE `t3` ( +`id` int(11) unsigned NOT NULL AUTO_INCREMENT, +`c1` datetime NOT NULL, +`c2` bigint(20) NOT NULL, +`c3` int(4) unsigned NOT NULL, +PRIMARY KEY (`id`), +KEY `c2` (`c2`), +KEY `c3` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE `t4` ( +`c1` int(11) NOT NULL, +`c2` bigint(20) DEFAULT NULL, +`c3` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE ALGORITHM=UNDEFINED VIEW `v1` AS select `t4`.`c1` AS `c1`,`t4`.`c2` AS `c2`,`t4`.`c3` AS `c3` from `t4`; +UPDATE t1 a JOIN t2 b ON a.c1 = b.c1 JOIN v1 vw ON b.c2 = vw.c1 JOIN t3 del ON vw.c2 = del.c2 SET a.c2 = ( SELECT max(t.c1) FROM t3 t, v1 i WHERE del.c2 = t.c2 AND vw.c3 = i.c3 AND t.c3 = 4 ) WHERE a.c2 IS NULL OR a.c2 < '2011-05-01'; +drop view v1; +drop table t1,t2,t3,t4; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index abb9c6240d3..d8b71fb119c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5410,6 +5410,24 @@ create view v2 as select t2.* from (t2 left join v1 using (id)); update t3 left join v2 using (id) set flag=flag+1; drop view v2, v1; drop table t1, t2, t3; +# +# MDEV-7207 - ALTER VIEW does not change ALGORITM +# +create table t1 (a int, b int); +create algorithm=temptable view v2 (c) as select b+1 from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci +alter algorithm=undefined view v2 (c) as select b+1 from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci +alter algorithm=merge view v2 (c) as select b+1 from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci +drop view v2; +drop table t1; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/std_data/old_decimal/t1dec102.MYD b/mysql-test/std_data/old_decimal/t1dec102.MYD new file mode 100644 index 00000000000..59e43854d4a --- /dev/null +++ b/mysql-test/std_data/old_decimal/t1dec102.MYD @@ -0,0 +1 @@ +ý 123.45ý 123.46ý 123.47
\ No newline at end of file diff --git a/mysql-test/std_data/old_decimal/t1dec102.MYI b/mysql-test/std_data/old_decimal/t1dec102.MYI Binary files differnew file mode 100644 index 00000000000..e0b2d4a003c --- /dev/null +++ b/mysql-test/std_data/old_decimal/t1dec102.MYI diff --git a/mysql-test/std_data/old_decimal/t1dec102.frm b/mysql-test/std_data/old_decimal/t1dec102.frm Binary files differnew file mode 100644 index 00000000000..652cfc3bbac --- /dev/null +++ b/mysql-test/std_data/old_decimal/t1dec102.frm diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result index 714c01d8426..0372d2749a8 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result @@ -327,6 +327,18 @@ INSERT INTO t2 SET a=1; INSERT INTO t2 SET b=1; UPDATE t1, t2 SET t1.a=10, t2.a=20; DROP TABLE t1,t2; +INSERT INTO t1dec102 VALUES (-999.99); +INSERT INTO t1dec102 VALUES (0); +INSERT INTO t1dec102 VALUES (999.99); +SELECT * FROM t1dec102 ORDER BY a; +a +-999.99 +0.00 +123.45 +123.46 +123.47 +999.99 +DROP TABLE t1dec102; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; @@ -4555,6 +4567,62 @@ SET TIMESTAMP=1000000000/*!*/; DROP TABLE `t1`,`t2` /* generated by server */ /*!*/; # at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-317 +/*!100001 SET @@session.gtid_seq_no=317*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-318 +/*!100001 SET @@session.gtid_seq_no=318*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-319 +/*!100001 SET @@session.gtid_seq_no=319*//*!*/; +BEGIN +/*!*/; +# at # +# at # +#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1dec102` mapped to number # +#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F +### INSERT INTO `test`.`t1dec102` +### SET +### @1=!! Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. # at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-320 ddl +/*!100001 SET @@session.gtid_seq_no=320*//*!*/; +# at # +#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 +SET TIMESTAMP=1000000000/*!*/; +DROP TABLE `t1dec102` /* generated by server */ +/*!*/; +# at # #010909 4:46:40 server id 1 end_log_pos # Rotate to master-bin.000002 pos: 4 DELIMITER ; # End of log file diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test index 9b41c63d195..9609a9af384 100644 --- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test @@ -438,9 +438,20 @@ INSERT INTO t2 SET b=1; UPDATE t1, t2 SET t1.a=10, t2.a=20; DROP TABLE t1,t2; +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1dec102.frm +--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1dec102.MYD +--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1dec102.MYI + +INSERT INTO t1dec102 VALUES (-999.99); +INSERT INTO t1dec102 VALUES (0); +INSERT INTO t1dec102 VALUES (999.99); +SELECT * FROM t1dec102 ORDER BY a; +DROP TABLE t1dec102; + flush logs; -let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9]*[.][0-9]{1,3})[0-9e+-]*[^ ]*(.*(FLOAT|DOUBLE).*[*].)/\1...\2/ --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001 diff --git a/mysql-test/suite/funcs_1/t/processlist_priv_no_prot.test b/mysql-test/suite/funcs_1/t/processlist_priv_no_prot.test index d6746d92250..88563b046df 100644 --- a/mysql-test/suite/funcs_1/t/processlist_priv_no_prot.test +++ b/mysql-test/suite/funcs_1/t/processlist_priv_no_prot.test @@ -25,10 +25,6 @@ let $fixed_bug_30395= 0; # The file with expected results fits only to a run without # ps-protocol/sp-protocol/cursor-protocol/view-protocol. -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL - + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} +--source include/no_protocol.inc --source suite/funcs_1/datadict/processlist_priv.inc diff --git a/mysql-test/suite/funcs_1/t/processlist_val_no_prot.test b/mysql-test/suite/funcs_1/t/processlist_val_no_prot.test index b92c963c79c..a03d3774484 100644 --- a/mysql-test/suite/funcs_1/t/processlist_val_no_prot.test +++ b/mysql-test/suite/funcs_1/t/processlist_val_no_prot.test @@ -20,10 +20,6 @@ # The file with expected results fits only to a run without # ps-protocol/sp-protocol/cursor-protocol/view-protocol. -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL - + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} +--source include/no_protocol.inc --source suite/funcs_1/datadict/processlist_val.inc diff --git a/mysql-test/suite/innodb/r/innodb_blob_unrecoverable_crash.result b/mysql-test/suite/innodb/r/innodb_blob_unrecoverable_crash.result new file mode 100644 index 00000000000..9f6b7ca6a23 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_blob_unrecoverable_crash.result @@ -0,0 +1,23 @@ +call mtr.add_suppression("InnoDB: The total blob data length"); +SET GLOBAL max_allowed_packet = 100*1024*1024; +# Connection big_packets: +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB; +INSERT INTO t1 (a, b) VALUES (1, '1'); +INSERT INTO t1 (a, b) VALUES (2, '2'); +INSERT INTO t1 (a, b) VALUES (3, '3'); +INSERT INTO t1 (a, b) VALUES (4, '4'); +INSERT INTO t1 (a, b) VALUES (5, '5'); +start transaction; +INSERT INTO t1 (a, b) VALUES (6, REPEAT('a', 20*1024*1024)); +ERROR 42000: The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size. +# Connection default: +# Quick shutdown and restart server +# Connection default: +SELECT a FROM t1; +a +1 +2 +3 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/xa_recovery.result b/mysql-test/suite/innodb/r/xa_recovery.result new file mode 100644 index 00000000000..84cb37ef7c9 --- /dev/null +++ b/mysql-test/suite/innodb/r/xa_recovery.result @@ -0,0 +1,17 @@ +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +XA START 'x'; +UPDATE t1 set a=2; +XA END 'x'; +XA PREPARE 'x'; +call mtr.add_suppression("Found 1 prepared XA transactions"); +SELECT * FROM t1 LOCK IN SHARE MODE; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +a +2 +XA ROLLBACK 'x'; +SELECT * FROM t1; +a +1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/foreign-keys.test b/mysql-test/suite/innodb/t/foreign-keys.test index 8ee96347208..2d586e2d6be 100644 --- a/mysql-test/suite/innodb/t/foreign-keys.test +++ b/mysql-test/suite/innodb/t/foreign-keys.test @@ -1,11 +1,6 @@ --source include/have_innodb.inc --source include/have_debug.inc -if (`select plugin_auth_version <= "5.5.39-MariaDB-36.0" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.39-MariaDB-36.0 or earlier -} - --echo # --echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE --echo # ADD FOREIGN KEY diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index 415ada2939a..ffe4ac9c3ae 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -1,8 +1,3 @@ -if (`select plugin_auth_version <= "5.5.37-MariaDB-34.0" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.37-MariaDB-34.0 or earlier -} - --source include/have_innodb.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc diff --git a/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test b/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test new file mode 100644 index 00000000000..16fb570737d --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_blob_unrecoverable_crash.test @@ -0,0 +1,55 @@ +--source include/not_embedded.inc +--source include/not_crashrep.inc +--source include/have_innodb.inc + +call mtr.add_suppression("InnoDB: The total blob data length"); + +let $old_max_allowed_packet = `select @@max_allowed_packet`; +SET GLOBAL max_allowed_packet = 100*1024*1024; + +--echo # Connection big_packets: +connect(big_packets,localhost,root,,); +connection big_packets; + +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB; + +# Insert a few rows (it doesn't really matter how many). These transactions +# are committed once they are acked, so they should not be lost. +INSERT INTO t1 (a, b) VALUES (1, '1'); +INSERT INTO t1 (a, b) VALUES (2, '2'); +INSERT INTO t1 (a, b) VALUES (3, '3'); +INSERT INTO t1 (a, b) VALUES (4, '4'); +INSERT INTO t1 (a, b) VALUES (5, '5'); + +# The BLOB insert will fail, and should disappear. However all data committed +# up to this point should not be lost. +start transaction; +--replace_regex /\(> [0-9]*\)/(> ####)/ +--error ER_TOO_BIG_ROWSIZE +INSERT INTO t1 (a, b) VALUES (6, REPEAT('a', 20*1024*1024)); + +--echo # Connection default: +connection default; + +# We expect a restart. +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Quick shutdown and restart server +--shutdown_server 0 + +# Wait for the server to come back up, and reconnect. +--enable_reconnect +--source include/wait_until_connected_again.inc + +--echo # Connection default: +connection default; + +# We should see (1,2,3,4,5) here. +SELECT a FROM t1; + +# Clean up. +DROP TABLE t1; + +--disable_query_log +eval set global max_allowed_packet = $old_max_allowed_packet; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/insert_debug.test b/mysql-test/suite/innodb/t/insert_debug.test index 666b634bef9..36ceba2ee8b 100644 --- a/mysql-test/suite/innodb/t/insert_debug.test +++ b/mysql-test/suite/innodb/t/insert_debug.test @@ -2,11 +2,6 @@ --source include/have_debug.inc --source include/have_partition.inc -if (`select plugin_auth_version < "5.6.22" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in InnoDB/XtraDB as of 5.6.21 or earlier -} - --echo # --echo # Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1 --echo # CAUSES INFINITE PAGE SPLIT diff --git a/mysql-test/suite/innodb/t/sp_temp_table.test b/mysql-test/suite/innodb/t/sp_temp_table.test index 9a6be85fd7e..b2883f551b9 100644 --- a/mysql-test/suite/innodb/t/sp_temp_table.test +++ b/mysql-test/suite/innodb/t/sp_temp_table.test @@ -1,11 +1,6 @@ --source include/have_innodb.inc --source include/big_test.inc -if (`select plugin_auth_version < "5.6.22" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in InnoDB/XtraDB as of 5.6.21 or earlier -} - --echo # --echo # Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE --echo # CALLED FROM A FUNCTION diff --git a/mysql-test/suite/innodb/t/strict_mode.test b/mysql-test/suite/innodb/t/strict_mode.test index 9b115091f84..86b56a09c0e 100644 --- a/mysql-test/suite/innodb/t/strict_mode.test +++ b/mysql-test/suite/innodb/t/strict_mode.test @@ -1,10 +1,5 @@ --source include/have_innodb.inc -if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier -} - --echo # --echo # Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN --echo # INNODB_STRICT_MODE = 1 diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test new file mode 100644 index 00000000000..837b33cb3c4 --- /dev/null +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -0,0 +1,47 @@ +if (`select plugin_auth_version <= "5.6.24" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in InnoDB as of 5.6.24 or earlier +} +--source include/have_innodb.inc +# Embedded server does not support restarting. +--source include/not_embedded.inc + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +connect (con1,localhost,root); +XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; +connection default; + +call mtr.add_suppression("Found 1 prepared XA transactions"); + +# Kill and restart the server. +-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- shutdown_server 0 +-- source include/wait_until_disconnected.inc + +-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- enable_reconnect +-- source include/wait_until_connected_again.inc +-- disable_reconnect + +disconnect con1; +connect (con1,localhost,root); +--send SELECT * FROM t1 LOCK IN SHARE MODE + +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = 'Sending data' and + info = 'SELECT * FROM t1 LOCK IN SHARE MODE'; +--source include/wait_condition.inc + +--source include/restart_mysqld.inc + +disconnect con1; + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +XA ROLLBACK 'x'; +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/maria/optimize.result b/mysql-test/suite/maria/optimize.result index 9cce55d6199..a78e8e469aa 100644 --- a/mysql-test/suite/maria/optimize.result +++ b/mysql-test/suite/maria/optimize.result @@ -6,3 +6,14 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +# disabled keys +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; diff --git a/mysql-test/suite/maria/optimize.test b/mysql-test/suite/maria/optimize.test index 6b310b1d1a6..b1fc250cd29 100644 --- a/mysql-test/suite/maria/optimize.test +++ b/mysql-test/suite/maria/optimize.test @@ -160,3 +160,13 @@ INSERT /*! IGNORE */ INTO t1 VALUES ('urxjxqvwabikpugvexxbxdpxjkeqiuhhuadbcuhoz check table t1; OPTIMIZE TABLE t1; drop table t1; + +--echo # +--echo # MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +--echo # disabled keys +--echo # +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result index 268db30bda0..77129d6bebb 100644 --- a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result +++ b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result @@ -58,7 +58,10 @@ t1.frm t1.par SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open'; SET DEBUG_SYNC='partition_open_error SIGNAL alter WAIT_FOR finish'; -SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; +SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, +PARTITION_DESCRIPTION, TABLE_ROWS +FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; SET DEBUG_SYNC = 'now WAIT_FOR parked'; # When waiting for the name lock in get_all_tables in sql_show.cc # this will not be concurrent any more, thus the TIMEOUT @@ -70,9 +73,9 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 INTO PARTITION p10 VALUES LESS THAN MAXVALUE); Warnings: Warning 1639 debug sync point wait timed out -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -def test t1 p0 NULL 1 NULL RANGE NULL a NULL 10 1 16384 16384 NULL 0 0 NULL NULL NULL NULL default NULL -def test t1 p10 NULL 2 NULL RANGE NULL a NULL MAXVALUE 3 5461 16384 NULL 0 0 NULL NULL NULL NULL default NULL +TABLE_SCHEMA TABLE_NAME PARTITION_NAME PARTITION_ORDINAL_POSITION PARTITION_DESCRIPTION TABLE_ROWS +test t1 p0 1 10 1 +test t1 p10 2 MAXVALUE 3 t1#P#p0.ibd t1#P#p10.ibd t1.frm diff --git a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test index fce26132030..df9c06011c2 100644 --- a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test +++ b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test @@ -62,7 +62,10 @@ SHOW CREATE TABLE t1; SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open'; SET DEBUG_SYNC='partition_open_error SIGNAL alter WAIT_FOR finish'; send -SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; +SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, + PARTITION_DESCRIPTION, TABLE_ROWS +FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; connect (con1, localhost, root,,); SET DEBUG_SYNC = 'now WAIT_FOR parked'; diff --git a/mysql-test/suite/percona/percona_innodb_fake_changes.result b/mysql-test/suite/percona/percona_innodb_fake_changes.result index 95f0c07cd11..1b870fdbb92 100644 --- a/mysql-test/suite/percona/percona_innodb_fake_changes.result +++ b/mysql-test/suite/percona/percona_innodb_fake_changes.result @@ -45,7 +45,7 @@ BEGIN; CREATE TABLE t2 (a INT) ENGINE=InnoDB; ERROR HY000: Can't create table `test`.`t2` (errno: 131 "Command not supported by database") DROP TABLE t1; -ERROR 42S02: Unknown table 'test.t1' +ERROR HY000: Storage engine InnoDB of the table `test`.`t1` doesn't have this option TRUNCATE TABLE t1; ERROR HY000: Got error 131 "Command not supported by database" during COMMIT ALTER TABLE t1 ENGINE=MyISAM; diff --git a/mysql-test/suite/percona/percona_innodb_fake_changes.test b/mysql-test/suite/percona/percona_innodb_fake_changes.test index 5fa3ecc7b63..67f5450ba45 100644 --- a/mysql-test/suite/percona/percona_innodb_fake_changes.test +++ b/mysql-test/suite/percona/percona_innodb_fake_changes.test @@ -38,7 +38,7 @@ SET innodb_fake_changes=1; BEGIN; --error 1005 CREATE TABLE t2 (a INT) ENGINE=InnoDB; ---error 1051 +--error 1031 DROP TABLE t1; --error 1180 TRUNCATE TABLE t1; diff --git a/mysql-test/suite/perfschema/include/connection_setup.inc b/mysql-test/suite/perfschema/include/connection_setup.inc index da57b6dd388..a661d43d063 100644 --- a/mysql-test/suite/perfschema/include/connection_setup.inc +++ b/mysql-test/suite/perfschema/include/connection_setup.inc @@ -48,7 +48,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --source ../include/wait_for_pfs_thread_count.inc --disable_query_log diff --git a/mysql-test/suite/perfschema/include/digest_setup.inc b/mysql-test/suite/perfschema/include/digest_setup.inc index ed463f58d04..6efab880d32 100644 --- a/mysql-test/suite/perfschema/include/digest_setup.inc +++ b/mysql-test/suite/perfschema/include/digest_setup.inc @@ -1,5 +1,5 @@ # Making sure not to run when ps-protocol is set. ---source ../include/no_protocol.inc +--source include/no_protocol.inc --echo #################################### --echo # SETUP diff --git a/mysql-test/suite/perfschema/include/event_aggregate_setup.inc b/mysql-test/suite/perfschema/include/event_aggregate_setup.inc index 769ba5f8607..ec35e60d463 100644 --- a/mysql-test/suite/perfschema/include/event_aggregate_setup.inc +++ b/mysql-test/suite/perfschema/include/event_aggregate_setup.inc @@ -62,7 +62,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --source ../include/wait_for_pfs_thread_count.inc --disable_query_log diff --git a/mysql-test/suite/perfschema/include/stage_setup.inc b/mysql-test/suite/perfschema/include/stage_setup.inc index 3558e43652e..639b1df8c02 100644 --- a/mysql-test/suite/perfschema/include/stage_setup.inc +++ b/mysql-test/suite/perfschema/include/stage_setup.inc @@ -24,7 +24,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --disable_query_log diff --git a/mysql-test/suite/perfschema/include/table_aggregate_setup.inc b/mysql-test/suite/perfschema/include/table_aggregate_setup.inc index 8efdc8d2f24..522cdb9346d 100644 --- a/mysql-test/suite/perfschema/include/table_aggregate_setup.inc +++ b/mysql-test/suite/perfschema/include/table_aggregate_setup.inc @@ -67,7 +67,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --source ../include/wait_for_pfs_thread_count.inc --disable_query_log diff --git a/mysql-test/suite/perfschema/r/threads_mysql.result b/mysql-test/suite/perfschema/r/threads_mysql.result index 4da857f83fc..6ab0b0641b0 100644 --- a/mysql-test/suite/perfschema/r/threads_mysql.result +++ b/mysql-test/suite/perfschema/r/threads_mysql.result @@ -13,7 +13,7 @@ processlist_user NULL processlist_host NULL processlist_db NULL processlist_command NULL -processlist_info INTERNAL DDL LOG RECOVER IN PROGRESS +processlist_info NULL unified_parent_thread_id NULL role NULL instrumented YES diff --git a/mysql-test/suite/perfschema/t/digest_null_literal.test b/mysql-test/suite/perfschema/t/digest_null_literal.test index a3007ced1e2..91f1eec1f95 100644 --- a/mysql-test/suite/perfschema/t/digest_null_literal.test +++ b/mysql-test/suite/perfschema/t/digest_null_literal.test @@ -7,7 +7,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc TRUNCATE TABLE performance_schema.events_statements_summary_by_digest; diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test index ae58f4089ed..c1af8516b79 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test index 8c408b160a6..a5ac18a8818 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test index ccd0ae383ee..ae1de4f032e 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Hostname 'santa.claus.ipv6.example.com' does not resolve to '2001:db8::6:6'. diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test index 72d5d693a1b..361a3ce6bd1 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Hostname 'santa.claus.ipv6.example.com' does not resolve to '2001:db8::6:6'. diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test index c253e4b77d5..9dbd682681e 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] IP address '192.0.2.4' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test index 096b4b11eb4..4836dfc2d36 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test index 575dab9a337..b675b5089a8 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test index f6e5fa118df..9ce4fb926e6 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test index 0e0e900405a..9c8168e573a 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test @@ -10,7 +10,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc --source include/have_plugin_auth.inc diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test index 9d4707dc027..cd78087dad1 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test @@ -10,7 +10,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test index d4adc3e0d00..0ced79544a3 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test @@ -10,7 +10,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test index e396dbbad3c..983a6e80ff7 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] IP address '2001:db8::6:6' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test index cc7eb0b566f..3cdd87e4cf9 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] IP address '2001:db8::6:6' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test index 80f07989212..3a30030413f 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] IP address '2001:db8::6:6' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test index 0d11e433b58..054940e4a02 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test @@ -8,7 +8,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # [Warning] IP address '2001:db8::6:6' could not be resolved: diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test index 6dd33b9bb5b..811c5c51c26 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test @@ -7,7 +7,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test index 2b30a4eaf41..c11922624c6 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test @@ -7,7 +7,7 @@ --source include/not_embedded.inc --source include/have_debug.inc ---source include/have_ipv6.inc +--source include/check_ipv6.inc --source include/have_perfschema.inc # Enforce a clean state diff --git a/mysql-test/suite/perfschema/t/nesting.test b/mysql-test/suite/perfschema/t/nesting.test index 21e7260222a..29819770645 100644 --- a/mysql-test/suite/perfschema/t/nesting.test +++ b/mysql-test/suite/perfschema/t/nesting.test @@ -5,7 +5,7 @@ # On windows, the socket instrumentation collects an extra "opt" # event, which changes the test output. --source include/not_windows.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --source ../include/wait_for_pfs_thread_count.inc --disable_query_log diff --git a/mysql-test/suite/perfschema/t/rpl_gtid_func.test b/mysql-test/suite/perfschema/t/rpl_gtid_func.test index f337f95bf84..6373d4284dc 100644 --- a/mysql-test/suite/perfschema/t/rpl_gtid_func.test +++ b/mysql-test/suite/perfschema/t/rpl_gtid_func.test @@ -1,7 +1,7 @@ --source include/not_embedded.inc --source include/have_innodb.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc -- source include/master-slave.inc diff --git a/mysql-test/suite/perfschema/t/rpl_statements.test b/mysql-test/suite/perfschema/t/rpl_statements.test index 479805edccc..4f65cdcbd7b 100644 --- a/mysql-test/suite/perfschema/t/rpl_statements.test +++ b/mysql-test/suite/perfschema/t/rpl_statements.test @@ -4,7 +4,7 @@ --source include/not_embedded.inc --source include/have_innodb.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc --source include/have_binlog_format_mixed.inc --source include/master-slave.inc diff --git a/mysql-test/suite/perfschema/t/socket_instances_func-master.opt b/mysql-test/suite/perfschema/t/socket_instances_func-master.opt index ab6ca1731f5..b12a8b3b70e 100644 --- a/mysql-test/suite/perfschema/t/socket_instances_func-master.opt +++ b/mysql-test/suite/perfschema/t/socket_instances_func-master.opt @@ -1 +1 @@ ---skip-name-resolve +--skip-name-resolve --bind-address=* diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test index 5ba3af1e408..c6860eb3213 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test @@ -26,7 +26,7 @@ # happens per SQL statement within our MTR tests. And there is a significant # difference between standard statement execution and execution via # prepared statement. ---source ../include/no_protocol.inc +--source include/no_protocol.inc # Set this to enable debugging output let $my_socket_debug_dbug= 0; diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test index ef5096d85ff..d06edb0d78f 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test @@ -36,7 +36,7 @@ # happens per SQL statement within our MTR tests. And there is a significant # difference between standard statement execution and execution via # prepared statement. ---source ../include/no_protocol.inc +--source include/no_protocol.inc #=================================== diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test index 5d4b4209b6e..cefaf1de549 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test @@ -38,7 +38,7 @@ # happens per SQL statement within our MTR tests. And there is a significant # difference between standard statement execution and execution via # prepared statement. ---source ../include/no_protocol.inc +--source include/no_protocol.inc #=================================== diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest.test b/mysql-test/suite/perfschema/t/start_server_low_digest.test index 953f4d31656..6f06def169b 100644 --- a/mysql-test/suite/perfschema/t/start_server_low_digest.test +++ b/mysql-test/suite/perfschema/t/start_server_low_digest.test @@ -4,7 +4,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc USE performance_schema; truncate table events_statements_history_long; diff --git a/mysql-test/suite/perfschema/t/statement_digest_long_query.test b/mysql-test/suite/perfschema/t/statement_digest_long_query.test index be80917c9af..7a080f7a29f 100644 --- a/mysql-test/suite/perfschema/t/statement_digest_long_query.test +++ b/mysql-test/suite/perfschema/t/statement_digest_long_query.test @@ -4,7 +4,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc USE performance_schema; truncate table events_statements_summary_by_digest; diff --git a/mysql-test/suite/perfschema/t/unary_digest.test b/mysql-test/suite/perfschema/t/unary_digest.test index c4583484f36..d8daea70d38 100644 --- a/mysql-test/suite/perfschema/t/unary_digest.test +++ b/mysql-test/suite/perfschema/t/unary_digest.test @@ -7,7 +7,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source ../include/no_protocol.inc +--source include/no_protocol.inc TRUNCATE TABLE performance_schema.events_statements_summary_by_digest; diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 09dcc06c848..bf71e518f97 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -45,6 +45,11 @@ id 2 alter table t1 rename renamed_t1; set global server_audit_events='connect,query'; +select 1, +2, +3; +1 2 3 +1 2 3 insert into t2 values (1), (2); select * from t2; id @@ -157,6 +162,8 @@ id CREATE USER u1 IDENTIFIED BY 'pwd-123'; GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +SET PASSWORD FOR u1=<secret>; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=<secret>' at line 1 CREATE USER u3 IDENTIFIED BY ''; drop user u1, u2, u3; select 2; @@ -246,6 +253,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,index_stats, TIME,HOSTNAME,root,localhost,ID,ID,RENAME,test,t1|test.renamed_t1, TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'alter table t1 rename renamed_t1',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_events=\'connect,query\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select 1, 2, 3',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t2 values (1), (2)',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t2',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t_doesnt_exist',ID @@ -329,6 +337,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'/*comment*/ select 2',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u1 IDENTIFIED BY *****',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT ALL ON sa_db TO u2 IDENTIFIED BY *****',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1 = PASSWORD(*****)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1=<secret>',ID TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop user u1, u2, u3',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_events=\'\'',0 diff --git a/mysql-test/suite/plugins/r/thread_pool_server_audit.result b/mysql-test/suite/plugins/r/thread_pool_server_audit.result new file mode 100644 index 00000000000..bf71e518f97 --- /dev/null +++ b/mysql-test/suite/plugins/r/thread_pool_server_audit.result @@ -0,0 +1,367 @@ +install plugin server_audit soname 'server_audit'; +show variables like 'server_audit%'; +Variable_name Value +server_audit_events +server_audit_excl_users +server_audit_file_path server_audit.log +server_audit_file_rotate_now OFF +server_audit_file_rotate_size 1000000 +server_audit_file_rotations 9 +server_audit_incl_users +server_audit_logging OFF +server_audit_mode 0 +server_audit_output_type file +server_audit_query_log_limit 1024 +server_audit_syslog_facility LOG_USER +server_audit_syslog_ident mysql-server_auditing +server_audit_syslog_info +server_audit_syslog_priority LOG_INFO +set global server_audit_file_path=null; +set global server_audit_incl_users=null; +set global server_audit_file_path='server_audit.log'; +set global server_audit_output_type=file; +set global server_audit_logging=on; +connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) +set global server_audit_incl_users='odin, dva, tri'; +create table t1 (id int); +set global server_audit_incl_users='odin, root, dva, tri'; +create table t2 (id int); +set global server_audit_excl_users='odin, dva, tri'; +Warnings: +Warning 1 User 'odin' is in the server_audit_incl_users, so wasn't added. +Warning 1 User 'dva' is in the server_audit_incl_users, so wasn't added. +Warning 1 User 'tri' is in the server_audit_incl_users, so wasn't added. +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +set global server_audit_incl_users='odin, root, dva, tri'; +insert into t2 values (1), (2); +select * from t2; +id +1 +2 +alter table t1 rename renamed_t1; +set global server_audit_events='connect,query'; +select 1, +2, +3; +1 2 3 +1 2 3 +insert into t2 values (1), (2); +select * from t2; +id +1 +2 +1 +2 +select * from t_doesnt_exist; +ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist +syntax_error_query; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'syntax_error_query' at line 1 +drop table renamed_t1, t2; +show variables like 'server_audit%'; +Variable_name Value +server_audit_events CONNECT,QUERY +server_audit_excl_users +server_audit_file_path server_audit.log +server_audit_file_rotate_now OFF +server_audit_file_rotate_size 1000000 +server_audit_file_rotations 9 +server_audit_incl_users odin, root, dva, tri +server_audit_logging ON +server_audit_mode 0 +server_audit_output_type file +server_audit_query_log_limit 1024 +server_audit_syslog_facility LOG_USER +server_audit_syslog_ident mysql-server_auditing +server_audit_syslog_info +server_audit_syslog_priority LOG_INFO +set global server_audit_mode=1; +set global server_audit_events=''; +create database sa_db; +create table t1 (id2 int); +insert into t1 values (1), (2); +select * from t1; +id2 +1 +2 +drop table t1; +use sa_db; +create table sa_t1(id int); +insert into sa_t1 values (1), (2); +drop table sa_t1; +drop database sa_db; +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +(select 2); +2 +2 +/*! select 2*/; +2 +2 +/*comment*/ select 2; +2 +2 +drop table t1; +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +(select 2); +2 +2 +/*! select 2*/; +2 +2 +/*comment*/ select 2; +2 +2 +drop table t1; +set global server_audit_events='query_dcl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +SET PASSWORD FOR u1=<secret>; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=<secret>' at line 1 +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +select 2; +2 +2 +(select 2); +2 +2 +/*! select 2*/; +2 +2 +/*comment*/ select 2; +2 +2 +drop table t1; +set global server_audit_events=''; +set global server_audit_query_log_limit= 15; +select (1), (2), (3), (4); +1 2 3 4 +1 2 3 4 +select 'A', 'B', 'C', 'D'; +A B C D +A B C D +set global server_audit_query_log_limit= 1024; +drop database sa_db; +set global server_audit_file_path='.'; +show status like 'server_audit_current_log'; +Variable_name Value +Server_audit_current_log HOME_DIR/server_audit.log +set global server_audit_file_path=''; +show status like 'server_audit_current_log'; +Variable_name Value +Server_audit_current_log server_audit.log +set global server_audit_file_path=' '; +show status like 'server_audit_current_log'; +Variable_name Value +Server_audit_current_log server_audit.log +set global server_audit_file_path='nonexisting_dir/'; +Warnings: +Warning 1 SERVER AUDIT plugin can't create file 'nonexisting_dir/'. +show status like 'server_audit_current_log'; +Variable_name Value +Server_audit_current_log server_audit.log +show variables like 'server_audit%'; +Variable_name Value +server_audit_events +server_audit_excl_users +server_audit_file_path +server_audit_file_rotate_now OFF +server_audit_file_rotate_size 1000000 +server_audit_file_rotations 9 +server_audit_incl_users odin, root, dva, tri +server_audit_logging ON +server_audit_mode 1 +server_audit_output_type file +server_audit_query_log_limit 1024 +server_audit_syslog_facility LOG_USER +server_audit_syslog_ident mysql-server_auditing +server_audit_syslog_info +server_audit_syslog_priority LOG_INFO +uninstall plugin server_audit; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_logging=on',0 +TIME,HOSTNAME,root,localhost,ID,0,CONNECT,mysql,,0 +TIME,HOSTNAME,root,localhost,ID,0,DISCONNECT,mysql,,0 +TIME,HOSTNAME,no_such_user,localhost,ID,0,FAILED_CONNECT,,,ID +TIME,HOSTNAME,no_such_user,localhost,ID,0,DISCONNECT,,,0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_incl_users=\'odin, root, dva, tri\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,CREATE,test,t2, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create table t2 (id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_excl_users=\'odin, dva, tri\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'SHOW WARNINGS',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_incl_users=\'odin, root, dva, tri\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,test,t2, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t2 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,test,t2, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t2',0 +TIME,HOSTNAME,root,localhost,ID,ID,ALTER,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,table_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,column_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,index_stats, +TIME,HOSTNAME,root,localhost,ID,ID,RENAME,test,t1|test.renamed_t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'alter table t1 rename renamed_t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_events=\'connect,query\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select 1, 2, 3',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t2 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t_doesnt_exist',ID +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'syntax_error_query',ID +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'drop table renamed_t1, t2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show variables like \'server_audit%\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_mode=1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_events=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,0,CONNECT,test,,0 +TIME,HOSTNAME,root,localhost,ID,ID,CREATE,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create table t1 (id2 int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,table_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,column_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,index_stats, +TIME,HOSTNAME,root,localhost,ID,ID,DROP,test,t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'drop table t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'use sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,CREATE,sa_db,sa_t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'create table sa_t1(id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,sa_db,sa_t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into sa_t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,table_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,column_stats, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,index_stats, +TIME,HOSTNAME,root,localhost,ID,ID,DROP,sa_db,sa_t1, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table sa_t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,0,DISCONNECT,sa_db,,0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'use sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,roles_mapping, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u1 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT ALL ON sa_db TO u2 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1 = PASSWORD(*****)',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,roles_mapping, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,roles_mapping, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop user u1, u2, u3',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'create table t1(id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'create table t1(id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'(select 2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'/*! select 2*/',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'/*comment*/ select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u1 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT ALL ON sa_db TO u2 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1 = PASSWORD(*****)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1=<secret>',ID +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop user u1, u2, u3',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_events=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global serv',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select \'A\', ',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_query_log_limit= 1024',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\' \'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\' \'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'nonexisting_dir/\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'nonexisting_dir/\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SHOW WARNINGS',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show variables like \'server_audit%\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,plugin, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'uninstall plugin server_audit',0 diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index 787861d3327..52428909c3b 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -13,6 +13,7 @@ set global server_audit_incl_users=null; set global server_audit_file_path='server_audit.log'; set global server_audit_output_type=file; set global server_audit_logging=on; +--sleep 2 connect (con1,localhost,root,,mysql); connection default; disconnect con1; @@ -35,6 +36,9 @@ insert into t2 values (1), (2); select * from t2; alter table t1 rename renamed_t1; set global server_audit_events='connect,query'; +select 1, + 2, + 3; insert into t2 values (1), (2); select * from t2; --error ER_NO_SUCH_TABLE @@ -103,6 +107,8 @@ select * from t1; CREATE USER u1 IDENTIFIED BY 'pwd-123'; GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +--error 1064 +SET PASSWORD FOR u1=<secret>; CREATE USER u3 IDENTIFIED BY ''; drop user u1, u2, u3; select 2; diff --git a/mysql-test/suite/plugins/t/thread_pool_server_audit.opt b/mysql-test/suite/plugins/t/thread_pool_server_audit.opt new file mode 100644 index 00000000000..30953d0c574 --- /dev/null +++ b/mysql-test/suite/plugins/t/thread_pool_server_audit.opt @@ -0,0 +1,2 @@ +--thread_handling=pool-of-threads + diff --git a/mysql-test/suite/plugins/t/thread_pool_server_audit.test b/mysql-test/suite/plugins/t/thread_pool_server_audit.test new file mode 100644 index 00000000000..626d4136c47 --- /dev/null +++ b/mysql-test/suite/plugins/t/thread_pool_server_audit.test @@ -0,0 +1,144 @@ +--source include/not_embedded.inc +--source include/have_pool_of_threads.inc + +if (!$SERVER_AUDIT_SO) { + skip No SERVER_AUDIT plugin; +} + +install plugin server_audit soname 'server_audit'; + +show variables like 'server_audit%'; +set global server_audit_file_path=null; +set global server_audit_incl_users=null; +set global server_audit_file_path='server_audit.log'; +set global server_audit_output_type=file; +set global server_audit_logging=on; +--sleep 2 +connect (con1,localhost,root,,mysql); +connection default; +disconnect con1; +--sleep 2 +--sleep 2 +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect (con1,localhost,no_such_user,,mysql); +connection default; +--sleep 2 +set global server_audit_incl_users='odin, dva, tri'; +create table t1 (id int); +set global server_audit_incl_users='odin, root, dva, tri'; +create table t2 (id int); +set global server_audit_excl_users='odin, dva, tri'; +insert into t1 values (1), (2); +select * from t1; +set global server_audit_incl_users='odin, root, dva, tri'; +insert into t2 values (1), (2); +select * from t2; +alter table t1 rename renamed_t1; +set global server_audit_events='connect,query'; +select 1, + 2, + 3; +insert into t2 values (1), (2); +select * from t2; +--error ER_NO_SUCH_TABLE +select * from t_doesnt_exist; +--error 1064 +syntax_error_query; +drop table renamed_t1, t2; +show variables like 'server_audit%'; +set global server_audit_mode=1; +set global server_audit_events=''; +create database sa_db; +--sleep 2 +connect (con1,localhost,root,,test); +connection con1; +--sleep 2 +--sleep 2 +create table t1 (id2 int); +insert into t1 values (1), (2); +select * from t1; +drop table t1; +use sa_db; +create table sa_t1(id int); +insert into sa_t1 values (1), (2); +drop table sa_t1; +drop database sa_db; +connection default; +disconnect con1; +--sleep 2 +--sleep 2 +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; + +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_dcl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +--error 1064 +SET PASSWORD FOR u1=<secret>; +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events=''; + +set global server_audit_query_log_limit= 15; +select (1), (2), (3), (4); +select 'A', 'B', 'C', 'D'; +set global server_audit_query_log_limit= 1024; +drop database sa_db; + +set global server_audit_file_path='.'; +--replace_regex /\.[\\\/]/HOME_DIR\// +show status like 'server_audit_current_log'; +set global server_audit_file_path=''; +show status like 'server_audit_current_log'; +set global server_audit_file_path=' '; +show status like 'server_audit_current_log'; +set global server_audit_file_path='nonexisting_dir/'; +show status like 'server_audit_current_log'; +show variables like 'server_audit%'; +uninstall plugin server_audit; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +# replace the timestamp and the hostname with constant values +--replace_regex /[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\,[^,]*\,/TIME,HOSTNAME,/ /\,[1-9][0-9]*\,/,1,/ /\,[1-9][0-9]*/,ID/ +cat_file $MYSQLD_DATADIR/server_audit.log; +remove_file $MYSQLD_DATADIR/server_audit.log; + diff --git a/mysql-test/suite/rpl/r/rpl_old_decimal.result b/mysql-test/suite/rpl/r/rpl_old_decimal.result new file mode 100644 index 00000000000..3e2fa3bf241 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_old_decimal.result @@ -0,0 +1,9 @@ +include/master-slave.inc +[connection master] +CREATE TABLE t1dec102 (a DECIMAL(10,2)); +INSERT INTO t1dec102 VALUES(999.99); +call mtr.add_suppression("Slave SQL.*Column 0 of table .* cannot be converted from type.* Error_code: 1677"); +include/wait_for_slave_sql_error_and_skip.inc [errno=1677] +Last_SQL_Error = 'Column 0 of table 'test.t1dec102' cannot be converted from type 'decimal(0,?)/*old*/' to type 'decimal(10,2)'' +DROP TABLE t1dec102; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result b/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result index 550b3f596e5..0264c9421fc 100644 --- a/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result +++ b/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result @@ -182,6 +182,11 @@ DROP USER test_3@localhost; ERROR HY000: Table 'user' was not locked with LOCK TABLES INSERT INTO t2 VALUES ("DROP USER test_3@localhost with table locked"); UNLOCK TABLE; +CREATE DATABASE db; +CREATE TABLE db.t1 LIKE t2; +CREATE TABLE t3 LIKE t2; +DROP TABLE t3; +DROP DATABASE db; DROP USER test_3@localhost; DROP FUNCTION f2; DROP PROCEDURE p2; diff --git a/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result b/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result index e71bb2e29c9..c2a0498509b 100644 --- a/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result +++ b/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result @@ -1,2 +1,4 @@ include/master-slave.inc [connection master] +start slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_old_decimal.test b/mysql-test/suite/rpl/t/rpl_old_decimal.test new file mode 100644 index 00000000000..79fd2754079 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_old_decimal.test @@ -0,0 +1,25 @@ +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + + +--connection slave +CREATE TABLE t1dec102 (a DECIMAL(10,2)); + +--connection master +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1dec102.frm +--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1dec102.MYD +--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1dec102.MYI +INSERT INTO t1dec102 VALUES(999.99); + +--let $slave_sql_errno=1677 +--let $show_slave_sql_error= 1 +call mtr.add_suppression("Slave SQL.*Column 0 of table .* cannot be converted from type.* Error_code: 1677"); +--source include/wait_for_slave_sql_error_and_skip.inc + +--connection master +DROP TABLE t1dec102; +--sync_slave_with_master + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test b/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test index e9cc098857e..bc4119f332f 100644 --- a/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test +++ b/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test @@ -150,6 +150,16 @@ DROP USER test_3@localhost; INSERT INTO t2 VALUES ("DROP USER test_3@localhost with table locked"); UNLOCK TABLE; + +# Bug #20439913 CREATE TABLE DB.TABLE LIKE TMPTABLE IS +# BINLOGGED INCORRECTLY - BREAKS A SLAVE +CREATE DATABASE db; +CREATE TABLE db.t1 LIKE t2; +CREATE TABLE t3 LIKE t2; +DROP TABLE t3; +DROP DATABASE db; +# end of Bug #20439913 test + DROP USER test_3@localhost; DROP FUNCTION f2; DROP PROCEDURE p2; diff --git a/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test b/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test index a79a1885a6c..38759c9b16a 100644 --- a/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test +++ b/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test @@ -10,3 +10,10 @@ --exec $MYSQL_SLAP --silent --socket=$SLAVE_MYSOCK -q "START SLAVE; STOP SLAVE; SHOW GLOBAL STATUS" -c 2 --number-of-queries=100 --create-schema=test # All done. + +--connection slave +start slave; + +--connection master +--source include/rpl_end.inc + diff --git a/mysql-test/suite/stress/t/ddl_archive.test b/mysql-test/suite/stress/t/ddl_archive.test index 0c47b5fcdd5..c688ae192d0 100644 --- a/mysql-test/suite/stress/t/ddl_archive.test +++ b/mysql-test/suite/stress/t/ddl_archive.test @@ -12,11 +12,8 @@ --source include/have_archive.inc let $engine_type= ARCHIVE; +--source include/no_protocol.inc -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} let $run= `SELECT '$BIG_TEST' = '1'`; if ($run) { diff --git a/mysql-test/suite/stress/t/ddl_csv.test b/mysql-test/suite/stress/t/ddl_csv.test index 9f6185c76be..3e0f8acb1d8 100644 --- a/mysql-test/suite/stress/t/ddl_csv.test +++ b/mysql-test/suite/stress/t/ddl_csv.test @@ -12,11 +12,8 @@ --source include/have_csv.inc let $engine_type= CSV; +--source include/no_protocol.inc -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} let $run= `SELECT '$BIG_TEST' = '1'`; if ($run) { diff --git a/mysql-test/suite/stress/t/ddl_innodb.test b/mysql-test/suite/stress/t/ddl_innodb.test index 784ba8ff003..083ec43e7d7 100644 --- a/mysql-test/suite/stress/t/ddl_innodb.test +++ b/mysql-test/suite/stress/t/ddl_innodb.test @@ -12,11 +12,8 @@ --source include/have_innodb.inc let $engine_type= InnoDB; +--source include/no_protocol.inc -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} let $run= `SELECT '$BIG_TEST' = '1'`; if ($run) { diff --git a/mysql-test/suite/stress/t/ddl_memory.test b/mysql-test/suite/stress/t/ddl_memory.test index 5178439bff1..bcca77a74d9 100644 --- a/mysql-test/suite/stress/t/ddl_memory.test +++ b/mysql-test/suite/stress/t/ddl_memory.test @@ -11,11 +11,8 @@ # Storage engine to be used in CREATE TABLE let $engine_type= MEMORY; +--source include/no_protocol.inc -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} let $run= `SELECT '$BIG_TEST' = '1'`; if ($run) { diff --git a/mysql-test/suite/stress/t/ddl_myisam.test b/mysql-test/suite/stress/t/ddl_myisam.test index 8d6226e573b..a9b14690c42 100644 --- a/mysql-test/suite/stress/t/ddl_myisam.test +++ b/mysql-test/suite/stress/t/ddl_myisam.test @@ -11,11 +11,8 @@ # Storage engine to be used in CREATE TABLE let $engine_type= MyISAM; +--source include/no_protocol.inc -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} let $run= `SELECT '$BIG_TEST' = '1'`; if ($run) { diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff index 6124273537e..28c12e27ebd 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff @@ -42,7 +42,7 @@ VARIABLE_NAME INNODB_BUFFER_POOL_SIZE SESSION_VALUE NULL GLOBAL_VALUE 8388608 -@@ -418,7 +446,7 @@ +@@ -432,7 +460,7 @@ DEFAULT_VALUE ON VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN @@ -51,7 +51,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -439,6 +467,104 @@ +@@ -453,6 +481,104 @@ ENUM_VALUE_LIST CRC32,STRICT_CRC32,INNODB,STRICT_INNODB,NONE,STRICT_NONE READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -156,7 +156,7 @@ VARIABLE_NAME INNODB_CMP_PER_INDEX_ENABLED SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -537,6 +663,20 @@ +@@ -551,6 +677,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -177,7 +177,7 @@ VARIABLE_NAME INNODB_DATA_FILE_PATH SESSION_VALUE NULL GLOBAL_VALUE ibdata1:12M:autoextend -@@ -733,6 +873,20 @@ +@@ -747,6 +887,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL @@ -198,7 +198,7 @@ VARIABLE_NAME INNODB_ENCRYPTION_ROTATE_KEY_AGE SESSION_VALUE NULL GLOBAL_VALUE 1 -@@ -803,6 +957,20 @@ +@@ -817,6 +971,20 @@ ENUM_VALUE_LIST OFF,ON,FORCE READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -219,7 +219,7 @@ VARIABLE_NAME INNODB_FAST_SHUTDOWN SESSION_VALUE NULL GLOBAL_VALUE 1 -@@ -930,11 +1098,11 @@ +@@ -944,11 +1112,11 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FLUSH_LOG_AT_TRX_COMMIT @@ -233,7 +233,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3. NUMERIC_MIN_VALUE 0 -@@ -1027,6 +1195,20 @@ +@@ -1041,6 +1209,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED @@ -254,7 +254,7 @@ VARIABLE_NAME INNODB_FT_AUX_TABLE SESSION_VALUE NULL GLOBAL_VALUE -@@ -1265,6 +1447,20 @@ +@@ -1279,6 +1461,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -275,7 +275,7 @@ VARIABLE_NAME INNODB_LARGE_PREFIX SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1293,6 +1489,20 @@ +@@ -1307,6 +1503,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -296,7 +296,7 @@ VARIABLE_NAME INNODB_LOCKS_UNSAFE_FOR_BINLOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1321,6 +1531,62 @@ +@@ -1335,6 +1545,62 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -359,7 +359,7 @@ VARIABLE_NAME INNODB_LOG_BUFFER_SIZE SESSION_VALUE NULL GLOBAL_VALUE 1048576 -@@ -1349,6 +1615,20 @@ +@@ -1363,6 +1629,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -380,7 +380,7 @@ VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1419,6 +1699,34 @@ +@@ -1433,6 +1713,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -415,7 +415,7 @@ VARIABLE_NAME INNODB_MAX_DIRTY_PAGES_PCT SESSION_VALUE NULL GLOBAL_VALUE 75.000000 -@@ -1685,6 +1993,62 @@ +@@ -1699,6 +2007,62 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -478,7 +478,7 @@ VARIABLE_NAME INNODB_PURGE_BATCH_SIZE SESSION_VALUE NULL GLOBAL_VALUE 300 -@@ -1853,6 +2217,48 @@ +@@ -1867,6 +2231,48 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -527,7 +527,7 @@ VARIABLE_NAME INNODB_SCRUB_LOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1881,6 +2287,34 @@ +@@ -1895,6 +2301,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -562,7 +562,7 @@ VARIABLE_NAME INNODB_SIMULATE_COMP_FAILURES SESSION_VALUE NULL GLOBAL_VALUE 0 -@@ -1944,7 +2378,7 @@ +@@ -1958,7 +2392,7 @@ DEFAULT_VALUE nulls_equal VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM @@ -571,7 +571,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2175,6 +2609,34 @@ +@@ -2189,6 +2623,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -606,7 +606,7 @@ VARIABLE_NAME INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2252,7 +2714,7 @@ +@@ -2266,7 +2728,7 @@ DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN @@ -615,7 +615,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2273,6 +2735,20 @@ +@@ -2287,6 +2749,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -636,7 +636,7 @@ VARIABLE_NAME INNODB_USE_MTFLUSH SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2287,6 +2763,20 @@ +@@ -2301,6 +2777,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -657,12 +657,12 @@ VARIABLE_NAME INNODB_USE_SYS_MALLOC SESSION_VALUE NULL GLOBAL_VALUE ON -@@ -2317,12 +2807,12 @@ +@@ -2331,12 +2821,12 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.24 -+GLOBAL_VALUE 5.6.23-72.1 +-GLOBAL_VALUE 5.6.25 ++GLOBAL_VALUE 5.6.24-72.2 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 1c59391f3fd..18f682bb16e 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -2331,7 +2331,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.24 +GLOBAL_VALUE 5.6.25 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test index f988292b21e..11634e1e0c7 100644 --- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_evict_basic.test @@ -2,11 +2,6 @@ # This is a debug variable for now -- source include/have_debug.inc -if (`select plugin_auth_version <= "5.6.10" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in InnoDB 5.6.10 or earlier -} - SELECT @@global.innodb_buffer_pool_evict; SET GLOBAL innodb_buffer_pool_evict = 'uncompressed'; diff --git a/mysql-test/suite/sys_vars/t/innodb_thread_sleep_delay_basic.test b/mysql-test/suite/sys_vars/t/innodb_thread_sleep_delay_basic.test index 782fb475140..85ae2358db5 100644 --- a/mysql-test/suite/sys_vars/t/innodb_thread_sleep_delay_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_thread_sleep_delay_basic.test @@ -1,8 +1,3 @@ -if (`select plugin_auth_version <= "5.5.37-MariaDB-34.0" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.37-MariaDB-34.0 or earlier -} - # # 2010-01-27 - Added # diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 8a4ad35765c..cdc188b7776 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1326,6 +1326,14 @@ SHOW CREATE TABLE t2; DROP TABLE t2; DROP TABLE t1; +CREATE TABLE t1 ( + `transaction_id` int(11) NOT NULL DEFAULT '0', + KEY `transaction_id` (`transaction_id`)); +ALTER TABLE t1 DROP KEY IF EXISTS transaction_id, ADD PRIMARY KEY IF NOT EXISTS (transaction_id); +SHOW CREATE TABLE t1; + +DROP TABLE t1; + --echo # Bug#11748057 (formerly known as 34972): ALTER TABLE statement doesn't --echo # identify correct column name. --echo # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 8b557626ae7..e89247dc0cc 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1636,6 +1636,22 @@ SET NAMES utf8 COLLATE utf8_general_ci; --source include/ctype_utf8_ilseq.inc --echo # +--echo # MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT +--echo # +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8); +CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('aaa'); +INSERT INTO t2 VALUES ('aaa'); +SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2); +INSERT INTO t1 VALUES ('aaa'); +INSERT INTO t2 VALUES ('aaa'); +# Running the below query crashed with two rows +--error ER_SUBQUERY_NO_1_ROW +SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2); +DROP TABLE t1, t2; + + +--echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test index 65a94dcb49e..86dcee8148a 100644 --- a/mysql-test/t/dyncol.test +++ b/mysql-test/t/dyncol.test @@ -657,6 +657,13 @@ SELECT select column_get(column_create(1, "18446744073709552001" as char), 1 as int); --echo # +--echo # MDEV-7505 - Too large scale in DECIMAL dynamic column getter crashes +--echo # mysqld +--echo # +--error ER_TOO_BIG_SCALE +SELECT COLUMN_GET(`x`, 'y' AS DECIMAL(5,34)); + +--echo # --echo # test of symbolic names --echo # --echo # creation test (names) diff --git a/mysql-test/t/empty_server_name-8224.test b/mysql-test/t/empty_server_name-8224.test new file mode 100644 index 00000000000..528bce5dac5 --- /dev/null +++ b/mysql-test/t/empty_server_name-8224.test @@ -0,0 +1,9 @@ +# +# MDEV-8224 Server crashes in get_server_from_table_to_cache on empty name +# +--source include/not_embedded.inc +create server '' foreign data wrapper w2 options (host '127.0.0.1'); +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--shutdown_server 10 +--source include/wait_until_disconnected.inc +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect diff --git a/mysql-test/t/func_regexp_pcre.test b/mysql-test/t/func_regexp_pcre.test index 6710f5cf096..c9b4c10007d 100644 --- a/mysql-test/t/func_regexp_pcre.test +++ b/mysql-test/t/func_regexp_pcre.test @@ -402,3 +402,27 @@ SET default_regex_flags=DEFAULT; --echo # MDEV-6965 non-captured group \2 in regexp_replace --echo # SELECT REGEXP_REPLACE('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that'); + +--echo # +--echo # MDEV-8102 REGEXP function fails to match hex values when expression is stored as a variable +--echo # + +--echo # Testing a warning +SET NAMES latin1; +SET @regCheck= '\\xE0\\x01'; +SELECT 0xE001 REGEXP @regCheck; + +--echo # Testing workaround N1: This makes the pattern to be a binary string: +SET NAMES latin1; +SET @regCheck= X'E001'; +SELECT 0xE001 REGEXP @regCheck; + +--echo # Testing workaround N2: This also makes the pattern to be a binary string, using a different syntax: +SET NAMES latin1; +SET @regCheck= _binary '\\xE0\\x01'; +SELECT 0xE001 REGEXP @regCheck; + +--echo # Testing workarond N3: This makes derivation of the subject string stronger (IMLICIT instead of COERCIBLE) +SET NAMES latin1; +SET @regCheck= '\\xE0\\x01'; +SELECT CAST(0xE001 AS BINARY) REGEXP @regCheck; diff --git a/mysql-test/t/func_regexp_pcre_debug.test b/mysql-test/t/func_regexp_pcre_debug.test new file mode 100644 index 00000000000..c2581fa4110 --- /dev/null +++ b/mysql-test/t/func_regexp_pcre_debug.test @@ -0,0 +1,6 @@ +--source include/have_debug.inc + +SET debug_dbug='+d,pcre_exec_error_123'; +SELECT 'a' RLIKE 'a'; +SET debug_dbug=''; +SELECT 'a' RLIKE 'a'; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 2b189765bbc..3fb87e91b17 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1649,3 +1649,44 @@ INSERT INTO t1 VALUES (17, NULL); INSERT INTO t1 VALUES (18, '2010-10-13'); SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id; DROP TABLE t1; + + +--echo # +--echo # Start of 10.0 tests +--echo # + +--echo # +--echo # MDEV-8205 timediff returns null when comparing decimal time to time string value +--echo # + +# 1h difference +SELECT + TIMEDIFF('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ) AS str_str, + TIMEDIFF('2014-01-01 00:00:00' , 20140101010000.000 ) AS str_dec, + TIMEDIFF(20140101000000.000 , 20140101010000.000 ) AS dec_dec, + TIMEDIFF(20140101000000.000 , '2014-01-01 01:00:00' ) AS dec_str; + +# 1D1h difference +SELECT + TIMEDIFF('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ) AS str_str, + TIMEDIFF('2014-01-01 00:00:00' , 20140102010000.000 ) AS str_dec, + TIMEDIFF(20140101000000.000 , 20140102010000.000 ) AS dec_dec, + TIMEDIFF(20140101000000.000 , '2014-01-02 01:00:00' ) AS dec_str; + +# 1M1D1h difference +SELECT + TIMEDIFF('2014-01-01 00:00:00' , '2014-02-02 01:00:00' ) AS str_str, + TIMEDIFF('2014-01-01 00:00:00' , 20140202010000.000 ) AS str_dec, + TIMEDIFF(20140101000000.000 , 20140202010000.000 ) AS dec_dec, + TIMEDIFF(20140101000000.000 , '2014-02-02 01:00:00' ) AS dec_str; + +# 2M1D1h difference +SELECT + TIMEDIFF('2014-01-01 00:00:00' , '2014-03-02 01:00:00' ) AS str_str, + TIMEDIFF('2014-01-01 00:00:00' , 20140302010000.000 ) AS str_dec, + TIMEDIFF(20140101000000.000 , 20140302010000.000 ) AS dec_dec, + TIMEDIFF(20140101000000.000 , '2014-03-02 01:00:00' ) AS dec_str; + +--echo # +--echo # End of 10.0 tests +--echo # diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index dfb7f28ab28..4b992faa306 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1522,7 +1522,7 @@ DROP TABLE t1; create table t1 (a int, b int); insert into t1 values (1,11), (1,12), (2,22),(2,23), (4,44),(4,45); create table t2 (c int, d int); -insert into t2 values (1,11), (1,12), (2,22),(2,23), (4,44),(4,45); +insert into t2 values (1,11), (2,22), (4,44); select distinct a,sum(b), (select d from t2 where c=a order by max(b) limit 1) from t1 group by a order by max(b); drop table t1, t2; diff --git a/mysql-test/t/information_schema2.test b/mysql-test/t/information_schema2.test index c2479087f47..d577cdc1e4d 100644 --- a/mysql-test/t/information_schema2.test +++ b/mysql-test/t/information_schema2.test @@ -7,3 +7,16 @@ select variable_name from information_schema.session_status where variable_name select variable_name from information_schema.session_variables where variable_name = (select variable_name from information_schema.session_variables where variable_name = 'basedir'); +# +# information_schema tables inside subqueries, they should not be re-populated +# (i_s.columns needs to scan i_s itself, creating a tmp table for every i_s +# table. if it's re-populated, it'll do that multiple times) +# +create table t1 (a char); +insert t1 values ('a'),('t'),('z'); +flush status; +select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1; +# fix the result in ps-protocol +--replace_result 44 43 +show status like 'created_tmp_tables'; +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 6c9371eed25..9ac49a9063d 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1751,6 +1751,16 @@ CHECK TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +--echo # disabled keys +--echo # +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +DROP TABLE t1; + # # Check some variables # diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test index 1ba4e91be3c..8ca82b87e30 100644 --- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test @@ -37,3 +37,14 @@ # --exec rm -rf $MYSQLTEST_VARDIR/zoneinfo + +--echo # +--echo # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL +--echo # +--exec mkdir $MYSQLTEST_VARDIR/zoneinfo +--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/Factory + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff --git a/mysql-test/t/mysql_upgrade_view.test b/mysql-test/t/mysql_upgrade_view.test index e222afa89fe..49a90264f11 100644 --- a/mysql-test/t/mysql_upgrade_view.test +++ b/mysql-test/t/mysql_upgrade_view.test @@ -8,6 +8,35 @@ drop view if exists t1,v1,v2,v3,v4,v1badcheck; create table t1(a int); create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50)); +create view v1 as select 1; + +repair table t1 quick; +repair table t1 extended; +repair table t1 use_frm; +--error ER_PARSE_ERROR +repair table t1 from mysql; + +--error ER_PARSE_ERROR +repair view v1 quick; +--error ER_PARSE_ERROR +repair view v1 extended; +--error ER_PARSE_ERROR +repair view v1 use_frm; +repair view v1 from mysql; + +--error ER_PARSE_ERROR +check view v1 quick; +--error ER_PARSE_ERROR +check view v1 fast; +--error ER_PARSE_ERROR +check view v1 medium; +--error ER_PARSE_ERROR +check view v1 extended; +--error ER_PARSE_ERROR +check view v1 changed; +check view v1 for upgrade; + +drop view v1; let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index e2733089f18..6cd0265f89a 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -8,6 +8,7 @@ call mtr.add_suppression("Invalid .old.. table or database name"); # check that CSV engine was compiled in, as the result of the test # depends on the presence of the log tables (which are CSV-based). --source include/have_csv.inc +let $MYSQLD_DATADIR= `select @@datadir`; # # Clean up after previous tests @@ -66,7 +67,6 @@ create table t_bug25347 (a int) engine=myisam; create view v_bug25347 as select * from t_bug25347; insert into t_bug25347 values (1),(2),(3); flush tables; -let $MYSQLD_DATADIR= `select @@datadir`; --echo removing and creating --remove_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI --write_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI @@ -119,7 +119,6 @@ DROP TABLE t1, t2; create table t1(a int) engine=myisam; create view v1 as select * from t1; show tables; -let $MYSQLD_DATADIR= `select @@datadir`; --copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm show tables; --exec $MYSQL_CHECK --check-upgrade --databases test @@ -164,24 +163,23 @@ CREATE TABLE `#mysql50#c@d` (a INT) engine=myisam; CREATE TABLE t1 (a INT) engine=myisam; # Create 5.0 like triggers -let $MYSQLTEST_VARDIR= `select @@datadir`; ---write_file $MYSQLTEST_VARDIR/a@b/c@d.TRG +--write_file $MYSQLD_DATADIR/a@b/c@d.TRG TYPE=TRIGGERS triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a' sql_modes=0 definers='root@localhost' EOF ---write_file $MYSQLTEST_VARDIR/a@b/tr1.TRN +--write_file $MYSQLD_DATADIR/a@b/tr1.TRN TYPE=TRIGGERNAME trigger_table=c@d EOF ---write_file $MYSQLTEST_VARDIR/a@b/t1.TRG +--write_file $MYSQLD_DATADIR/a@b/t1.TRG TYPE=TRIGGERS triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a' sql_modes=0 definers='root@localhost' EOF ---write_file $MYSQLTEST_VARDIR/a@b/tr2.TRN +--write_file $MYSQLD_DATADIR/a@b/tr2.TRN TYPE=TRIGGERNAME trigger_table=t1 EOF @@ -255,7 +253,6 @@ INSERT INTO bug47205 VALUES ("foobar"); FLUSH TABLE bug47205; --echo # Replace the FRM with a 5.0 FRM that will require upgrade -let $MYSQLD_DATADIR= `select @@datadir`; --remove_file $MYSQLD_DATADIR/test/bug47205.frm --copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm @@ -279,7 +276,6 @@ CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY) FLUSH TABLE bug47205; --echo # Replace the FRM with a 5.0 FRM that will require upgrade -let $MYSQLD_DATADIR= `select @@datadir`; --remove_file $MYSQLD_DATADIR/test/bug47205.frm --copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm @@ -322,3 +318,34 @@ CREATE TABLE test.`t.1` (id int); --exec $MYSQL_CHECK test t.1 drop table test.`t.1`; + +# +# MDEV-8123 mysqlcheck: new --process-views option conflicts with --quick, --extended and such +# +create view v1 as select 1; +--echo mysqlcheck --process-views test +--exec $MYSQL_CHECK --process-views test +--echo mysqlcheck --process-views --extended test +--exec $MYSQL_CHECK --process-views --extended test +--echo mysqlcheck --process-views --fast test +--exec $MYSQL_CHECK --process-views --fast test +--echo mysqlcheck --process-views --quick test +--exec $MYSQL_CHECK --process-views --quick test +--echo mysqlcheck --process-views --check-only-changed test +--exec $MYSQL_CHECK --process-views --check-only-changed test +--echo mysqlcheck --process-views --medium-check test +--exec $MYSQL_CHECK --process-views --medium-check test +--echo mysqlcheck --process-views --check-upgrade test +--exec $MYSQL_CHECK --process-views --check-upgrade test +drop view v1; + + +# +# MDEV-8124 mysqlcheck: --auto-repair runs REPAIR TABLE instead of REPAIR VIEW on views +# +create table t1(a int); +--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v1.frm $MYSQLD_DATADIR/test/v1.frm +--echo mysqlcheck --process-views --check-upgrade --auto-repair test +--exec $MYSQL_CHECK --process-views --check-upgrade --auto-repair test +drop view v1; +drop table t1; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index a74e95ab65b..2d90764da0d 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -1,3 +1,7 @@ +if (`select plugin_auth_version < "5.6.25" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in InnoDB as of 5.6.24 or earlier +} --source include/not_embedded.inc --source include/have_partition.inc --source include/have_innodb.inc @@ -403,7 +407,7 @@ DROP TABLE t1; create table t1 (a int) engine=innodb partition by hash(a) ; # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status like 't1'; drop table t1; @@ -415,12 +419,12 @@ engine = innodb partition by key (a); # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status; insert into t1 values (0), (1), (2), (3); # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status; drop table t1; @@ -429,17 +433,17 @@ engine = innodb partition by key (a); # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); # Data_free for InnoDB tablespace varies depending on which # tests have been run before this one ---replace_column 10 # +--replace_column 10 # 12 # show table status; drop table t1; @@ -675,6 +679,18 @@ ALTER TABLE t1 ADD UNIQUE KEY (b); SHOW CREATE TABLE t1; SELECT * FROM t1; DROP TABLE t1; +--echo # +--echo # Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE +--echo # WRONG FOR PARTITIONED TABLES +--echo # + +CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB +PARTITION BY HASH (a) PARTITIONS 2; + +SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE +CREATE_TIME IS NOT NULL AND TABLE_NAME='t1'; + +DROP TABLE t1; --echo # --echo # BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == diff --git a/mysql-test/t/partition_myisam.test b/mysql-test/t/partition_myisam.test index a33b9e19fbf..bce0c6f009c 100644 --- a/mysql-test/t/partition_myisam.test +++ b/mysql-test/t/partition_myisam.test @@ -123,7 +123,7 @@ CHECK TABLE t1; SELECT * FROM t1; --echo # Note that it is currently impossible to drop a partitioned table --echo # without the .par file ---error ER_BAD_TABLE_ERROR +--error ER_GET_ERRNO DROP TABLE t1; --remove_file $MYSQLD_DATADIR/test/t1.frm --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI diff --git a/mysql-test/t/partition_not_blackhole.test b/mysql-test/t/partition_not_blackhole.test index 103c441dac4..64d4f3877c8 100644 --- a/mysql-test/t/partition_not_blackhole.test +++ b/mysql-test/t/partition_not_blackhole.test @@ -19,7 +19,7 @@ SHOW TABLES; --replace_result $MYSQLD_DATADIR ./ --error ER_FAILED_READ_FROM_PAR_FILE SHOW CREATE TABLE t1; ---error ER_BAD_TABLE_ERROR +--error ER_GET_ERRNO DROP TABLE t1; --list_files $MYSQLD_DATADIR/test t1* --remove_file $MYSQLD_DATADIR/test/t1.frm diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 0655aff9fc9..13e2c71fbc4 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -252,3 +252,16 @@ select plugin_name from information_schema.plugins where plugin_library like 'ha uninstall soname 'ha_example'; select plugin_name from information_schema.plugins where plugin_library like 'ha_example%'; + +--echo # +--echo # MDEV-5309 - RENAME TABLE does not check for existence of the table's +--echo # engine +--echo # +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TABLE t1(a INT) ENGINE=EXAMPLE; +SELECT * FROM t1; +FLUSH TABLES; +UNINSTALL PLUGIN example; +--error ER_NO_SUCH_TABLE +RENAME TABLE t1 TO t2; +DROP TABLE t1; diff --git a/mysql-test/t/query_cache_ps_no_prot.test b/mysql-test/t/query_cache_ps_no_prot.test index 16533c7194e..4b2bb842e34 100644 --- a/mysql-test/t/query_cache_ps_no_prot.test +++ b/mysql-test/t/query_cache_ps_no_prot.test @@ -16,12 +16,7 @@ let collation=utf8_unicode_ci; --source include/have_collation.inc # The file with expected results fits only to a run without -# ps-protocol/sp-protocol/cursor-protocol/view-protocol. -if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL - + $VIEW_PROTOCOL > 0`) -{ - --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled -} +--source include/no_protocol.inc # The main testing script --source include/query_cache_sql_prepare.inc diff --git a/mysql-test/t/range_innodb.test b/mysql-test/t/range_innodb.test new file mode 100644 index 00000000000..f76794814ef --- /dev/null +++ b/mysql-test/t/range_innodb.test @@ -0,0 +1,47 @@ +--echo # +--echo # Range optimizer (and related) tests that need InnoDB. +--echo # + +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t0, t1, t2; +--enable_warnings + +--echo # +--echo # MDEV-6735: Range checked for each record used with key +--echo # + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 + D.a * 1000 +from t0 A, t0 B, t0 C, t0 D; + +create table t2 ( + a int, + b int, + filler1 char(100), + filler2 char(100), + filler3 char(100), + filler4 char(100), + key(a), + key(b) +) engine=innodb; + +insert into t2 +select + a,a, + repeat('0123456789', 10), + repeat('0123456789', 10), + repeat('0123456789', 10), + repeat('0123456789', 10) +from t1; + +analyze table t2; +--echo # The following must not use "Range checked for each record": +explain select * from t0 left join t2 on t2.a <t0.a and t2.b between 50 and 250; + +drop table t0,t1,t2; + diff --git a/mysql-test/t/ssl_7937.combinations b/mysql-test/t/ssl_7937.combinations new file mode 100644 index 00000000000..46a45686a9b --- /dev/null +++ b/mysql-test/t/ssl_7937.combinations @@ -0,0 +1,5 @@ +[ssl] +--loose-enable-ssl + +[nossl] +--loose-disable-ssl diff --git a/mysql-test/t/ssl_7937.test b/mysql-test/t/ssl_7937.test new file mode 100644 index 00000000000..d593b9d936d --- /dev/null +++ b/mysql-test/t/ssl_7937.test @@ -0,0 +1,35 @@ +# +# MDEV-7937: Enforce SSL when --ssl client option is used +# + +source include/have_ssl_crypto_functs.inc; + +# create a procedure instead of SHOW STATUS LIKE 'ssl_cipher' +# because the cipher depends on openssl (or yassl) version, +# and it's actual value doesn't matter here anyway +create procedure have_ssl() + select if(variable_value > '','yes','no') as 'have_ssl' + from information_schema.session_status + where variable_name='ssl_cipher'; + +--disable_abort_on_error +--echo mysql --ssl-ca=cacert.pem -e "call test.have_ssl()" +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem -e "call test.have_ssl()" 2>&1 +--echo mysql --ssl -e "call test.have_ssl()" +--exec $MYSQL --ssl -e "call test.have_ssl()" 2>&1 +--echo mysql --ssl-ca=cacert.pem --ssl-verify-server-cert -e "call test.have_ssl()" +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-verify-server-cert -e "call test.have_ssl()" 2>&1 + +--echo mysql --ssl --ssl-verify-server-cert -e "call test.have_ssl()" +# this is the test where certificate verification fails. +# but yassl doesn't support certificate verification, so +# we fake the test result for yassl +let yassl=`select variable_value='Unknown' from information_schema.session_status where variable_name='Ssl_session_cache_mode'`; +if (!$yassl) { + --exec $MYSQL --ssl --ssl-verify-server-cert -e "call test.have_ssl()" 2>&1 +} +if ($yassl) { + --echo ERROR 2026 (HY000): SSL connection error: Failed to verify the server certificate +} + +drop procedure have_ssl; diff --git a/mysql-test/t/truncate-stale-6500.test b/mysql-test/t/truncate-stale-6500.test new file mode 100644 index 00000000000..47dffb1966d --- /dev/null +++ b/mysql-test/t/truncate-stale-6500.test @@ -0,0 +1,32 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +SET GLOBAL query_cache_size=1024*1024*8; +CREATE TABLE `test` ( + `uniqueId` INT NOT NULL, + `partitionId` INT NOT NULL, + PRIMARY KEY (`uniqueId`,`partitionId`) +) ENGINE=InnoDB PARTITION BY LIST (partitionId) ( + PARTITION p01 VALUES IN (1), + PARTITION p02 VALUES IN (2) +); + + +INSERT INTO `test`(`uniqueId`,`partitionId`) VALUES(407237055, 2); + +SELECT * FROM `test`; + +--echo #Confirms 1 row in partition 'p02' +SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test'; +ALTER TABLE `test` TRUNCATE PARTITION `p02`; + +--echo #Confirms no more rows in partition 'p02' +SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test'; + +--echo #Before the patch, this returned the previously existing values. +SELECT * FROM `test`; +SELECT SQL_CACHE * FROM `test`; +SELECT SQL_NO_CACHE * FROM `test`; + +DROP TABLE test; +SET GLOBAL query_cache_size=DEFAULT; diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 1d4ef345747..659e75270ca 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -583,3 +583,27 @@ JOIN WHERE CONCAT(t1.col1, CAST(subq.col0 AS DECIMAL)); DROP TABLE t1, t2; + + +--echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # MDEV-8267 Add /*old*/ comment into I_S.COLUMN_TYPE for old DECIMAL +--echo # + +let $MYSQLD_DATADIR= `select @@datadir`; + +--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1dec102.frm +--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1dec102.MYD +--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1dec102.MYI + +SHOW CREATE TABLE t1dec102; +SHOW COLUMNS FROM t1dec102; +SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1dec102'; +DROP TABLE t1dec102; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/update_innodb.test b/mysql-test/t/update_innodb.test new file mode 100644 index 00000000000..67c356c4e2e --- /dev/null +++ b/mysql-test/t/update_innodb.test @@ -0,0 +1,39 @@ +--source include/have_innodb.inc + +CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` datetime DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `t2` ( + `c0` varchar(10) NOT NULL, + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + PRIMARY KEY (`c0`,`c1`), + KEY `c1` (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `t3` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `c1` datetime NOT NULL, + `c2` bigint(20) NOT NULL, + `c3` int(4) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `c2` (`c2`), + KEY `c3` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `t4` ( + `c1` int(11) NOT NULL, + `c2` bigint(20) DEFAULT NULL, + `c3` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + CREATE ALGORITHM=UNDEFINED VIEW `v1` AS select `t4`.`c1` AS `c1`,`t4`.`c2` AS `c2`,`t4`.`c3` AS `c3` from `t4`; + +UPDATE t1 a JOIN t2 b ON a.c1 = b.c1 JOIN v1 vw ON b.c2 = vw.c1 JOIN t3 del ON vw.c2 = del.c2 SET a.c2 = ( SELECT max(t.c1) FROM t3 t, v1 i WHERE del.c2 = t.c2 AND vw.c3 = i.c3 AND t.c3 = 4 ) WHERE a.c2 IS NULL OR a.c2 < '2011-05-01'; + +drop view v1; +drop table t1,t2,t3,t4; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 84d7da548b2..e95194e3f2c 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5367,6 +5367,19 @@ update t3 left join v2 using (id) set flag=flag+1; drop view v2, v1; drop table t1, t2, t3; +--echo # +--echo # MDEV-7207 - ALTER VIEW does not change ALGORITM +--echo # +create table t1 (a int, b int); +create algorithm=temptable view v2 (c) as select b+1 from t1; +show create view v2; +alter algorithm=undefined view v2 (c) as select b+1 from t1; +show create view v2; +alter algorithm=merge view v2 (c) as select b+1 from t1; +show create view v2; +drop view v2; +drop table t1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/packaging/WiX/CPackWixConfig.cmake b/packaging/WiX/CPackWixConfig.cmake index c782b7cd17a..9caae8375d8 100644 --- a/packaging/WiX/CPackWixConfig.cmake +++ b/packaging/WiX/CPackWixConfig.cmake @@ -1,119 +1,119 @@ -# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-IF(ESSENTIALS)
- SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles")
- SET(CPACK_WIX_UI "WixUI_InstallDir")
- IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
- SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-winx64")
- ELSE()
- SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-win32")
- ENDIF()
-ELSE()
- SET(CPACK_COMPONENTS_USED
- "Server;Client;DataFiles;Development;SharedLibraries;Documentation;IniFiles;Readme;Server_Scripts;DebugBinaries")
-ENDIF()
-
-
-# Some components like Embedded are optional
-# We will build MSI without embedded if it was not selected for build
-#(need to modify CPACK_COMPONENTS_ALL for that)
-SET(CPACK_ALL)
-FOREACH(comp1 ${CPACK_COMPONENTS_USED})
- SET(found)
- FOREACH(comp2 ${CPACK_COMPONENTS_ALL})
- IF(comp1 STREQUAL comp2)
- SET(found 1)
- BREAK()
- ENDIF()
- ENDFOREACH()
- IF(found)
- SET(CPACK_ALL ${CPACK_ALL} ${comp1})
- ENDIF()
-ENDFOREACH()
-SET(CPACK_COMPONENTS_ALL ${CPACK_ALL})
-
-# Always install (hidden), includes Readme files
-SET(CPACK_COMPONENT_GROUP_ALWAYSINSTALL_HIDDEN 1)
-SET(CPACK_COMPONENT_README_GROUP "AlwaysInstall")
-
-# Feature MySQL Server
-SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DISPLAY_NAME "MySQL Server")
-SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_EXPANDED "1")
-SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install MySQL Server")
- # Subfeature "Server" (hidden)
- SET(CPACK_COMPONENT_SERVER_GROUP "MySQLServer")
- SET(CPACK_COMPONENT_SERVER_HIDDEN 1)
- # Subfeature "Client"
- SET(CPACK_COMPONENT_CLIENT_GROUP "MySQLServer")
- SET(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client Programs")
- SET(CPACK_COMPONENT_CLIENT_DESCRIPTION
- "Various helpful (commandline) tools including the mysql command line client" )
- # Subfeature "Debug binaries"
- SET(CPACK_COMPONENT_DEBUGBINARIES_GROUP "MySQLServer")
- SET(CPACK_COMPONENT_DEBUGBINARIES_DISPLAY_NAME "Debug binaries")
- SET(CPACK_COMPONENT_DEBUGBINARIES_DESCRIPTION
- "Debug/trace versions of executables and libraries" )
- #SET(CPACK_COMPONENT_DEBUGBINARIES_WIX_LEVEL 2)
-
-
- #Subfeature "Data Files"
- SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer")
- SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files")
- SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" )
- SET(CPACK_COMPONENT_DATAFILES_HIDDEN 1)
-
-
-#Feature "Devel"
-SET(CPACK_COMPONENT_GROUP_DEVEL_DISPLAY_NAME "Development Components")
-SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Installs C/C++ header files and libraries")
- #Subfeature "Development"
- SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "Devel")
- SET(CPACK_COMPONENT_DEVELOPMENT_HIDDEN 1)
-
- #Subfeature "Shared libraries"
- SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "Devel")
- SET(CPACK_COMPONENT_SHAREDLIBRARIES_DISPLAY_NAME "Client C API library (shared)")
- SET(CPACK_COMPONENT_SHAREDLIBRARIES_DESCRIPTION "Installs shared client library")
-
- #Subfeature "Embedded"
- SET(CPACK_COMPONENT_EMBEDDED_GROUP "Devel")
- SET(CPACK_COMPONENT_EMBEDDED_DISPLAY_NAME "Embedded server library")
- SET(CPACK_COMPONENT_EMBEDDED_DESCRIPTION "Installs embedded server library")
- SET(CPACK_COMPONENT_EMBEDDED_WIX_LEVEL 2)
-
-#Feature Debug Symbols
-SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DISPLAY_NAME "Debug Symbols")
-SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DESCRIPTION "Installs Debug Symbols")
-SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_WIX_LEVEL 2)
- SET(CPACK_COMPONENT_DEBUGINFO_GROUP "DebugSymbols")
- SET(CPACK_COMPONENT_DEBUGINFO_HIDDEN 1)
-
-#Feature Documentation
-SET(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
-SET(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Installs documentation")
-SET(CPACK_COMPONENT_DOCUMENTATION_WIX_LEVEL 2)
-
-#Feature tests
-SET(CPACK_COMPONENT_TEST_DISPLAY_NAME "Tests")
-SET(CPACK_COMPONENT_TEST_DESCRIPTION "Installs unittests (requires Perl to run)")
-SET(CPACK_COMPONENT_TEST_WIX_LEVEL 2)
-
-
-#Feature Misc (hidden, installs only if everything is installed)
-SET(CPACK_COMPONENT_GROUP_MISC_HIDDEN 1)
-SET(CPACK_COMPONENT_GROUP_MISC_WIX_LEVEL 100)
- SET(CPACK_COMPONENT_INIFILES_GROUP "Misc")
- SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "Misc")
+# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +IF(ESSENTIALS) + SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles") + SET(CPACK_WIX_UI "WixUI_InstallDir") + IF(CMAKE_SIZEOF_VOID_P MATCHES 8) + SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-winx64") + ELSE() + SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-win32") + ENDIF() +ELSE() + SET(CPACK_COMPONENTS_USED + "Server;Client;DataFiles;Development;SharedLibraries;Documentation;IniFiles;Readme;Server_Scripts;DebugBinaries") +ENDIF() + + +# Some components like Embedded are optional +# We will build MSI without embedded if it was not selected for build +#(need to modify CPACK_COMPONENTS_ALL for that) +SET(CPACK_ALL) +FOREACH(comp1 ${CPACK_COMPONENTS_USED}) + SET(found) + FOREACH(comp2 ${CPACK_COMPONENTS_ALL}) + IF(comp1 STREQUAL comp2) + SET(found 1) + BREAK() + ENDIF() + ENDFOREACH() + IF(found) + SET(CPACK_ALL ${CPACK_ALL} ${comp1}) + ENDIF() +ENDFOREACH() +SET(CPACK_COMPONENTS_ALL ${CPACK_ALL}) + +# Always install (hidden), includes Readme files +SET(CPACK_COMPONENT_GROUP_ALWAYSINSTALL_HIDDEN 1) +SET(CPACK_COMPONENT_README_GROUP "AlwaysInstall") + +# Feature MySQL Server +SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DISPLAY_NAME "MySQL Server") +SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_EXPANDED "1") +SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install MySQL Server") + # Subfeature "Server" (hidden) + SET(CPACK_COMPONENT_SERVER_GROUP "MySQLServer") + SET(CPACK_COMPONENT_SERVER_HIDDEN 1) + # Subfeature "Client" + SET(CPACK_COMPONENT_CLIENT_GROUP "MySQLServer") + SET(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client Programs") + SET(CPACK_COMPONENT_CLIENT_DESCRIPTION + "Various helpful (commandline) tools including the mysql command line client" ) + # Subfeature "Debug binaries" + SET(CPACK_COMPONENT_DEBUGBINARIES_GROUP "MySQLServer") + SET(CPACK_COMPONENT_DEBUGBINARIES_DISPLAY_NAME "Debug binaries") + SET(CPACK_COMPONENT_DEBUGBINARIES_DESCRIPTION + "Debug/trace versions of executables and libraries" ) + #SET(CPACK_COMPONENT_DEBUGBINARIES_WIX_LEVEL 2) + + + #Subfeature "Data Files" + SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer") + SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files") + SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" ) + SET(CPACK_COMPONENT_DATAFILES_HIDDEN 1) + + +#Feature "Devel" +SET(CPACK_COMPONENT_GROUP_DEVEL_DISPLAY_NAME "Development Components") +SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Installs C/C++ header files and libraries") + #Subfeature "Development" + SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "Devel") + SET(CPACK_COMPONENT_DEVELOPMENT_HIDDEN 1) + + #Subfeature "Shared libraries" + SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "Devel") + SET(CPACK_COMPONENT_SHAREDLIBRARIES_DISPLAY_NAME "Client C API library (shared)") + SET(CPACK_COMPONENT_SHAREDLIBRARIES_DESCRIPTION "Installs shared client library") + + #Subfeature "Embedded" + SET(CPACK_COMPONENT_EMBEDDED_GROUP "Devel") + SET(CPACK_COMPONENT_EMBEDDED_DISPLAY_NAME "Embedded server library") + SET(CPACK_COMPONENT_EMBEDDED_DESCRIPTION "Installs embedded server library") + SET(CPACK_COMPONENT_EMBEDDED_WIX_LEVEL 2) + +#Feature Debug Symbols +SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DISPLAY_NAME "Debug Symbols") +SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DESCRIPTION "Installs Debug Symbols") +SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_WIX_LEVEL 2) + SET(CPACK_COMPONENT_DEBUGINFO_GROUP "DebugSymbols") + SET(CPACK_COMPONENT_DEBUGINFO_HIDDEN 1) + +#Feature Documentation +SET(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation") +SET(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Installs documentation") +SET(CPACK_COMPONENT_DOCUMENTATION_WIX_LEVEL 2) + +#Feature tests +SET(CPACK_COMPONENT_TEST_DISPLAY_NAME "Tests") +SET(CPACK_COMPONENT_TEST_DESCRIPTION "Installs unittests (requires Perl to run)") +SET(CPACK_COMPONENT_TEST_WIX_LEVEL 2) + + +#Feature Misc (hidden, installs only if everything is installed) +SET(CPACK_COMPONENT_GROUP_MISC_HIDDEN 1) +SET(CPACK_COMPONENT_GROUP_MISC_WIX_LEVEL 100) + SET(CPACK_COMPONENT_INIFILES_GROUP "Misc") + SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "Misc") diff --git a/packaging/WiX/create_msi.cmake.in b/packaging/WiX/create_msi.cmake.in index 8de271fc1cf..d0a8f0046cf 100644 --- a/packaging/WiX/create_msi.cmake.in +++ b/packaging/WiX/create_msi.cmake.in @@ -1,398 +1,398 @@ -# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
-SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
-SET(CANDLE_EXECUTABLE "@CANDLE_EXECUTABLE@")
-SET(LIGHT_EXECUTABLE "@LIGHT_EXECUTABLE@")
-SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
-SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
-SET(VERSION "@VERSION@")
-SET(MAJOR_VERSION "@MAJOR_VERSION@")
-SET(MINOR_VERSION "@MINOR_VERSION@")
-SET(PATCH_VERSION "@PATCH_VERSION@")
-SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)
-SET(MANUFACTURER "@MANUFACTURER@")
-SET(WIXCA_LOCATION "@WIXCA_LOCATION@")
-SET(COPYING_RTF "@COPYING_RTF@")
-SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@")
-SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@")
-
-LIST(APPEND EXCLUDE_DIRS
- bin/debug
- data/test
- lib/plugin/debug
- mysql-test
- scripts
- sql-bench
-)
-
-LIST(APPEND EXCLUDE_FILES
- bin/echo.exe
- bin/mysql_client_test_embedded.exe
- bin/mysqld-debug.exe
- bin/mysqltest_embedded.exe
- bin/replace.exe
- lib/debug/mysqlserver.lib
- lib/libmysqld.dll
- lib/libmysqld.lib
- lib/mysqlserver.lib
- lib/mysqlservices.lib
-)
-
-IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(Win64 " Win64='yes'")
- SET(Platform x64)
- SET(PlatformProgramFilesFolder ProgramFiles64Folder)
-ELSE()
- SET(Platform x86)
- SET(PlatformProgramFilesFolder ProgramFilesFolder)
- SET(Win64)
-ENDIF()
-
-SET(ENV{VS_UNICODE_OUTPUT})
-
-# Switch off the monolithic install
-EXECUTE_PROCESS(
- COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=0 ${CMAKE_BINARY_DIR}
- OUTPUT_QUIET
-)
-
-INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake)
-
-IF(CPACK_WIX_CONFIG)
- INCLUDE(${CPACK_WIX_CONFIG})
-ENDIF()
-
-IF(NOT CPACK_WIX_UI)
- SET(CPACK_WIX_UI "WixUI_Mondo_Custom")
-ENDIF()
-
-SET(WIX_FEATURES)
-FOREACH(comp ${CPACK_COMPONENTS_ALL})
- STRING(TOUPPER "${comp}" comp_upper)
- IF(NOT CPACK_COMPONENT_${comp_upper}_GROUP)
- SET(WIX_FEATURE_${comp_upper}_COMPONENTS "${comp}")
- SET(CPACK_COMPONENT_${comp_upper}_HIDDEN 1)
- SET(CPACK_COMPONENT_GROUP_${comp_upper}_DISPLAY_NAME ${CPACK_COMPONENT_${comp_upper}_DISPLAY_NAME})
- SET(CPACK_COMPONENT_GROUP_${comp_upper}_DESCRIPTION ${CPACK_COMPONENT_${comp_upper}_DESCRIPTION})
- SET(CPACK_COMPONENT_GROUP_${comp_upper}_WIX_LEVEL ${CPACK_COMPONENT_${comp_upper}_WIX_LEVEL})
- SET(WIX_FEATURES ${WIX_FEATURES} WIX_FEATURE_${comp_upper})
- ELSE()
- SET(FEATURE_NAME WIX_FEATURE_${CPACK_COMPONENT_${comp_upper}_GROUP})
- SET(WIX_FEATURES ${WIX_FEATURES} ${FEATURE_NAME})
- LIST(APPEND ${FEATURE_NAME}_COMPONENTS ${comp})
- ENDIF()
-ENDFOREACH()
-
-LIST(REMOVE_DUPLICATES WIX_FEATURES)
-
-SET(CPACK_WIX_FEATURES)
-
-FOREACH(f ${WIX_FEATURES})
- STRING(TOUPPER "${f}" f_upper)
- STRING(REPLACE "WIX_FEATURE_" "" f_upper ${f_upper})
- IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
- SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})
- ELSE()
- SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
- ENDIF()
-
- IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
- SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})
- ELSE()
- SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
- ENDIF()
- IF(CPACK_COMPONENT_${f_upper}_WIX_LEVEL)
- SET(Level ${CPACK_COMPONENT_${f_upper}_WIX_LEVEL})
- ELSE()
- SET(Level 1)
- ENDIF()
- IF(CPACK_COMPONENT_GROUP_${f_upper}_HIDDEN)
- SET(DISPLAY "Display='hidden'")
- SET(TITLE ${f_upper})
- SET(DESCRIPTION ${f_upper})
- ELSE()
- SET(DISPLAY)
- IF(CPACK_COMPONENT_GROUP_${f_upper}_EXPANDED)
- SET(DISPLAY "Display='expand'")
- ENDIF()
- IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
- SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})
- ELSE()
- SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
- ENDIF()
- IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
- SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})
- ELSE()
- SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
- ENDIF()
- ENDIF()
-
- SET(CPACK_WIX_FEATURES
- "${CPACK_WIX_FEATURES}
- <Feature Id='${f_upper}'
- Title='${TITLE}'
- Description='${DESCRIPTION}'
- ConfigurableDirectory='INSTALLDIR'
- Level='${Level}' ${DISPLAY} >"
- )
- FOREACH(c ${${f}_COMPONENTS})
- STRING(TOUPPER "${c}" c_upper)
- IF (CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)
- SET(TITLE ${CPACK_COMPONENT_${c_upper}_DISPLAY_NAME})
- ELSE()
- SET(TITLE CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)
- ENDIF()
-
- IF (CPACK_COMPONENT_${c_upper}_DESCRIPTION)
- SET(DESCRIPTION ${CPACK_COMPONENT_${c_upper}_DESCRIPTION})
- ELSE()
- SET(DESCRIPTION CPACK_COMPONENT_${c_upper}_DESCRIPTION)
- ENDIF()
- IF(CPACK_COMPONENT_${c_upper}_WIX_LEVEL)
- SET(Level ${CPACK_COMPONENT_${c_upper}_WIX_LEVEL})
- ELSE()
- SET(Level 1)
- ENDIF()
- IF(CPACK_COMPONENT_${c_upper}_HIDDEN)
- SET(CPACK_WIX_FEATURES
- "${CPACK_WIX_FEATURES}
- <ComponentGroupRef Id='componentgroup.${c}'/>")
- ELSE()
- SET(CPACK_WIX_FEATURES
- "${CPACK_WIX_FEATURES}
- <Feature Id='${c}'
- Title='${TITLE}'
- Description='${DESCRIPTION}'
- ConfigurableDirectory='INSTALLDIR'
- Level='${Level}'>
- <ComponentGroupRef Id='componentgroup.${c}'/>
- </Feature>")
- ENDIF()
-
- ENDFOREACH()
- SET(CPACK_WIX_FEATURES
- "${CPACK_WIX_FEATURES}
- </Feature>
- ")
-ENDFOREACH()
-
-
-IF(CMAKE_INSTALL_CONFIG_NAME)
- STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}"
- WIXCA_LOCATION "${WIXCA_LOCATION}")
- SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
-ENDIF()
-
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
- ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
-
-
-FOREACH(comp ${CPACK_COMPONENTS_ALL})
- SET(ENV{DESTDIR} testinstall/${comp})
- SET(DIRS ${DIRS} testinstall/${comp})
- EXECUTE_PROCESS(
- COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -DCMAKE_INSTALL_COMPONENT=${comp}
- -DCMAKE_INSTALL_PREFIX= -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
- OUTPUT_QUIET
- )
-ENDFOREACH()
-
-MACRO(GENERATE_GUID VarName)
- EXECUTE_PROCESS(COMMAND uuidgen -c
- OUTPUT_VARIABLE ${VarName}
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-ENDMACRO()
-
-SET(INC_VAR 0)
-MACRO(MAKE_WIX_IDENTIFIER str varname)
- STRING(REPLACE "/" "." ${varname} "${str}")
- STRING(REGEX REPLACE "[^a-zA-Z_0-9.]" "_" ${varname} "${${varname}}")
- STRING(LENGTH "${${varname}}" len)
- # Identifier should be smaller than 72 character
- # We have to cut down the length to 70 chars, since we add 2 char prefix
- # pretty often
- IF(len GREATER 70)
- STRING(SUBSTRING "${${varname}}" 0 67 shortstr)
- MATH(EXPR INC_VAR ${INC_VAR}+1)
- SET(${varname} "${shortstr}${INC_VAR}")
- ENDIF()
-ENDMACRO()
-
-
-FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
- FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
- IF(dir_rel)
- LIST(FIND EXCLUDE_DIRS ${dir_rel} TO_EXCLUDE)
- IF(NOT TO_EXCLUDE EQUAL -1)
- MESSAGE(STATUS "excluding directory: ${dir_rel}")
- RETURN()
- ENDIF()
- ENDIF()
- FILE(GLOB all_files ${dir}/*)
- IF(NOT all_files)
- RETURN()
- ENDIF()
- IF(dir_rel)
- MAKE_DIRECTORY(${dir_root}/${dir_rel})
- MAKE_WIX_IDENTIFIER("${dir_rel}" id)
- SET(DirectoryRefId "D.${id}")
- ELSE()
- SET(DirectoryRefId "INSTALLDIR")
- ENDIF()
- FILE(APPEND ${file} "<DirectoryRef Id='${DirectoryRefId}'>\n")
-
- SET(NONEXEFILES)
- FOREACH(f ${all_files})
- IF(NOT IS_DIRECTORY ${f})
- FILE(RELATIVE_PATH rel ${topdir} ${f})
- SET(TO_EXCLUDE)
- IF(rel MATCHES "\\.pdb$")
- SET(TO_EXCLUDE TRUE)
- ELSE()
- LIST(FIND EXCLUDE_FILES ${rel} RES)
- IF(NOT RES EQUAL -1)
- SET(TO_EXCLUDE TRUE)
- ENDIF()
- ENDIF()
- IF(TO_EXCLUDE)
- MESSAGE(STATUS "excluding file: ${rel}")
- ELSE()
- MAKE_WIX_IDENTIFIER("${rel}" id)
- FILE(TO_NATIVE_PATH ${f} f_native)
- GET_FILENAME_COMPONENT(f_ext "${f}" EXT)
- # According to MSDN each DLL or EXE should be in the own component
- IF(f_ext MATCHES ".exe" OR f_ext MATCHES ".dll")
-
- FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64}>\n")
- FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\n")
- FILE(APPEND ${file} " </Component>\n")
- FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n")
- ELSE()
- SET(NONEXEFILES "${NONEXEFILES}\n<File Id='F.${id}' Source='${f_native}'/>" )
- ENDIF()
- ENDIF()
- ENDIF()
- ENDFOREACH()
- FILE(APPEND ${file} "</DirectoryRef>\n")
- IF(NONEXEFILES)
- GENERATE_GUID(guid)
- SET(ComponentId "C._files_${COMP_NAME}.${DirectoryRefId}")
- FILE(APPEND ${file}
- "<DirectoryRef Id='${DirectoryRefId}'>\n<Component Guid='${guid}' Id='${ComponentId}' ${Win64}>${NONEXEFILES}\n</Component></DirectoryRef>\n")
- FILE(APPEND ${file_comp} " <ComponentRef Id='${ComponentId}'/>\n")
- ENDIF()
- FOREACH(f ${all_files})
- IF(IS_DIRECTORY ${f})
- TRAVERSE_FILES(${f} ${topdir} ${file} ${file_comp} ${dir_root})
- ENDIF()
- ENDFOREACH()
-ENDFUNCTION()
-
-FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
- FILE(RELATIVE_PATH rel ${topdir} ${dir})
- IF(rel)
- MAKE_WIX_IDENTIFIER("${rel}" id)
- GET_FILENAME_COMPONENT(name ${dir} NAME)
- FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
- ENDIF()
- FILE(GLOB all_files ${dir}/*)
- FOREACH(f ${all_files})
- IF(IS_DIRECTORY ${f})
- TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
- ENDIF()
- ENDFOREACH()
- IF(rel)
- FILE(APPEND ${file} "${prefix}</Directory>\n")
- ENDIF()
-ENDFUNCTION()
-
-SET(CPACK_WIX_COMPONENTS)
-SET(CPACK_WIX_COMPONENT_GROUPS)
-GET_FILENAME_COMPONENT(abs . ABSOLUTE)
-FOREACH(d ${DIRS})
- GET_FILENAME_COMPONENT(d ${d} ABSOLUTE)
- GET_FILENAME_COMPONENT(d_name ${d} NAME)
- FILE(WRITE ${abs}/${d_name}_component_group.wxs "<ComponentGroup Id='componentgroup.${d_name}'>")
- SET(COMP_NAME ${d_name})
- TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs ${abs}/${d_name}_component_group.wxs "${abs}/dirs")
- FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>")
- IF(EXISTS ${d_name}.wxs)
- FILE(READ ${d_name}.wxs WIX_TMP)
- SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
- FILE(REMOVE ${d_name}.wxs)
- ENDIF()
-
- FILE(READ ${d_name}_component_group.wxs WIX_TMP)
-
- SET(CPACK_WIX_COMPONENT_GROUPS "${CPACK_WIX_COMPONENT_GROUPS}\n${WIX_TMP}")
- FILE(REMOVE ${d_name}_component_group.wxs)
-ENDFOREACH()
-
-FILE(WRITE directories.wxs "<DirectoryRef Id='INSTALLDIR'>\n")
-TRAVERSE_DIRECTORIES(${abs}/dirs ${abs}/dirs directories.wxs "")
-FILE(APPEND directories.wxs "</DirectoryRef>\n")
-
-FILE(READ directories.wxs CPACK_WIX_DIRECTORIES)
-FILE(REMOVE directories.wxs)
-
-
-FOREACH(src ${CPACK_WIX_INCLUDE})
-SET(CPACK_WIX_INCLUDES
-"${CPACK_WIX_INCLUDES}
- <?include ${src}?>"
-)
-ENDFOREACH()
-
-
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
- ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
-
-SET(EXTRA_CANDLE_ARGS)
-IF("$ENV{EXTRA_CANDLE_ARGS}")
- SET(EXTRA_CANDLE_ARGS "$ENV{EXTRA_CANDLE_ARGS}")
-ENDIF()
-
-SET(EXTRA_LIGHT_ARGS)
-IF("$ENV{EXTRA_LIGHT_ARGS}")
- SET(EXTRA_LIGHT_ARGS "$ENV{EXTRA_LIGHT_ARGS}")
-ENDIF()
-
-FILE(REMOVE mysql_server.wixobj)
-EXECUTE_PROCESS(
- COMMAND ${CANDLE_EXECUTABLE} -ext WixUtilExtension mysql_server.wxs ${EXTRA_CANDLE_ARGS}
- RESULT_VARIABLE CANDLE_RESULT
-)
-
-IF(CANDLE_RESULT)
- MESSAGE(FATAL_ERROR "ERROR: can't run candle")
-ENDIF()
-
-EXECUTE_PROCESS(
- COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension
- mysql_server.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi
- ${EXTRA_LIGHT_ARGS}
- RESULT_VARIABLE LIGHT_RESULT
-)
-
-IF(LIGHT_RESULT)
- MESSAGE(FATAL_ERROR "ERROR: can't run light")
-ENDIF()
-
-# Switch monolithic install on again
-EXECUTE_PROCESS(
- COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR}
-)
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") +SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") +SET(CANDLE_EXECUTABLE "@CANDLE_EXECUTABLE@") +SET(LIGHT_EXECUTABLE "@LIGHT_EXECUTABLE@") +SET(CMAKE_COMMAND "@CMAKE_COMMAND@") +SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@") +SET(VERSION "@VERSION@") +SET(MAJOR_VERSION "@MAJOR_VERSION@") +SET(MINOR_VERSION "@MINOR_VERSION@") +SET(PATCH_VERSION "@PATCH_VERSION@") +SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@) +SET(MANUFACTURER "@MANUFACTURER@") +SET(WIXCA_LOCATION "@WIXCA_LOCATION@") +SET(COPYING_RTF "@COPYING_RTF@") +SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@") +SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@") + +LIST(APPEND EXCLUDE_DIRS + bin/debug + data/test + lib/plugin/debug + mysql-test + scripts + sql-bench +) + +LIST(APPEND EXCLUDE_FILES + bin/echo.exe + bin/mysql_client_test_embedded.exe + bin/mysqld-debug.exe + bin/mysqltest_embedded.exe + bin/replace.exe + lib/debug/mysqlserver.lib + lib/libmysqld.dll + lib/libmysqld.lib + lib/mysqlserver.lib + lib/mysqlservices.lib +) + +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(Win64 " Win64='yes'") + SET(Platform x64) + SET(PlatformProgramFilesFolder ProgramFiles64Folder) +ELSE() + SET(Platform x86) + SET(PlatformProgramFilesFolder ProgramFilesFolder) + SET(Win64) +ENDIF() + +SET(ENV{VS_UNICODE_OUTPUT}) + +# Switch off the monolithic install +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=0 ${CMAKE_BINARY_DIR} + OUTPUT_QUIET +) + +INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake) + +IF(CPACK_WIX_CONFIG) + INCLUDE(${CPACK_WIX_CONFIG}) +ENDIF() + +IF(NOT CPACK_WIX_UI) + SET(CPACK_WIX_UI "WixUI_Mondo_Custom") +ENDIF() + +SET(WIX_FEATURES) +FOREACH(comp ${CPACK_COMPONENTS_ALL}) + STRING(TOUPPER "${comp}" comp_upper) + IF(NOT CPACK_COMPONENT_${comp_upper}_GROUP) + SET(WIX_FEATURE_${comp_upper}_COMPONENTS "${comp}") + SET(CPACK_COMPONENT_${comp_upper}_HIDDEN 1) + SET(CPACK_COMPONENT_GROUP_${comp_upper}_DISPLAY_NAME ${CPACK_COMPONENT_${comp_upper}_DISPLAY_NAME}) + SET(CPACK_COMPONENT_GROUP_${comp_upper}_DESCRIPTION ${CPACK_COMPONENT_${comp_upper}_DESCRIPTION}) + SET(CPACK_COMPONENT_GROUP_${comp_upper}_WIX_LEVEL ${CPACK_COMPONENT_${comp_upper}_WIX_LEVEL}) + SET(WIX_FEATURES ${WIX_FEATURES} WIX_FEATURE_${comp_upper}) + ELSE() + SET(FEATURE_NAME WIX_FEATURE_${CPACK_COMPONENT_${comp_upper}_GROUP}) + SET(WIX_FEATURES ${WIX_FEATURES} ${FEATURE_NAME}) + LIST(APPEND ${FEATURE_NAME}_COMPONENTS ${comp}) + ENDIF() +ENDFOREACH() + +LIST(REMOVE_DUPLICATES WIX_FEATURES) + +SET(CPACK_WIX_FEATURES) + +FOREACH(f ${WIX_FEATURES}) + STRING(TOUPPER "${f}" f_upper) + STRING(REPLACE "WIX_FEATURE_" "" f_upper ${f_upper}) + IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME) + SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME}) + ELSE() + SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME) + ENDIF() + + IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION) + SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION}) + ELSE() + SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION) + ENDIF() + IF(CPACK_COMPONENT_${f_upper}_WIX_LEVEL) + SET(Level ${CPACK_COMPONENT_${f_upper}_WIX_LEVEL}) + ELSE() + SET(Level 1) + ENDIF() + IF(CPACK_COMPONENT_GROUP_${f_upper}_HIDDEN) + SET(DISPLAY "Display='hidden'") + SET(TITLE ${f_upper}) + SET(DESCRIPTION ${f_upper}) + ELSE() + SET(DISPLAY) + IF(CPACK_COMPONENT_GROUP_${f_upper}_EXPANDED) + SET(DISPLAY "Display='expand'") + ENDIF() + IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME) + SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME}) + ELSE() + SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME) + ENDIF() + IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION) + SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION}) + ELSE() + SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION) + ENDIF() + ENDIF() + + SET(CPACK_WIX_FEATURES + "${CPACK_WIX_FEATURES} + <Feature Id='${f_upper}' + Title='${TITLE}' + Description='${DESCRIPTION}' + ConfigurableDirectory='INSTALLDIR' + Level='${Level}' ${DISPLAY} >" + ) + FOREACH(c ${${f}_COMPONENTS}) + STRING(TOUPPER "${c}" c_upper) + IF (CPACK_COMPONENT_${c_upper}_DISPLAY_NAME) + SET(TITLE ${CPACK_COMPONENT_${c_upper}_DISPLAY_NAME}) + ELSE() + SET(TITLE CPACK_COMPONENT_${c_upper}_DISPLAY_NAME) + ENDIF() + + IF (CPACK_COMPONENT_${c_upper}_DESCRIPTION) + SET(DESCRIPTION ${CPACK_COMPONENT_${c_upper}_DESCRIPTION}) + ELSE() + SET(DESCRIPTION CPACK_COMPONENT_${c_upper}_DESCRIPTION) + ENDIF() + IF(CPACK_COMPONENT_${c_upper}_WIX_LEVEL) + SET(Level ${CPACK_COMPONENT_${c_upper}_WIX_LEVEL}) + ELSE() + SET(Level 1) + ENDIF() + IF(CPACK_COMPONENT_${c_upper}_HIDDEN) + SET(CPACK_WIX_FEATURES + "${CPACK_WIX_FEATURES} + <ComponentGroupRef Id='componentgroup.${c}'/>") + ELSE() + SET(CPACK_WIX_FEATURES + "${CPACK_WIX_FEATURES} + <Feature Id='${c}' + Title='${TITLE}' + Description='${DESCRIPTION}' + ConfigurableDirectory='INSTALLDIR' + Level='${Level}'> + <ComponentGroupRef Id='componentgroup.${c}'/> + </Feature>") + ENDIF() + + ENDFOREACH() + SET(CPACK_WIX_FEATURES + "${CPACK_WIX_FEATURES} + </Feature> + ") +ENDFOREACH() + + +IF(CMAKE_INSTALL_CONFIG_NAME) + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}" + WIXCA_LOCATION "${WIXCA_LOCATION}") + SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}") +ENDIF() + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs) + + +FOREACH(comp ${CPACK_COMPONENTS_ALL}) + SET(ENV{DESTDIR} testinstall/${comp}) + SET(DIRS ${DIRS} testinstall/${comp}) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -DCMAKE_INSTALL_COMPONENT=${comp} + -DCMAKE_INSTALL_PREFIX= -P ${CMAKE_BINARY_DIR}/cmake_install.cmake + OUTPUT_QUIET + ) +ENDFOREACH() + +MACRO(GENERATE_GUID VarName) + EXECUTE_PROCESS(COMMAND uuidgen -c + OUTPUT_VARIABLE ${VarName} + OUTPUT_STRIP_TRAILING_WHITESPACE) +ENDMACRO() + +SET(INC_VAR 0) +MACRO(MAKE_WIX_IDENTIFIER str varname) + STRING(REPLACE "/" "." ${varname} "${str}") + STRING(REGEX REPLACE "[^a-zA-Z_0-9.]" "_" ${varname} "${${varname}}") + STRING(LENGTH "${${varname}}" len) + # Identifier should be smaller than 72 character + # We have to cut down the length to 70 chars, since we add 2 char prefix + # pretty often + IF(len GREATER 70) + STRING(SUBSTRING "${${varname}}" 0 67 shortstr) + MATH(EXPR INC_VAR ${INC_VAR}+1) + SET(${varname} "${shortstr}${INC_VAR}") + ENDIF() +ENDMACRO() + + +FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root) + FILE(RELATIVE_PATH dir_rel ${topdir} ${dir}) + IF(dir_rel) + LIST(FIND EXCLUDE_DIRS ${dir_rel} TO_EXCLUDE) + IF(NOT TO_EXCLUDE EQUAL -1) + MESSAGE(STATUS "excluding directory: ${dir_rel}") + RETURN() + ENDIF() + ENDIF() + FILE(GLOB all_files ${dir}/*) + IF(NOT all_files) + RETURN() + ENDIF() + IF(dir_rel) + MAKE_DIRECTORY(${dir_root}/${dir_rel}) + MAKE_WIX_IDENTIFIER("${dir_rel}" id) + SET(DirectoryRefId "D.${id}") + ELSE() + SET(DirectoryRefId "INSTALLDIR") + ENDIF() + FILE(APPEND ${file} "<DirectoryRef Id='${DirectoryRefId}'>\n") + + SET(NONEXEFILES) + FOREACH(f ${all_files}) + IF(NOT IS_DIRECTORY ${f}) + FILE(RELATIVE_PATH rel ${topdir} ${f}) + SET(TO_EXCLUDE) + IF(rel MATCHES "\\.pdb$") + SET(TO_EXCLUDE TRUE) + ELSE() + LIST(FIND EXCLUDE_FILES ${rel} RES) + IF(NOT RES EQUAL -1) + SET(TO_EXCLUDE TRUE) + ENDIF() + ENDIF() + IF(TO_EXCLUDE) + MESSAGE(STATUS "excluding file: ${rel}") + ELSE() + MAKE_WIX_IDENTIFIER("${rel}" id) + FILE(TO_NATIVE_PATH ${f} f_native) + GET_FILENAME_COMPONENT(f_ext "${f}" EXT) + # According to MSDN each DLL or EXE should be in the own component + IF(f_ext MATCHES ".exe" OR f_ext MATCHES ".dll") + + FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64}>\n") + FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\n") + FILE(APPEND ${file} " </Component>\n") + FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n") + ELSE() + SET(NONEXEFILES "${NONEXEFILES}\n<File Id='F.${id}' Source='${f_native}'/>" ) + ENDIF() + ENDIF() + ENDIF() + ENDFOREACH() + FILE(APPEND ${file} "</DirectoryRef>\n") + IF(NONEXEFILES) + GENERATE_GUID(guid) + SET(ComponentId "C._files_${COMP_NAME}.${DirectoryRefId}") + FILE(APPEND ${file} + "<DirectoryRef Id='${DirectoryRefId}'>\n<Component Guid='${guid}' Id='${ComponentId}' ${Win64}>${NONEXEFILES}\n</Component></DirectoryRef>\n") + FILE(APPEND ${file_comp} " <ComponentRef Id='${ComponentId}'/>\n") + ENDIF() + FOREACH(f ${all_files}) + IF(IS_DIRECTORY ${f}) + TRAVERSE_FILES(${f} ${topdir} ${file} ${file_comp} ${dir_root}) + ENDIF() + ENDFOREACH() +ENDFUNCTION() + +FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix) + FILE(RELATIVE_PATH rel ${topdir} ${dir}) + IF(rel) + MAKE_WIX_IDENTIFIER("${rel}" id) + GET_FILENAME_COMPONENT(name ${dir} NAME) + FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n") + ENDIF() + FILE(GLOB all_files ${dir}/*) + FOREACH(f ${all_files}) + IF(IS_DIRECTORY ${f}) + TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ") + ENDIF() + ENDFOREACH() + IF(rel) + FILE(APPEND ${file} "${prefix}</Directory>\n") + ENDIF() +ENDFUNCTION() + +SET(CPACK_WIX_COMPONENTS) +SET(CPACK_WIX_COMPONENT_GROUPS) +GET_FILENAME_COMPONENT(abs . ABSOLUTE) +FOREACH(d ${DIRS}) + GET_FILENAME_COMPONENT(d ${d} ABSOLUTE) + GET_FILENAME_COMPONENT(d_name ${d} NAME) + FILE(WRITE ${abs}/${d_name}_component_group.wxs "<ComponentGroup Id='componentgroup.${d_name}'>") + SET(COMP_NAME ${d_name}) + TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs ${abs}/${d_name}_component_group.wxs "${abs}/dirs") + FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>") + IF(EXISTS ${d_name}.wxs) + FILE(READ ${d_name}.wxs WIX_TMP) + SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}") + FILE(REMOVE ${d_name}.wxs) + ENDIF() + + FILE(READ ${d_name}_component_group.wxs WIX_TMP) + + SET(CPACK_WIX_COMPONENT_GROUPS "${CPACK_WIX_COMPONENT_GROUPS}\n${WIX_TMP}") + FILE(REMOVE ${d_name}_component_group.wxs) +ENDFOREACH() + +FILE(WRITE directories.wxs "<DirectoryRef Id='INSTALLDIR'>\n") +TRAVERSE_DIRECTORIES(${abs}/dirs ${abs}/dirs directories.wxs "") +FILE(APPEND directories.wxs "</DirectoryRef>\n") + +FILE(READ directories.wxs CPACK_WIX_DIRECTORIES) +FILE(REMOVE directories.wxs) + + +FOREACH(src ${CPACK_WIX_INCLUDE}) +SET(CPACK_WIX_INCLUDES +"${CPACK_WIX_INCLUDES} + <?include ${src}?>" +) +ENDFOREACH() + + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs) + +SET(EXTRA_CANDLE_ARGS) +IF("$ENV{EXTRA_CANDLE_ARGS}") + SET(EXTRA_CANDLE_ARGS "$ENV{EXTRA_CANDLE_ARGS}") +ENDIF() + +SET(EXTRA_LIGHT_ARGS) +IF("$ENV{EXTRA_LIGHT_ARGS}") + SET(EXTRA_LIGHT_ARGS "$ENV{EXTRA_LIGHT_ARGS}") +ENDIF() + +FILE(REMOVE mysql_server.wixobj) +EXECUTE_PROCESS( + COMMAND ${CANDLE_EXECUTABLE} -ext WixUtilExtension mysql_server.wxs ${EXTRA_CANDLE_ARGS} + RESULT_VARIABLE CANDLE_RESULT +) + +IF(CANDLE_RESULT) + MESSAGE(FATAL_ERROR "ERROR: can't run candle") +ENDIF() + +EXECUTE_PROCESS( + COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension + mysql_server.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi + ${EXTRA_LIGHT_ARGS} + RESULT_VARIABLE LIGHT_RESULT +) + +IF(LIGHT_RESULT) + MESSAGE(FATAL_ERROR "ERROR: can't run light") +ENDIF() + +# Switch monolithic install on again +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR} +) diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs index a28c3c9b8a1..0ccd30f6754 100644 --- a/packaging/WiX/custom_ui.wxs +++ b/packaging/WiX/custom_ui.wxs @@ -1,115 +1,115 @@ -<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
- xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
-
-<!--
- Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--->
-
- <UI Id="WixUI_Mondo_Custom">
- <Dialog Id="CustomWelcomeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
- <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
- <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
- </Control>
- <Control Id="Next" Type="PushButton" X="220" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
- <Publish Event="NewDialog" Value="LicenseAgreementDlg">NOT OLDERVERSIONBEINGUPGRADED</Publish>
- <Publish Event="NewDialog" Value="UpgradeDlg">OLDERVERSIONBEINGUPGRADED</Publish>
- </Control>
- <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" Disabled="yes" />
- <Control Id="Description" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgDescription)" />
- <Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgTitle)" />
- <Control Id="CopyrightText" Type="Text" X="135" Y="200" Width="220" Height="40" Transparent="yes" Text="Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved." />
- <Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.WelcomeDlgBitmap)" />
- <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
- </Dialog>
-
- <Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
- <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade">
- <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
- <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
- <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
- <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
- <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
- </Control>
- <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
- <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
- </Control>
- <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
- <Condition Action="default">WixUI_InstallMode = "Remove"</Condition>
- </Control>
- <Control Id="InstallTitle" Type="Text" X="15" Y="15" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallTitle)">
- <Condition Action="show">NOT Installed</Condition>
- </Control>
- <Control Id="InstallText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallText)">
- <Condition Action="show">NOT Installed</Condition>
- </Control>
- <Control Id="UpgradeText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="no" NoPrefix="yes"
- Text="Click Upgrade to upgrade your installation from version [OLDERVERSION] to version [ProductVersion]. Click Cancel to exit the upgrade."/>
- <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.VerifyReadyDlgBannerBitmap)" />
- <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
- <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
- </Dialog>
-
- <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
- <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
- <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
-
- <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
- <Property Id="WixUI_Mode" Value="Mondo" />
-
- <DialogRef Id="ErrorDlg" />
- <DialogRef Id="FatalError" />
- <DialogRef Id="FilesInUse" />
- <DialogRef Id="MsiRMFilesInUse" />
- <DialogRef Id="PrepareDlg" />
- <DialogRef Id="ProgressDlg" />
- <DialogRef Id="ResumeDlg" />
- <DialogRef Id="UserExit" />
-
- <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
-
- <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish>
- <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish>
-
- <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
- <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
- <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
- <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-
- <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish>
- <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish>
- <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish>
-
- <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
-
- <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
- <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
- <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
- <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
-
- <Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish>
-
- <InstallUISequence>
- <Show Dialog="CustomWelcomeDlg" Before="ProgressDlg">NOT Installed</Show>
- </InstallUISequence>
- </UI>
-
- <UIRef Id="WixUI_Common" />
-</Include>
+<Include xmlns="http://schemas.microsoft.com/wix/2006/wi" + xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> + +<!-- + Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> + + <UI Id="WixUI_Mondo_Custom"> + <Dialog Id="CustomWelcomeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes"> + <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)"> + <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish> + </Control> + <Control Id="Next" Type="PushButton" X="220" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)"> + <Publish Event="NewDialog" Value="LicenseAgreementDlg">NOT OLDERVERSIONBEINGUPGRADED</Publish> + <Publish Event="NewDialog" Value="UpgradeDlg">OLDERVERSIONBEINGUPGRADED</Publish> + </Control> + <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" Disabled="yes" /> + <Control Id="Description" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgDescription)" /> + <Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgTitle)" /> + <Control Id="CopyrightText" Type="Text" X="135" Y="200" Width="220" Height="40" Transparent="yes" Text="Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved." /> + <Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.WelcomeDlgBitmap)" /> + <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" /> + </Dialog> + + <Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes"> + <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade"> + <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish> + <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish> + <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish> + <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish> + <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish> + </Control> + <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)"> + <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish> + </Control> + <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)"> + <Condition Action="default">WixUI_InstallMode = "Remove"</Condition> + </Control> + <Control Id="InstallTitle" Type="Text" X="15" Y="15" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallTitle)"> + <Condition Action="show">NOT Installed</Condition> + </Control> + <Control Id="InstallText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallText)"> + <Condition Action="show">NOT Installed</Condition> + </Control> + <Control Id="UpgradeText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="no" NoPrefix="yes" + Text="Click Upgrade to upgrade your installation from version [OLDERVERSION] to version [ProductVersion]. Click Cancel to exit the upgrade."/> + <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.VerifyReadyDlgBannerBitmap)" /> + <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" /> + <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" /> + </Dialog> + + <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" /> + <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" /> + <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> + + <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> + <Property Id="WixUI_Mode" Value="Mondo" /> + + <DialogRef Id="ErrorDlg" /> + <DialogRef Id="FatalError" /> + <DialogRef Id="FilesInUse" /> + <DialogRef Id="MsiRMFilesInUse" /> + <DialogRef Id="PrepareDlg" /> + <DialogRef Id="ProgressDlg" /> + <DialogRef Id="ResumeDlg" /> + <DialogRef Id="UserExit" /> + + <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish> + + <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish> + <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish> + + <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish> + <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish> + <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + + <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish> + <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish> + <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish> + + <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish> + + <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> + <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish> + + <Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish> + + <InstallUISequence> + <Show Dialog="CustomWelcomeDlg" Before="ProgressDlg">NOT Installed</Show> + </InstallUISequence> + </UI> + + <UIRef Id="WixUI_Common" /> +</Include> diff --git a/packaging/WiX/extra.wxs.in b/packaging/WiX/extra.wxs.in index 91bf3f64b8e..92a79064d54 100644 --- a/packaging/WiX/extra.wxs.in +++ b/packaging/WiX/extra.wxs.in @@ -1,81 +1,81 @@ -<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
- xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
-
-<!--
- Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--->
-
- <!-- Datafiles that installation will copy to CommonAppData (initial database)
- They are declared Permanent and NeverOverwrite since it is user data -->
- <DirectoryRef Id='TARGETDIR'>
- <Directory Id="CommonAppDataFolder">
- <Directory Id="datadir.mysql" Name="MySQL">
- <Directory Id="datadir.mysql.mysqlserver"
- Name="MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@">
- <Directory Id="DATADIR" Name=".">
- <Component Id="component.datadir" Guid="d3491319-5dbc-4477-95f3-4f809ef1dd2d">
- <CreateFolder>
- <util:PermissionEx User="[LogonUser]" GenericAll="yes" />
- </CreateFolder>
- </Component>
- <Directory Id="datadir.mysql.mysqlserver.data" Name="data">
- <Directory Id="datadir.mysql.mysqlserver.data.mysql" Name="mysql">
- <Component Id="component.datadir.mysql"
- Guid="19ec0f1f-1a7f-424e-a788-b09346c0a709"
- Permanent="yes" NeverOverwrite="yes">
- <CreateFolder>
- <util:PermissionEx User="[LogonUser]" GenericAll="yes" />
- </CreateFolder>
- @DATADIR_MYSQL_FILES@
- </Component>
- </Directory>
- <Directory Id="datadir.mysql.mysqlserver.data.performance_schema"
- Name="performance_schema">
- <Component Id="component.datadir.performance_schema"
- Guid="af2a6776-2655-431f-a748-9e9f4645acc3"
- Permanent="yes" NeverOverwrite="yes">
- <CreateFolder>
- <util:PermissionEx User="[LogonUser]" GenericAll="yes" />
- </CreateFolder>
- @DATADIR_PERFORMANCE_SCHEMA_FILES@
- </Component>
- </Directory>
- <Directory Id="datadir.mysql.mysqlserver.data.test" Name="test">
- <Component Id="component.datadir.test" Guid="52fa9f0a-fcd1-420a-b2ac-95a8f70ad20a">
- <CreateFolder/>
- </Component>
- </Directory>
- </Directory>
- </Directory>
- </Directory>
- </Directory>
- </Directory>
- </DirectoryRef>
-
- <Feature Id='UserEditableDataFiles'
- Title='Server data files'
- Description='Server data files'
- ConfigurableDirectory='DATADIR'
- Level='1'>
- <ComponentRef Id="component.datadir"/>
- <ComponentRef Id="component.datadir.mysql"/>
- <ComponentRef Id="component.datadir.performance_schema"/>
- <ComponentRef Id="component.datadir.test"/>
- </Feature>
-</Include>
-
-
-
+<Include xmlns="http://schemas.microsoft.com/wix/2006/wi" + xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> + +<!-- + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> + + <!-- Datafiles that installation will copy to CommonAppData (initial database) + They are declared Permanent and NeverOverwrite since it is user data --> + <DirectoryRef Id='TARGETDIR'> + <Directory Id="CommonAppDataFolder"> + <Directory Id="datadir.mysql" Name="MySQL"> + <Directory Id="datadir.mysql.mysqlserver" + Name="MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@"> + <Directory Id="DATADIR" Name="."> + <Component Id="component.datadir" Guid="d3491319-5dbc-4477-95f3-4f809ef1dd2d"> + <CreateFolder> + <util:PermissionEx User="[LogonUser]" GenericAll="yes" /> + </CreateFolder> + </Component> + <Directory Id="datadir.mysql.mysqlserver.data" Name="data"> + <Directory Id="datadir.mysql.mysqlserver.data.mysql" Name="mysql"> + <Component Id="component.datadir.mysql" + Guid="19ec0f1f-1a7f-424e-a788-b09346c0a709" + Permanent="yes" NeverOverwrite="yes"> + <CreateFolder> + <util:PermissionEx User="[LogonUser]" GenericAll="yes" /> + </CreateFolder> + @DATADIR_MYSQL_FILES@ + </Component> + </Directory> + <Directory Id="datadir.mysql.mysqlserver.data.performance_schema" + Name="performance_schema"> + <Component Id="component.datadir.performance_schema" + Guid="af2a6776-2655-431f-a748-9e9f4645acc3" + Permanent="yes" NeverOverwrite="yes"> + <CreateFolder> + <util:PermissionEx User="[LogonUser]" GenericAll="yes" /> + </CreateFolder> + @DATADIR_PERFORMANCE_SCHEMA_FILES@ + </Component> + </Directory> + <Directory Id="datadir.mysql.mysqlserver.data.test" Name="test"> + <Component Id="component.datadir.test" Guid="52fa9f0a-fcd1-420a-b2ac-95a8f70ad20a"> + <CreateFolder/> + </Component> + </Directory> + </Directory> + </Directory> + </Directory> + </Directory> + </Directory> + </DirectoryRef> + + <Feature Id='UserEditableDataFiles' + Title='Server data files' + Description='Server data files' + ConfigurableDirectory='DATADIR' + Level='1'> + <ComponentRef Id="component.datadir"/> + <ComponentRef Id="component.datadir.mysql"/> + <ComponentRef Id="component.datadir.performance_schema"/> + <ComponentRef Id="component.datadir.test"/> + </Feature> +</Include> + + + diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in index 1802baedf3b..1e7c20468ef 100644 --- a/packaging/WiX/mysql_server.wxs.in +++ b/packaging/WiX/mysql_server.wxs.in @@ -1,196 +1,196 @@ -<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
- xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
-
-<!--
- Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--->
-
- <Product
- Id="*"
- UpgradeCode="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3"
- Name="MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@"
- Version="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
- Language="1033"
- Manufacturer="@MANUFACTURER@">
-
- <Package Id='*'
- Keywords='Installer'
- Description="MySQL Database Server"
- Manufacturer='@MANUFACTURER@'
- InstallerVersion='200'
- Languages='1033'
- Compressed='yes'
- SummaryCodepage='1252'
- Platform='@Platform@'
- InstallScope="perMachine"/>
-
- <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
-
- <!-- Upgrade -->
- <Upgrade Id="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3">
- <UpgradeVersion
- Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
- IncludeMinimum="yes"
- Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
- IncludeMaximum="yes"
- Property="OLDERVERSIONBEINGUPGRADED"
- MigrateFeatures="yes"
- />
- <UpgradeVersion
- Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
- IncludeMinimum="no"
- OnlyDetect="yes"
- Property="NEWERVERSIONDETECTED" />
- </Upgrade>
- <Condition Message="A later version of [ProductName] is already installed. Setup will now exit.">
- NOT NEWERVERSIONDETECTED OR Installed
- </Condition>
- <InstallExecuteSequence>
- <RemoveExistingProducts After="InstallInitialize"/>
- </InstallExecuteSequence>
-
- <!-- Save/restore install location -->
- <CustomAction Id="SaveTargetDir" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]" />
- <InstallExecuteSequence>
- <Custom Action="SaveTargetDir" After="InstallValidate">
- NOT
- Installed
- </Custom>
- </InstallExecuteSequence>
- <InstallUISequence>
- <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->
- <AppSearch After="FindRelatedProducts"/>
- </InstallUISequence>
-
- <!-- Find previous installation -->
- <Property Id="INSTALLDIR">
- <RegistrySearch Id="FindInstallLocation"
- Root="HKLM"
- Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
- Name="InstallLocation"
- Type="raw" />
- </Property>
- <?if @Platform@ != "x64" ?>
- <Property Id="OLDERVERSION">
- <RegistrySearch Id="FindOlderVersion"
- Root="HKLM"
- Win64 = "no"
- Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
- Name="DisplayVersion"
- Type="raw" />
- </Property>
- <?else ?>
- <Property Id="OLDERVERSION">
- <RegistrySearch Id="FindOlderVersion"
- Root="HKLM"
- Win64 = "yes"
- Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
- Name="DisplayVersion"
- Type="raw" />
- </Property>
- <?endif ?>
- <Property Id="DATADIR">
- <RegistrySearch Id="FindDataDir"
- Root="HKLM"
- Key="SOFTWARE\MySQL AB\[ProductName]"
- Name="DataLocation"
- Type="raw" />
- </Property>
- <Property Id="INSTALLDIR2">
- <RegistrySearch Id="FindInstallLocation2"
- Root="HKLM"
- Key="SOFTWARE\MySQL AB\[ProductName]"
- Name="Location"
- Type="raw" />
- </Property>
- <CustomAction Id="SetInstallDir2" Property="INSTALLDIR" Value="[INSTALLDIR2]" />
- <InstallUISequence>
- <Custom Action="SetInstallDir2" After="AppSearch">INSTALLDIR2</Custom>
- </InstallUISequence>
-
-
- <!-- UI -->
- <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
- <UIRef Id="@CPACK_WIX_UI@" />
- <UIRef Id="WixUI_ErrorProgressText" />
- <WixVariable
- Id="WixUIBannerBmp"
- Value="@CMAKE_CURRENT_SOURCE_DIR@/AdminHeader.jpg" />
- <WixVariable
- Id="WixUIDialogBmp"
- Value="@CMAKE_CURRENT_SOURCE_DIR@/AdminBackground.jpg" />
- <Icon
- Id="icon.ico"
- SourceFile="@CMAKE_CURRENT_SOURCE_DIR@/MySQLServer.ico"/>
- <Property
- Id="ARPPRODUCTICON"
- Value="icon.ico" />
-
- <!-- License -->
- <WixVariable
- Id="WixUILicenseRtf"
- Value="@COPYING_RTF@"/>
-
- <!-- How to remove the service on uninstall -->
- <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' />
- <CustomAction Id="UnregisterProperty" Property="UnregisterService" Value="[INSTALLDIR]" Return="check" />
- <CustomAction Id="UnregisterPropertySilent" Property="UnregisterServiceSilently" Value="[INSTALLDIR]" Return="check" />
- <CustomAction Id="UnregisterService"
- BinaryKey="wixca.dll"
- DllEntry="RemoveService"
- Execute="deferred"
- Impersonate="no"
- Return="check" />
- <CustomAction Id="UnregisterServiceSilently"
- BinaryKey="wixca.dll"
- DllEntry="RemoveServiceNoninteractive"
- Execute="deferred"
- Impersonate="no"
- Return="check" />
- <InstallExecuteSequence>
- <Custom Action="UnregisterProperty" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL"</Custom>
- <Custom Action="UnregisterPropertySilent" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL"</Custom>
- <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL" And UILevel>4</Custom>
- <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL" And UILevel<=4</Custom>
- </InstallExecuteSequence>
-
- <!-- Installation root-->
- <Directory Id='TARGETDIR' Name='SourceDir'>
- <Directory Id='@PlatformProgramFilesFolder@'>
- <Directory Id='directory.MySQL' Name='MySQL'>
- <Directory Id='INSTALLDIR' Name='MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@'>
- </Directory>
- </Directory>
- </Directory>
- </Directory>
-
- <!-- CPACK_WIX_FEATURES -->
- @CPACK_WIX_FEATURES@
-
- <!-- CPACK_WIX_DIRECTORIES -->
- @CPACK_WIX_DIRECTORIES@
-
- <!--CPACK_WIX_COMPONENTS-->
- @CPACK_WIX_COMPONENTS@
-
- <!--CPACK_WIX_COMPONENTS_GROUPS -->
- @CPACK_WIX_COMPONENT_GROUPS@
-
- <!--CPACK_WIX_INCLUDES -->
- @CPACK_WIX_INCLUDES@
- </Product>
-
-</Wix>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" + xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> + +<!-- + Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +--> + + <Product + Id="*" + UpgradeCode="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3" + Name="MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@" + Version="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@" + Language="1033" + Manufacturer="@MANUFACTURER@"> + + <Package Id='*' + Keywords='Installer' + Description="MySQL Database Server" + Manufacturer='@MANUFACTURER@' + InstallerVersion='200' + Languages='1033' + Compressed='yes' + SummaryCodepage='1252' + Platform='@Platform@' + InstallScope="perMachine"/> + + <Media Id='1' Cabinet='product.cab' EmbedCab='yes' /> + + <!-- Upgrade --> + <Upgrade Id="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3"> + <UpgradeVersion + Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0" + IncludeMinimum="yes" + Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@" + IncludeMaximum="yes" + Property="OLDERVERSIONBEINGUPGRADED" + MigrateFeatures="yes" + /> + <UpgradeVersion + Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@" + IncludeMinimum="no" + OnlyDetect="yes" + Property="NEWERVERSIONDETECTED" /> + </Upgrade> + <Condition Message="A later version of [ProductName] is already installed. Setup will now exit."> + NOT NEWERVERSIONDETECTED OR Installed + </Condition> + <InstallExecuteSequence> + <RemoveExistingProducts After="InstallInitialize"/> + </InstallExecuteSequence> + + <!-- Save/restore install location --> + <CustomAction Id="SaveTargetDir" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]" /> + <InstallExecuteSequence> + <Custom Action="SaveTargetDir" After="InstallValidate"> + NOT + Installed + </Custom> + </InstallExecuteSequence> + <InstallUISequence> + <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts --> + <AppSearch After="FindRelatedProducts"/> + </InstallUISequence> + + <!-- Find previous installation --> + <Property Id="INSTALLDIR"> + <RegistrySearch Id="FindInstallLocation" + Root="HKLM" + Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]" + Name="InstallLocation" + Type="raw" /> + </Property> + <?if @Platform@ != "x64" ?> + <Property Id="OLDERVERSION"> + <RegistrySearch Id="FindOlderVersion" + Root="HKLM" + Win64 = "no" + Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]" + Name="DisplayVersion" + Type="raw" /> + </Property> + <?else ?> + <Property Id="OLDERVERSION"> + <RegistrySearch Id="FindOlderVersion" + Root="HKLM" + Win64 = "yes" + Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]" + Name="DisplayVersion" + Type="raw" /> + </Property> + <?endif ?> + <Property Id="DATADIR"> + <RegistrySearch Id="FindDataDir" + Root="HKLM" + Key="SOFTWARE\MySQL AB\[ProductName]" + Name="DataLocation" + Type="raw" /> + </Property> + <Property Id="INSTALLDIR2"> + <RegistrySearch Id="FindInstallLocation2" + Root="HKLM" + Key="SOFTWARE\MySQL AB\[ProductName]" + Name="Location" + Type="raw" /> + </Property> + <CustomAction Id="SetInstallDir2" Property="INSTALLDIR" Value="[INSTALLDIR2]" /> + <InstallUISequence> + <Custom Action="SetInstallDir2" After="AppSearch">INSTALLDIR2</Custom> + </InstallUISequence> + + + <!-- UI --> + <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property> + <UIRef Id="@CPACK_WIX_UI@" /> + <UIRef Id="WixUI_ErrorProgressText" /> + <WixVariable + Id="WixUIBannerBmp" + Value="@CMAKE_CURRENT_SOURCE_DIR@/AdminHeader.jpg" /> + <WixVariable + Id="WixUIDialogBmp" + Value="@CMAKE_CURRENT_SOURCE_DIR@/AdminBackground.jpg" /> + <Icon + Id="icon.ico" + SourceFile="@CMAKE_CURRENT_SOURCE_DIR@/MySQLServer.ico"/> + <Property + Id="ARPPRODUCTICON" + Value="icon.ico" /> + + <!-- License --> + <WixVariable + Id="WixUILicenseRtf" + Value="@COPYING_RTF@"/> + + <!-- How to remove the service on uninstall --> + <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' /> + <CustomAction Id="UnregisterProperty" Property="UnregisterService" Value="[INSTALLDIR]" Return="check" /> + <CustomAction Id="UnregisterPropertySilent" Property="UnregisterServiceSilently" Value="[INSTALLDIR]" Return="check" /> + <CustomAction Id="UnregisterService" + BinaryKey="wixca.dll" + DllEntry="RemoveService" + Execute="deferred" + Impersonate="no" + Return="check" /> + <CustomAction Id="UnregisterServiceSilently" + BinaryKey="wixca.dll" + DllEntry="RemoveServiceNoninteractive" + Execute="deferred" + Impersonate="no" + Return="check" /> + <InstallExecuteSequence> + <Custom Action="UnregisterProperty" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL"</Custom> + <Custom Action="UnregisterPropertySilent" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL"</Custom> + <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL" And UILevel>4</Custom> + <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And REMOVE="ALL" And UILevel<=4</Custom> + </InstallExecuteSequence> + + <!-- Installation root--> + <Directory Id='TARGETDIR' Name='SourceDir'> + <Directory Id='@PlatformProgramFilesFolder@'> + <Directory Id='directory.MySQL' Name='MySQL'> + <Directory Id='INSTALLDIR' Name='MySQL Server @MAJOR_VERSION@.@MINOR_VERSION@'> + </Directory> + </Directory> + </Directory> + </Directory> + + <!-- CPACK_WIX_FEATURES --> + @CPACK_WIX_FEATURES@ + + <!-- CPACK_WIX_DIRECTORIES --> + @CPACK_WIX_DIRECTORIES@ + + <!--CPACK_WIX_COMPONENTS--> + @CPACK_WIX_COMPONENTS@ + + <!--CPACK_WIX_COMPONENTS_GROUPS --> + @CPACK_WIX_COMPONENT_GROUPS@ + + <!--CPACK_WIX_INCLUDES --> + @CPACK_WIX_INCLUDES@ + </Product> + +</Wix> diff --git a/pcre/RunTest.bat b/pcre/RunTest.bat index 35d7f71f9e8..8f290f59130 100644 --- a/pcre/RunTest.bat +++ b/pcre/RunTest.bat @@ -1,616 +1,616 @@ -@echo off
-@rem This file must use CRLF linebreaks to function properly
-@rem and requires both pcretest and pcregrep
-@rem This file was originally contributed by Ralf Junker, and touched up by
-@rem Daniel Richard G. Tests 10-12 added by Philip H.
-@rem Philip H also changed test 3 to use "wintest" files.
-@rem
-@rem Updated by Tom Fortmann to support explicit test numbers on the command line.
-@rem Added argument validation and added error reporting.
-@rem
-@rem MS Windows batch file to run pcretest on testfiles with the correct
-@rem options.
-@rem
-@rem Sheri Pierce added logic to skip feature dependent tests
-@rem tests 4 5 9 15 and 18 require utf support
-@rem tests 6 7 10 16 and 19 require ucp support
-@rem 11 requires ucp and link size 2
-@rem 12 requires presence of jit support
-@rem 13 requires absence of jit support
-@rem Sheri P also added override tests for study and jit testing
-@rem Zoltan Herczeg added libpcre16 support
-@rem Zoltan Herczeg added libpcre32 support
-
-setlocal enabledelayedexpansion
-if [%srcdir%]==[] (
-if exist testdata\ set srcdir=.)
-if [%srcdir%]==[] (
-if exist ..\testdata\ set srcdir=..)
-if [%srcdir%]==[] (
-if exist ..\..\testdata\ set srcdir=..\..)
-if NOT exist %srcdir%\testdata\ (
-Error: echo distribution testdata folder not found!
-call :conferror
-exit /b 1
-goto :eof
-)
-
-if [%pcretest%]==[] set pcretest=.\pcretest.exe
-
-echo source dir is %srcdir%
-echo pcretest=%pcretest%
-
-if NOT exist %pcretest% (
-echo Error: %pcretest% not found!
-echo.
-call :conferror
-exit /b 1
-)
-
-%pcretest% -C linksize >NUL
-set link_size=%ERRORLEVEL%
-%pcretest% -C pcre8 >NUL
-set support8=%ERRORLEVEL%
-%pcretest% -C pcre16 >NUL
-set support16=%ERRORLEVEL%
-%pcretest% -C pcre32 >NUL
-set support32=%ERRORLEVEL%
-%pcretest% -C utf >NUL
-set utf=%ERRORLEVEL%
-%pcretest% -C ucp >NUL
-set ucp=%ERRORLEVEL%
-%pcretest% -C jit >NUL
-set jit=%ERRORLEVEL%
-
-if %support8% EQU 1 (
-if not exist testout8 md testout8
-if not exist testoutstudy8 md testoutstudy8
-if not exist testoutjit8 md testoutjit8
-)
-
-if %support16% EQU 1 (
-if not exist testout16 md testout16
-if not exist testoutstudy16 md testoutstudy16
-if not exist testoutjit16 md testoutjit16
-)
-
-if %support16% EQU 1 (
-if not exist testout32 md testout32
-if not exist testoutstudy32 md testoutstudy32
-if not exist testoutjit32 md testoutjit32
-)
-
-set do1=no
-set do2=no
-set do3=no
-set do4=no
-set do5=no
-set do6=no
-set do7=no
-set do8=no
-set do9=no
-set do10=no
-set do11=no
-set do12=no
-set do13=no
-set do14=no
-set do15=no
-set do16=no
-set do17=no
-set do18=no
-set do19=no
-set do20=no
-set do21=no
-set do22=no
-set do23=no
-set do24=no
-set do25=no
-set do26=no
-set all=yes
-
-for %%a in (%*) do (
- set valid=no
- for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26) do if %%v == %%a set valid=yes
- if "!valid!" == "yes" (
- set do%%a=yes
- set all=no
-) else (
- echo Invalid test number - %%a!
- echo Usage %0 [ test_number ] ...
- echo Where test_number is one or more optional test numbers 1 through 26, default is all tests.
- exit /b 1
-)
-)
-set failed="no"
-
-if "%all%" == "yes" (
- set do1=yes
- set do2=yes
- set do3=yes
- set do4=yes
- set do5=yes
- set do6=yes
- set do7=yes
- set do8=yes
- set do9=yes
- set do10=yes
- set do11=yes
- set do12=yes
- set do13=yes
- set do14=yes
- set do15=yes
- set do16=yes
- set do17=yes
- set do18=yes
- set do19=yes
- set do20=yes
- set do21=yes
- set do22=yes
- set do23=yes
- set do24=yes
- set do25=yes
- set do26=yes
-)
-
-@echo RunTest.bat's pcretest output is written to newly created subfolders named
-@echo testout, testoutstudy and testoutjit.
-@echo.
-
-set mode=
-set bits=8
-
-:nextMode
-if "%mode%" == "" (
- if %support8% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 8-bit library ----
- echo.
-)
-if "%mode%" == "-16" (
- if %support16% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 16-bit library ----
- echo.
-)
-if "%mode%" == "-32" (
- if %support32% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 32-bit library ----
- echo.
-)
-if "%do1%" == "yes" call :do1
-if "%do2%" == "yes" call :do2
-if "%do3%" == "yes" call :do3
-if "%do4%" == "yes" call :do4
-if "%do5%" == "yes" call :do5
-if "%do6%" == "yes" call :do6
-if "%do7%" == "yes" call :do7
-if "%do8%" == "yes" call :do8
-if "%do9%" == "yes" call :do9
-if "%do10%" == "yes" call :do10
-if "%do11%" == "yes" call :do11
-if "%do12%" == "yes" call :do12
-if "%do13%" == "yes" call :do13
-if "%do14%" == "yes" call :do14
-if "%do15%" == "yes" call :do15
-if "%do16%" == "yes" call :do16
-if "%do17%" == "yes" call :do17
-if "%do18%" == "yes" call :do18
-if "%do19%" == "yes" call :do19
-if "%do20%" == "yes" call :do20
-if "%do21%" == "yes" call :do21
-if "%do22%" == "yes" call :do22
-if "%do23%" == "yes" call :do23
-if "%do24%" == "yes" call :do24
-if "%do25%" == "yes" call :do25
-if "%do26%" == "yes" call :do26
-:modeSkip
-if "%mode%" == "" (
- set mode=-16
- set bits=16
- goto nextMode
-)
-if "%mode%" == "-16" (
- set mode=-32
- set bits=32
- goto nextMode
-)
-
-@rem If mode is -32, testing is finished
-if %failed% == "yes" (
-echo In above output, one or more of the various tests failed!
-exit /b 1
-)
-echo All OK
-goto :eof
-
-:runsub
-@rem Function to execute pcretest and compare the output
-@rem Arguments are as follows:
-@rem
-@rem 1 = test number
-@rem 2 = outputdir
-@rem 3 = test name use double quotes
-@rem 4 - 9 = pcretest options
-
-if [%1] == [] (
- echo Missing test number argument!
- exit /b 1
-)
-
-if [%2] == [] (
- echo Missing outputdir!
- exit /b 1
-)
-
-if [%3] == [] (
- echo Missing test name argument!
- exit /b 1
-)
-
-set testinput=testinput%1
-set testoutput=testoutput%1
-if exist %srcdir%\testdata\win%testinput% (
- set testinput=wintestinput%1
- set testoutput=wintestoutput%1
-)
-
-echo Test %1: %3
-%pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
-if errorlevel 1 (
- echo. failed executing command-line:
- echo. %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
- set failed="yes"
- goto :eof
-)
-
-set type=
-if [%1]==[11] (
- set type=-%bits%
-)
-if [%1]==[18] (
- set type=-%bits%
-)
-if [%1]==[21] (
- set type=-%bits%
-)
-if [%1]==[22] (
- set type=-%bits%
-)
-
-fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL
-
-if errorlevel 1 (
- echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
- if [%1]==[2] (
- echo.
- echo ** Test 2 requires a lot of stack. PCRE can be configured to
- echo ** use heap for recursion. Otherwise, to pass Test 2
- echo ** you generally need to allocate 8 mb stack to PCRE.
- echo ** See the 'pcrestack' page for a discussion of PCRE's
- echo ** stack usage.
- echo.
-)
- if [%1]==[3] (
- echo.
- echo ** Test 3 failure usually means french locale is not
- echo ** available on the system, rather than a bug or problem with PCRE.
- echo.
- goto :eof
-)
-
- set failed="yes"
- goto :eof
-)
-
-echo. Passed.
-goto :eof
-
-:do1
-call :runsub 1 testout "Main functionality (Compatible with Perl >= 5.10)" -q
-call :runsub 1 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do2
- call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q
- call :runsub 2 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do3
- call :runsub 3 testout "Locale-specific features" -q
- call :runsub 3 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do4
-if %utf% EQU 0 (
- echo Test 4 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
- call :runsub 4 testout "UTF-%bits% support - (Compatible with Perl >= 5.10)" -q
- call :runsub 4 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do5
-if %utf% EQU 0 (
- echo Test 5 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
- call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits%" -q
- call :runsub 5 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do6
-if %ucp% EQU 0 (
- echo Test 6 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 6 testout "Unicode property support (Compatible with Perl >= 5.10)" -q
- call :runsub 6 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 6 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do7
-if %ucp% EQU 0 (
- echo Test 7 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 7 testout "API, internals, and non-Perl stuff for Unicode property support" -q
- call :runsub 7 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 7 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do8
- call :runsub 8 testout "DFA matching main functionality" -q -dfa
- call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s
-goto :eof
-
-:do9
-if %utf% EQU 0 (
- echo Test 9 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
- call :runsub 9 testout "DFA matching with UTF-%bits%" -q -dfa
- call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s
- goto :eof
-
-:do10
-if %ucp% EQU 0 (
- echo Test 10 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa
- call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s
-goto :eof
-
-:do11
-if NOT %link_size% EQU 2 (
- echo Test 11 Skipped because link size is not 2.
- goto :eof
-)
-if %ucp% EQU 0 (
- echo Test 11 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 11 testout "Internal offsets and code size tests" -q
- call :runsub 11 testoutstudy "Test with Study Override" -q -s
-goto :eof
-
-:do12
-if %jit% EQU 0 (
- echo Test 12 Skipped due to absence of JIT support.
- goto :eof
-)
- call :runsub 12 testout "JIT-specific features (JIT available)" -q
-goto :eof
-
-:do13
-if %jit% EQU 1 (
- echo Test 13 Skipped due to presence of JIT support.
- goto :eof
-)
- call :runsub 13 testout "JIT-specific features (JIT not available)" -q
-goto :eof
-
-:do14
-if NOT %bits% EQU 8 (
- echo Test 14 Skipped when running 16/32-bit tests.
- goto :eof
-)
- copy /Y %srcdir%\testdata\saved16 testsaved16
- copy /Y %srcdir%\testdata\saved32 testsaved32
- call :runsub 14 testout "Specials for the basic 8-bit library" -q
- call :runsub 14 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 14 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do15
-if NOT %bits% EQU 8 (
- echo Test 15 Skipped when running 16/32-bit tests.
- goto :eof
-)
-if %utf% EQU 0 (
- echo Test 15 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
- call :runsub 15 testout "Specials for the 8-bit library with UTF-%bits% support" -q
- call :runsub 15 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 15 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do16
-if NOT %bits% EQU 8 (
- echo Test 16 Skipped when running 16/32-bit tests.
- goto :eof
-)
-if %ucp% EQU 0 (
- echo Test 16 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 16 testout "Specials for the 8-bit library with Unicode propery support" -q
- call :runsub 16 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 16 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do17
-if %bits% EQU 8 (
- echo Test 17 Skipped when running 8-bit tests.
- goto :eof
-)
- call :runsub 17 testout "Specials for the basic 16/32-bit library" -q
- call :runsub 17 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 17 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do18
-if %bits% EQU 8 (
- echo Test 18 Skipped when running 8-bit tests.
- goto :eof
-)
-if %utf% EQU 0 (
- echo Test 18 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
- call :runsub 18 testout "Specials for the 16/32-bit library with UTF-%bits% support" -q
- call :runsub 18 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 18 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do19
-if %bits% EQU 8 (
- echo Test 19 Skipped when running 8-bit tests.
- goto :eof
-)
-if %ucp% EQU 0 (
- echo Test 19 Skipped due to absence of Unicode property support.
- goto :eof
-)
- call :runsub 19 testout "Specials for the 16/32-bit library with Unicode property support" -q
- call :runsub 19 testoutstudy "Test with Study Override" -q -s
- if %jit% EQU 1 call :runsub 19 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do20
-if %bits% EQU 8 (
- echo Test 20 Skipped when running 8-bit tests.
- goto :eof
-)
- call :runsub 20 testout "DFA specials for the basic 16/32-bit library" -q -dfa
- call :runsub 20 testoutstudy "Test with Study Override" -q -dfa -s
-goto :eof
-
-:do21
-if %bits% EQU 8 (
- echo Test 21 Skipped when running 8-bit tests.
- goto :eof
-)
-if NOT %link_size% EQU 2 (
- echo Test 21 Skipped because link size is not 2.
- goto :eof
-)
-copy /Y %srcdir%\testdata\saved8 testsaved8
-copy /Y %srcdir%\testdata\saved16LE-1 testsaved16LE-1
-copy /Y %srcdir%\testdata\saved16BE-1 testsaved16BE-1
-copy /Y %srcdir%\testdata\saved32LE-1 testsaved32LE-1
-copy /Y %srcdir%\testdata\saved32BE-1 testsaved32BE-1
-call :runsub 21 testout "Reloads for the basic 16/32-bit library" -q
-call :runsub 21 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do22
-if %bits% EQU 8 (
- echo Test 22 Skipped when running 8-bit tests.
- goto :eof
-)
-if %utf% EQU 0 (
- echo Test 22 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
-if NOT %link_size% EQU 2 (
- echo Test 22 Skipped because link size is not 2.
- goto :eof
-)
-copy /Y %srcdir%\testdata\saved16LE-2 testsaved16LE-2
-copy /Y %srcdir%\testdata\saved16BE-2 testsaved16BE-2
-copy /Y %srcdir%\testdata\saved32LE-2 testsaved32LE-2
-copy /Y %srcdir%\testdata\saved32BE-2 testsaved32BE-2
-call :runsub 22 testout "Reloads for the 16/32-bit library with UTF-16/32 support" -q
-call :runsub 22 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do23
-if NOT %bits% EQU 16 (
- echo Test 23 Skipped when running 8/32-bit tests.
- goto :eof
-)
-call :runsub 23 testout "Specials for the 16-bit library" -q
-call :runsub 23 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 23 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do24
-if NOT %bits% EQU 16 (
- echo Test 24 Skipped when running 8/32-bit tests.
- goto :eof
-)
-if %utf% EQU 0 (
- echo Test 24 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
-call :runsub 24 testout "Specials for the 16-bit library with UTF-16 support" -q
-call :runsub 24 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 24 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do25
-if NOT %bits% EQU 32 (
- echo Test 25 Skipped when running 8/16-bit tests.
- goto :eof
-)
-call :runsub 25 testout "Specials for the 32-bit library" -q
-call :runsub 25 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 25 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:do26
-if NOT %bits% EQU 32 (
- echo Test 26 Skipped when running 8/16-bit tests.
- goto :eof
-)
-if %utf% EQU 0 (
- echo Test 26 Skipped due to absence of UTF-%bits% support.
- goto :eof
-)
-call :runsub 26 testout "Specials for the 32-bit library with UTF-32 support" -q
-call :runsub 26 testoutstudy "Test with Study Override" -q -s
-if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -s+
-goto :eof
-
-:conferror
-@echo.
-@echo Either your build is incomplete or you have a configuration error.
-@echo.
-@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
-@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat.
-@echo For manual testing of all available features, after configuring with cmake
-@echo and building, you can run the built pcre_test.bat. For best results with
-@echo cmake builds and tests avoid directories with full path names that include
-@echo spaces for source or build.
-@echo.
-@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
-@echo for input and verification should be found automatically when (from the
-@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
-@echo runs all tests compatible with the linked pcre library but it can be given
-@echo a test number as an argument.
-@echo.
-@echo If the build dir is not under the source dir you can either copy your exes
-@echo to the source folder or copy RunTest.bat and the testdata folder to the
-@echo location of your built exes and then run RunTest.bat.
-@echo.
-goto :eof
+@echo off +@rem This file must use CRLF linebreaks to function properly +@rem and requires both pcretest and pcregrep +@rem This file was originally contributed by Ralf Junker, and touched up by +@rem Daniel Richard G. Tests 10-12 added by Philip H. +@rem Philip H also changed test 3 to use "wintest" files. +@rem +@rem Updated by Tom Fortmann to support explicit test numbers on the command line. +@rem Added argument validation and added error reporting. +@rem +@rem MS Windows batch file to run pcretest on testfiles with the correct +@rem options. +@rem +@rem Sheri Pierce added logic to skip feature dependent tests +@rem tests 4 5 9 15 and 18 require utf support +@rem tests 6 7 10 16 and 19 require ucp support +@rem 11 requires ucp and link size 2 +@rem 12 requires presence of jit support +@rem 13 requires absence of jit support +@rem Sheri P also added override tests for study and jit testing +@rem Zoltan Herczeg added libpcre16 support +@rem Zoltan Herczeg added libpcre32 support + +setlocal enabledelayedexpansion +if [%srcdir%]==[] ( +if exist testdata\ set srcdir=.) +if [%srcdir%]==[] ( +if exist ..\testdata\ set srcdir=..) +if [%srcdir%]==[] ( +if exist ..\..\testdata\ set srcdir=..\..) +if NOT exist %srcdir%\testdata\ ( +Error: echo distribution testdata folder not found! +call :conferror +exit /b 1 +goto :eof +) + +if [%pcretest%]==[] set pcretest=.\pcretest.exe + +echo source dir is %srcdir% +echo pcretest=%pcretest% + +if NOT exist %pcretest% ( +echo Error: %pcretest% not found! +echo. +call :conferror +exit /b 1 +) + +%pcretest% -C linksize >NUL +set link_size=%ERRORLEVEL% +%pcretest% -C pcre8 >NUL +set support8=%ERRORLEVEL% +%pcretest% -C pcre16 >NUL +set support16=%ERRORLEVEL% +%pcretest% -C pcre32 >NUL +set support32=%ERRORLEVEL% +%pcretest% -C utf >NUL +set utf=%ERRORLEVEL% +%pcretest% -C ucp >NUL +set ucp=%ERRORLEVEL% +%pcretest% -C jit >NUL +set jit=%ERRORLEVEL% + +if %support8% EQU 1 ( +if not exist testout8 md testout8 +if not exist testoutstudy8 md testoutstudy8 +if not exist testoutjit8 md testoutjit8 +) + +if %support16% EQU 1 ( +if not exist testout16 md testout16 +if not exist testoutstudy16 md testoutstudy16 +if not exist testoutjit16 md testoutjit16 +) + +if %support16% EQU 1 ( +if not exist testout32 md testout32 +if not exist testoutstudy32 md testoutstudy32 +if not exist testoutjit32 md testoutjit32 +) + +set do1=no +set do2=no +set do3=no +set do4=no +set do5=no +set do6=no +set do7=no +set do8=no +set do9=no +set do10=no +set do11=no +set do12=no +set do13=no +set do14=no +set do15=no +set do16=no +set do17=no +set do18=no +set do19=no +set do20=no +set do21=no +set do22=no +set do23=no +set do24=no +set do25=no +set do26=no +set all=yes + +for %%a in (%*) do ( + set valid=no + for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26) do if %%v == %%a set valid=yes + if "!valid!" == "yes" ( + set do%%a=yes + set all=no +) else ( + echo Invalid test number - %%a! + echo Usage %0 [ test_number ] ... + echo Where test_number is one or more optional test numbers 1 through 26, default is all tests. + exit /b 1 +) +) +set failed="no" + +if "%all%" == "yes" ( + set do1=yes + set do2=yes + set do3=yes + set do4=yes + set do5=yes + set do6=yes + set do7=yes + set do8=yes + set do9=yes + set do10=yes + set do11=yes + set do12=yes + set do13=yes + set do14=yes + set do15=yes + set do16=yes + set do17=yes + set do18=yes + set do19=yes + set do20=yes + set do21=yes + set do22=yes + set do23=yes + set do24=yes + set do25=yes + set do26=yes +) + +@echo RunTest.bat's pcretest output is written to newly created subfolders named +@echo testout, testoutstudy and testoutjit. +@echo. + +set mode= +set bits=8 + +:nextMode +if "%mode%" == "" ( + if %support8% EQU 0 goto modeSkip + echo. + echo ---- Testing 8-bit library ---- + echo. +) +if "%mode%" == "-16" ( + if %support16% EQU 0 goto modeSkip + echo. + echo ---- Testing 16-bit library ---- + echo. +) +if "%mode%" == "-32" ( + if %support32% EQU 0 goto modeSkip + echo. + echo ---- Testing 32-bit library ---- + echo. +) +if "%do1%" == "yes" call :do1 +if "%do2%" == "yes" call :do2 +if "%do3%" == "yes" call :do3 +if "%do4%" == "yes" call :do4 +if "%do5%" == "yes" call :do5 +if "%do6%" == "yes" call :do6 +if "%do7%" == "yes" call :do7 +if "%do8%" == "yes" call :do8 +if "%do9%" == "yes" call :do9 +if "%do10%" == "yes" call :do10 +if "%do11%" == "yes" call :do11 +if "%do12%" == "yes" call :do12 +if "%do13%" == "yes" call :do13 +if "%do14%" == "yes" call :do14 +if "%do15%" == "yes" call :do15 +if "%do16%" == "yes" call :do16 +if "%do17%" == "yes" call :do17 +if "%do18%" == "yes" call :do18 +if "%do19%" == "yes" call :do19 +if "%do20%" == "yes" call :do20 +if "%do21%" == "yes" call :do21 +if "%do22%" == "yes" call :do22 +if "%do23%" == "yes" call :do23 +if "%do24%" == "yes" call :do24 +if "%do25%" == "yes" call :do25 +if "%do26%" == "yes" call :do26 +:modeSkip +if "%mode%" == "" ( + set mode=-16 + set bits=16 + goto nextMode +) +if "%mode%" == "-16" ( + set mode=-32 + set bits=32 + goto nextMode +) + +@rem If mode is -32, testing is finished +if %failed% == "yes" ( +echo In above output, one or more of the various tests failed! +exit /b 1 +) +echo All OK +goto :eof + +:runsub +@rem Function to execute pcretest and compare the output +@rem Arguments are as follows: +@rem +@rem 1 = test number +@rem 2 = outputdir +@rem 3 = test name use double quotes +@rem 4 - 9 = pcretest options + +if [%1] == [] ( + echo Missing test number argument! + exit /b 1 +) + +if [%2] == [] ( + echo Missing outputdir! + exit /b 1 +) + +if [%3] == [] ( + echo Missing test name argument! + exit /b 1 +) + +set testinput=testinput%1 +set testoutput=testoutput%1 +if exist %srcdir%\testdata\win%testinput% ( + set testinput=wintestinput%1 + set testoutput=wintestoutput%1 +) + +echo Test %1: %3 +%pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput% +if errorlevel 1 ( + echo. failed executing command-line: + echo. %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput% + set failed="yes" + goto :eof +) + +set type= +if [%1]==[11] ( + set type=-%bits% +) +if [%1]==[18] ( + set type=-%bits% +) +if [%1]==[21] ( + set type=-%bits% +) +if [%1]==[22] ( + set type=-%bits% +) + +fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL + +if errorlevel 1 ( + echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput% + if [%1]==[2] ( + echo. + echo ** Test 2 requires a lot of stack. PCRE can be configured to + echo ** use heap for recursion. Otherwise, to pass Test 2 + echo ** you generally need to allocate 8 mb stack to PCRE. + echo ** See the 'pcrestack' page for a discussion of PCRE's + echo ** stack usage. + echo. +) + if [%1]==[3] ( + echo. + echo ** Test 3 failure usually means french locale is not + echo ** available on the system, rather than a bug or problem with PCRE. + echo. + goto :eof +) + + set failed="yes" + goto :eof +) + +echo. Passed. +goto :eof + +:do1 +call :runsub 1 testout "Main functionality (Compatible with Perl >= 5.10)" -q +call :runsub 1 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do2 + call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q + call :runsub 2 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do3 + call :runsub 3 testout "Locale-specific features" -q + call :runsub 3 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do4 +if %utf% EQU 0 ( + echo Test 4 Skipped due to absence of UTF-%bits% support. + goto :eof +) + call :runsub 4 testout "UTF-%bits% support - (Compatible with Perl >= 5.10)" -q + call :runsub 4 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do5 +if %utf% EQU 0 ( + echo Test 5 Skipped due to absence of UTF-%bits% support. + goto :eof +) + call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits%" -q + call :runsub 5 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do6 +if %ucp% EQU 0 ( + echo Test 6 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 6 testout "Unicode property support (Compatible with Perl >= 5.10)" -q + call :runsub 6 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 6 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do7 +if %ucp% EQU 0 ( + echo Test 7 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 7 testout "API, internals, and non-Perl stuff for Unicode property support" -q + call :runsub 7 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 7 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do8 + call :runsub 8 testout "DFA matching main functionality" -q -dfa + call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s +goto :eof + +:do9 +if %utf% EQU 0 ( + echo Test 9 Skipped due to absence of UTF-%bits% support. + goto :eof +) + call :runsub 9 testout "DFA matching with UTF-%bits%" -q -dfa + call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s + goto :eof + +:do10 +if %ucp% EQU 0 ( + echo Test 10 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa + call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s +goto :eof + +:do11 +if NOT %link_size% EQU 2 ( + echo Test 11 Skipped because link size is not 2. + goto :eof +) +if %ucp% EQU 0 ( + echo Test 11 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 11 testout "Internal offsets and code size tests" -q + call :runsub 11 testoutstudy "Test with Study Override" -q -s +goto :eof + +:do12 +if %jit% EQU 0 ( + echo Test 12 Skipped due to absence of JIT support. + goto :eof +) + call :runsub 12 testout "JIT-specific features (JIT available)" -q +goto :eof + +:do13 +if %jit% EQU 1 ( + echo Test 13 Skipped due to presence of JIT support. + goto :eof +) + call :runsub 13 testout "JIT-specific features (JIT not available)" -q +goto :eof + +:do14 +if NOT %bits% EQU 8 ( + echo Test 14 Skipped when running 16/32-bit tests. + goto :eof +) + copy /Y %srcdir%\testdata\saved16 testsaved16 + copy /Y %srcdir%\testdata\saved32 testsaved32 + call :runsub 14 testout "Specials for the basic 8-bit library" -q + call :runsub 14 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 14 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do15 +if NOT %bits% EQU 8 ( + echo Test 15 Skipped when running 16/32-bit tests. + goto :eof +) +if %utf% EQU 0 ( + echo Test 15 Skipped due to absence of UTF-%bits% support. + goto :eof +) + call :runsub 15 testout "Specials for the 8-bit library with UTF-%bits% support" -q + call :runsub 15 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 15 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do16 +if NOT %bits% EQU 8 ( + echo Test 16 Skipped when running 16/32-bit tests. + goto :eof +) +if %ucp% EQU 0 ( + echo Test 16 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 16 testout "Specials for the 8-bit library with Unicode propery support" -q + call :runsub 16 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 16 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do17 +if %bits% EQU 8 ( + echo Test 17 Skipped when running 8-bit tests. + goto :eof +) + call :runsub 17 testout "Specials for the basic 16/32-bit library" -q + call :runsub 17 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 17 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do18 +if %bits% EQU 8 ( + echo Test 18 Skipped when running 8-bit tests. + goto :eof +) +if %utf% EQU 0 ( + echo Test 18 Skipped due to absence of UTF-%bits% support. + goto :eof +) + call :runsub 18 testout "Specials for the 16/32-bit library with UTF-%bits% support" -q + call :runsub 18 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 18 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do19 +if %bits% EQU 8 ( + echo Test 19 Skipped when running 8-bit tests. + goto :eof +) +if %ucp% EQU 0 ( + echo Test 19 Skipped due to absence of Unicode property support. + goto :eof +) + call :runsub 19 testout "Specials for the 16/32-bit library with Unicode property support" -q + call :runsub 19 testoutstudy "Test with Study Override" -q -s + if %jit% EQU 1 call :runsub 19 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do20 +if %bits% EQU 8 ( + echo Test 20 Skipped when running 8-bit tests. + goto :eof +) + call :runsub 20 testout "DFA specials for the basic 16/32-bit library" -q -dfa + call :runsub 20 testoutstudy "Test with Study Override" -q -dfa -s +goto :eof + +:do21 +if %bits% EQU 8 ( + echo Test 21 Skipped when running 8-bit tests. + goto :eof +) +if NOT %link_size% EQU 2 ( + echo Test 21 Skipped because link size is not 2. + goto :eof +) +copy /Y %srcdir%\testdata\saved8 testsaved8 +copy /Y %srcdir%\testdata\saved16LE-1 testsaved16LE-1 +copy /Y %srcdir%\testdata\saved16BE-1 testsaved16BE-1 +copy /Y %srcdir%\testdata\saved32LE-1 testsaved32LE-1 +copy /Y %srcdir%\testdata\saved32BE-1 testsaved32BE-1 +call :runsub 21 testout "Reloads for the basic 16/32-bit library" -q +call :runsub 21 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do22 +if %bits% EQU 8 ( + echo Test 22 Skipped when running 8-bit tests. + goto :eof +) +if %utf% EQU 0 ( + echo Test 22 Skipped due to absence of UTF-%bits% support. + goto :eof +) +if NOT %link_size% EQU 2 ( + echo Test 22 Skipped because link size is not 2. + goto :eof +) +copy /Y %srcdir%\testdata\saved16LE-2 testsaved16LE-2 +copy /Y %srcdir%\testdata\saved16BE-2 testsaved16BE-2 +copy /Y %srcdir%\testdata\saved32LE-2 testsaved32LE-2 +copy /Y %srcdir%\testdata\saved32BE-2 testsaved32BE-2 +call :runsub 22 testout "Reloads for the 16/32-bit library with UTF-16/32 support" -q +call :runsub 22 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do23 +if NOT %bits% EQU 16 ( + echo Test 23 Skipped when running 8/32-bit tests. + goto :eof +) +call :runsub 23 testout "Specials for the 16-bit library" -q +call :runsub 23 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 23 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do24 +if NOT %bits% EQU 16 ( + echo Test 24 Skipped when running 8/32-bit tests. + goto :eof +) +if %utf% EQU 0 ( + echo Test 24 Skipped due to absence of UTF-%bits% support. + goto :eof +) +call :runsub 24 testout "Specials for the 16-bit library with UTF-16 support" -q +call :runsub 24 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 24 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do25 +if NOT %bits% EQU 32 ( + echo Test 25 Skipped when running 8/16-bit tests. + goto :eof +) +call :runsub 25 testout "Specials for the 32-bit library" -q +call :runsub 25 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 25 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:do26 +if NOT %bits% EQU 32 ( + echo Test 26 Skipped when running 8/16-bit tests. + goto :eof +) +if %utf% EQU 0 ( + echo Test 26 Skipped due to absence of UTF-%bits% support. + goto :eof +) +call :runsub 26 testout "Specials for the 32-bit library with UTF-32 support" -q +call :runsub 26 testoutstudy "Test with Study Override" -q -s +if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -s+ +goto :eof + +:conferror +@echo. +@echo Either your build is incomplete or you have a configuration error. +@echo. +@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS" +@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat. +@echo For manual testing of all available features, after configuring with cmake +@echo and building, you can run the built pcre_test.bat. For best results with +@echo cmake builds and tests avoid directories with full path names that include +@echo spaces for source or build. +@echo. +@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed +@echo for input and verification should be found automatically when (from the +@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat +@echo runs all tests compatible with the linked pcre library but it can be given +@echo a test number as an argument. +@echo. +@echo If the build dir is not under the source dir you can either copy your exes +@echo to the source folder or copy RunTest.bat and the testdata folder to the +@echo location of your built exes and then run RunTest.bat. +@echo. +goto :eof diff --git a/plugin/auth_dialog/CMakeLists.txt b/plugin/auth_dialog/CMakeLists.txt index 9b4dcfd99bf..a23518060be 100644 --- a/plugin/auth_dialog/CMakeLists.txt +++ b/plugin/auth_dialog/CMakeLists.txt @@ -15,4 +15,4 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA MYSQL_ADD_PLUGIN(dialog dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c - MODULE_ONLY COMPONENT SharedLibraries) + MODULE_ONLY COMPONENT ClientPlugins) diff --git a/plugin/auth_dialog/dialog.c b/plugin/auth_dialog/dialog.c index 0fa5ab93a35..da937ea6e91 100644 --- a/plugin/auth_dialog/dialog.c +++ b/plugin/auth_dialog/dialog.c @@ -25,6 +25,8 @@ the answer back to the server. No encryption is involved, the answers are sent in clear text. */ +#define _GNU_SOURCE 1 /* for RTLD_DEFAULT */ + #include <my_global.h> #include <mysql/client_plugin.h> #include <mysql.h> diff --git a/plugin/auth_examples/CMakeLists.txt b/plugin/auth_examples/CMakeLists.txt index f6c2b637067..c7b7e5be62d 100644 --- a/plugin/auth_examples/CMakeLists.txt +++ b/plugin/auth_examples/CMakeLists.txt @@ -30,4 +30,4 @@ MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c MYSQL_ADD_PLUGIN(auth_0x0100 auth_0x0100.c MODULE_ONLY COMPONENT Test) MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c - MODULE_ONLY COMPONENT SharedLibraries) + MODULE_ONLY COMPONENT ClientPlugins) diff --git a/plugin/handler_socket/CMakeLists.txt b/plugin/handler_socket/CMakeLists.txt index 358139eda1e..2e7caa80897 100644 --- a/plugin/handler_socket/CMakeLists.txt +++ b/plugin/handler_socket/CMakeLists.txt @@ -6,9 +6,7 @@ IF(WIN32) ENDIF() #Remove -fno-implicit-templates from compiler flags(handlersocket would not work with it) -IF(CMAKE_COMPILER_IS_GNUCXX) - STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -ENDIF() +STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) INCLUDE_DIRECTORIES(libhsclient) diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 84626c02f8c..1c91c66759d 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -1128,6 +1128,8 @@ static size_t escape_string(const char *str, unsigned int len, *(result++)= '\\'; *(result++)= '\\'; } + else if (is_space(*str)) + *(result++)= ' '; else *(result++)= *str; str++; @@ -1183,9 +1185,15 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len, for (c=0; c<d_len; c++) result[c]= is_space(str[c]) ? ' ' : str[c]; - memmove(result + d_len, "*****", 5); - result+= d_len + 5; - b_char= *(next_s++); + if (*next_s) + { + memmove(result + d_len, "*****", 5); + result+= d_len + 5; + b_char= *(next_s++); + } + else + result+= d_len; + while (*next_s) { if (*next_s == b_char) diff --git a/plugin/win_auth_client/CMakeLists.txt b/plugin/win_auth_client/CMakeLists.txt index 75ee55117bd..5d72d24d6ad 100644 --- a/plugin/win_auth_client/CMakeLists.txt +++ b/plugin/win_auth_client/CMakeLists.txt @@ -29,7 +29,7 @@ IF(WIN32) MYSQL_ADD_PLUGIN(authentication_windows_client ${PLUGIN_SOURCES} ${HEADERS} LINK_LIBRARIES Secur32 - MODULE_ONLY COMPONENT SharedLibraries) + MODULE_ONLY COMPONENT ClientPlugins) #IF(MSVC) # INSTALL_DEBUG_TARGET(auth_win_client DESTINATION ${INSTALL_LIBDIR}/debug) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 68a051f7249..13fc69912f6 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -149,22 +149,16 @@ SET(CONFIGURE_LINE "Built using CMake") # Also required for mysqlbug, autoconf only supports --version so for now we # just explicitly require GNU -IF(CMAKE_COMPILER_IS_GNUCC) - EXECUTE_PROCESS( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version - COMMAND sed 1q - OUTPUT_VARIABLE CC_VERSION) -ELSE() - SET(CC_VERSION "") -ENDIF() -IF(CMAKE_COMPILER_IS_GNUCXX) - EXECUTE_PROCESS( - COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version - COMMAND sed 1q - OUTPUT_VARIABLE CXX_VERSION) -ELSE() - SET(CXX_VERSION "") -ENDIF() +EXECUTE_PROCESS( + COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version + COMMAND sed 1q + ERROR_QUIET + OUTPUT_VARIABLE CC_VERSION) +EXECUTE_PROCESS( + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version + COMMAND sed 1q + ERROR_QUIET + OUTPUT_VARIABLE CXX_VERSION) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqlbug.sh ${CMAKE_CURRENT_BINARY_DIR}/mysqlbug ESCAPE_QUOTES @ONLY) diff --git a/sql-common/client.c b/sql-common/client.c index 3816a4ea135..9f4225ec6ae 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1848,6 +1848,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , mysql_options(mysql, MYSQL_OPT_SSL_CAPATH, capath) | mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, cipher) ? 1 : 0); + mysql->options.use_ssl= TRUE; #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */ DBUG_RETURN(result); } @@ -2652,16 +2653,10 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, mysql->client_flag|= CLIENT_MULTI_RESULTS; #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) - if (mysql->options.ssl_key || mysql->options.ssl_cert || - mysql->options.ssl_ca || mysql->options.ssl_capath || - mysql->options.ssl_cipher || - (mysql->options.extension && - (mysql->options.extension->ssl_crl || - mysql->options.extension->ssl_crlpath))) - mysql->options.use_ssl= 1; if (mysql->options.use_ssl) mysql->client_flag|= CLIENT_SSL; #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY*/ + if (mpvio->db) mysql->client_flag|= CLIENT_CONNECT_WITH_DB; @@ -2690,6 +2685,23 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, end= buff+5; } #ifdef HAVE_OPENSSL + + /* + If client uses ssl and client also has to verify the server + certificate, a ssl connection is required. + If the server does not support ssl, we abort the connection. + */ + if (mysql->options.use_ssl && + (mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) && + !(mysql->server_capabilities & CLIENT_SSL)) + { + set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate, + ER(CR_SSL_CONNECTION_ERROR), + "SSL is required, but the server does not " + "support it"); + goto error; + } + if (mysql->client_flag & CLIENT_SSL) { /* Do the SSL layering. */ diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 6a011df795a..28757a2c96c 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1314,16 +1314,8 @@ int number_to_time(my_bool neg, ulonglong nr, ulong sec_part, MYSQL_TIME *ltime, int *was_cut) { if (nr > 9999999 && nr < 99991231235959ULL && neg == 0) - { - if (number_to_datetime(nr, sec_part, ltime, - TIME_INVALID_DATES, was_cut) < 0) - return -1; - - ltime->year= ltime->month= ltime->day= 0; - ltime->time_type= MYSQL_TIMESTAMP_TIME; - *was_cut= MYSQL_TIME_NOTE_TRUNCATED; - return 0; - } + return number_to_datetime(nr, sec_part, ltime, + TIME_INVALID_DATES, was_cut) < 0 ? -1 : 0; *was_cut= 0; ltime->year= ltime->month= ltime->day= 0; diff --git a/sql/field.cc b/sql/field.cc index b85a0024988..3fcae19237b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1331,18 +1331,13 @@ int Field_num::check_int(CHARSET_INFO *cs, const char *str, int length, if (str == int_end || error == MY_ERRNO_EDOM) { ErrConvString err(str, length, cs); - push_warning_printf(get_thd(), Sql_condition::WARN_LEVEL_WARN, - ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, - ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), - "integer", err.ptr(), field_name, - (ulong) table->in_use->get_stmt_da()-> - current_row_for_warning()); + set_warning_truncated_wrong_value("integer", err.ptr()); return 1; } /* Test if we have garbage at the end of the given string. */ if (test_if_important_data(cs, int_end, str + length)) { - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); return 2; } return 0; @@ -1411,7 +1406,7 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len, return 0; out_of_range: - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } @@ -1432,12 +1427,12 @@ int Field::warn_if_overflow(int op_result) { if (op_result == E_DEC_OVERFLOW) { - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } if (op_result == E_DEC_TRUNCATED) { - set_warning(Sql_condition::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); + set_note(WARN_DATA_TRUNCATED, 1); /* We return 0 here as this is not a critical issue */ } return 0; @@ -1763,7 +1758,7 @@ longlong Field::convert_decimal2longlong(const my_decimal *val, { if (val->sign()) { - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); i= 0; *err= 1; } @@ -2071,7 +2066,7 @@ void Field_decimal::overflow(bool negative) uint len=field_length; uchar *to=ptr, filler= '9'; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); if (negative) { if (!unsigned_flag) @@ -2179,7 +2174,7 @@ int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) from++; if (from == end) { - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); is_cuted_fields_incr=1; } else if (*from == '+' || *from == '-') // Found some sign ? @@ -2255,7 +2250,7 @@ int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) for (;from != end && my_isspace(&my_charset_bin, *from); from++) ; if (from != end) // If still something left, warn { - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); is_cuted_fields_incr=1; } } @@ -2433,8 +2428,7 @@ int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) if (tmp_char != '0') // Losing a non zero digit ? { if (!is_cuted_fields_incr) - set_warning(Sql_condition::WARN_LEVEL_WARN, - WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); return 0; } continue; @@ -2456,7 +2450,7 @@ int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) This is a note, not a warning, as we don't want to abort when we cut decimals in strict mode */ - set_warning(Sql_condition::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); + set_note(WARN_DATA_TRUNCATED, 1); } return 0; } @@ -2657,7 +2651,7 @@ void Field_decimal::sql_type(String &res) const if (dec) tmp--; res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(), - "decimal(%d,%d)",tmp,dec)); + "decimal(%d,%d)/*old*/",tmp,dec)); add_zerofill_and_unsigned(res); } @@ -2806,7 +2800,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value) if (unsigned_flag && decimal_value->sign()) { DBUG_PRINT("info", ("unsigned overflow")); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; decimal_value= &decimal_zero; } @@ -2850,32 +2844,22 @@ int Field_new_decimal::store(const char *from, uint length, thd->abort_on_warning) { ErrConvString errmsg(from, length, charset_arg); - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, - ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), - "decimal", errmsg.ptr(), field_name, - static_cast<ulong>(thd->get_stmt_da()-> - current_row_for_warning())); + set_warning_truncated_wrong_value("decimal", errmsg.ptr()); DBUG_RETURN(err); } switch (err) { case E_DEC_TRUNCATED: - set_warning(Sql_condition::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); + set_note(WARN_DATA_TRUNCATED, 1); break; case E_DEC_OVERFLOW: - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); set_value_on_overflow(&decimal_value, decimal_value.sign()); break; case E_DEC_BAD_NUM: { ErrConvString errmsg(from, length, charset_arg); - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, - ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), - "decimal", errmsg.ptr(), field_name, - static_cast<ulong>(thd->get_stmt_da()-> - current_row_for_warning())); + set_warning_truncated_wrong_value("decimal", errmsg.ptr()); my_decimal_set_zero(&decimal_value); break; } @@ -3182,13 +3166,13 @@ int Field_tiny::store(double nr) if (nr < 0.0) { *ptr=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > 255.0) { *ptr= (uchar) 255; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3199,13 +3183,13 @@ int Field_tiny::store(double nr) if (nr < -128.0) { *ptr= (uchar) -128; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > 127.0) { *ptr=127; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3225,13 +3209,13 @@ int Field_tiny::store(longlong nr, bool unsigned_val) if (nr < 0 && !unsigned_val) { *ptr= 0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if ((ulonglong) nr > (ulonglong) 255) { *ptr= (char) 255; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3244,13 +3228,13 @@ int Field_tiny::store(longlong nr, bool unsigned_val) if (nr < -128) { *ptr= (char) -128; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > 127) { *ptr=127; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3361,13 +3345,13 @@ int Field_short::store(double nr) if (nr < 0) { res=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > (double) UINT_MAX16) { res=(int16) UINT_MAX16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3378,13 +3362,13 @@ int Field_short::store(double nr) if (nr < (double) INT_MIN16) { res=INT_MIN16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > (double) INT_MAX16) { res=INT_MAX16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3406,13 +3390,13 @@ int Field_short::store(longlong nr, bool unsigned_val) if (nr < 0L && !unsigned_val) { res=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if ((ulonglong) nr > (ulonglong) UINT_MAX16) { res=(int16) UINT_MAX16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3426,13 +3410,13 @@ int Field_short::store(longlong nr, bool unsigned_val) if (nr < INT_MIN16) { res=INT_MIN16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > (longlong) INT_MAX16) { res=INT_MAX16; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3549,14 +3533,14 @@ int Field_medium::store(double nr) if (nr < 0) { int3store(ptr,0); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr >= (double) (long) (1L << 24)) { uint32 tmp=(uint32) (1L << 24)-1L; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3568,14 +3552,14 @@ int Field_medium::store(double nr) { long tmp=(long) INT_MIN24; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > (double) INT_MAX24) { long tmp=(long) INT_MAX24; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3595,14 +3579,14 @@ int Field_medium::store(longlong nr, bool unsigned_val) if (nr < 0 && !unsigned_val) { int3store(ptr,0); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if ((ulonglong) nr >= (ulonglong) (long) (1L << 24)) { long tmp= (long) (1L << 24)-1L; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3617,14 +3601,14 @@ int Field_medium::store(longlong nr, bool unsigned_val) { long tmp= (long) INT_MIN24; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (nr > (longlong) INT_MAX24) { long tmp=(long) INT_MAX24; int3store(ptr,tmp); - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3746,7 +3730,7 @@ int Field_long::store(double nr) else if (nr > (double) UINT_MAX32) { res= UINT_MAX32; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else @@ -3768,7 +3752,7 @@ int Field_long::store(double nr) res=(int32) (longlong) nr; } if (error) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); int4store(ptr,res); return error; @@ -3814,7 +3798,7 @@ int Field_long::store(longlong nr, bool unsigned_val) res=(int32) nr; } if (error) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); int4store(ptr,res); return error; @@ -3913,7 +3897,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) tmp= cs->cset->strntoull10rnd(cs,from,len,unsigned_flag,&end,&error); if (error == MY_ERRNO_ERANGE) { - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (get_thd()->count_cuted_fields && @@ -3935,7 +3919,7 @@ int Field_longlong::store(double nr) res= double_to_longlong(nr, unsigned_flag, &error); if (error) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); int8store(ptr,res); return error; @@ -3956,7 +3940,7 @@ int Field_longlong::store(longlong nr, bool unsigned_val) if (unsigned_flag != unsigned_val) { nr= unsigned_flag ? (ulonglong) 0 : (ulonglong) LONGLONG_MAX; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } } @@ -4070,8 +4054,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (!len || ((uint) (end-from) != len && get_thd()->count_cuted_fields))) { - set_warning(Sql_condition::WARN_LEVEL_WARN, - (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); + set_warning(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED, 1); error= error ? 1 : 2; } Field_float::store(nr); @@ -4087,7 +4070,7 @@ int Field_float::store(double nr) unsigned_flag, FLT_MAX); if (error) { - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); if (error < 0) // Wrong double value { error= 1; @@ -4258,8 +4241,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (!len || ((uint) (end-from) != len && get_thd()->count_cuted_fields))) { - set_warning(Sql_condition::WARN_LEVEL_WARN, - (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); + set_warning(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED, 1); error= error ? 1 : 2; } Field_double::store(nr); @@ -4275,7 +4257,7 @@ int Field_double::store(double nr) unsigned_flag, DBL_MAX); if (error) { - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); if (error < 0) // Wrong double value { error= 1; @@ -4637,7 +4619,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, MYSQL_TIME *l_time, if (MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut) || !have_smth_to_conv) { error= 1; - set_datetime_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, + set_datetime_warning(WARN_DATA_TRUNCATED, str, MYSQL_TIMESTAMP_DATETIME, 1); } else if (MYSQL_TIME_WARN_HAVE_NOTES(was_cut)) @@ -4655,7 +4637,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, MYSQL_TIME *l_time, conversion_error= ER_WARN_DATA_OUT_OF_RANGE; if (conversion_error) { - set_datetime_warning(Sql_condition::WARN_LEVEL_WARN, conversion_error, + set_datetime_warning(conversion_error, str, MYSQL_TIMESTAMP_DATETIME, !error); error= 1; } @@ -5166,7 +5148,7 @@ void Field_temporal::set_warnings(Sql_condition::enum_warning_level trunc_level, set_datetime_warning(trunc_level, WARN_DATA_TRUNCATED, str, mysql_type_to_time_type(type()), 1); if (was_cut & MYSQL_TIME_WARN_OUT_OF_RANGE) - set_datetime_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, + set_datetime_warning(ER_WARN_DATA_OUT_OF_RANGE, str, mysql_type_to_time_type(type()), 1); } @@ -5720,7 +5702,7 @@ int Field_year::store(const char *from, uint len,CHARSET_INFO *cs) error == MY_ERRNO_ERANGE) { *ptr=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } if (get_thd()->count_cuted_fields && @@ -5763,7 +5745,7 @@ int Field_year::store(longlong nr, bool unsigned_val) if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155) { *ptr= 0; - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } if (nr != 0 || field_length != 4) // 0000 -> 0; 00 -> 2000 @@ -5784,8 +5766,7 @@ int Field_year::store_time_dec(MYSQL_TIME *ltime, uint dec) if (Field_year::store(ltime->year, 0)) return 1; - set_datetime_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, - &str, ltime->time_type, 1); + set_datetime_warning(WARN_DATA_TRUNCATED, &str, ltime->time_type, 1); return 0; } @@ -6357,14 +6338,7 @@ Field_longstr::check_string_copy_error(const String_copier *copier, return FALSE; convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6); - - THD *thd= get_thd(); - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, - ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), - "string", tmp, field_name, - thd->get_stmt_da()->current_row_for_warning()); + set_warning_truncated_wrong_value("string", tmp); return TRUE; } @@ -6399,14 +6373,14 @@ Field_longstr::report_if_important_data(const char *pstr, const char *end, if (test_if_important_data(field_charset, pstr, end)) { if (thd->abort_on_warning) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_DATA_TOO_LONG, 1); + set_warning(ER_DATA_TOO_LONG, 1); else - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); return 2; } else if (count_spaces) { /* If we lost only spaces then produce a NOTE, not a WARNING */ - set_warning(Sql_condition::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); + set_note(WARN_DATA_TRUNCATED, 1); return 2; } } @@ -6463,9 +6437,9 @@ int Field_str::store(double nr) if (error) { if (get_thd()->abort_on_warning) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_DATA_TOO_LONG, 1); + set_warning(ER_DATA_TOO_LONG, 1); else - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); } return store(buff, length, &my_charset_numeric); } @@ -8090,6 +8064,14 @@ err_exit: return -1; } +Field::geometry_type Field_geom::geometry_type_merge(geometry_type a, + geometry_type b) +{ + if (a == b) + return a; + return Field::GEOM_GEOMETRY; +} + #endif /*HAVE_SPATIAL*/ /**************************************************************************** @@ -8150,13 +8132,13 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) if (err || end != from+length || tmp > typelib->count) { tmp=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); } if (!get_thd()->count_cuted_fields) err= 0; } else - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); } store_type((ulonglong) tmp); return err; @@ -8175,7 +8157,7 @@ int Field_enum::store(longlong nr, bool unsigned_val) int error= 0; if ((ulonglong) nr > typelib->count || nr == 0) { - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); if (nr != 0 || get_thd()->count_cuted_fields) { nr= 0; @@ -8328,11 +8310,11 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs) tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1)) { tmp=0; - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); } } else if (got_warning) - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); store_type(tmp); return err; } @@ -8352,7 +8334,7 @@ int Field_set::store(longlong nr, bool unsigned_val) if ((ulonglong) nr > max_nr) { nr&= max_nr; - set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + set_warning(WARN_DATA_TRUNCATED, 1); error=1; } store_type((ulonglong) nr); @@ -8729,9 +8711,9 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs) set_rec_bits((1 << bit_len) - 1, bit_ptr, bit_ofs, bit_len); memset(ptr, 0xff, bytes_in_rec); if (get_thd()->really_abort_on_warning()) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_DATA_TOO_LONG, 1); + set_warning(ER_DATA_TOO_LONG, 1); else - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } /* delta is >= -1 here */ @@ -9166,9 +9148,9 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) if (bits) *ptr&= ((1 << bits) - 1); /* set first uchar */ if (get_thd()->really_abort_on_warning()) - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_DATA_TOO_LONG, 1); + set_warning(ER_DATA_TOO_LONG, 1); else - set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); return 1; } bzero(ptr, delta); @@ -10261,6 +10243,19 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level, } +void Field::set_warning_truncated_wrong_value(const char *type, + const char *value) +{ + THD *thd= get_thd(); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, + ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), + type, value, field_name, + static_cast<ulong>(thd->get_stmt_da()-> + current_row_for_warning())); +} + + /* @brief Return possible keys for a field diff --git a/sql/field.h b/sql/field.h index 777c72db906..da353f70745 100644 --- a/sql/field.h +++ b/sql/field.h @@ -900,14 +900,32 @@ public: virtual int set_time() { return 1; } bool set_warning(Sql_condition::enum_warning_level, unsigned int code, int cuted_increment) const; +protected: + bool set_warning(unsigned int code, int cuted_increment) const + { + return set_warning(Sql_condition::WARN_LEVEL_WARN, code, cuted_increment); + } + bool set_note(unsigned int code, int cuted_increment) const + { + return set_warning(Sql_condition::WARN_LEVEL_NOTE, code, cuted_increment); + } void set_datetime_warning(Sql_condition::enum_warning_level, uint code, const ErrConv *str, timestamp_type ts_type, int cuted_increment) const; + void set_datetime_warning(uint code, + const ErrConv *str, timestamp_type ts_type, + int cuted_increment) const + { + set_datetime_warning(Sql_condition::WARN_LEVEL_WARN, code, str, ts_type, + cuted_increment); + } + void set_warning_truncated_wrong_value(const char *type, const char *value); inline bool check_overflow(int op_result) { return (op_result == E_DEC_OVERFLOW); } int warn_if_overflow(int op_result); +public: void set_table_name(String *alias) { table_name= &alias->Ptr; @@ -2694,6 +2712,7 @@ public: int reset(void) { return Field_blob::reset() || !maybe_null(); } geometry_type get_geometry_type() { return geom_type; }; + static geometry_type geometry_type_merge(geometry_type, geometry_type); uint get_srid() { return srid; } }; diff --git a/sql/filesort.cc b/sql/filesort.cc index 58f7ecd51ee..4e8273e27d2 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, Monty Program Ab. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2009, 2015, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/handler.cc b/sql/handler.cc index 8d69a93c2c1..d4d796b779d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2331,9 +2331,11 @@ handle_condition(THD *, } -/** @brief - This should return ENOENT if the file doesn't exists. - The .frm file will be deleted only if we return 0 or ENOENT +/** delete a table in the engine + + @note + ENOENT and HA_ERR_NO_SUCH_TABLE are not considered errors. + The .frm file will be deleted only if we return 0. */ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, const char *db, const char *alias, bool generate_warning) @@ -2348,47 +2350,66 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, /* table_type is NULL in ALTER TABLE when renaming only .frm files */ if (table_type == NULL || table_type == view_pseudo_hton || ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type))) - DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); + DBUG_RETURN(0); bzero((char*) &dummy_table, sizeof(dummy_table)); bzero((char*) &dummy_share, sizeof(dummy_share)); dummy_table.s= &dummy_share; path= get_canonical_filename(file, path, tmp_path); - if ((error= file->ha_delete_table(path)) && generate_warning) + if ((error= file->ha_delete_table(path))) { /* - Because file->print_error() use my_error() to generate the error message - we use an internal error handler to intercept it and store the text - in a temporary buffer. Later the message will be presented to user - as a warning. + it's not an error if the table doesn't exist in the engine. + warn the user, but still report DROP being a success */ - Ha_delete_table_error_handler ha_delete_table_error_handler; - - /* Fill up strucutures that print_error may need */ - dummy_share.path.str= (char*) path; - dummy_share.path.length= strlen(path); - dummy_share.normalized_path= dummy_share.path; - dummy_share.db.str= (char*) db; - dummy_share.db.length= strlen(db); - dummy_share.table_name.str= (char*) alias; - dummy_share.table_name.length= strlen(alias); - dummy_table.alias.set(alias, dummy_share.table_name.length, - table_alias_charset); + bool intercept= error == ENOENT || error == HA_ERR_NO_SUCH_TABLE; - file->change_table_ptr(&dummy_table, &dummy_share); - - thd->push_internal_handler(&ha_delete_table_error_handler); - file->print_error(error, 0); + if (!intercept || generate_warning) + { + /* + Because file->print_error() use my_error() to generate the error message + we use an internal error handler to intercept it and store the text + in a temporary buffer. Later the message will be presented to user + as a warning. + */ + Ha_delete_table_error_handler ha_delete_table_error_handler; + + /* Fill up strucutures that print_error may need */ + dummy_share.path.str= (char*) path; + dummy_share.path.length= strlen(path); + dummy_share.normalized_path= dummy_share.path; + dummy_share.db.str= (char*) db; + dummy_share.db.length= strlen(db); + dummy_share.table_name.str= (char*) alias; + dummy_share.table_name.length= strlen(alias); + dummy_table.alias.set(alias, dummy_share.table_name.length, + table_alias_charset); + + file->change_table_ptr(&dummy_table, &dummy_share); + +#if MYSQL_VERSION_ID > 100105 + // XXX as an ugly 10.0-only hack we intercept HA_ERR_ROW_IS_REFERENCED, + // to report it under the old historical error number. +#error remove HA_ERR_ROW_IS_REFERENCED, use ME_JUST_WARNING instead of a handler +#endif + if (intercept || error == HA_ERR_ROW_IS_REFERENCED) + thd->push_internal_handler(&ha_delete_table_error_handler); - thd->pop_internal_handler(); + file->print_error(error, 0); - /* - XXX: should we convert *all* errors to warnings here? - What if the error is fatal? - */ - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, error, - ha_delete_table_error_handler.buff); + if (intercept || error == HA_ERR_ROW_IS_REFERENCED) + { + thd->pop_internal_handler(); + if (error == HA_ERR_ROW_IS_REFERENCED) + my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0)); + else + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, error, + ha_delete_table_error_handler.buff); + } + } + if (intercept) + error= 0; } delete file; diff --git a/sql/item.cc b/sql/item.cc index eb82bec7f7c..b4de9732b59 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1046,6 +1046,42 @@ Item *Item::safe_charset_converter(CHARSET_INFO *tocs) /** + Some pieces of the code do not support changing of + Item_cache to other Item types. + + Example: + Item_singlerow_subselect has "Item_cache **row". + Creating of Item_func_conv_charset followed by THD::change_item_tree() + should not change row[i] from Item_cache directly to Item_func_conv_charset, because Item_singlerow_subselect + because Item_singlerow_subselect later calls Item_cache-specific methods, + e.g. row[i]->store() and row[i]->cache_value(). + + Let's wrap Item_func_conv_charset in a new Item_cache, + so the Item_cache-specific methods can still be used for + Item_singlerow_subselect::row[i] safely. + + As a bonus we cache the converted value, instead of converting every time + + TODO: we should eventually check all other use cases of change_item_tree(). + Perhaps some more potentially dangerous substitution examples exist. +*/ +Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs) +{ + if (!example) + return Item::safe_charset_converter(tocs); + Item *conv= example->safe_charset_converter(tocs); + if (conv == example) + return this; + Item_cache *cache; + if (!conv || !(cache= new Item_cache_str(conv))) + return NULL; // Safe conversion is not possible, or OEM + cache->setup(conv); + cache->fixed= false; // Make Item::fix_fields() happy + return cache; +} + + +/** @details Created mostly for mysql_prepare_table(). Important when a string ENUM/SET column is described with a numeric default value: @@ -9382,6 +9418,11 @@ bool Item_type_holder::join_types(THD *thd, Item *item) item_decimals= 0; decimals= MY_MAX(decimals, item_decimals); } + + if (fld_type == FIELD_TYPE_GEOMETRY) + geometry_type= + Field_geom::geometry_type_merge(geometry_type, item->get_geometry_type()); + if (Field::result_merge_type(fld_type) == DECIMAL_RESULT) { decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE); diff --git a/sql/item.h b/sql/item.h index bcb4df04c64..825435908c3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4679,7 +4679,6 @@ class Item_cache: public Item_basic_constant { protected: Item *example; - table_map used_table_map; /** Field that this object will get value from. This is used by index-based subquery engines to detect and remove the equality injected @@ -4697,7 +4696,7 @@ protected: bool value_cached; public: Item_cache(): - example(0), used_table_map(0), cached_field(0), + example(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING), value_cached(0) { @@ -4706,7 +4705,7 @@ public: null_value= 1; } Item_cache(enum_field_types field_type_arg): - example(0), used_table_map(0), cached_field(0), + example(0), cached_field(0), cached_field_type(field_type_arg), value_cached(0) { @@ -4715,8 +4714,6 @@ public: null_value= 1; } - void set_used_tables(table_map map) { used_table_map= map; } - virtual bool allocate(uint i) { return 0; } virtual bool setup(Item *item) { @@ -4730,7 +4727,6 @@ public: enum_field_types field_type() const { return cached_field_type; } static Item_cache* get_cache(const Item *item); static Item_cache* get_cache(const Item* item, const Item_result type); - table_map used_tables() const { return used_table_map; } virtual void keep_array() {} virtual void print(String *str, enum_query_type query_type); bool eq_def(Field *field) @@ -4781,6 +4777,7 @@ public: return TRUE; return (this->*processor)(arg); } + virtual Item *safe_charset_converter(CHARSET_INFO *tocs); }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 9920aa40542..1d307d5b9f7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5072,10 +5072,65 @@ bool Regexp_processor_pcre::compile(Item *item, bool send_error) } +/** + Send a warning explaining an error code returned by pcre_exec(). +*/ +void Regexp_processor_pcre::pcre_exec_warn(int rc) const +{ + char buf[64]; + const char *errmsg= NULL; + /* + Make a descriptive message only for those pcre_exec() error codes + that can actually happen in MariaDB. + */ + switch (rc) + { + case PCRE_ERROR_NOMEMORY: + errmsg= "pcre_exec: Out of memory"; + break; + case PCRE_ERROR_BADUTF8: + errmsg= "pcre_exec: Invalid utf8 byte sequence in the subject string"; + break; + case PCRE_ERROR_RECURSELOOP: + errmsg= "pcre_exec: Recursion loop detected"; + break; + default: + /* + As other error codes should normally not happen, + we just report the error code without textual description + of the code. + */ + my_snprintf(buf, sizeof(buf), "pcre_exec: Internal error (%d)", rc); + errmsg= buf; + } + push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, + ER_REGEXP_ERROR, ER(ER_REGEXP_ERROR), errmsg); +} + + +/** + Call pcre_exec() and send a warning if pcre_exec() returned with an error. +*/ +int Regexp_processor_pcre::pcre_exec_with_warn(const pcre *code, + const pcre_extra *extra, + const char *subject, + int length, int startoffset, + int options, int *ovector, + int ovecsize) +{ + int rc= pcre_exec(code, extra, subject, length, + startoffset, options, ovector, ovecsize); + DBUG_EXECUTE_IF("pcre_exec_error_123", rc= -123;); + if (rc < PCRE_ERROR_NOMATCH) + pcre_exec_warn(rc); + return rc; +} + + bool Regexp_processor_pcre::exec(const char *str, int length, int offset) { - m_pcre_exec_rc= pcre_exec(m_pcre, NULL, str, length, - offset, 0, m_SubStrVec, m_subpatterns_needed * 3); + m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, NULL, str, length, offset, 0, + m_SubStrVec, m_subpatterns_needed * 3); return false; } @@ -5085,8 +5140,10 @@ bool Regexp_processor_pcre::exec(String *str, int offset, { if (!(str= convert_if_needed(str, &subject_converter))) return true; - m_pcre_exec_rc= pcre_exec(m_pcre, NULL, str->c_ptr_safe(), str->length(), - offset, 0, m_SubStrVec, m_subpatterns_needed * 3); + m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, NULL, + str->c_ptr_safe(), str->length(), + offset, 0, + m_SubStrVec, m_subpatterns_needed * 3); if (m_pcre_exec_rc > 0) { uint i; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 35310219c45..899a202c16a 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1574,6 +1574,10 @@ class Regexp_processor_pcre int m_pcre_exec_rc; int m_SubStrVec[30]; uint m_subpatterns_needed; + void pcre_exec_warn(int rc) const; + int pcre_exec_with_warn(const pcre *code, const pcre_extra *extra, + const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize); public: String *convert_if_needed(String *src, String *converter); String subject_converter; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4bf8dd5ae1b..d46261e6509 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -5106,6 +5106,16 @@ null: void Item_dyncol_get::print(String *str, enum_query_type query_type) { + /* + Parent cast doesn't exist yet, only print dynamic column name. This happens + when called from create_func_cast() / wrong_precision_error(). + */ + if (!str->length()) + { + args[1]->print(str, query_type); + return; + } + /* see create_func_dyncol_get */ DBUG_ASSERT(str->length() >= 5); DBUG_ASSERT(strncmp(str->ptr() + str->length() - 5, "cast(", 5) == 0); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index bac5c599561..8cf498f4b56 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2008, 2015, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3280,7 +3280,19 @@ void Item_func_group_concat::cleanup() } DBUG_ASSERT(tree == 0); } - + /* + As the ORDER structures pointed to by the elements of the + 'order' array may be modified in find_order_in_list() called + from Item_func_group_concat::setup() to point to runtime + created objects, we need to reset them back to the original + arguments of the function. + */ + ORDER **order_ptr= order; + for (uint i= 0; i < arg_count_order; i++) + { + (*order_ptr)->item= &args[arg_count_field + i]; + order_ptr++; + } DBUG_VOID_RETURN; } diff --git a/sql/log.h b/sql/log.h index 2d0c2d1eee9..e097e3bacab 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1058,8 +1058,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); void sql_print_error(const char *format, ...); void sql_print_warning(const char *format, ...); void sql_print_information(const char *format, ...); -typedef void (*sql_print_message_func)(const char *format, ...) - ATTRIBUTE_FORMAT_FPTR(printf, 1, 2); +typedef void (*sql_print_message_func)(const char *format, ...); extern sql_print_message_func sql_print_message_handlers[]; int error_log_print(enum loglevel level, const char *format, diff --git a/sql/log_event.cc b/sql/log_event.cc index 973e94e448c..7594a6f7f10 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2399,6 +2399,12 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr, my_snprintf(typestr, typestr_length, "STRING(%d)", length); return my_b_write_quoted_with_length(file, ptr, length); + case MYSQL_TYPE_DECIMAL: + my_b_printf(file, + "!! Old DECIMAL (mysql-4.1 or earlier). " + "Not enough metadata to display the value. "); + break; + default: { char tmp[5]; diff --git a/sql/message.rc b/sql/message.rc index 116522b7d48..0885a897e6f 100644 --- a/sql/message.rc +++ b/sql/message.rc @@ -1,2 +1,2 @@ -LANGUAGE 0x9,0x1
-1 11 MSG00001.bin
+LANGUAGE 0x9,0x1 +1 11 MSG00001.bin diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08bacd05c7c..29b6a19f137 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2510,10 +2510,11 @@ static MYSQL_SOCKET activate_tcp_port(uint port) if (mysql_socket_getfd(ip_sock) == INVALID_SOCKET) { - sql_print_error("Failed to create a socket for %s '%s': errno: %d.", - (a->ai_family == AF_INET) ? "IPv4" : "IPv6", - (const char *) ip_addr, - (int) socket_errno); + sql_print_message_func func= real_bind_addr_str ? sql_print_error + : sql_print_warning; + func("Failed to create a socket for %s '%s': errno: %d.", + (a->ai_family == AF_INET) ? "IPv4" : "IPv6", + (const char *) ip_addr, (int) socket_errno); } else { @@ -5865,6 +5866,8 @@ int mysqld_main(int argc, char **argv) mysql_cond_signal(&COND_server_started); mysql_mutex_unlock(&LOCK_server_started); + MYSQL_SET_STAGE(0 ,__FILE__, __LINE__); + #if defined(_WIN32) || defined(HAVE_SMEM) handle_connections_methods(); #else diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index d2b792a259d..fc9578cbc6d 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -1086,7 +1086,7 @@ bool Master_info_index::init_all_master_info() { /* Master_info is not in HASH; Add it */ if (master_info_index->add_master_info(mi, FALSE)) - return 1; + DBUG_RETURN(1); succ_num++; unlock_slave_threads(mi); } @@ -1119,7 +1119,7 @@ bool Master_info_index::init_all_master_info() /* Master_info was not registered; add it */ if (master_info_index->add_master_info(mi, FALSE)) - return 1; + DBUG_RETURN(1); succ_num++; unlock_slave_threads(mi); @@ -1216,7 +1216,7 @@ Master_info_index::get_master_info(const LEX_STRING *connection_name, mysql_mutex_assert_owner(&LOCK_active_mi); if (!this) // master_info_index is set to NULL on server shutdown - return NULL; + DBUG_RETURN(NULL); /* Make name lower case for comparison */ res= strmake(buff, connection_name->str, connection_name->length); @@ -1371,7 +1371,7 @@ bool Master_info_index::give_error_if_slave_running() DBUG_ENTER("give_error_if_slave_running"); mysql_mutex_assert_owner(&LOCK_active_mi); if (!this) // master_info_index is set to NULL on server shutdown - return TRUE; + DBUG_RETURN(TRUE); for (uint i= 0; i< master_info_hash.records; ++i) { @@ -1402,7 +1402,7 @@ bool Master_info_index::any_slave_sql_running() { DBUG_ENTER("any_slave_sql_running"); if (!this) // master_info_index is set to NULL on server shutdown - return TRUE; + DBUG_RETURN(TRUE); for (uint i= 0; i< master_info_hash.records; ++i) { diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 9067f1e4253..146bf3b0c0e 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -452,7 +452,7 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ CHARSET_INFO *cs= str->charset(); uint32 length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), - "decimal(%d,?)", metadata); + "decimal(%d,?)/*old*/", metadata); str->length(length); } break; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 848020c1846..280666d9fae 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8042,9 +8042,10 @@ bool setup_tables(THD *thd, Name_resolution_context *context, if (select_lex->first_cond_optimization) { leaves.empty(); - if (!select_lex->is_prep_leaf_list_saved) + if (select_lex->prep_leaf_list_state != SELECT_LEX::SAVED) { make_leaves_list(thd, leaves, tables, full_table_list, first_select_table); + select_lex->prep_leaf_list_state= SELECT_LEX::READY; select_lex->leaf_tables_exec.empty(); } else diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 94dcfedcf02..1108d6dde86 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1080,7 +1080,7 @@ bool setup_connection_thread_globals(THD *thd) bool login_connection(THD *thd) { NET *net= &thd->net; - int error; + int error= 0; DBUG_ENTER("login_connection"); DBUG_PRINT("info", ("login_connection called by thread %lu", thd->thread_id)); @@ -1099,7 +1099,8 @@ bool login_connection(THD *thd) my_sleep(1000); /* must wait after eof() */ #endif statistic_increment(aborted_connects,&LOCK_status); - DBUG_RETURN(1); + error=1; + goto exit; } /* Connect completed, set read/write timeouts back to default */ my_net_set_read_timeout(net, thd->variables.net_read_timeout); @@ -1109,10 +1110,13 @@ bool login_connection(THD *thd) if (increment_connection_count(thd, TRUE)) { my_error(ER_OUTOFMEMORY, MYF(0), 2*sizeof(USER_STATS)); - DBUG_RETURN(1); + error= 1; + goto exit; } - DBUG_RETURN(0); +exit: + mysql_audit_notify_connection_connect(thd); + DBUG_RETURN(error); } @@ -1264,7 +1268,6 @@ bool thd_prepare_connection(THD *thd) bool rc; lex_start(thd); rc= login_connection(thd); - mysql_audit_notify_connection_connect(thd); if (rc) return rc; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 992510a18e6..ac2eda2d0de 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -540,6 +540,7 @@ void lex_start(THD *thd) lex->in_sum_func= NULL; lex->used_tables= 0; + lex->only_view= FALSE; lex->reset_slave_info.all= false; lex->limit_rows_examined= 0; lex->limit_rows_examined_cnt= ULONGLONG_MAX; @@ -1898,7 +1899,7 @@ void st_select_lex::init_query() exclude_from_table_unique_test= no_wrap_view_item= FALSE; nest_level= 0; link_next= 0; - is_prep_leaf_list_saved= FALSE; + prep_leaf_list_state= UNINIT; have_merged_subqueries= FALSE; bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); m_non_agg_field_used= false; @@ -4179,12 +4180,22 @@ bool st_select_lex::save_prep_leaf_tables(THD *thd) { List_iterator_fast<TABLE_LIST> li(leaf_tables); TABLE_LIST *table; + + /* + Check that the SELECT_LEX was really prepared and so tables are setup. + + It can be subquery in SET clause of UPDATE which was not prepared yet, so + its tables are not yet setup and ready for storing. + */ + if (prep_leaf_list_state != READY) + return FALSE; + while ((table= li++)) { if (leaf_tables_prep.push_back(table)) return TRUE; } - is_prep_leaf_list_saved= TRUE; + prep_leaf_list_state= SAVED; for (SELECT_LEX_UNIT *u= first_inner_unit(); u; u= u->next_unit()) { for (SELECT_LEX *sl= u->first_select(); sl; sl= sl->next_select()) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 76424f60c34..2e820e7a923 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -780,7 +780,8 @@ public: List<TABLE_LIST> leaf_tables; List<TABLE_LIST> leaf_tables_exec; List<TABLE_LIST> leaf_tables_prep; - bool is_prep_leaf_list_saved; + enum leaf_list_state {UNINIT, READY, SAVED}; + enum leaf_list_state prep_leaf_list_state; uint insert_tables; st_select_lex *merged_into; /* select which this select is merged into */ /* (not 0 only for views/derived tables) */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 8755ec47c54..96f67c3302b 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -837,9 +837,16 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) log. The exception is a unimplemented truncate method or failure before any call to handler::truncate() is done. Also, it is logged in statement format, regardless of the binlog format. + + Since we've changed data within the table, we also have to invalidate + the query cache for it. */ - if (error != HA_ERR_WRONG_COMMAND && binlog_stmt) - error|= write_bin_log(thd, !error, thd->query(), thd->query_length()); + if (error != HA_ERR_WRONG_COMMAND) + { + query_cache_invalidate3(thd, first_table, FALSE); + if (binlog_stmt) + error|= write_bin_log(thd, !error, thd->query(), thd->query_length()); + } /* A locked table ticket was upgraded to a exclusive lock. After the diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 2c17898f07c..6496e1895fb 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -238,7 +238,6 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, { int rc= 1; handlerton *hton; - bool new_exists, old_exists; const char *new_alias, *old_alias; DBUG_ENTER("do_rename"); @@ -254,17 +253,13 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, } DBUG_ASSERT(new_alias); - new_exists= ha_table_exists(thd, new_db, new_alias); - - if (new_exists) + if (ha_table_exists(thd, new_db, new_alias)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); DBUG_RETURN(1); // This can't be skipped } - old_exists= ha_table_exists(thd, ren_table->db, old_alias, &hton); - - if (old_exists) + if (ha_table_exists(thd, ren_table->db, old_alias, &hton) && hton) { DBUG_ASSERT(!thd->locked_tables_mode); tdc_remove_table(thd, TDC_RT_REMOVE_ALL, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 02335ddf0f7..f8257e0cfe6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9803,10 +9803,24 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (!sel->quick_keys.is_subset(tab->checked_keys) || !sel->needed_reg.is_subset(tab->checked_keys)) { + /* + "Range checked for each record" is a "last resort" access method + that should only be used when the other option is a cross-product + join. + + We use the following condition (it's approximate): + 1. There are potential keys for (sel->needed_reg) + 2. There were no possible ways to construct a quick select, or + the quick select would be more expensive than the full table + scan. + */ tab->use_quick= (!sel->needed_reg.is_clear_all() && (sel->quick_keys.is_clear_all() || - (sel->quick && - (sel->quick->records >= 100L)))) ? + (sel->quick && + sel->quick->read_time > + tab->table->file->scan_time() + + tab->table->file->stats.records/TIME_FOR_COMPARE + ))) ? 2 : 1; sel->read_tables= used_tables & ~current_map; sel->quick_keys.clear_all(); diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index 9b944662545..297972f6dc4 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -320,7 +320,8 @@ get_server_from_table_to_cache(TABLE *table) table->use_all_columns(); /* get each field into the server struct ptr */ - server->server_name= get_field(&mem, table->field[0]); + ptr= get_field(&mem, table->field[0]); + server->server_name= ptr ? ptr : blank; server->server_name_length= (uint) strlen(server->server_name); ptr= get_field(&mem, table->field[1]); server->host= ptr ? ptr : blank; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0ed68315877..4a396622862 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2009, 2015, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2375,7 +2375,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) Security_context *tmp_sctx= tmp->security_ctx; struct st_my_thread_var *mysys_var; if ((tmp->vio_ok() || tmp->system_thread) && - (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user)))) + (!user || (!tmp->system_thread && + tmp_sctx->user && !strcmp(tmp_sctx->user, user)))) { thread_info *thd_info= new thread_info; @@ -2756,7 +2757,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) ulonglong max_counter; if ((!tmp->vio_ok() && !tmp->system_thread) || - (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user)))) + (user && (tmp->system_thread || !tmp_sctx->user || + strcmp(tmp_sctx->user, user)))) continue; restore_record(table, s->default_values); @@ -7911,15 +7913,20 @@ bool get_schema_tables_result(JOIN *join, TABLE_LIST *table_list= tab->table->pos_in_table_list; if (table_list->schema_table && thd->fill_information_schema_tables()) { +#if MYSQL_VERSION_ID > 100105 +#error I_S tables only need to be re-populated if make_cond_for_info_schema() will preserve outer fields bool is_subselect= (&lex->unit != lex->current_select->master_unit() && lex->current_select->master_unit()->item); +#else +#define is_subselect false +#endif /* A value of 0 indicates a dummy implementation */ if (table_list->schema_table->fill_table == 0) continue; /* skip I_S optimizations specific to get_all_tables */ - if (thd->lex->describe && + if (lex->describe && (table_list->schema_table->fill_table != get_all_tables)) continue; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4d2a107dfe6..774fbaf4406 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1672,6 +1672,7 @@ void execute_ddl_log_recovery() (void) mysql_file_delete(key_file_global_ddl_log, file_name, MYF(0)); global_ddl_log.recovery_phase= FALSE; mysql_mutex_unlock(&LOCK_gdl); + thd->reset_query(); delete thd; DBUG_VOID_RETURN; } @@ -2177,15 +2178,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, char path[FN_REFLEN + 1], wrong_tables_buff[160], *alias= NULL; String wrong_tables(wrong_tables_buff, sizeof(wrong_tables_buff)-1, system_charset_info); - uint path_length= 0; + uint path_length= 0, errors= 0; int error= 0; int non_temp_tables_count= 0; - bool foreign_key_error=0; bool non_tmp_error= 0; bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0; bool non_tmp_table_deleted= 0; bool is_drop_tmp_if_exists_added= 0; - bool one_table= tables->next_local == 0; bool was_view= 0; String built_query; String built_trans_tmp_query, built_non_trans_tmp_query; @@ -2471,12 +2470,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, error= ha_delete_table(thd, table_type, path, db, table->table_name, !dont_log_query); - if (error == HA_ERR_ROW_IS_REFERENCED) - { - /* the table is referenced by a foreign key constraint */ - foreign_key_error= 1; - } - if (!error || error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) + if (!error) { int frm_delete_error, trigger_drop_error= 0; /* Delete the table definition file */ @@ -2494,11 +2488,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, if (trigger_drop_error || (frm_delete_error && frm_delete_error != ENOENT)) error= 1; - else if (!frm_delete_error || !error || if_exists) - { - error= 0; + else if (frm_delete_error && if_exists) thd->clear_error(); - } } non_tmp_error= error ? TRUE : non_tmp_error; } @@ -2509,6 +2500,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, wrong_tables.append(db); wrong_tables.append('.'); wrong_tables.append(table->table_name); + errors++; } else { @@ -2532,14 +2524,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, err: if (wrong_tables.length()) { - if (one_table && was_view) + DBUG_ASSERT(errors); + if (errors == 1 && was_view) my_printf_error(ER_IT_IS_A_VIEW, ER(ER_IT_IS_A_VIEW), MYF(0), wrong_tables.c_ptr_safe()); - else if (!foreign_key_error) + else if (errors > 1 || !thd->is_error()) my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), wrong_tables.c_ptr_safe()); - else - my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0)); error= 1; } @@ -2590,8 +2581,8 @@ err: /* Chop of the last comma */ built_query.chop(); built_query.append(" /* generated by server */"); - int error_code = (non_tmp_error ? - (foreign_key_error ? ER_ROW_IS_REFERENCED : ER_BAD_TABLE_ERROR) : 0); + int error_code = non_tmp_error ? thd->get_stmt_da()->sql_errno() + : 0; error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_query.ptr(), built_query.length(), @@ -5119,6 +5110,7 @@ mysql_rename_table(handlerton *base, const char *old_db, ulonglong save_bits= thd->variables.option_bits; int length; DBUG_ENTER("mysql_rename_table"); + DBUG_ASSERT(base); DBUG_PRINT("enter", ("old: '%s'.'%s' new: '%s'.'%s'", old_db, old_name, new_db, new_name)); @@ -5126,8 +5118,7 @@ mysql_rename_table(handlerton *base, const char *old_db, if (flags & NO_FK_CHECKS) thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS; - file= (base == NULL ? 0 : - get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base)); + file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base); build_table_filename(from, sizeof(from) - 1, old_db, old_name, "", flags & FN_FROM_IS_TMP); @@ -5454,8 +5445,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if (!table->view) { int result __attribute__((unused))= - show_create_table(thd, table, &query, - create_info, WITHOUT_DB_NAME); + show_create_table(thd, table, &query, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); // show_create_table() always return 0 do_logging= FALSE; @@ -5837,12 +5827,17 @@ drop_create_field: /* let us check the name of the first key part. */ if ((keyname= key->name.str) == NULL) { - List_iterator<Key_part_spec> part_it(key->columns); - Key_part_spec *kp; - if ((kp= part_it++)) - keyname= kp->field_name.str; - if (keyname == NULL) - continue; + if (key->type == Key::PRIMARY) + keyname= primary_key_name; + else + { + List_iterator<Key_part_spec> part_it(key->columns); + Key_part_spec *kp; + if ((kp= part_it++)) + keyname= kp->field_name.str; + if (keyname == NULL) + continue; + } } if (key->type != Key::FOREIGN_KEY) { diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 07a85afdf82..1dadad9dd17 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -224,7 +224,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) view->definer.user= decoy.definer.user; lex->definer= &view->definer; } - if (lex->create_view_algorithm == DTYPE_ALGORITHM_UNDEFINED) + if (lex->create_view_algorithm == VIEW_ALGORITHM_INHERIT) lex->create_view_algorithm= (uint8) decoy.algorithm; if (lex->create_view_suid == VIEW_SUID_DEFAULT) lex->create_view_suid= decoy.view_suid ? diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a18cc2280d3..373503ad94d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7200,7 +7200,7 @@ alter: my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"); MYSQL_YYABORT; } - lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; + lex->create_view_algorithm= VIEW_ALGORITHM_INHERIT; lex->create_view_mode= VIEW_ALTER; } view_tail @@ -7950,8 +7950,13 @@ opt_checksum_type: | EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; } ; +repair_table_or_view: + table_or_tables table_list opt_mi_repair_type + | VIEW_SYM { Lex->only_view= TRUE; } table_list opt_view_repair_type + ; + repair: - REPAIR opt_no_write_to_binlog table_or_view + REPAIR opt_no_write_to_binlog { LEX *lex=Lex; lex->sql_command = SQLCOM_REPAIR; @@ -7961,18 +7966,9 @@ repair: /* Will be overriden during execution. */ YYPS->m_lock_type= TL_UNLOCK; } - table_list opt_mi_repair_type + repair_table_or_view { LEX* lex= thd->lex; - if ((lex->only_view && - ((lex->check_opt.flags & (T_QUICK | T_EXTEND)) || - (lex->check_opt.sql_flags & TT_USEFRM))) || - (!lex->only_view && - (lex->check_opt.sql_flags & TT_FROM_MYSQL))) - { - my_parse_error(ER(ER_SYNTAX_ERROR)); - MYSQL_YYABORT; - } DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_repair_table(); if (lex->m_sql_cmd == NULL) @@ -7994,6 +7990,10 @@ mi_repair_type: QUICK { Lex->check_opt.flags|= T_QUICK; } | EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; } | USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; } + ; + +opt_view_repair_type: + /* empty */ { } | FROM MYSQL_SYM { Lex->check_opt.sql_flags|= TT_FROM_MYSQL; } ; @@ -8113,30 +8113,27 @@ binlog_base64_event: } ; -check: - CHECK_SYM table_or_view +check_view_or_table: + table_or_tables table_list opt_mi_check_type + | VIEW_SYM { Lex->only_view= TRUE; } table_list opt_view_check_type + ; + +check: CHECK_SYM { LEX *lex=Lex; - if (lex->sphead) - { - my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK"); - MYSQL_YYABORT; - } lex->sql_command = SQLCOM_CHECK; lex->check_opt.init(); lex->alter_info.reset(); /* Will be overriden during execution. */ YYPS->m_lock_type= TL_UNLOCK; } - table_list opt_mi_check_type + check_view_or_table { LEX* lex= thd->lex; - if (lex->only_view && - (lex->check_opt.flags & (T_QUICK | T_FAST | T_EXTEND | - T_CHECK_ONLY_CHANGED))) + if (lex->sphead) { - my_parse_error(ER(ER_SYNTAX_ERROR)); + my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK"); MYSQL_YYABORT; } DBUG_ASSERT(!lex->m_sql_cmd); @@ -8165,6 +8162,11 @@ mi_check_type: | FOR_SYM UPGRADE_SYM { Lex->check_opt.sql_flags|= TT_FOR_UPGRADE; } ; +opt_view_check_type: + /* empty */ { } + | FOR_SYM UPGRADE_SYM { Lex->check_opt.sql_flags|= TT_FOR_UPGRADE; } + ; + optimize: OPTIMIZE opt_no_write_to_binlog table_or_tables { @@ -8246,7 +8248,6 @@ keycache: LEX *lex=Lex; lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; lex->ident= $6; - lex->only_view= FALSE; } ; @@ -8291,7 +8292,6 @@ preload: LEX *lex=Lex; lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->alter_info.reset(); - lex->only_view= FALSE; } preload_list_or_parts {} @@ -12625,7 +12625,6 @@ show_param: lex->sql_command = SQLCOM_SHOW_CREATE; if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0)) MYSQL_YYABORT; - lex->only_view= 0; lex->create_info.storage_media= HA_SM_DEFAULT; } | CREATE VIEW_SYM table_ident @@ -15011,13 +15010,8 @@ lock: ; table_or_tables: - TABLE_SYM { Lex->only_view= FALSE; } - | TABLES { Lex->only_view= FALSE; } - ; - -table_or_view: - table_or_tables - | VIEW_SYM { Lex->only_view= TRUE; } + TABLE_SYM { } + | TABLES { } ; table_lock_list: diff --git a/sql/table.h b/sql/table.h index 622a3b26190..c0501b58fc3 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1535,6 +1535,8 @@ class IS_table_read_plan; #define DT_PHASES_MATERIALIZE (DT_COMMON | DT_MATERIALIZE) #define VIEW_ALGORITHM_UNDEFINED 0 +/* Special value for ALTER VIEW: inherit original algorithm. */ +#define VIEW_ALGORITHM_INHERIT DTYPE_VIEW #define VIEW_ALGORITHM_MERGE (DTYPE_VIEW | DTYPE_MERGE) #define VIEW_ALGORITHM_TMPTABLE (DTYPE_VIEW | DTYPE_MATERIALIZE) diff --git a/sql/tztime.cc b/sql/tztime.cc index 9fa065eefa0..5e5f34f29a5 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2517,7 +2517,8 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose) for (i= 0; i < cur_dir->number_of_files; i++) { - if (cur_dir->dir_entry[i].name[0] != '.') + if (cur_dir->dir_entry[i].name[0] != '.' && + strcmp(cur_dir->dir_entry[i].name, "Factory")) { name_end_tmp= strmake(name_end, cur_dir->dir_entry[i].name, FN_REFLEN - (name_end - fullname)); diff --git a/sql/winservice.h b/sql/winservice.h index fca7b129de5..c3e2bfe1b20 100644 --- a/sql/winservice.h +++ b/sql/winservice.h @@ -1,40 +1,40 @@ -/*
- Copyright (c) 2011, 2012, Monty Program Ab
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- Extract properties of a windows service binary path
-*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <windows.h>
-typedef struct mysqld_service_properties_st
-{
- char mysqld_exe[MAX_PATH];
- char inifile[MAX_PATH];
- char datadir[MAX_PATH];
- int version_major;
- int version_minor;
- int version_patch;
-} mysqld_service_properties;
-
-extern int get_mysql_service_properties(const wchar_t *bin_path,
- mysqld_service_properties *props);
-
-#ifdef __cplusplus
-}
-#endif
+/* + Copyright (c) 2011, 2012, Monty Program Ab + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + Extract properties of a windows service binary path +*/ +#ifdef __cplusplus +extern "C" { +#endif + +#include <windows.h> +typedef struct mysqld_service_properties_st +{ + char mysqld_exe[MAX_PATH]; + char inifile[MAX_PATH]; + char datadir[MAX_PATH]; + int version_major; + int version_minor; + int version_patch; +} mysqld_service_properties; + +extern int get_mysql_service_properties(const wchar_t *bin_path, + mysqld_service_properties *props); + +#ifdef __cplusplus +} +#endif diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index a2f537436c9..193514eeb99 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -1,7 +1,7 @@ /************* Array C++ Functions Source Code File (.CPP) *************/ /* Name: ARRAY.CPP Version 2.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* This file contains the XOBJECT derived class ARRAY functions. */ /* ARRAY is used for elaborate type of processing, such as sorting */ @@ -19,14 +19,14 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <stdint.h> // for uintprt_h -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ @@ -186,7 +186,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec) // The error message was built by PlgDBalloc Type = TYPE_ERROR; else if (type != TYPE_PCHAR) - Value = AllocateValue(g, type, Len, prec, NULL); + Value = AllocateValue(g, type, Len, prec); Constant = TRUE; } // end of ARRAY constructor @@ -610,7 +610,7 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp) // The error message was built by PlgDBalloc return TYPE_ERROR; else - Value = AllocateValue(g, Type, Len, prec, NULL); + Value = AllocateValue(g, Type, Len, prec); /*********************************************************************/ /* Converting STRING to DATE can be done according to date format. */ @@ -848,7 +848,7 @@ void *ARRAY::GetSortIndex(PGLOBAL g) /* the indication of whether the Find will be always true, always not */ /* true or other. */ /***********************************************************************/ -int ARRAY::BlockTest(PGLOBAL g, int opc, int opm, +int ARRAY::BlockTest(PGLOBAL, int opc, int opm, void *minp, void *maxp, bool s) { bool bin, bax, pin, pax, veq, all = (opm == 2); @@ -1038,7 +1038,7 @@ void ARRAY::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of ARRAY contents. */ /***********************************************************************/ -void ARRAY::Print(PGLOBAL g, char *ps, uint z) +void ARRAY::Print(PGLOBAL, char *ps, uint z) { if (z < 16) return; diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp index 802231b24ec..1f5a1a27ae5 100644 --- a/storage/connect/blkfil.cpp +++ b/storage/connect/blkfil.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -20,13 +20,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -56,7 +56,7 @@ BLOCKFILTER::BLOCKFILTER(PTDBDOS tdbp, int op) /***********************************************************************/ /* Make file output of BLOCKFILTER contents. */ /***********************************************************************/ -void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n) +void BLOCKFILTER::Print(PGLOBAL, FILE *f, uint n) { char m[64]; @@ -70,7 +70,7 @@ void BLOCKFILTER::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of BLOCKFILTER contents. */ /***********************************************************************/ -void BLOCKFILTER::Print(PGLOBAL g, char *ps, uint z) +void BLOCKFILTER::Print(PGLOBAL, char *ps, uint z) { strncat(ps, "BlockFilter(s)", z); } // end of Print @@ -186,7 +186,7 @@ void BLKFILARI::Reset(PGLOBAL g) /***********************************************************************/ /* Evaluate block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILARI::BlockEval(PGLOBAL g) +int BLKFILARI::BlockEval(PGLOBAL) { int mincmp, maxcmp, n; @@ -306,7 +306,7 @@ void BLKFILAR2::MakeValueBitmap(void) /***********************************************************************/ /* Evaluate XDB2 block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILAR2::BlockEval(PGLOBAL g) +int BLKFILAR2::BlockEval(PGLOBAL) { #if defined(_DEBUG) assert (Colp->IsClustered()); @@ -428,7 +428,7 @@ void BLKFILMR2::MakeValueBitmap(void) /***********************************************************************/ /* Evaluate XDB2 block filter for arithmetic operators. */ /***********************************************************************/ -int BLKFILMR2::BlockEval(PGLOBAL g) +int BLKFILMR2::BlockEval(PGLOBAL) { #if defined(_DEBUG) assert (Colp->IsClustered()); @@ -514,7 +514,7 @@ void BLKSPCARI::Reset(PGLOBAL g) /***********************************************************************/ /* Evaluate block filter for arithmetic operators (ROWID) */ /***********************************************************************/ -int BLKSPCARI::BlockEval(PGLOBAL g) +int BLKSPCARI::BlockEval(PGLOBAL) { int mincmp, maxcmp, n, m; @@ -605,7 +605,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp) /***********************************************************************/ /* Reset: have the sorted array reset its Bot value to -1 (bottom). */ /***********************************************************************/ -void BLKFILIN::Reset(PGLOBAL g) +void BLKFILIN::Reset(PGLOBAL) { Arap->Reset(); // MakeValueBitmap(); // Does nothing for class BLKFILIN @@ -736,7 +736,7 @@ void BLKFILIN2::MakeValueBitmap(void) /* ended string in case of string argument. This is because the ARRAY */ /* can have a different width than the char column. */ /***********************************************************************/ -int BLKFILIN2::BlockEval(PGLOBAL g) +int BLKFILIN2::BlockEval(PGLOBAL) { if (N < 0) return Result; // Was set in MakeValueBitmap @@ -909,7 +909,7 @@ int BLKFILIN2::BlockEval(PGLOBAL g) /***********************************************************************/ /* BLKSPCIN constructor. */ /***********************************************************************/ -BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, +BLKSPCIN::BLKSPCIN(PGLOBAL, PTDBDOS tdbp, int op, int opm, PXOB *xp, int bsize) : BLOCKFILTER(tdbp, op) { @@ -930,7 +930,7 @@ BLKSPCIN::BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, /***********************************************************************/ /* Reset: have the sorted array reset its Bot value to -1 (bottom). */ /***********************************************************************/ -void BLKSPCIN::Reset(PGLOBAL g) +void BLKSPCIN::Reset(PGLOBAL) { Arap->Reset(); } // end of Reset diff --git a/storage/connect/block.h b/storage/connect/block.h index d63a899d1f5..aa4edde5ec9 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -24,11 +24,11 @@ #if !defined(BLOCK_DEFINED) #define BLOCK_DEFINED -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Definition of class BLOCK with its method function new. */ @@ -38,7 +38,7 @@ typedef class BLOCK *PBLOCK; class DllExport BLOCK { public: void * operator new(size_t size, PGLOBAL g, void *p = NULL) { -// if (trace > 2) +// if (trace > 3) // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); return (PlugSubAlloc(g, p, size)); @@ -50,7 +50,7 @@ class DllExport BLOCK { #if !defined(__BORLANDC__) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PGLOBAL, void *) {} - void operator delete(void *ptr,size_t size) {} + void operator delete(void *, size_t) {} #endif virtual ~BLOCK() {} diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h index 5baab294737..6488b513ba9 100644 --- a/storage/connect/catalog.h +++ b/storage/connect/catalog.h @@ -1,7 +1,7 @@ /*************** Catalog H Declares Source Code File (.H) **************/ /* Name: CATALOG.H Version 3.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2000-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */ /* */ /* This file contains the CATALOG PlugDB classes definitions. */ /***********************************************************************/ @@ -73,33 +73,29 @@ class DllExport CATALOG { // Methods virtual void Reset(void) {} //virtual void SetDataPath(PGLOBAL g, const char *path) {} - virtual bool CheckName(PGLOBAL g, char *name) {return true;} - virtual bool ClearName(PGLOBAL g, PSZ name) {return true;} - virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} - virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} - virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, - PRELDEF *prp = NULL) {return NULL;} - virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} - virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} - virtual bool TestCond(PGLOBAL g, const char *name, const char *type) - {return true;} - virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} - virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, - MODE mode = MODE_READ, LPCSTR type = NULL) - {return NULL;} - virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} - virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, - int maxbuf, int info[]) {} - virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer, - int maxbuf, int info[]) {} - virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, - char *buffer, int maxbuf, int info[]) {return NULL;} - virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} - virtual void ClearDB(PGLOBAL g) {} + virtual bool CheckName(PGLOBAL, char*) {return true;} + virtual bool ClearName(PGLOBAL, PSZ) {return true;} + virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} + virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;} + virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR, + PRELDEF* = NULL) {return NULL;} + virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;} + virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;} + virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;} + virtual bool DropTable(PGLOBAL, PSZ, bool) {return true;} + virtual PTDB GetTable(PGLOBAL, PTABLE, + MODE = MODE_READ, LPCSTR = NULL) {return NULL;} + virtual void TableNames(PGLOBAL, char*, int, int[]) {} + virtual void ColumnNames(PGLOBAL, char*, char*, int, int[]) {} + virtual void ColumnDefs(PGLOBAL, char*, char*, int, int[]) {} + virtual void *DecodeValues(PGLOBAL, char*, char*, char*, + int, int[]) {return NULL;} + virtual int ColumnType(PGLOBAL, char*, char*) {return 0;} + virtual void ClearDB(PGLOBAL) {} protected: - virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;} - virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} + virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;} + virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} // Members char *Cbuf; /* Buffer used for col section */ diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index f5bd32db738..80b405be041 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -1,7 +1,7 @@ /************* Colblk C++ Functions Source Code File (.CPP) ************/ /* Name: COLBLK.CPP Version 2.1 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* This file contains the COLBLK class functions. */ /***********************************************************************/ @@ -111,7 +111,7 @@ bool COLBLK::Compare(PXOB xp) /***********************************************************************/ /* SetFormat: function used to set SELECT output format. */ /***********************************************************************/ -bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) +bool COLBLK::SetFormat(PGLOBAL, FORMAT& fmt) { fmt = Format; @@ -175,7 +175,7 @@ bool COLBLK::InitValue(PGLOBAL g) /***********************************************************************/ /* SetBuffer: prepare a column block for write operation. */ /***********************************************************************/ -bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) +bool COLBLK::SetBuffer(PGLOBAL g, PVAL, bool, bool) { sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); return true; @@ -214,7 +214,7 @@ void COLBLK::WriteColumn(PGLOBAL g) /***********************************************************************/ /* Make file output of a column descriptor block. */ /***********************************************************************/ -void COLBLK::Print(PGLOBAL g, FILE *f, uint n) +void COLBLK::Print(PGLOBAL, FILE *f, uint n) { char m[64]; int i; @@ -237,7 +237,7 @@ void COLBLK::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of a column descriptor block. */ /***********************************************************************/ -void COLBLK::Print(PGLOBAL g, char *ps, uint z) +void COLBLK::Print(PGLOBAL, char *ps, uint) { sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); } // end of Print @@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op) Buf_Type = TYPE_STRING; *Format.Type = 'C'; Format.Length = Long; -#if defined(WIN32) +#if defined(__WIN__) Format.Prec = 1; // Case insensitive -#endif // WIN32 +#endif // __WIN__ Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && To_Tdb->GetAmType() != TYPE_AM_PLG && To_Tdb->GetAmType() != TYPE_AM_PLM); @@ -347,7 +347,7 @@ TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp) /***********************************************************************/ /* ReadColumn: what this routine does is to return the table ID. */ /***********************************************************************/ -void TIDBLK::ReadColumn(PGLOBAL g) +void TIDBLK::ReadColumn(PGLOBAL) { if (Tname == NULL) { Tname = (char*)To_Tdb->GetName(); @@ -406,7 +406,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) /***********************************************************************/ /* ReadColumn: what this routine does is to return the server ID. */ /***********************************************************************/ -void SIDBLK::ReadColumn(PGLOBAL g) +void SIDBLK::ReadColumn(PGLOBAL) { //if (Sname == NULL) { Sname = (char*)To_Tdb->GetServer(); diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h index 5e8dc77ff69..c64f9d95129 100644 --- a/storage/connect/colblk.h +++ b/storage/connect/colblk.h @@ -1,7 +1,7 @@ /*************** Colblk H Declares Source Code File (.H) ***************/ /* Name: COLBLK.H Version 1.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* This file contains the COLBLK and derived classes declares. */ /***********************************************************************/ @@ -23,7 +23,7 @@ class DllExport COLBLK : public XOBJECT { // Default constructors used by derived classes COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process - COLBLK(int n) {} // Used when changing a column class in TDBXML + COLBLK(int) {} // Used when changing a column class in TDBXML public: // Implementation @@ -69,7 +69,7 @@ class DllExport COLBLK : public XOBJECT { virtual bool IsSpecial(void) {return false;} virtual bool Eval(PGLOBAL g); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); - virtual void SetTo_Val(PVAL valp) {} + virtual void SetTo_Val(PVAL) {} virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g); virtual void Print(PGLOBAL g, FILE *, uint); diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 7c32c65226d..4e554b16638 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2012 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /***********************************************************************/ -/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2012 */ +/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -237,7 +237,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) /* OPENTAB: Open a Table. */ /***********************************************************************/ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, - bool del, PHC h) + bool del, PHC) { char *p; int i, n, rc; @@ -709,6 +709,28 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted) return (tdbp->To_Kindex->IsMul()) ? 2 : 1; } // end of CntIndexInit +#if defined(WORDS_BIGENDIAN) +/***********************************************************************/ +/* Swap bytes of the key that are written in little endian order. */ +/***********************************************************************/ +static void SetSwapValue(PVAL valp, char *kp) +{ + if (valp->IsTypeNum() && valp->GetType() != TYPE_DECIM) { + uchar buf[8]; + int i, k= valp->GetClen(); + + for (i = 0; k > 0;) + buf[i++]= kp[--k]; + + + + valp->SetBinValue((void*)buf); + } else + valp->SetBinValue((void*)kp); + +} // end of SetSwapValue +#endif // WORDS_BIGENDIAN + /***********************************************************************/ /* IndexRead: fetch a record having the index value. */ /***********************************************************************/ @@ -779,7 +801,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, if (!valp->IsTypeNum()) { if (colp->GetColUse(U_VAR)) { +#if defined(WORDS_BIGENDIAN) + ((char*)&lg)[0]= ((char*)kp)[1]; + ((char*)&lg)[1]= ((char*)kp)[0]; +#else // !WORDS_BIGENDIAN lg= *(short*)kp; +#endif //!WORDS_BIGENDIAN kp+= sizeof(short); rcb= valp->SetValue_char(kp, (int)lg); } else @@ -797,7 +824,11 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, } // endif b } else +#if defined(WORDS_BIGENDIAN) + SetSwapValue(valp, kp); +#else // !WORDS_BIGENDIAN valp->SetBinValue((void*)kp); +#endif //!WORDS_BIGENDIAN kp+= valp->GetClen(); @@ -893,7 +924,12 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, if (!valp->IsTypeNum()) { if (colp->GetColUse(U_VAR)) { +#if defined(WORDS_BIGENDIAN) + ((char*)&lg)[0]= ((char*)p)[1]; + ((char*)&lg)[1]= ((char*)p)[0]; +#else // !WORDS_BIGENDIAN lg= *(short*)p; +#endif //!WORDS_BIGENDIAN p+= sizeof(short); rcb= valp->SetValue_char((char*)p, (int)lg); } else @@ -912,7 +948,11 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, } // endif b } else +#if defined(WORDS_BIGENDIAN) + SetSwapValue(valp, (char*)p); +#else // !WORDS_BIGENDIAN valp->SetBinValue((void*)p); +#endif // !WORDS_BIGENDIAN if (trace) { char bf[32]; diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp index 9e518775c0f..64a0a172956 100644 --- a/storage/connect/domdoc.cpp +++ b/storage/connect/domdoc.cpp @@ -4,7 +4,7 @@ /******************************************************************/ #include "my_global.h" #include <stdio.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #if defined(MSX2) #import "msxml2.dll" //Does not exist on Vista diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 1e65fa2a413..5cf9a4d945c 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -17,12 +17,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -30,7 +30,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -191,11 +191,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) return true; } // endif Memory -#if defined(WIN32) +#if defined(__WIN__) if (mode != MODE_DELETE) { -#else // !WIN32 +#else // !__WIN__ if (mode == MODE_READ) { -#endif // !WIN32 +#endif // !__WIN__ CloseFileHandle(hFile); // Not used anymore hFile = INVALID_HANDLE_VALUE; // For Fblock } // endif Mode @@ -276,7 +276,7 @@ bool MAPFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Record file position in case of UPDATE or DELETE. */ /***********************************************************************/ -bool MAPFAM::RecordPos(PGLOBAL g) +bool MAPFAM::RecordPos(PGLOBAL) { Fpos = Mempos; return false; @@ -285,7 +285,7 @@ bool MAPFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Initialize Fpos and Mempos for indexed DELETE. */ /***********************************************************************/ -int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int MAPFAM::InitDelete(PGLOBAL, int fpos, int spos) { Fpos = Memory + (ptrdiff_t)fpos; Mempos = Memory + (ptrdiff_t)spos; @@ -371,7 +371,7 @@ int MAPFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ /* WriteBuffer: File write routine for MAP access method. */ /***********************************************************************/ -int MAPFAM::WriteBuffer(PGLOBAL g) +int MAPFAM::WriteBuffer(PGLOBAL g __attribute__((unused))) { #if defined(_DEBUG) // Insert mode is no more handled using file mapping @@ -452,7 +452,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = Tpos - Memory; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -482,7 +482,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) #endif // UNIX } // endif Abort -#if defined(WIN32) +#if defined(__WIN__) CloseHandle(fp->Handle); #else // UNIX close(fp->Handle); @@ -495,7 +495,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Table file close routine for MAP access method. */ /***********************************************************************/ -void MAPFAM::CloseTableFile(PGLOBAL g, bool abort) +void MAPFAM::CloseTableFile(PGLOBAL g, bool) { PlugCloseFile(g, To_Fb); To_Fb = NULL; // To get correct file size in Cardinality @@ -551,7 +551,7 @@ int MBKFAM::Cardinality(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int MBKFAM::SkipRecord(PGLOBAL g, bool header) +int MBKFAM::SkipRecord(PGLOBAL, bool) { return RC_OK; } // end of SkipRecord @@ -685,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Initialize CurBlk, CurNum, Mempos and Fpos for indexed DELETE. */ /***********************************************************************/ -int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int MPXFAM::InitDelete(PGLOBAL, int fpos, int) { Fpos = Memory + Headlen + (ptrdiff_t)fpos * Lrecl; Mempos = Fpos + Lrecl; @@ -740,7 +740,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ /* WriteBuffer: File write routine for MAP access method. */ /***********************************************************************/ -int MPXFAM::WriteBuffer(PGLOBAL g) +int MPXFAM::WriteBuffer(PGLOBAL g __attribute__((unused))) { #if defined(_DEBUG) // Insert mode is no more handled using file mapping diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index f1fc466a5fc..8afda723578 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -1,11 +1,11 @@ /*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/ /* PROGRAM NAME: FILAMDBF */ /* ------------- */ -/* Version 1.7 */ +/* Version 1.8 */ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -22,12 +22,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> //#include <errno.h> //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -35,7 +35,7 @@ //#include <io.h> #endif // !UNIX //#include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ #include <ctype.h> #include <stdio.h> #include <string.h> @@ -74,28 +74,28 @@ typedef struct _dbfheader { //uchar Dbfox :4; /* FoxPro if equal to 3 */ uchar Version; /* Version information flags */ char Filedate[3]; /* date, YYMMDD, binary. YY=year-1900 */ -private: + private: /* The following four members are stored in little-endian format on disk */ char m_RecordsBuf[4]; /* records in the file */ char m_HeadlenBuf[2]; /* bytes in the header */ char m_ReclenBuf[2]; /* bytes in a record */ char m_FieldsBuf[2]; /* Reserved but used to store fields */ -public: + public: char Incompleteflag; /* 01 if incomplete, else 00 */ char Encryptflag; /* 01 if encrypted, else 00 */ char Reserved2[12]; /* for LAN use */ char Mdxflag; /* 01 if production .mdx, else 00 */ char Language; /* Codepage */ char Reserved3[2]; - - uint Records() const { return uint4korr(m_RecordsBuf); } - ushort Headlen() const { return uint2korr(m_HeadlenBuf); } - ushort Reclen() const { return uint2korr(m_ReclenBuf); } - ushort Fields() const { return uint2korr(m_FieldsBuf); } - - void SetHeadlen(ushort num) { int2store(m_HeadlenBuf, num); } - void SetReclen(ushort num) { int2store(m_ReclenBuf, num); } - void SetFields(ushort num) { int2store(m_FieldsBuf, num); } + + uint Records(void) const {return uint4korr(m_RecordsBuf);} + ushort Headlen(void) const {return uint2korr(m_HeadlenBuf);} + ushort Reclen(void) const {return uint2korr(m_ReclenBuf);} + ushort Fields(void) const {return uint2korr(m_FieldsBuf);} + + void SetHeadlen(ushort num) {int2store(m_HeadlenBuf, num);} + void SetReclen(ushort num) {int2store(m_ReclenBuf, num);} + void SetFields(ushort num) {int2store(m_FieldsBuf, num);} } DBFHEADER; /****************************************************************************/ @@ -410,13 +410,13 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath) } else if (rc == RC_FX) return -1; - if ((int) header.Reclen() != lrecl) { + if ((int)header.Reclen() != lrecl) { sprintf(g->Message, MSG(BAD_LRECL), lrecl, header.Reclen()); return -1; } // endif Lrecl - Records = (int) header.Records(); - return (int) header.Headlen(); + Records = (int)header.Records(); + return (int)header.Headlen(); } // end of ScanHeader /* ---------------------------- Class DBFFAM ------------------------------ */ @@ -528,7 +528,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); if (mode == MODE_INSERT) { -#if defined(WIN32) +#if defined(__WIN__) /************************************************************************/ /* Now we can revert to binary mode in particular because the eventual */ /* writing of a new header must be done in binary mode to avoid */ @@ -538,7 +538,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno)); return true; } // endif setmode -#endif // WIN32 +#endif // __WIN__ /************************************************************************/ /* If this is a new file, the header must be generated. */ @@ -577,8 +577,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) header->Filedate[0] = datm->tm_year - 100; header->Filedate[1] = datm->tm_mon + 1; header->Filedate[2] = datm->tm_mday; - header->SetHeadlen((ushort) hlen); - header->SetReclen((ushort) reclen); + header->SetHeadlen((ushort)hlen); + header->SetReclen((ushort)reclen); descp = (DESCRIPTOR*)header; // Currently only standard Xbase types are supported @@ -639,13 +639,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) DBFHEADER header; if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) { - if (Lrecl != (int) header.Reclen()) { + if (Lrecl != (int)header.Reclen()) { sprintf(g->Message, MSG(BAD_LRECL), Lrecl, header.Reclen()); return true; } // endif Lrecl - Records = (int) header.Records(); - Headlen = (int) header.Headlen(); + Records = (int)header.Records(); + Headlen = (int)header.Headlen(); } else if (rc == RC_NF) { Records = 0; Headlen = 0; @@ -881,9 +881,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort) if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b"))) { char nRecords[4]; - int4store(&nRecords, n); + int4store(nRecords, n); + fseek(Stream, 4, SEEK_SET); // Get header.Records position - fwrite(&nRecords, sizeof(nRecords), 1, Stream); + fwrite(nRecords, sizeof(nRecords), 1, Stream); fclose(Stream); Stream= NULL; Records= n; // Update Records value @@ -958,13 +959,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g) /************************************************************************/ DBFHEADER *hp = (DBFHEADER*)Memory; - if (Lrecl != (int) hp->Reclen()) { + if (Lrecl != (int)hp->Reclen()) { sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen()); return true; } // endif Lrecl - Records = (int) hp->Records(); - Headlen = (int) hp->Headlen(); + Records = (int)hp->Records(); + Headlen = (int)hp->Headlen(); } // endif Headlen /**************************************************************************/ diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index 980d558eee5..cd25429318a 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #endif // !UNIX #include <sys/stat.h> #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -46,6 +46,7 @@ #include "plgdbsem.h" #include "filamfix.h" #include "tabdos.h" +#include "tabfix.h" #include "osutil.h" #ifndef INVALID_SET_FILE_POINTER @@ -102,7 +103,7 @@ bool FIXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Initialize CurBlk and CurNum for indexed DELETE. */ /***********************************************************************/ -int FIXFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int FIXFAM::InitDelete(PGLOBAL, int fpos, int) { CurBlk = fpos / Nrec; CurNum = fpos % Nrec; @@ -133,18 +134,35 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() == RECFM_BIN) { // The buffer must be prepared depending on column types int n = 0; + bool b = false; PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); - PCOLDEF cdp; +// PCOLDEF cdp; + PBINCOL colp; // Prepare the first line of the buffer memset(To_Buf, 0, Buflen); +#if 0 for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) { - if (IsTypeNum(cdp->GetType())) - memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + if (!IsTypeNum(cdp->GetType())) { + memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + b = true; + } // endif not num - n = MY_MAX(n, cdp->GetPoff() + cdp->GetClen()); + n = MY_MAX(n, cdp->GetOffset() + cdp->GetClen()); } // endfor cdp +#endif // 0 + + for (colp = (PBINCOL)Tdbp->GetColumns(); colp; + colp = (PBINCOL)colp->GetNext()) + if (!colp->IsSpecial()) { + if (!IsTypeNum(colp->GetResultType())) { + memset(To_Buf + colp->GetDeplac(), ' ', colp->GetLength()); + b = true; + } // endif not num + + n = MY_MAX(n, colp->GetDeplac() + colp->GetFileSize()); + } // endif !special // We do this for binary table because the lrecl can have been // specified with additional space to include line ending. @@ -156,9 +174,10 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) } // endif n - // Now repeat this for the whole buffer - for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) - memcpy(To_Buf + len, To_Buf, Lrecl); + if (b) + // Now repeat this for the whole buffer + for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) + memcpy(To_Buf + len, To_Buf, Lrecl); } else { memset(To_Buf, ' ', Buflen); @@ -319,10 +338,10 @@ int FIXFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif if (trace) @@ -659,7 +678,7 @@ BGXFAM::BGXFAM(PBGXFAM txfp) : FIXFAM(txfp) /***********************************************************************/ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) { -#if defined(WIN32) +#if defined(__WIN__) char buf[256]; DWORD drc; LARGE_INTEGER of; @@ -675,14 +694,14 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) sprintf(g->Message, MSG(SFP_ERROR), buf); return true; } // endif -#else // !WIN32 +#else // !__WIN__ if (lseek64(h, pos, org) < 0) { // sprintf(g->Message, MSG(ERROR_IN_LSK), errno); sprintf(g->Message, "lseek64: %s", strerror(errno)); printf("%s\n", g->Message); return true; } // endif -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of BigSeek @@ -690,11 +709,12 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) /***********************************************************************/ /* Read from a big file. */ /***********************************************************************/ -int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) +int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), + HANDLE h, void *inbuf, int req) { int rc; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -716,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = -1; } else rc = (int)nbr; -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); rc = (int)nbr; -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigRead @@ -733,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); @@ -760,7 +780,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbw -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -775,7 +795,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigWrite @@ -810,7 +830,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) if (trace) htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode); -#if defined(WIN32) +#if defined(__WIN__) DWORD rc, access, creation, share = 0; /*********************************************************************/ @@ -967,7 +987,7 @@ int BGXFAM::Cardinality(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); -#if defined(WIN32) // OB +#if defined(__WIN__) // OB LARGE_INTEGER len; DWORD rc = 0; @@ -1326,7 +1346,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl)) return RC_FX; @@ -1336,12 +1356,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !WIN32 +#else // !__WIN__ if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !WIN32 +#endif // !__WIN__ } // endif UseTemp @@ -1366,7 +1386,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g) strcat(PlugRemoveType(tempname, tempname), ".t"); remove(tempname); // Be sure it does not exist yet -#if defined(WIN32) +#if defined(__WIN__) Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); @@ -1506,7 +1526,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort) void BGXFAM::Rewind(void) { #if 0 // This is probably unuseful because file is accessed directly -#if defined(WIN32) //OB +#if defined(__WIN__) //OB SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index eb4e026ee8a..e53cdcd9ba9 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) || defined(UNIV_LINUX) #include <errno.h> #include <unistd.h> @@ -36,7 +36,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -436,7 +436,7 @@ err: /* The purpose of this function is to deal with access methods that */ /* are not coherent regarding the use of SetPos and GetPos. */ /***********************************************************************/ -int TXTFAM::InitDelete(PGLOBAL g, int fpos, int spos) +int TXTFAM::InitDelete(PGLOBAL g, int, int) { strcpy(g->Message, "InitDelete should not be used by this table type"); return RC_FX; @@ -519,7 +519,7 @@ int DOSFAM::Cardinality(PGLOBAL g) /* Use BlockTest to reduce the table estimated size. */ /* Note: This function is not really implemented yet. */ /***********************************************************************/ -int DOSFAM::MaxBlkSize(PGLOBAL g, int s) +int DOSFAM::MaxBlkSize(PGLOBAL, int s) { return s; } // end of MaxBlkSize @@ -716,10 +716,10 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header) if (feof(Stream)) return RC_EF; -#if defined(UNIX) || defined(UNIV_LINUX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); #endif return RC_FX; } // endif fgets @@ -799,12 +799,12 @@ int DOSFAM::ReadBuffer(PGLOBAL g) if (trace > 1) htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p); -#if defined(UNIX) - if (true) { - // Data files can be imported from Windows (having CRLF) -#else +#if defined(__WIN__) if (Bin) { // Data file is read in binary so CRLF remains +#else + if (true) { + // Data files can be imported from Windows (having CRLF) #endif if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? @@ -833,10 +833,10 @@ int DOSFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); #endif if (trace) @@ -1028,15 +1028,15 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(UNIX) - if (ftruncate(h, (off_t)Tpos)) { - sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); +#if defined(__WIN__) + if (chsize(h, Tpos)) { + sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); close(h); return RC_FX; } // endif #else - if (chsize(h, Tpos)) { - sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); + if (ftruncate(h, (off_t)Tpos)) { + sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); close(h); return RC_FX; } // endif @@ -1272,7 +1272,7 @@ int BLKFAM::Cardinality(PGLOBAL g) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int BLKFAM::MaxBlkSize(PGLOBAL g, int s) +int BLKFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -1343,7 +1343,7 @@ int BLKFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool BLKFAM::SetPos(PGLOBAL g, int pos) +bool BLKFAM::SetPos(PGLOBAL g, int) { strcpy(g->Message, "Blocked variable tables cannot be used indexed"); return true; @@ -1353,7 +1353,7 @@ bool BLKFAM::SetPos(PGLOBAL g, int pos) /* Record file position in case of UPDATE or DELETE. */ /* Not used yet for blocked tables. */ /***********************************************************************/ -bool BLKFAM::RecordPos(PGLOBAL g) +bool BLKFAM::RecordPos(PGLOBAL) { Fpos = (CurNum + Nrec * CurBlk); // Computed file index return false; @@ -1362,7 +1362,7 @@ bool BLKFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int BLKFAM::SkipRecord(PGLOBAL g, bool header) +int BLKFAM::SkipRecord(PGLOBAL, bool header) { if (header) { // For Delete @@ -1466,10 +1466,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(UNIX) - sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#else +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); +#else + sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif if (trace) @@ -1551,11 +1551,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g) Spos = GetNextPos(); // New start position // Prepare the output buffer -#if defined(WIN32) +#if defined(__WIN__) crlf = "\r\n"; #else crlf = "\n"; -#endif // WIN32 +#endif // __WIN__ strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf); len = strlen(OutBuf); } else { diff --git a/storage/connect/filamtxt.h b/storage/connect/filamtxt.h index 1c8ea1e3a6c..ae8f74a9830 100644 --- a/storage/connect/filamtxt.h +++ b/storage/connect/filamtxt.h @@ -57,8 +57,8 @@ class DllExport TXTFAM : public BLOCK { virtual int GetFileLength(PGLOBAL g); virtual int Cardinality(PGLOBAL g); virtual int MaxBlkSize(PGLOBAL g, int s); - virtual bool AllocateBuffer(PGLOBAL g) {return false;} - virtual void ResetBuffer(PGLOBAL g) {} + virtual bool AllocateBuffer(PGLOBAL) {return false;} + virtual void ResetBuffer(PGLOBAL) {} virtual int GetNerr(void) {return 0;} virtual int GetRowID(void) = 0; virtual bool RecordPos(PGLOBAL g) = 0; diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index e1f11bbf4cf..fdc5433f4a4 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -21,7 +21,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -29,7 +29,7 @@ #endif // __BORLAND__ //#include <windows.h> #include <sys/stat.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -40,7 +40,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -49,7 +49,7 @@ /* tabdos.h is header containing the TABDOS class declarations. */ /***********************************************************************/ #include "global.h" -#include "osutil.h" // Unuseful for WIN32 +#include "osutil.h" // Unuseful for WINDOWS #include "plgdbsem.h" #include "valblk.h" #include "filamfix.h" @@ -279,7 +279,7 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int VCTFAM::MaxBlkSize(PGLOBAL g, int s) +int VCTFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -376,11 +376,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn) int h, n; PlugSetPath(filename, fn, Tdbp->GetPath()); -#if defined(WIN32) +#if defined(__WIN__) h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE); -#else // !WIN32 +#else // !__WIN__ h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE); -#endif // !WIN32 +#endif // !__WIN__ if (h == -1) return true; @@ -1669,7 +1669,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) // Remove extra blocks n = Block * Blksize; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -1716,7 +1716,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Move intermediate deleted or updated lines. */ /***********************************************************************/ -bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b) +bool VCMFAM::MoveIntermediateLines(PGLOBAL, bool *) { int i, m, n; @@ -1765,7 +1765,7 @@ bool VCMFAM::MoveIntermediateLines(PGLOBAL g, bool *b) /***********************************************************************/ /* Data Base close routine for VMP access method. */ /***********************************************************************/ -void VCMFAM::CloseTableFile(PGLOBAL g, bool abort) +void VCMFAM::CloseTableFile(PGLOBAL g, bool) { int wrc = RC_OK; MODE mode = Tdbp->GetMode(); @@ -1800,7 +1800,7 @@ void VCMFAM::CloseTableFile(PGLOBAL g, bool abort) /***********************************************************************/ /* ReadBlock: Read column values from current block. */ /***********************************************************************/ -bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) +bool VCMFAM::ReadBlock(PGLOBAL, PVCTCOL colp) { char *mempos; int i = colp->Index - 1; @@ -1830,7 +1830,7 @@ bool VCMFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) /* the mapped file, except when checking for Update but in this case */ /* we do not want to write back the modifications either. */ /***********************************************************************/ -bool VCMFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) +bool VCMFAM::WriteBlock(PGLOBAL, PVCTCOL colp __attribute__((unused))) { #if defined(_DEBUG) char *mempos; @@ -2124,7 +2124,7 @@ bool VECFAM::AllocateBuffer(PGLOBAL g) /***********************************************************************/ /* Do initial action when inserting. */ /***********************************************************************/ -bool VECFAM::InitInsert(PGLOBAL g) +bool VECFAM::InitInsert(PGLOBAL) { // We come here in MODE_INSERT only CurBlk = 0; @@ -2365,7 +2365,7 @@ bool VECFAM::MoveLines(PGLOBAL g) /***********************************************************************/ /* Move intermediate deleted or updated lines. */ /***********************************************************************/ -bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn) +bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *) { int i, n; bool b = false; @@ -2574,11 +2574,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) char fn[_MAX_PATH]; sprintf(fn, Colfn, colp->Index); -#if defined(WIN32) +#if defined(__WIN__) if (feof(Streams[i])) -#else // !WIN32 +#else // !__WIN__ if (errno == NO_ERROR) -#endif // !WIN32 +#endif // !__WIN__ sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn); else sprintf(g->Message, MSG(READ_ERROR), @@ -2969,7 +2969,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = Tpos * Clens[i]; -#if defined(WIN32) +#if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -3009,7 +3009,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for VMP access method. */ /***********************************************************************/ -void VMPFAM::CloseTableFile(PGLOBAL g, bool abort) +void VMPFAM::CloseTableFile(PGLOBAL g, bool) { if (Tdbp->GetMode() == MODE_DELETE) { // Set Block and Nrec values for TDBVCT::MakeBlockValues @@ -3049,7 +3049,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp) /***********************************************************************/ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) { -#if defined(WIN32) +#if defined(__WIN__) char buf[256]; DWORD drc, m = (b) ? FILE_END : FILE_BEGIN; LARGE_INTEGER of; @@ -3065,12 +3065,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) sprintf(g->Message, MSG(SFP_ERROR), buf); return true; } // endif -#else // !WIN32 +#else // !__WIN__ if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) { sprintf(g->Message, MSG(ERROR_IN_LSK), errno); return true; } // endif -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of BigSeek @@ -3082,7 +3082,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -3108,7 +3108,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbr -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); @@ -3123,7 +3123,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigRead @@ -3135,7 +3135,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); @@ -3162,7 +3162,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif brc || nbw -#else // !WIN32 +#else // !__WIN__ size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -3177,7 +3177,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of BigWrite @@ -3203,7 +3203,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) if (Header == 2) strcat(PlugRemoveType(filename, filename), ".blk"); -#if defined(WIN32) +#if defined(__WIN__) LARGE_INTEGER len; h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -3215,11 +3215,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) } // endif h if (h == INVALID_HANDLE_VALUE || !len.QuadPart) { -#else // !WIN32 +#else // !__WIN__ h = open64(filename, O_RDONLY, 0); if (h == INVALID_HANDLE_VALUE || !_filelength(h)) { -#endif // !WIN32 +#endif // !__WIN__ // Consider this is a void table if (trace) htrc("Void table h=%d\n", h); @@ -3280,17 +3280,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) strcat(PlugRemoveType(filename, filename), ".blk"); if (h == INVALID_HANDLE_VALUE) { -#if defined(WIN32) +#if defined(__WIN__) DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING; h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL); -#else // !WIN32 +#else // !__WIN__ int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC; h = open64(filename, oflag, 0); -#endif // !WIN32 +#endif // !__WIN__ if (h == INVALID_HANDLE_VALUE) { sprintf(g->Message, "Error opening header file %s", filename); @@ -3328,7 +3328,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) PlugSetPath(filename, fn, Tdbp->GetPath()); -#if defined(WIN32) +#if defined(__WIN__) char *p; DWORD rc; bool brc; @@ -3380,7 +3380,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) CloseHandle(h); return true; -#else // !WIN32 +#else // !__WIN__ int h; BIGINT pos; @@ -3409,7 +3409,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); close(h); return true; -#endif // !WIN32 +#endif // !__WIN__ } // end of MakeEmptyFile /***********************************************************************/ @@ -3440,7 +3440,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) htrc("OpenTableFile: filename=%s mode=%d Last=%d\n", filename, mode, Last); -#if defined(WIN32) +#if defined(__WIN__) DWORD access, creation, share = 0, rc = 0; /*********************************************************************/ @@ -3766,7 +3766,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g) if (!Closing && !MaxBlk) { // Close the VCT file and reopen it in mode Insert -//#if defined(WIN32) //OB +//#if defined(__WIN__) //OB // CloseHandle(Hfile); //#else // UNIX // close(Hfile); @@ -3893,7 +3893,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) /***************************************************************/ /* Remove extra records. */ /***************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) BIGINT pos = (BIGINT)Block * (BIGINT)Blksize; if (BigSeek(g, Hfile, pos)) @@ -3905,12 +3905,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !WIN32 +#else // !__WIN__ if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !WIN32 +#endif // !__WIN__ } else // MaxBlk // Clean the unused space in the file, this is required when // inserting again with a partial column list. @@ -3947,7 +3947,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g) else if (MakeEmptyFile(g, tempname)) return true; -#if defined(WIN32) +#if defined(__WIN__) DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW; Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, @@ -4218,7 +4218,7 @@ void BGVFAM::Rewind(void) CurNum = Nrec - 1; #if 0 // This is probably unuseful as the file is directly accessed -#if defined(WIN32) //OB +#if defined(__WIN__) //OB SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index 1288689325c..56faa555069 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,21 +17,21 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #else // !UNIX #include <io.h> #endif #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -89,11 +89,11 @@ int ZIPFAM::Zerror(PGLOBAL g) strcpy(g->Message, gzerror(Zfile, &errnum)); if (errnum == Z_ERRNO) -#if defined(WIN32) +#if defined(__WIN__) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL)); -#else // !WIN32 +#else // !__WIN__ sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#endif // !WIN32 +#endif // !__WIN__ return (errnum == Z_STREAM_END) ? RC_EF : RC_FX; } // end of Zerror @@ -247,7 +247,7 @@ int ZIPFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool ZIPFAM::SetPos(PGLOBAL g, int pos) +bool ZIPFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) { sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP"); return true; @@ -267,7 +267,7 @@ bool ZIPFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ /* Record file position in case of UPDATE or DELETE. */ /***********************************************************************/ -bool ZIPFAM::RecordPos(PGLOBAL g) +bool ZIPFAM::RecordPos(PGLOBAL) { Zpos = gztell(Zfile); return false; @@ -376,7 +376,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for ZDOS access method. (NIY) */ /***********************************************************************/ -int ZIPFAM::DeleteRecords(PGLOBAL g, int irc) +int ZIPFAM::DeleteRecords(PGLOBAL g, int) { strcpy(g->Message, MSG(NO_ZIP_DELETE)); return RC_FX; @@ -385,7 +385,7 @@ int ZIPFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for DOS access method. */ /***********************************************************************/ -void ZIPFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZIPFAM::CloseTableFile(PGLOBAL, bool) { int rc = gzclose(Zfile); @@ -431,7 +431,7 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp) /***********************************************************************/ /* Use BlockTest to reduce the table estimated size. */ /***********************************************************************/ -int ZBKFAM::MaxBlkSize(PGLOBAL g, int s) +int ZBKFAM::MaxBlkSize(PGLOBAL g, int) { int rc = RC_OK, savcur = CurBlk; int size; @@ -503,7 +503,7 @@ int ZBKFAM::GetPos(void) /* Record file position in case of UPDATE or DELETE. */ /* Not used yet for fixed tables. */ /***********************************************************************/ -bool ZBKFAM::RecordPos(PGLOBAL g) +bool ZBKFAM::RecordPos(PGLOBAL /*g*/) { //strcpy(g->Message, "RecordPos not implemented for zip blocked tables"); //return true; @@ -513,7 +513,7 @@ bool ZBKFAM::RecordPos(PGLOBAL g) /***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ -int ZBKFAM::SkipRecord(PGLOBAL g, bool header) +int ZBKFAM::SkipRecord(PGLOBAL /*g*/, bool) { //strcpy(g->Message, "SkipRecord not implemented for zip blocked tables"); //return RC_FX; @@ -668,7 +668,7 @@ int ZBKFAM::DeleteRecords(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for ZBK access method. */ /***********************************************************************/ -void ZBKFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZBKFAM::CloseTableFile(PGLOBAL g, bool) { int rc = RC_OK; @@ -764,9 +764,9 @@ bool ZIXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() < 2) // if not binary, the file is physically a text file for (int len = Lrecl; len <= Buflen; len += Lrecl) { -#if defined(WIN32) +#if defined(__WIN__) To_Buf[len - 2] = '\r'; -#endif // WIN32 +#endif // __WIN__ To_Buf[len - 1] = '\n'; } // endfor len @@ -1060,7 +1060,7 @@ int ZLBFAM::GetNextPos(void) /***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ -bool ZLBFAM::SetPos(PGLOBAL g, int pos) +bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) { sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP"); return true; @@ -1350,7 +1350,7 @@ bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g) /***********************************************************************/ /* Table file close routine for DOS access method. */ /***********************************************************************/ -void ZLBFAM::CloseTableFile(PGLOBAL g, bool abort) +void ZLBFAM::CloseTableFile(PGLOBAL g, bool) { int rc = RC_OK; diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 949d49c2943..262d6b58a70 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -13,13 +13,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ diff --git a/storage/connect/filter.h b/storage/connect/filter.h index 78e066d9ab7..15730e2cc44 100644 --- a/storage/connect/filter.h +++ b/storage/connect/filter.h @@ -1,7 +1,7 @@ /*************** Filter H Declares Source Code File (.H) ***************/ /* Name: FILTER.H Version 1.2 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2010-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 2010-2015 */ /* */ /* This file contains the FILTER and derived classes declares. */ /***********************************************************************/ @@ -105,8 +105,8 @@ class FILTERX : public FILTER { virtual bool Eval(PGLOBAL) = 0; // just to prevent direct FILTERX use // Fake operator new used to change a filter into a derived filter - void * operator new(size_t size, PFIL filp) {return filp;} -#if defined(WIN32) + void * operator new(size_t, PFIL filp) {return filp;} +#if defined(__WIN__) // Avoid warning C4291 by defining a matching dummy delete operator void operator delete(void *, PFIL) {} #else diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index a72a2b9b31e..22c3a1e79ad 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -20,11 +20,12 @@ */ #define FLEX_SCANNER -#if WIN32 +#ifdef __WIN__ #define __STDC__ 1 +#define isatty _isatty #endif #include <stdio.h> -#ifndef WIN32 +#ifndef __WIN__ #include <unistd.h> #endif diff --git a/storage/connect/global.h b/storage/connect/global.h index 10564d09815..4d01a3ff05b 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -13,11 +13,11 @@ #include <time.h> /* time_t type declaration */ #include <setjmp.h> /* Long jump declarations */ -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #define XML_SUPPORT 1 @@ -42,11 +42,11 @@ #define STEP(I) MSG_##I #endif // !XMSG and !NEWMSG -#if defined(WIN32) +#if defined(__WIN__) #define CRLF 2 -#else // !WIN32 +#else // !__WIN__ #define CRLF 1 -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Define access to the thread based trace value. */ @@ -104,7 +104,7 @@ #define SYS_STAMP "DOSR" #elif defined(WIN) #define SYS_STAMP "WIN1" -#elif defined(WIN32) +#elif defined(__WIN__) #define SYS_STAMP "WIN2" #else #define SYS_STAMP "XXXX" @@ -248,9 +248,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *); #elif defined(NEWMSG) DllExport char *PlugGetMessage(PGLOBAL, int); #endif // XMSG || NEWMSG -#if defined(WIN32) +#if defined(__WIN__) DllExport short GetLineLength(PGLOBAL); // Console line length -#endif // WIN32 +#endif // __WIN__ DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 2c8e563ffdc..d3741349026 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -138,10 +138,10 @@ #include "reldef.h" #include "tabcol.h" #include "xindex.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include "tabwmi.h" -#endif // WIN32 +#endif // __WIN__ #include "connect.h" #include "user_connect.h" #include "ha_connect.h" @@ -153,6 +153,7 @@ #endif // LIBXML2_SUPPORT #include "taboccur.h" #include "tabpivot.h" +#include "tabfix.h" #define my_strupr(p) my_caseup_str(default_charset_info, (p)); #define my_strlwr(p) my_casedn_str(default_charset_info, (p)); @@ -168,13 +169,13 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.03.0007 April 30, 2015"; -#if defined(WIN32) + char version[]= "Version 1.03.0007 June 03, 2015"; +#if defined(__WIN__) char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__; char slash= '\\'; -#else // !WIN32 +#else // !__WIN__ char slash= '/'; -#endif // !WIN32 +#endif // !__WIN__ } // extern "C" #if defined(XMAP) @@ -193,10 +194,9 @@ extern "C" { /* Utility functions. */ /***********************************************************************/ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info); -PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, - int pretty, int lvl, int mxr, bool info); -PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info); +PQRYRES VirColumns(PGLOBAL g, bool info); +PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info); +PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info); void PushWarning(PGLOBAL g, THD *thd, int level); bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, const char *db, char *tab, const char *src, int port); @@ -349,7 +349,7 @@ int GetConvSize(void) {return THDVAR(current_thd, conv_size);} TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);} uint GetJsonGrpSize(void) {return THDVAR(current_thd, json_grp_size);} uint GetWorkSize(void) {return THDVAR(current_thd, work_size);} -void SetWorkSize(uint n) +void SetWorkSize(uint) { // Changing the session variable value seems to be impossible here // and should be done in a check function @@ -629,11 +629,11 @@ static int connect_init_func(void *p) } #endif // 0 (LINUX) -#if defined(WIN32) +#if defined(__WIN__) sql_print_information("CONNECT: %s", compver); -#else // !WIN32 +#else // !__WIN__ sql_print_information("CONNECT: %s", version); -#endif // !WIN32 +#endif // !__WIN__ #ifdef LIBXML2_SUPPORT XmlInitParserLib(); @@ -656,6 +656,7 @@ static int connect_init_func(void *p) sql_print_information("connect_init: hton=%p", p); DTVAL::SetTimeShift(); // Initialize time zone shift once for all + BINCOL::SetEndian(); // Initialize host endian setting DBUG_RETURN(0); } // end of connect_init_func @@ -664,7 +665,7 @@ static int connect_init_func(void *p) @brief Plugin clean up */ -static int connect_done_func(void *p) +static int connect_done_func(void *) { int error= 0; PCONNECT pc, pn; @@ -674,9 +675,9 @@ static int connect_done_func(void *p) XmlCleanupParserLib(); #endif // LIBXML2_SUPPORT -#if !defined(WIN32) +#if !defined(__WIN__) //PROFILE_End(); Causes signal 11 -#endif // !WIN32 +#endif // !__WIN__ for (pc= user_connect::to_users; pc; pc= pn) { if (pc->g) @@ -743,11 +744,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) xp= (table) ? GetUser(ha_thd(), NULL) : NULL; if (xp) xp->SetHandler(this); -#if defined(WIN32) +#if defined(__WIN__) datapath= ".\\"; -#else // !WIN32 +#else // !__WIN__ datapath= "./"; -#endif // !WIN32 +#endif // !__WIN__ tdbp= NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL; sdvalout= NULL; @@ -822,8 +823,6 @@ ha_connect::~ha_connect(void) /****************************************************************************/ static PCONNECT GetUser(THD *thd, PCONNECT xp) { - const char *dbn= NULL; - if (!thd) return NULL; @@ -835,7 +834,7 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp) break; if (!xp) { - xp= new user_connect(thd, dbn); + xp= new user_connect(thd); if (xp->user_init()) { delete xp; @@ -908,7 +907,8 @@ const char *ha_connect::index_type(uint inx) If all_parts is set, MySQL wants to know the flags for the combined index, up to and including 'part'. */ -ulong ha_connect::index_flags(uint inx, uint part, bool all_parts) const +//ong ha_connect::index_flags(uint inx, uint part, bool all_parts) const +ulong ha_connect::index_flags(uint, uint, bool) const { ulong flags= HA_READ_NEXT | HA_READ_RANGE | HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR; @@ -1017,6 +1017,117 @@ char *GetListOption(PGLOBAL g, const char *opname, } // end of GetListOption /****************************************************************************/ +/* Return the value of a string option or NULL if not specified. */ +/****************************************************************************/ +char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef) +{ + const char *opval= NULL; + + if (!options) + return sdef; + else if (!stricmp(opname, "Type")) + opval= options->type; + else if (!stricmp(opname, "Filename")) + opval= options->filename; + else if (!stricmp(opname, "Optname")) + opval= options->optname; + else if (!stricmp(opname, "Tabname")) + opval= options->tabname; + else if (!stricmp(opname, "Tablist")) + opval= options->tablist; + else if (!stricmp(opname, "Database") || + !stricmp(opname, "DBname")) + opval= options->dbname; + else if (!stricmp(opname, "Separator")) + opval= options->separator; + else if (!stricmp(opname, "Qchar")) + opval= options->qchar; + else if (!stricmp(opname, "Module")) + opval= options->module; + else if (!stricmp(opname, "Subtype")) + opval= options->subtype; + else if (!stricmp(opname, "Catfunc")) + opval= options->catfunc; + else if (!stricmp(opname, "Srcdef")) + opval= options->srcdef; + else if (!stricmp(opname, "Colist")) + opval= options->colist; + else if (!stricmp(opname, "Data_charset")) + opval= options->data_charset; + + if (!opval && options && options->oplist) + opval= GetListOption(g, opname, options->oplist); + + return opval ? (char*)opval : sdef; +} // end of GetStringTableOption + +/****************************************************************************/ +/* Return the value of a Boolean option or bdef if not specified. */ +/****************************************************************************/ +bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef) +{ + bool opval= bdef; + char *pv; + + if (!options) + return bdef; + else if (!stricmp(opname, "Mapped")) + opval= options->mapped; + else if (!stricmp(opname, "Huge")) + opval= options->huge; + else if (!stricmp(opname, "Split")) + opval= options->split; + else if (!stricmp(opname, "Readonly")) + opval= options->readonly; + else if (!stricmp(opname, "SepIndex")) + opval= options->sepindex; + else if (!stricmp(opname, "Header")) + opval= (options->header != 0); // Is Boolean for some table types + else if (options->oplist) + if ((pv= GetListOption(g, opname, options->oplist))) + opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); + + return opval; +} // end of GetBooleanTableOption + +/****************************************************************************/ +/* Return the value of an integer option or NO_IVAL if not specified. */ +/****************************************************************************/ +int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef) +{ + ulonglong opval= NO_IVAL; + + if (!options) + return idef; + else if (!stricmp(opname, "Lrecl")) + opval= options->lrecl; + else if (!stricmp(opname, "Elements")) + opval= options->elements; + else if (!stricmp(opname, "Multiple")) + opval= options->multiple; + else if (!stricmp(opname, "Header")) + opval= options->header; + else if (!stricmp(opname, "Quoted")) + opval= options->quoted; + else if (!stricmp(opname, "Ending")) + opval= options->ending; + else if (!stricmp(opname, "Compressed")) + opval= (options->compressed); + + if (opval == NO_IVAL) { + char *pv; + + if ((pv= GetListOption(g, opname, options->oplist))) + opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true); + else + return idef; + + } // endif opval + + return (int)opval; +} // end of GetIntegerTableOption + +/****************************************************************************/ /* Return the table option structure. */ /****************************************************************************/ PTOS ha_connect::GetTableOptionStruct(TABLE_SHARE *s) @@ -1034,9 +1145,6 @@ char *ha_connect::GetRealString(const char *s) char *sv; if (IsPartitioned() && s) { -// sv= (char*)PlugSubAlloc(xp->g, NULL, strlen(s) + strlen(partname)); - // With wrong string pattern, the size of the constructed string - // can be more than strlen(s) + strlen(partname) sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sprintf(sv, s, partname); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); @@ -1047,7 +1155,7 @@ char *ha_connect::GetRealString(const char *s) } // end of GetRealString /****************************************************************************/ -/* Return the value of a string option or NULL if not specified. */ +/* Return the value of a string option or sdef if not specified. */ /****************************************************************************/ char *ha_connect::GetStringOption(char *opname, char *sdef) { @@ -1065,37 +1173,6 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) opval= thd_query_string(table->in_use)->str; else if (!stricmp(opname, "Partname")) opval= partname; - else if (!options) - ; - else if (!stricmp(opname, "Type")) - opval= (char*)options->type; - else if (!stricmp(opname, "Filename")) - opval= GetRealString(options->filename); - else if (!stricmp(opname, "Optname")) - opval= (char*)options->optname; - else if (!stricmp(opname, "Tabname")) - opval= GetRealString(options->tabname); - else if (!stricmp(opname, "Tablist")) - opval= (char*)options->tablist; - else if (!stricmp(opname, "Database") || - !stricmp(opname, "DBname")) - opval= (char*)options->dbname; - else if (!stricmp(opname, "Separator")) - opval= (char*)options->separator; - else if (!stricmp(opname, "Qchar")) - opval= (char*)options->qchar; - else if (!stricmp(opname, "Module")) - opval= (char*)options->module; - else if (!stricmp(opname, "Subtype")) - opval= (char*)options->subtype; - else if (!stricmp(opname, "Catfunc")) - opval= (char*)options->catfunc; - else if (!stricmp(opname, "Srcdef")) - opval= (char*)options->srcdef; - else if (!stricmp(opname, "Colist")) - opval= (char*)options->colist; - else if (!stricmp(opname, "Data_charset")) - opval= (char*)options->data_charset; else if (!stricmp(opname, "Table_charset")) { const CHARSET_INFO *chif= (tshp) ? tshp->table_charset : table->s->table_charset; @@ -1103,17 +1180,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) if (chif) opval= (char*)chif->csname; - } // endif Table_charset - - if (!opval && options && options->oplist) { - opval= GetListOption(xp->g, opname, options->oplist); - - if (opval && (!stricmp(opname, "connect") - || !stricmp(opname, "tabname") - || !stricmp(opname, "filename"))) - opval = GetRealString(opval); + } else + opval= GetStringTableOption(xp->g, options, opname, NULL); - } // endif opval + if (opval && (!stricmp(opname, "connect") + || !stricmp(opname, "tabname") + || !stricmp(opname, "filename"))) + opval = GetRealString(opval); if (!opval) { if (sdef && !strcmp(sdef, "*")) { @@ -1144,31 +1217,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) /****************************************************************************/ bool ha_connect::GetBooleanOption(char *opname, bool bdef) { - bool opval= bdef; - char *pv; + bool opval; PTOS options= GetTableOptionStruct(); if (!stricmp(opname, "View")) opval= (tshp) ? tshp->is_view : table_share->is_view; - else if (!options) - ; - else if (!stricmp(opname, "Mapped")) - opval= options->mapped; - else if (!stricmp(opname, "Huge")) - opval= options->huge; -//else if (!stricmp(opname, "Compressed")) -// opval= options->compressed; - else if (!stricmp(opname, "Split")) - opval= options->split; - else if (!stricmp(opname, "Readonly")) - opval= options->readonly; - else if (!stricmp(opname, "SepIndex")) - opval= options->sepindex; - else if (!stricmp(opname, "Header")) - opval= (options->header != 0); // Is Boolean for some table types - else if (options->oplist) - if ((pv= GetListOption(xp->g, opname, options->oplist))) - opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); + else + opval= GetBooleanTableOption(xp->g, options, opname, bdef); return opval; } // end of GetBooleanOption @@ -1197,37 +1252,18 @@ bool ha_connect::SetBooleanOption(char *opname, bool b) /****************************************************************************/ int ha_connect::GetIntegerOption(char *opname) { - ulonglong opval= NO_IVAL; - char *pv; + int opval; PTOS options= GetTableOptionStruct(); TABLE_SHARE *tsp= (tshp) ? tshp : table_share; if (!stricmp(opname, "Avglen")) - opval= (ulonglong)tsp->avg_row_length; + opval= (int)tsp->avg_row_length; else if (!stricmp(opname, "Estimate")) - opval= (ulonglong)tsp->max_rows; - else if (!options) - ; - else if (!stricmp(opname, "Lrecl")) - opval= options->lrecl; - else if (!stricmp(opname, "Elements")) - opval= options->elements; - else if (!stricmp(opname, "Multiple")) - opval= options->multiple; - else if (!stricmp(opname, "Header")) - opval= options->header; - else if (!stricmp(opname, "Quoted")) - opval= options->quoted; - else if (!stricmp(opname, "Ending")) - opval= options->ending; - else if (!stricmp(opname, "Compressed")) - opval= (options->compressed); - - if (opval == (ulonglong)NO_IVAL && options && options->oplist) - if ((pv= GetListOption(xp->g, opname, options->oplist))) - opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true); + opval= (int)tsp->max_rows; + else + opval= GetIntegerTableOption(xp->g, options, opname, NO_IVAL); - return (int)opval; + return opval; } // end of GetIntegerOption /****************************************************************************/ @@ -2008,7 +2044,7 @@ int ha_connect::MakeRecord(char *buf) /***********************************************************************/ /* Set row values from a MySQL pseudo record. Specific to MySQL. */ /***********************************************************************/ -int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) +int ha_connect::ScanRecord(PGLOBAL g, uchar *) { char attr_buffer[1024]; char data_buffer[1024]; @@ -2150,7 +2186,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) /* Check change in index column. Specific to MySQL. */ /* Should be elaborated to check for real changes. */ /***********************************************************************/ -int ha_connect::CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf) +int ha_connect::CheckRecord(PGLOBAL g, const uchar *, uchar *newbuf) { return ScanRecord(g, newbuf); } // end of dummy CheckRecord @@ -2923,7 +2959,7 @@ bool ha_connect::get_error_message(int error, String* buf) &dummy_errors); if (trace) - htrc("GEM(%u): %s\n", len, g->Message); + htrc("GEM(%d): len=%u %s\n", error, len, g->Message); msg[len]= '\0'; buf->copy(msg, (uint)strlen(msg), system_charset_info); @@ -3019,7 +3055,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) @brief Make the indexes for this table */ -int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt) +int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) { int rc= 0; PGLOBAL& g= xp->g; @@ -3223,7 +3259,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data) @see sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc */ -int ha_connect::delete_row(const uchar *buf) +int ha_connect::delete_row(const uchar *) { int rc= 0; DBUG_ENTER("ha_connect::delete_row"); @@ -3501,7 +3537,8 @@ int ha_connect::index_last(uchar *buf) /****************************************************************************/ /* This is called to get more rows having the same index value. */ /****************************************************************************/ -int ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen) +//t ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen) +int ha_connect::index_next_same(uchar *buf, const uchar *, uint) { int rc; DBUG_ENTER("ha_connect::index_next_same"); @@ -3690,7 +3727,7 @@ int ha_connect::rnd_next(uchar *buf) @see filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc */ -void ha_connect::position(const uchar *record) +void ha_connect::position(const uchar *) { DBUG_ENTER("ha_connect::position"); //if (((PTDBASE)tdbp)->GetDef()->Indexable()) @@ -3873,7 +3910,7 @@ int ha_connect::info(uint flag) @see ha_innodb.cc */ -int ha_connect::extra(enum ha_extra_function operation) +int ha_connect::extra(enum ha_extra_function /*operation*/) { DBUG_ENTER("ha_connect::extra"); DBUG_RETURN(0); @@ -3952,11 +3989,11 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) case TAB_JSON: if (options->filename && *options->filename) { char *s, path[FN_REFLEN], dbpath[FN_REFLEN]; -#if defined(WIN32) +#if defined(__WIN__) s= "\\"; -#else // !WIN32 +#else // !__WIN__ s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcpy(dbpath, mysql_real_data_home); if (db) @@ -4481,7 +4518,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) @see get_lock_data() in lock.cc */ -THR_LOCK_DATA **ha_connect::store_lock(THD *thd, +THR_LOCK_DATA **ha_connect::store_lock(THD *, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { @@ -4715,6 +4752,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, else rows= HA_POS_ERROR; + if (trace) + htrc("records_in_range: rows=%llu\n", rows); + DBUG_RETURN(rows); } // end of records_in_range @@ -4898,7 +4938,7 @@ static int init_table_share(THD* thd, oom|= sql->append(' '); oom|= sql->append(opt->name); oom|= sql->append('='); - oom|= sql->append(vull ? "ON" : "OFF"); + oom|= sql->append(vull ? "YES" : "NO"); } // endif vull break; @@ -4952,7 +4992,7 @@ static int init_table_share(THD* thd, @note this function is no more called in case of CREATE .. SELECT */ -static int connect_assisted_discovery(handlerton *hton, THD* thd, +static int connect_assisted_discovery(handlerton *, THD* thd, TABLE_SHARE *table_s, HA_CREATE_INFO *create_info) { @@ -4960,12 +5000,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, const char *fncn= "?"; const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src; const char *col, *ocl, *rnk, *pic, *fcl, *skc; - char *tab, *dsn, *shm, *dpath, *objn; -#if defined(WIN32) + char *tab, *dsn, *shm, *dpath; +#if defined(__WIN__) char *nsp= NULL, *cls= NULL; -#endif // WIN32 - int port= 0, hdr= 0, mxr __attribute__((unused))= 0, mxe= 0, rc= 0; - int cop __attribute__((unused))= 0, pty= 2, lrecl= 0, lvl= 0; +#endif // __WIN__ + int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0; + int cop __attribute__((unused))= 0, lrecl= 0; #if defined(ODBC_SUPPORT) POPARM sop = NULL; char *ucnc = NULL; @@ -4995,7 +5035,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, if (!g) return HA_ERR_INTERNAL_ERROR; - user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL; + user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL; // Get the useful create options ttp= GetTypeID(topt->type); @@ -5026,11 +5066,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, skc= GetListOption(g, "skipcol", topt->oplist, NULL); rnk= GetListOption(g, "rankcol", topt->oplist, NULL); pwd= GetListOption(g, "password", topt->oplist); - objn= GetListOption(g, "Object", topt->oplist, NULL); -#if defined(WIN32) +#if defined(__WIN__) nsp= GetListOption(g, "namespace", topt->oplist); cls= GetListOption(g, "class", topt->oplist); -#endif // WIN32 +#endif // __WIN__ port= atoi(GetListOption(g, "port", topt->oplist, "0")); #if defined(ODBC_SUPPORT) mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0")); @@ -5044,8 +5083,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #if defined(PROMPT_OK) cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0")); #endif // PROMPT_OK - pty= atoi(GetListOption(g,"Pretty", topt->oplist, "2")); - lvl= atoi(GetListOption(g,"Level", topt->oplist, "0")); } else { host= "localhost"; user= (ttp == TAB_ODBC ? NULL : "root"); @@ -5189,11 +5226,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; break; -#if defined(WIN32) +#if defined(__WIN__) case TAB_WMI: ok= true; break; -#endif // WIN32 +#endif // __WIN__ #if defined(PIVOT_SUPPORT) case TAB_PIVOT: supfnc= FNC_NO; @@ -5306,11 +5343,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, case TAB_CSV: qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL); break; -#if defined(WIN32) +#if defined(__WIN__) case TAB_WMI: qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); break; -#endif // WIN32 +#endif // __WIN__ case TAB_PRX: case TAB_TBL: case TAB_XCL: @@ -5334,10 +5371,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, break; #endif // PIVOT_SUPPORT case TAB_VIR: - qrp= VirColumns(g, tab, (char*)db, fnc == FNC_COL); + qrp= VirColumns(g, fnc == FNC_COL); break; case TAB_JSON: - qrp= JSONColumns(g, (char*)db, fn, objn, pty, lrecl, lvl, fnc == FNC_COL); + qrp= JSONColumns(g, (char*)db, topt, fnc == FNC_COL); break; #if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT) case TAB_XML: @@ -5486,10 +5523,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, #if defined(ODBC_SUPPORT) if (ttp == TAB_ODBC) { - int plgtyp; + int plgtyp; + bool w= false; // Wide character type // typ must be PLG type, not SQL type - if (!(plgtyp= TranslateSQLType(typ, dec, prec, v))) { + if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) { if (GetTypeConv() == TPC_SKIP) { // Skip this column sprintf(g->Message, "Column %s skipped (unsupported type %d)", @@ -5506,6 +5544,13 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, typ= plgtyp; switch (typ) { + case TYPE_STRING: + if (w) { + sprintf(g->Message, "Column %s is wide characters", cnm); + push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message); + } // endif w + + break; case TYPE_DOUBLE: // Some data sources do not count dec in length (prec) prec += (dec + 2); // To be safe @@ -5764,11 +5809,11 @@ int ha_connect::create(const char *name, TABLE *table_arg, // on Windows and libxml2 otherwise switch (*xsup) { case '*': -#if defined(WIN32) +#if defined(__WIN__) dom= true; -#else // !WIN32 +#else // !__WIN__ dom= false; -#endif // !WIN32 +#endif // !__WIN__ break; case 'M': case 'D': @@ -6115,11 +6160,11 @@ bool ha_connect::FileExists(const char *fn, bool bf) NULL, NULL, 0, 0)) return true; -#if defined(WIN32) +#if defined(__WIN__) s= "\\"; -#else // !WIN32 +#else // !__WIN__ s= "/"; -#endif // !WIN32 +#endif // !__WIN__ if (IsPartitioned()) { sprintf(tfn, fn, GetPartName()); @@ -6461,8 +6506,7 @@ fin: @note: This function is no more called by check_if_supported_inplace_alter */ -bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, - uint table_changes) +bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *, uint) { DBUG_ENTER("ha_connect::check_if_incompatible_data"); // TO DO: really implement and check it. @@ -6604,7 +6648,7 @@ maria_declare_plugin(connect) 0x0103, /* version number (1.03) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.03.0006", /* string version */ + "1.03.0007", /* string version */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index 1e597f751ca..3d03bea5d00 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -23,7 +23,7 @@ #define ARGS MY_MIN(24,len-i),s+MY_MAX(i-3,0) -#if defined(WIN32) +#if defined(__WIN__) #define EL "\r\n" #else #define EL "\n" diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 1afd79bec05..ff4025ee0fb 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -296,7 +296,7 @@ my_bool Json_Value_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Value_init char *Json_Value(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; PJVAL jvp; @@ -329,7 +329,7 @@ my_bool Json_Array_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_init char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -376,7 +376,7 @@ my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_Add_init char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; PJVAL jvp; @@ -410,7 +410,7 @@ void Json_Array_Add_deinit(UDF_INIT* initid) } // end of Json_Array_Add_deinit /***********************************************************************/ -/* Add values to a Json array. */ +/* Delete a value from a Json array. */ /***********************************************************************/ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { @@ -429,7 +429,7 @@ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Array_Delete_init char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; int n; @@ -451,7 +451,7 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, } else { n = *(int*)args->args[1]; arp = jvp->GetArray(); - arp->DeleteValue(n - 1); + arp->DeleteValue(n); arp->InitArray(g); if (!(str = Serialize(g, arp, NULL, 0))) { @@ -482,7 +482,7 @@ my_bool Json_Object_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } // end of Json_Object_init char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -520,7 +520,7 @@ my_bool Json_Object_Nonull_init(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Object_Nonull_init char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) + unsigned long *res_length, char *, char *) { char *str; uint i; @@ -574,8 +574,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) return false; } // end of Json_Array_Grp_init -void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, - char *is_null, char *error) +void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; PJAR arp = (PJAR)g->Activityp; @@ -585,8 +584,8 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Array_Grp_add -char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) +char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, + unsigned long *res_length, char *, char *) { char *str; PGLOBAL g = (PGLOBAL)initid->ptr; @@ -605,7 +604,7 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of Json_Array_Grp -void Json_Array_Grp_clear(UDF_INIT *initid, char *is_null, char *error) +void Json_Array_Grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; @@ -646,8 +645,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) return false; } // end of Json_Object_Grp_init -void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, - char *is_null, char *error) +void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; PJOB objp = (PJOB)g->Activityp; @@ -657,8 +655,8 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, } // end of Json_Object_Grp_add -char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, - unsigned long *res_length, char *is_null, char *error) +char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, + unsigned long *res_length, char *, char *) { char *str; PGLOBAL g = (PGLOBAL)initid->ptr; @@ -675,7 +673,7 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of Json_Object_Grp -void Json_Object_Grp_clear(UDF_INIT *initid, char *is_null, char *error) +void Json_Object_Grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 7d1d014c48b..c2882fc0d7c 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -533,8 +533,8 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) // This function does not crash ( if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) { xmlErrorPtr err = xmlGetLastError(); - strcpy(g->Message, (err) ? err->message : "Error saving XML doc"); + xmlResetError(Xerr); rc = -1; } // endif Save // rc = xmlDocDump(of, Docp); @@ -569,6 +569,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); //if (xp && xp->Count == 1) { + if (xp) { if (Nlist) { xmlXPathFreeNodeSet(Nlist); @@ -605,7 +606,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) Ctxp = NULL; } // endif Ctxp -// } // endif Count + } // endif xp CloseXML2File(g, xp, false); } // end of Close diff --git a/storage/connect/macutil.cpp b/storage/connect/macutil.cpp index 4d3022b91b6..f5d3bb11fe9 100644 --- a/storage/connect/macutil.cpp +++ b/storage/connect/macutil.cpp @@ -2,11 +2,11 @@ /* MACUTIL: Author Olivier Bertrand -- 2008-2012 */ /* From the article and sample code by Khalid Shaikh. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include "my_global.h" -#else // !WIN32 -#error This is WIN32 only DLL -#endif // !WIN32 +#else // !__WIN__ +#error This is WINDOWS only DLL +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" #include "macutil.h" diff --git a/storage/connect/macutil.h b/storage/connect/macutil.h index 8a3e97e12e1..c80bd58e20a 100644 --- a/storage/connect/macutil.h +++ b/storage/connect/macutil.h @@ -1,10 +1,10 @@ // MACUTIL.H Olivier Bertrand 2008-2012 // Get Mac Addresses via GetAdaptersInfo -#if defined(WIN32) +#if defined(__WIN__) #include <iphlpapi.h> -#else // !WIN32 -#error This is WIN32 only -#endif // !WIN32 +#else // !__WIN__ +#error This is WINDOWS only +#endif // !__WIN__ #include "block.h" typedef class MACINFO *MACIP; diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp index 97c638b4254..c4e016f1511 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -14,7 +14,7 @@ #include "plgdbsem.h" #include "maputil.h" -#ifdef WIN32 +#ifdef __WIN__ /***********************************************************************/ /* In Insert mode, just open the file for append. Otherwise */ /* create the mapping file object. The map handle can be released */ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index b15c8fa2322..9c72e9cd665 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2014 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ /* ------------- */ /* Version 1.4 */ /* */ -/* Author: Olivier Bertrand 2012 - 2014 */ +/* Author: Olivier Bertrand 2012 - 2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -30,7 +30,7 @@ /***********************************************************************/ #include <my_config.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> //#include <sqlext.h> #elif defined(UNIX) @@ -66,10 +66,10 @@ #include "tabfmt.h" #include "tabvct.h" #include "tabsys.h" -#if defined(WIN32) +#if defined(__WIN__) #include "tabmac.h" #include "tabwmi.h" -#endif // WIN32 +#endif // __WIN__ //#include "tabtbl.h" #include "tabxcl.h" #include "tabtbl.h" @@ -93,13 +93,33 @@ /***********************************************************************/ /* Extern static variables. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // !WIN32 +#endif // !__WIN__ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ +/* Get the plugin directory. */ +/***********************************************************************/ +char *GetPluginDir(void) +{ + char *plugin_dir; + +#if defined(_WIN64) + plugin_dir = (char *)GetProcAddress(GetModuleHandle(NULL), + "?opt_plugin_dir@@3PADEA"); +#elif defined(_WIN32) + plugin_dir = (char*)GetProcAddress(GetModuleHandle(NULL), + "?opt_plugin_dir@@3PADA"); +#else + plugin_dir = opt_plugin_dir; +#endif + + return plugin_dir; +} // end of GetPluginDir + +/***********************************************************************/ /* Get a unique enum table type ID. */ /***********************************************************************/ TABTYPE GetTypeID(const char *type) @@ -122,7 +142,7 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "DIR")) ? TAB_DIR -#ifdef WIN32 +#ifdef __WIN__ : (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "WMI")) ? TAB_WMI #endif @@ -328,12 +348,12 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) { typedef PQRYRES (__stdcall *XCOLDEF) (PGLOBAL, void*, char*, char*, bool); const char *module, *subtype; - char c, getname[40] = "Col"; -#if defined(WIN32) + char c, soname[_MAX_PATH], getname[40] = "Col"; +#if defined(__WIN__) HANDLE hdll; /* Handle to the external DLL */ -#else // !WIN32 +#else // !__WIN__ void *hdll; /* Handle for the loaded shared library */ -#endif // !WIN32 +#endif // !__WIN__ XCOLDEF coldef = NULL; PQRYRES qrp = NULL; @@ -343,6 +363,17 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) if (!module || !subtype) return NULL; + /*********************************************************************/ + /* Ensure that the .dll doesn't have a path. */ + /* This is done to ensure that only approved dll from the system */ + /* directories are used (to make this even remotely secure). */ + /*********************************************************************/ + if (check_valid_path(module, strlen(module))) { + strcpy(g->Message, "Module cannot contain a path"); + return NULL; + } else + PlugSetPath(soname, module, GetPluginDir()); + // The exported name is always in uppercase for (int i = 0; ; i++) { c = subtype[i]; @@ -350,13 +381,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) if (!c) break; } // endfor i -#if defined(WIN32) +#if defined(__WIN__) // Load the Dll implementing the table - if (!(hdll = LoadLibrary(module))) { + if (!(hdll = LoadLibrary(soname))) { char buf[256]; DWORD rc = GetLastError(); - sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, module); + sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, (LPTSTR)buf, sizeof(buf), NULL); @@ -370,13 +401,13 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) FreeLibrary((HMODULE)hdll); return NULL; } // endif coldef -#else // !WIN32 +#else // !__WIN__ const char *error = NULL; // Load the desired shared library - if (!(hdll = dlopen(module, RTLD_LAZY))) { + if (!(hdll = dlopen(soname, RTLD_LAZY))) { error = dlerror(); - sprintf(g->Message, MSG(SHARED_LIB_ERR), module, SVP(error)); + sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); return NULL; } // endif Hdll @@ -387,7 +418,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) dlclose(hdll); return NULL; } // endif coldef -#endif // !WIN32 +#endif // !__WIN__ // Just in case the external Get function does not set error messages sprintf(g->Message, "Error getting column info from %s", subtype); @@ -395,11 +426,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) // Get the table column definition qrp = coldef(g, topt, tab, db, info); -#if defined(WIN32) +#if defined(__WIN__) FreeLibrary((HMODULE)hdll); -#else // !WIN32 +#else // !__WIN__ dlclose(hdll); -#endif // !WIN32 +#endif // !__WIN__ return qrp; } // end of OEMColumns @@ -411,11 +442,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) /***********************************************************************/ CATALOG::CATALOG(void) { -#if defined(WIN32) +#if defined(__WIN__) //DataPath= ".\\"; -#else // !WIN32 +#else // !__WIN__ //DataPath= "./"; -#endif // !WIN32 +#endif // !__WIN__ memset(&Ctb, 0, sizeof(CURTAB)); Cbuf= NULL; Cblen= 0; @@ -458,11 +489,11 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) } if (*path != '.') { -#if defined(WIN32) +#if defined(__WIN__) char *s= "\\"; -#else // !WIN32 +#else // !__WIN__ char *s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcat(strcat(strcat(strcpy(buf, "."), s), path), s); } else strcpy(buf, path); @@ -478,7 +509,7 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) /* Look for a table descriptor matching the name and type. */ /***********************************************************************/ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, - LPCSTR type, PRELDEF *prp) + LPCSTR type, PRELDEF *) { if (trace) printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); @@ -523,10 +554,10 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) #if defined(ODBC_SUPPORT) case TAB_ODBC: tdp= new(g) ODBCDEF; break; #endif // ODBC_SUPPORT -#if defined(WIN32) +#if defined(__WIN__) case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break; -#endif // WIN32 +#endif // __WIN__ case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break; @@ -589,7 +620,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) /***********************************************************************/ /* ClearDB: Terminates Database usage. */ /***********************************************************************/ -void MYCAT::ClearDB(PGLOBAL g) +void MYCAT::ClearDB(PGLOBAL) { } // end of ClearDB diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h index cdbe4e5bca9..d4024e6b6c3 100644 --- a/storage/connect/mycat.h +++ b/storage/connect/mycat.h @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2013 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ #include "block.h" #include "catalog.h" -typedef struct ha_table_option_struct TOS, *PTOS; +//typedef struct ha_table_option_struct TOS, *PTOS; /** structure for CREATE TABLE options (table options) @@ -98,7 +98,7 @@ class MYCAT : public CATALOG { void Reset(void); //void SetDataPath(PGLOBAL g, const char *path) // {SetPath(g, &DataPath, path);} - bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary + bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, PRELDEF *prp = NULL); PTDB GetTable(PGLOBAL g, PTABLE tablep, diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 47d781d9ff6..ada0109a820 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2007-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,11 +35,11 @@ #include "my_sys.h" #include "mysqld_error.h" #endif // !MYSQL_PREPARED_STATEMENTS -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" @@ -451,15 +451,15 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); //mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); -#if defined(WIN32) +#if defined(__WIN__) if (!strcmp(host, ".")) { mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL); pipe = mysqld_unix_port; } // endif host -#else // !WIN32 +#else // !__WIN__ if (!strcmp(host, "localhost")) pipe = mysqld_unix_port; -#endif // !WIN32 +#endif // !__WIN__ #if 0 if (pwd && !strcmp(pwd, "*")) { @@ -720,7 +720,7 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w) /***********************************************************************/ /* Get table size by executing "select count(*) from table_name". */ /***********************************************************************/ -int MYSQLC::GetTableSize(PGLOBAL g, PSZ query) +int MYSQLC::GetTableSize(PGLOBAL g __attribute__((unused)), PSZ query) { if (mysql_real_query(m_DB, query, strlen(query))) { #if defined(_DEBUG) diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 79b8a43fe5a..fa34edd804c 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -7,24 +7,24 @@ /* DO NOT define DLL_EXPORT in your application so these items are */ /* declared are imported from the Myconn DLL. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include <winsock.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/socket.h> -#endif // !WIN32 +#endif // !__WIN__ #include <mysql.h> #include <errmsg.h> #include "myutil.h" -#if defined(WIN32) && defined(MYCONN_EXPORTS) +#if defined(__WIN__) && defined(MYCONN_EXPORTS) #if defined(DLL_EXPORT) #define DllItem _declspec(dllexport) #else // !DLL_EXPORT #define DllItem _declspec(dllimport) #endif // !DLL_EXPORT -#else // !WIN32 || !MYCONN_EXPORTS +#else // !__WIN__ || !MYCONN_EXPORTS #define DllItem -#endif // !WIN32 +#endif // !__WIN__ #define MYSQL_ENABLED 0x00000001 #define MYSQL_LOGON 0x00000002 diff --git a/storage/connect/mysql-test/connect/r/bin.result b/storage/connect/mysql-test/connect/r/bin.result index bbf5614b555..4ba353ac705 100644 --- a/storage/connect/mysql-test/connect/r/bin.result +++ b/storage/connect/mysql-test/connect/r/bin.result @@ -14,12 +14,12 @@ SET time_zone='+00:00'; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', -name CHAR(10) not null, +name CHAR(10) NOT NULL, birth DATE NOT NULL, id CHAR(5) NOT NULL FIELD_FORMAT='S', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; SELECT * FROM t1; fig name birth id salary dept 5500 ARCHIBALD 1980-01-25 3789 4380.50 318 @@ -41,12 +41,12 @@ DROP TABLE t1; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', -name CHAR(10) not null, +name CHAR(10) NOT NULL, birth DATE NOT NULL, id CHAR(5) NOT NULL FIELD_FORMAT='S', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ERROR HY000: Table 't1' is read only ALTER TABLE t1 READONLY=NO; @@ -59,7 +59,7 @@ t1 CREATE TABLE `t1` ( `id` char(5) NOT NULL `FIELD_FORMAT`='S', `salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F', `dept` int(4) NOT NULL `FIELD_FORMAT`='S' -) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=NO +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=NO INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); SELECT * FROM t1; fig name birth id salary dept @@ -78,7 +78,7 @@ t1 CREATE TABLE `t1` ( `id` char(5) NOT NULL `FIELD_FORMAT`='S', `salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F', `dept` int(4) NOT NULL `FIELD_FORMAT`='S' -) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=YES +) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=YES INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ERROR HY000: Table 't1' is read only DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/r/json.result b/storage/connect/mysql-test/connect/r/json.result index 80b0a2cbc18..acb74c38e26 100644 --- a/storage/connect/mysql-test/connect/r/json.result +++ b/storage/connect/mysql-test/connect/r/json.result @@ -97,7 +97,7 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L CREATE TABLE t2 ( FIRSTNAME CHAR(32), LASTNAME CHAR(32)) -ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR'; +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR'; SELECT * FROM t2; FIRSTNAME LASTNAME William J. Pardi @@ -252,9 +252,9 @@ DROP TABLE t1; # CREATE TABLE t2 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t2; WHO WEEK WHAT AMOUNT @@ -268,9 +268,9 @@ Janet 3 Food 18.00 Janet 3 Beer 18.00 CREATE TABLE t3 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t3; WHO WEEK WHAT AMOUNT @@ -284,9 +284,9 @@ Beth 4 Beer 15.00 Janet 4 Car 17.00 CREATE TABLE t4 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t4; WHO WEEK WHAT AMOUNT diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test index 06d73529c00..1e45bcaf93a 100644 --- a/storage/connect/mysql-test/connect/t/bin.test +++ b/storage/connect/mysql-test/connect/t/bin.test @@ -19,12 +19,12 @@ SET time_zone='+00:00'; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', - name CHAR(10) not null, + name CHAR(10) NOT NULL, birth DATE NOT NULL, id CHAR(5) NOT NULL FIELD_FORMAT='S', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; SELECT * FROM t1; --error ER_GET_ERRMSG @@ -40,12 +40,12 @@ DROP TABLE t1; CREATE TABLE t1 ( fig INT(4) NOT NULL FIELD_FORMAT='C', - name CHAR(10) not null, + name CHAR(10) NOT NULL, birth DATE NOT NULL, id CHAR(5) NOT NULL FIELD_FORMAT='S', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', dept INT(4) NOT NULL FIELD_FORMAT='S' -) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; +) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little'; --error ER_OPEN_AS_READONLY INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); ALTER TABLE t1 READONLY=NO; diff --git a/storage/connect/mysql-test/connect/t/json.test b/storage/connect/mysql-test/connect/t/json.test index f89f58534e7..1cc2c054db4 100644 --- a/storage/connect/mysql-test/connect/t/json.test +++ b/storage/connect/mysql-test/connect/t/json.test @@ -97,7 +97,7 @@ SELECT * FROM t1 WHERE ISBN = '9782212090819'; CREATE TABLE t2 ( FIRSTNAME CHAR(32), LASTNAME CHAR(32)) -ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR'; +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[1]:AUTHOR'; SELECT * FROM t2; INSERT INTO t2 VALUES('Charles','Dickens'); SELECT * FROM t1; @@ -162,25 +162,25 @@ DROP TABLE t1; --echo # CREATE TABLE t2 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[0]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[0]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t2; CREATE TABLE t3 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t3; CREATE TABLE t4 ( WHO CHAR(12), -WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER', -WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT', -AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT') +WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER', +WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT', +AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT') ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json'; SELECT * FROM t4; diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index fe504bbe422..d4416e188c8 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -13,11 +13,11 @@ /************************************************************************/ #include "my_global.h" #include <mysql.h> -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 2f2f5f38c29..6aaa048de81 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -11,7 +11,7 @@ /***********************************************************************/ #include <my_global.h> #include <m_string.h> -#if defined(WIN32) +#if defined(__WIN__) //nclude <io.h> //nclude <fcntl.h> #include <direct.h> // for getcwd @@ -45,13 +45,13 @@ #include "osutil.h" -#if defined(WIN32) +#if defined(__WIN__) /***********************************************************************/ /* For dynamic load of ODBC32.DLL */ /***********************************************************************/ #pragma comment(lib, "odbc32.lib") extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // WIN32 +#endif // __WIN__ int GetConvSize(); @@ -116,16 +116,24 @@ static int GetSQLCType(int type) /***********************************************************************/ /* TranslateSQLType: translate a SQL Type to a PLG type. */ /***********************************************************************/ -int TranslateSQLType(int stp, int prec, int& len, char& v) +int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) { int type; switch (stp) { + case SQL_WVARCHAR: // (-9) + w = true; case SQL_VARCHAR: // 12 v = 'V'; + type = TYPE_STRING; + break; + case SQL_WCHAR: // (-8) + w = true; case SQL_CHAR: // 1 type = TYPE_STRING; break; + case SQL_WLONGVARCHAR: // (-10) + w = true; case SQL_LONGVARCHAR: // (-1) v = 'V'; type = TYPE_STRING; @@ -180,7 +188,6 @@ int TranslateSQLType(int stp, int prec, int& len, char& v) case SQL_BINARY: // (-2) case SQL_VARBINARY: // (-3) case SQL_LONGVARBINARY: // (-4) -// case SQL_BIT: // (-7) case SQL_GUID: // (-11) default: type = TYPE_ERROR; @@ -410,6 +417,7 @@ PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop) PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) { // int i, type, len, prec; + bool w = false; // PCOLRES crp, crpt, crpl, crpp; PQRYRES qrp; ODBConn *ocp; @@ -455,7 +463,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) type = crpt->Kdata->GetIntValue(i); len = crpl->Kdata->GetIntValue(i); prec = crpp->Kdata->GetIntValue(i); - type = TranslateSQLType(type, prec, len); + type = TranslateSQLType(type, prec, len, w); crpt->Kdata->SetValue(type, i); // Some data sources do not count prec in length @@ -1201,15 +1209,15 @@ bool ODBConn::DriverConnect(DWORD Options) SWORD nResult; PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN); UWORD wConnectOption = SQL_DRIVER_COMPLETE; -#if defined(WIN32) +#if defined(__WIN__) HWND hWndTop = GetForegroundWindow(); HWND hWnd = GetParent(hWndTop); if (hWnd == NULL) hWnd = GetDesktopWindow(); -#else // !WIN32 +#else // !__WIN__ HWND hWnd = (HWND)1; -#endif // !WIN32 +#endif // !__WIN__ PGLOBAL& g = m_G; PDBUSER dup = PlgGetUser(g); @@ -1222,10 +1230,10 @@ bool ODBConn::DriverConnect(DWORD Options) SQL_NTS, ConnOut, MAX_CONNECT_LEN, &nResult, wConnectOption); -#if defined(WIN32) +#if defined(__WIN__) if (hWndTop) EnableWindow(hWndTop, true); -#endif // WIN32 +#endif // __WIN__ // If user hit 'Cancel' if (rc == SQL_NO_DATA_FOUND) { diff --git a/storage/connect/odbconn.h b/storage/connect/odbconn.h index 41cc2439354..6a24334f08c 100644 --- a/storage/connect/odbconn.h +++ b/storage/connect/odbconn.h @@ -29,9 +29,9 @@ //efine MAX_CURSOR_NAME 18 // Max size of a cursor name #define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type -#if !defined(WIN32) +#if !defined(__WIN__) typedef unsigned char *PUCHAR; -#endif // !WIN32 +#endif // !__WIN__ // Field Flags, used to indicate status of fields //efine SQL_FIELD_FLAG_DIRTY 0x1 diff --git a/storage/connect/os.h b/storage/connect/os.h index 8f77a0ad39f..2dc603fdcda 100644 --- a/storage/connect/os.h +++ b/storage/connect/os.h @@ -15,16 +15,16 @@ typedef off_t off64_t; #endif #endif -#if defined(WIN32) +#if defined(__WIN__) typedef __int64 BIGINT; -#else // !WIN32 +#else // !__WIN__ typedef longlong BIGINT; #define FILE_BEGIN SEEK_SET #define FILE_CURRENT SEEK_CUR #define FILE_END SEEK_END -#endif // !WIN32 +#endif // !__WIN__ -#if !defined(WIN32) +#if !defined(__WIN__) typedef const void *LPCVOID; typedef const char *LPCTSTR; typedef const char *LPCSTR; @@ -61,6 +61,6 @@ typedef int HANDLE; #define _MAX_EXT FN_EXTLEN #define INVALID_HANDLE_VALUE (-1) #define __stdcall -#endif /* !WIN32 */ +#endif /* !__WIN__ */ #endif /* _OS_H_INCLUDED */ diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index 66985847ce7..2e9e120b0c8 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -4,7 +4,7 @@ #include <stdio.h> #include "osutil.h" -#ifdef WIN32 +#ifdef __WIN__ my_bool CloseFileHandle(HANDLE h) { return !CloseHandle(h); diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 4dc8f293070..b57d9e20ceb 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -389,6 +389,7 @@ typedef struct _qryres *PQRYRES; typedef struct _colres *PCOLRES; typedef struct _datpar *PDTP; typedef struct indx_used *PXUSED; +typedef struct ha_table_option_struct TOS, *PTOS; /***********************************************************************/ /* Utility blocks for file and storage. */ @@ -543,11 +544,11 @@ typedef struct _colres { char Var; /* Type added information */ } COLRES; -#if defined(WIN32) && !defined(NOEX) +#if defined(__WIN__) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !WIN32 +#else // !__WIN__ #define DllExport -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Utility routines. */ @@ -593,6 +594,9 @@ DllExport void NewPointer(PTABS, void *, void *); DllExport void SetTrc(void); DllExport char *GetListOption(PGLOBAL, const char *, const char *, const char *def=NULL); +DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *); +DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool); +DllExport int GetIntegerTableOption(PGLOBAL, PTOS, char *, int); #define MSGID_NONE 0 #define MSGID_CANNOT_OPEN 1 diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 32f6d6f8366..9e236da2d93 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -38,12 +38,12 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> #define BIGMEM 1048576 // 1 Megabyte -#else // !WIN32 +#else // !__WIN__ #include <unistd.h> #include <fcntl.h> #if defined(THREAD) @@ -51,7 +51,7 @@ #endif // THREAD #include <stdarg.h> #define BIGMEM 2147483647 // Max int value -#endif // !WIN32 +#endif // !__WIN__ #include <locale.h> /***********************************************************************/ @@ -73,11 +73,11 @@ /* Macro or external routine definition */ /***********************************************************************/ #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) extern CRITICAL_SECTION parsec; // Used calling the Flex parser -#else // !WIN32 +#else // !__WIN__ extern pthread_mutex_t parmut; -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD /***********************************************************************/ @@ -403,11 +403,11 @@ char *SetPath(PGLOBAL g, const char *path) } // endif path if (*path != '.') { -#if defined(WIN32) +#if defined(__WIN__) char *s= "\\"; -#else // !WIN32 +#else // !__WIN__ char *s= "/"; -#endif // !WIN32 +#endif // !__WIN__ strcat(strcat(strcat(strcpy(buf, "."), s), path), s); } else strcpy(buf, path); @@ -426,7 +426,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op) char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL; switch (op) { // Determine which part to extract -#if !defined(UNIX) +#if defined(__WIN__) case OP_FDISK: drive = pBuff; break; #endif // !UNIX case OP_FPATH: direc = pBuff; break; @@ -702,19 +702,19 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) /* instruction is included in an Enter/LeaveCriticalSection bracket. */ /*********************************************************************/ #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) EnterCriticalSection((LPCRITICAL_SECTION)&parsec); -#else // !WIN32 +#else // !__WIN__ pthread_mutex_lock(&parmut); -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD /*int rc =*/ fmdflex(pdp); #if defined(THREAD) -#if defined(WIN32) +#if defined(__WIN__) LeaveCriticalSection((LPCRITICAL_SECTION)&parsec); -#else // !WIN32 +#else // !__WIN__ pthread_mutex_unlock(&parmut); -#endif // !WIN32 +#endif // !__WIN__ #endif // THREAD if (trace) @@ -888,7 +888,7 @@ FILE *PlugReopenFile(PGLOBAL g, PFBLOCK fp, LPCSTR md) /* Close file routine: the purpose of this routine is to avoid */ /* double closing that freeze the system on some Unix platforms. */ /***********************************************************************/ -int PlugCloseFile(PGLOBAL g, PFBLOCK fp, bool all) +int PlugCloseFile(PGLOBAL g __attribute__((unused)), PFBLOCK fp, bool all) { int rc = 0; @@ -1109,7 +1109,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp) return amn; } // end of GetAmName -#if defined(WIN32) && !defined(NOCATCH) +#if defined(__WIN__) && !defined(NOCATCH) /***********************************************************************/ /* GetExceptionDesc: return the description of an exception code. */ /***********************************************************************/ @@ -1197,7 +1197,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e) return p; } // end of GetExceptionDesc -#endif // WIN32 && !NOCATCH +#endif // __WIN__ && !NOCATCH /***********************************************************************/ /* PlgDBalloc: allocates or suballocates memory conditionally. */ @@ -1239,7 +1239,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp) if (!mp.Sub) { // For allocations greater than one fourth of remaining storage // in the area, do allocate from virtual storage. -#if defined(WIN32) +#if defined(__WIN__) if (mp.Size >= BIGMEM) mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT, PAGE_READWRITE); else @@ -1336,7 +1336,7 @@ void PlgDBfree(MBLOCK& mp) htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size); if (!mp.Sub && mp.Memp) -#if defined(WIN32) +#if defined(__WIN__) if (mp.Size >= BIGMEM) VirtualFree(mp.Memp, 0, MEM_RELEASE); else @@ -1532,11 +1532,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2) bp[0] = buff1; bp[1] = buff2; for (i = 0; i < 2; i++) { -#if defined(WIN32) +#if defined(__WIN__) h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY); -#else // !WIN32 +#else // !__WIN__ h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY); -#endif // !WIN32 +#endif // !__WIN__ if (h[i] == -1) { // if (errno != ENOENT) { diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 36d115e0096..c0e249adf12 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -44,7 +44,7 @@ /* */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #else #if defined(UNIX) || defined(UNIV_LINUX) @@ -80,9 +80,9 @@ #include "rcmsg.h" #endif // NEWMSG -#if defined(WIN32) +#if defined(__WIN__) extern HINSTANCE s_hModule; /* Saved module handle */ -#endif // WIN32 +#endif // __WIN__ #if defined(XMSG) extern char *msg_path; @@ -192,7 +192,7 @@ int PlugExit(PGLOBAL g) /***********************************************************************/ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) { -#if !defined(UNIX) && !defined(UNIV_LINUX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -220,7 +220,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) BOOL PlugIsAbsolutePath(LPCSTR path) { -#if defined(WIN32) +#if defined(__WIN__) return ((path[0] >= 'a' && path[0] <= 'z') || (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; #else @@ -238,7 +238,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR]; char fname[_MAX_FNAME]; char ftype[_MAX_EXT]; -#if !defined(UNIX) && !defined(UNIV_LINUX) +#if defined(__WIN__) char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE]; #else char *drive = NULL, *defdrv = NULL; @@ -255,7 +255,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return pBuff; } // endif -#if !defined(WIN32) +#if !defined(__WIN__) if (*FileName == '~') { if (_fullpath(pBuff, FileName, _MAX_PATH)) { if (trace > 1) @@ -266,7 +266,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return FileName; // Error, return unchanged name } // endif FileName -#endif // !WIN32 +#endif // !__WIN__ if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) { @@ -295,11 +295,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) if (trace > 1) { htrc("after _splitpath: FileName=%s\n", FileName); -#if defined(UNIX) || defined(UNIV_LINUX) - htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype); -#else +#if defined(__WIN__) htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype); htrc("defdrv=%s defdir=%s\n", defdrv, defdir); +#else + htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype); #endif } // endif trace @@ -427,7 +427,7 @@ char *PlugGetMessage(PGLOBAL g, int mid) } // end of PlugGetMessage #endif // NEWMSG -#if defined(WIN32) +#if defined(__WIN__) /***********************************************************************/ /* Return the line length of the console screen buffer. */ /***********************************************************************/ @@ -439,7 +439,7 @@ short GetLineLength(PGLOBAL g) return (b) ? coninfo.dwSize.X : 0; } // end of GetLineLength -#endif // WIN32 +#endif // __WIN__ /***********************************************************************/ /* Program for memory allocation of work and language areas. */ @@ -502,7 +502,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; - if (trace > 2) + if (trace > 3) htrc("SubAlloc in %p size=%d used=%d free=%d\n", memp, size, pph->To_Free, pph->FreeBlk); @@ -526,7 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) pph->To_Free += size; /* New offset of pool free block */ pph->FreeBlk -= size; /* New size of pool free block */ - if (trace > 2) + if (trace > 3) htrc("Done memp=%p used=%d free=%d\n", memp, pph->To_Free, pph->FreeBlk); diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c index eafcbdcd81b..75759e03314 100644 --- a/storage/connect/rcmsg.c +++ b/storage/connect/rcmsg.c @@ -21,9 +21,9 @@ #include "msgid.h" #endif // NEWMSG -#if !defined(WIN32) +#if !defined(__WIN__) #define stricmp strcasecmp -#endif // !WIN32 +#endif // !__WIN__ char *msglang(void); diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 47f825e965d..60d515a61ca 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -17,7 +17,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <sqlext.h> #else #include <dlfcn.h> // dlopen(), dlclose(), dlsym() ... @@ -48,14 +48,15 @@ #include "tabmul.h" #include "ha_connect.h" -#if !defined(WIN32) +#if !defined(__WIN__) extern handlerton *connect_hton; -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* External function. */ /***********************************************************************/ USETEMP UseTemp(void); +char *GetPluginDir(void); /* --------------------------- Class RELDEF -------------------------- */ @@ -246,7 +247,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) /***********************************************************************/ PSZ TABDEF::GetPath(void) { - return (Database) ? (PSZ)Database : Hc->GetDataPath(); + return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL; } // end of GetPath /***********************************************************************/ @@ -255,7 +256,8 @@ PSZ TABDEF::GetPath(void) int TABDEF::GetColCatInfo(PGLOBAL g) { char *type= GetStringCatInfo(g, "Type", "*"); - int i, loff, poff, nof, nlg; + char c, fty, eds; + int i, n, loff, poff, nof, nlg; void *field= NULL; TABTYPE tc; PCOLDEF cdp, lcdp= NULL, tocols= NULL; @@ -322,7 +324,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0) return -1; // Error, probably unhandled type - else if (nof) + else loff= cdp->GetOffset(); switch (tc) { @@ -330,20 +332,52 @@ int TABDEF::GetColCatInfo(PGLOBAL g) cdp->SetOffset(0); // Not to have shift case TAB_BIN: // BIN/VEC are packed by default - if (nof) + if (nof) { // Field width is the internal representation width // that can also depend on the column format - switch (cdp->Fmt ? *cdp->Fmt : 'X') { - case 'C': break; + fty = cdp->Decode ? 'C' : 'X'; + eds = 0; + n = 0; + + if (cdp->Fmt && !cdp->Decode) { + for (i = 0; cdp->Fmt[i]; i++) { + c = toupper(cdp->Fmt[i]); + + if (isdigit(c)) + n = (n * 10 + (c - '0')); + else if (c == 'L' || c == 'B' || c == 'H') + eds = c; + else + fty = c; + + } // endfor i + + } // endif Fmt + + if (n) + nof = n; + else switch (fty) { + case 'X': + if (eds && IsTypeChar(cdp->Buf_Type)) + nof = sizeof(longlong); + else + nof= cdp->Clen; + + break; + case 'C': break; case 'R': - case 'F': - case 'L': - case 'I': nof= 4; break; - case 'D': nof= 8; break; - case 'S': nof= 2; break; - case 'T': nof= 1; break; - default: nof= cdp->Clen; - } // endswitch Fmt + case 'F': nof = sizeof(float); break; + case 'I': nof = sizeof(int); break; + case 'D': nof = sizeof(double); break; + case 'S': nof = sizeof(short); break; + case 'T': nof = sizeof(char); break; + case 'G': nof = sizeof(longlong); break; + default: /* Wrong format */ + sprintf(g->Message, "Invalid format %c", fty); + return -1; + } // endswitch fty + + } // endif nof default: break; @@ -369,20 +403,16 @@ int TABDEF::GetColCatInfo(PGLOBAL g) // not specified (for instance if quoted is specified) // if ((ending= Hc->GetIntegerOption("Ending")) < 0) { if ((ending= Hc->GetIntegerOption("Ending")) <= 0) { -#if defined(WIN32) - ending= 2; -#else - ending= 1; -#endif + ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF; Hc->SetIntegerOption("Ending", ending); } // endif ending // Calculate the default record size switch (tc) { case TAB_FIX: + case TAB_BIN: recln= nlg + ending; // + length of line ending break; - case TAB_BIN: case TAB_VEC: recln= nlg; @@ -433,20 +463,31 @@ void TABDEF::SetIndexInfo(void) PTABDEF OEMDEF::GetXdef(PGLOBAL g) { typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *); - char c, getname[40] = "Get"; + char c, soname[_MAX_PATH], getname[40] = "Get"; PTABDEF xdefp; XGETDEF getdef = NULL; PCATLG cat = Cat; -#if defined(WIN32) + /*********************************************************************/ + /* Ensure that the .dll doesn't have a path. */ + /* This is done to ensure that only approved dll from the system */ + /* directories are used (to make this even remotely secure). */ + /*********************************************************************/ + if (check_valid_path(Module, strlen(Module))) { + strcpy(g->Message, "Module cannot contain a path"); + return NULL; + } else + PlugSetPath(soname, Module, GetPluginDir()); + +#if defined(__WIN__) // Is the DLL already loaded? - if (!Hdll && !(Hdll = GetModuleHandle(Module))) + if (!Hdll && !(Hdll = GetModuleHandle(soname))) // No, load the Dll implementing the function - if (!(Hdll = LoadLibrary(Module))) { + if (!(Hdll = LoadLibrary(soname))) { char buf[256]; DWORD rc = GetLastError(); - sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module); + sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, soname); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, (LPTSTR)buf, sizeof(buf), NULL); @@ -467,10 +508,11 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef -#else // !WIN32 +#else // !__WIN__ const char *error = NULL; Dl_info dl_info; - + +#if 0 // Don't know what all this stuff does // The OEM lib must retrieve exported CONNECT variables if (dladdr(&connect_hton, &dl_info)) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { @@ -484,15 +526,16 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error)); return NULL; } // endif dladdr +#endif // 0 // Is the library already loaded? -// if (!Hdll && !(Hdll = ???)) - // Load the desired shared library - if (!(Hdll = dlopen(Module, RTLD_LAZY))) { - error = dlerror(); - sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error)); - return NULL; - } // endif Hdll + if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD))) + // Load the desired shared library + if (!(Hdll = dlopen(soname, RTLD_LAZY))) { + error = dlerror(); + sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); + return NULL; + } // endif Hdll // The exported name is always in uppercase for (int i = 0; ; i++) { @@ -508,7 +551,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) dlclose(Hdll); return NULL; } // endif getdef -#endif // !WIN32 +#endif // !__WIN__ // Just in case the external Get function does not set error messages sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); @@ -548,7 +591,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g) /***********************************************************************/ /* Define: initialize the table definition block from XDB file. */ /***********************************************************************/ -bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int) { Module = GetStringCatInfo(g, "Module", ""); Subtype = GetStringCatInfo(g, "Subtype", Module); @@ -715,7 +758,7 @@ COLDEF::COLDEF(void) : COLCRT() /***********************************************************************/ /* Define: initialize a column definition from a COLINFO structure. */ /***********************************************************************/ -int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) +int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff) { Name = (PSZ)PlugDup(g, cfp->Name); @@ -745,7 +788,8 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) if (cfp->Datefmt) Decode = (PSZ)PlugDup(g, cfp->Datefmt); - } // endif special + } else + Offset = poff; if (cfp->Fieldfmt) Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt); diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h index 13bd392b706..4aa29037dfc 100644 --- a/storage/connect/reldef.h +++ b/storage/connect/reldef.h @@ -1,7 +1,7 @@ /*************** RelDef H Declares Source Code File (.H) ***************/ /* Name: RELDEF.H Version 1.5 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* This file contains the DEF classes definitions. */ /***********************************************************************/ @@ -89,7 +89,7 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ bool IsReadOnly(void) {return Read_Only;} virtual AMT GetDefType(void) {return TYPE_AM_TAB;} virtual PIXDEF GetIndx(void) {return NULL;} - virtual void SetIndx(PIXDEF xp) {} + virtual void SetIndx(PIXDEF) {} virtual bool IsHuge(void) {return false;} const CHARSET_INFO *data_charset() {return m_data_charset;} @@ -139,11 +139,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */ PTABDEF GetXdef(PGLOBAL g); // Members -#if defined(WIN32) +#if defined(__WIN__) HANDLE Hdll; /* Handle to the external DLL */ -#else // !WIN32 +#else // !__WIN__ void *Hdll; /* Handle for the loaded shared library */ -#endif // !WIN32 +#endif // !__WIN__ PTABDEF Pxdef; /* Pointer to the external TABDEF class */ char *Module; /* Path/Name of the DLL implenting it */ char *Subtype; /* The name of the OEM table sub type */ diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp index 8f350c6f074..662c0b514cf 100644 --- a/storage/connect/tabcol.cpp +++ b/storage/connect/tabcol.cpp @@ -1,7 +1,7 @@ /************* TabCol C++ Functions Source Code File (.CPP) ************/ /* Name: TABCOL.CPP Version 2.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */ /***********************************************************************/ @@ -91,7 +91,7 @@ void XTAB::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of XTAB contents. */ /***********************************************************************/ -void XTAB::Print(PGLOBAL g, char *ps, uint z) +void XTAB::Print(PGLOBAL, char *ps, uint z) { char buf[128]; int i, n = (int)z - 1; @@ -125,7 +125,7 @@ COLUMN::COLUMN(LPCSTR name) : Name(name) /***********************************************************************/ /* COLUMN SetFormat: should never be called. */ /***********************************************************************/ -bool COLUMN::SetFormat(PGLOBAL g, FORMAT& fmt) +bool COLUMN::SetFormat(PGLOBAL g, FORMAT&) { strcpy(g->Message, MSG(NO_FORMAT_COL)); return true; @@ -154,7 +154,7 @@ void COLUMN::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of COLUMN contents. */ /***********************************************************************/ -void COLUMN::Print(PGLOBAL g, char *ps, uint z) +void COLUMN::Print(PGLOBAL, char *ps, uint z) { char buf[80]; diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index ba22da52998..a1e58ab3344 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <sys\timeb.h> // For testing only #include <fcntl.h> @@ -26,7 +26,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -112,12 +112,13 @@ DOSDEF::DOSDEF(void) Maxerr = 0; ReadMode = 0; Ending = 0; + Teds = 0; } // end of DOSDEF constructor /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) { char buf[8]; bool map = (am && (*am == 'M' || *am == 'm')); @@ -146,6 +147,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Padded = GetBoolCatInfo("Padded", false); Blksize = GetIntCatInfo("Blksize", 0); Eof = (GetIntCatInfo("EOF", 0) != 0); + Teds = toupper(*GetStringCatInfo(g, "Endian", "")); } else if (Recfm == RECFM_DBF) { Maxerr = GetIntCatInfo("Maxerr", 0); Accept = GetBoolCatInfo("Accept", false); @@ -206,11 +208,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g) // Delete any eventually ill formed non matching optimization file if (!GetOptFileName(g, filename)) -#if defined(WIN32) +#if defined(__WIN__) DeleteFile(filename); #else // UNIX remove(filename); -#endif // WIN32 +#endif // __WIN__ Optimized = 0; } // end of RemoveOptValues @@ -251,7 +253,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) /*********************************************************************/ if (sep) { // Indexes are save in separate files -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -268,7 +270,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) strcat(strcat(fname, "_"), pxdf->GetName()); _makepath(filename, drive, direc, fname, ftype); PlugSetPath(filename, filename, GetPath()); -#if defined(WIN32) +#if defined(__WIN__) if (!DeleteFile(filename)) rc |= (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -285,7 +287,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) // Drop all indexes, delete the common file PlugSetPath(filename, Ofn, GetPath()); strcat(PlugRemoveType(filename, filename), ftype); -#if defined(WIN32) +#if defined(__WIN__) if (!DeleteFile(filename)) rc = (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -303,7 +305,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) /***********************************************************************/ /* InvalidateIndex: mark all indexes as invalid. */ /***********************************************************************/ -bool DOSDEF::InvalidateIndex(PGLOBAL g) +bool DOSDEF::InvalidateIndex(PGLOBAL) { if (To_Indx) for (PIXDEF xp = To_Indx; xp; xp = xp->Next) @@ -954,7 +956,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g) #if 0 if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS) return false; -#endif // WIN32 +#endif // __WIN__ if (defp->Optimized) return false; // Already done or to be redone @@ -1736,15 +1738,16 @@ err: /***********************************************************************/ /* Make a dynamic index. */ /***********************************************************************/ -bool TDBDOS::InitialyzeIndex(PGLOBAL g, PIXDEF xdp, bool sorted) +bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) { int k, rc; - bool brc, dynamic; + volatile bool dynamic; + bool brc; PCOL colp; PCOLDEF cdp; PVAL valp; PXLOAD pxp; - PKXBASE kxp; + volatile PKXBASE kxp; PKPDEF kdp; if (!xdp && !(xdp = To_Xdp)) { @@ -1864,7 +1867,7 @@ int TDBDOS::GetProgCur(void) /***********************************************************************/ /* RowNumber: return the ordinal number of the current row. */ /***********************************************************************/ -int TDBDOS::RowNumber(PGLOBAL g, bool b) +int TDBDOS::RowNumber(PGLOBAL g, bool) { if (To_Kindex) { /*******************************************************************/ @@ -1944,7 +1947,7 @@ int TDBDOS::Cardinality(PGLOBAL g) rec = ((PDOSDEF)To_Def)->Ending; if (AvgLen <= 0) // No given average estimate - rec += EstimatedLength(g); + rec += EstimatedLength(); else // An estimate was given for the average record length rec += AvgLen; @@ -1988,7 +1991,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) /* Estimate the number of lines in the table (if not known) by */ /* dividing the file length by minimum record length. */ /*****************************************************************/ - rec = EstimatedLength(g) + ((PDOSDEF)To_Def)->Ending; + rec = EstimatedLength() + ((PDOSDEF)To_Def)->Ending; MaxSize = (len + rec - 1) / rec; if (trace) @@ -2005,7 +2008,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) /***********************************************************************/ /* DOS EstimatedLength. Returns an estimated minimum line length. */ /***********************************************************************/ -int TDBDOS::EstimatedLength(PGLOBAL g) +int TDBDOS::EstimatedLength(void) { int dep = 0; PCOLDEF cdp = To_Def->GetCols(); @@ -2023,7 +2026,7 @@ int TDBDOS::EstimatedLength(PGLOBAL g) /***********************************************************************/ /* DOS tables favor the use temporary files for Update. */ /***********************************************************************/ -bool TDBDOS::IsUsingTemp(PGLOBAL g) +bool TDBDOS::IsUsingTemp(PGLOBAL) { USETEMP utp = UseTemp(); @@ -2183,7 +2186,7 @@ int TDBDOS::ReadDB(PGLOBAL g) /***********************************************************************/ /* PrepareWriting: Prepare the line to write. */ /***********************************************************************/ -bool TDBDOS::PrepareWriting(PGLOBAL g) +bool TDBDOS::PrepareWriting(PGLOBAL) { if (!Ftype && (Mode == MODE_INSERT || Txfp->GetUseTemp())) { char *p; diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h index b7150294e9b..c098886f14b 100644 --- a/storage/connect/tabdos.h +++ b/storage/connect/tabdos.h @@ -1,7 +1,7 @@ /*************** TabDos H Declares Source Code File (.H) ***************/ /* Name: TABDOS.H Version 3.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the DOS classes declares. */ /***********************************************************************/ @@ -91,6 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ int Maxerr; /* Maximum number of bad records (DBF) */ int ReadMode; /* Specific to DBF */ int Ending; /* Length of end of lines */ + int Teds; /* Binary table default endian setting */ }; // end of DOSDEF /***********************************************************************/ @@ -123,11 +124,11 @@ class DllExport TDBDOS : public TDBASE { // Implementation virtual AMT GetAmType(void) {return Txfp->GetAmType();} - virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;} - virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;} + virtual PSZ GetFile(PGLOBAL) {return Txfp->To_File;} + virtual void SetFile(PGLOBAL, PSZ fn) {Txfp->To_File = fn;} virtual void SetAbort(bool b) {Abort = b;} virtual RECFM GetFtype(void) {return Ftype;} - virtual bool SkipHeader(PGLOBAL g) {return false;} + virtual bool SkipHeader(PGLOBAL) {return false;} virtual void RestoreNrec(void) {Txfp->SetNrec(1);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBDOS(g, this);} @@ -149,7 +150,7 @@ class DllExport TDBDOS : public TDBASE { // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;} + virtual char *GetOpenMode(PGLOBAL, char*) {return NULL;} virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);} virtual int GetProgMax(PGLOBAL g); virtual int GetProgCur(void); @@ -168,7 +169,7 @@ class DllExport TDBDOS : public TDBASE { virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);} // Specific routine - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); // Optimization routines virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index 77e47e6f8dd..acd548c86ab 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -17,7 +17,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -35,7 +35,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -54,6 +54,7 @@ extern int num_read, num_there, num_eq[2]; // Statistics static const longlong M2G = 0x80000000; static const longlong M4G = (longlong)2 * M2G; +char BINCOL::Endian = 'H'; /***********************************************************************/ /* External function. */ @@ -67,10 +68,12 @@ USETEMP UseTemp(void); /***********************************************************************/ TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) { + Teds = tdp->Teds; // For BIN tables } // end of TDBFIX standard constructor TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp) { + Teds = tdbp->Teds; } // end of TDBFIX copy constructor // Method @@ -271,7 +274,7 @@ int TDBFIX::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ /* FIX tables don't use temporary files except if specified as do it. */ /***********************************************************************/ -bool TDBFIX::IsUsingTemp(PGLOBAL g) +bool TDBFIX::IsUsingTemp(PGLOBAL) { // Not ready yet to handle using a temporary file with mapping // or while deleting from DBF files. @@ -373,19 +376,94 @@ int TDBFIX::WriteDB(PGLOBAL g) BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) : DOSCOL(g, cdp, tp, cp, i, am) { - Fmt = (cdp->GetFmt()) ? toupper(*cdp->GetFmt()) : 'X'; + char c, *fmt = cdp->GetFmt(); + + Fmt = GetDomain() ? 'C' : 'X'; + Buff = NULL; + Eds = ((PTDBFIX)tp)->Teds; + N = 0; + M = GetTypeSize(Buf_Type, sizeof(longlong)); + Lim = 0; + + if (fmt) { + for (N = 0, i = 0; fmt[i]; i++) { + c = toupper(fmt[i]); + + if (isdigit(c)) + N = (N * 10 + (c - '0')); + else if (c == 'L' || c == 'B' || c == 'H') + Eds = c; + else + Fmt = c; + + } // endfor i + + // M is the size of the source value + switch (Fmt) { + case 'C': Eds = 0; break; + case 'X': break; + case 'S': M = sizeof(short); break; + case 'T': M = sizeof(char); break; + case 'I': M = sizeof(int); break; + case 'G': M = sizeof(longlong); break; + case 'R': // Real + case 'F': M = sizeof(float); break; + case 'D': M = sizeof(double); break; + default: + sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); + longjmp(g->jumper[g->jump_level], 11); + } // endswitch Fmt + + } else if (IsTypeChar(Buf_Type)) + Eds = 0; + + if (Eds) { + // This is a byte order specification + if (!N) + N = M; + + if (Eds != 'L' && Eds != 'B') + Eds = Endian; + + if (N != M || Eds != Endian || IsTypeChar(Buf_Type)) { + Buff = (char*)PlugSubAlloc(g, NULL, M); + memset(Buff, 0, M); + Lim = MY_MIN(N, M); + } else + Eds = 0; // New format is a no op + + } // endif Eds + } // end of BINCOL constructor /***********************************************************************/ -/* FIXCOL constructor used for copying columns. */ +/* BINCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ /***********************************************************************/ BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) { + Eds = col1->Eds; Fmt = col1->Fmt; + N = col1->N; + M = col1->M; + Lim = col1->Lim; } // end of BINCOL copy constructor /***********************************************************************/ +/* Set Endian according to the host setting. */ +/***********************************************************************/ +void BINCOL::SetEndian(void) + { + union { + short S; + char C[sizeof(short)]; + }; + + S = 1; + Endian = (C[0] == 1) ? 'L' : 'B'; + } // end of SetEndian + +/***********************************************************************/ /* ReadColumn: what this routine does is to access the last line */ /* read from the corresponding table and extract from it the field */ /* corresponding to this column. */ @@ -416,22 +494,40 @@ void BINCOL::ReadColumn(PGLOBAL g) /*********************************************************************/ /* Set Value from the line field. */ /*********************************************************************/ + if (Eds) { + for (int i = 0; i < Lim; i++) + if (Eds == 'B' && Endian == 'L') + Buff[i] = p[N - i - 1]; + else if (Eds == 'L' && Endian == 'B') + Buff[M - i - 1] = p[i]; + else if (Endian == 'B') + Buff[M - i - 1] = p[N - i - 1]; + else + Buff[i] = p[i]; + + p = Buff; + } // endif Eds + switch (Fmt) { case 'X': // Standard not converted values - Value->SetBinValue(p); + if (Eds && IsTypeChar(Buf_Type)) + Value->SetValue(*(longlong*)p); + else + Value->SetBinValue(p); + break; case 'S': // Short integer - Value->SetValue((int)*(short*)p); + Value->SetValue(*(short*)p); break; case 'T': // Tiny integer - Value->SetValue((int)*p); + Value->SetValue(*p); break; - case 'L': // Long Integer - strcpy(g->Message, "Format L is deprecated, use I"); - longjmp(g->jumper[g->jump_level], 11); case 'I': // Integer Value->SetValue(*(int*)p); break; + case 'G': // Large (great) integer + Value->SetValue(*(longlong*)p); + break; case 'F': // Float case 'R': // Real Value->SetValue((double)*(float*)p); @@ -483,7 +579,7 @@ void BINCOL::WriteColumn(PGLOBAL g) if (Value != To_Val) Value->SetValue_pval(To_Val, false); // Convert the updated value - p = tdbp->To_Line + Deplac; + p = (Eds) ? Buff : tdbp->To_Line + Deplac; /*********************************************************************/ /* Check whether updating is Ok, meaning col value is not too long. */ @@ -493,11 +589,13 @@ void BINCOL::WriteColumn(PGLOBAL g) switch (Fmt) { case 'X': // Standard not converted values - if (Value->GetBinValue(p, Long, Status)) { + if (Eds && IsTypeChar(Buf_Type)) + *(longlong *)p = Value->GetBigintValue(); + else if (Value->GetBinValue(p, Long, Status)) { sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, Value->GetSize(), Long); longjmp(g->jumper[g->jump_level], 31); - } // endif Fmt + } // endif p break; case 'S': // Short integer @@ -520,9 +618,6 @@ void BINCOL::WriteColumn(PGLOBAL g) *p = (char)n; break; - case 'L': // Long Integer - strcpy(g->Message, "Format L is deprecated, use I"); - longjmp(g->jumper[g->jump_level], 11); case 'I': // Integer n = Value->GetBigintValue(); @@ -533,9 +628,9 @@ void BINCOL::WriteColumn(PGLOBAL g) *(int *)p = Value->GetIntValue(); break; - case 'B': // Large (big) integer + case 'G': // Large (great) integer if (Status) - *(longlong *)p = (longlong)Value->GetBigintValue(); + *(longlong *)p = Value->GetBigintValue(); break; case 'F': // Float @@ -567,6 +662,21 @@ void BINCOL::WriteColumn(PGLOBAL g) longjmp(g->jumper[g->jump_level], 11); } // endswitch Fmt + if (Eds && Status) { + p = tdbp->To_Line + Deplac; + + for (int i = 0; i < Lim; i++) + if (Eds == 'B' && Endian == 'L') + p[N - i - 1] = Buff[i]; + else if (Eds == 'L' && Endian == 'B') + p[i] = Buff[M - i - 1]; + else if (Endian == 'B') + p[N - i - 1] = Buff[M - i - 1]; + else + p[i] = Buff[i]; + + } // endif Eds + } // end of WriteColumn /* ------------------------ End of TabFix ---------------------------- */ diff --git a/storage/connect/tabfix.h b/storage/connect/tabfix.h index 7d5b964da2a..49956ba0711 100644 --- a/storage/connect/tabfix.h +++ b/storage/connect/tabfix.h @@ -1,7 +1,7 @@ /*************** TabDos H Declares Source Code File (.H) ***************/ -/* Name: TABFIX.H Version 2.3 */ +/* Name: TABFIX.H Version 2.4 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */ /***********************************************************************/ @@ -12,7 +12,7 @@ typedef class FIXCOL *PFIXCOL; typedef class BINCOL *PBINCOL; -typedef class TXTFAM *PTXF; +typedef class TXTFAM *PTXF; /***********************************************************************/ /* This is the DOS/UNIX Access Method class declaration for files */ @@ -53,7 +53,8 @@ class DllExport TDBFIX : public TDBDOS { protected: virtual bool PrepareWriting(PGLOBAL g) {return false;} - // Members are inherited from TDBDOS + // Members + char Teds; /* Binary table default endian setting */ }; // end of class TDBFIX /***********************************************************************/ @@ -68,17 +69,29 @@ class DllExport BINCOL : public DOSCOL { BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation - virtual int GetAmType(void) {return TYPE_AM_BIN;} + virtual int GetAmType(void) {return TYPE_AM_BIN;} + int GetDeplac(void) {return Deplac;} + int GetFileSize(void) + {return N ? N : GetTypeSize(Buf_Type, Long);} // Methods - virtual void ReadColumn(PGLOBAL g); - virtual void WriteColumn(PGLOBAL g); + virtual void ReadColumn(PGLOBAL g); + virtual void WriteColumn(PGLOBAL g); + + // Static + static void SetEndian(void); protected: BINCOL(void) {} // Default constructor not to be used // Members - char Fmt; // The column numeric format + static char Endian; // The host endian setting (L or B) + char *Buff; // Utility buffer + char Eds; // The file endian setting + char Fmt; // The converted value format + int N; // The number of bytes in the file + int M; // The buffer type size + int Lim; // Min(N,M) }; // end of class BINCOL /***********************************************************************/ diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index d5f8dc50a89..015f8d93b15 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2001 - 2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2001 - 2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -20,7 +20,7 @@ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -102,14 +102,14 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, } // endif info // num_max = atoi(p+1); // Max num of record to test -#if defined(WIN32) +#if defined(__WIN__) if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6)) dechar = '.'; else dechar = ','; -#else // !WIN32 +#else // !__WIN__ dechar = '.'; -#endif // !WIN32 +#endif // !__WIN__ if (trace) htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n", @@ -147,7 +147,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, if (fgets(buf, sizeof(buf), infile)) { n = strlen(buf) + 1; buf[n - 2] = '\0'; -#if defined(UNIX) +#if !defined(__WIN__) // The file can be imported from Windows if (buf[n - 3] == '\r') buf[n - 3] = 0; @@ -204,7 +204,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep, if (fgets(buf, sizeof(buf), infile)) { n = strlen(buf); buf[n - 1] = '\0'; -#if defined(UNIX) +#if !defined(__WIN__) // The file can be imported from Windows if (buf[n - 2] == '\r') buf[n - 2] = 0; @@ -625,7 +625,7 @@ bool TDBCSV::CheckErr(void) /***********************************************************************/ /* CSV EstimatedLength. Returns an estimated minimum line length. */ /***********************************************************************/ -int TDBCSV::EstimatedLength(PGLOBAL g) +int TDBCSV::EstimatedLength(void) { int n = 0; PCOLDEF cdp; @@ -1118,7 +1118,7 @@ PCOL TDBFMT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /* FMT EstimatedLength. Returns an estimated minimum line length. */ /* The big problem here is how can we astimated that minimum ? */ /***********************************************************************/ -int TDBFMT::EstimatedLength(PGLOBAL g) +int TDBFMT::EstimatedLength(void) { // This is rather stupid !!! return ((PDOSDEF)To_Def)->GetEnding() + (int)((Lrecl / 10) + 1); diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h index 8a1e1f17561..ce80a276cdc 100644 --- a/storage/connect/tabfmt.h +++ b/storage/connect/tabfmt.h @@ -75,7 +75,7 @@ class TDBCSV : public TDBDOS { virtual int ReadBuffer(PGLOBAL g); // Physical file read // Specific routines - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); virtual bool SkipHeader(PGLOBAL g); virtual bool CheckErr(void); @@ -157,7 +157,7 @@ class TDBFMT : public TDBCSV { virtual int ReadBuffer(PGLOBAL g); // Physical file read // Specific routines - virtual int EstimatedLength(PGLOBAL g); + virtual int EstimatedLength(void); protected: virtual bool PrepareWriting(PGLOBAL g) diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 0231b369fc1..fafba6228b9 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -59,16 +59,15 @@ typedef struct _jncol { /* JSONColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside a JSON file. */ /***********************************************************************/ -PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, - int pretty, int lrecl, int lvl, bool info) +PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - char filename[_MAX_PATH], colname[65], fmt[129]; - int i, j, n = 0; + char *fn, colname[65], fmt[129]; + int i, j, lvl, n = 0; int ncol = sizeof(buftyp) / sizeof(int); PVAL valp; JCOL jcol; @@ -78,37 +77,42 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, PJVAL jvp; PJOB row; PJDEF tdp; - TDBJSN *tjnp; - PJTDB tjsp; + TDBJSN *tjnp = NULL; + PJTDB tjsp = NULL; PQRYRES qrp; PCOLRES crp; + jcol.Name = jcol.Fmt = NULL; + if (info) { length[0] = 128; length[7] = 256; goto skipit; } // endif info - if (trace) - htrc("File %s pretty=%d lvl=%d lrecl=%d\n", - SVP(fn), pretty, lvl, lrecl); - /*********************************************************************/ /* Open the input file. */ /*********************************************************************/ - if (!fn) { + if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; - } else - PlugSetPath(filename, fn, dp); + } else { + lvl = GetIntegerTableOption(g, topt, "Level", 0); + lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl; + } // endif fn tdp = new(g) JSONDEF; - tdp->Database = dp; - tdp->Fn = filename; - tdp->Objname = objn; - tdp->Pretty = pretty; + tdp->Fn = fn; + tdp->Database = SetPath(g, db); + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; + tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); + + if (trace) + htrc("File %s objname=%s pretty=%d lvl=%d\n", + tdp->Fn, tdp->Objname, tdp->Pretty, lvl); - if (pretty == 2) { + if (tdp->Pretty == 2) { tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); if (tjsp->MakeDocument(g)) @@ -116,13 +120,12 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; } else { - if (!lrecl) { - sprintf(g->Message, "LRECL must be specified for pretty=%d", pretty); + if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) { + sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); return NULL; } // endif lrecl - tdp->Lrecl = lrecl; - tdp->Ending = CRLF; + tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); tjnp->SetMode(MODE_READ); @@ -263,7 +266,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, jcp->Found = false; } // endfor jcp - if (pretty != 2) { + if (tdp->Pretty != 2) { // Read next record switch (tjnp->ReadDB(g)) { case RC_EF: @@ -283,7 +286,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, } // endor i - if (pretty != 2) + if (tdp->Pretty != 2) tjnp->CloseDB(g); skipit: @@ -339,7 +342,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn, return qrp; err: - if (pretty != 2) + if (tdp->Pretty != 2) tjnp->CloseDB(g); return NULL; @@ -354,22 +357,21 @@ JSONDEF::JSONDEF(void) Xcol = NULL; Pretty = 2; Limit = 1; - Level = 0; - ReadMode = 0; + Base = 0; Strict = false; } // end of JSONDEF constructor /***********************************************************************/ /* DefineAM: define specific AM block values. */ /***********************************************************************/ -bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) { Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT); Objname = GetStringCatInfo(g, "Object", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL); Pretty = GetIntCatInfo("Pretty", 2); - Level = GetIntCatInfo("Level", 0); Limit = GetIntCatInfo("Limit", 10); + Base = GetIntCatInfo("Base", 0) ? 1 : 0; return DOSDEF::DefineAM(g, "DOS", poff); } // end of DefineAM @@ -438,6 +440,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) Xcol = tdp->Xcol; Limit = tdp->Limit; Pretty = tdp->Pretty; + B = tdp->Base ? 1 : 0; Strict = tdp->Strict; } else { Jmode = MODE_OBJECT; @@ -445,11 +448,12 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) Xcol = NULL; Limit = 1; Pretty = 0; + B = 0; Strict = false; } // endif tdp Fpos = -1; - N = 0; + N = M = 0; NextSame = 0; SameRow = 0; Xval = -1; @@ -467,10 +471,12 @@ TDBJSN::TDBJSN(TDBJSN *tdbp) : TDBDOS(NULL, tdbp) Xcol = tdbp->Xcol; Fpos = tdbp->Fpos; N = tdbp->N; + M = tdbp->M; Limit = tdbp->Limit; NextSame = tdbp->NextSame; SameRow = tdbp->SameRow; Xval = tdbp->Xval; + B = tdbp->B; Pretty = tdbp->Pretty; Strict = tdbp->Strict; Comma = tdbp->Comma; @@ -506,7 +512,7 @@ PCOL TDBJSN::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBJSN::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBJSN::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -561,7 +567,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g) jsp->GetObject()->GetValue(objpath) : NULL; } else if (objpath[strlen(objpath)-1] == ']') { val = (jsp->GetType() == TYPE_JAR) ? - jsp->GetArray()->GetValue(atoi(objpath+1) - 1) : NULL; + jsp->GetArray()->GetValue(atoi(objpath+1) - B) : NULL; } else val = NULL; @@ -617,11 +623,11 @@ bool TDBJSN::SkipHeader(PGLOBAL g) return true; #endif // _DEBUG -#if defined(WIN32) +#if defined(__WIN__) #define Ending 2 -#else // !WIN32 +#else // !__WIN__ #define Ending 1 -#endif // !WIN32 +#endif // !__WIN__ if (Pretty == 1) { if (Mode == MODE_INSERT || Mode == MODE_DELETE) { @@ -647,6 +653,7 @@ int TDBJSN::ReadDB(PGLOBAL g) if (NextSame) { SameRow = NextSame; NextSame = 0; + M++; return RC_OK; } else if ((rc = TDBDOS::ReadDB(g)) == RC_OK) if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) { @@ -658,6 +665,7 @@ int TDBJSN::ReadDB(PGLOBAL g) Row = FindRow(g); SameRow = 0; Fpos++; + M = 1; rc = RC_OK; } // endif's @@ -706,7 +714,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) val->SetValue(arp); val = new(g) JVALUE; - i = atoi(objpath+1) - 1; + i = atoi(objpath+1) - B; arp->SetValue(g, val, i); arp->InitArray(g); } else { @@ -854,8 +862,8 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) return true; else if (jnp->Op != OP_EXP) { if (b) { - // Return 1st value - jnp->Rank = 1; + // Return 1st value (B is the index base) + jnp->Rank = Tjp->B; jnp->Op = OP_EQ; } else if (!Value->IsTypeNum()) { jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING); @@ -866,13 +874,9 @@ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) } // endif OP } else if (dg) { - if (atoi(p) > 0) { - // Return nth value - jnp->Rank = atoi(p); - jnp->Op = OP_EQ; - } else // Ignore array - jnp->Op = OP_NULL; - + // Return nth value + jnp->Rank = atoi(p) - Tjp->B; + jnp->Op = OP_EQ; } else if (n == 1) { // Set the Op value; switch (*p) { @@ -1116,16 +1120,12 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) arp = (PJAR)row; if (!Nodes[i].Key) { - if (Nodes[i].Op != OP_NULL) { - if (Nodes[i].Rank) { - val = arp->GetValue(Nodes[i].Rank - 1); - } else if (Nodes[i].Op == OP_EXP) { - return ExpandArray(g, arp, i); - } else - return CalculateArray(g, arp, i); - - } else - val = NULL; + if (Nodes[i].Op == OP_EQ) + val = arp->GetValue(Nodes[i].Rank); + else if (Nodes[i].Op == OP_EXP) + return ExpandArray(g, arp, i); + else + return CalculateArray(g, arp, i); } else if (i < Nod-1) { strcpy(g->Message, "Unexpected array"); @@ -1287,16 +1287,12 @@ PJSON JSONCOL::GetRow(PGLOBAL g) break; case TYPE_JAR: if (!Nodes[i].Key) { - if (Nodes[i].Op != OP_NULL) { - arp = (PJAR)row; - - if (Nodes[i].Rank) - val = arp->GetValue(Nodes[i].Rank - 1); - else - val = arp->GetValue(Nodes[i].Rx); + arp = (PJAR)row; - } else - val = NULL; + if (Nodes[i].Op == OP_EQ) + val = arp->GetValue(Nodes[i].Rank); + else + val = arp->GetValue(Nodes[i].Rx); } else { strcpy(g->Message, "Unexpected array"); @@ -1388,8 +1384,8 @@ void JSONCOL::WriteColumn(PGLOBAL g) } // endif jsp if (arp) { - if (Nod > 1 && Nodes[Nod-2].Rank) - arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank-1); + if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ) + arp->SetValue(g, new(g) JVALUE(jsp), Nodes[Nod-2].Rank); else arp->AddValue(g, new(g) JVALUE(jsp)); @@ -1409,8 +1405,8 @@ void JSONCOL::WriteColumn(PGLOBAL g) case TYPE_INT: case TYPE_DOUBLE: if (arp) { - if (Nodes[Nod-1].Rank) - arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank-1); + if (Nodes[Nod-1].Op == OP_EQ) + arp->SetValue(g, new(g) JVALUE(g, Value), Nodes[Nod-1].Rank); else arp->AddValue(g, new(g) JVALUE(g, Value)); @@ -1486,7 +1482,7 @@ int TDBJSON::MakeNewDoc(PGLOBAL g) /***********************************************************************/ int TDBJSON::MakeDocument(PGLOBAL g) { - char *p, *memory, *objpath, *key; + char *p, *memory, *objpath, *key = NULL; int len, i = 0; MODE mode = Mode; PJSON jsp; @@ -1560,7 +1556,7 @@ int TDBJSON::MakeDocument(PGLOBAL g) arp = jsp->GetArray(); objp = NULL; - i = atoi(objpath+1) - 1; + i = atoi(objpath+1) - B; val = arp->GetValue(i); if (!val) { @@ -1646,7 +1642,7 @@ void TDBJSON::ResetSize(void) /***********************************************************************/ /* TDBJSON is not indexable. */ /***********************************************************************/ -int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) +int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool) { if (pxdf) { strcpy(g->Message, "JSON not indexable when pretty = 2"); @@ -1677,7 +1673,7 @@ int TDBJSON::GetRecpos(void) /***********************************************************************/ /* Set the position in the table. */ /***********************************************************************/ -bool TDBJSON::SetRecpos(PGLOBAL g, int recpos) +bool TDBJSON::SetRecpos(PGLOBAL, int recpos) { #if 0 union { @@ -1739,7 +1735,7 @@ bool TDBJSON::OpenDB(PGLOBAL g) /***********************************************************************/ /* ReadDB: Data Base read routine for JSON access method. */ /***********************************************************************/ -int TDBJSON::ReadDB(PGLOBAL g) +int TDBJSON::ReadDB(PGLOBAL) { int rc; @@ -1748,6 +1744,7 @@ int TDBJSON::ReadDB(PGLOBAL g) if (NextSame) { SameRow = NextSame; NextSame = false; + M++; rc = RC_OK; } else if (++Fpos < (signed)Doc->size()) { Row = Doc->GetValue(Fpos); @@ -1756,6 +1753,7 @@ int TDBJSON::ReadDB(PGLOBAL g) Row = ((PJVAL)Row)->GetJson(); SameRow = 0; + M = 1; rc = RC_OK; } else rc = RC_EF; @@ -1857,11 +1855,8 @@ void TDBJSON::CloseDB(PGLOBAL g) /***********************************************************************/ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) { - Fn = tdp->GetFn(); - Objn = tdp->Objname; - Pretty = tdp->Pretty; - Lrecl = tdp->Lrecl; - lvl = tdp->Level; + Topt = tdp->GetTopt(); + Db = (char*)tdp->GetDB(); } // end of TDBJCL constructor /***********************************************************************/ @@ -1869,8 +1864,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBJCL::GetResult(PGLOBAL g) { - return JSONColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Objn, - Pretty, Lrecl, lvl, false); + return JSONColumns(g, Db, Topt, false); } // end of GetResult /* --------------------------- End of json --------------------------- */ diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 10b9a9a9cc3..4505d30a21c 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -36,8 +36,7 @@ class JSONDEF : public DOSDEF { /* Table description */ friend class TDBJSON; friend class TDBJSN; friend class TDBJCL; - friend PQRYRES JSONColumns(PGLOBAL, char *, const char *, char *, - int, int, int, bool); + friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool); public: // Constructor JSONDEF(void); @@ -57,6 +56,7 @@ class JSONDEF : public DOSDEF { /* Table description */ int Limit; /* Limit of multiple values */ int Pretty; /* Depends on file structure */ int Level; /* Used for catalog table */ + int Base; /* Tne array index base */ bool Strict; /* Strict syntax checking */ }; // end of JSONDEF @@ -82,9 +82,9 @@ class TDBJSN : public TDBDOS { // Methods virtual PTDB CopyOne(PTABS t); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); virtual int RowNumber(PGLOBAL g, bool b = FALSE) - {return (b) ? N : Fpos + 1;} + {return (b) ? M : N;} // Database routines virtual int Cardinality(PGLOBAL g); @@ -106,13 +106,14 @@ class TDBJSN : public TDBDOS { char *Objname; // The table object name char *Xcol; // Name of expandable column int Fpos; // The current row index -//int Spos; // DELETE start index int N; // The current Rownum + int M; // Index of multiple value int Limit; // Limit of multiple values int Pretty; // Depends on file structure int NextSame; // Same next row int SameRow; // Same row nb int Xval; // Index of expandable array + int B; // Array index base bool Strict; // Strict syntax checking bool Comma; // Row has final comma }; // end of class TDBJSN @@ -224,11 +225,6 @@ class TDBJCL : public TDBCAT { virtual PQRYRES GetResult(PGLOBAL g); // Members -//char *Dp; - const char *Fn; - char *Objn; - int Pretty; - int Lrecl; - int lvl; + PTOS Topt; + char *Db; }; // end of class TDBJCL - diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp index d163c443cd5..933e072c1bb 100644 --- a/storage/connect/table.cpp +++ b/storage/connect/table.cpp @@ -1,7 +1,7 @@ /************** Table C++ Functions Source Code File (.CPP) ************/ /* Name: TABLE.CPP Version 2.7 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* This file contains the TBX, TDB and OPJOIN classes functions. */ /***********************************************************************/ @@ -74,7 +74,7 @@ TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum) /***********************************************************************/ /* RowNumber: returns the current row ordinal number. */ /***********************************************************************/ -int TDB::RowNumber(PGLOBAL g, bool b) +int TDB::RowNumber(PGLOBAL g, bool) { sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType())); return 0; @@ -122,7 +122,7 @@ void TDB::Print(PGLOBAL g, FILE *f, uint n) } // end of Print -void TDB::Print(PGLOBAL g, char *ps, uint z) +void TDB::Print(PGLOBAL, char *ps, uint) { sprintf(ps, "R%d.%s", Tdb_No, Name); } // end of Print @@ -263,7 +263,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBASE::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -327,7 +327,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) return NULL; } // endif's name - if (!(colp = InsertSpecialColumn(g, colp))) { + if (!(colp = InsertSpecialColumn(colp))) { sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); return NULL; } // endif Insert @@ -338,7 +338,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) /***********************************************************************/ /* ResetTableOpt: Wrong for this table type. */ /***********************************************************************/ -int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox) +int TDBASE::ResetTableOpt(PGLOBAL g, bool, bool) { strcpy(g->Message, "This table is not indexable"); return RC_INFO; @@ -365,7 +365,7 @@ void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp) /***********************************************************************/ /* SetRecpos: Replace the table at the specified position. */ /***********************************************************************/ -bool TDBASE::SetRecpos(PGLOBAL g, int recpos) +bool TDBASE::SetRecpos(PGLOBAL g, int) { strcpy(g->Message, MSG(SETRECPOS_NIY)); return true; @@ -386,7 +386,7 @@ void TDBASE::PrintAM(FILE *f, char *m) /* Two questions here: exact meaning of U_J_INT ? */ /* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */ /***********************************************************************/ -void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2) +void TDBASE::MarkDB(PGLOBAL, PTDB tdb2) { if (trace) htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2); @@ -453,7 +453,7 @@ bool TDBCAT::Initialize(PGLOBAL g) /***********************************************************************/ /* CAT: Get the number of properties. */ /***********************************************************************/ -int TDBCAT::GetMaxSize(PGLOBAL g) +int TDBCAT::GetMaxSize(PGLOBAL g __attribute__((unused))) { if (MaxSize < 0) { // if (Initialize(g)) @@ -528,7 +528,7 @@ bool TDBCAT::InitCol(PGLOBAL g) /***********************************************************************/ /* SetRecpos: Replace the table at the specified position. */ /***********************************************************************/ -bool TDBCAT::SetRecpos(PGLOBAL g, int recpos) +bool TDBCAT::SetRecpos(PGLOBAL, int recpos) { N = recpos - 1; return false; @@ -537,7 +537,7 @@ bool TDBCAT::SetRecpos(PGLOBAL g, int recpos) /***********************************************************************/ /* Data Base read routine for CAT access method. */ /***********************************************************************/ -int TDBCAT::ReadDB(PGLOBAL g) +int TDBCAT::ReadDB(PGLOBAL) { return (++N < Qrp->Nblin) ? RC_OK : RC_EF; } // end of ReadDB @@ -554,7 +554,7 @@ int TDBCAT::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for CAT access methods. */ /***********************************************************************/ -int TDBCAT::DeleteDB(PGLOBAL g, int irc) +int TDBCAT::DeleteDB(PGLOBAL g, int) { strcpy(g->Message, "Delete not enabled for CAT tables"); return RC_FX; @@ -563,7 +563,7 @@ int TDBCAT::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for WMI access method. */ /***********************************************************************/ -void TDBCAT::CloseDB(PGLOBAL g) +void TDBCAT::CloseDB(PGLOBAL) { // Nothing to do } // end of CloseDB @@ -584,7 +584,7 @@ CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n) /***********************************************************************/ /* Read the next Data Source elements. */ /***********************************************************************/ -void CATCOL::ReadColumn(PGLOBAL g) +void CATCOL::ReadColumn(PGLOBAL) { // Get the value of the Name or Description property if (Crp->Kdata) diff --git a/storage/connect/tabmac.cpp b/storage/connect/tabmac.cpp index f072465ced5..e6e2abb54e2 100644 --- a/storage/connect/tabmac.cpp +++ b/storage/connect/tabmac.cpp @@ -3,12 +3,12 @@ /* From the article and sample code by Khalid Shaikh. */ /* TABMAC: virtual table to get the list of MAC addresses. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include "my_global.h" //#include <iphlpapi.h> -#else // !WIN32 -#error This is a WIN32 only table type -#endif // !WIN32 +#else // !__WIN__ +#error This is a WINDOWS only table type +#endif // !__WIN__ #include "global.h" #include "plgdbsem.h" //#include "catalog.h" diff --git a/storage/connect/tabmac.h b/storage/connect/tabmac.h index 5e6c98d68fb..f9a66e82eaa 100644 --- a/storage/connect/tabmac.h +++ b/storage/connect/tabmac.h @@ -1,11 +1,11 @@ // TABMAC.H Olivier Bertrand 2011-2012 // MAC: virtual table to Get Mac Addresses via GetAdaptersInfo -#if defined(WIN32) +#if defined(__WIN__) #include <windows.h> #include <iphlpapi.h> -#else // !WIN32 -#error This is a WIN32 only table TYPE -#endif // !WIN32 +#else // !__WIN__ +#error This is a WINDOWS only table TYPE +#endif // !__WIN__ /***********************************************************************/ /* Definitions. */ diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 94950584c9b..3008ca1b8ca 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -37,7 +37,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -145,7 +145,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) /*******************************************************************/ /* To_File is a multiple name with special characters */ /*******************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) char drive[_MAX_DRIVE], direc[_MAX_DIR]; WIN32_FIND_DATA FileData; HANDLE hSearch; @@ -196,7 +196,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) return true; } // endif FindClose -#else // !WIN32 +#else // !__WIN__ struct stat fileinfo; char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN]; DIR *dir; @@ -249,7 +249,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) // Close the dir handle. closedir(dir); -#endif // !WIN32 +#endif // !__WIN__ } else { /*******************************************************************/ @@ -269,7 +269,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) p = filename + strlen(filename) - 1; -#if defined(UNIX) +#if !defined(__WIN__) // Data files can be imported from Windows (having CRLF) if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? @@ -297,7 +297,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) } // endif Mul -#if defined(WIN32) +#if defined(__WIN__) suite: #endif @@ -561,7 +561,7 @@ int TDBMUL::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for MUL access method. */ /***********************************************************************/ -int TDBMUL::DeleteDB(PGLOBAL g, int irc) +int TDBMUL::DeleteDB(PGLOBAL g, int) { // When implementing DELETE_MODE InitFileNames must be updated to // eliminate CRLF under Windows if the file is read in binary. @@ -586,7 +586,7 @@ void TDBMUL::CloseDB(PGLOBAL g) /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR, int) { Desc = Fn = GetStringCatInfo(g, "Filename", NULL); Incl = (GetIntCatInfo("Subdir", 0) != 0); @@ -597,7 +597,7 @@ bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB DIRDEF::GetTable(PGLOBAL g, MODE m) +PTDB DIRDEF::GetTable(PGLOBAL g, MODE) { #if 0 if (Huge) @@ -620,17 +620,17 @@ TDBDIR::TDBDIR(PDIRDEF tdp) : TDBASE(tdp) { To_File = tdp->Fn; iFile = 0; -#if defined(WIN32) +#if defined(__WIN__) memset(&FileData, 0, sizeof(_finddata_t)); Hsearch = -1; *Drive = '\0'; -#else // !WIN32 +#else // !__WIN__ memset(&Fileinfo, 0, sizeof(struct stat)); Entry = NULL; Dir = NULL; Done = false; *Pattern = '\0'; -#endif // !WIN32 +#endif // !__WIN__ *Fpath = '\0'; *Direc = '\0'; *Fname = '\0'; @@ -641,17 +641,17 @@ TDBDIR::TDBDIR(PTDBDIR tdbp) : TDBASE(tdbp) { To_File = tdbp->To_File; iFile = tdbp->iFile; -#if defined(WIN32) +#if defined(__WIN__) FileData = tdbp->FileData; Hsearch = tdbp->Hsearch; strcpy(Drive, tdbp->Drive); -#else // !WIN32 +#else // !__WIN__ Fileinfo = tdbp->Fileinfo; Entry = tdbp->Entry; Dir = tdbp->Dir; Done = tdbp->Done; strcpy(Pattern, tdbp->Pattern); -#endif // !WIN32 +#endif // !__WIN__ strcpy(Direc, tdbp->Direc); strcpy(Fname, tdbp->Fname); strcpy(Ftype, tdbp->Ftype); @@ -675,7 +675,7 @@ char* TDBDIR::Path(PGLOBAL g) { PCATLG cat = PlgGetCatalog(g); -#if defined(WIN32) +#if defined(__WIN__) if (!*Drive) { PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); _splitpath(Fpath, Drive, Direc, Fname, Ftype); @@ -683,7 +683,7 @@ char* TDBDIR::Path(PGLOBAL g) _makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull ??? return Fpath; -#else // !WIN32 +#else // !__WIN__ if (!Done) { PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); _splitpath(Fpath, NULL, Direc, Fname, Ftype); @@ -692,7 +692,7 @@ char* TDBDIR::Path(PGLOBAL g) } // endif Done return Pattern; -#endif // !WIN32 +#endif // !__WIN__ } // end of Path /***********************************************************************/ @@ -710,7 +710,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { int n = -1; -#if defined(WIN32) +#if defined(__WIN__) int h; // Start searching files in the target directory. @@ -726,7 +726,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) } else n = 0; -#else // !WIN32 +#else // !__WIN__ Path(g); // Start searching files in the target directory. @@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) // Close the DIR handle. closedir(Dir); -#endif // !WIN32 +#endif // !__WIN__ MaxSize = n; } // endif MaxSize @@ -776,10 +776,10 @@ bool TDBDIR::OpenDB(PGLOBAL g) } // endif use Use = USE_OPEN; -#if !defined(WIN32) +#if !defined(__WIN__) Path(g); // Be sure it is done Dir = NULL; // For ReadDB -#endif // !WIN32 +#endif // !__WIN__ return false; } // end of OpenDB @@ -790,7 +790,7 @@ int TDBDIR::ReadDB(PGLOBAL g) { int rc = RC_OK; -#if defined(WIN32) +#if defined(__WIN__) if (Hsearch == -1) { /*******************************************************************/ /* Start searching files in the target directory. The use of the */ @@ -848,7 +848,7 @@ int TDBDIR::ReadDB(PGLOBAL g) rc = RC_EF; } // endif Entry -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of ReadDB @@ -865,7 +865,7 @@ int TDBDIR::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for DIR access method. */ /***********************************************************************/ -int TDBDIR::DeleteDB(PGLOBAL g, int irc) +int TDBDIR::DeleteDB(PGLOBAL g, int) { strcpy(g->Message, MSG(TABDIR_READONLY)); return RC_FX; // NIY @@ -874,19 +874,19 @@ int TDBDIR::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for MUL access method. */ /***********************************************************************/ -void TDBDIR::CloseDB(PGLOBAL g) +void TDBDIR::CloseDB(PGLOBAL) { -#if defined(WIN32) +#if defined(__WIN__) // Close the search handle. _findclose(Hsearch); Hsearch = -1; -#else // !WIN32 +#else // !__WIN__ // Close the DIR handle if (Dir) { closedir(Dir); Dir = NULL; } // endif dir -#endif // !WIN32 +#endif // !__WIN__ iFile = 0; } // end of CloseDB @@ -895,7 +895,7 @@ void TDBDIR::CloseDB(PGLOBAL g) /***********************************************************************/ /* DIRCOL public constructor. */ /***********************************************************************/ -DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -935,19 +935,19 @@ void DIRCOL::ReadColumn(PGLOBAL g) /* Retrieve the information corresponding to the column number. */ /*********************************************************************/ switch (N) { -#if defined(WIN32) +#if defined(__WIN__) case 0: Value->SetValue_psz(tdbp->Drive); break; -#endif // WIN32 +#endif // __WIN__ case 1: Value->SetValue_psz(tdbp->Direc); break; case 2: Value->SetValue_psz(tdbp->Fname); break; case 3: Value->SetValue_psz(tdbp->Ftype); break; -#if defined(WIN32) +#if defined(__WIN__) case 4: Value->SetValue((int)tdbp->FileData.attrib); break; case 5: Value->SetValue((int)tdbp->FileData.size); break; case 6: Value->SetValue((int)tdbp->FileData.time_write); break; case 7: Value->SetValue((int)tdbp->FileData.time_create); break; case 8: Value->SetValue((int)tdbp->FileData.time_access); break; -#else // !WIN32 +#else // !__WIN__ case 4: Value->SetValue((int)tdbp->Fileinfo.st_mode); break; case 5: Value->SetValue((int)tdbp->Fileinfo.st_size); break; case 6: Value->SetValue((int)tdbp->Fileinfo.st_mtime); break; @@ -955,7 +955,7 @@ void DIRCOL::ReadColumn(PGLOBAL g) case 8: Value->SetValue((int)tdbp->Fileinfo.st_atime); break; case 9: Value->SetValue((int)tdbp->Fileinfo.st_uid); break; case 10: Value->SetValue((int)tdbp->Fileinfo.st_gid); break; -#endif // !WIN32 +#endif // !__WIN__ default: sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); longjmp(g->jumper[g->jump_level], GetAmType()); @@ -1006,7 +1006,7 @@ int TDBSDR::FindInDir(PGLOBAL g) size_t m = strlen(Direc); // Start searching files in the target directory. -#if defined(WIN32) +#if defined(__WIN__) int h = _findfirst(Path(g), &FileData); if (h != -1) { @@ -1039,7 +1039,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the search handle. _findclose(h); } // endif h -#else // !WIN32 +#else // !__WIN__ int k; DIR *dir = opendir(Direc); @@ -1073,7 +1073,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the DIR handle. closedir(dir); -#endif // !WIN32 +#endif // !__WIN__ return n; } // end of FindInDir @@ -1089,13 +1089,13 @@ bool TDBSDR::OpenDB(PGLOBAL g) Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR)); Sub->Next = NULL; Sub->Prev = NULL; -#if defined(WIN32) +#if defined(__WIN__) Sub->H = -1; Sub->Len = strlen(Direc); -#else // !WIN32 +#else // !__WIN__ Sub->D = NULL; Sub->Len = 0; -#endif // !WIN32 +#endif // !__WIN__ } // endif To_Sub return TDBDIR::OpenDB(g); @@ -1108,7 +1108,7 @@ int TDBSDR::ReadDB(PGLOBAL g) { int rc; -#if defined(WIN32) +#if defined(__WIN__) again: rc = TDBDIR::ReadDB(g); @@ -1160,7 +1160,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif H } // endif rc -#else // !WIN32 +#else // !__WIN__ rc = RC_NF; again: @@ -1217,7 +1217,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif Entry -#endif // !WIN32 +#endif // !__WIN__ return rc; } // end of ReadDB diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h index 379e8f88e93..433cc3a2ee3 100644 --- a/storage/connect/tabmul.h +++ b/storage/connect/tabmul.h @@ -6,14 +6,14 @@ /* */ /* This file contains the TDBMUL and TDBDIR classes declares. */ /***********************************************************************/ -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> -#endif // !WIN32 +#endif // !__WIN__ //#include "osutil.h" #include "block.h" @@ -132,17 +132,17 @@ class TDBDIR : public TDBASE { // Members PSZ To_File; // Points to file search pathname int iFile; // Index of currently retrieved file -#if defined(WIN32) +#if defined(__WIN__) _finddata_t FileData; // Find data structure int Hsearch; // Search handle char Drive[_MAX_DRIVE]; // Drive name -#else // !WIN32 +#else // !__WIN__ struct stat Fileinfo; // File info structure struct dirent *Entry; // Point to directory entry structure DIR *Dir; // To searched directory structure bool Done; // true when _splipath is done char Pattern[_MAX_FNAME+_MAX_EXT]; -#endif // !WIN32 +#endif // !__WIN__ char Fpath[_MAX_PATH]; // Absolute file search pattern char Direc[_MAX_DIR]; // Search path char Fname[_MAX_FNAME]; // File name @@ -183,11 +183,11 @@ class TDBSDR : public TDBDIR { typedef struct _Sub_Dir { struct _Sub_Dir *Next; struct _Sub_Dir *Prev; -#if defined(WIN32) +#if defined(__WIN__) int H; // Search handle -#else // !WIN32 +#else // !__WIN__ DIR *D; -#endif // !WIN32 +#endif // !__WIN__ size_t Len; // Initial directory name length } SUBDIR, *PSUBDIR; diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index b18e4da2ec4..19a5dfd758f 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -5,7 +5,7 @@ /* */ /* AUTHOR: */ /* ------- */ -/* Olivier BERTRAND 2007-2014 */ +/* Olivier BERTRAND 2007-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,9 +35,9 @@ #include "my_global.h" #include "sql_class.h" #include "sql_servers.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ //#include <fnmatch.h> //#include <errno.h> #include <stdlib.h> @@ -46,7 +46,7 @@ #include "osutil.h" //#include <io.h> //#include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -307,7 +307,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b) /***********************************************************************/ /* DefineAM: define specific AM block values from XCV file. */ /***********************************************************************/ -bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int) { char *url; @@ -380,7 +380,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE m) +PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE) { if (Xsrc) return new(g) TDBMYEXC(this); @@ -438,7 +438,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBASE(tdp) Nparm = 0; } // end of TDBMYSQL constructor -TDBMYSQL::TDBMYSQL(PGLOBAL g, PTDBMY tdbp) : TDBASE(tdbp) +TDBMYSQL::TDBMYSQL(PTDBMY tdbp) : TDBASE(tdbp) { Host = tdbp->Host; Database = tdbp->Database; @@ -468,7 +468,7 @@ PTDB TDBMYSQL::CopyOne(PTABS t) PCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBMYSQL(g, this); + tp = new(g) TDBMYSQL(this); for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) { cp2 = new(g) MYSQLCOL((PMYCOL)cp1, tp); @@ -816,7 +816,7 @@ int TDBMYSQL::GetMaxSize(PGLOBAL g) /***********************************************************************/ /* This a fake routine as ROWID does not exist in MySQL. */ /***********************************************************************/ -int TDBMYSQL::RowNumber(PGLOBAL g, bool b) +int TDBMYSQL::RowNumber(PGLOBAL, bool) { return N + 1; } // end of RowNumber @@ -832,7 +832,7 @@ int TDBMYSQL::GetProgMax(PGLOBAL g) /***********************************************************************/ /* MySQL Bind Parameter function. */ /***********************************************************************/ -int TDBMYSQL::BindColumns(PGLOBAL g) +int TDBMYSQL::BindColumns(PGLOBAL g __attribute__((unused))) { #if defined(MYSQL_PREPARED_STATEMENTS) if (Prep) { @@ -1425,7 +1425,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ /* WriteColumn: make sure the bind buffer is updated. */ /***********************************************************************/ -void MYSQLCOL::WriteColumn(PGLOBAL g) +void MYSQLCOL::WriteColumn(PGLOBAL) { /*********************************************************************/ /* Do convert the column value if necessary. */ @@ -1463,7 +1463,7 @@ TDBMYEXC::TDBMYEXC(PMYDEF tdp) : TDBMYSQL(tdp) Nerr = 0; } // end of TDBMYEXC constructor -TDBMYEXC::TDBMYEXC(PGLOBAL g, PTDBMYX tdbp) : TDBMYSQL(g, tdbp) +TDBMYEXC::TDBMYEXC(PTDBMYX tdbp) : TDBMYSQL(tdbp) { Cmdlist = tdbp->Cmdlist; Cmdcol = tdbp->Cmdcol; @@ -1481,7 +1481,7 @@ PTDB TDBMYEXC::CopyOne(PTABS t) PCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBMYEXC(g, this); + tp = new(g) TDBMYEXC(this); for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) { cp2 = new(g) MYXCOL((PMYXCOL)cp1, tp); @@ -1534,7 +1534,7 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g) /***********************************************************************/ /* EXC GetMaxSize: returns the maximum number of rows in the table. */ /***********************************************************************/ -int TDBMYEXC::GetMaxSize(PGLOBAL g) +int TDBMYEXC::GetMaxSize(PGLOBAL) { if (MaxSize < 0) { MaxSize = 10; // a guess @@ -1711,7 +1711,7 @@ void MYXCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ /* WriteColumn: should never be called. */ /***********************************************************************/ -void MYXCOL::WriteColumn(PGLOBAL g) +void MYXCOL::WriteColumn(PGLOBAL) { assert(false); } // end of WriteColumn diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 99930d43a57..17d7b190340 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -73,11 +73,11 @@ class TDBMYSQL : public TDBASE { public: // Constructor TDBMYSQL(PMYDEF tdp); - TDBMYSQL(PGLOBAL g, PTDBMY tdbp); + TDBMYSQL(PTDBMY tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;} - virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);} + virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(this);} // Methods virtual PTDB CopyOne(PTABS t); @@ -180,11 +180,11 @@ class TDBMYEXC : public TDBMYSQL { public: // Constructors TDBMYEXC(PMYDEF tdp); - TDBMYEXC(PGLOBAL g, PTDBMYX tdbp); + TDBMYEXC(PTDBMYX tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_MYX;} - virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(g, this);} + virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYEXC(this);} // Methods virtual PTDB CopyOne(PTABS t); diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 7f7b1c5d50c..07e260154e0 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -13,7 +13,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -266,7 +266,7 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) +PTDB OCCURDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc != FNC_COL) return new(g) TDBOCCUR(this); @@ -432,7 +432,7 @@ int TDBOCCUR::GetMaxSize(PGLOBAL g) /* In this sample, ROWID will be the (virtual) row number, */ /* while ROWNUM will be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBOCCUR::RowNumber(PGLOBAL g, bool b) +int TDBOCCUR::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -567,7 +567,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g) /* ReadColumn: what this routine does is to access the Mth columns of */ /* list, extract its name and set to it the rank column value. */ /***********************************************************************/ -void RANKCOL::ReadColumn(PGLOBAL g) +void RANKCOL::ReadColumn(PGLOBAL) { PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb; PCOL *col = tdbp->Col; diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 3bf1238cebc..307509848f4 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -1268,6 +1268,10 @@ void ODBCCOL::ReadColumn(PGLOBAL g) } // endif Buf_Type + // Handle null values + if (Value->IsZero()) + Value->SetNull(Nullable); + if (trace) { char buf[64]; @@ -1393,7 +1397,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g) /* -------------------------- Class TDBXDBC -------------------------- */ /***********************************************************************/ -/* Implementation of the TDBODBC class. */ +/* Implementation of the TDBXDBC class. */ /***********************************************************************/ TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp) { diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 401ffa3780e..b628e26d3c7 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif @@ -376,7 +376,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE m) +PTDB PIVOTDEF::GetTable(PGLOBAL g, MODE) { return new(g) TDBPIVOT(this); } // end of GetTable @@ -634,7 +634,7 @@ bool TDBPIVOT::MakeViewColumns(PGLOBAL g) /***********************************************************************/ /* PIVOT GetMaxSize: returns the maximum number of rows in the table. */ /***********************************************************************/ -int TDBPIVOT::GetMaxSize(PGLOBAL g) +int TDBPIVOT::GetMaxSize(PGLOBAL g __attribute__((unused))) { #if 0 if (MaxSize < 0) @@ -649,7 +649,7 @@ int TDBPIVOT::GetMaxSize(PGLOBAL g) /* In this sample, ROWID will be the (virtual) row number, */ /* while ROWNUM will be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBPIVOT::RowNumber(PGLOBAL g, bool b) +int TDBPIVOT::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -806,7 +806,7 @@ int TDBPIVOT::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for PIVOT access methods. */ /***********************************************************************/ -int TDBPIVOT::DeleteDB(PGLOBAL g, int irc) +int TDBPIVOT::DeleteDB(PGLOBAL g, int) { sprintf(g->Message, MSG(NO_TABLE_DEL), "PIVOT"); return RC_FX; diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 3ed182c5e33..76890e84429 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -3,7 +3,7 @@ /* ------------- */ /* Version 2.3 */ /* */ -/* Author Olivier BERTRAND 2004-2014 */ +/* Author Olivier BERTRAND 2004-2015 */ /* */ /* This program are the INI/CFG tables classes. */ /***********************************************************************/ @@ -12,12 +12,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include application header files: */ @@ -36,9 +36,9 @@ #include "global.h" #include "plgdbsem.h" #include "reldef.h" -#if !defined(WIN32) +#if !defined(__WIN__) #include "osutil.h" -#endif // !WIN32 +#endif // !__WIN__ #include "filamtxt.h" #include "tabdos.h" #include "tabsys.h" @@ -48,10 +48,10 @@ #define CSZ 36 // Column section name length #define CDZ 256 // Column definition length -#if !defined(WIN32) +#if !defined(__WIN__) #define GetPrivateProfileSectionNames(S,L,I) \ GetPrivateProfileString(NULL,NULL,"",S,L,I) -#endif // !WIN32 +#endif // !__WIN__ /* -------------- Implementation of the INI classes ------------------ */ @@ -70,7 +70,7 @@ INIDEF::INIDEF(void) /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool INIDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char buf[8]; @@ -96,7 +96,7 @@ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB INIDEF::GetTable(PGLOBAL g, MODE m) +PTDB INIDEF::GetTable(PGLOBAL g, MODE) { PTDBASE tdbp; @@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g) // Delete the INI table file if not protected if (!IsReadOnly()) { PlugSetPath(filename, Fn, GetPath()); -#if defined(WIN32) +#if defined(__WIN__) rc = !DeleteFile(filename); #else // UNIX rc = remove(filename); @@ -277,49 +277,27 @@ bool TDBINI::OpenDB(PGLOBAL g) /***********************************************************************/ /* Data Base read routine for INI access method. */ /***********************************************************************/ -int TDBINI::ReadDB(PGLOBAL g) +int TDBINI::ReadDB(PGLOBAL) { /*********************************************************************/ /* Now start the pseudo reading process. */ /*********************************************************************/ -#if 0 // INI tables are not indexable - if (To_Kindex) { - /*******************************************************************/ - /* Reading is by an index table. */ - /*******************************************************************/ - int recpos = To_Kindex->Fetch(g); - - switch (recpos) { - case -1: // End of file reached - return RC_EF; - case -2: // No match for join - return RC_NF; - case -3: // Same record as last non null one - return RC_OK; - default: - Section = (char*)recpos; // No good on 64 bit machines - } // endswitch recpos - - } else { -#endif // 0 - if (!Section) - Section = Seclist; - else - Section += (strlen(Section) + 1); - - if (trace > 1) - htrc("INI ReadDB: section=%s N=%d\n", Section, N); + if (!Section) + Section = Seclist; + else + Section += (strlen(Section) + 1); - N++; -//} // endif To_Kindex + if (trace > 1) + htrc("INI ReadDB: section=%s N=%d\n", Section, N); + N++; return (*Section) ? RC_OK : RC_EF; } // end of ReadDB /***********************************************************************/ /* WriteDB: Data Base write routine for INI access methods. */ /***********************************************************************/ -int TDBINI::WriteDB(PGLOBAL g) +int TDBINI::WriteDB(PGLOBAL) { // This is to check that section name was given when inserting if (Mode == MODE_INSERT) @@ -365,11 +343,11 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* Data Base close routine for INI access methods. */ /***********************************************************************/ -void TDBINI::CloseDB(PGLOBAL g) +void TDBINI::CloseDB(PGLOBAL) { -#if !defined(WIN32) +#if !defined(__WIN__) PROFILE_Close(Ifile); -#endif // !WIN32 +#endif // !__WIN__ } // end of CloseDB // ------------------------ INICOL functions ---------------------------- @@ -377,7 +355,7 @@ void TDBINI::CloseDB(PGLOBAL g) /***********************************************************************/ /* INICOL public constructor. */ /***********************************************************************/ -INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -471,7 +449,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) /* from the corresponding section, extract from it the key value */ /* corresponding to this column name and convert it to buffer type. */ /***********************************************************************/ -void INICOL::ReadColumn(PGLOBAL g) +void INICOL::ReadColumn(PGLOBAL) { PTDBINI tdbp = (PTDBINI)To_Tdb; @@ -747,7 +725,7 @@ int TDBXIN::ReadDB(PGLOBAL g) /***********************************************************************/ /* WriteDB: Data Base write routine for XIN access methods. */ /***********************************************************************/ -int TDBXIN::WriteDB(PGLOBAL g) +int TDBXIN::WriteDB(PGLOBAL) { // To check that section and key names were given when inserting if (Mode == MODE_INSERT) { @@ -809,7 +787,7 @@ XINCOL::XINCOL(XINCOL *col1, PTDB tdbp) : INICOL(col1, tdbp) /* from the corresponding section, extract from it the key value */ /* corresponding to this column name and convert it to buffer type. */ /***********************************************************************/ -void XINCOL::ReadColumn(PGLOBAL g) +void XINCOL::ReadColumn(PGLOBAL) { PTDBXIN tdbp = (PTDBXIN)To_Tdb; diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 2bf26a5f183..7f979eaf4be 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -39,7 +39,7 @@ //#include "sql_base.h" #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -73,15 +73,15 @@ #include "tabmysql.h" #include "ha_connect.h" -#if defined(WIN32) +#if defined(__WIN__) #if defined(__BORLANDC__) #define SYSEXIT void _USERENTRY #else #define SYSEXIT void #endif -#else // !WIN32 +#else // !__WIN__ #define SYSEXIT void * -#endif // !WIN32 +#endif // !__WIN__ /* ---------------------------- Class TBLDEF ---------------------------- */ @@ -101,7 +101,7 @@ TBLDEF::TBLDEF(void) /**************************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /**************************************************************************/ -bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char *tablist, *dbname, *def = NULL; @@ -161,7 +161,7 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB TBLDEF::GetTable(PGLOBAL g, MODE m) +PTDB TBLDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -202,7 +202,7 @@ PCOL TDBTBL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp) +PCOL TDBTBL::InsertSpecialColumn(PCOL scp) { PCOL colp; @@ -548,7 +548,7 @@ int TDBTBL::ReadDB(PGLOBAL g) /***********************************************************************/ /* ReadColumn: */ /***********************************************************************/ -void TBTBLK::ReadColumn(PGLOBAL g) +void TBTBLK::ReadColumn(PGLOBAL) { if (trace) htrc("TBT ReadColumn: name=%s\n", Name); diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 8bf440985ea..9d3f297f9e7 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -81,7 +81,7 @@ class DllExport TDBTBL : public TDBPRX { virtual int Cardinality(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); virtual int RowNumber(PGLOBAL g, bool b = FALSE); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); + virtual PCOL InsertSpecialColumn(PCOL scp); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index c26d766af01..331a7f45d4d 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -14,7 +14,7 @@ #include "sql_class.h" #include "table.h" #include "field.h" -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -292,7 +292,7 @@ PRXDEF::PRXDEF(void) /***********************************************************************/ /* DefineAM: define specific AM block values from XCOL file. */ /***********************************************************************/ -bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int) { char *pn, *db, *tab, *def = NULL; @@ -322,7 +322,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB PRXDEF::GetTable(PGLOBAL g, MODE mode) +PTDB PRXDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -341,7 +341,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) Tdbp = NULL; // The object table } // end of TDBPRX constructor -TDBPRX::TDBPRX(PGLOBAL g, PTDBPRX tdbp) : TDBASE(tdbp) +TDBPRX::TDBPRX(PTDBPRX tdbp) : TDBASE(tdbp) { Tdbp = tdbp->Tdbp; } // end of TDBPRX copy constructor @@ -353,7 +353,7 @@ PTDB TDBPRX::CopyOne(PTABS t) PPRXCOL cp1, cp2; PGLOBAL g = t->G; - tp = new(g) TDBPRX(g, this); + tp = new(g) TDBPRX(this); for (cp1 = (PPRXCOL)Columns; cp1; cp1 = (PPRXCOL)cp1->GetNext()) { cp2 = new(g) PRXCOL(cp1, tp); // Make a copy diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index c5935d72184..b320d169b36 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -59,12 +59,12 @@ class DllExport TDBPRX : public TDBASE { public: // Constructors TDBPRX(PPRXDEF tdp); - TDBPRX(PGLOBAL g, PTDBPRX tdbp); + TDBPRX(PTDBPRX tdbp); // Implementation virtual AMT GetAmType(void) {return TYPE_AM_PRX;} virtual PTDB Duplicate(PGLOBAL g) - {return (PTDB)new(g) TDBPRX(g, this);} + {return (PTDB)new(g) TDBPRX(this);} // Methods virtual PTDB CopyOne(PTABS t); diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 3ed40540395..e788529075f 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -94,7 +94,7 @@ PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ -bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) { DOSDEF::DefineAM(g, "BIN", poff); @@ -146,7 +146,7 @@ bool VCTDEF::Erase(char *filename) for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) { sprintf(filename, fpat, i); -//#if defined(WIN32) +//#if defined(__WIN__) // rc |= !DeleteFile(filename); //#else // UNIX rc |= remove(filename); @@ -175,7 +175,7 @@ bool VCTDEF::Erase(char *filename) int VCTDEF::MakeFnPattern(char *fpat) { char pat[8]; -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -290,7 +290,7 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* VEC tables are not ready yet to use temporary files. */ /***********************************************************************/ -bool TDBVCT::IsUsingTemp(PGLOBAL g) +bool TDBVCT::IsUsingTemp(PGLOBAL) { // For developpers return (UseTemp() == TMP_TEST); @@ -570,7 +570,7 @@ void VCTCOL::ReadColumn(PGLOBAL g) /* On each change of block the buffer is written back to file and */ /* in mode Insert the buffer is filled with the block to update. */ /***********************************************************************/ -void VCTCOL::WriteColumn(PGLOBAL g) +void VCTCOL::WriteColumn(PGLOBAL) { PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;; diff --git a/storage/connect/tabvir.cpp b/storage/connect/tabvir.cpp index b4c76f5ad56..356fc981357 100644 --- a/storage/connect/tabvir.cpp +++ b/storage/connect/tabvir.cpp @@ -29,7 +29,7 @@ /***********************************************************************/ /* Return the unique column definition to MariaDB. */ /***********************************************************************/ -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info) +PQRYRES VirColumns(PGLOBAL g, bool info) { int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_STRING, TYPE_STRING}; @@ -95,7 +95,7 @@ PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info) /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ -PTDB VIRDEF::GetTable(PGLOBAL g, MODE m) +PTDB VIRDEF::GetTable(PGLOBAL g, MODE) { // Column blocks will be allocated only when needed. if (Catfunc == FNC_COL) @@ -241,7 +241,7 @@ bool TDBVIR::OpenDB(PGLOBAL g) /***********************************************************************/ /* Data Base read routine for the VIR access method. */ /***********************************************************************/ -int TDBVIR::ReadDB(PGLOBAL g) +int TDBVIR::ReadDB(PGLOBAL) { return (++N >= Size) ? RC_EF : RC_OK; } // end of ReadDB @@ -258,7 +258,7 @@ int TDBVIR::WriteDB(PGLOBAL g) /***********************************************************************/ /* Data Base delete line routine for the VIR access methods. */ /***********************************************************************/ -int TDBVIR::DeleteDB(PGLOBAL g, int irc) +int TDBVIR::DeleteDB(PGLOBAL g, int) { sprintf(g->Message, MSG(VIR_NO_DELETE), To_Def->GetType()); return RC_FX; @@ -269,7 +269,7 @@ int TDBVIR::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ /* VIRCOL public constructor. */ /***********************************************************************/ -VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) +VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) : COLBLK(cdp, tdbp, i) { if (cprec) { @@ -299,7 +299,7 @@ void VIRCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ PQRYRES TDBVICL::GetResult(PGLOBAL g) { - return VirColumns(g, NULL, NULL, false); + return VirColumns(g, false); } // end of GetResult /* ------------------------- End of Virtual -------------------------- */ diff --git a/storage/connect/tabvir.h b/storage/connect/tabvir.h index 8d0caa257e7..a53aceaeceb 100644 --- a/storage/connect/tabvir.h +++ b/storage/connect/tabvir.h @@ -11,7 +11,7 @@ typedef class TDBVIR *PTDBVIR; /***********************************************************************/ /* Return the unique column definition to MariaDB. */ /***********************************************************************/ -PQRYRES VirColumns(PGLOBAL g, char *tab, char *db, bool info); +PQRYRES VirColumns(PGLOBAL g, bool info); /* --------------------------- VIR classes --------------------------- */ diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index 7c69426a066..98a44b9d635 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -2,9 +2,9 @@ /* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2013 */ /* TABWMI: Virtual table to get WMI information. */ /***********************************************************************/ -#if !defined(WIN32) -#error This is a WIN32 only table type -#endif // !WIN32 +#if !defined(__WIN__) +#error This is a WINDOWS only table type +#endif // !__WIN__ #include "my_global.h" #include <stdio.h> diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index dffbaf6e187..add61431493 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(WIN32) +#if defined(__WIN__) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -83,7 +83,7 @@ bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) /***********************************************************************/ /* GetTable: makes a new TDB of the proper type. */ /***********************************************************************/ -PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) +PTDB XCLDEF::GetTable(PGLOBAL g, MODE) { if (Catfunc == FNC_COL) return new(g) TDBTBC(this); @@ -117,7 +117,7 @@ PCOL TDBXCL::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) PCOL colp; if (!stricmp(cdp->GetName(), Xcolumn)) { - Xcolp = new(g) XCLCOL(g, cdp, this, cprec, n); + Xcolp = new(g) XCLCOL(cdp, this, cprec, n); colp = Xcolp; } else colp = new(g) PRXCOL(cdp, this, cprec, n); @@ -144,7 +144,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g) /* For this table type, ROWID is the (virtual) row number, */ /* while ROWNUM is be the occurence rank in the multiple column. */ /***********************************************************************/ -int TDBXCL::RowNumber(PGLOBAL g, bool b) +int TDBXCL::RowNumber(PGLOBAL, bool b) { return (b) ? M : N; } // end of RowNumber @@ -232,7 +232,7 @@ int TDBXCL::ReadDB(PGLOBAL g) /***********************************************************************/ /* XCLCOL public constructor. */ /***********************************************************************/ -XCLCOL::XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) +XCLCOL::XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) : PRXCOL(cdp, tdbp, cprec, i, "XCL") { // Set additional XXL access method information for column. diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h index ed15a67b629..291f0b4263a 100644 --- a/storage/connect/tabxcl.h +++ b/storage/connect/tabxcl.h @@ -85,7 +85,7 @@ class XCLCOL : public PRXCOL { friend class TDBXCL; public: // Constructors - XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); + XCLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); // Methods using PRXCOL::Init; diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 6fba8382aaa..49fa9a1c554 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -15,12 +15,12 @@ #include <stdio.h> #include <fcntl.h> #include <errno.h> -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <winsock2.h> //#include <windows.h> #include <comdef.h> -#else // !WIN32 +#else // !__WIN__ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -28,7 +28,7 @@ //#include <ctype.h> #include "osutil.h" #define _O_RDONLY O_RDONLY -#endif // !WIN32 +#endif // !__WIN__ #include "resource.h" // for IDS_COLUMNS #define INCLUDE_TDBXML @@ -53,11 +53,11 @@ extern "C" char version[]; -#if defined(WIN32) && defined(DOMDOC_SUPPORT) +#if defined(__WIN__) && defined(DOMDOC_SUPPORT) #define XMLSUP "MS-DOM" -#else // !WIN32 +#else // !__WIN__ #define XMLSUP "libxml2" -#endif // !WIN32 +#endif // !__WIN__ #define TYPE_UNKNOWN 12 /* Must be greater than other types */ @@ -110,14 +110,14 @@ typedef struct LVL { /* XMLColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside an XML file. */ /***********************************************************************/ -PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) +PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - char *op, colname[65], fmt[129], buf[512]; + char *fn, *op, colname[65], fmt[129], buf[512]; int i, j, lvl, n = 0; int ncol = sizeof(buftyp) / sizeof(int); bool ok = true; @@ -138,33 +138,35 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) /*********************************************************************/ /* Open the input file. */ /*********************************************************************/ - if (!topt->filename) { + if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; - } else - lvl = atoi(GetListOption(g, "Level", topt->oplist, "0")); + } else { + lvl = GetIntegerTableOption(g, topt, "Level", 0); + lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl; + } // endif fn if (trace) htrc("File %s lvl=%d\n", topt->filename, lvl); tdp = new(g) XMLDEF; - tdp->Database = dp; - tdp->Fn = (char*)topt->filename; + tdp->Fn = fn; + tdp->Database = SetPath(g, db); tdp->Tabname = tab; - if (!(op = GetListOption(g, "Xmlsup", topt->oplist, NULL))) -#if defined(WIN32) + if (!(op = GetStringTableOption(g, topt, "Xmlsup", NULL))) +#if defined(__WIN__) tdp->Usedom = true; -#else // !WIN32 +#else // !__WIN__ tdp->Usedom = false; -#endif // !WIN32 +#endif // !__WIN__ else tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D'); txmp = new(g) TDBXML(tdp); if (txmp->Initialize(g)) - return NULL; + goto err; xcol = new(g) XMCOL; colname[64] = 0; @@ -224,8 +226,16 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) if (vp->atp) { strncpy(colname, vp->atp->GetName(g), sizeof(colname)); strncat(xcol->Name, colname, 64); - vp->atp->GetText(g, buf, sizeof(buf)); - strncat(fmt, "@", sizeof(fmt)); + + switch (vp->atp->GetText(g, buf, sizeof(buf))) { + case RC_INFO: + PushWarning(g, txmp); + case RC_OK: + strncat(fmt, "@", sizeof(fmt)); + break; + default: + goto err; + } // enswitch rc if (j) strncat(fmt, colname, sizeof(fmt)); @@ -273,7 +283,15 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) } else ok = true; - node->GetContent(g, buf, sizeof(buf)); + switch (node->GetContent(g, buf, sizeof(buf))) { + case RC_INFO: + PushWarning(g, txmp); + case RC_OK: + break; + default: + goto err; + } // enswitch rc + } // endif atp; xcol->Len = strlen(buf); @@ -313,10 +331,6 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) pxcp = xcp; -// for (j = lvl - 1; j >= 0; j--) -// if (jrp[j] && (jrp[j] = jrp[j]->GetNext())) -// goto more; - if (vp->atp) vp->atp = vp->atp->GetNext(g); @@ -420,9 +434,7 @@ XMLDEF::XMLDEF(void) /***********************************************************************/ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - char *defrow, *defcol, buf[10]; -//void *memp = Cat->GetDescp(); -//PSZ dbfile = Cat->GetDescFile(); + char *defrow, *defcol, buf[10]; Fn = GetStringCatInfo(g, "Filename", NULL); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8"); @@ -437,7 +449,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) return true; } // endif flag - defrow = defcol = ""; + defrow = defcol = NULL; GetCharCatInfo("Coltype", "", buf, sizeof(buf)); switch (toupper(*buf)) { @@ -470,36 +482,29 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Tabname = GetStringCatInfo(g, "Tabname", Tabname); Rowname = GetStringCatInfo(g, "Rownode", defrow); Colname = GetStringCatInfo(g, "Colnode", defcol); - Mulnode = GetStringCatInfo(g, "Mulnode", ""); - XmlDB = GetStringCatInfo(g, "XmlDB", ""); - Nslist = GetStringCatInfo(g, "Nslist", ""); - DefNs = GetStringCatInfo(g, "DefNs", ""); + Mulnode = GetStringCatInfo(g, "Mulnode", NULL); + XmlDB = GetStringCatInfo(g, "XmlDB", NULL); + Nslist = GetStringCatInfo(g, "Nslist", NULL); + DefNs = GetStringCatInfo(g, "DefNs", NULL); Limit = GetIntCatInfo("Limit", 10); - Xpand = (GetIntCatInfo("Expand", 0) != 0); + Xpand = GetBoolCatInfo("Expand", false); Header = GetIntCatInfo("Header", 0); GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf)); -//if (*buf == '*') // Try the old (deprecated) option -// GetCharCatInfo("Method", "*", buf, sizeof(buf)); - -//if (*buf == '*') // Is there a default for the database? -// GetCharCatInfo("Defxml", XMLSUP, buf, sizeof(buf)); - // Note that if no support is specified, the default is MS-DOM // on Windows and libxml2 otherwise if (*buf == '*') -#if defined(WIN32) +#if defined(__WIN__) Usedom = true; -#else // !WIN32 +#else // !__WIN__ Usedom = false; -#endif // !WIN32 +#endif // !__WIN__ else Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D'); // Get eventual table node attribute - Attrib = GetStringCatInfo(g, "Attribute", ""); - Hdattr = GetStringCatInfo(g, "HeadAttr", ""); - + Attrib = GetStringCatInfo(g, "Attribute", NULL); + Hdattr = GetStringCatInfo(g, "HeadAttr", NULL); return false; } // end of DefineAM @@ -519,30 +524,6 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m) return tdbp; } // end of GetTable -#if 0 -/***********************************************************************/ -/* DeleteTableFile: Delete XML table files using platform API. */ -/***********************************************************************/ -bool XMLDEF::DeleteTableFile(PGLOBAL g) - { - char filename[_MAX_PATH]; - bool rc; - - // Delete the XML table file if not protected - if (!IsReadOnly()) { - PlugSetPath(filename, Fn, GetPath()); -#if defined(WIN32) - rc = !DeleteFile(filename); -#else // UNIX - rc = remove(filename); -#endif // UNIX - } else - rc =true; - - return rc; // Return true if error - } // end of DeleteTableFile -#endif // 0 - /* ------------------------- TDBXML Class ---------------------------- */ /***********************************************************************/ @@ -564,14 +545,14 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp) Xfile = tdp->Fn; Enc = tdp->Encoding; Tabname = tdp->Tabname; - Rowname = (tdp->Rowname && *tdp->Rowname) ? tdp->Rowname : NULL; - Colname = (tdp->Colname && *tdp->Colname) ? tdp->Colname : NULL; - Mulnode = (tdp->Mulnode && *tdp->Mulnode) ? tdp->Mulnode : NULL; - XmlDB = (tdp->XmlDB && *tdp->XmlDB) ? tdp->XmlDB : NULL; - Nslist = (tdp->Nslist && *tdp->Nslist) ? tdp->Nslist : NULL; - DefNs = (tdp->DefNs && *tdp->DefNs) ? tdp->DefNs : NULL; - Attrib = (tdp->Attrib && *tdp->Attrib) ? tdp->Attrib : NULL; - Hdattr = (tdp->Hdattr && *tdp->Hdattr) ? tdp->Hdattr : NULL; + Rowname = (tdp->Rowname) ? tdp->Rowname : NULL; + Colname = (tdp->Colname) ? tdp->Colname : NULL; + Mulnode = (tdp->Mulnode) ? tdp->Mulnode : NULL; + XmlDB = (tdp->XmlDB) ? tdp->XmlDB : NULL; + Nslist = (tdp->Nslist) ? tdp->Nslist : NULL; + DefNs = (tdp->DefNs) ? tdp->DefNs : NULL; + Attrib = (tdp->Attrib) ? tdp->Attrib : NULL; + Hdattr = (tdp->Hdattr) ? tdp->Hdattr : NULL; Coltype = tdp->Coltype; Limit = tdp->Limit; Xpand = tdp->Xpand; @@ -667,7 +648,7 @@ PCOL TDBXML::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/ -PCOL TDBXML::InsertSpecialColumn(PGLOBAL g, PCOL colp) +PCOL TDBXML::InsertSpecialColumn(PCOL colp) { if (!colp->IsSpecial()) return NULL; @@ -854,7 +835,6 @@ bool TDBXML::Initialize(PGLOBAL g) To_Xb = Docp->LinkXblock(g, Mode, rc, filename); // Add a CONNECT comment node -// sprintf(buf, " Created by CONNECT %s ", version); strcpy(buf, " Created by the MariaDB CONNECT Storage Engine"); Docp->AddComment(g, buf); @@ -898,7 +878,7 @@ bool TDBXML::Initialize(PGLOBAL g) Nlist = TabNode->GetChildElements(g); Docp->SetNofree(true); // For libxml2 -#if defined(WIN32) +#if defined(__WIN__) } catch(_com_error e) { // We come here if a DOM command threw an error char buf[128]; @@ -912,7 +892,7 @@ bool TDBXML::Initialize(PGLOBAL g) sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error()); goto error; -#endif // WIN32 +#endif // __WIN__ #if !defined(UNIX) } catch(...) { // Other errors @@ -1037,7 +1017,7 @@ int TDBXML::GetMaxSize(PGLOBAL g) else MaxSize = 10; - } // endif MaxSize + } // endif MaxSize return MaxSize; } // end of GetMaxSize @@ -1278,8 +1258,7 @@ void TDBXML::CloseDB(PGLOBAL g) { if (Docp) { if (Changed) { - char filename[_MAX_PATH]; -// PDBUSER dup = (PDBUSER)g->Activityp->Aptr; + char filename[_MAX_PATH]; // We used the file name relative to recorded datapath PlugSetPath(filename, Xfile, GetPath()); @@ -1321,7 +1300,6 @@ void TDBXML::CloseDB(PGLOBAL g) NewRow = false; Hasnod = false; Write = false; -// Bufdone = false; Nodedone = false; Void = false; Nrow = -1; @@ -1413,8 +1391,6 @@ bool XMLCOL::AllocBuf(PGLOBAL g, bool mode) if (Valbuf) return false; // Already done -//Valbuf = (char*)PlugSubAlloc(g, NULL, Long + 1); -//Valbuf[Long] = '\0'; return ParseXpath(g, mode); } // end of AllocBuf @@ -1506,8 +1482,6 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) // HTML like table, columns are retrieved by position new(this) XPOSCOL(Value); // Change the class of this column Inod = -1; -// Tdbp->Hasnod = true; -// return false; } else if (Type == 0 && !mode) { strcat(strcat(pbuf, "@"), Name); } else { // Type == 1 @@ -1657,7 +1631,6 @@ void XMLCOL::WriteColumn(PGLOBAL g) int done = 0; int i, n, k = 0; PXNODE TopNode = NULL; -//PXATTR AttNode = NULL; if (trace > 1) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", @@ -1689,7 +1662,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ /* Null values are represented by no node. */ /*********************************************************************/ - if (Value->IsNull()) + if (Value->IsNull()) return; /*********************************************************************/ @@ -1892,7 +1865,6 @@ void XMULCOL::WriteColumn(PGLOBAL g) int done = 0; int i, n, len, k = 0; PXNODE TopNode = NULL; -//PXATTR AttNode = NULL; if (trace) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", @@ -2190,7 +2162,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g) TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); - Dp = tdp->GetPath(); + Db = (char*)tdp->GetDB(); Tabn = tdp->Tabname; } // end of TDBXCT constructor @@ -2199,7 +2171,7 @@ TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBXCT::GetResult(PGLOBAL g) { - return XMLColumns(g, Dp, Tabn, Topt, false); + return XMLColumns(g, Db, Tabn, Topt, false); } // end of GetResult /* ------------------------ End of Tabxml ---------------------------- */ diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h index f6cfd3fb510..7ba3166881d 100644 --- a/storage/connect/tabxml.h +++ b/storage/connect/tabxml.h @@ -1,7 +1,7 @@ /*************** Tabxml H Declares Source Code File (.H) ***************/ /* Name: TABXML.H Version 1.6 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ +/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */ /* */ /* This file contains the XML table classes declares. */ /***********************************************************************/ @@ -84,7 +84,7 @@ class DllExport TDBXML : public TDBASE { // Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); //virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;} virtual int Cardinality(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); @@ -255,8 +255,7 @@ class TDBXCT : public TDBCAT { // Members PTOS Topt; - char *Dp; -//const char *Fn; + char *Db; char *Tabn; }; // end of class TDBXCT diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index 4affe447b00..34d192361a5 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -1,4 +1,4 @@ -/* Copyright (C) Olivier Bertrand 2004 - 2014 +/* Copyright (C) Olivier Bertrand 2004 - 2015 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ */ /****************************************************************************/ -/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2014 */ +/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2015 */ /****************************************************************************/ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation @@ -63,7 +63,7 @@ void SetWorkSize(uint); /****************************************************************************/ /* Constructor. */ /****************************************************************************/ -user_connect::user_connect(THD *thd, const char *dbn) +user_connect::user_connect(THD *thd) { thdp= thd; next= NULL; diff --git a/storage/connect/user_connect.h b/storage/connect/user_connect.h index 44e4e94fa8a..7f37973f378 100644 --- a/storage/connect/user_connect.h +++ b/storage/connect/user_connect.h @@ -45,7 +45,7 @@ class user_connect friend int connect_done_func(void *); public: // Constructor - user_connect(THD *thd, const char *dbn); + user_connect(THD *thd); // Destructor virtual ~user_connect(); diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index e731ad156d9..5fefcba5856 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -23,7 +23,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> #else #include "osutil.h" @@ -132,7 +132,7 @@ VALBLK::VALBLK(void *mp, int type, int nval, bool un) /***********************************************************************/ /* Raise error for numeric types. */ /***********************************************************************/ -PSZ VALBLK::GetCharValue(int n) +PSZ VALBLK::GetCharValue(int) { PGLOBAL& g = Global; @@ -145,7 +145,7 @@ PSZ VALBLK::GetCharValue(int n) /***********************************************************************/ /* Set format so formatted dates can be converted on input. */ /***********************************************************************/ -bool VALBLK::SetFormat(PGLOBAL g, PSZ fmt, int len, int year) +bool VALBLK::SetFormat(PGLOBAL g, PSZ, int, int) { sprintf(g->Message, MSG(NO_DATE_FMT), Type); return true; @@ -752,7 +752,7 @@ double CHRBLK::GetFloatValue(int n) /***********************************************************************/ /* STRING GetCharString: get string representation of a char value. */ /***********************************************************************/ -char *CHRBLK::GetCharString(char *p, int n) +char *CHRBLK::GetCharString(char *, int n) { return (char *)GetValPtrEx(n); } // end of GetCharString diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index 5a98257f98f..f6eb7258a77 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -95,17 +95,17 @@ class VALBLK : public BLOCK { virtual bool IsCi(void) {return false;} // Methods - virtual void SetValue(short sval, int n) {assert(false);} - virtual void SetValue(ushort sval, int n) {assert(false);} - virtual void SetValue(int lval, int n) {assert(false);} - virtual void SetValue(uint lval, int n) {assert(false);} - virtual void SetValue(longlong lval, int n) {assert(false);} - virtual void SetValue(ulonglong lval, int n) {assert(false);} - virtual void SetValue(double fval, int n) {assert(false);} - virtual void SetValue(char cval, int n) {assert(false);} - virtual void SetValue(uchar cval, int n) {assert(false);} - virtual void SetValue(PSZ sp, int n) {assert(false);} - virtual void SetValue(char *sp, uint len, int n) {assert(false);} + virtual void SetValue(short, int) {assert(false);} + virtual void SetValue(ushort, int) {assert(false);} + virtual void SetValue(int, int) {assert(false);} + virtual void SetValue(uint, int) {assert(false);} + virtual void SetValue(longlong, int) {assert(false);} + virtual void SetValue(ulonglong, int) {assert(false);} + virtual void SetValue(double, int) {assert(false);} + virtual void SetValue(char, int) {assert(false);} + virtual void SetValue(uchar, int) {assert(false);} + virtual void SetValue(PSZ, int) {assert(false);} + virtual void SetValue(char *, uint, int) {assert(false);} virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVBLK pv, int n1, int n2) = 0; virtual void SetMin(PVAL valp, int n) = 0; @@ -271,7 +271,7 @@ class STRBLK : public VALBLK { // Implementation virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}} virtual bool IsNull(int n) {return Strp[n] == NULL;} - virtual void SetNullable(bool b) {} // Always nullable + virtual void SetNullable(bool) {} // Always nullable virtual bool Init(PGLOBAL g, bool check); virtual int GetVlen(void) {return sizeof(PSZ);} virtual PSZ GetCharValue(int n) {return Strp[n];} @@ -284,7 +284,7 @@ class STRBLK : public VALBLK { virtual longlong GetBigintValue(int n); virtual ulonglong GetUBigintValue(int n); virtual double GetFloatValue(int n) {return atof(Strp[n]);} - virtual char *GetCharString(char *p, int n) {return Strp[n];} + virtual char *GetCharString(char *, int n) {return Strp[n];} virtual void Reset(int n) {Strp[n] = NULL;} // Methods diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index d14fc367cc7..03ec0eb8e40 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -30,11 +30,11 @@ #include "sql_class.h" #include "sql_time.h" -#if defined(WIN32) +#if defined(__WIN__) //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #include <string.h> -#endif // !WIN32 +#endif // !__WIN__ #include <math.h> @@ -77,12 +77,12 @@ int DTVAL::Shift = 0; /***********************************************************************/ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); -#if !defined(WIN32) +#if !defined(__WIN__) extern "C" { PSZ strupr(PSZ s); PSZ strlwr(PSZ s); } -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Get a long long number from its character representation. */ @@ -475,7 +475,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns) break; case TYPE_DATE: - vp = new(g) DTVAL(g, valp->GetIntValue()); + vp = new(g) DTVAL(valp->GetIntValue()); break; case TYPE_DOUBLE: vp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE, @@ -551,7 +551,7 @@ BYTE VALUE::TestValue(PVAL vp) /***********************************************************************/ /* Compute a function on a string. */ /***********************************************************************/ -bool VALUE::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) +bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL) { strcpy(g->Message, "Compute not implemented for this value type"); return true; @@ -976,7 +976,7 @@ ulonglong TYPVAL<ulonglong>::MinMaxVal(bool b) {return (b) ? 0xFFFFFFFFFFFFFFFFLL : 0;} template <> -double TYPVAL<double>::MinMaxVal(bool b) +double TYPVAL<double>::MinMaxVal(bool) {assert(false); return 0.0;} template <> @@ -1566,7 +1566,7 @@ bool TYPVAL<PSZ>::GetBinValue(void *buf, int buflen, bool go) /***********************************************************************/ /* STRING ShowValue: get string representation of a char value. */ /***********************************************************************/ -char *TYPVAL<PSZ>::ShowValue(char *buf, int len) +char *TYPVAL<PSZ>::ShowValue(char *, int) { return Strp; } // end of ShowValue @@ -1574,7 +1574,7 @@ char *TYPVAL<PSZ>::ShowValue(char *buf, int len) /***********************************************************************/ /* STRING GetCharString: get string representation of a char value. */ /***********************************************************************/ -char *TYPVAL<PSZ>::GetCharString(char *p) +char *TYPVAL<PSZ>::GetCharString(char *) { return Strp; } // end of GetCharString @@ -1618,10 +1618,10 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp) else n = strcmp(Strp, vp->GetCharValue()); -#if defined(WIN32) +#if defined(__WIN__) if (n == _NLSCMPERROR) return n; // Here we should raise an error -#endif // WIN32 +#endif // __WIN__ return (n > 0) ? 1 : (n < 0) ? -1 : 0; } // end of CompareValue @@ -1681,7 +1681,7 @@ bool TYPVAL<PSZ>::FormatValue(PVAL vp, char *fmt) /***********************************************************************/ /* STRING SetFormat function (used to set SELECT output format). */ /***********************************************************************/ -bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL g, FORMAT& fmt) +bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt) { fmt.Type[0] = 'C'; fmt.Length = Len; @@ -2300,7 +2300,7 @@ char *BINVAL::ShowValue(char *buf, int len) /***********************************************************************/ /* BINVAL GetCharString: get string representation of a binary value. */ /***********************************************************************/ -char *BINVAL::GetCharString(char *p) +char *BINVAL::GetCharString(char *) { if (!Chrp) Chrp = (char*)PlugSubAlloc(Global, NULL, Clen * 2 + 1); @@ -2349,7 +2349,7 @@ bool BINVAL::FormatValue(PVAL vp, char *fmt) /***********************************************************************/ /* BINVAL SetFormat function (used to set SELECT output format). */ /***********************************************************************/ -bool BINVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt) +bool BINVAL::SetConstFormat(PGLOBAL, FORMAT& fmt) { fmt.Type[0] = 'B'; fmt.Length = Clen; @@ -2379,7 +2379,7 @@ DTVAL::DTVAL(PGLOBAL g, int n, int prec, PSZ fmt) /***********************************************************************/ /* DTVAL public constructor from int. */ /***********************************************************************/ -DTVAL::DTVAL(PGLOBAL g, int n) : TYPVAL<int>(n, TYPE_DATE) +DTVAL::DTVAL(int n) : TYPVAL<int>(n, TYPE_DATE) { Pdtp = NULL; Len = 19; diff --git a/storage/connect/value.h b/storage/connect/value.h index c5aeb5c2a2f..780917c9962 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -36,8 +36,9 @@ typedef struct _datpar *PDTP; // For DTVAL DllExport PSZ GetTypeName(int); DllExport int GetTypeSize(int, int); #ifdef ODBC_SUPPORT -/* This function is exported for use in EOM table type DLLs */ -DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); +/* This function is exported for use in OEM table type DLLs */ +DllExport int TranslateSQLType(int stp, int prec, + int& len, char& v, bool& w); #endif DllExport char *GetFormatType(int); DllExport int GetFormatType(char); @@ -94,18 +95,18 @@ class DllExport VALUE : public BLOCK { virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual bool SetValue_char(char *p, int n) = 0; virtual void SetValue_psz(PSZ s) = 0; - virtual void SetValue_bool(bool b) {assert(FALSE);} + virtual void SetValue_bool(bool) {assert(FALSE);} virtual int CompareValue(PVAL vp) = 0; virtual BYTE TestValue(PVAL vp); - virtual void SetValue(char c) {assert(false);} - virtual void SetValue(uchar c) {assert(false);} - virtual void SetValue(short i) {assert(false);} - virtual void SetValue(ushort i) {assert(false);} - virtual void SetValue(int n) {assert(false);} - virtual void SetValue(uint n) {assert(false);} - virtual void SetValue(longlong n) {assert(false);} - virtual void SetValue(ulonglong n) {assert(false);} - virtual void SetValue(double f) {assert(false);} + virtual void SetValue(char) {assert(false);} + virtual void SetValue(uchar) {assert(false);} + virtual void SetValue(short) {assert(false);} + virtual void SetValue(ushort) {assert(false);} + virtual void SetValue(int) {assert(false);} + virtual void SetValue(uint) {assert(false);} + virtual void SetValue(longlong) {assert(false);} + virtual void SetValue(ulonglong) {assert(false);} + virtual void SetValue(double) {assert(false);} virtual void SetValue_pvblk(PVBLK blk, int n) = 0; virtual void SetBinValue(void *p) = 0; virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; @@ -338,7 +339,7 @@ class DllExport BINVAL: public VALUE { virtual void SetValue(double f); virtual void SetBinValue(void *p); virtual bool GetBinValue(void *buf, int buflen, bool go); - virtual int CompareValue(PVAL vp) {assert(false); return 0;} + virtual int CompareValue(PVAL) {assert(false); return 0;} virtual char *ShowValue(char *buf, int); virtual char *GetCharString(char *p); virtual bool IsEqual(PVAL vp, bool chktype); @@ -359,14 +360,9 @@ class DllExport DTVAL : public TYPVAL<int> { public: // Constructors DTVAL(PGLOBAL g, int n, int p, PSZ fmt); - DTVAL(PGLOBAL g, PSZ s, int n); - DTVAL(PGLOBAL g, short i); - DTVAL(PGLOBAL g, int n); - DTVAL(PGLOBAL g, longlong n); - DTVAL(PGLOBAL g, double f); + DTVAL(int n); // Implementation - virtual bool IsZero(void) {return Null;} virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_char(char *p, int n); virtual void SetValue_psz(PSZ s); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 024a9c081cd..a2d75cec8ab 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -1,7 +1,7 @@ /***************** Xindex C++ Class Xindex Code (.CPP) *****************/ /* Name: XINDEX.CPP Version 2.9 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* This file contains the class XINDEX implementation code. */ /***********************************************************************/ @@ -10,12 +10,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(WIN32) +#if defined(__WIN__) #include <io.h> #include <fcntl.h> #include <errno.h> //#include <windows.h> -#else // !WIN32 +#else // !__WIN__ #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !WIN32 +#endif // !__WIN__ /***********************************************************************/ /* Include required application header files */ @@ -179,7 +179,7 @@ XXBASE::XXBASE(PTDBDOS tbxp, bool b) : CSORT(b), /***********************************************************************/ /* Make file output of XINDEX contents. */ /***********************************************************************/ -void XXBASE::Print(PGLOBAL g, FILE *f, uint n) +void XXBASE::Print(PGLOBAL, FILE *f, uint n) { char m[64]; @@ -191,7 +191,7 @@ void XXBASE::Print(PGLOBAL g, FILE *f, uint n) /***********************************************************************/ /* Make string output of XINDEX contents. */ /***********************************************************************/ -void XXBASE::Print(PGLOBAL g, char *ps, uint z) +void XXBASE::Print(PGLOBAL, char *ps, uint z) { *ps = '\0'; strncat(ps, "Xindex", z); @@ -287,7 +287,7 @@ int XINDEX::Qcompare(int *i1, int *i2) /* Sure enough, it is done while records are read and permit to avoid */ /* reading the table while doing the join (Dynamic index only) */ /***********************************************************************/ -bool XINDEX::AddColumns(PIXDEF xdp) +bool XINDEX::AddColumns(void) { if (!Dynamic) return false; // Not applying to static index @@ -340,6 +340,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } // endif n + if (trace) + htrc("XINDEX Make: n=%d\n", n); + // File position must be stored Record.Size = n * sizeof(int); @@ -377,7 +380,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) To_LastCol = prev; - if (AddColumns(sxp)) { + if (AddColumns()) { PCOL kolp = To_Cols[0]; // Temporary while imposing Nk = 1 i = 0; @@ -477,6 +480,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } else To_Rec[nkey] = Tdbp->GetRecpos(); + if (trace > 1) + htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]); + /*******************************************************************/ /* Get the keys and place them in the key blocks. */ /*******************************************************************/ @@ -733,7 +739,7 @@ int XINDEX::ColMaxSame(PXCOL kp) /* Reorder: use the sort index to reorder the data in storage so */ /* it will be physically sorted and sort index can be removed. */ /***********************************************************************/ -bool XINDEX::Reorder(PGLOBAL g) +bool XINDEX::Reorder(PGLOBAL g __attribute__((unused))) { register int i, j, k, n; bool sorted = true; @@ -835,7 +841,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) if ((sep = defp->GetBoolCatInfo("SepIndex", false))) { // Index is saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -988,7 +994,7 @@ bool XINDEX::Init(PGLOBAL g) if (defp->SepIndex()) { // Index was saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1241,7 +1247,7 @@ bool XINDEX::MapInit(PGLOBAL g) if (defp->SepIndex()) { // Index was save in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1454,7 +1460,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) if (defp->SepIndex()) { // Index was saved in a separate file -#if !defined(UNIX) +#if defined(__WIN__) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1585,7 +1591,7 @@ int XINDEX::Range(PGLOBAL g, int limit, bool incl) if (++i == Nval) break; } // endfor kp - if ((k = FastFind(Nval)) < Num_K) + if ((k = FastFind()) < Num_K) n = k; // if (limit) // n = (Mul) ? k : kp->Val_K; @@ -1759,6 +1765,9 @@ int XINDEX::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDEX Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -1776,9 +1785,6 @@ int XINDEX::Fetch(PGLOBAL g) break; case OP_SAME: // Read next same // Logically the key values should be the same as before - if (trace > 1) - htrc("looking for next same value\n"); - if (NextVal(true)) { Op = OP_EQ; return -2; // no more equal values @@ -1824,9 +1830,9 @@ int XINDEX::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); - Cur_K = FastFind(Nval); + Cur_K = FastFind(); if (Cur_K >= Num_K) /*************************************************************/ @@ -1857,12 +1863,12 @@ int XINDEX::Fetch(PGLOBAL g) /* FastFind: Returns the index of matching record in a join using an */ /* optimized algorithm based on dichotomie and optimized comparing. */ /***********************************************************************/ -int XINDEX::FastFind(int nv) +int XINDEX::FastFind(void) { register int curk, sup, inf, i= 0, k, n = 2; register PXCOL kp, kcp; - assert((int)nv == Nval); +//assert((int)nv == Nval); if (Nblk && Op == OP_EQ) { // Look in block values to find in which block to search @@ -1896,6 +1902,10 @@ int XINDEX::FastFind(int nv) sup = To_KeyCol->Ndf; } // endif Nblk + if (trace > 2) + htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) { while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -1970,6 +1980,9 @@ int XINDEX::FastFind(int nv) curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K; } // endfor kcp + if (trace > 2) + htrc("XINDEX FastFind: curk=%d\n", curk); + return curk; } // end of FastFind @@ -2018,7 +2031,7 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl) /*********************************************************************/ if (xp->GetType() == TYPE_CONST) { kp->Valp->SetValue_pval(xp->GetValue(), !kp->Prefix); - k = FastFind(Nval); + k = FastFind(); if (k < Num_K || Op != OP_EQ) if (limit) @@ -2043,8 +2056,7 @@ int XINDXS::GroupSize(void) #if defined(_DEBUG) assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif); #endif // _DEBUG - return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] - : 1; + return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] : 1; } // end of GroupSize /***********************************************************************/ @@ -2106,6 +2118,9 @@ int XINDXS::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDXS Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -2120,9 +2135,6 @@ int XINDXS::Fetch(PGLOBAL g) Op = OP_NEXT; break; case OP_SAME: // Read next same - if (trace > 1) - htrc("looking for next same value\n"); - if (!Mul || NextVal(true)) { Op = OP_EQ; return -2; // No more equal values @@ -2160,9 +2172,9 @@ int XINDXS::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); - Cur_K = FastFind(1); + Cur_K = FastFind(); if (Cur_K >= Num_K) // Rank not whithin index table, signal record not found @@ -2190,9 +2202,9 @@ int XINDXS::Fetch(PGLOBAL g) /* FastFind: Returns the index of matching indexed record using an */ /* optimized algorithm based on dichotomie and optimized comparing. */ /***********************************************************************/ -int XINDXS::FastFind(int nk) +int XINDXS::FastFind(void) { - register int sup, inf, i= 0, n = 2; + register int sup, inf, i= 0, n = 2; register PXCOL kcp = To_KeyCol; if (Nblk && Op == OP_EQ) { @@ -2215,7 +2227,6 @@ int XINDXS::FastFind(int nk) if (inf < 0) return Num_K; -// i = inf; inf *= Sblk; if ((sup = inf + Sblk) > Ndif) @@ -2227,6 +2238,10 @@ int XINDXS::FastFind(int nk) sup = Ndif; } // endif Nblk + if (trace > 2) + htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -2249,6 +2264,9 @@ int XINDXS::FastFind(int nk) n = 0; } // endif sup + if (trace > 2) + htrc("XINDXS FastFind: n=%d i=%d\n", n, i); + // Loop on kcp because of dynamic indexing for (; kcp; kcp = kcp->Next) kcp->Val_K = i; // Used by FillValue @@ -2330,6 +2348,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } else if (mode == MODE_WRITE) { if (id >= 0) { // New not sep index file. Write the header. @@ -2337,6 +2359,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) Write(g, noff, sizeof(IOFF), MAX_INDX, rc); fseek(Xfile, 0, SEEK_END); NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } // endif id } else if (mode == MODE_READ && id >= 0) { @@ -2346,6 +2372,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif MAX_INDX + if (trace) + htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low); + // Position the cursor at the offset of this index if (fseek(Xfile, noff[id].Low, SEEK_SET)) { sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); @@ -2360,7 +2389,8 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) /***********************************************************************/ /* Move into an index file. */ /***********************************************************************/ -bool XFILE::Seek(PGLOBAL g, int low, int high, int origin) +bool XFILE::Seek(PGLOBAL g, int low, int high __attribute__((unused)), + int origin) { #if defined(_DEBUG) assert(high == 0); @@ -2371,7 +2401,6 @@ bool XFILE::Seek(PGLOBAL g, int low, int high, int origin) return true; } // endif -//ftell(Xfile); return false; } // end of Seek @@ -2479,7 +2508,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) if (trace) htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode); -#if defined(WIN32) +#if defined(__WIN__) LONG high = 0; DWORD rc, drc, access, share, creation; @@ -2655,7 +2684,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) /***********************************************************************/ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin) { -#if defined(WIN32) +#if defined(__WIN__) LONG hi = high; DWORD rc = SetFilePointer(Hfile, low, &hi, origin); @@ -2691,7 +2720,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) { bool rc = false; -#if defined(WIN32) +#if defined(__WIN__) bool brc; DWORD nbr, count = (DWORD)(n * size); @@ -2737,7 +2766,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) /***********************************************************************/ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) { -#if defined(WIN32) +#if defined(__WIN__) bool brc; DWORD nbw, count = (DWORD)n * (DWORD) size; @@ -2779,7 +2808,7 @@ void XHUGE::Close(char *fn, int id) if (trace) htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val); -#if defined(WIN32) +#if defined(__WIN__) if (id >= 0 && fn) { CloseFileHandle(Hfile); Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL, @@ -2794,7 +2823,7 @@ void XHUGE::Close(char *fn, int id) } // endif SetFilePointer } // endif id -#else // !WIN32 +#else // !__WIN__ if (id >= 0 && fn) { if (Hfile != INVALID_HANDLE_VALUE) { if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) { @@ -2810,7 +2839,7 @@ void XHUGE::Close(char *fn, int id) htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno)); } // endif id -#endif // !WIN32 +#endif // !__WIN__ XLOAD::Close(); } // end of Close @@ -2819,7 +2848,7 @@ void XHUGE::Close(char *fn, int id) /***********************************************************************/ /* Don't know whether this is possible for huge files. */ /***********************************************************************/ -void *XHUGE::FileView(PGLOBAL g, char *fn) +void *XHUGE::FileView(PGLOBAL g, char *) { strcpy(g->Message, MSG(NO_PART_MAP)); return NULL; @@ -2879,7 +2908,7 @@ bool XXROW::Init(PGLOBAL g) /***********************************************************************/ /* RANGE: Tell how many record exist in a given value range. */ /***********************************************************************/ -int XXROW::Range(PGLOBAL g, int limit, bool incl) +int XXROW::Range(PGLOBAL, int limit, bool incl) { int n = Valp->GetIntValue(); @@ -2895,7 +2924,7 @@ int XXROW::Range(PGLOBAL g, int limit, bool incl) /***********************************************************************/ /* XXROW: Fetch a physical or logical record. */ /***********************************************************************/ -int XXROW::Fetch(PGLOBAL g) +int XXROW::Fetch(PGLOBAL) { if (Num_K == 0) return -1; // means end of file @@ -2904,7 +2933,7 @@ int XXROW::Fetch(PGLOBAL g) /* Look for a key equal to the link column of previous table, */ /* and return its rank whithin the index table. */ /*********************************************************************/ - Cur_K = FastFind(1); + Cur_K = FastFind(); if (Cur_K >= Num_K) /*******************************************************************/ @@ -2926,7 +2955,7 @@ int XXROW::Fetch(PGLOBAL g) /***********************************************************************/ /* FastFind: Returns the index of matching record in a join. */ /***********************************************************************/ -int XXROW::FastFind(int nk) +int XXROW::FastFind(void) { int n = Valp->GetIntValue(); @@ -3158,12 +3187,18 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp) xp->Reset(); xp->Eval(g); Valp->SetValue_pval(xp->GetValue(), false); -// Valp->SetValue_pval(xp->GetValue(), !Prefix); } // endif Type + if (trace > 1) { + char buf[32]; + + htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf)); + } // endif trace + return false; } // end of InitFind +#if 0 /***********************************************************************/ /* InitBinFind: initialize Value to the value pointed by vp. */ /***********************************************************************/ @@ -3171,6 +3206,7 @@ void KXYCOL::InitBinFind(void *vp) { Valp->SetBinValue(vp); } // end of InitBinFind +#endif // 0 /***********************************************************************/ /* KXYCOL FillValue: called by COLBLK::Eval when a column value is */ diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index 6e40e9b160e..51b678992ea 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -1,7 +1,7 @@ /*************** Xindex H Declares Source Code File (.H) ***************/ /* Name: XINDEX.H Version 3.5 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2004 - 2013 */ +/* (C) Copyright to the author Olivier BERTRAND 2004 - 2015 */ /* */ /* This file contains the XINDEX class declares. */ /***********************************************************************/ @@ -65,7 +65,11 @@ typedef struct index_def : public BLOCK { typedef struct index_off { union { +#if defined(WORDS_BIGENDIAN) + struct {int High; int Low;}; +#else // !WORDS_BIGENDIAN struct {int Low; int High;}; +#endif //!WORDS_BIGENDIAN longlong Val; // File position }; // end of union } IOFF; @@ -205,12 +209,11 @@ class DllExport XXBASE : public CSORT, public BLOCK { #endif // XMAP virtual int MaxRange(void) {return 1;} virtual int Fetch(PGLOBAL g) = 0; - virtual bool NextVal(bool eq) {return true;} + virtual bool NextVal(bool) {return true;} virtual bool PrevVal(void) {return true;} - virtual int FastFind(int nk) = 0; - virtual bool Reorder(PGLOBAL g) {return true;} - virtual int Range(PGLOBAL g, int limit = 0, bool incl = true) - {return -1;} // Means error + virtual int FastFind(void) = 0; + virtual bool Reorder(PGLOBAL) {return true;} + virtual int Range(PGLOBAL, int = 0, bool = true) {return -1;} // Means error virtual int Qcompare(int *, int *) = 0; virtual int GroupSize(void) {return 1;} virtual void Close(void) = 0; @@ -266,7 +269,7 @@ class DllExport XINDEX : public XXBASE { #endif // XMAP virtual int Qcompare(int *, int *); virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual int GroupSize(void); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int MaxRange(void) {return MaxSame;} @@ -280,7 +283,7 @@ class DllExport XINDEX : public XXBASE { bool GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk); protected: - bool AddColumns(PIXDEF xdp); + bool AddColumns(void); bool NextValDif(void); // Members @@ -312,7 +315,7 @@ class DllExport XINDXS : public XINDEX { // Methods virtual int Qcompare(int *, int *); virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual bool NextVal(bool eq); virtual bool PrevVal(void); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); @@ -347,7 +350,7 @@ class DllExport XLOAD : public BLOCK { protected: // Members -#if defined(WIN32) +#if defined(__WIN__) HANDLE Hfile; // Handle to file or map #else // UNIX int Hfile; // Descriptor to file or map @@ -421,14 +424,14 @@ class DllExport XXROW : public XXBASE { // Methods virtual bool Init(PGLOBAL g); #if defined(XMAP) - virtual bool MapInit(PGLOBAL g) {return true;} + virtual bool MapInit(PGLOBAL) {return true;} #endif // XMAP virtual int Fetch(PGLOBAL g); - virtual int FastFind(int nk); + virtual int FastFind(void); virtual int MaxRange(void) {return 1;} virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int Qcompare(int *, int *) {assert(false); return 0;} - virtual bool Make(PGLOBAL g, PIXDEF sxp) {return false;} + virtual bool Make(PGLOBAL, PIXDEF) {return false;} virtual void Close(void) {} protected: @@ -463,7 +466,7 @@ class KXYCOL: public BLOCK { virtual void FreeData(void); virtual void FillValue(PVAL valp); virtual int CompVal(int i); - void InitBinFind(void *vp); +// void InitBinFind(void *vp); bool MakeBlockArray(PGLOBAL g, int nb, int size); int Compare(int i1, int i2); int CompBval(int i); diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp index 92bf039c07c..a6faebf3c2b 100644 --- a/storage/connect/xobject.cpp +++ b/storage/connect/xobject.cpp @@ -11,6 +11,7 @@ /* Include mariaDB header file. */ /***********************************************************************/ #include "my_global.h" +#include "m_string.h" /***********************************************************************/ /* Include required application header files */ diff --git a/storage/connect/xobject.h b/storage/connect/xobject.h index 8e2358dd526..82ff9e21225 100644 --- a/storage/connect/xobject.h +++ b/storage/connect/xobject.h @@ -42,9 +42,9 @@ class DllExport XOBJECT : public BLOCK { virtual int GetResultType(void) {return TYPE_VOID;} virtual int GetKey(void) {return 0;} #if defined(_DEBUG) - virtual void SetKey(int k) {assert(false);} + virtual void SetKey(int) {assert(false);} #else // !_DEBUG - virtual void SetKey(int k) {} // Only defined for COLBLK + virtual void SetKey(int) {} // Only defined for COLBLK #endif // !_DEBUG virtual int GetLength(void) = 0; virtual int GetLengthEx(void) = 0; diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h index d1ea2b0d85f..1a75d97bafa 100644 --- a/storage/connect/xtable.h +++ b/storage/connect/xtable.h @@ -77,21 +77,21 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block. virtual int GetTdb_No(void) {return Tdb_No;} virtual PTDB GetNext(void) {return Next;} virtual PCATLG GetCat(void) {return NULL;} - virtual void SetAbort(bool b) {;} + virtual void SetAbort(bool) {;} // Methods virtual bool IsSame(PTDB tp) {return tp == this;} virtual bool IsSpecial(PSZ name) = 0; - virtual bool GetBlockValues(PGLOBAL g) {return false;} - virtual int Cardinality(PGLOBAL g) {return 0;} + virtual bool GetBlockValues(PGLOBAL) {return false;} + virtual int Cardinality(PGLOBAL) {return 0;} virtual int GetMaxSize(PGLOBAL) = 0; virtual int GetProgMax(PGLOBAL) = 0; virtual int GetProgCur(void) = 0; virtual int RowNumber(PGLOBAL g, bool b = false); virtual bool IsReadOnly(void) {return true;} virtual const CHARSET_INFO *data_charset() {return NULL;} - virtual PTDB Duplicate(PGLOBAL g) {return NULL;} - virtual PTDB CopyOne(PTABS t) {return this;} + virtual PTDB Duplicate(PGLOBAL) {return NULL;} + virtual PTDB CopyOne(PTABS) {return this;} virtual PTDB Copy(PTABS t); virtual void PrintAM(FILE *f, char *m) {fprintf(f, "%s AM(%d)\n", m, GetAmType());} @@ -108,7 +108,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block. virtual int WriteDB(PGLOBAL) = 0; virtual int DeleteDB(PGLOBAL, int) = 0; virtual void CloseDB(PGLOBAL) = 0; - virtual int CheckWrite(PGLOBAL g) {return 0;} + virtual int CheckWrite(PGLOBAL) {return 0;} virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int) = 0; protected: @@ -155,7 +155,7 @@ class DllExport TDBASE : public TDB { PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;} // Methods - virtual bool IsUsingTemp(PGLOBAL g) {return false;} + virtual bool IsUsingTemp(PGLOBAL) {return false;} virtual bool IsIndexed(void) {return false;} virtual bool IsSpecial(PSZ name); virtual PCATLG GetCat(void); @@ -170,9 +170,9 @@ class DllExport TDBASE : public TDB { virtual CHARSET_INFO *data_charset(void); virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int GetProgCur(void) {return GetRecpos();} - virtual PSZ GetFile(PGLOBAL g) {return "Not a file";} + virtual PSZ GetFile(PGLOBAL) {return "Not a file";} virtual int GetRemote(void) {return 0;} - virtual void SetFile(PGLOBAL g, PSZ fn) {} + virtual void SetFile(PGLOBAL, PSZ) {} virtual void ResetDB(void) {} virtual void ResetSize(void) {MaxSize = -1;} virtual void RestoreNrec(void) {} @@ -183,12 +183,12 @@ class DllExport TDBASE : public TDB { virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int) {assert(false); return NULL;} - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); + virtual PCOL InsertSpecialColumn(PCOL colp); virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp); virtual void MarkDB(PGLOBAL g, PTDB tdb2); - virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) + virtual int MakeIndex(PGLOBAL g, PIXDEF, bool) {strcpy(g->Message, "Remote index"); return RC_INFO;} - virtual bool ReadKey(PGLOBAL g, OPVAL op, const void *key, int len) + virtual bool ReadKey(PGLOBAL, OPVAL, const void *, int) {assert(false); return true;} protected: @@ -225,7 +225,7 @@ class DllExport TDBCAT : public TDBASE { // Methods virtual int GetRecpos(void) {return N;} virtual int GetProgCur(void) {return N;} - virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} + virtual int RowNumber(PGLOBAL, bool = false) {return N + 1;} virtual bool SetRecpos(PGLOBAL g, int recpos); // Database routines diff --git a/storage/federatedx/README.windows b/storage/federatedx/README.windows index 3f1f2a3c79a..74de15c6521 100644 --- a/storage/federatedx/README.windows +++ b/storage/federatedx/README.windows @@ -1,23 +1,23 @@ -The following files are changed in order to build a new engine on Windows:
-
-- Update win\configure.js with
-case "WITH_FEDERATEDX_STORAGE_ENGINE":
-to make sure it will pass WITH_FEDERATEDX_STORAGE_ENGINE in.
-
-- Update CMakeFiles.txt under mysql root:
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- ADD_DEFINITIONS(-D WITH_FEDERATEDX_STORAGE_ENGINE)
- SET (mysql_plugin_defs
- "${mysql_plugin_defs},builtin_skeleton_plugin")
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
-
- and,
-
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- ADD_SUBDIRECTORY(storage/skeleton/src)
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
-
- - Update CMakeFiles.txt under sql:
- IF(WITH_FEDERATEDX_STORAGE_ENGINE)
- TARGET_LINK_LIBRARIES(mysqld skeleton)
- ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE)
+The following files are changed in order to build a new engine on Windows: + +- Update win\configure.js with +case "WITH_FEDERATEDX_STORAGE_ENGINE": +to make sure it will pass WITH_FEDERATEDX_STORAGE_ENGINE in. + +- Update CMakeFiles.txt under mysql root: + IF(WITH_FEDERATEDX_STORAGE_ENGINE) + ADD_DEFINITIONS(-D WITH_FEDERATEDX_STORAGE_ENGINE) + SET (mysql_plugin_defs + "${mysql_plugin_defs},builtin_skeleton_plugin") + ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE) + + and, + + IF(WITH_FEDERATEDX_STORAGE_ENGINE) + ADD_SUBDIRECTORY(storage/skeleton/src) + ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE) + + - Update CMakeFiles.txt under sql: + IF(WITH_FEDERATEDX_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqld skeleton) + ENDIF(WITH_FEDERATEDX_STORAGE_ENGINE) diff --git a/storage/innobase/api/api0api.cc b/storage/innobase/api/api0api.cc index 8769fc47166..0fe21423232 100644 --- a/storage/innobase/api/api0api.cc +++ b/storage/innobase/api/api0api.cc @@ -595,6 +595,21 @@ ib_trx_begin( return(static_cast<ib_trx_t>(trx)); } + +/*****************************************************************//** +Check if transaction is read_only +@return transaction read_only status */ +UNIV_INTERN +ib_u32_t +ib_trx_read_only( +/*=============*/ + ib_trx_t ib_trx) /*!< in: trx handle */ +{ + trx_t* trx = (trx_t*) ib_trx; + + return(trx->read_only); +} + /*****************************************************************//** Get the transaction's state. @return transaction state */ diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 287ad154d2f..12115fde7f4 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. @@ -495,6 +495,79 @@ buf_page_is_zeroes( return(true); } +/** Checks if the page is in crc32 checksum format. +@param[in] read_buf database page +@param[in] checksum_field1 new checksum field +@param[in] checksum_field2 old checksum field +@return true if the page is in crc32 checksum format */ +UNIV_INLINE +bool +buf_page_is_checksum_valid_crc32( + const byte* read_buf, + ulint checksum_field1, + ulint checksum_field2) +{ + ib_uint32_t crc32 = buf_calc_page_crc32(read_buf); + + return(checksum_field1 == crc32 && checksum_field2 == crc32); +} + +/** Checks if the page is in innodb checksum format. +@param[in] read_buf database page +@param[in] checksum_field1 new checksum field +@param[in] checksum_field2 old checksum field +@return true if the page is in innodb checksum format */ +UNIV_INLINE +bool +buf_page_is_checksum_valid_innodb( + const byte* read_buf, + ulint checksum_field1, + ulint checksum_field2) +{ + /* There are 2 valid formulas for + checksum_field2 (old checksum field) which algo=innodb could have + written to the page: + + 1. Very old versions of InnoDB only stored 8 byte lsn to the + start and the end of the page. + + 2. Newer InnoDB versions store the old formula checksum + (buf_calc_page_old_checksum()). */ + + if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN) + && checksum_field2 != buf_calc_page_old_checksum(read_buf)) { + return(false); + } + + /* old field is fine, check the new field */ + + /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id + (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */ + + if (checksum_field1 != 0 + && checksum_field1 != buf_calc_page_new_checksum(read_buf)) { + return(false); + } + + return(true); +} + +/** Checks if the page is in none checksum format. +@param[in] read_buf database page +@param[in] checksum_field1 new checksum field +@param[in] checksum_field2 old checksum field +@return true if the page is in none checksum format */ +UNIV_INLINE +bool +buf_page_is_checksum_valid_none( + const byte* read_buf, + ulint checksum_field1, + ulint checksum_field2) +{ + return(checksum_field1 == checksum_field2 + && checksum_field1 == BUF_NO_CHECKSUM_MAGIC); +} + /********************************************************************//** Checks if a page is corrupt. @return TRUE if corrupted */ @@ -511,8 +584,6 @@ buf_page_is_corrupted( ulint page_encrypted = fil_page_is_encrypted(read_buf); ulint checksum_field1; ulint checksum_field2; - ibool crc32_inited = FALSE; - ib_uint32_t crc32 = ULINT32_UNDEFINED; if (!page_encrypted && !zip_size && memcmp(read_buf + FIL_PAGE_LSN + 4, @@ -595,148 +666,121 @@ buf_page_is_corrupted( return(FALSE); } - switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - - crc32 = buf_calc_page_crc32(read_buf); - - return(checksum_field1 != crc32 || checksum_field2 != crc32); - - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - - return(checksum_field1 - != buf_calc_page_new_checksum(read_buf) - || checksum_field2 - != buf_calc_page_old_checksum(read_buf)); - - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); ); - return(checksum_field1 != BUF_NO_CHECKSUM_MAGIC - || checksum_field2 != BUF_NO_CHECKSUM_MAGIC); + ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET); + ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID); + const srv_checksum_algorithm_t curr_algo = + static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); + switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_INNODB: - /* There are 3 valid formulas for - checksum_field2 (old checksum field): - - 1. Very old versions of InnoDB only stored 8 byte lsn to the - start and the end of the page. - - 2. InnoDB versions before MySQL 5.6.3 store the old formula - checksum (buf_calc_page_old_checksum()). - - 3. InnoDB versions 5.6.3 and newer with - innodb_checksum_algorithm=strict_crc32|crc32 store CRC32. */ - - /* since innodb_checksum_algorithm is not strict_* allow - any of the algos to match for the old field */ - - if (checksum_field2 - != mach_read_from_4(read_buf + FIL_PAGE_LSN) - && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - - /* The checksum does not match any of the - fast to check. First check the selected algorithm - for writing checksums because we assume that the - chance of it matching is higher. */ - - if (srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_CRC32) { - - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = TRUE; - - if (checksum_field2 != crc32 - && checksum_field2 - != buf_calc_page_old_checksum(read_buf)) { + case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - return(TRUE); - } - } else { - ut_ad(srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_INNODB); + if (buf_page_is_checksum_valid_crc32(read_buf, + checksum_field1, checksum_field2)) { + return(FALSE); + } - if (checksum_field2 - != buf_calc_page_old_checksum(read_buf)) { + if (buf_page_is_checksum_valid_none(read_buf, + checksum_field1, checksum_field2)) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_NONE, + space_id, page_no); + } - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = TRUE; + return(FALSE); + } - if (checksum_field2 != crc32) { - return(TRUE); - } - } + if (buf_page_is_checksum_valid_innodb(read_buf, + checksum_field1, checksum_field2)) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_INNODB, + space_id, page_no); } - } - /* old field is fine, check the new field */ + return(FALSE); + } - /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id - (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */ + return(TRUE); - if (checksum_field1 != 0 - && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { + case SRV_CHECKSUM_ALGORITHM_INNODB: + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - /* The checksum does not match any of the - fast to check. First check the selected algorithm - for writing checksums because we assume that the - chance of it matching is higher. */ + if (buf_page_is_checksum_valid_innodb(read_buf, + checksum_field1, checksum_field2)) { + return(FALSE); + } - if (srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_CRC32) { + if (buf_page_is_checksum_valid_none(read_buf, + checksum_field1, checksum_field2)) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_NONE, + space_id, page_no); + } - if (!crc32_inited) { - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = TRUE; - } + return(FALSE); + } - if (checksum_field1 != crc32 - && checksum_field1 - != buf_calc_page_new_checksum(read_buf)) { + if (buf_page_is_checksum_valid_crc32(read_buf, + checksum_field1, checksum_field2)) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_CRC32, + space_id, page_no); + } - return(TRUE); - } - } else { - ut_ad(srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_INNODB); + return(FALSE); + } - if (checksum_field1 - != buf_calc_page_new_checksum(read_buf)) { + return(TRUE); - if (!crc32_inited) { - crc32 = buf_calc_page_crc32( - read_buf); - crc32_inited = TRUE; - } + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - if (checksum_field1 != crc32) { - return(TRUE); - } - } - } + if (buf_page_is_checksum_valid_none(read_buf, + checksum_field1, checksum_field2)) { + return(FALSE); } - /* If CRC32 is stored in at least one of the fields, then the - other field must also be CRC32 */ - if (crc32_inited - && ((checksum_field1 == crc32 - && checksum_field2 != crc32) - || (checksum_field1 != crc32 - && checksum_field2 == crc32))) { + if (buf_page_is_checksum_valid_crc32(read_buf, + checksum_field1, checksum_field2)) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_CRC32, + space_id, page_no); + return(FALSE); + } - return(TRUE); + if (buf_page_is_checksum_valid_innodb(read_buf, + checksum_field1, checksum_field2)) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_INNODB, + space_id, page_no); + return(FALSE); } - break; + return(TRUE); + case SRV_CHECKSUM_ALGORITHM_NONE: /* should have returned FALSE earlier */ - ut_error; + break; /* no default so the compiler will emit a warning if new enum is added and not handled here */ } - DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); ); - + ut_error; return(FALSE); } @@ -1823,6 +1867,9 @@ page_found: goto page_found; } + /* The maximum number of purge threads should never exceed + BUF_POOL_WATCH_SIZE. So there is no way for purge thread + instance to hold a watch when setting another watch. */ for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) { bpage = &buf_pool->watch[i]; diff --git a/storage/innobase/buf/buf0checksum.cc b/storage/innobase/buf/buf0checksum.cc index aa02cda2937..4101d117896 100644 --- a/storage/innobase/buf/buf0checksum.cc +++ b/storage/innobase/buf/buf0checksum.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -141,14 +141,17 @@ buf_checksum_algorithm_name( { switch (algo) { case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: return("crc32"); + case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: + return("strict_crc32"); case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: return("innodb"); + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + return("strict_innodb"); case SRV_CHECKSUM_ALGORITHM_NONE: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: return("none"); + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + return("strict_none"); } ut_error; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fe59d076358..b9b8ecd4916 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -544,7 +544,8 @@ ib_cb_t innodb_api_cb[] = { (ib_cb_t) ib_get_idx_field_name, (ib_cb_t) ib_trx_get_start_time, (ib_cb_t) ib_cfg_bk_commit_interval, - (ib_cb_t) ib_cursor_stmt_begin + (ib_cb_t) ib_cursor_stmt_begin, + (ib_cb_t) ib_trx_read_only }; @@ -9190,6 +9191,11 @@ ha_innobase::general_fetch( DBUG_ENTER("general_fetch"); + /* If transaction is not startted do not continue, instead return a error code. */ + if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) { + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + ut_a(prebuilt->trx == thd_to_trx(user_thd)); innobase_srv_conc_enter_innodb(prebuilt->trx); @@ -12606,6 +12612,13 @@ ha_innobase::estimate_rows_upper_bound() prebuilt->trx->op_info = ""; + /* Set num_rows less than MERGEBUFF to simulate the case where we do + not have enough space to merge the externally sorted file blocks. */ + DBUG_EXECUTE_IF("set_num_rows_lt_MERGEBUFF", + estimate = 2; + DBUG_SET("-d,set_num_rows_lt_MERGEBUFF"); + ); + DBUG_RETURN((ha_rows) estimate); } @@ -12871,7 +12884,6 @@ ha_innobase::info_low( dict_table_t* ib_table; ha_rows rec_per_key; ib_uint64_t n_rows; - char path[FN_REFLEN]; os_file_stat_t stat_info; DBUG_ENTER("info"); @@ -12929,17 +12941,6 @@ ha_innobase::info_low( "returning various info to MySQL"; } - my_snprintf(path, sizeof(path), "%s/%s%s", - mysql_data_home, ib_table->name, reg_ext); - - unpack_filename(path,path); - - /* Note that we do not know the access time of the table, - nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ - - if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) { - stats.create_time = (ulong) stat_info.ctime; - } } if (flag & HA_STATUS_VARIABLE) { @@ -13071,6 +13072,7 @@ ha_innobase::info_low( if (flag & HA_STATUS_CONST) { ulong i; + char path[FN_REFLEN]; /* Verify the number of index in InnoDB and MySQL matches up. If prebuilt->clust_index_was_generated holds, InnoDB defines GEN_CLUST_INDEX internally */ @@ -13224,6 +13226,20 @@ ha_innobase::info_low( if (!(flag & HA_STATUS_NO_LOCK)) { dict_table_stats_unlock(ib_table, RW_S_LATCH); } + + my_snprintf(path, sizeof(path), "%s/%s%s", + mysql_data_home, + table->s->normalized_path.str, + reg_ext); + + unpack_filename(path,path); + + /* Note that we do not know the access time of the table, + nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ + + if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) { + stats.create_time = (ulong) stat_info.ctime; + } } if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { diff --git a/storage/innobase/include/api0api.h b/storage/innobase/include/api0api.h index d77d691becc..e4c9c941de5 100644 --- a/storage/innobase/include/api0api.h +++ b/storage/innobase/include/api0api.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -494,6 +494,14 @@ ib_trx_state( /*=========*/ ib_trx_t ib_trx); /*!< in: trx handle */ + +/*****************************************************************//** +Check if the transaction is read_only */ +ib_u32_t +ib_trx_read_only( +/*=============*/ + ib_trx_t ib_trx); /*!< in: trx handle */ + /*****************************************************************//** Release the resources of the transaction. If the transaction was selected as a victim by InnoDB and rolled back then use this function diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index fe6b755dc59..04593f5b754 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -387,10 +387,10 @@ to original un-instrumented file I/O APIs */ enum os_file_type_t { OS_FILE_TYPE_UNKNOWN = 0, - OS_FILE_TYPE_FILE, /* regular file */ + OS_FILE_TYPE_FILE, /* regular file + (or a character/block device) */ OS_FILE_TYPE_DIR, /* directory */ - OS_FILE_TYPE_LINK, /* symbolic link */ - OS_FILE_TYPE_BLOCK /* block device */ + OS_FILE_TYPE_LINK /* symbolic link */ }; /* Maximum path string length in bytes when referring to tables with in the diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h index b16a99b51c0..feb64fb1e41 100644 --- a/storage/innobase/include/os0sync.h +++ b/storage/innobase/include/os0sync.h @@ -452,7 +452,7 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */ # define os_atomic_test_and_set_ulint(ptr, new_val) \ __sync_lock_test_and_set(ptr, new_val) -#ifdef __powerpc__ +#if defined(__powerpc__) || defined(__aarch64__) /* os_atomic_test_and_set_byte_release() should imply a release barrier before setting, and a full barrier after. But __sync_lock_test_and_set() is only diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 2b47aef8790..d83b6e1985d 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1123,6 +1123,20 @@ page_find_rec_with_heap_no( const rec_t* page_find_rec_max_not_deleted( const page_t* page); + +/** Issue a warning when the checksum that is stored in the page is valid, +but different than the global setting innodb_checksum_algorithm. +@param[in] current_algo current checksum algorithm +@param[in] page_checksum page valid checksum +@param[in] space_id tablespace id +@param[in] page_no page number */ +void +page_warn_strict_checksum( + srv_checksum_algorithm_t curr_algo, + srv_checksum_algorithm_t page_checksum, + ulint space_id, + ulint page_no); + #ifdef UNIV_MATERIALIZE #undef UNIV_INLINE #define UNIV_INLINE UNIV_INLINE_ORIGINAL diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 6fe6934e35c..0c2abef4b09 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -545,6 +545,21 @@ from outside the buffer pool. # define UNIV_INLINE UNIV_INLINE_ORIGINAL #endif +#ifdef UNIV_INNOCHECKSUM +/** Issue a warning when the checksum that is stored in the page is valid, +but different than the global setting innodb_checksum_algorithm. +@param[in] current_algo current checksum algorithm +@param[in] page_checksum page valid checksum +@param[in] space_id tablespace id +@param[in] page_no page number */ +void +page_warn_strict_checksum( + srv_checksum_algorithm_t curr_algo, + srv_checksum_algorithm_t page_checksum, + ulint space_id, + ulint page_no); +#endif /* UNIV_INNOCHECKSUM */ + #ifndef UNIV_INNOCHECKSUM #ifndef UNIV_NONINL # include "page0zip.ic" diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index f8dad7b3ced..4732ac48290 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 24 +#define INNODB_VERSION_BUGFIX 25 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index d844ebfccb3..80525a39d1e 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -3470,8 +3470,9 @@ os_file_get_status( stat_info->type = OS_FILE_TYPE_LINK; break; case S_IFBLK: - stat_info->type = OS_FILE_TYPE_BLOCK; - break; + /* Handle block device as regular file. */ + case S_IFCHR: + /* Handle character device as regular file. */ case S_IFREG: stat_info->type = OS_FILE_TYPE_FILE; break; @@ -3480,8 +3481,8 @@ os_file_get_status( } - if (check_rw_perm && (stat_info->type == OS_FILE_TYPE_FILE - || stat_info->type == OS_FILE_TYPE_BLOCK)) { + if (check_rw_perm && stat_info->type == OS_FILE_TYPE_FILE) { + int fh; int access; diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index 4aff88818bb..fca8641342c 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -2819,3 +2819,45 @@ page_find_rec_max_not_deleted( } return(prev_rec); } + +/** Issue a warning when the checksum that is stored in the page is valid, +but different than the global setting innodb_checksum_algorithm. +@param[in] current_algo current checksum algorithm +@param[in] page_checksum page valid checksum +@param[in] space_id tablespace id +@param[in] page_no page number */ +void +page_warn_strict_checksum( + srv_checksum_algorithm_t curr_algo, + srv_checksum_algorithm_t page_checksum, + ulint space_id, + ulint page_no) +{ + srv_checksum_algorithm_t curr_algo_nonstrict; + switch (curr_algo) { + case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: + curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32; + break; + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB; + break; + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE; + break; + default: + ut_error; + } + + ib_logf(IB_LOG_LEVEL_WARN, + "innodb_checksum_algorithm is set to \"%s\"" + " but the page [page id: space=" ULINTPF "," + " page number=" ULINTPF "] contains a valid checksum \"%s\"." + " Accepting the page as valid. Change innodb_checksum_algorithm" + " to \"%s\" to silently accept such pages or rewrite all pages" + " so that they contain \"%s\" checksum.", + buf_checksum_algorithm_name(curr_algo), + space_id, page_no, + buf_checksum_algorithm_name(page_checksum), + buf_checksum_algorithm_name(curr_algo_nonstrict), + buf_checksum_algorithm_name(curr_algo_nonstrict)); +} diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 0e36040ffe2..e8fd10912a7 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -47,6 +47,8 @@ using namespace std; #include "btr0cur.h" #include "page0types.h" #include "log0recv.h" +#else +#define page_warn_strict_checksum(A,B,C,D) #endif /* !UNIV_INNOCHECKSUM */ #include "zlib.h" #ifndef UNIV_HOTBACKUP @@ -4926,6 +4928,10 @@ page_zip_verify_checksum( stored = static_cast<ib_uint32_t>(mach_read_from_4( static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); + ulint page_no = mach_read_from_4(static_cast<const unsigned char*> (data) + FIL_PAGE_OFFSET); + ulint space_id = mach_read_from_4(static_cast<const unsigned char*> + (data) + FIL_PAGE_SPACE_ID); + #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -4951,40 +4957,113 @@ page_zip_verify_checksum( } #endif + const srv_checksum_algorithm_t curr_algo = + static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); + + if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { + return(TRUE); + } + calc = static_cast<ib_uint32_t>(page_zip_calc_checksum( - data, size, static_cast<srv_checksum_algorithm_t>( - srv_checksum_algorithm))); + data, size, curr_algo)); if (stored == calc) { return(TRUE); } - switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { + switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - return(stored == calc); case SRV_CHECKSUM_ALGORITHM_CRC32: + if (stored == BUF_NO_CHECKSUM_MAGIC) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_NONE, + space_id, page_no); + } + return(TRUE); } - crc32 = calc; + innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); + + if (stored == innodb) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_INNODB, + space_id, page_no); + } + + return(TRUE); + } + break; + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_INNODB: + if (stored == BUF_NO_CHECKSUM_MAGIC) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_NONE, + space_id, page_no); + } + + return(TRUE); + } + + crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); + + if (stored == crc32) { + if (curr_algo + == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_CRC32, + space_id, page_no); + } + return(TRUE); } + + break; + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); - innodb = calc; + + if (stored == crc32) { + page_warn_strict_checksum( + curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32, + space_id, page_no); + + return(TRUE); + } + + innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); + + if (stored == innodb) { + page_warn_strict_checksum( + curr_algo, + SRV_CHECKSUM_ALGORITHM_INNODB, + space_id, page_no); + return(TRUE); + } + break; case SRV_CHECKSUM_ALGORITHM_NONE: - return(TRUE); + ut_error; /* no default so the compiler will emit a warning if new enum is added and not handled here */ } - return(stored == crc32 || stored == innodb); + return(FALSE); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index b225669b0f7..cab7621a0d4 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1327,18 +1327,14 @@ row_insert_for_mysql( mem_analyze_corruption(prebuilt); ut_error; - } else if (srv_created_new_raw || srv_force_recovery) { - fputs("InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" + } else if (srv_force_recovery) { + fputs("InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: database modifications by the user. Shut down\n" "InnoDB: mysqld and edit my.cnf so that" - " newraw is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", + "InnoDB: innodb_force_... is removed.\n", stderr); - if(srv_force_recovery) { - return(DB_READ_ONLY); - } - return(DB_ERROR); + + return(DB_READ_ONLY); } trx->op_info = "inserting"; @@ -1729,18 +1725,14 @@ row_update_for_mysql( ut_error; } - if (UNIV_UNLIKELY(srv_created_new_raw || srv_force_recovery)) { - fputs("InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" + if (UNIV_UNLIKELY(srv_force_recovery)) { + fputs("InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw" - " is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", + "InnoDB: mysqld and edit my.cnf so that" + "InnoDB: innodb_force_... is removed.\n", stderr); - if(srv_force_recovery) { - return(DB_READ_ONLY); - } - return(DB_ERROR); + + return(DB_READ_ONLY); } DEBUG_SYNC_C("innodb_row_update_for_mysql_begin"); @@ -2239,22 +2231,6 @@ row_create_table_for_mysql( goto err_exit; ); - if (srv_created_new_raw) { - fputs("InnoDB: A new raw disk partition was initialized:\n" - "InnoDB: we do not allow database modifications" - " by the user.\n" - "InnoDB: Shut down mysqld and edit my.cnf so that newraw" - " is replaced with raw.\n", stderr); -err_exit: - dict_mem_table_free(table); - - if (commit) { - trx_commit_for_mysql(trx); - } - - return(DB_ERROR); - } - trx->op_info = "creating table"; if (row_mysql_is_system_table(table->name)) { @@ -2265,7 +2241,19 @@ err_exit: "InnoDB: MySQL system tables must be" " of the MyISAM type!\n", table->name); - goto err_exit; + +#ifndef DBUG_OFF +err_exit: +#endif /* !DBUG_OFF */ + dict_mem_table_free(table); + + if (commit) { + trx_commit_for_mysql(trx); + } + + trx->op_info = ""; + + return(DB_ERROR); } trx_start_if_not_started_xa(trx); @@ -3350,16 +3338,6 @@ row_truncate_table_for_mysql( ut_ad(table); - if (srv_created_new_raw) { - fputs("InnoDB: A new raw disk partition was initialized:\n" - "InnoDB: we do not allow database modifications" - " by the user.\n" - "InnoDB: Shut down mysqld and edit my.cnf so that newraw" - " is replaced with raw.\n", stderr); - - return(DB_ERROR); - } - if (dict_table_is_discarded(table)) { return(DB_TABLESPACE_DELETED); } else if (table->ibd_file_missing) { @@ -3839,16 +3817,6 @@ row_drop_table_for_mysql( ut_a(name != NULL); - if (srv_created_new_raw) { - fputs("InnoDB: A new raw disk partition was initialized:\n" - "InnoDB: we do not allow database modifications" - " by the user.\n" - "InnoDB: Shut down mysqld and edit my.cnf so that newraw" - " is replaced with raw.\n", stderr); - - DBUG_RETURN(DB_ERROR); - } - /* The table name is prefixed with the database name and a '/'. Certain table names starting with 'innodb_' have their special meaning regardless of the database name. Thus, we need to @@ -4866,19 +4834,16 @@ row_rename_table_for_mysql( ut_a(new_name != NULL); ut_ad(trx->state == TRX_STATE_ACTIVE); - if (srv_created_new_raw || srv_force_recovery) { - fputs("InnoDB: A new raw disk partition was initialized or\n" - "InnoDB: innodb_force_recovery is on: we do not allow\n" + if (srv_force_recovery) { + fputs("InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: database modifications by the user. Shut down\n" - "InnoDB: mysqld and edit my.cnf so that newraw" - " is replaced\n" - "InnoDB: with raw, and innodb_force_... is removed.\n", + "InnoDB: mysqld and edit my.cnf so that" + "InnoDB: innodb_force_... is removed.\n", stderr); - if(srv_force_recovery) { - err = DB_READ_ONLY; - } + err = DB_READ_ONLY; goto funct_exit; + } else if (row_mysql_is_system_table(new_name)) { fprintf(stderr, diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 03fd34827f5..648e9e95f19 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation @@ -244,8 +244,8 @@ srv_file_check_mode( /* Note: stat.rw_perm is only valid of files */ - if (stat.type == OS_FILE_TYPE_FILE - || stat.type == OS_FILE_TYPE_BLOCK) { + if (stat.type == OS_FILE_TYPE_FILE) { + if (!stat.rw_perm) { ib_logf(IB_LOG_LEVEL_ERROR, @@ -442,14 +442,16 @@ srv_parse_data_file_paths_and_sizes( && *(str + 1) == 'e' && *(str + 2) == 'w') { str += 3; + /* Initialize new raw device only during bootstrap */ (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW; } if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') { str += 3; + /* Initialize new raw device only during bootstrap */ if ((srv_data_file_is_raw_partition)[i] == 0) { - (srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW; + (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW; } } @@ -905,6 +907,24 @@ open_or_create_data_files( return(DB_ERROR); } + + const char* check_msg; + check_msg = fil_read_first_page( + files[i], FALSE, &flags, &space, +#ifdef UNIV_LOG_ARCHIVE + min_arch_log_no, max_arch_log_no, +#endif /* UNIV_LOG_ARCHIVE */ + min_flushed_lsn, max_flushed_lsn, NULL); + + /* If first page is valid, don't overwrite DB. + It prevents overwriting DB when mysql_install_db + starts mysqld multiple times during bootstrap. */ + if (check_msg == NULL) { + + srv_created_new_raw = FALSE; + ret = FALSE; + } + } else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) { srv_start_raw_disk_in_use = TRUE; @@ -3167,9 +3187,9 @@ innobase_shutdown_for_mysql(void) ibuf_close(); log_shutdown(); - lock_sys_close(); trx_sys_file_format_close(); trx_sys_close(); + lock_sys_close(); /* We don't create these mutexes in RO mode because we don't create the temp files that the cover. */ diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index aa0cdfee4c0..d464515a228 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. @@ -1119,8 +1119,8 @@ sync_array_print_info_low( os_thread_id_t r = 0; fprintf(file, - "OS WAIT ARRAY INFO: reservation count %ld\n", - (long) arr->res_count); + "OS WAIT ARRAY INFO: reservation count " ULINTPF "\n", + arr->res_count); for (i = 0; count < arr->n_reserved; ++i) { sync_cell_t* cell; @@ -1215,7 +1215,7 @@ sync_array_print( } fprintf(file, - "OS WAIT ARRAY INFO: signal count %ld\n", (long) sg_count); + "OS WAIT ARRAY INFO: signal count " ULINTPF "\n", sg_count); } diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 2c31af9442c..81df8062c54 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -1319,8 +1319,6 @@ trx_sys_close(void) /* Free the double write data structures. */ buf_dblwr_free(); - mutex_enter(&trx_sys->mutex); - ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0); /* Only prepared transactions may be left in the system. Free them. */ @@ -1360,8 +1358,6 @@ trx_sys_close(void) ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0); - mutex_exit(&trx_sys->mutex); - mutex_free(&trx_sys->mutex); mem_free(trx_sys); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 5410bb98190..7f3cfa22255 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -312,11 +312,10 @@ trx_free_prepared( /*==============*/ trx_t* trx) /*!< in, own: trx object */ { - ut_ad(mutex_own(&trx_sys->mutex)); - ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)); ut_a(trx->magic_n == TRX_MAGIC_N); + lock_trx_release_locks(trx); trx_undo_free_prepared(trx); assert_trx_in_rw_list(trx); diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 506ce2307a3..c031c7f2500 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -3117,10 +3117,8 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name) for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (! maria_is_key_active(share->state.key_map, key)) - continue; - - if (share->state.key_root[key] != HA_OFFSET_ERROR) + if (maria_is_key_active(share->state.key_map, key) && + share->state.key_root[key] != HA_OFFSET_ERROR) { index_pos[key]=param->new_file_pos; /* Write first block here */ if (sort_one_index(param,info,keyinfo,share->state.key_root[key], diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index 85a84f91ef0..f1ca174ed50 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -168,7 +168,7 @@ macro(check_build_flag flag) check_cxxflag(${flag}) endmacro() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX) check_build_flag("-Wall") check_build_flag("-Wextra") check_build_flag("-Wno-unused-but-set-variable") @@ -201,7 +201,7 @@ endif() option(GRN_WITH_DEBUG "enable debug build." OFF) if(GRN_WITH_DEBUG) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX) set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} -g3 -O0") set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} -g3 -O0") endif() diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index c38e7378015..9175f50fce7 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1936,16 +1936,8 @@ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name) for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (! mi_is_key_active(info->s->state.key_map, key)) - { - /* Since the key is not active, this should not be read, but we - initialize it anyway to silence a Valgrind warn when passing that - chunk of memory to pwrite(). */ - index_pos[key]= HA_OFFSET_ERROR; - continue; - } - - if (share->state.key_root[key] != HA_OFFSET_ERROR) + if (mi_is_key_active(info->s->state.key_map, key) && + share->state.key_root[key] != HA_OFFSET_ERROR) { index_pos[key]=param->new_file_pos; /* Write first block here */ if (sort_one_index(param,info,keyinfo,share->state.key_root[key], diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 9ab0bd99201..be61734e01c 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2010, Oracle and/or its affiliates + Copyright (c) 2002, 2015, Oracle and/or its affiliates This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -69,6 +69,10 @@ static double mbr_join_square(const double *a, const double *b, int n_dim) b += 2; }while (a != end); + /* Check for infinity or NaN */ + if (my_isinf(square) || isnan(square)) + square = DBL_MAX; + return square; } @@ -103,6 +107,9 @@ static void pick_seeds(SplitStruct *node, int n_entries, double max_d = -DBL_MAX; double d; + *seed_a = node; + *seed_b = node + 1; + for (cur1 = node; cur1 < lim1; ++cur1) { for (cur2=cur1 + 1; cur2 < lim2; ++cur2) diff --git a/storage/oqgraph/CMakeLists.txt b/storage/oqgraph/CMakeLists.txt index 2c09a27a581..1cb5c828d92 100644 --- a/storage/oqgraph/CMakeLists.txt +++ b/storage/oqgraph/CMakeLists.txt @@ -25,6 +25,7 @@ IF(MSVC) # ENDIF() ELSE() # See if that works. On old gcc it'll fail because of -fno-rtti +SET(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}") CHECK_CXX_SOURCE_COMPILES( " #define BOOST_NO_RTTI 1 diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 2e1393ec591..81592c85d0c 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -225,7 +225,7 @@ maria_declare_plugin(perfschema) 0x0001, pfs_status_vars, NULL, - "5.6.20", + "5.6.25", MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; diff --git a/storage/sphinx/mysql-test/sphinx/my.cnf b/storage/sphinx/mysql-test/sphinx/my.cnf index a3789a065bf..f60380b7171 100644 --- a/storage/sphinx/mysql-test/sphinx/my.cnf +++ b/storage/sphinx/mysql-test/sphinx/my.cnf @@ -16,7 +16,6 @@ mem_limit = 32M [searchd] read_timeout = 5 max_children = 30 -max_matches = 1000 seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1 @@ -24,7 +23,7 @@ log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-searchd.log query_log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-query.log #log-error = @ENV.MYSQLTEST_VARDIR/searchd/sphinx.log pid_file = @ENV.MYSQLTEST_VARDIR/run/searchd.pid -port = @ENV.SPHINXSEARCH_PORT +listen = @ENV.SPHINXSEARCH_PORT [ENV] SPHINXSEARCH_PORT = @OPT.port diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 08adb7355e4..a8a821e5ad6 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -25,8 +25,8 @@ IF (HAVE_WVLA) ENDIF() ############################################ -SET(TOKUDB_VERSION "tokudb-7.5.6") SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-10.1/README-TOKUDB\nusr/share/doc/mariadb-server-10.1/README.md" PARENT_SCOPE) +SET(TOKUDB_VERSION "tokudb-7.5.7") SET(USE_BDB OFF CACHE BOOL "") MARK_AS_ADVANCED(BUILDNAME) MARK_AS_ADVANCED(BUILD_TESTING) diff --git a/storage/tokudb/ft-index/buildheader/make_tdb.cc b/storage/tokudb/ft-index/buildheader/make_tdb.cc index 3f9a721d9aa..53706649231 100644 --- a/storage/tokudb/ft-index/buildheader/make_tdb.cc +++ b/storage/tokudb/ft-index/buildheader/make_tdb.cc @@ -587,6 +587,7 @@ static void print_db_txn_struct (void) { "uint64_t (*get_client_id)(DB_TXN *)", "bool (*is_prepared)(DB_TXN *)", "DB_TXN *(*get_child)(DB_TXN *)", + "uint64_t (*get_start_time)(DB_TXN *)", NULL}; sort_and_dump_fields("db_txn", false, extra); } @@ -786,7 +787,7 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) { printf("typedef void (*lock_timeout_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid);\n"); printf("typedef int (*iterate_row_locks_callback)(DB **db, DBT *left_key, DBT *right_key, void *extra);\n"); - printf("typedef int (*iterate_transactions_callback)(uint64_t txnid, uint64_t client_id, iterate_row_locks_callback cb, void *locks_extra, void *extra);\n"); + printf("typedef int (*iterate_transactions_callback)(DB_TXN *dbtxn, iterate_row_locks_callback cb, void *locks_extra, void *extra);\n"); printf("typedef int (*iterate_requests_callback)(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid, uint64_t start_time, void *extra);\n"); print_db_env_struct(); print_db_key_range_struct(); diff --git a/storage/tokudb/ft-index/ft/ft-verify.cc b/storage/tokudb/ft-index/ft/ft-verify.cc index d9606f37604..0a85136816f 100644 --- a/storage/tokudb/ft-index/ft/ft-verify.cc +++ b/storage/tokudb/ft-index/ft/ft-verify.cc @@ -160,10 +160,14 @@ get_ith_key_dbt (BASEMENTNODE bn, int i) { #define VERIFY_ASSERTION(predicate, i, string) ({ \ if(!(predicate)) { \ - (void) verbose; \ - if (true) { \ - fprintf(stderr, "%s:%d: Looking at child %d of block %" PRId64 ": %s\n", __FILE__, __LINE__, i, blocknum.b, string); \ - } \ + fprintf(stderr, "%s:%d: Looking at child %d of block %" PRId64 ": %s\n", __FILE__, __LINE__, i, blocknum.b, string); \ + result = TOKUDB_NEEDS_REPAIR; \ + if (!keep_going_on_failure) goto done; \ + }}) + +#define VERIFY_ASSERTION_BASEMENT(predicate, bn, entry, string) ({ \ + if(!(predicate)) { \ + fprintf(stderr, "%s:%d: Looking at block %" PRId64 " bn %d entry %d: %s\n", __FILE__, __LINE__, blocknum.b, bn, entry, string); \ result = TOKUDB_NEEDS_REPAIR; \ if (!keep_going_on_failure) goto done; \ }}) @@ -201,7 +205,6 @@ struct verify_message_tree_extra { int verify_message_tree(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) __attribute__((nonnull(3))); int verify_message_tree(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) { - int verbose = e->verbose; BLOCKNUM blocknum = e->blocknum; int keep_going_on_failure = e->keep_going_on_failure; int result = 0; @@ -236,7 +239,6 @@ int error_on_iter(const int32_t &UU(offset), const uint32_t UU(idx), void *UU(e) int verify_marked_messages(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) __attribute__((nonnull(3))); int verify_marked_messages(const int32_t &offset, const uint32_t UU(idx), struct verify_message_tree_extra *const e) { - int verbose = e->verbose; BLOCKNUM blocknum = e->blocknum; int keep_going_on_failure = e->keep_going_on_failure; int result = 0; @@ -462,16 +464,16 @@ toku_verify_ftnode_internal(FT_HANDLE ft_handle, DBT kdbt = get_ith_key_dbt(bn, j); if (curr_less_pivot) { int compare = compare_pairs(ft_handle, curr_less_pivot, &kdbt); - VERIFY_ASSERTION(compare < 0, j, "The leafentry is >= the lower-bound pivot"); + VERIFY_ASSERTION_BASEMENT(compare < 0, i, j, "The leafentry is >= the lower-bound pivot"); } if (curr_geq_pivot) { int compare = compare_pairs(ft_handle, curr_geq_pivot, &kdbt); - VERIFY_ASSERTION(compare >= 0, j, "The leafentry is < the upper-bound pivot"); + VERIFY_ASSERTION_BASEMENT(compare >= 0, i, j, "The leafentry is < the upper-bound pivot"); } if (0 < j) { DBT prev_key_dbt = get_ith_key_dbt(bn, j-1); int compare = compare_pairs(ft_handle, &prev_key_dbt, &kdbt); - VERIFY_ASSERTION(compare < 0, j, "Adjacent leafentries are out of order"); + VERIFY_ASSERTION_BASEMENT(compare < 0, i, j, "Adjacent leafentries are out of order"); } } } diff --git a/storage/tokudb/ft-index/ft/logger/recover.cc b/storage/tokudb/ft-index/ft/logger/recover.cc index cae7397651d..680485201da 100644 --- a/storage/tokudb/ft-index/ft/logger/recover.cc +++ b/storage/tokudb/ft-index/ft/logger/recover.cc @@ -111,7 +111,8 @@ int tokuft_recovery_trace = 0; // turn on recovery tracing, d #endif // time in seconds between recovery progress reports -#define TOKUDB_RECOVERY_PROGRESS_TIME 15 +#define TOKUFT_RECOVERY_PROGRESS_TIME 15 +time_t tokuft_recovery_progress_time = TOKUFT_RECOVERY_PROGRESS_TIME; enum ss { BACKWARD_NEWER_CHECKPOINT_END = 1, @@ -325,14 +326,12 @@ static int recover_env_init (RECOVER_ENV renv, } static void recover_env_cleanup (RECOVER_ENV renv) { - int r; - invariant_zero(renv->fmap.filenums->size()); file_map_destroy(&renv->fmap); if (renv->destroy_logger_at_end) { toku_logger_close_rollback(renv->logger); - r = toku_logger_close(&renv->logger); + int r = toku_logger_close(&renv->logger); assert(r == 0); } else { toku_logger_write_log_files(renv->logger, true); @@ -749,6 +748,36 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *UU(l), RECOVER_E return 0; } +struct toku_txn_progress_extra { + time_t tlast; + LSN lsn; + const char *type; + TXNID_PAIR xid; + uint64_t last_total; +}; + +static void toku_recover_txn_progress(TOKU_TXN_PROGRESS txn_progress, void *extra) { + toku_txn_progress_extra *txn_progress_extra = static_cast<toku_txn_progress_extra *>(extra); + if (txn_progress_extra->last_total == 0) + txn_progress_extra->last_total = txn_progress->entries_total; + else + assert(txn_progress_extra->last_total == txn_progress->entries_total); + time_t tnow = time(NULL); + if (tnow - txn_progress_extra->tlast >= tokuft_recovery_progress_time) { + txn_progress_extra->tlast = tnow; + fprintf(stderr, "%.24s TokuFT ", ctime(&tnow)); + if (txn_progress_extra->lsn.lsn != 0) + fprintf(stderr, "lsn %" PRIu64 " ", txn_progress_extra->lsn.lsn); + fprintf(stderr, "%s xid %" PRIu64 ":%" PRIu64 " ", + txn_progress_extra->type, txn_progress_extra->xid.parent_id64, txn_progress_extra->xid.child_id64); + fprintf(stderr, "%" PRIu64 "/%" PRIu64 " ", + txn_progress->entries_processed, txn_progress->entries_total); + if (txn_progress->entries_total > 0) + fprintf(stderr, "%.0f%% ", ((double) txn_progress->entries_processed / (double) txn_progress->entries_total) * 100.0); + fprintf(stderr, "\n"); + } +} + static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) { // find the transaction by transaction id TOKUTXN txn = NULL; @@ -756,8 +785,8 @@ static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) { assert(txn!=NULL); // commit the transaction - int r = toku_txn_commit_with_lsn(txn, true, l->lsn, - NULL, NULL); + toku_txn_progress_extra extra = { time(NULL), l->lsn, "commit", l->xid }; + int r = toku_txn_commit_with_lsn(txn, true, l->lsn, toku_recover_txn_progress, &extra); assert(r == 0); // close the transaction @@ -799,7 +828,8 @@ static int toku_recover_xabort (struct logtype_xabort *l, RECOVER_ENV renv) { assert(txn!=NULL); // abort the transaction - r = toku_txn_abort_with_lsn(txn, l->lsn, NULL, NULL); + toku_txn_progress_extra extra = { time(NULL), l->lsn, "abort", l->xid }; + r = toku_txn_abort_with_lsn(txn, l->lsn, toku_recover_txn_progress, &extra); assert(r == 0); // close the transaction @@ -1301,7 +1331,6 @@ static int is_txn_unprepared(TOKUTXN txn, void* extra) { return 0; } - static int find_an_unprepared_txn (RECOVER_ENV renv, TOKUTXN *txnp) { TOKUTXN txn = nullptr; int r = toku_txn_manager_iter_over_live_root_txns( @@ -1326,6 +1355,7 @@ static int call_prepare_txn_callback_iter(TOKUTXN txn, void* extra) { } static void recover_abort_live_txn(TOKUTXN txn) { + fprintf(stderr, "%s %" PRIu64 "\n", __FUNCTION__, txn->txnid.parent_id64); // recursively abort all children first if (txn->child != NULL) { recover_abort_live_txn(txn->child); @@ -1333,7 +1363,8 @@ static void recover_abort_live_txn(TOKUTXN txn) { // sanity check that the recursive call successfully NULLs out txn->child invariant(txn->child == NULL); // abort the transaction - int r = toku_txn_abort_txn(txn, NULL, NULL); + toku_txn_progress_extra extra = { time(NULL), ZERO_LSN, "abort live", txn->txnid }; + int r = toku_txn_abort_txn(txn, toku_recover_txn_progress, &extra); assert(r == 0); // close the transaction @@ -1451,9 +1482,10 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di // trace progress if ((i % 1000) == 0) { tnow = time(NULL); - if (tnow - tlast >= TOKUDB_RECOVERY_PROGRESS_TIME) { + if (tnow - tlast >= tokuft_recovery_progress_time) { thislsn = toku_log_entry_get_lsn(le); - fprintf(stderr, "%.24s TokuFT recovery scanning backward from %" PRIu64 " at %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, recover_state(renv)); + fprintf(stderr, "%.24s TokuFT recovery scanning backward from %" PRIu64 " at %" PRIu64 " (%s)\n", + ctime(&tnow), lastlsn.lsn, thislsn.lsn, recover_state(renv)); tlast = tnow; } } @@ -1482,16 +1514,18 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di assert(le); thislsn = toku_log_entry_get_lsn(le); tnow = time(NULL); - fprintf(stderr, "%.24s TokuFT recovery starts scanning forward to %" PRIu64 " from %" PRIu64 " left %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv)); + fprintf(stderr, "%.24s TokuFT recovery starts scanning forward to %" PRIu64 " from %" PRIu64 " left %" PRIu64 " (%s)\n", + ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv)); for (unsigned i=0; 1; i++) { // trace progress if ((i % 1000) == 0) { tnow = time(NULL); - if (tnow - tlast >= TOKUDB_RECOVERY_PROGRESS_TIME) { + if (tnow - tlast >= tokuft_recovery_progress_time) { thislsn = toku_log_entry_get_lsn(le); - fprintf(stderr, "%.24s TokuFT recovery scanning forward to %" PRIu64 " at %" PRIu64 " left %" PRIu64 " (%s)\n", ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv)); + fprintf(stderr, "%.24s TokuFT recovery scanning forward to %" PRIu64 " at %" PRIu64 " left %" PRIu64 " (%s)\n", + ctime(&tnow), lastlsn.lsn, thislsn.lsn, lastlsn.lsn - thislsn.lsn, recover_state(renv)); tlast = tnow; } } diff --git a/storage/tokudb/ft-index/ft/txn/txn.cc b/storage/tokudb/ft-index/ft/txn/txn.cc index 18d5a6b67dd..922c955a6b5 100644 --- a/storage/tokudb/ft-index/ft/txn/txn.cc +++ b/storage/tokudb/ft-index/ft/txn/txn.cc @@ -344,6 +344,7 @@ static txn_child_manager tcm; .state = TOKUTXN_LIVE, .num_pin = 0, .client_id = 0, + .start_time = time(NULL), }; TOKUTXN result = NULL; @@ -787,6 +788,10 @@ void toku_txn_set_client_id(TOKUTXN txn, uint64_t client_id) { txn->client_id = client_id; } +time_t toku_txn_get_start_time(struct tokutxn *txn) { + return txn->start_time; +} + int toku_txn_reads_txnid(TXNID txnid, TOKUTXN txn) { int r = 0; TXNID oldest_live_in_snapshot = toku_get_oldest_in_live_root_txn_list(txn); diff --git a/storage/tokudb/ft-index/ft/txn/txn.h b/storage/tokudb/ft-index/ft/txn/txn.h index 6381b5a7779..4f2778bf858 100644 --- a/storage/tokudb/ft-index/ft/txn/txn.h +++ b/storage/tokudb/ft-index/ft/txn/txn.h @@ -253,6 +253,7 @@ struct tokutxn { uint32_t num_pin; // number of threads (all hot indexes) that want this // txn to not transition to commit or abort uint64_t client_id; + time_t start_time; }; typedef struct tokutxn *TOKUTXN; @@ -368,6 +369,8 @@ bool toku_txn_has_spilled_rollback(struct tokutxn *txn); uint64_t toku_txn_get_client_id(struct tokutxn *txn); void toku_txn_set_client_id(struct tokutxn *txn, uint64_t client_id); +time_t toku_txn_get_start_time(struct tokutxn *txn); + // // This function is used by the leafentry iterators. // returns TOKUDB_ACCEPT if live transaction context is allowed to read a value diff --git a/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc b/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc index dd00ddeeb9a..c104c5c8541 100644 --- a/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc +++ b/storage/tokudb/ft-index/src/tests/test_iterate_live_transactions.cc @@ -104,9 +104,11 @@ struct iterate_extra { bool visited_txn[3]; }; -static int iterate_callback(uint64_t txnid, uint64_t client_id, +static int iterate_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { + uint64_t txnid = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); iterate_extra *info = reinterpret_cast<iterate_extra *>(extra); DB *db; DBT left_key, right_key; diff --git a/storage/tokudb/ft-index/src/tests/test_stress0.cc b/storage/tokudb/ft-index/src/tests/test_stress0.cc index 5dbca08db48..26192d851aa 100644 --- a/storage/tokudb/ft-index/src/tests/test_stress0.cc +++ b/storage/tokudb/ft-index/src/tests/test_stress0.cc @@ -140,9 +140,11 @@ static int UU() iterate_pending_lock_requests_op(DB_TXN *UU(txn), ARG arg, void return r; } -static int iterate_txns(uint64_t txnid, uint64_t client_id, +static int iterate_txns(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { + uint64_t txnid = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); invariant_null(extra); invariant(txnid > 0); invariant(client_id == 0); diff --git a/storage/tokudb/ft-index/src/ydb.cc b/storage/tokudb/ft-index/src/ydb.cc index 85445a67eef..ab15a44489e 100644 --- a/storage/tokudb/ft-index/src/ydb.cc +++ b/storage/tokudb/ft-index/src/ydb.cc @@ -2492,24 +2492,21 @@ struct iter_txns_callback_extra { }; static int iter_txns_callback(TOKUTXN txn, void *extra) { + int r = 0; iter_txns_callback_extra *info = reinterpret_cast<iter_txns_callback_extra *>(extra); - DB_TXN *dbtxn = toku_txn_get_container_db_txn(txn); invariant_notnull(dbtxn); + if (db_txn_struct_i(dbtxn)->tokutxn == txn) { // make sure that the dbtxn is fully initialized + toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex); + toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock); - toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex); - toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock); - - iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map); - const int r = info->callback(toku_txn_get_txnid(txn).parent_id64, - toku_txn_get_client_id(txn), - iter_txn_row_locks_callback, - &e, - info->extra); + iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map); + r = info->callback(dbtxn, iter_txn_row_locks_callback, &e, info->extra); - toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock); - toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex); + toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock); + toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex); + } return r; } diff --git a/storage/tokudb/ft-index/src/ydb_txn.cc b/storage/tokudb/ft-index/src/ydb_txn.cc index 82903849535..885c6b713b2 100644 --- a/storage/tokudb/ft-index/src/ydb_txn.cc +++ b/storage/tokudb/ft-index/src/ydb_txn.cc @@ -433,6 +433,11 @@ static DB_TXN *toku_txn_get_child(DB_TXN *txn) { return db_txn_struct_i(txn)->child; } +static uint64_t toku_txn_get_start_time(DB_TXN *txn) { + TOKUTXN ttxn = db_txn_struct_i(txn)->tokutxn; + return toku_txn_get_start_time(ttxn); +} + static inline void txn_func_init(DB_TXN *txn) { #define STXN(name) txn->name = locked_txn_ ## name STXN(abort); @@ -451,6 +456,7 @@ static inline void txn_func_init(DB_TXN *txn) { txn->id64 = toku_txn_id64; txn->is_prepared = toku_txn_is_prepared; txn->get_child = toku_txn_get_child; + txn->get_start_time = toku_txn_get_start_time; } // diff --git a/storage/tokudb/ft-index/tools/CMakeLists.txt b/storage/tokudb/ft-index/tools/CMakeLists.txt index 71c44df9acd..f745517d84e 100644 --- a/storage/tokudb/ft-index/tools/CMakeLists.txt +++ b/storage/tokudb/ft-index/tools/CMakeLists.txt @@ -1,6 +1,6 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPRECATE_ERRNO) -set(tools tokudb_dump tokuftdump tdb_logprint tdb-recover ftverify ba_replay) +set(tools tokudb_dump tokuftdump tokuft_logprint tdb-recover ftverify ba_replay) foreach(tool ${tools}) add_executable(${tool} ${tool}.cc) add_dependencies(${tool} install_tdb_h) @@ -12,9 +12,6 @@ endforeach(tool) # link in math.h library just for this tool. target_link_libraries(ftverify m) -install( - TARGETS tokuftdump - DESTINATION ${INSTALL_BINDIR} - COMPONENT Server - ) +install(TARGETS tokuftdump DESTINATION ${INSTALL_BINDIR} COMPONENT Server) +install(TARGETS tokuft_logprint DESTINATION ${INSTALL_BINDIR} COMPONENT Server) diff --git a/storage/tokudb/ft-index/tools/tdb_logprint.cc b/storage/tokudb/ft-index/tools/tokuft_logprint.cc index 15a28632cfb..1dd7581b9f5 100644 --- a/storage/tokudb/ft-index/tools/tdb_logprint.cc +++ b/storage/tokudb/ft-index/tools/tokuft_logprint.cc @@ -91,8 +91,6 @@ PATENT RIGHTS GRANT: /* Dump the log from stdin to stdout. */ -#include <config.h> - #include "ft/log_header.h" #include "ft/logger/logger.h" diff --git a/storage/tokudb/ft-index/tools/tokuftdump.cc b/storage/tokudb/ft-index/tools/tokuftdump.cc index d680a3dd0d0..14c3c31a061 100644 --- a/storage/tokudb/ft-index/tools/tokuftdump.cc +++ b/storage/tokudb/ft-index/tools/tokuftdump.cc @@ -250,6 +250,8 @@ static int64_t getRootNode(FT ft) { } static int print_le(const void* key, const uint32_t keylen, const LEAFENTRY &le, const uint32_t idx UU(), void *const ai UU()) { + unsigned int *le_index = (unsigned int *) ai; + printf("%u: ", *le_index); *le_index += 1; print_klpair(stdout, key, keylen, le); printf("\n"); return 0; @@ -539,7 +541,8 @@ ok: printf(" n_bytes_in_buffer= %" PRIu64 "", BLB_DATA(n, i)->get_disk_size()); printf(" items_in_buffer=%u\n", BLB_DATA(n, i)->num_klpairs()); if (do_dump_data) { - BLB_DATA(n, i)->iterate<void, print_le>(NULL); + unsigned int le_index = 0; + BLB_DATA(n, i)->iterate<void, print_le>(&le_index); } } } @@ -938,6 +941,7 @@ static void run_iteractive_loop(int fd, FT ft, CACHEFILE cf) { } else if (strcmp(fields[0], "header") == 0) { toku_ft_free(ft); open_header(fd, &ft, cf); + dump_header(ft); } else if (strcmp(fields[0], "rn") == 0||strcmp(fields[0], "rootNode")==0||strcmp(fields[0], "rootnode") == 0) { printf("Root node :%d\n",root); } else if (strcmp(fields[0], "block") == 0 && nfields == 2) { diff --git a/storage/tokudb/ft-index/util/scoped_malloc.cc b/storage/tokudb/ft-index/util/scoped_malloc.cc index 551bd944beb..15d4fb3e52e 100644 --- a/storage/tokudb/ft-index/util/scoped_malloc.cc +++ b/storage/tokudb/ft-index/util/scoped_malloc.cc @@ -145,6 +145,9 @@ namespace toku { } void destroy() { +#if TOKU_SCOPED_MALLOC_DEBUG + printf("%s %p %p\n", __FUNCTION__, this, m_stack); +#endif if (m_stack != NULL) { toku_free(m_stack); m_stack = NULL; @@ -167,13 +170,17 @@ namespace toku { static void destroy_and_deregister(void *key) { invariant_notnull(key); tl_stack *st = reinterpret_cast<tl_stack *>(key); - st->destroy(); + size_t n = 0; toku_mutex_lock(&global_stack_set_mutex); - invariant_notnull(global_stack_set); - size_t n = global_stack_set->erase(st); - invariant(n == 1); + if (global_stack_set) { + n = global_stack_set->erase(st); + } toku_mutex_unlock(&global_stack_set_mutex); + + if (n == 1) { + st->destroy(); // destroy the stack if this function erased it from the set. otherwise, somebody else destroyed it. + } } // Allocate 'size' bytes and return a pointer to the first byte @@ -244,6 +251,11 @@ void toku_scoped_malloc_init(void) { } void toku_scoped_malloc_destroy(void) { + toku_scoped_malloc_destroy_key(); + toku_scoped_malloc_destroy_set(); +} + +void toku_scoped_malloc_destroy_set(void) { toku_mutex_lock(&toku::global_stack_set_mutex); invariant_notnull(toku::global_stack_set); // Destroy any tl_stacks that were registered as thread locals but did not @@ -254,10 +266,11 @@ void toku_scoped_malloc_destroy(void) { (*i)->destroy(); } delete toku::global_stack_set; + toku::global_stack_set = nullptr; toku_mutex_unlock(&toku::global_stack_set_mutex); +} - // We're deregistering the destructor key here. When this thread exits, - // the tl_stack destructor won't get called, so we need to do that first. +void toku_scoped_malloc_destroy_key(void) { int r = pthread_key_delete(toku::tl_stack_destroy_pthread_key); invariant_zero(r); } diff --git a/storage/tokudb/ft-index/util/scoped_malloc.h b/storage/tokudb/ft-index/util/scoped_malloc.h index dbd919d155e..0233b0f1aa5 100644 --- a/storage/tokudb/ft-index/util/scoped_malloc.h +++ b/storage/tokudb/ft-index/util/scoped_malloc.h @@ -151,3 +151,7 @@ void toku_scoped_malloc_init(void); void toku_scoped_malloc_destroy(void); +void toku_scoped_malloc_destroy_set(void); + +void toku_scoped_malloc_destroy_key(void); + diff --git a/storage/tokudb/ft-index/util/tests/sm-basic.cc b/storage/tokudb/ft-index/util/tests/sm-basic.cc new file mode 100644 index 00000000000..5df64294721 --- /dev/null +++ b/storage/tokudb/ft-index/util/tests/sm-basic.cc @@ -0,0 +1,127 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/* +COPYING CONDITIONS NOTICE: + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation, and provided that the + following conditions are met: + + * Redistributions of source code must retain this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below). + + * Redistributions in binary form must reproduce this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below) in the documentation and/or other materials + provided with the distribution. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +COPYRIGHT NOTICE: + + TokuFT, Tokutek Fractal Tree Indexing Library. + Copyright (C) 2007-2013 Tokutek, Inc. + +DISCLAIMER: + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +UNIVERSITY PATENT NOTICE: + + The technology is licensed by the Massachusetts Institute of + Technology, Rutgers State University of New Jersey, and the Research + Foundation of State University of New York at Stony Brook under + United States of America Serial No. 11/760379 and to the patents + and/or patent applications resulting from it. + +PATENT MARKING NOTICE: + + This software is covered by US Patent No. 8,185,551. + This software is covered by US Patent No. 8,489,638. + +PATENT RIGHTS GRANT: + + "THIS IMPLEMENTATION" means the copyrightable works distributed by + Tokutek as part of the Fractal Tree project. + + "PATENT CLAIMS" means the claims of patents that are owned or + licensable by Tokutek, both currently or in the future; and that in + the absence of this license would be infringed by THIS + IMPLEMENTATION or by using or running THIS IMPLEMENTATION. + + "PATENT CHALLENGE" shall mean a challenge to the validity, + patentability, enforceability and/or non-infringement of any of the + PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. + + Tokutek hereby grants to you, for the term and geographical scope of + the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, + irrevocable (except as stated in this section) patent license to + make, have made, use, offer to sell, sell, import, transfer, and + otherwise run, modify, and propagate the contents of THIS + IMPLEMENTATION, where such license applies only to the PATENT + CLAIMS. This grant does not include claims that would be infringed + only as a consequence of further modifications of THIS + IMPLEMENTATION. If you or your agent or licensee institute or order + or agree to the institution of patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that + THIS IMPLEMENTATION constitutes direct or contributory patent + infringement, or inducement of patent infringement, then any rights + granted to you under this License shall terminate as of the date + such litigation is filed. If you or your agent or exclusive + licensee institute or order or agree to the institution of a PATENT + CHALLENGE, then Tokutek may terminate any rights granted to you + under this License. +*/ + +// test that basic scoped malloc works with a thread + +#ident "Copyright (c) 2015 Tokutek Inc. All rights reserved." +#include <toku_portability.h> +#include <toku_assert.h> +#include <toku_pthread.h> +#include <util/scoped_malloc.h> + +static void sm_test(void) { + toku::scoped_malloc a(1); + { + toku::scoped_malloc b(2); + { + toku::scoped_malloc c(3); + } + } +} + +static void *sm_test_f(void *arg) { + sm_test(); + return arg; +} + +int main(void) { + toku_scoped_malloc_init(); + + // run the test + toku_pthread_t tid; + int r; + r = toku_pthread_create(&tid, NULL, sm_test_f, NULL); + assert_zero(r); + void *ret; + r = toku_pthread_join(tid, &ret); + assert_zero(r); + + toku_scoped_malloc_destroy(); + + return 0; +} diff --git a/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc b/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc new file mode 100644 index 00000000000..653d4148fd0 --- /dev/null +++ b/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc @@ -0,0 +1,128 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/* +COPYING CONDITIONS NOTICE: + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation, and provided that the + following conditions are met: + + * Redistributions of source code must retain this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below). + + * Redistributions in binary form must reproduce this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below) in the documentation and/or other materials + provided with the distribution. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +COPYRIGHT NOTICE: + + TokuFT, Tokutek Fractal Tree Indexing Library. + Copyright (C) 2007-2013 Tokutek, Inc. + +DISCLAIMER: + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +UNIVERSITY PATENT NOTICE: + + The technology is licensed by the Massachusetts Institute of + Technology, Rutgers State University of New Jersey, and the Research + Foundation of State University of New York at Stony Brook under + United States of America Serial No. 11/760379 and to the patents + and/or patent applications resulting from it. + +PATENT MARKING NOTICE: + + This software is covered by US Patent No. 8,185,551. + This software is covered by US Patent No. 8,489,638. + +PATENT RIGHTS GRANT: + + "THIS IMPLEMENTATION" means the copyrightable works distributed by + Tokutek as part of the Fractal Tree project. + + "PATENT CLAIMS" means the claims of patents that are owned or + licensable by Tokutek, both currently or in the future; and that in + the absence of this license would be infringed by THIS + IMPLEMENTATION or by using or running THIS IMPLEMENTATION. + + "PATENT CHALLENGE" shall mean a challenge to the validity, + patentability, enforceability and/or non-infringement of any of the + PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. + + Tokutek hereby grants to you, for the term and geographical scope of + the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, + irrevocable (except as stated in this section) patent license to + make, have made, use, offer to sell, sell, import, transfer, and + otherwise run, modify, and propagate the contents of THIS + IMPLEMENTATION, where such license applies only to the PATENT + CLAIMS. This grant does not include claims that would be infringed + only as a consequence of further modifications of THIS + IMPLEMENTATION. If you or your agent or licensee institute or order + or agree to the institution of patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that + THIS IMPLEMENTATION constitutes direct or contributory patent + infringement, or inducement of patent infringement, then any rights + granted to you under this License shall terminate as of the date + such litigation is filed. If you or your agent or exclusive + licensee institute or order or agree to the institution of a PATENT + CHALLENGE, then Tokutek may terminate any rights granted to you + under this License. +*/ + +// force a race between the scoped malloc global destructor and a thread variable destructor + +#ident "Copyright (c) 2015 Tokutek Inc. All rights reserved." +#define TOKU_SCOPED_MALLOC_DEBUG 1 +#include <toku_portability.h> +#include <toku_assert.h> +#include <toku_pthread.h> +#include <toku_race_tools.h> +#include <util/scoped_malloc.h> + +volatile int state = 0; + +static void sm_test(void) { + toku::scoped_malloc a(1); +} + +static void *sm_test_f(void *arg) { + sm_test(); + state = 1; + while (state != 2) sleep(1); + return arg; +} + +int main(void) { + TOKU_VALGRIND_HG_DISABLE_CHECKING(&state, sizeof state); + state = 0; + toku_scoped_malloc_init(); + toku_pthread_t tid; + int r; + r = toku_pthread_create(&tid, NULL, sm_test_f, NULL); + assert_zero(r); + void *ret; + while (state != 1) sleep(1); + toku_scoped_malloc_destroy_set(); + state = 2; + r = toku_pthread_join(tid, &ret); + assert_zero(r); + toku_scoped_malloc_destroy_key(); + return 0; +} diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 2aa2dcbda93..6c514c6d94b 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -6203,6 +6203,12 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { if (error) { goto cleanup; } thd_set_ha_data(thd, tokudb_hton, trx); } + + if (tokudb_debug & TOKUDB_DEBUG_TXN) { + TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, + trx->tokudb_lock_count, trx->create_lock_count); + } + if (trx->all == NULL) { trx->sp_level = NULL; } @@ -6211,22 +6217,16 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { if (lock_type == F_WRLCK) { use_write_locks = true; } - if (!trx->tokudb_lock_count++) { - if (trx->stmt) { - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("stmt already set %p %p %p %p", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level); - } - } else { - assert(trx->stmt == 0); - transaction = NULL; // Safety - error = create_txn(thd, trx); - if (error) { - trx->tokudb_lock_count--; // We didn't get the lock - goto cleanup; - } + if (!trx->stmt) { + transaction = NULL; // Safety + error = create_txn(thd, trx); + if (error) { + goto cleanup; } + trx->create_lock_count = trx->tokudb_lock_count; } transaction = trx->sub_sp_level; + trx->tokudb_lock_count++; } else { tokudb_pthread_mutex_lock(&share->mutex); @@ -6241,21 +6241,24 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { added_rows = 0; deleted_rows = 0; share->rows_from_locked_table = 0; - if (trx->tokudb_lock_count > 0 && !--trx->tokudb_lock_count) { - if (trx->stmt) { - /* - F_UNLCK is done without a transaction commit / rollback. - This happens if the thread didn't update any rows - We must in this case commit the work to keep the row locks - */ - DBUG_PRINT("trans", ("commiting non-updating transaction")); - reset_stmt_progress(&trx->stmt_progress); - commit_txn(trx->stmt, 0); - trx->stmt = NULL; - trx->sub_sp_level = NULL; + if (trx->tokudb_lock_count > 0) { + if (--trx->tokudb_lock_count <= trx->create_lock_count) { + trx->create_lock_count = 0; + if (trx->stmt) { + /* + F_UNLCK is done without a transaction commit / rollback. + This happens if the thread didn't update any rows + We must in this case commit the work to keep the row locks + */ + DBUG_PRINT("trans", ("commiting non-updating transaction")); + reset_stmt_progress(&trx->stmt_progress); + commit_txn(trx->stmt, 0); + trx->stmt = NULL; + trx->sub_sp_level = NULL; + } } + transaction = NULL; } - transaction = NULL; } cleanup: if (tokudb_debug & TOKUDB_DEBUG_LOCK) @@ -6270,8 +6273,9 @@ cleanup: */ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { TOKUDB_HANDLER_DBUG_ENTER("cmd %d lock %d %s", thd_sql_command(thd), lock_type, share->table_name); - if (0) + if (tokudb_debug & TOKUDB_DEBUG_LOCK) { TOKUDB_HANDLER_TRACE("q %s", thd->query()); + } int error = 0; tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); @@ -6281,6 +6285,11 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { thd_set_ha_data(thd, tokudb_hton, trx); } + if (tokudb_debug & TOKUDB_DEBUG_TXN) { + TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, + trx->tokudb_lock_count, trx->create_lock_count); + } + /* note that trx->stmt may have been already initialized as start_stmt() is called for *each table* not for each storage engine, @@ -6291,9 +6300,7 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { if (error) { goto cleanup; } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("%p %p %p %p %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, trx->tokudb_lock_count); - } + trx->create_lock_count = trx->tokudb_lock_count; } else { if (tokudb_debug & TOKUDB_DEBUG_TXN) { diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc index b109cd1b976..42205c6d6be 100644 --- a/storage/tokudb/ha_tokudb_admin.cc +++ b/storage/tokudb/ha_tokudb_admin.cc @@ -121,9 +121,10 @@ static int analyze_progress(void *v_extra, uint64_t rows) { progress_time = (float) (t_now - t_start) / (float) t_limit; char *write_status_msg = extra->write_status_msg; TABLE_SHARE *table_share = extra->table_share; - sprintf(write_status_msg, "%s.%s.%s %u of %u %.lf%% rows %.lf%% time", - table_share->db.str, table_share->table_name.str, extra->key_name, - extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0); + sprintf(write_status_msg, "%.*s.%.*s.%s %u of %u %.lf%% rows %.lf%% time", + (int) table_share->db.length, table_share->db.str, + (int) table_share->table_name.length, table_share->table_name.str, + extra->key_name, extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0); thd_proc_info(thd, write_status_msg); return 0; } @@ -338,8 +339,10 @@ static int ha_tokudb_check_progress(void *extra, float progress) { static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) { if (thd->vio_ok()) { - char tablename[256]; - snprintf(tablename, sizeof tablename, "%s.%s", table->s->db.str, table->s->table_name.str); + char tablename[table->s->db.length + 1 + table->s->table_name.length + 1]; + snprintf(tablename, sizeof tablename, "%.*s.%.*s", + (int) table->s->db.length, table->s->db.str, + (int) table->s->table_name.length, table->s->table_name.str); thd->protocol->prepare_for_resend(); thd->protocol->store(tablename, strlen(tablename), system_charset_info); thd->protocol->store("check", 5, system_charset_info); @@ -388,6 +391,11 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { } struct check_context check_context = { thd }; r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going); + if (r != 0) { + char msg[32 + strlen(kname)]; + sprintf(msg, "Corrupt %s", kname); + ha_tokudb_check_info(thd, table, msg); + } snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u result=%d", share->table_name, kname, i, r); thd_proc_info(thd, write_status_msg); if (tokudb_debug & TOKUDB_DEBUG_CHECK) { diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc index d574bae9a33..28c0b4419c0 100644 --- a/storage/tokudb/ha_tokudb_alter_56.cc +++ b/storage/tokudb/ha_tokudb_alter_56.cc @@ -784,13 +784,16 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i assert(trx->tokudb_lock_count > 0); // for partitioned tables, we use a single transaction to do all of the partition changes. the tokudb_lock_count // is a reference count for each of the handlers to the same transaction. obviously, we want to only abort once. - if (!--trx->tokudb_lock_count) { - abort_txn(ctx->alter_txn); - ctx->alter_txn = NULL; - trx->stmt = NULL; - trx->sub_sp_level = NULL; + if (trx->tokudb_lock_count > 0) { + if (--trx->tokudb_lock_count <= trx->create_lock_count) { + trx->create_lock_count = 0; + abort_txn(ctx->alter_txn); + ctx->alter_txn = NULL; + trx->stmt = NULL; + trx->sub_sp_level = NULL; + } + transaction = NULL; } - transaction = NULL; if (ctx->add_index_changed) { restore_add_index(table, ha_alter_info->index_add_count, ctx->incremented_num_DBs, ctx->modified_DBs); diff --git a/storage/tokudb/hatoku_defines.h b/storage/tokudb/hatoku_defines.h index 69dbd6b7e5c..f93e07548e6 100644 --- a/storage/tokudb/hatoku_defines.h +++ b/storage/tokudb/hatoku_defines.h @@ -356,6 +356,7 @@ typedef struct st_tokudb_trx_data { DB_TXN *sp_level; DB_TXN *sub_sp_level; uint tokudb_lock_count; + uint create_lock_count; tokudb_stmt_progress stmt_progress; bool checkpoint_lock_taken; LIST *handlers; diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index d282d68acc1..1572c3652e0 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -1714,6 +1714,8 @@ static int tokudb_fractal_tree_info(TABLE *table, THD *thd) { error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); if (!error) { error = tokudb_report_fractal_tree_info_for_db(&curr_key, &curr_val, table, thd); + if (error) + error = 0; // ignore read uncommitted errors } if (!error && thd_killed(thd)) error = ER_QUERY_INTERRUPTED; @@ -1992,7 +1994,9 @@ struct tokudb_search_txn_extra { uint64_t match_client_id; }; -static int tokudb_search_txn_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { +static int tokudb_search_txn_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { + uint64_t txn_id = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); struct tokudb_search_txn_extra *e = reinterpret_cast<struct tokudb_search_txn_extra *>(extra); if (e->match_txn_id == txn_id) { e->match_found = true; @@ -2124,6 +2128,7 @@ static struct st_mysql_information_schema tokudb_trx_information_schema = { MYSQ static ST_FIELD_INFO tokudb_trx_field_info[] = { {"trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, {"trx_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"trx_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} }; @@ -2132,12 +2137,17 @@ struct tokudb_trx_extra { TABLE *table; }; -static int tokudb_trx_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { +static int tokudb_trx_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { + uint64_t txn_id = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); + uint64_t start_time = txn->get_start_time(txn); struct tokudb_trx_extra *e = reinterpret_cast<struct tokudb_trx_extra *>(extra); THD *thd = e->thd; TABLE *table = e->table; table->field[0]->store(txn_id, false); table->field[1]->store(client_id, false); + uint64_t tnow = (uint64_t) time(NULL); + table->field[2]->store(tnow >= start_time ? tnow - start_time : 0, false); int error = schema_table_store_record(thd, table); if (!error && thd_killed(thd)) error = ER_QUERY_INTERRUPTED; @@ -2285,7 +2295,9 @@ struct tokudb_locks_extra { TABLE *table; }; -static int tokudb_locks_callback(uint64_t txn_id, uint64_t client_id, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { +static int tokudb_locks_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { + uint64_t txn_id = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); struct tokudb_locks_extra *e = reinterpret_cast<struct tokudb_locks_extra *>(extra); THD *thd = e->thd; TABLE *table = e->table; diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result index 018900c7b98..190581eddae 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result @@ -2,7 +2,7 @@ set default_storage_engine='tokudb'; set tokudb_prelock_empty=false; drop table if exists t; create table t (id int primary key); -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name @@ -19,7 +19,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id TRX_ID MYSQL_ID TRX_ID MYSQL_ID @@ -31,7 +31,7 @@ select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name ERROR 23000: Duplicate entry '1' for key 'PRIMARY' commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name @@ -48,7 +48,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id TRX_ID MYSQL_ID TRX_ID MYSQL_ID @@ -59,7 +59,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result index b9fca50b507..13cdad7a438 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result @@ -2,7 +2,7 @@ set default_storage_engine='tokudb'; set tokudb_prelock_empty=false; drop table if exists t; create table t (id int primary key); -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name @@ -19,7 +19,7 @@ TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name REQUEST_TRX_ID BLOCK_TRX_ID ./test/t-main 0001000000 0001000000 LOCK_WAITS_START_TIME test t main -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id TRX_ID MYSQL_ID TRX_ID MYSQL_ID @@ -30,7 +30,7 @@ select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name ERROR HY000: Lock wait timeout exceeded; try restarting transaction commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result index e4c1adcca19..63e4816e16e 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result @@ -1,23 +1,23 @@ set default_storage_engine='tokudb'; set tokudb_prelock_empty=false; drop table if exists t; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id set autocommit=0; create table t (id int primary key); insert into t values (1); -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id TXN_ID_DEFAULT CLIENT_ID_DEFAULT commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id set autocommit=0; insert into t values (2); -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id TXN_ID_A CLIENT_ID_A commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; trx_id trx_mysql_thread_id drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test index c4f9ccefe5c..0f712000527 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test @@ -13,7 +13,7 @@ create table t (id int primary key); # verify that txn_a insert (1) blocks txn_b insert (1) and txn_b gets a duplicate key error # should be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; @@ -43,7 +43,7 @@ select * from information_schema.tokudb_lock_waits; # should find the presence of two transactions replace_column 1 TRX_ID 2 MYSQL_ID; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; commit; @@ -66,7 +66,7 @@ disconnect conn_b; # verify that the lock on the 2nd transaction has been released # should be be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; @@ -96,7 +96,7 @@ select * from information_schema.tokudb_lock_waits; # should find the presence of two transactions replace_column 1 TRX_ID 2 MYSQL_ID; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; commit; @@ -116,7 +116,7 @@ disconnect conn_b; # verify that the lock on the 2nd transaction has been released # should be be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test index 75929fa3b3d..3011443fa04 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test @@ -10,7 +10,7 @@ enable_warnings; create table t (id int primary key); # should be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; @@ -40,7 +40,7 @@ select * from information_schema.tokudb_lock_waits; # should find the presence of two transactions replace_column 1 TRX_ID 2 MYSQL_ID; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; sleep 5; # sleep longer than the lock timer to force a lock timeout on txn_b @@ -61,7 +61,7 @@ disconnect conn_a; disconnect conn_b; # should be be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test index b1d5c7e5009..d3c2636ba54 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test @@ -8,7 +8,7 @@ drop table if exists t; enable_warnings; # should be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; # should have my txn let $default_id=`select connection_id()`; @@ -16,11 +16,11 @@ set autocommit=0; create table t (id int primary key); insert into t values (1); replace_column 1 TXN_ID_DEFAULT 2 CLIENT_ID_DEFAULT; -eval select * from information_schema.tokudb_trx; +eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; # should be empty commit; -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connect(conn_a,localhost,root,,); let a_id=`select connection_id()`; @@ -29,13 +29,13 @@ insert into t values (2); connection default; replace_column 1 TXN_ID_A 2 CLIENT_ID_A; -eval select * from information_schema.tokudb_trx; +eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; commit; connection default; # should be empty -select * from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; disconnect conn_a; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result new file mode 100644 index 00000000000..1bc0372f1b8 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result @@ -0,0 +1,18 @@ +drop table if exists t1,t3; +create table t3(a3 int,b3 decimal(0,0),c3 int,d3 int,primary key(a3,b3)) engine=TOKUDB; +LOCK TABLES t3 WRITE; +create temporary table t1(f1 int,index(f1)) engine=innodb; +INSERT INTO t1 VALUES(1),(1),(1); +select * from t1; +f1 +1 +1 +1 +ALTER TABLE t1 engine=TOKUDB; +select * from t1; +f1 +1 +1 +1 +unlock tables; +drop table t1,t3; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result new file mode 100644 index 00000000000..ae87dbab281 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result @@ -0,0 +1,9 @@ +drop table if exists t1,t3; +CREATE TABLE t3(a int,c int,d int)engine=TOKUDB; +lock table t3 read; +create temporary table t1 engine=tokudb as SELECT 1; +select * from t1; +1 +1 +unlock tables; +drop table t1,t3; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result new file mode 100644 index 00000000000..1d26f43c9dd --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result @@ -0,0 +1,14 @@ +drop table if exists t2,t3,t4; +CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB; +CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb; +CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 13; +LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE; +INSERT INTO t2(a)VALUES (REPEAT(0,1)); +ALTER TABLE t2 ADD COLUMN(c INT); +alter table t4 add column c int; +UPDATE t2 SET a=1; +select * from t2; +a b c +1 NULL NULL +unlock tables; +drop table t2,t3,t4; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result new file mode 100644 index 00000000000..0a50e63e037 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result @@ -0,0 +1,14 @@ +drop table if exists t2,t3,t4; +CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB; +CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb; +CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 1; +LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE; +INSERT INTO t2(a)VALUES (REPEAT(0,1)); +ALTER TABLE t2 ADD COLUMN(c INT); +alter table t4 add column c int; +UPDATE t2 SET a=1; +select * from t2; +a b c +1 NULL NULL +unlock tables; +drop table t2,t3,t4; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result new file mode 100644 index 00000000000..d94da5c0673 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result @@ -0,0 +1,11 @@ +drop table if exists s,t; +create table s (id int) engine=tokudb; +lock tables s write; +create temporary table t (id int, key(id)) engine=innodb; +insert into t values (1); +alter table t engine=tokudb; +select * from t; +id +1 +unlock tables; +drop table s, t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result b/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result index e63f73caf20..0cf75d40847 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/tokudb718.result @@ -3,7 +3,8 @@ drop table if exists t; create table t (id int primary key); begin; insert into t values (1),(2); -select * from information_schema.tokudb_fractal_tree_info; -ERROR HY000: Got error -30994 "Internal error < 0 (Not system error)" from storage engine TokuDB +select dictionary_name from information_schema.tokudb_fractal_tree_info; +dictionary_name +./test/t-status commit; drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test new file mode 100644 index 00000000000..1114de6b325 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test @@ -0,0 +1,17 @@ +# DB-805 test that conversion of t1 from innodb to tokudb can write rows +source include/have_tokudb.inc; +source include/have_innodb.inc; +disable_warnings; +drop table if exists t1,t3; +enable_warnings; + +create table t3(a3 int,b3 decimal(0,0),c3 int,d3 int,primary key(a3,b3)) engine=TOKUDB; +LOCK TABLES t3 WRITE; +create temporary table t1(f1 int,index(f1)) engine=innodb; +INSERT INTO t1 VALUES(1),(1),(1); +select * from t1; +ALTER TABLE t1 engine=TOKUDB; +select * from t1; +unlock tables; + +drop table t1,t3; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test new file mode 100644 index 00000000000..3815e59f78c --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test @@ -0,0 +1,13 @@ +# DB-806 test that lock tables and create select can write rows to the new table +source include/have_tokudb.inc; +disable_warnings; +drop table if exists t1,t3; +enable_warnings; + +CREATE TABLE t3(a int,c int,d int)engine=TOKUDB; +lock table t3 read; +create temporary table t1 engine=tokudb as SELECT 1; +select * from t1; +unlock tables; + +drop table t1,t3;
\ No newline at end of file diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test new file mode 100644 index 00000000000..509f482765e --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test @@ -0,0 +1,22 @@ +# DB-811 test that alter table t2 updates both the schema (FRM) and the data (tokudb files) + +source include/have_tokudb.inc; +source include/have_innodb.inc; +source include/have_partition.inc; +disable_warnings; +drop table if exists t2,t3,t4; +enable_warnings; + +CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB; +CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb; +CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 13; +LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE; +INSERT INTO t2(a)VALUES (REPEAT(0,1)); +ALTER TABLE t2 ADD COLUMN(c INT); +alter table t4 add column c int; +UPDATE t2 SET a=1; +select * from t2; +unlock tables; + +drop table t2,t3,t4; + diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test new file mode 100644 index 00000000000..5b8c6ed79d3 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test @@ -0,0 +1,22 @@ +# DB-811 test that alter table t2 updates both the schema (FRM) and the data (tokudb files) + +source include/have_tokudb.inc; +source include/have_innodb.inc; +source include/have_partition.inc; +disable_warnings; +drop table if exists t2,t3,t4; +enable_warnings; + +CREATE TABLE t3(a INT,b INT,UNIQUE KEY (a,b)) engine=TOKUDB; +CREATE TABLE t4(c1 FLOAT ZEROFILL) engine=innodb; +CREATE TABLE t2(a int KEY,b CHAR (1)) engine=TOKUDB PARTITION BY HASH (a) PARTITIONS 1; +LOCK TABLES t4 WRITE,t3 WRITE,t2 WRITE; +INSERT INTO t2(a)VALUES (REPEAT(0,1)); +ALTER TABLE t2 ADD COLUMN(c INT); +alter table t4 add column c int; +UPDATE t2 SET a=1; +select * from t2; +unlock tables; + +drop table t2,t3,t4; + diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test new file mode 100644 index 00000000000..2e01c0e5797 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test @@ -0,0 +1,16 @@ +# test DB-823 +# test that the conversion of table t from innodb to tokudb succeeds. +source include/have_tokudb.inc; +source include/have_innodb.inc; +disable_warnings; +drop table if exists s,t; +enable_warnings; +create table s (id int) engine=tokudb; +lock tables s write; +create temporary table t (id int, key(id)) engine=innodb; +insert into t values (1); +alter table t engine=tokudb; +select * from t; +unlock tables; +drop table s, t; + diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test b/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test index 415bb7a2332..735a88afed8 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/tokudb718.test @@ -7,7 +7,6 @@ enable_warnings; create table t (id int primary key); begin; insert into t values (1),(2); ---error 1030 -select * from information_schema.tokudb_fractal_tree_info; +select dictionary_name from information_schema.tokudb_fractal_tree_info; commit; drop table t; diff --git a/storage/xtradb/api/api0api.cc b/storage/xtradb/api/api0api.cc index 3859fb84b81..8769fc47166 100644 --- a/storage/xtradb/api/api0api.cc +++ b/storage/xtradb/api/api0api.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2008, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2008, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -318,35 +318,6 @@ ib_wake_master_thread(void) } } -/*********************************************************************//** -Calculate the max row size of the columns in a cluster index. -@return max row length */ -UNIV_INLINE -ulint -ib_get_max_row_len( -/*===============*/ - dict_index_t* cluster) /*!< in: cluster index */ -{ - ulint i; - ulint max_len = 0; - ulint n_fields = cluster->n_fields; - - /* Add the size of the ordering columns in the - clustered index. */ - for (i = 0; i < n_fields; ++i) { - const dict_col_t* col; - - col = dict_index_get_nth_col(cluster, i); - - /* Use the maximum output size of - mach_write_compressed(), although the encoded - length should always fit in 2 bytes. */ - max_len += dict_col_get_max_size(col); - } - - return(max_len); -} - /*****************************************************************//** Read the columns from a rec into a tuple. */ static @@ -710,120 +681,6 @@ ib_trx_rollback( return(err); } -/*****************************************************************//** -Find an index definition from the index vector using index name. -@return index def. if found else NULL */ -UNIV_INLINE -const ib_index_def_t* -ib_table_find_index( -/*================*/ - ib_vector_t* indexes, /*!< in: vector of indexes */ - const char* name) /*!< in: index name */ -{ - ulint i; - - for (i = 0; i < ib_vector_size(indexes); ++i) { - const ib_index_def_t* index_def; - - index_def = (ib_index_def_t*) ib_vector_get(indexes, i); - - if (innobase_strcasecmp(name, index_def->name) == 0) { - return(index_def); - } - } - - return(NULL); -} - -/*****************************************************************//** -Get the InnoDB internal precise type from the schema column definition. -@return precise type in api format */ -UNIV_INLINE -ulint -ib_col_get_prtype( -/*==============*/ - const ib_col_t* ib_col) /*!< in: column definition */ -{ - ulint prtype = 0; - - if (ib_col->ib_col_attr & IB_COL_UNSIGNED) { - prtype |= DATA_UNSIGNED; - - ut_a(ib_col->ib_col_type == IB_INT); - } - - if (ib_col->ib_col_attr & IB_COL_NOT_NULL) { - prtype |= DATA_NOT_NULL; - } - - return(prtype); -} - -/*****************************************************************//** -Get the InnoDB internal main type from the schema column definition. -@return column main type */ -UNIV_INLINE -ulint -ib_col_get_mtype( -/*==============*/ - const ib_col_t* ib_col) /*!< in: column definition */ -{ - /* Note: The api0api.h types should map directly to - the internal numeric codes. */ - return(ib_col->ib_col_type); -} - -/*****************************************************************//** -Find a column in the the column vector with the same name. -@return col. def. if found else NULL */ -UNIV_INLINE -const ib_col_t* -ib_table_find_col( -/*==============*/ - const ib_vector_t* cols, /*!< in: column list head */ - const char* name) /*!< in: column name to find */ -{ - ulint i; - - for (i = 0; i < ib_vector_size(cols); ++i) { - const ib_col_t* ib_col; - - ib_col = static_cast<const ib_col_t*>( - ib_vector_get((ib_vector_t*) cols, i)); - - if (innobase_strcasecmp(ib_col->name, name) == 0) { - return(ib_col); - } - } - - return(NULL); -} - -/*****************************************************************//** -Find a column in the the column list with the same name. -@return col. def. if found else NULL */ -UNIV_INLINE -const ib_key_col_t* -ib_index_find_col( -/*==============*/ - ib_vector_t* cols, /*!< in: column list head */ - const char* name) /*!< in: column name to find */ -{ - ulint i; - - for (i = 0; i < ib_vector_size(cols); ++i) { - const ib_key_col_t* ib_col; - - ib_col = static_cast<ib_key_col_t*>(ib_vector_get(cols, i)); - - if (innobase_strcasecmp(ib_col->name, name) == 0) { - return(ib_col); - } - } - - return(NULL); -} - #ifdef __WIN__ /*****************************************************************//** Convert a string to lower case. */ @@ -947,34 +804,6 @@ ib_table_name_check( /*****************************************************************//** -Get an index definition that is tagged as a clustered index. -@return cluster index schema */ -UNIV_INLINE -ib_index_def_t* -ib_find_clustered_index( -/*====================*/ - ib_vector_t* indexes) /*!< in: index defs. to search */ -{ - ulint i; - ulint n_indexes; - - n_indexes = ib_vector_size(indexes); - - for (i = 0; i < n_indexes; ++i) { - ib_index_def_t* ib_index_def; - - ib_index_def = static_cast<ib_index_def_t*>( - ib_vector_get(indexes, i)); - - if (ib_index_def->clustered) { - return(ib_index_def); - } - } - - return(NULL); -} - -/*****************************************************************//** Get a table id. The caller must have acquired the dictionary mutex. @return DB_SUCCESS if found */ static @@ -3564,41 +3393,6 @@ ib_cursor_set_cluster_access( prebuilt->need_to_access_clustered = TRUE; } -/*************************************************************//** -Convert and write an INT column value to an InnoDB tuple. -@return DB_SUCCESS or error */ -UNIV_INLINE -ib_err_t -ib_tuple_write_int( -/*===============*/ - ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ - ulint col_no, /*!< in: column number */ - const void* value, /*!< in: integer value */ - ulint value_len) /*!< in: sizeof value type */ -{ - const dfield_t* dfield; - ulint data_len; - ulint type_len; - ib_tuple_t* tuple = (ib_tuple_t*) ib_tpl; - - ut_a(col_no < ib_tuple_get_n_cols(ib_tpl)); - - dfield = ib_col_get_dfield(tuple, col_no); - - data_len = dfield_get_len(dfield); - type_len = dtype_get_len(dfield_get_type(dfield)); - - if (dtype_get_mtype(dfield_get_type(dfield)) != DATA_INT - || value_len != data_len) { - - return(DB_DATA_MISMATCH); - } - - return(ib_col_set_value( - ib_tpl, static_cast<ib_ulint_t>(col_no), - value, static_cast<ib_ulint_t>(type_len), true)); -} - /*****************************************************************//** Write an integer value to a column. Integers are stored in big-endian format and will need to be converted from the host format. diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc index b57a8873bd5..94a3af2852b 100644 --- a/storage/xtradb/dict/dict0boot.cc +++ b/storage/xtradb/dict/dict0boot.cc @@ -302,8 +302,7 @@ dict_boot(void) /* Insert into the dictionary cache the descriptions of the basic system tables */ /*-------------------------*/ - table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0, - false); + table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0); dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); @@ -357,8 +356,7 @@ dict_boot(void) ut_a(error == DB_SUCCESS); /*-------------------------*/ - table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0, - false); + table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0); dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); @@ -391,8 +389,7 @@ dict_boot(void) ut_a(error == DB_SUCCESS); /*-------------------------*/ - table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0, - false); + table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0); dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); @@ -425,8 +422,7 @@ dict_boot(void) ut_a(error == DB_SUCCESS); /*-------------------------*/ - table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0, - false); + table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0); dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index 3b044c74b52..811d737e6bf 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, SkySQL Ab. All Rights Reserved. @@ -684,6 +684,33 @@ dict_table_get_col_name_for_mysql( return(s); } #ifndef UNIV_HOTBACKUP +/** Allocate and init the autoinc latch of a given table. +This function must not be called concurrently on the same table object. +@param[in,out] table_void table whose autoinc latch to create */ +void +dict_table_autoinc_alloc( + void* table_void) +{ + dict_table_t* table = static_cast<dict_table_t*>(table_void); + table->autoinc_mutex = new (std::nothrow) ib_mutex_t(); + ut_a(table->autoinc_mutex != NULL); + mutex_create(autoinc_mutex_key, + table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX); +} + +/** Allocate and init the zip_pad_mutex of a given index. +This function must not be called concurrently on the same index object. +@param[in,out] index_void index whose zip_pad_mutex to create */ +void +dict_index_zip_pad_alloc( + void* index_void) +{ + dict_index_t* index = static_cast<dict_index_t*>(index_void); + index->zip_pad.mutex = new (std::nothrow) os_fast_mutex_t; + ut_a(index->zip_pad.mutex != NULL); + os_fast_mutex_init(zip_pad_mutex_key, index->zip_pad.mutex); +} + /********************************************************************//** Acquire the autoinc lock. */ UNIV_INTERN @@ -692,7 +719,32 @@ dict_table_autoinc_lock( /*====================*/ dict_table_t* table) /*!< in/out: table */ { - mutex_enter(&table->autoinc_mutex); +#ifdef HAVE_ATOMIC_BUILTINS + os_once::do_or_wait_for_done( + &table->autoinc_mutex_created, + dict_table_autoinc_alloc, table); +#else /* HAVE_ATOMIC_BUILTINS */ + ut_ad(table->autoinc_mutex_created == os_once::DONE); +#endif /* HAVE_ATOMIC_BUILTINS */ + + mutex_enter(table->autoinc_mutex); +} + +/** Acquire the zip_pad_mutex latch. +@param[in,out] index the index whose zip_pad_mutex to acquire.*/ +void +dict_index_zip_pad_lock( + dict_index_t* index) +{ +#ifdef HAVE_ATOMIC_BUILTINS + os_once::do_or_wait_for_done( + &index->zip_pad.mutex_created, + dict_index_zip_pad_alloc, index); +#else /* HAVE_ATOMIC_BUILTINS */ + ut_ad(index->zip_pad.mutex_created == os_once::DONE); +#endif /* HAVE_ATOMIC_BUILTINS */ + + os_fast_mutex_lock(index->zip_pad.mutex); } /********************************************************************//** @@ -704,7 +756,7 @@ dict_table_autoinc_initialize( dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: next value to assign to a row */ { - ut_ad(mutex_own(&table->autoinc_mutex)); + ut_ad(dict_table_autoinc_own(table)); table->autoinc = value; } @@ -746,7 +798,7 @@ dict_table_autoinc_read( /*====================*/ const dict_table_t* table) /*!< in: table */ { - ut_ad(mutex_own(&table->autoinc_mutex)); + ut_ad(dict_table_autoinc_own(table)); return(table->autoinc); } @@ -762,7 +814,7 @@ dict_table_autoinc_update_if_greater( dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: value which was assigned to a row */ { - ut_ad(mutex_own(&table->autoinc_mutex)); + ut_ad(dict_table_autoinc_own(table)); if (value > table->autoinc) { @@ -778,7 +830,7 @@ dict_table_autoinc_unlock( /*======================*/ dict_table_t* table) /*!< in/out: table */ { - mutex_exit(&table->autoinc_mutex); + mutex_exit(table->autoinc_mutex); } #endif /* !UNIV_HOTBACKUP */ @@ -1626,15 +1678,18 @@ dict_table_rename_in_cache( } else if (table->space != TRX_SYS_SPACE) { char* new_path = NULL; - if (table->dir_path_of_temp_table != NULL) { + if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: trying to rename a" " TEMPORARY TABLE ", stderr); ut_print_name(stderr, NULL, TRUE, old_name); - fputs(" (", stderr); - ut_print_filename(stderr, - table->dir_path_of_temp_table); - fputs(" )\n", stderr); + if (table->dir_path_of_temp_table != NULL) { + fputs(" (", stderr); + ut_print_filename( + stderr, table->dir_path_of_temp_table); + fputs(" )\n", stderr); + } + return(DB_ERROR); } else if (DICT_TF_HAS_DATA_DIR(table->flags)) { @@ -5945,8 +6000,7 @@ dict_ind_init(void) dict_table_t* table; /* create dummy table and index for REDUNDANT infimum and supremum */ - table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0, - true); + table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0); dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR, DATA_ENGLISH | DATA_NOT_NULL, 8); @@ -5959,7 +6013,7 @@ dict_ind_init(void) /* create dummy table and index for COMPACT infimum and supremum */ table = dict_mem_table_create("SYS_DUMMY2", DICT_HDR_SPACE, 1, - DICT_TF_COMPACT, 0, true); + DICT_TF_COMPACT, 0); dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR, DATA_ENGLISH | DATA_NOT_NULL, 8); dict_ind_compact = dict_mem_index_create("SYS_DUMMY2", "SYS_DUMMY2", @@ -6795,10 +6849,10 @@ dict_index_zip_success( return; } - os_fast_mutex_lock(&index->zip_pad.mutex); + dict_index_zip_pad_lock(index); ++index->zip_pad.success; dict_index_zip_pad_update(&index->zip_pad, zip_threshold); - os_fast_mutex_unlock(&index->zip_pad.mutex); + dict_index_zip_pad_unlock(index); } /*********************************************************************//** @@ -6818,10 +6872,10 @@ dict_index_zip_failure( return; } - os_fast_mutex_lock(&index->zip_pad.mutex); + dict_index_zip_pad_lock(index); ++index->zip_pad.failure; dict_index_zip_pad_update(&index->zip_pad, zip_threshold); - os_fast_mutex_unlock(&index->zip_pad.mutex); + dict_index_zip_pad_unlock(index); } @@ -6853,9 +6907,9 @@ dict_index_zip_pad_optimal_page_size( #ifdef HAVE_ATOMIC_BUILTINS pad = os_atomic_increment_ulint(&index->zip_pad.pad, 0); #else /* HAVE_ATOMIC_BUILTINS */ - os_fast_mutex_lock(&index->zip_pad.mutex); + dict_index_zip_pad_lock(index); pad = index->zip_pad.pad; - os_fast_mutex_unlock(&index->zip_pad.mutex); + dict_index_zip_pad_unlock(index); #endif /* HAVE_ATOMIC_BUILTINS */ ut_ad(pad < UNIV_PAGE_SIZE); diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc index fb33c31ff92..58521b833b6 100644 --- a/storage/xtradb/dict/dict0load.cc +++ b/storage/xtradb/dict/dict0load.cc @@ -2182,8 +2182,7 @@ err_len: /* See if the tablespace is available. */ *table = dict_mem_table_create( - name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2, - false); + name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2); field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len); ut_ad(len == 8); /* this was checked earlier */ diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index 43ccbdd5fe7..ffdc5100558 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -79,10 +79,7 @@ dict_mem_table_create( the table is placed */ ulint n_cols, /*!< in: number of columns */ ulint flags, /*!< in: table flags */ - ulint flags2, /*!< in: table flags2 */ - bool nonshared)/*!< in: whether the table object is a dummy - one that does not need the initialization of - locking-related fields. */ + ulint flags2) /*!< in: table flags2 */ { dict_table_t* table; mem_heap_t* heap; @@ -118,18 +115,10 @@ dict_mem_table_create( dict_table_stats_latch_create(table, true); #ifndef UNIV_HOTBACKUP + table->autoinc_lock = static_cast<ib_lock_t*>( + mem_heap_alloc(heap, lock_get_size())); - if (!nonshared) { - - table->autoinc_lock = static_cast<ib_lock_t*>( - mem_heap_alloc(heap, lock_get_size())); - - mutex_create(autoinc_mutex_key, - &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX); - } else { - - table->autoinc_lock = NULL; - } + dict_table_autoinc_create_lazy(table); table->autoinc = 0; @@ -212,10 +201,7 @@ dict_mem_table_free( } } #ifndef UNIV_HOTBACKUP - if (table->autoinc_lock) { - - mutex_free(&(table->autoinc_mutex)); - } + dict_table_autoinc_destroy(table); #endif /* UNIV_HOTBACKUP */ dict_table_stats_latch_destroy(table); @@ -580,8 +566,7 @@ dict_mem_index_create( dict_mem_fill_index_struct(index, heap, table_name, index_name, space, type, n_fields); - os_fast_mutex_init(zip_pad_mutex_key, &index->zip_pad.mutex); - + dict_index_zip_pad_mutex_create_lazy(index); return(index); } @@ -714,7 +699,7 @@ dict_mem_index_free( } #endif /* UNIV_BLOB_DEBUG */ - os_fast_mutex_free(&index->zip_pad.mutex); + dict_index_zip_pad_mutex_destroy(index); mem_heap_free(index->heap); } diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index 34acab04241..363a46d7fdf 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -305,44 +305,6 @@ xdes_find_bit( } /**********************************************************************//** -Looks for a descriptor bit having the desired value. Scans the extent in -a direction opposite to xdes_find_bit. -@return bit index of the bit, ULINT_UNDEFINED if not found */ -UNIV_INLINE -ulint -xdes_find_bit_downward( -/*===================*/ - xdes_t* descr, /*!< in: descriptor */ - ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ - ibool val, /*!< in: desired bit value */ - ulint hint, /*!< in: hint of which bit position would - be desirable */ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ulint i; - - ut_ad(descr && mtr); - ut_ad(val <= TRUE); - ut_ad(hint < FSP_EXTENT_SIZE); - ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX)); - for (i = hint + 1; i > 0; i--) { - if (val == xdes_mtr_get_bit(descr, bit, i - 1, mtr)) { - - return(i - 1); - } - } - - for (i = FSP_EXTENT_SIZE - 1; i > hint; i--) { - if (val == xdes_mtr_get_bit(descr, bit, i, mtr)) { - - return(i); - } - } - - return(ULINT_UNDEFINED); -} - -/**********************************************************************//** Returns the number of used pages in a descriptor. @return number of pages used */ UNIV_INLINE diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 37e742bf938..5adda1fad6c 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -81,11 +81,13 @@ ulint n_nodes = 0; /** Error condition reported by fts_utf8_decode() */ const ulint UTF8_ERROR = 0xFFFFFFFF; +#ifdef FTS_CACHE_SIZE_DEBUG /** The cache size permissible lower limit (1K) */ static const ulint FTS_CACHE_SIZE_LOWER_LIMIT_IN_MB = 1; /** The cache size permissible upper limit (1G) */ static const ulint FTS_CACHE_SIZE_UPPER_LIMIT_IN_MB = 1024; +#endif /* FTS_CACHE_SIZE_DEBUG */ /** Time to sleep after DEADLOCK error before retrying operation. */ static const ulint FTS_DEADLOCK_RETRY_WAIT = 100000; @@ -191,7 +193,7 @@ static const char* fts_create_common_tables_sql = { "" "CREATE TABLE \"%s_CONFIG\" (\n" " key CHAR(50),\n" - " value CHAR(50) NOT NULL\n" + " value CHAR(200) NOT NULL\n" ") COMPACT;\n" "CREATE UNIQUE CLUSTERED INDEX IND ON \"%s_CONFIG\"(key);\n" }; @@ -329,27 +331,6 @@ fts_update_sync_doc_id( doc_id_t doc_id, /*!< in: last document id */ trx_t* trx) /*!< in: update trx, or NULL */ __attribute__((nonnull(1))); -/******************************************************************** -Check if we should stop. */ -UNIV_INLINE -ibool -fts_is_stop_signalled( -/*==================*/ - fts_t* fts) /*!< in: fts instance */ -{ - ibool stop_signalled = FALSE; - - mutex_enter(&fts->bg_threads_mutex); - - if (fts->fts_status & BG_THREAD_STOP) { - - stop_signalled = TRUE; - } - - mutex_exit(&fts->bg_threads_mutex); - - return(stop_signalled); -} /****************************************************************//** This function loads the default InnoDB stopword list */ @@ -1971,7 +1952,7 @@ fts_create_one_index_table( flags2 = DICT_TF2_USE_TABLESPACE; } - new_table = dict_mem_table_create(table_name, 0, 5, 1, flags2, false); + new_table = dict_mem_table_create(table_name, 0, 5, 1, flags2); field = dict_index_get_nth_field(index, 0); charset = innobase_get_fts_charset( @@ -3409,7 +3390,7 @@ fts_fetch_doc_from_rec( doc->charset = get_doc->index_cache->charset; /* Null Field */ - if (doc->text.f_len == UNIV_SQL_NULL) { + if (doc->text.f_len == UNIV_SQL_NULL || doc->text.f_len == 0) { continue; } @@ -5545,7 +5526,7 @@ fts_savepoint_lookup( /*********************************************************************//** Release the savepoint data identified by name. All savepoints created -after the named savepoint are also released. +after the named savepoint are kept. @return DB_SUCCESS or error code */ UNIV_INTERN void @@ -5554,81 +5535,37 @@ fts_savepoint_release( trx_t* trx, /*!< in: transaction */ const char* name) /*!< in: savepoint name */ { - ulint i; - ib_vector_t* savepoints; - ulint top_of_stack = 0; - ut_a(name != NULL); - savepoints = trx->fts_trx->savepoints; + ib_vector_t* savepoints = trx->fts_trx->savepoints; ut_a(ib_vector_size(savepoints) > 0); - /* Skip the implied savepoint (first element). */ - for (i = 1; i < ib_vector_size(savepoints); ++i) { - fts_savepoint_t* savepoint; + ulint i = fts_savepoint_lookup(savepoints, name); + if (i != ULINT_UNDEFINED) { + ut_a(i >= 1); + fts_savepoint_t* savepoint; savepoint = static_cast<fts_savepoint_t*>( ib_vector_get(savepoints, i)); - /* Even though we release the resources that are part - of the savepoint, we don't (always) actually delete the - entry. We simply set the savepoint name to NULL. Therefore - we have to skip deleted/released entries. */ - if (savepoint->name != NULL - && strcmp(name, savepoint->name) == 0) { - break; + if (i == ib_vector_size(savepoints) - 1) { + /* If the savepoint is the last, we save its + tables to the previous savepoint. */ + fts_savepoint_t* prev_savepoint; + prev_savepoint = static_cast<fts_savepoint_t*>( + ib_vector_get(savepoints, i - 1)); - /* Track the previous savepoint instance that will - be at the top of the stack after the release. */ - } else if (savepoint->name != NULL) { - /* We need to delete all entries - greater than this element. */ - top_of_stack = i; + ib_rbt_t* tables = savepoint->tables; + savepoint->tables = prev_savepoint->tables; + prev_savepoint->tables = tables; } - } - - /* Only if we found and element to release. */ - if (i < ib_vector_size(savepoints)) { - fts_savepoint_t* last_savepoint; - fts_savepoint_t* top_savepoint; - ib_rbt_t* tables; - - ut_a(top_of_stack < ib_vector_size(savepoints)); - /* Exchange tables between last savepoint and top savepoint */ - last_savepoint = static_cast<fts_savepoint_t*>( - ib_vector_last(trx->fts_trx->savepoints)); - top_savepoint = static_cast<fts_savepoint_t*>( - ib_vector_get(savepoints, top_of_stack)); - tables = top_savepoint->tables; - top_savepoint->tables = last_savepoint->tables; - last_savepoint->tables = tables; - - /* Skip the implied savepoint. */ - for (i = ib_vector_size(savepoints) - 1; - i > top_of_stack; - --i) { - - fts_savepoint_t* savepoint; - - savepoint = static_cast<fts_savepoint_t*>( - ib_vector_get(savepoints, i)); - - /* Skip savepoints that were released earlier. */ - if (savepoint->name != NULL) { - savepoint->name = NULL; - fts_savepoint_free(savepoint); - } - - ib_vector_pop(savepoints); - } + fts_savepoint_free(savepoint); + ib_vector_remove(savepoints, *(void**)savepoint); /* Make sure we don't delete the implied savepoint. */ ut_a(ib_vector_size(savepoints) > 0); - - /* This must hold. */ - ut_a(ib_vector_size(savepoints) == (top_of_stack + 1)); } } @@ -6330,7 +6267,7 @@ fts_fake_hex_to_dec( { ib_id_t dec_id = 0; char tmp_id[FTS_AUX_MIN_TABLE_ID_LENGTH]; - int ret; + int ret __attribute__((unused)); ret = sprintf(tmp_id, UINT64PFx, id); ut_ad(ret == 16); diff --git a/storage/xtradb/fts/fts0opt.cc b/storage/xtradb/fts/fts0opt.cc index 5891b53a6e2..e096b8bf6d6 100644 --- a/storage/xtradb/fts/fts0opt.cc +++ b/storage/xtradb/fts/fts0opt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -42,9 +42,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang /** The FTS optimize thread's work queue. */ static ib_wqueue_t* fts_optimize_wq; -/** The number of document ids to delete in one statement. */ -static const ulint FTS_MAX_DELETE_DOC_IDS = 1000; - /** Time to wait for a message. */ static const ulint FTS_QUEUE_WAIT_IN_USECS = 5000000; @@ -1154,6 +1151,7 @@ fts_optimize_encode_node( } /* Calculate the space required to store the ilist. */ + ut_ad(doc_id > node->last_doc_id); doc_id_delta = doc_id - node->last_doc_id; enc_len = fts_get_encoded_len(static_cast<ulint>(doc_id_delta)); @@ -1396,7 +1394,8 @@ fts_optimize_word( src_node = (fts_node_t*) ib_vector_get(word->nodes, i); - if (!dst_node) { + if (dst_node == NULL + || dst_node->last_doc_id > src_node->first_doc_id) { dst_node = static_cast<fts_node_t*>( ib_vector_push(nodes, NULL)); diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 9d8e7aec9ab..66060439215 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -57,9 +57,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang /*Initial byte length for 'words' in fts_ranking_t */ #define RANKING_WORDS_INIT_LEN 4 -/* Coeffecient to use for normalize relevance ranking. */ -static const double FTS_NORMALIZE_COEFF = 0.0115F; - // FIXME: Need to have a generic iterator that traverses the ilist. typedef std::vector<fts_string_t> word_vector_t; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index df883fb25e0..8ec276dcbc3 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -3356,19 +3356,6 @@ trx_is_strict( return(trx && trx->mysql_thd && THDVAR(trx->mysql_thd, strict_mode)); } -/**********************************************************************//** -Determines if the current MySQL thread is running in strict mode. -If thd==NULL, THDVAR returns the global value of innodb-strict-mode. -@return TRUE if strict */ -UNIV_INLINE -ibool -thd_is_strict( -/*==========*/ - THD* thd) /*!< in: MySQL thread descriptor */ -{ - return(THDVAR(thd, strict_mode)); -} - /**************************************************************//** Resets some fields of a prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing. */ @@ -8695,7 +8682,8 @@ calc_row_difference( } } } - innodb_idx++; + if (field->stored_in_db) + innodb_idx++; } /* If the update changes a column with an FTS index on it, we @@ -9722,6 +9710,11 @@ ha_innobase::general_fetch( DBUG_ENTER("general_fetch"); + /* If transaction is not startted do not continue, instead return a error code. */ + if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) { + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + if (UNIV_UNLIKELY(srv_pass_corrupt_table <= 1 && share && share->ib_table && share->ib_table->is_corrupt)) { DBUG_RETURN(HA_ERR_CRASHED); @@ -10889,18 +10882,18 @@ create_table_def( /* Adjust for the FTS hidden field */ if (!has_doc_id_col) { table = dict_mem_table_create(table_name, 0, s_cols + 1, - flags, flags2, false); + flags, flags2); /* Set the hidden doc_id column. */ table->fts->doc_col = s_cols; } else { table = dict_mem_table_create(table_name, 0, s_cols, - flags, flags2, false); + flags, flags2); table->fts->doc_col = doc_id_col; } } else { table = dict_mem_table_create(table_name, 0, s_cols, - flags, flags2, false); + flags, flags2); } if (flags2 & DICT_TF2_TEMPORARY) { @@ -12001,7 +11994,7 @@ ha_innobase::create( DBUG_ASSERT(thd != NULL); DBUG_ASSERT(create_info != NULL); - if (form->s->fields > REC_MAX_N_USER_FIELDS) { + if (form->s->stored_fields > REC_MAX_N_USER_FIELDS) { DBUG_RETURN(HA_ERR_TOO_MANY_FIELDS); } else if (srv_read_only_mode) { DBUG_RETURN(HA_ERR_TABLE_READONLY); @@ -13496,18 +13489,6 @@ ha_innobase::info_low( prebuilt->trx->op_info = "returning various info to MySQL"; } - - my_snprintf(path, sizeof(path), "%s/%s%s", - mysql_data_home, ib_table->name, reg_ext); - - unpack_filename(path,path); - - /* Note that we do not know the access time of the table, - nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ - - if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) { - stats.create_time = (ulong) stat_info.ctime; - } } if (flag & HA_STATUS_VARIABLE) { @@ -13793,6 +13774,20 @@ ha_innobase::info_low( if (!(flag & HA_STATUS_NO_LOCK)) { dict_table_stats_unlock(ib_table, RW_S_LATCH); } + + my_snprintf(path, sizeof(path), "%s/%s%s", + mysql_data_home, + table->s->normalized_path.str, + reg_ext); + + unpack_filename(path,path); + + /* Note that we do not know the access time of the table, + nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ + + if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) { + stats.create_time = (ulong) stat_info.ctime; + } } if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 4b09820d400..f791a4dcd2e 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -2841,7 +2841,7 @@ prepare_inplace_alter_table_dict( /* The initial space id 0 may be overridden later. */ ctx->new_table = dict_mem_table_create( - new_table_name, 0, n_cols, flags, flags2, false); + new_table_name, 0, n_cols, flags, flags2); /* The rebuilt indexed_table will use the renamed column names. */ ctx->col_names = NULL; diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index d0561efb8ad..e124cb98f99 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyrigth (c) 2014, 2015, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -3233,8 +3233,6 @@ i_s_fts_index_cache_fill_one_index( for (rbt_node = rbt_first(index_cache->words); rbt_node; rbt_node = rbt_next(index_cache->words, rbt_node)) { - doc_id_t doc_id = 0; - fts_tokenizer_word_t* word; word = rbt_value(fts_tokenizer_word_t, rbt_node); @@ -3260,6 +3258,7 @@ i_s_fts_index_cache_fill_one_index( fts_node_t* node; byte* ptr; ulint decoded = 0; + doc_id_t doc_id = 0; node = static_cast<fts_node_t*> (ib_vector_get( word->nodes, i)); @@ -3931,10 +3930,14 @@ i_s_fts_config_fill( if (!user_table) { DBUG_RETURN(0); + } else if (!dict_table_has_fts_index(user_table)) { + dict_table_close(user_table, FALSE, FALSE); + + DBUG_RETURN(0); } trx = trx_allocate_for_background(); - trx->op_info = "Select for FTS DELETE TABLE"; + trx->op_info = "Select for FTS CONFIG TABLE"; FTS_INIT_FTS_TABLE(&fts_table, "CONFIG", FTS_COMMON_TABLE, user_table); diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc index 068a9fc9334..972208c51bd 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.cc +++ b/storage/xtradb/ibuf/ibuf0ibuf.cc @@ -611,8 +611,7 @@ ibuf_init_at_db_start(void) heap = mem_heap_create(450); /* Use old-style record format for the insert buffer. */ - table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0, - false); + table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0); dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0); @@ -1573,7 +1572,7 @@ ibuf_dummy_index_create( table = dict_mem_table_create("IBUF_DUMMY", DICT_HDR_SPACE, n, - comp ? DICT_TF_COMPACT : 0, 0, true); + comp ? DICT_TF_COMPACT : 0, 0); index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY", DICT_HDR_SPACE, 0, n); diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index deea392f9fd..d5cd8c595c2 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, SkySQL Ab. All Rights Reserved. @@ -348,10 +348,7 @@ dict_mem_table_create( of the table is placed */ ulint n_cols, /*!< in: number of columns */ ulint flags, /*!< in: table flags */ - ulint flags2, /*!< in: table flags2 */ - bool nonshared);/*!< in: whether the table object is a dummy - one that does not need the initialization of - locking-related fields. */ + ulint flags2); /*!< in: table flags2 */ /**********************************************************************//** Determines if a table belongs to a system database @return true if table belong to a system database */ @@ -646,11 +643,12 @@ extern ulong zip_failure_threshold_pct; compression failures */ extern ulong zip_pad_max; -/** Data structure to hold information about about how much space in +/** Data structure to hold information about how much space in an uncompressed page should be left as padding to avoid compression failures. This estimate is based on a self-adapting heuristic. */ struct zip_pad_info_t { - os_fast_mutex_t mutex; /*!< mutex protecting the info */ + os_fast_mutex_t* + mutex; /*!< mutex protecting the info */ ulint pad; /*!< number of bytes used as pad */ ulint success;/*!< successful compression ops during current round */ @@ -658,6 +656,9 @@ struct zip_pad_info_t { current round */ ulint n_rounds;/*!< number of currently successful rounds */ + volatile os_once::state_t + mutex_created; + /*!< Creation state of mutex member */ }; /** Number of samples of data size kept when page compression fails for @@ -1157,8 +1158,7 @@ struct dict_table_t{ dict_table_t::indexes*::stat_index_size dict_table_t::indexes*::stat_n_leaf_pages (*) those are not always protected for - performance reasons. NULL for dumy table - objects. */ + performance reasons. */ unsigned stat_initialized:1; /*!< TRUE if statistics have been calculated the first time after database startup or table creation */ @@ -1292,12 +1292,15 @@ struct dict_table_t{ and release it without a need to allocate space from the lock heap of the trx: otherwise the lock heap would grow rapidly - if we do a large insert from a select. NULL - for dummy table objects. */ - ib_mutex_t autoinc_mutex; + if we do a large insert from a select */ + ib_mutex_t* autoinc_mutex; /*!< mutex protecting the autoincrement - counter. Not initialized for dummy table - objects */ + counter */ + + /** Creation state of autoinc_mutex member */ + volatile os_once::state_t + autoinc_mutex_created; + ib_uint64_t autoinc;/*!< autoinc counter value to give to the next inserted row */ ulong n_waiting_or_granted_auto_inc_locks; @@ -1361,6 +1364,111 @@ struct dict_foreign_add_to_referenced_table { } }; +/** Destroy the autoinc latch of the given table. +This function is only called from either single threaded environment +or from a thread that has not shared the table object with other threads. +@param[in,out] table table whose stats latch to destroy */ +inline +void +dict_table_autoinc_destroy( + dict_table_t* table) +{ + if (table->autoinc_mutex_created == os_once::DONE + && table->autoinc_mutex != NULL) { + mutex_free(table->autoinc_mutex); + delete table->autoinc_mutex; + } +} + +/** Allocate and init the autoinc latch of a given table. +This function must not be called concurrently on the same table object. +@param[in,out] table_void table whose autoinc latch to create */ +void +dict_table_autoinc_alloc( + void* table_void); + +/** Allocate and init the zip_pad_mutex of a given index. +This function must not be called concurrently on the same index object. +@param[in,out] index_void index whose zip_pad_mutex to create */ +void +dict_index_zip_pad_alloc( + void* index_void); + +/** Request for lazy creation of the autoinc latch of a given table. +This function is only called from either single threaded environment +or from a thread that has not shared the table object with other threads. +@param[in,out] table table whose autoinc latch is to be created. */ +inline +void +dict_table_autoinc_create_lazy( + dict_table_t* table) +{ +#ifdef HAVE_ATOMIC_BUILTINS + table->autoinc_mutex = NULL; + table->autoinc_mutex_created = os_once::NEVER_DONE; +#else /* HAVE_ATOMIC_BUILTINS */ + dict_table_autoinc_alloc(table); + table->autoinc_mutex_created = os_once::DONE; +#endif /* HAVE_ATOMIC_BUILTINS */ +} + +/** Request a lazy creation of dict_index_t::zip_pad::mutex. +This function is only called from either single threaded environment +or from a thread that has not shared the table object with other threads. +@param[in,out] index index whose zip_pad mutex is to be created */ +inline +void +dict_index_zip_pad_mutex_create_lazy( + dict_index_t* index) +{ +#ifdef HAVE_ATOMIC_BUILTINS + index->zip_pad.mutex = NULL; + index->zip_pad.mutex_created = os_once::NEVER_DONE; +#else /* HAVE_ATOMIC_BUILTINS */ + dict_index_zip_pad_alloc(index); + index->zip_pad.mutex_created = os_once::DONE; +#endif /* HAVE_ATOMIC_BUILTINS */ +} + +/** Destroy the zip_pad_mutex of the given index. +This function is only called from either single threaded environment +or from a thread that has not shared the table object with other threads. +@param[in,out] table table whose stats latch to destroy */ +inline +void +dict_index_zip_pad_mutex_destroy( + dict_index_t* index) +{ + if (index->zip_pad.mutex_created == os_once::DONE + && index->zip_pad.mutex != NULL) { + os_fast_mutex_free(index->zip_pad.mutex); + delete index->zip_pad.mutex; + } +} + +/** Release the zip_pad_mutex of a given index. +@param[in,out] index index whose zip_pad_mutex is to be released */ +inline +void +dict_index_zip_pad_unlock( + dict_index_t* index) +{ + os_fast_mutex_unlock(index->zip_pad.mutex); +} + +#ifdef UNIV_DEBUG +/** Check if the current thread owns the autoinc_mutex of a given table. +@param[in] table the autoinc_mutex belongs to this table +@return true, if the current thread owns the autoinc_mutex, false otherwise.*/ +inline +bool +dict_table_autoinc_own( + const dict_table_t* table) +{ + return(mutex_own(table->autoinc_mutex)); +} +#endif /* UNIV_DEBUG */ + #ifndef UNIV_NONINL #include "dict0mem.ic" #endif diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h index bd37287f1a0..3a7707ee130 100644 --- a/storage/xtradb/include/os0sync.h +++ b/storage/xtradb/include/os0sync.h @@ -452,7 +452,7 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */ # define os_atomic_test_and_set_ulint(ptr, new_val) \ __sync_lock_test_and_set(ptr, new_val) -#ifdef __powerpc__ +#if defined(__powerpc__) || defined(__aarch64__) /* os_atomic_test_and_set_byte_release() should imply a release barrier before setting, and a full barrier after. But __sync_lock_test_and_set() is only diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 11f9d7876f4..241f210869f 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 23 +#define INNODB_VERSION_BUGFIX 24 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 72.1 +#define PERCONA_INNODB_VERSION 72.2 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 59168fb741b..d46214dccb6 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2014, 2015, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -387,8 +387,10 @@ because there is no parallel deadlock check. This stack is protected by the lock_sys_t::mutex. */ static lock_stack_t* lock_stack; +#ifdef UNIV_DEBUG /** The count of the types of locks. */ static const ulint lock_types = UT_ARR_SIZE(lock_compatibility_matrix); +#endif /* UNIV_DEBUG */ #ifdef UNIV_PFS_MUTEX /* Key to register mutex with performance schema */ diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index 72efe771302..93ed384c0c7 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, SkySQL Ab. All Rights Reserved. @@ -1951,7 +1951,7 @@ loop: goto loop; } - ut_ad(!allow_ibuf == mutex_own(&log_sys->mutex)); + ut_ad((!allow_ibuf) == mutex_own(&log_sys->mutex)); if (!allow_ibuf) { recv_no_ibuf_operations = TRUE; diff --git a/storage/xtradb/mtr/mtr0log.cc b/storage/xtradb/mtr/mtr0log.cc index db39ebeafa4..82df1df63d4 100644 --- a/storage/xtradb/mtr/mtr0log.cc +++ b/storage/xtradb/mtr/mtr0log.cc @@ -571,7 +571,7 @@ mlog_parse_index( n = n_uniq = 1; } table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n, - comp ? DICT_TF_COMPACT : 0, 0, true); + comp ? DICT_TF_COMPACT : 0, 0); ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY", DICT_HDR_SPACE, 0, n); ind->table = table; diff --git a/storage/xtradb/os/os0sync.cc b/storage/xtradb/os/os0sync.cc index 451ba5285e3..03c53848832 100644 --- a/storage/xtradb/os/os0sync.cc +++ b/storage/xtradb/os/os0sync.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -234,24 +234,6 @@ os_cond_broadcast( } /*********************************************************//** -Wakes one thread waiting for condition variable */ -UNIV_INLINE -void -os_cond_signal( -/*==========*/ - os_cond_t* cond) /*!< in: condition variable. */ -{ - ut_a(cond); - -#ifdef __WIN__ - ut_a(wake_condition_variable != NULL); - wake_condition_variable(cond); -#else - ut_a(pthread_cond_signal(cond) == 0); -#endif -} - -/*********************************************************//** Destroys condition variable */ UNIV_INLINE void diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc index 86c33ab5efb..58559cc438b 100644 --- a/storage/xtradb/page/page0zip.cc +++ b/storage/xtradb/page/page0zip.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, SkySQL Ab. All Rights Reserved. @@ -1601,7 +1601,7 @@ page_zip_fields_free( { if (index) { dict_table_t* table = index->table; - os_fast_mutex_free(&index->zip_pad.mutex); + dict_index_zip_pad_mutex_destroy(index); mem_heap_free(index->heap); dict_mem_table_free(table); @@ -1652,7 +1652,7 @@ page_zip_fields_decode( } table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n, - DICT_TF_COMPACT, 0, true); + DICT_TF_COMPACT, 0); index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY", DICT_HDR_SPACE, 0, n); index->table = table; diff --git a/storage/xtradb/pars/pars0pars.cc b/storage/xtradb/pars/pars0pars.cc index 18feb9407c7..c87e1f8e247 100644 --- a/storage/xtradb/pars/pars0pars.cc +++ b/storage/xtradb/pars/pars0pars.cc @@ -1998,7 +1998,7 @@ pars_create_table( n_cols = que_node_list_get_len(column_defs); table = dict_mem_table_create( - table_sym->name, 0, n_cols, flags, flags2, false); + table_sym->name, 0, n_cols, flags, flags2); #ifdef UNIV_DEBUG if (not_fit_in_memory != NULL) { diff --git a/storage/xtradb/que/que0que.cc b/storage/xtradb/que/que0que.cc index 8d9b8fac776..e2dc0239e13 100644 --- a/storage/xtradb/que/que0que.cc +++ b/storage/xtradb/que/que0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -390,32 +390,6 @@ que_fork_start_command( return(thr); } -/****************************************************************//** -Tests if all the query threads in the same fork have a given state. -@return TRUE if all the query threads in the same fork were in the -given state */ -UNIV_INLINE -ibool -que_fork_all_thrs_in_state( -/*=======================*/ - que_fork_t* fork, /*!< in: query fork */ - ulint state) /*!< in: state */ -{ - que_thr_t* thr_node; - - for (thr_node = UT_LIST_GET_FIRST(fork->thrs); - thr_node != NULL; - thr_node = UT_LIST_GET_NEXT(thrs, thr_node)) { - - if (thr_node->state != state) { - - return(FALSE); - } - } - - return(TRUE); -} - /**********************************************************************//** Calls que_graph_free_recursive for statements in a statement list. */ static diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index ac0e75929a4..9d403e64fd0 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1390,6 +1390,27 @@ blob_done: dfield_set_data(dfield, data, len); } + if (len != UNIV_SQL_NULL && col->mtype == DATA_MYSQL + && col->len != len && !dict_table_is_comp(log->table)) { + + ut_ad(col->len >= len); + if (dict_table_is_comp(index->table)) { + byte* buf = (byte*) mem_heap_alloc(heap, + col->len); + memcpy(buf, dfield->data, len); + memset(buf + len, 0x20, col->len - len); + + dfield_set_data(dfield, buf, col->len); + } else { + /* field length mismatch should not happen + when rebuilding the redundant row format + table. */ + ut_ad(0); + *error = DB_CORRUPTION; + return(NULL); + } + } + /* See if any columns were changed to NULL or NOT NULL. */ const dict_col_t* new_col = dict_table_get_nth_col(log->table, col_no); diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index bdcbd00ac80..2df9c2bea82 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -244,22 +244,88 @@ row_merge_buf_free( mem_heap_free(buf->heap); } -/******************************************************//** -Insert a data tuple into a sort buffer. -@return number of rows added, 0 if out of space */ +/** Convert the field data from compact to redundant format. +@param[in] row_field field to copy from +@param[out] field field to copy to +@param[in] len length of the field data +@param[in] zip_size compressed BLOB page size, + zero for uncompressed BLOBs +@param[in,out] heap memory heap where to allocate data when + converting to ROW_FORMAT=REDUNDANT, or NULL + when not to invoke + row_merge_buf_redundant_convert(). */ +static +void +row_merge_buf_redundant_convert( + const dfield_t* row_field, + dfield_t* field, + ulint len, + ulint zip_size, + mem_heap_t* heap, + trx_t* trx) +{ + ut_ad(DATA_MBMINLEN(field->type.mbminmaxlen) == 1); + ut_ad(DATA_MBMAXLEN(field->type.mbminmaxlen) > 1); + + byte* buf = (byte*) mem_heap_alloc(heap, len); + ulint field_len = row_field->len; + ut_ad(field_len <= len); + + if (row_field->ext) { + const byte* field_data = static_cast<byte*>( + dfield_get_data(row_field)); + ulint ext_len; + + ut_a(field_len >= BTR_EXTERN_FIELD_REF_SIZE); + ut_a(memcmp(field_data + field_len - BTR_EXTERN_FIELD_REF_SIZE, + field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE)); + + byte* data = btr_copy_externally_stored_field( + &ext_len, field_data, zip_size, field_len, heap, trx); + + ut_ad(ext_len < len); + + memcpy(buf, data, ext_len); + field_len = ext_len; + } else { + memcpy(buf, row_field->data, field_len); + } + + memset(buf + field_len, 0x20, len - field_len); + + dfield_set_data(field, buf, len); +} + +/** Insert a data tuple into a sort buffer. +@param[in,out] buf sort buffer +@param[in] fts_index fts index to be created +@param[in] old_table original table +@param[in,out] psort_info parallel sort info +@param[in] row table row +@param[in] ext cache of externally stored + column prefixes, or NULL +@param[in,out] doc_id Doc ID if we are creating + FTS index +@param[in,out] conv_heap memory heap where to allocate data when + converting to ROW_FORMAT=REDUNDANT, or NULL + when not to invoke + row_merge_buf_redundant_convert() +@param[in,out] exceed_page set if the record size exceeds the page size + when converting to ROW_FORMAT=REDUNDANT +@return number of rows added, 0 if out of space */ static ulint row_merge_buf_add( -/*==============*/ - row_merge_buf_t* buf, /*!< in/out: sort buffer */ - dict_index_t* fts_index,/*!< in: fts index to be created */ - const dict_table_t* old_table,/*!< in: original table */ - fts_psort_t* psort_info, /*!< in: parallel sort info */ - const dtuple_t* row, /*!< in: table row */ - const row_ext_t* ext, /*!< in: cache of externally stored - column prefixes, or NULL */ - doc_id_t* doc_id) /*!< in/out: Doc ID if we are - creating FTS index */ + row_merge_buf_t* buf, + dict_index_t* fts_index, + const dict_table_t* old_table, + fts_psort_t* psort_info, + const dtuple_t* row, + const row_ext_t* ext, + doc_id_t* doc_id, + mem_heap_t* conv_heap, + bool* exceed_page, + trx_t* trx) { ulint i; const dict_index_t* index; @@ -409,6 +475,23 @@ row_merge_buf_add( n_row_added = 1; continue; } + + if (field->len != UNIV_SQL_NULL + && col->mtype == DATA_MYSQL + && col->len != field->len) { + + if (conv_heap != NULL) { + row_merge_buf_redundant_convert( + row_field, field, col->len, + dict_table_zip_size(old_table), + conv_heap, trx); + } else { + /* Field length mismatch should not + happen when rebuilding redundant row + format table. */ + ut_ad(dict_table_is_comp(index->table)); + } + } } len = dfield_get_len(field); @@ -517,6 +600,14 @@ row_merge_buf_add( of extra_size. */ data_size += (extra_size + 1) + ((extra_size + 1) >= 0x80); + /* Record size can exceed page size while converting to + redundant row format. But there is assert + ut_ad(size < UNIV_PAGE_SIZE) in rec_offs_data_size(). + It may hit the assert before attempting to insert the row. */ + if (conv_heap != NULL && data_size > UNIV_PAGE_SIZE) { + *exceed_page = true; + } + ut_ad(data_size < srv_sort_buf_size); /* Reserve one byte for the end marker of row_merge_block_t. */ @@ -536,6 +627,10 @@ row_merge_buf_add( dfield_dup(field++, buf->heap); } while (--n_fields); + if (conv_heap != NULL) { + mem_heap_empty(conv_heap); + } + DBUG_RETURN(n_row_added); } @@ -1219,6 +1314,7 @@ row_merge_read_clustered_index( os_event_t fts_parallel_sort_event = NULL; ibool fts_pll_sort = FALSE; ib_int64_t sig_count = 0; + mem_heap_t* conv_heap = NULL; float curr_progress; ib_int64_t read_rows = 0; @@ -1324,6 +1420,11 @@ row_merge_read_clustered_index( row_heap = mem_heap_create(sizeof(mrec_buf_t)); + if (dict_table_is_comp(old_table) + && !dict_table_is_comp(new_table)) { + conv_heap = mem_heap_create(sizeof(mrec_buf_t)); + } + /* Scan the clustered index. */ for (;;) { const rec_t* rec; @@ -1608,16 +1709,24 @@ write_buffers: row_merge_buf_t* buf = merge_buf[i]; merge_file_t* file = &files[i]; ulint rows_added = 0; + bool exceed_page = false; if (UNIV_LIKELY (row && (rows_added = row_merge_buf_add( buf, fts_index, old_table, - psort_info, row, ext, &doc_id)))) { + psort_info, row, ext, &doc_id, + conv_heap, &exceed_page, trx)))) { /* If we are creating FTS index, a single row can generate more records for tokenized word */ file->n_rec += rows_added; + + if (exceed_page) { + err = DB_TOO_BIG_RECORD; + break; + } + if (doc_id > max_doc_id) { max_doc_id = doc_id; } @@ -1718,12 +1827,18 @@ write_buffers: (!(rows_added = row_merge_buf_add( buf, fts_index, old_table, psort_info, row, ext, - &doc_id)))) { + &doc_id, conv_heap, + &exceed_page, trx)))) { /* An empty buffer should have enough room for at least one record. */ ut_error; } + if (exceed_page) { + err = DB_TOO_BIG_RECORD; + break; + } + file->n_rec += rows_added; } } @@ -1759,6 +1874,10 @@ func_exit: } all_done: + if (conv_heap != NULL) { + mem_heap_free(conv_heap); + } + #ifdef FTS_INTERNAL_DIAG_PRINT DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Scan Table\n"); #endif diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index d0f1b1d1b89..4fc301111c9 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -3494,13 +3494,11 @@ row_truncate_table_for_mysql( goto funct_exit; } - if (table->space && !table->dir_path_of_temp_table) { + if (table->space && !DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) { /* Discard and create the single-table tablespace. */ ulint space = table->space; ulint flags = fil_space_get_flags(space); - ut_a(!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)); - dict_get_and_save_data_dir_path(table, true); if (flags != ULINT_UNDEFINED @@ -4305,8 +4303,9 @@ row_drop_table_for_mysql( is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY); /* If there is a temp path then the temp flag is set. - However, during recovery, we might have a temp flag but - not know the temp path */ + However, during recovery or reloading the table object + after eviction from data dictionary cache, we might + have a temp flag but not know the temp path */ ut_a(table->dir_path_of_temp_table == NULL || is_temp); if (dict_table_is_discarded(table) || table->ibd_file_missing) { @@ -4875,6 +4874,7 @@ row_rename_table_for_mysql( ibool old_is_tmp, new_is_tmp; pars_info_t* info = NULL; int retry; + bool aux_fts_rename = false; ut_a(old_name != NULL); ut_a(new_name != NULL); @@ -5161,34 +5161,8 @@ row_rename_table_for_mysql( if (dict_table_has_fts_index(table) && !dict_tables_have_same_db(old_name, new_name)) { err = fts_rename_aux_tables(table, new_name, trx); - - if (err != DB_SUCCESS && (table->space != 0)) { - char* orig_name = table->name; - trx_t* trx_bg = trx_allocate_for_background(); - - /* If the first fts_rename fails, the trx would - be rolled back and committed, we can't use it any more, - so we have to start a new background trx here. */ - ut_a(trx_state_eq(trx, TRX_STATE_NOT_STARTED)); - trx_bg->op_info = "Revert the failing rename " - "for fts aux tables"; - trx_bg->dict_operation_lock_mode = RW_X_LATCH; - trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE); - - /* If rename fails and table has its own tablespace, - we need to call fts_rename_aux_tables again to - revert the ibd file rename, which is not under the - control of trx. Also notice the parent table name - in cache is not changed yet. If the reverting fails, - the ibd data may be left in the new database, which - can be fixed only manually. */ - table->name = const_cast<char*>(new_name); - fts_rename_aux_tables(table, old_name, trx_bg); - table->name = orig_name; - - trx_bg->dict_operation_lock_mode = 0; - trx_commit_for_mysql(trx_bg); - trx_free_for_background(trx_bg); + if (err != DB_TABLE_NOT_FOUND) { + aux_fts_rename = true; } } @@ -5289,6 +5263,37 @@ end: } funct_exit: + if (aux_fts_rename && err != DB_SUCCESS + && table != NULL && (table->space != 0)) { + + char* orig_name = table->name; + trx_t* trx_bg = trx_allocate_for_background(); + + /* If the first fts_rename fails, the trx would + be rolled back and committed, we can't use it any more, + so we have to start a new background trx here. */ + ut_a(trx_state_eq(trx_bg, TRX_STATE_NOT_STARTED)); + trx_bg->op_info = "Revert the failing rename " + "for fts aux tables"; + trx_bg->dict_operation_lock_mode = RW_X_LATCH; + trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE); + + /* If rename fails and table has its own tablespace, + we need to call fts_rename_aux_tables again to + revert the ibd file rename, which is not under the + control of trx. Also notice the parent table name + in cache is not changed yet. If the reverting fails, + the ibd data may be left in the new database, which + can be fixed only manually. */ + table->name = const_cast<char*>(new_name); + fts_rename_aux_tables(table, old_name, trx_bg); + table->name = orig_name; + + trx_bg->dict_operation_lock_mode = 0; + trx_commit_for_mysql(trx_bg); + trx_free_for_background(trx_bg); + } + if (table != NULL) { dict_table_close(table, dict_locked, FALSE); } diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index aabe604cad6..f0761759def 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -3277,9 +3277,9 @@ innobase_shutdown_for_mysql(void) ibuf_close(); log_shutdown(); - lock_sys_close(); trx_sys_file_format_close(); trx_sys_close(); + lock_sys_close(); /* We don't create these mutexes in RO mode because we don't create the temp files that the cover. */ diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc index dabf70fd041..14b332a2185 100644 --- a/storage/xtradb/sync/sync0sync.cc +++ b/storage/xtradb/sync/sync0sync.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 17986c293e9..5d3b86e158f 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -478,11 +478,12 @@ trx_free_prepared( /*==============*/ trx_t* trx) /*!< in, own: trx object */ { - ut_ad(mutex_own(&trx_sys->mutex)); - ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)); ut_a(trx->magic_n == TRX_MAGIC_N); + mutex_exit(&trx_sys->mutex); + lock_trx_release_locks(trx); + mutex_enter(&trx_sys->mutex); trx_undo_free_prepared(trx); assert_trx_in_rw_list(trx); diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index 6291d107d90..1e364bc951b 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -26,7 +26,7 @@ SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c my_strchr.c strcont.c strappend.c) IF(NOT HAVE_STRNLEN) - # OSX does not have strnlen + # OSX below 10.7 did not have strnlen SET(STRINGS_SOURCES ${STRINGS_SOURCES} strnlen.c) ENDIF() # Avoid dependencies on perschema data defined in mysys diff --git a/win/packaging/CPackWixConfig.cmake b/win/packaging/CPackWixConfig.cmake index 474c207891c..58a2ef44eef 100644 --- a/win/packaging/CPackWixConfig.cmake +++ b/win/packaging/CPackWixConfig.cmake @@ -68,7 +68,6 @@ SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install server") SET(CPACK_COMPONENT_CONNECT-ENGINE_DESCRIPTION "Server data files" ) SET(CPACK_COMPONENT_CONNECT-ENGINE_HIDDEN 1) - #Feature "Devel" SET(CPACK_COMPONENT_GROUP_DEVEL_DISPLAY_NAME "Development Components") SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Installs C/C++ header files and libraries") |