diff options
author | Alexander Nozdrin <alik@sun.com> | 2010-02-23 18:49:21 +0300 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2010-02-23 18:49:21 +0300 |
commit | 1dd2f90faf79eb1b194c9af0cde987c8a7b3058f (patch) | |
tree | df9457baf92d1aba63e31cc13fdfe0cc6b6e4be6 /sql | |
parent | fcc9c8627a54f68ffe7c2f225d20a9f8c1016a08 (diff) | |
parent | 0a8a9a3fc083fbaf44ce2b59d4995af9950f11b4 (diff) | |
download | mariadb-git-1dd2f90faf79eb1b194c9af0cde987c8a7b3058f.tar.gz |
Auto-merge from mysql-next-mr-bugfixing.
Diffstat (limited to 'sql')
-rwxr-xr-x[-rw-r--r--] | sql/CMakeLists.txt | 308 | ||||
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/handler.cc | 10 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 4 | ||||
-rw-r--r-- | sql/lex.h | 2 | ||||
-rw-r--r-- | sql/log.cc | 18 | ||||
-rw-r--r-- | sql/main.cc | 25 | ||||
-rw-r--r-- | sql/mysql_priv.h | 21 | ||||
-rw-r--r-- | sql/mysqld.cc | 146 | ||||
-rw-r--r-- | sql/nt_servc.cc | 1 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/share/CMakeLists.txt | 52 | ||||
-rw-r--r-- | sql/share/Makefile.am | 5 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 6 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/spatial.cc | 22 | ||||
-rw-r--r-- | sql/sql_builtin.cc.in | 9 | ||||
-rw-r--r-- | sql/sql_class.h | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 22 | ||||
-rw-r--r-- | sql/sql_table.cc | 51 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 28 | ||||
-rw-r--r-- | sql/structs.h | 1 | ||||
-rw-r--r-- | sql/sys_vars.cc | 24 | ||||
-rw-r--r-- | sql/table.cc | 88 | ||||
-rw-r--r-- | sql/unireg.cc | 129 |
29 files changed, 633 insertions, 359 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index ee69e154278..28a9d321455 100644..100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -12,36 +12,34 @@ # 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 -INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") - -SET(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_DEBUG} -DUSE_SYMDIR /Zi") -SET(CMAKE_C_FLAGS_DEBUG - "${CMAKE_C_FLAGS_DEBUG} -DUSE_SYMDIR /Zi") -SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/extra/yassl/include - ${CMAKE_SOURCE_DIR}/sql - ${CMAKE_SOURCE_DIR}/regex - ${CMAKE_SOURCE_DIR}/zlib + + +INCLUDE_DIRECTORIES( +${CMAKE_SOURCE_DIR}/include +${CMAKE_SOURCE_DIR}/sql +${CMAKE_SOURCE_DIR}/regex +${ZLIB_INCLUDE_DIR} +${SSL_INCLUDE_DIRS} +${CMAKE_BINARY_DIR}/sql ) -SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/sql_yacc.h - ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc - ${CMAKE_SOURCE_DIR}/include/mysql_version.h - ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc - ${CMAKE_SOURCE_DIR}/sql/lex_hash.h - ${PROJECT_SOURCE_DIR}/include/mysqld_error.h - ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h - ${PROJECT_SOURCE_DIR}/include/sql_state.h - PROPERTIES GENERATED 1) +SET(GEN_SOURCES +${CMAKE_BINARY_DIR}/sql/sql_yacc.h +${CMAKE_BINARY_DIR}/sql/sql_yacc.cc +${CMAKE_BINARY_DIR}/sql/sql_builtin.cc +${CMAKE_BINARY_DIR}/sql/lex_hash.h +) -ADD_DEFINITIONS(-DMYSQL_SERVER -D_CONSOLE -DHAVE_DLOPEN -DHAVE_EVENT_SCHEDULER) +SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1) + +ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER) +IF(SSL_DEFINES) + ADD_DEFINITIONS(${SSL_DEFINES}) +ENDIF() SET (SQL_SOURCE - ../sql-common/client.c derror.cc des_key_file.cc + ../sql-common/client.c derror.cc des_key_file.cc discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort.cc gstream.cc ha_partition.cc @@ -54,7 +52,7 @@ SET (SQL_SOURCE log_event_old.cc rpl_record_old.cc message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c mysqld.cc net_serv.cc keycaches.cc - nt_servc.cc nt_servc.h opt_range.cc opt_range.h opt_sum.cc + opt_range.cc opt_range.h opt_sum.cc ../sql-common/pack.c parse_file.cc password.c procedure.cc protocol.cc records.cc repl_failsafe.cc rpl_filter.cc set_var.cc slave.cc sp.cc sp_cache.cc sp_head.cc sp_pcontext.cc @@ -78,79 +76,203 @@ SET (SQL_SOURCE sql_profile.cc event_parse_data.cc sql_signal.cc rpl_handler.cc mdl.cc transaction.cc sys_vars.cc - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h - ${PROJECT_SOURCE_DIR}/include/mysqld_error.h - ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h - ${PROJECT_SOURCE_DIR}/include/sql_state.h - ${PROJECT_SOURCE_DIR}/include/mysql_version.h - ${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc - ${PROJECT_SOURCE_DIR}/sql/lex_hash.h) -ADD_LIBRARY(sql ${SQL_SOURCE}) - -IF (NOT EXISTS cmake_dummy.cc) - FILE (WRITE cmake_dummy.cc "") -ENDIF (NOT EXISTS cmake_dummy.cc) -ADD_EXECUTABLE(mysqld cmake_dummy.cc) - -SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX}) -SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) - -SET (MYSQLD_CORE_LIBS mysys zlib dbug strings yassl taocrypt vio regex sql) -TARGET_LINK_LIBRARIES(mysqld ${MYSQLD_CORE_LIBS} ${MYSQLD_STATIC_ENGINE_LIBS}) - - -IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS) - # Set module definition file. Also use non-incremental linker, - # incremental appears to crash from time to time,if used with /DEF option - SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "/DEF:mysqld.def /INCREMENTAL:NO") - - FOREACH (CORELIB ${MYSQLD_CORE_LIBS}) - GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION) - FILE(TO_NATIVE_PATH ${LOC} LOC) - SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC}) - ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS}) + ${GEN_SOURCES} + ${MYSYS_LIBWRAP_SOURCE}) + +MYSQL_ADD_PLUGIN(partition ha_partition.cc STORAGE_ENGINE DEFAULT STATIC_ONLY +RECOMPILE_FOR_EMBEDDED) + +ADD_LIBRARY(sql STATIC ${SQL_SOURCE}) +DTRACE_INSTRUMENT(sql) +TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS} + mysys dbug strings vio regex + ${LIBWRAP} ${LIBCRYPT} ${LIBDL} + ${SSL_LIBRARIES}) + - ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK - COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js - ${PLATFORM} ${LIB_LOCATIONS} > mysqld.def - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/sql) -ENDIF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS) -ADD_DEPENDENCIES(sql GenError) +IF(WIN32) + SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h) +ELSE() + SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL}) +ENDIF() -# Sql Parser custom command -ADD_CUSTOM_COMMAND( - OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - COMMAND bison ARGS -y -p MYSQL --defines=sql_yacc.h - --output=sql_yacc.cc sql_yacc.yy - DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy) +MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR}) + +IF(NOT WITHOUT_DYNAMIC_PLUGINS) + SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) + GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS) + IF(NOT mysqld_link_flags) + SET(mysqld_link_flags) + ENDIF() + IF (MINGW OR CYGWIN) + SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} -Wl,--export-all-symbols") + ENDIF() + IF(MSVC) + # Set module definition file. Also use non-incremental linker, + # incremental appears to crash from time to time,if used with /DEF option + SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO") + FOREACH (CORELIB sql mysys dbug strings) + GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION) + FILE(TO_NATIVE_PATH ${LOC} LOC) + SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC}) + ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS}) + SET(_PLATFORM x86) + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(_PLATFORM x64) + ENDIF() + ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK + COMMAND echo ${_PLATFORM} && cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js + ${_PLATFORM} ${LIB_LOCATIONS} > mysqld.def + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + ADD_DEPENDENCIES(sql GenError) + ENDIF() +ENDIF() + +SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) +TARGET_LINK_LIBRARIES(mysqld sql) + +# Provide plugins with minimal set of libraries +SET(INTERFACE_LIBS ${LIBRT}) +IF(INTERFACE_LIBS) + SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_INTERFACE_LIBRARIES + "${INTERFACE_LIBS}") +ENDIF() + +# On Solaris, some extra effort is required in order to get dtrace probes +# from static libraries +DTRACE_INSTRUMENT_STATIC_LIBS(mysqld + "sql;mysys;${MYSQLD_STATIC_PLUGIN_LIBS}") + + +SET(WITH_MYSQLD_LDFLAGS "" CACHE STRING "Additional linker flags for mysqld") +MARK_AS_ADVANCED(WITH_MYSQLD_LDFLAGS) +IF(WITH_MYSQLD_LDFLAGS) + GET_TARGET_PROPERTY(mysqld LINK_FLAGS MYSQLD_LINK_FLAGS) + IF(NOT MYSQLD_LINK_FLAGS) + SET(MYSQLD_LINK_FLAGS) + ENDIF() + SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS + "${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}") +ENDIF() +INSTALL_DEBUG_TARGET(mysqld DESTINATION ${INSTALL_SBINDIR} RENAME mysqld-debug) + +# Handle out-of-source build from source package with possibly broken +# bison. Copy bison output to from source to build directory, if not already +# there +IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc) + IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc + ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h + ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY) + ENDIF() + ENDIF() +ENDIF() + + +INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake) +RUN_BISON( + ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy + ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc + ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h +) # Gen_lex_hash ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) -TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient) -GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) +TARGET_LINK_LIBRARIES(gen_lex_hash mysys) + ADD_CUSTOM_COMMAND( - OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h - COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h - DEPENDS ${GEN_LEX_HASH_EXE}) - -ADD_CUSTOM_TARGET( - GenServerSource ALL - DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - ${PROJECT_SOURCE_DIR}/sql/message.h - ${PROJECT_SOURCE_DIR}/sql/message.rc - ${PROJECT_SOURCE_DIR}/sql/lex_hash.h) - -ADD_DEPENDENCIES(mysqld GenServerSource) - -# Remove the auto-generated files as part of 'Clean Solution' -SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES - "lex_hash.h;sql_yacc.h;sql_yacc.cc;mysqld.def") - -ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def) -ADD_DEPENDENCIES(udf_example strings GenError) -TARGET_LINK_LIBRARIES(udf_example strings) + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h + COMMAND gen_lex_hash ARGS > lex_hash.h.tmp && + ${CMAKE_COMMAND} -E copy_if_different lex_hash.h.tmp lex_hash.h + COMMAND ${CMAKE_COMMAND} -E remove -f lex_hash.h.tmp + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_lex_hash.cc) + +ADD_CUSTOM_TARGET( + GenServerSource + DEPENDS ${GEN_SOURCES} +) + +#Need this only for embedded +SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE) + +IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED) + ADD_LIBRARY(udf_example MODULE udf_example.c) + SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "") + # udf_example depends on strings + IF(WIN32) + IF(MSVC) + SET_TARGET_PROPERTIES(udf_example PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/udf_example.def") + ENDIF() + TARGET_LINK_LIBRARIES(udf_example strings) + ELSE() + # udf_example is using safemutex exported by mysqld + TARGET_LINK_LIBRARIES(udf_example mysqld) + ENDIF() +ENDIF() + +FOREACH(tool glibtoolize libtoolize aclocal autoconf autoheader automake gtar + tar bzr) + STRING(TOUPPER ${tool} TOOL) + FIND_PROGRAM(${TOOL}_EXECUTABLE ${tool} DOC "path to the executable") + MARK_AS_ADVANCED(${TOOL}_EXECUTABLE) +ENDFOREACH() + +CONFIGURE_FILE( + ${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in ${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY) + +ADD_CUSTOM_TARGET(dist + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake + DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.h + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +) + + + + +IF(INSTALL_LAYOUT STREQUAL "STANDALONE") + +# We need to create empty directories (data/test) the installation. +# This does not work with current CPack due to http://www.cmake.org/Bug/view.php?id=8767 +# Avoid completely empty directories and install dummy file instead. +SET(DUMMY_FILE ${CMAKE_CURRENT_BINARY_DIR}/.empty ) +FILE(WRITE ${DUMMY_FILE} "") +INSTALL(FILES ${DUMMY_FILE} DESTINATION data/test) + +# Install initial database on windows +IF(NOT CMAKE_CROSSCOMPILING) + GET_TARGET_PROPERTY(MYSQLD_EXECUTABLE mysqld LOCATION) +ENDIF() +IF(WIN32 AND MYSQLD_EXECUTABLE) + CONFIGURE_FILE( + ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + @ONLY + ) + + IF(MSVC_IDE OR CMAKE_GENERATOR MATCHES "Xcode") + SET (CONFIG_PARAM -DCONFIG=${CMAKE_CFG_INTDIR}) + ENDIF() + MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm + COMMAND ${CMAKE_COMMAND} + ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data + DEPENDS mysqld + ) + ADD_CUSTOM_TARGET(initial_database + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm + ) + INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data/mysql DESTINATION data) +ELSE() + # Not windows or cross compiling, just install an empty directory + INSTALL(FILES ${DUMMY_FILE} DESTINATION data/mysql) +ENDIF() +ENDIF() + diff --git a/sql/Makefile.am b/sql/Makefile.am index 3a244642e29..9a60cbcbf66 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -125,7 +125,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ net_serv.cc protocol.cc sql_state.c \ lock.cc my_lock.c \ sql_string.cc sql_manager.cc sql_map.cc \ - mysqld.cc password.c hash_filo.cc hostname.cc \ + main.cc mysqld.cc password.c hash_filo.cc hostname.cc \ sql_connect.cc scheduler.cc sql_parse.cc \ keycaches.cc set_var.cc sql_yacc.yy sys_vars.cc \ sql_base.cc table.cc sql_select.cc sql_insert.cc \ diff --git a/sql/handler.cc b/sql/handler.cc index c29a6568c3f..69ac4e72555 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1152,7 +1152,7 @@ int ha_commit_trans(THD *thd, bool all) uint rw_ha_count; bool rw_trans; - DBUG_EXECUTE_IF("crash_commit_before", abort();); + DBUG_EXECUTE_IF("crash_commit_before", DBUG_ABORT();); /* Close all cursors that can not survive COMMIT */ if (is_real_trans) /* not a statement commit */ @@ -1204,7 +1204,7 @@ int ha_commit_trans(THD *thd, bool all) } status_var_increment(thd->status_var.ha_prepare_count); } - DBUG_EXECUTE_IF("crash_commit_after_prepare", abort();); + DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT();); if (error || (is_real_trans && xid && (error= !(cookie= tc_log->log_xid(thd, xid))))) { @@ -1212,13 +1212,13 @@ int ha_commit_trans(THD *thd, bool all) error= 1; goto end; } - DBUG_EXECUTE_IF("crash_commit_after_log", abort();); + DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_ABORT();); } error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0; - DBUG_EXECUTE_IF("crash_commit_before_unlog", abort();); + DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_ABORT();); if (cookie) tc_log->unlog(cookie, xid); - DBUG_EXECUTE_IF("crash_commit_after", abort();); + DBUG_EXECUTE_IF("crash_commit_after", DBUG_ABORT();); RUN_HOOK(transaction, after_commit, (thd, FALSE)); end: if (rw_trans) diff --git a/sql/handler.h b/sql/handler.h index a9b81d8373f..1734e5727dc 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1011,6 +1011,7 @@ typedef struct st_key_create_information enum ha_key_alg algorithm; ulong block_size; LEX_STRING parser_name; + LEX_STRING comment; } KEY_CREATE_INFO; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 1da383ce3e9..ed465cbe280 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2865,9 +2865,7 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref) buff should match stack usage from Item_func_case::val_int() -> Item_func_case::find_item() */ -#ifndef EMBEDDED_LIBRARY uchar buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2]; -#endif bool res= Item_func::fix_fields(thd, ref); /* Call check_stack_overrun after fix_fields to be sure that stack variable @@ -4081,9 +4079,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) DBUG_ASSERT(fixed == 0); List_iterator<Item> li(list); Item *item; -#ifndef EMBEDDED_LIBRARY uchar buff[sizeof(char*)]; // Max local vars in function -#endif not_null_tables_cache= used_tables_cache= 0; const_item_cache= 1; /* diff --git a/sql/item_func.cc b/sql/item_func.cc index 75f8b2045b5..e49ee4346b1 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -151,9 +151,7 @@ Item_func::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); Item **arg,**arg_end; -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning uchar buff[STACK_BUFF_ALLOC]; // Max argument in function -#endif used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; @@ -2839,9 +2837,7 @@ bool udf_handler::fix_fields(THD *thd, Item_result_field *func, uint arg_count, Item **arguments) { -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning uchar buff[STACK_BUFF_ALLOC]; // Max argument in function -#endif DBUG_ENTER("Item_udf_func::fix_fields"); if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) diff --git a/sql/lex.h b/sql/lex.h index 5493206c214..fbedddc6941 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -226,7 +226,6 @@ static SYMBOL symbols[] = { { "FORCE", SYM(FORCE_SYM)}, { "FOREIGN", SYM(FOREIGN)}, { "FOUND", SYM(FOUND_SYM)}, - { "FRAC_SECOND", SYM(FRAC_SECOND_SYM)}, { "FROM", SYM(FROM)}, { "FULL", SYM(FULL)}, { "FULLTEXT", SYM(FULLTEXT_SYM)}, @@ -517,7 +516,6 @@ static SYMBOL symbols[] = { { "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM)}, { "SQL_SMALL_RESULT", SYM(SQL_SMALL_RESULT)}, { "SQL_THREAD", SYM(SQL_THREAD)}, - { "SQL_TSI_FRAC_SECOND", SYM(FRAC_SECOND_SYM)}, { "SQL_TSI_SECOND", SYM(SECOND_SYM)}, { "SQL_TSI_MINUTE", SYM(MINUTE_SYM)}, { "SQL_TSI_HOUR", SYM(HOUR_SYM)}, diff --git a/sql/log.cc b/sql/log.cc index 75853aec485..ce9d75089d1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2814,7 +2814,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, sql_print_error("MSYQL_BIN_LOG::open failed to sync the index file."); DBUG_RETURN(1); } - DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", abort();); + DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_ABORT();); #endif write_error= 0; @@ -2911,7 +2911,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, if (write_file_name_to_index_file) { #ifdef HAVE_REPLICATION - DBUG_EXECUTE_IF("crash_create_critical_before_update_index", abort();); + DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_ABORT();); #endif DBUG_ASSERT(my_b_inited(&index_file) != 0); @@ -2930,7 +2930,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, goto err; #ifdef HAVE_REPLICATION - DBUG_EXECUTE_IF("crash_create_after_update_index", abort();); + DBUG_EXECUTE_IF("crash_create_after_update_index", DBUG_ABORT();); #endif } } @@ -3392,7 +3392,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included) /* Store where we are in the new file for the execution thread */ flush_relay_log_info(rli); - DBUG_EXECUTE_IF("crash_before_purge_logs", abort();); + DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_ABORT();); mysql_mutex_lock(&rli->log_space_lock); rli->relay_log.purge_logs(to_purge_if_included, included, @@ -3520,7 +3520,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, break; } - DBUG_EXECUTE_IF("crash_purge_before_update_index", abort();); + DBUG_EXECUTE_IF("crash_purge_before_update_index", DBUG_ABORT();); if ((error= sync_purge_index_file())) { @@ -3535,7 +3535,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, goto err; } - DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", abort();); + DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", DBUG_ABORT();); err: /* Read each entry from purge_index_file and delete the file. */ @@ -3545,7 +3545,7 @@ err: " that would be purged."); close_purge_index_file(); - DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", abort();); + DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", DBUG_ABORT();); if (need_mutex) mysql_mutex_unlock(&LOCK_index); @@ -5091,7 +5091,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event, DBUG_PRINT("info", ("error writing binlog cache: %d", write_error)); DBUG_PRINT("info", ("crashing before writing xid")); - abort(); + DBUG_ABORT(); }); if ((write_error= write_cache(cache, false, false))) @@ -5106,7 +5106,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool synced= 0; if (flush_and_sync(&synced)) goto err; - DBUG_EXECUTE_IF("half_binlogged_transaction", abort();); + DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_ABORT();); if (cache->error) // Error on read { sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno); diff --git a/sql/main.cc b/sql/main.cc new file mode 100644 index 00000000000..249a2a883fe --- /dev/null +++ b/sql/main.cc @@ -0,0 +1,25 @@ +/* Copyright (C) 2009 Sun Microsystems, Inc. + + 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 */ + +/* + main() for mysqld. + Calls mysqld_main() entry point exported by sql library. +*/ +extern int mysqld_main(int argc, char **argv); + +int main(int argc, char **argv) +{ + return mysqld_main(argc, argv); +} diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index b27a7ea5078..a006d2a07ff 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -198,12 +198,12 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); if (((THD *) Thd) != NULL) \ push_warning_printf(((THD *) Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ ER_WARN_DEPRECATED_SYNTAX, \ - ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \ - (Old), #VerHi "." #VerLo, (New)); \ + ER(ER_WARN_DEPRECATED_SYNTAX), \ + (Old), (New)); \ else \ sql_print_warning("The syntax '%s' is deprecated and will be removed " \ - "in MySQL %s. Please use %s instead.", \ - (Old), #VerHi "." #VerLo, (New)); \ + "in a future release. Please use %s instead.", \ + (Old), (New)); \ } while(0) extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info; @@ -2027,7 +2027,7 @@ extern bool in_bootstrap; extern uint volatile thread_count, global_read_lock; extern uint connection_count; extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; -extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; +extern my_bool opt_local_infile, opt_myisam_use_mmap; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern uint slave_exec_mode_options; extern ulonglong slave_type_conversions_options; @@ -2317,7 +2317,7 @@ ulong next_io_size(ulong pos); void append_unescaped(String *res, const char *pos, uint length); int create_frm(THD *thd, const char *name, const char *db, const char *table, uint reclength, uchar *fileinfo, - HA_CREATE_INFO *create_info, uint keys); + HA_CREATE_INFO *create_info, uint keys, KEY *key_info); void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); int rename_file_ext(const char * from,const char * to,const char * ext); bool check_db_name(LEX_STRING *db); @@ -2327,6 +2327,7 @@ char *get_field(MEM_ROOT *mem, Field *field); bool get_field(MEM_ROOT *mem, Field *field, class String *res); int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr); char *fn_rext(char *name); +bool check_duplicate_warning(THD *thd, char *msg, ulong length); /* Conversion functions */ #endif /* MYSQL_SERVER */ @@ -2533,14 +2534,14 @@ inline bool is_user_table(TABLE * table) #ifndef EMBEDDED_LIBRARY extern "C" void unireg_abort(int exit_code) __attribute__((noreturn)); void kill_delayed_threads(void); -bool check_stack_overrun(THD *thd, long margin, uchar *dummy); #else extern "C" void unireg_clear(int exit_code); #define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0) inline void kill_delayed_threads(void) {} -#define check_stack_overrun(A, B, C) 0 #endif +bool check_stack_overrun(THD *thd, long margin, uchar *dummy); + /* This must match the path length limit in the ER_NOT_RW_DIR error msg. */ #define ER_NOT_RW_DIR_PATHSIZE 200 bool is_usable_directory(THD *thd, const char *varname, @@ -2638,7 +2639,6 @@ enum options_mysqld OPT_BOOTSTRAP, OPT_CONSOLE, OPT_DEBUG_SYNC_TIMEOUT, - OPT_DELAY_KEY_WRITE_ALL, OPT_ISAM_LOG, OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_AGE_THRESHOLD, @@ -2657,19 +2657,16 @@ enum options_mysqld OPT_SAFE, OPT_SERVER_ID, OPT_SKIP_HOST_CACHE, - OPT_SKIP_LOCK, OPT_SKIP_NEW, OPT_SKIP_PRIOR, OPT_SKIP_RESOLVE, OPT_SKIP_STACK_TRACE, - OPT_SKIP_SYMLINKS, OPT_SLOW_QUERY_LOG, OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CERT, OPT_SSL_CIPHER, OPT_SSL_KEY, - OPT_UPDATE_LOG, OPT_WANT_CORE, OPT_ENGINE_CONDITION_PUSHDOWN }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a11ba2eec49..6bd133660b3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -52,6 +52,10 @@ #include "sp_rcontext.h" #include "sp_cache.h" +#ifdef HAVE_POLL_H +#include <poll.h> +#endif + #define mysqld_charset &my_charset_latin1 /* stack traces are only supported on linux intel */ @@ -177,6 +181,9 @@ typedef fp_except fp_except_t; /* for IRIX to use set_fpc_csr() */ #include <sys/fpu.h> #endif +#ifdef HAVE_FPU_CONTROL_H +#include <fpu_control.h> +#endif #if defined(__i386__) && !defined(HAVE_FPU_CONTROL_H) # define fpu_control_t unsigned int # define _FPU_EXTENDED 0x300 @@ -4008,21 +4015,13 @@ static int init_server_components() Implementation of the above : - If mysqld is started with --log-update and --log-bin, ignore --log-update (print a warning), push a warning when SQL_LOG_UPDATE - is used, and turn off --sql-bin-update-same. + is used, This will completely ignore SQL_LOG_UPDATE - If mysqld is started with --log-update only, change it to --log-bin (with the filename passed to log-update, plus '-bin') (print a warning), push a warning when SQL_LOG_UPDATE is - used, and turn on --sql-bin-update-same. + used. This will translate SQL_LOG_UPDATE to SQL_LOG_BIN. - - Note that we tell the user that --sql-bin-update-same is deprecated and - does nothing, and we don't take into account if he used this option or - not; but internally we give this variable a value to have the behaviour - we want (i.e. have SQL_LOG_UPDATE influence SQL_LOG_BIN or not). - As sql-bin-update-same, log-update and log-bin cannot be changed by the - user after starting the server (they are not variables), the user will - not later interfere with the settings we do here. */ if (opt_bin_log) { @@ -4471,7 +4470,7 @@ static void test_lc_time_sz() #ifdef __WIN__ int win_main(int argc, char **argv) #else -int main(int argc, char **argv) +int mysqld_main(int argc, char **argv) #endif { /* @@ -5017,7 +5016,7 @@ default_service_handling(char **argv, } -int main(int argc, char **argv) +int mysqld_main(int argc, char **argv) { /* When several instances are running on the same machine, we @@ -5348,26 +5347,47 @@ void handle_connections_sockets() { my_socket sock,new_sock; uint error_count=0; - uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1); - fd_set readFDs,clientFDs; THD *thd; struct sockaddr_storage cAddr; - int ip_flags=0,socket_flags=0,flags; + int ip_flags=0,socket_flags=0,flags,retval; st_vio *vio_tmp; +#ifdef HAVE_POLL + int socket_count= 0; + struct pollfd fds[2]; // for ip_sock and unix_sock +#else + fd_set readFDs,clientFDs; + uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1); +#endif + DBUG_ENTER("handle_connections_sockets"); LINT_INIT(new_sock); +#ifndef HAVE_POLL FD_ZERO(&clientFDs); +#endif + if (ip_sock != INVALID_SOCKET) { +#ifdef HAVE_POLL + fds[socket_count].fd= ip_sock; + fds[socket_count].events= POLLIN; + socket_count++; +#else FD_SET(ip_sock,&clientFDs); +#endif #ifdef HAVE_FCNTL ip_flags = fcntl(ip_sock, F_GETFL, 0); #endif } #ifdef HAVE_SYS_UN_H +#ifdef HAVE_POLL + fds[socket_count].fd= unix_sock; + fds[socket_count].events= POLLIN; + socket_count++; +#else FD_SET(unix_sock,&clientFDs); +#endif #ifdef HAVE_FCNTL socket_flags=fcntl(unix_sock, F_GETFL, 0); #endif @@ -5377,12 +5397,15 @@ void handle_connections_sockets() MAYBE_BROKEN_SYSCALL; while (!abort_loop) { - readFDs=clientFDs; -#ifdef HPUX10 - if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0) - continue; +#ifdef HAVE_POLL + retval= poll(fds, socket_count, -1); #else - if (select((int) max_used_connection,&readFDs,0,0,0) < 0) + readFDs=clientFDs; + + retval= select((int) max_used_connection,&readFDs,0,0,0); +#endif + + if (retval < 0) { if (socket_errno != SOCKET_EINTR) { @@ -5392,7 +5415,7 @@ void handle_connections_sockets() MAYBE_BROKEN_SYSCALL continue; } -#endif /* HPUX10 */ + if (abort_loop) { MAYBE_BROKEN_SYSCALL; @@ -5400,6 +5423,21 @@ void handle_connections_sockets() } /* Is this a new connection request ? */ +#ifdef HAVE_POLL + for (int i= 0; i < socket_count; ++i) + { + if (fds[i].revents & POLLIN) + { + sock= fds[i].fd; +#ifdef HAVE_FCNTL + flags= fcntl(sock, F_GETFL, 0); +#else + flags= 0; +#endif // HAVE_FCNTL + break; + } + } +#else // HAVE_POLL #ifdef HAVE_SYS_UN_H if (FD_ISSET(unix_sock,&readFDs)) { @@ -5407,11 +5445,12 @@ void handle_connections_sockets() flags= socket_flags; } else -#endif +#endif // HAVE_SYS_UN_H { sock = ip_sock; flags= ip_flags; } +#endif // HAVE_POLL #if !defined(NO_FCNTL_NONBLOCK) if (!(test_flags & TEST_BLOCKING)) @@ -5975,12 +6014,6 @@ struct my_option my_long_options[]= 0, 0, 0}, {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).", - (uchar**) &default_character_set_name, (uchar**) &default_character_set_name, - 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"default-collation", 0, "Set the default collation (deprecated option, use --collation-server instead).", - (uchar**) &default_collation_name, (uchar**) &default_collation_name, - 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, /* default-storage-engine should have "MyISAM" as def_value. Instead of initializing it here it is done in init_common_variables() due to a compiler bug in Sun Studio compiler. */ @@ -5990,9 +6023,6 @@ struct my_option my_long_options[]= {"default-time-zone", 0, "Set the default time zone.", (uchar**) &default_tz_name, (uchar**) &default_tz_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, - "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead).", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_OPENSSL {"des-key-file", 0, "Load keys for des_encrypt() and des_encrypt from given file.", @@ -6006,10 +6036,6 @@ struct my_option my_long_options[]= (uchar**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ - {"enable-locking", 0, - "Deprecated option, use --external-locking instead.", - (uchar**) &opt_external_locking, (uchar**) &opt_external_locking, - 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_STACK_TRACE_ON_SEGV {"enable-pstack", 0, "Print a symbolic stack trace on failure.", (uchar**) &opt_do_pstack, (uchar**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, @@ -6062,9 +6088,6 @@ struct my_option my_long_options[]= {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", (uchar**) &myisam_log_filename, (uchar**) &myisam_log_filename, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"log-long-format", '0', - "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-short-format", 0, "Don't log extra information to update and slow-query logs.", (uchar**) &opt_short_log_format, (uchar**) &opt_short_log_format, @@ -6097,11 +6120,6 @@ struct my_option my_long_options[]= REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0, TC_LOG_PAGE_SIZE, 0}, #endif - {"log-update", OPT_UPDATE_LOG, - "The update log is deprecated since version 5.0, is replaced by the binary \ -log and this option justs turns on --log-bin instead.", - (uchar**) &opt_update_logname, (uchar**) &opt_update_logname, 0, GET_STR, - OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-info-file", 0, "The location and name of the file that remembers the master and where the I/O replication \ thread is in the master's binlogs.", @@ -6165,11 +6183,6 @@ Can't be set to 1 if --log-slave-updates is used.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifndef TO_BE_DELETED - {"safe-show-database", 0, - "Deprecated option; use GRANT SHOW DATABASES instead...", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#endif {"safe-user-create", 0, "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", (uchar**) &opt_safe_user_create, (uchar**) &opt_safe_user_create, 0, GET_BOOL, @@ -6182,9 +6195,6 @@ Can't be set to 1 if --log-slave-updates is used.", (uchar**)&sf_malloc_mem_limit, (uchar**)&sf_malloc_mem_limit, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"set-variable", 'O', - "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", - 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"show-slave-auth-info", 0, "Show user and password in SHOW SLAVE HOSTS on this master", (uchar**) &opt_show_slave_auth_info, (uchar**) &opt_show_slave_auth_info, 0, @@ -6197,9 +6207,6 @@ Can't be set to 1 if --log-slave-updates is used.", #endif {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-locking", OPT_SKIP_LOCK, - "Deprecated option, use --skip-external-locking instead.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-name-resolve", OPT_SKIP_RESOLVE, "Don't resolve hostnames. All hostnames are IP's or 'localhost'.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -6211,8 +6218,6 @@ Can't be set to 1 if --log-slave-updates is used.", {"skip-stack-trace", OPT_SKIP_STACK_TRACE, "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option. Use --skip-symbolic-links instead.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-thread-priority", OPT_SKIP_PRIOR, "Don't give threads different priorities. This option is deprecated " "because it has no effect; the implied behavior is already the default.", @@ -6224,10 +6229,6 @@ Can't be set to 1 if --log-slave-updates is used.", (uchar**) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ - {"sql-bin-update-same", 0, - "The update log is deprecated since version 5.0, is replaced by the " - "binary log and this option does nothing anymore.", - 0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_OPENSSL {"ssl", 0, "Enable SSL for connection (automatically enabled with other flags).", @@ -6286,20 +6287,12 @@ Can't be set to 1 if --log-slave-updates is used.", 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"warnings", 'W', "Deprecated; use --log-warnings instead.", - (uchar**) &global_system_variables.log_warnings, - (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, - 1, 0, ULONG_MAX, 0, 0, 0}, {"plugin-load", 0, "Optional semicolon-separated list of plugins to load, where each plugin is " "identified as name=library, where name is the plugin name and library " "is the plugin library in plugin_dir.", (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"record_buffer", 0, "Deprecated; use --read-buffer-size instead.", - (uchar**) &global_system_variables.read_buff_size, - (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, - 128*1024L, IO_SIZE*2, INT_MAX32, 0, IO_SIZE, 0}, {"table_cache", 0, "Deprecated; use --table-open-cache instead.", (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, @@ -7213,9 +7206,6 @@ mysqld_get_one_option(int optid, case (int) OPT_ISAM_LOG: opt_myisam_log=1; break; - case (int) OPT_UPDATE_LOG: - opt_update_log=1; - break; case (int) OPT_BIN_LOG: opt_bin_log= test(argument != disabled_my_option); break; @@ -7336,9 +7326,6 @@ mysqld_get_one_option(int optid, "and will be removed in MySQL 7.0. This option has no effect " "as the implied behavior is already the default."); break; - case (int) OPT_SKIP_LOCK: - opt_external_locking=0; - break; case (int) OPT_SKIP_HOST_CACHE: opt_specialflag|= SPECIAL_NO_HOST_CACHE; break; @@ -7351,9 +7338,6 @@ mysqld_get_one_option(int optid, case (int) OPT_SKIP_STACK_TRACE: test_flags|=TEST_NO_STACKTRACE; break; - case (int) OPT_SKIP_SYMLINKS: - my_use_symdir=0; - break; case (int) OPT_BIND_ADDRESS: { struct addrinfo *res_lst, hints; @@ -7386,12 +7370,6 @@ mysqld_get_one_option(int optid, case OPT_SERVER_ID: server_id_supplied = 1; break; - case OPT_DELAY_KEY_WRITE_ALL: - if (argument != disabled_my_option) - delay_key_write_options= DELAY_KEY_WRITE_ALL; - else - delay_key_write_options= DELAY_KEY_WRITE_NONE; - break; case OPT_ONE_THREAD: thread_handling= SCHEDULER_ONE_THREAD_PER_CONNECTION; break; @@ -7691,7 +7669,7 @@ static char *get_relative_path(const char *path) strcmp(DEFAULT_MYSQL_HOME,FN_ROOTDIR)) { path+=(uint) strlen(DEFAULT_MYSQL_HOME); - while (*path == FN_LIBCHAR) + while (*path == FN_LIBCHAR || *path == FN_LIBCHAR2) path++; } return (char*) path; diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index f41fa08f828..76dc2846ed0 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -10,6 +10,7 @@ #include <windows.h> #include <process.h> #include <stdio.h> +#include <stdlib.h> #include "nt_servc.h" diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b9ea8c7c991..68285563239 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2266,9 +2266,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, keys_to_use.intersect(head->keys_in_use_for_query); if (!keys_to_use.is_clear_all()) { -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning uchar buff[STACK_BUFF_ALLOC]; -#endif MEM_ROOT alloc; SEL_TREE *tree= NULL; KEY_PART *key_parts; diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt new file mode 100644 index 00000000000..944120cfc24 --- /dev/null +++ b/sql/share/CMakeLists.txt @@ -0,0 +1,52 @@ +# Copyright (C) 2009 Sun Microsystems, Inc +# +# 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 (dirs +danish +german +slovak +dutch +greek +norwegian +spanish +english +hungarian +norwegian-ny +swedish +italian +polish +ukrainian +japanese +portuguese +romanian +estonian +korean +russian +czech +french +serbian +) + +SET(files + errmsg-utf8.txt +) + +FOREACH (dir ${dirs}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir} + DESTINATION ${INSTALL_MYSQLSHAREDIR}) +ENDFOREACH() +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/charsets DESTINATION ${INSTALL_MYSQLSHAREDIR}) + +INSTALL(FILES ${files} DESTINATION ${INSTALL_MYSQLSHAREDIR}) diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am index 203dbe54254..da19ed1c5a7 100644 --- a/sql/share/Makefile.am +++ b/sql/share/Makefile.am @@ -15,8 +15,9 @@ ## Process this file with automake to create Makefile.in -EXTRA_DIST= errmsg-utf8.txt - +EXTRA_DIST= errmsg-utf8.txt \ + CMakeLists.txt + dist-hook: for dir in charsets @AVAILABLE_LANGUAGES@; do \ test -d $(distdir)/$$dir || mkdir $(distdir)/$$dir; \ diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index a49aab0a9ab..7ea8c75e43e 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -5018,10 +5018,8 @@ ER_UNKNOWN_STORAGE_ENGINE 42000 ger "Unbekannte Speicher-Engine '%s'" por "Motor de tabela desconhecido '%s'" spa "Desconocido motor de tabla '%s'" -# When using this error code, use ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER) -# for the message string. See, for example, code in mysql_priv.h. ER_WARN_DEPRECATED_SYNTAX - eng "'%s' is deprecated; use '%s' instead" + eng "'%s' is deprecated and will be removed in a future release. Please use %s instead" ger "'%s' ist veraltet. Bitte benutzen Sie '%s'" por "'%s' é desatualizado. Use '%s' em seu lugar" spa "'%s' está desaprobado, use '%s' en su lugar" @@ -6321,3 +6319,5 @@ ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT ER_SPATIAL_MUST_HAVE_GEOM_COL 42000 eng "A SPATIAL index may only contain a geometrical type column" +ER_TOO_LONG_INDEX_COMMENT + eng "Comment for index '%-.64s' is too long (max = %lu)" diff --git a/sql/slave.cc b/sql/slave.cc index 337117a8d86..45c73a3e190 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1602,7 +1602,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi) " to the relay log, SHOW SLAVE STATUS may be" " inaccurate"); rli->relay_log.harvest_bytes_written(&rli->log_space_total); - if (flush_master_info(mi, TRUE, FALSE)) + if (flush_master_info(mi, TRUE, TRUE)) sql_print_error("Failed to flush master info file"); delete ev; } diff --git a/sql/spatial.cc b/sql/spatial.cc index 671b8544b8a..9a31b099e92 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1612,9 +1612,8 @@ int Gis_multi_polygon::area(double *ar, const char **end_of_data) const int Gis_multi_polygon::centroid(String *result) const { uint32 n_polygons; - bool first_loop= 1; Gis_polygon p; - double UNINIT_VAR(res_area), UNINIT_VAR(res_cx), UNINIT_VAR(res_cy); + double res_area= 0.0, res_cx= 0.0, res_cy= 0.0; double cur_area, cur_cx, cur_cy; const char *data= m_data; @@ -1631,20 +1630,13 @@ int Gis_multi_polygon::centroid(String *result) const p.centroid_xy(&cur_cx, &cur_cy)) return 1; - if (!first_loop) - { - double sum_area= res_area + cur_area; - res_cx= (res_area * res_cx + cur_area * cur_cx) / sum_area; - res_cy= (res_area * res_cy + cur_area * cur_cy) / sum_area; - } - else - { - first_loop= 0; - res_area= cur_area; - res_cx= cur_cx; - res_cy= cur_cy; - } + res_area+= cur_area; + res_cx+= cur_area * cur_cx; + res_cy+= cur_area * cur_cy; } + + res_cx/= res_area; + res_cy/= res_area; return create_point(result, res_cx, res_cy); } diff --git a/sql/sql_builtin.cc.in b/sql/sql_builtin.cc.in index f8767949fe3..d9d9b610baf 100644 --- a/sql/sql_builtin.cc.in +++ b/sql/sql_builtin.cc.in @@ -17,7 +17,12 @@ typedef struct st_mysql_plugin builtin_plugin[]; -extern builtin_plugin +#ifdef _MSC_VER +extern "C" +#else +extern +#endif +builtin_plugin @mysql_mandatory_plugins@ @mysql_optional_plugins@ builtin_binlog_plugin; struct st_mysql_plugin *mysql_optional_plugins[]= @@ -29,5 +34,3 @@ struct st_mysql_plugin *mysql_mandatory_plugins[]= { builtin_binlog_plugin, @mysql_mandatory_plugins@ 0 }; - - diff --git a/sql/sql_class.h b/sql/sql_class.h index 9dfb0c8d9d4..2efff63354a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2293,7 +2293,7 @@ public: void add_changed_table(const char *key, long key_length); CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length); int send_explain_fields(select_result *result); -#ifndef EMBEDDED_LIBRARY + /** Clear the current error, if any. We do not clear is_fatal_error or is_fatal_sub_stmt_error since we @@ -2309,6 +2309,7 @@ public: is_slave_error= 0; DBUG_VOID_RETURN; } +#ifndef EMBEDDED_LIBRARY inline bool vio_ok() const { return net.vio != 0; } /** Return FALSE if connection to client is broken. */ bool is_connected() @@ -2316,7 +2317,6 @@ public: return vio_ok() ? vio_is_connected(net.vio) : FALSE; } #else - void clear_error(); inline bool vio_ok() const { return TRUE; } inline bool is_connected() { return TRUE; } #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b0d8614dc84..c7e1be2237b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5171,7 +5171,6 @@ bool check_global_access(THD *thd, ulong want_access) Check stack size; Send error if there isn't enough stack to continue ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY #if STACK_DIRECTION < 0 #define used_stack(A,B) (long) (A - B) @@ -5209,7 +5208,7 @@ bool check_stack_overrun(THD *thd, long margin, #endif return 0; } -#endif /* EMBEDDED_LIBRARY */ + #define MY_YACC_INIT 1000 // Start with big alloc #define MY_YACC_MAX 32000 // Because of 'short' diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c37aeb39f6c..468f81a7d87 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2516,9 +2516,7 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select, { int error; DBUG_ENTER("get_quick_record_count"); -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning uchar buff[STACK_BUFF_ALLOC]; -#endif if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) DBUG_RETURN(0); // Fatal error flag is set if (select) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2e1827f9a35..8b8e223ad02 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1375,7 +1375,6 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, end= longlong10_to_str(create_info.auto_increment_value, buff,10); packet->append(buff, (uint) (end - buff)); } - if (share->table_charset && !(thd->variables.sql_mode & MODE_MYSQL323) && @@ -1520,6 +1519,14 @@ static void store_key_options(THD *thd, String *packet, TABLE *table, end= longlong10_to_str(key_info->block_size, buff, 10); packet->append(buff, (uint) (end - buff)); } + DBUG_ASSERT(test(key_info->flags & HA_USES_COMMENT) == + (key_info->comment.length > 0)); + if (key_info->flags & HA_USES_COMMENT) + { + packet->append(STRING_WITH_LEN(" COMMENT ")); + append_unescaped(packet, key_info->comment.str, + key_info->comment.length); + } } } @@ -4767,6 +4774,11 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, else table->field[14]->store("", 0, cs); table->field[14]->set_notnull(); + DBUG_ASSERT(test(key_info->flags & HA_USES_COMMENT) == + (key_info->comment.length > 0)); + if (key_info->flags & HA_USES_COMMENT) + table->field[15]->store(key_info->comment.str, + key_info->comment.length, cs); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); } @@ -6725,7 +6737,8 @@ ST_FIELD_INFO tables_fields_info[]= (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE}, {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options", OPEN_FRM_ONLY}, - {"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, + {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, + "Comment", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -6759,7 +6772,8 @@ ST_FIELD_INFO columns_fields_info[]= {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY}, {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY}, - {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, + {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, + "Comment", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -6917,6 +6931,8 @@ ST_FIELD_INFO stat_fields_info[]= {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY}, {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type", OPEN_FULL_TABLE}, {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment", OPEN_FRM_ONLY}, + {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, + "Index_comment", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2e057d6a731..9acbc37fd9a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2646,6 +2646,21 @@ CHARSET_INFO* get_sql_field_charset(Create_field *sql_field, } +bool check_duplicate_warning(THD *thd, char *msg, ulong length) +{ + List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list()); + MYSQL_ERROR *err; + while ((err= it++)) + { + if (strncmp(msg, err->get_message_text(), length) == 0) + { + return true; + } + } + return false; +} + + /* Preparation for table creation @@ -3486,6 +3501,40 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length); DBUG_RETURN(TRUE); } + + uint tmp_len= system_charset_info->cset->charpos(system_charset_info, + key->key_create_info.comment.str, + key->key_create_info.comment.str + + key->key_create_info.comment.length, + INDEX_COMMENT_MAXLEN); + + if (tmp_len < key->key_create_info.comment.length) + { + if ((thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + { + my_error(ER_TOO_LONG_INDEX_COMMENT, MYF(0), + key_info->name, (uint) INDEX_COMMENT_MAXLEN); + DBUG_RETURN(-1); + } + char warn_buff[MYSQL_ERRMSG_SIZE]; + my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_INDEX_COMMENT), + key_info->name, (uint) INDEX_COMMENT_MAXLEN); + /* do not push duplicate warnings */ + if (!check_duplicate_warning(thd, warn_buff, strlen(warn_buff))) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_LONG_INDEX_COMMENT, warn_buff); + + key->key_create_info.comment.length= tmp_len; + } + + key_info->comment.length= key->key_create_info.comment.length; + if (key_info->comment.length > 0) + { + key_info->flags|= HA_USES_COMMENT; + key_info->comment.str= key->key_create_info.comment.str; + } + key_info++; } if (!unique_key && !primary_key && @@ -6196,6 +6245,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, key_create_info.block_size= key_info->block_size; if (key_info->flags & HA_USES_PARSER) key_create_info.parser_name= *plugin_name(key_info->parser); + if (key_info->flags & HA_USES_COMMENT) + key_create_info.comment= key_info->comment; if (key_info->flags & HA_SPATIAL) key_type= Key::SPATIAL; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 34361ab3f99..f03694cb359 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -968,7 +968,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token FOREIGN /* SQL-2003-R */ %token FOR_SYM /* SQL-2003-R */ %token FOUND_SYM /* SQL-2003-R */ -%token FRAC_SECOND_SYM %token FROM %token FULL /* SQL-2003-R */ %token FULLTEXT_SYM @@ -1494,8 +1493,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %type <date_time_type> date_time_type; %type <interval> interval -%type <interval_time_st> interval_time_st - %type <interval_time_st> interval_time_stamp %type <db_type> storage_engines known_storage_engines @@ -6063,6 +6060,7 @@ key_using_alg: all_key_opt: KEY_BLOCK_SIZE opt_equal ulong_num { Lex->key_create_info.block_size= $3; } + | COMMENT_SYM TEXT_STRING_sys { Lex->key_create_info.comment= $2; } ; normal_key_opt: @@ -9534,7 +9532,7 @@ using_list: ; interval: - interval_time_st {} + interval_time_stamp {} | DAY_HOUR_SYM { $$=INTERVAL_DAY_HOUR; } | DAY_MICROSECOND_SYM { $$=INTERVAL_DAY_MICROSECOND; } | DAY_MINUTE_SYM { $$=INTERVAL_DAY_MINUTE; } @@ -9549,27 +9547,6 @@ interval: ; interval_time_stamp: - interval_time_st {} - | FRAC_SECOND_SYM - { - $$=INTERVAL_MICROSECOND; - /* - FRAC_SECOND was mistakenly implemented with - a wrong resolution. According to the ODBC - standard it should be nanoseconds, not - microseconds. Changing it to nanoseconds - in MySQL would mean making TIMESTAMPDIFF - and TIMESTAMPADD to return DECIMAL, since - the return value would be too big for BIGINT - Hence we just deprecate the incorrect - implementation without changing its - resolution. - */ - WARN_DEPRECATED(yythd, 6, 2, "FRAC_SECOND", "MICROSECOND"); - } - ; - -interval_time_st: DAY_SYM { $$=INTERVAL_DAY; } | WEEK_SYM { $$=INTERVAL_WEEK; } | HOUR_SYM { $$=INTERVAL_HOUR; } @@ -12306,7 +12283,6 @@ keyword_sp: | FILE_SYM {} | FIRST_SYM {} | FIXED_SYM {} - | FRAC_SECOND_SYM {} | GEOMETRY_SYM {} | GEOMETRYCOLLECTION {} | GET_FORMAT {} diff --git a/sql/structs.h b/sql/structs.h index 041a6809804..6d2cf54d693 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -102,6 +102,7 @@ typedef struct st_key { int bdb_return_if_eq; } handler; TABLE *table; + LEX_STRING comment; } KEY; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 4575ca79049..ba970925fc6 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2205,30 +2205,6 @@ static Sys_var_bit Sys_log_binlog( DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super), ON_UPDATE(fix_sql_log_bin)); -static bool deprecated_log_update(sys_var *self, THD *thd, set_var *var) -{ - /* - The update log is not supported anymore since 5.0. - See sql/mysqld.cc/, comments in function init_server_components() for an - explaination of the different warnings we send below - */ - - if (opt_sql_bin_update) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_UPDATE_LOG_DEPRECATED_TRANSLATED, - ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED)); - else - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_UPDATE_LOG_DEPRECATED_IGNORED, - ER(ER_UPDATE_LOG_DEPRECATED_IGNORED)); - return check_has_super(self, thd, var); -} -static Sys_var_bit Sys_log_update( - "sql_log_update", "alias for sql_log_bin", - SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_BIN_LOG, - DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, - ON_CHECK(deprecated_log_update), ON_UPDATE(fix_sql_log_bin)); - static Sys_var_bit Sys_sql_warnings( "sql_warnings", "sql_warnings", SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_WARNINGS, diff --git a/sql/table.cc b/sql/table.cc index 514ea865e8c..0e66ff9da94 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -517,7 +517,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) int error, table_type; bool error_given; File file; - uchar head[288], *disk_buff; + uchar head[64], *disk_buff; char path[FN_REFLEN]; MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("open_table_def"); @@ -660,6 +660,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, uint i,j; bool use_hash; char *keynames, *names, *comment_pos; + uchar forminfo[288]; uchar *record; uchar *disk_buff, *strpos, *null_flags, *null_pos; ulong pos, record_offset, *rec_per_key, rec_buff_length; @@ -682,6 +683,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (!(pos=get_form_pos(file,head,(TYPELIB*) 0))) goto err; /* purecov: inspected */ + mysql_file_seek(file,pos,MY_SEEK_SET,MYF(0)); + if (mysql_file_read(file, forminfo,288,MYF(MY_NABP))) + goto err; share->frm_version= head[2]; /* Check if .frm file created by MySQL 5.0. In this case we want to @@ -827,6 +831,20 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, keynames=(char*) key_part; strpos+= (strmov(keynames, (char *) strpos) - keynames)+1; + //reading index comments + for (keyinfo= share->key_info, i=0; i < keys; i++, keyinfo++) + { + if (keyinfo->flags & HA_USES_COMMENT) + { + keyinfo->comment.length= uint2korr(strpos); + keyinfo->comment.str= strmake_root(&share->mem_root, (char*) strpos+2, + keyinfo->comment.length); + strpos+= 2 + keyinfo->comment.length; + } + DBUG_ASSERT(test(keyinfo->flags & HA_USES_COMMENT) == + (keyinfo->comment.length > 0)); + } + share->reclength = uint2korr((head+16)); if (*(head+26) == 1) share->system= 1; /* one-record-database */ @@ -1007,6 +1025,25 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } } } + if (forminfo[46] == (uchar)255) + { + //reading long table comment + if (next_chunk + 2 > buff_end) + { + DBUG_PRINT("error", + ("long table comment is not defined in .frm")); + my_free(buff, MYF(0)); + goto err; + } + share->comment.length = uint2korr(next_chunk); + if (! (share->comment.str= strmake_root(&share->mem_root, + (char*)next_chunk + 2, share->comment.length))) + { + my_free(buff, MYF(0)); + goto err; + } + next_chunk+= 2 + share->comment.length; + } my_free(buff, MYF(0)); } share->key_block_size= uint2korr(head+62); @@ -1023,29 +1060,30 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, record_offset, MYF(MY_NABP))) goto err; /* purecov: inspected */ - mysql_file_seek(file, pos, MY_SEEK_SET, MYF(0)); - if (mysql_file_read(file, head, 288, MYF(MY_NABP))) - goto err; + mysql_file_seek(file, pos+288, MY_SEEK_SET, MYF(0)); #ifdef HAVE_CRYPTED_FRM if (crypted) { - crypted->decode((char*) head+256,288-256); - if (sint2korr(head+284) != 0) // Should be 0 + crypted->decode((char*) forminfo+256,288-256); + if (sint2korr(forminfo+284) != 0) // Should be 0 goto err; // Wrong password } #endif - share->fields= uint2korr(head+258); - pos= uint2korr(head+260); /* Length of all screens */ - n_length= uint2korr(head+268); - interval_count= uint2korr(head+270); - interval_parts= uint2korr(head+272); - int_length= uint2korr(head+274); - share->null_fields= uint2korr(head+282); - com_length= uint2korr(head+284); - share->comment.length= (int) (head[46]); - share->comment.str= strmake_root(&share->mem_root, (char*) head+47, - share->comment.length); + share->fields= uint2korr(forminfo+258); + pos= uint2korr(forminfo+260); /* Length of all screens */ + n_length= uint2korr(forminfo+268); + interval_count= uint2korr(forminfo+270); + interval_parts= uint2korr(forminfo+272); + int_length= uint2korr(forminfo+274); + share->null_fields= uint2korr(forminfo+282); + com_length= uint2korr(forminfo+284); + if (forminfo[46] != (uchar)255) + { + share->comment.length= (int) (forminfo[46]); + share->comment.str= strmake_root(&share->mem_root, (char*) forminfo+47, + share->comment.length); + } DBUG_PRINT("info",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d com_length: %d", interval_count,interval_parts, share->keys,n_length,int_length, com_length)); @@ -2437,12 +2475,14 @@ void append_unescaped(String *res, const char *pos, uint length) File create_frm(THD *thd, const char *name, const char *db, const char *table, uint reclength, uchar *fileinfo, - HA_CREATE_INFO *create_info, uint keys) + HA_CREATE_INFO *create_info, uint keys, KEY *key_info) { register File file; ulong length; uchar fill[IO_SIZE]; int create_flags= O_RDWR | O_TRUNC; + ulong key_comment_total_bytes= 0; + uint i; if (create_info->options & HA_LEX_CREATE_TMP_TABLE) create_flags|= O_EXCL | O_NOFOLLOW; @@ -2479,7 +2519,17 @@ File create_frm(THD *thd, const char *name, const char *db, 1 byte for the NAMES_SEP_CHAR (after the last name) 9 extra bytes (padding for safety? alignment?) */ - key_length= keys * (8 + MAX_REF_PARTS * 9 + NAME_LEN + 1) + 16; + for (i= 0; i < keys; i++) + { + DBUG_ASSERT(test(key_info[i].flags & HA_USES_COMMENT) == + (key_info[i].comment.length > 0)); + if (key_info[i].flags & HA_USES_COMMENT) + key_comment_total_bytes += 2 + key_info[i].comment.length; + } + + key_length= keys * (8 + MAX_REF_PARTS * 9 + NAME_LEN + 1) + 16 + + key_comment_total_bytes; + length= next_io_size((ulong) (IO_SIZE+key_length+reclength+ create_info->extra_size)); int4store(fileinfo+10,length); diff --git a/sql/unireg.cc b/sql/unireg.cc index b20e759efbb..c7d2f2f5b5b 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -188,27 +188,6 @@ bool mysql_create_frm(THD *thd, const char *file_name, if (key_info[i].parser_name) create_info->extra_size+= key_info[i].parser_name->length + 1; } - - if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo, - create_info, keys)) < 0) - { - my_free(screen_buff, MYF(0)); - DBUG_RETURN(1); - } - - key_buff_length= uint4korr(fileinfo+47); - keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); - key_info_length= pack_keys(keybuff, keys, key_info, data_offset); - (void) get_form_pos(file,fileinfo,&formnames); - if (!(filepos=make_new_entry(file,fileinfo,&formnames,""))) - goto err; - maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000)); - int2store(forminfo+2,maxlength); - int4store(fileinfo+10,(ulong) (filepos+maxlength)); - fileinfo[26]= (uchar) test((create_info->max_rows == 1) && - (create_info->min_rows == 1) && (keys == 0)); - int2store(fileinfo+28,key_info_length); - /* This gives us the byte-position of the character at (character-position, not byte-position) TABLE_COMMENT_MAXLEN. @@ -222,33 +201,78 @@ bool mysql_create_frm(THD *thd, const char *file_name, string), the string is too long. For additional credit, realise that UTF-8 has 1-3 bytes before 6.0, - and 1-4 bytes in 6.0 (6.0 also has UTF-32). This means that the - inlined COMMENT supposedly does not exceed 60 character plus - terminator, vulgo, 181 bytes. + and 1-4 bytes in 6.0 (6.0 also has UTF-32). */ - tmp_len= system_charset_info->cset->charpos(system_charset_info, create_info->comment.str, create_info->comment.str + - create_info->comment.length, 60); + create_info->comment.length, + TABLE_COMMENT_MAXLEN); + if (tmp_len < create_info->comment.length) { + char *real_table_name= (char*) table; + List_iterator<Create_field> it(create_fields); + Create_field *field; + while ((field=it++)) + { + if (field->field && field->field->table && + (real_table_name= field->field->table->s->table_name.str)) + break; + } if ((thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) { - my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len); - goto err; + my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), + real_table_name, (uint) TABLE_COMMENT_MAXLEN); + my_free(screen_buff,MYF(0)); + DBUG_RETURN(1); } - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_TOO_LONG_TABLE_COMMENT, - ER(ER_TOO_LONG_TABLE_COMMENT), - table, tmp_len); + char warn_buff[MYSQL_ERRMSG_SIZE]; + my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_TABLE_COMMENT), + real_table_name, (uint) TABLE_COMMENT_MAXLEN); + /* do not push duplicate warnings */ + if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff))) + push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_LONG_TABLE_COMMENT, warn_buff); create_info->comment.length= tmp_len; } + /* + If table comment is longer than TABLE_COMMENT_INLINE_MAXLEN bytes, + store the comment in an extra segment (up to TABLE_COMMENT_MAXLEN bytes). + Pre 6.0, the limit was 60 characters, with no extra segment-handling. + */ + if (create_info->comment.length > TABLE_COMMENT_INLINE_MAXLEN) + { + forminfo[46]=255; + create_info->extra_size+= 2 + create_info->comment.length; + } + else{ + strmake((char*) forminfo+47, create_info->comment.str ? + create_info->comment.str : "", create_info->comment.length); + forminfo[46]=(uchar) create_info->comment.length; + } + + if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo, + create_info, keys, key_info)) < 0) + { + my_free(screen_buff, MYF(0)); + DBUG_RETURN(1); + } + + key_buff_length= uint4korr(fileinfo+47); + keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); + key_info_length= pack_keys(keybuff, keys, key_info, data_offset); + (void) get_form_pos(file,fileinfo,&formnames); + if (!(filepos=make_new_entry(file,fileinfo,&formnames,""))) + goto err; + maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000)); + int2store(forminfo+2,maxlength); + int4store(fileinfo+10,(ulong) (filepos+maxlength)); + fileinfo[26]= (uchar) test((create_info->max_rows == 1) && + (create_info->min_rows == 1) && (keys == 0)); + int2store(fileinfo+28,key_info_length); - strmake((char*) forminfo+47, create_info->comment.str ? - create_info->comment.str : "", create_info->comment.length); - forminfo[46]=(uchar) create_info->comment.length; #ifdef WITH_PARTITION_STORAGE_ENGINE if (part_info) { @@ -309,6 +333,15 @@ bool mysql_create_frm(THD *thd, const char *file_name, goto err; } } + if (forminfo[46] == (uchar)255) + { + uchar comment_length_buff[2]; + int2store(comment_length_buff,create_info->comment.length); + if (mysql_file_write(file, comment_length_buff, 2, MYF(MY_NABP)) || + mysql_file_write(file, (uchar*) create_info->comment.str, + create_info->comment.length, MYF(MY_NABP))) + goto err; + } mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0)); if (mysql_file_write(file, forminfo, 288, MYF_RW) || @@ -561,6 +594,16 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, pos=tmp; } *(pos++)=0; + for (key=keyinfo,end=keyinfo+key_count ; key != end ; key++) + { + if (key->flags & HA_USES_COMMENT) + { + int2store(pos, key->comment.length); + uchar *tmp= (uchar*)strnmov((char*) pos+2,key->comment.str, + key->comment.length); + pos= tmp; + } + } if (key_count > 127 || key_parts > 127) { @@ -614,19 +657,23 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, field->comment.str, field->comment.str + field->comment.length, - 255); + COLUMN_COMMENT_MAXLEN); if (tmp_len < field->comment.length) { if ((current_thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) { - my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len); + my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), + field->field_name, (uint) COLUMN_COMMENT_MAXLEN); DBUG_RETURN(1); } - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_TOO_LONG_FIELD_COMMENT, - ER(ER_TOO_LONG_FIELD_COMMENT), - field->field_name, tmp_len); + char warn_buff[MYSQL_ERRMSG_SIZE]; + my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_FIELD_COMMENT), + field->field_name, (uint) COLUMN_COMMENT_MAXLEN); + /* do not push duplicate warnings */ + if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff))) + push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_LONG_FIELD_COMMENT, warn_buff); field->comment.length= tmp_len; } |