diff --git a/CMakeLists.txt b/CMakeLists.txt index 192b745c4e2..e1129dc5cda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,6 @@ ENDIF() INCLUDE(maintainer) SET(MYSQL_MAINTAINER_MODE "OFF" CACHE STRING "MySQL maintainer-specific development environment. Options are: ON OFF AUTO.") -MARK_AS_ADVANCED(MYSQL_MAINTAINER_MODE) # Whether the maintainer mode compiler options should be enabled. IF(CMAKE_C_COMPILER_ID MATCHES "GNU") @@ -168,13 +167,12 @@ IF(DISABLE_SHARED) ENDIF() OPTION(ENABLED_PROFILING "Enable profiling" ON) OPTION(CYBOZU "" OFF) -OPTION(BACKUP_TEST "" OFF) -OPTION(WITHOUT_SERVER OFF) +OPTION(WITHOUT_SERVER "Build only the client library and clients" OFF) IF(UNIX) OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) ENDIF() OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) -MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) +MARK_AS_ADVANCED(CYBOZU) OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF) @@ -272,7 +270,6 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3") OPTION(ENABLED_LOCAL_INFILE "If we should should enable LOAD DATA LOCAL by default" ${IF_WIN}) -MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE) OPTION(WITH_FAST_MUTEXES "Compile with fast mutexes" OFF) MARK_AS_ADVANCED(WITH_FAST_MUTEXES) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 85ec0480a40..6673cdc438c 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -46,8 +46,6 @@ SET(FEATURE_SET_large 5) SET(FEATURE_SET_xlarge 6) SET(FEATURE_SET_community 7) -#SET(WITH_CASSANDRA_STORAGE_ENGINE ON) - IF(FEATURE_SET) STRING(TOLOWER ${FEATURE_SET} feature_set) SET(num ${FEATURE_SET_${feature_set}}) @@ -56,7 +54,7 @@ IF(FEATURE_SET) Should be xsmall, small, classic, large, or community ") ENDIF() - SET(WITH_PARTITION_STORAGE_ENGINE OFF) + SET(PLUGIN_PARTITION "NO") IF(num EQUAL FEATURE_SET_xsmall) SET(WITH_NONE ON) ENDIF() @@ -65,34 +63,23 @@ IF(FEATURE_SET) SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "") ENDIF() IF(num GREATER FEATURE_SET_small) - SET(WITH_ARCHIVE_STORAGE_ENGINE ON) - SET(WITH_BLACKHOLE_STORAGE_ENGINE ON) - SET(WITH_FEDERATEDX_STORAGE_ENGINE ON) - SET(WITH_PLUGIN_FEEDBACK ON) + SET(PLUGIN_ARCHIVE "STATIC") + SET(PLUGIN_BLACKHOLE "STATIC") + SET(PLUGIN_FEDERATEDX "STATIC") + SET(PLUGIN_FEEDBACK "STATIC") ENDIF() IF(num GREATER FEATURE_SET_classic) - SET(WITH_INNOBASE_STORAGE_ENGINE ON) + SET(PLUGIN_INNOBASE "STATIC") ENDIF() IF(num GREATER FEATURE_SET_large) - SET(WITH_PARTITION_STORAGE_ENGINE ON) + SET(PLUGIN_PARTITION "STATIC") + #SET(PLUGIN_CASSANDRA "STATIC") ENDIF() IF(num GREATER FEATURE_SET_xlarge) # OPTION(WITH_ALL ON) # better no set this, otherwise server would be linked # statically with experimental stuff like audit_null ENDIF() - - # Update cache with current values, remove engines we do not care about - # from build. - FOREACH(eng ARCHIVE BLACKHOLE FEDERATED INNOBASE PARTITION) - IF(NOT WITH_${eng}_STORAGE_ENGINE) - SET(WITHOUT_${eng}_STORAGE_ENGINE ON CACHE BOOL "") - MARK_AS_ADVANCED(WITHOUT_${eng}_STORAGE_ENGINE) - SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "") - ELSE() - SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "") - ENDIF() - ENDFOREACH() ENDIF() OPTION(ENABLED_LOCAL_INFILE "" ON) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index ee345b177bd..bd834ece4b0 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -312,7 +312,7 @@ FUNCTION(INSTALL_DEBUG_TARGET target) MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET") ENDIF() GET_TARGET_PROPERTY(target_location ${target} LOCATION) - IF(CMAKE_GENERATOR MATCHES "Makefiles") + IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}") ELSE() STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" ) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 6f3dec4619a..b550695b796 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -29,11 +29,11 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) MACRO(MYSQL_ADD_PLUGIN) MYSQL_PARSE_ARGUMENTS(ARG - "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG" + "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG;ONLY_IF" "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED" ${ARGN} ) - + # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql @@ -47,45 +47,58 @@ MACRO(MYSQL_ADD_PLUGIN) STRING(TOUPPER ${plugin} plugin) STRING(TOLOWER ${plugin} target) - # Figure out whether to build plugin - IF(WITH_PLUGIN_${plugin}) - SET(WITH_${plugin} 1) - ENDIF() + IF (ARG_MANDATORY) + UNSET(PLUGIN_${plugin} CACHE) + SET(PLUGIN_${plugin} "YES") + ELSE() + SET (compat ".") + # Figure out whether to build plugin. + # recognize and support the maze of old WITH/WITHOUT combinations + IF(WITHOUT_${plugin}_STORAGE_ENGINE + OR WITHOUT_${plugin} + OR WITHOUT_PLUGIN_${plugin} + OR WITH_NONE) - IF(WITH_MAX_NO_NDB) - SET(WITH_MAX 1) - SET(WITHOUT_NDBCLUSTER 1) - ENDIF() - - IF(ARG_DEFAULT) - IF(NOT DEFINED WITH_${plugin} AND - NOT DEFINED WITH_${plugin}_STORAGE_ENGINE) - SET(WITH_${plugin} 1) + SET(compat "${compat}without") ENDIF() - ENDIF() - - IF(WITH_${plugin}_STORAGE_ENGINE - OR WITH_{$plugin} - OR WITH_ALL - OR WITH_MAX - AND NOT WITHOUT_${plugin}_STORAGE_ENGINE - AND NOT WITHOUT_${plugin} - AND NOT ARG_MODULE_ONLY) - - SET(WITH_${plugin} 1) - ELSEIF(WITHOUT_${plugin} OR WITHOUT_${plugin}_STORAGE_ENGINE OR - WITH_NONE OR ${plugin}_DISABLED) - SET(WITHOUT_${plugin} 1) - SET(WITH_${plugin}_STORAGE_ENGINE 0) - SET(WITH_${plugin} 0) - ENDIF() - - - IF(ARG_MANDATORY) - SET(WITH_${plugin} 1) + IF(WITH_${plugin}_STORAGE_ENGINE + OR WITH_${plugin} + OR WITH_PLUGIN_${plugin} + OR WITH_ALL + OR WITH_MAX + OR WITH_MAX_NO_NDB + OR ARG_DEFAULT) + + SET(compat "with${compat}") + ENDIF() + + IF (compat STREQUAL ".") + SET(howtobuild DYNAMIC) + ELSEIF (compat STREQUAL "with.") + IF (NOT ARG_MODULE_ONLY) + SET(howtobuild STATIC) + ELSE() + SET(howtobuild DYNAMIC) + ENDIF() + ELSEIF (compat STREQUAL ".without") + SET(howtobuild NO) + ELSEIF (compat STREQUAL "with.without") + SET(howtobuild STATIC) + ENDIF() + + # NO - not at all + # YES - static if possible, otherwise dynamic if possible, otherwise abort + # AUTO - static if possible, otherwise dynamic, if possible + # STATIC - static if possible, otherwise not at all + # DYNAMIC - dynamic if possible, otherwise not at all + SET(PLUGIN_${plugin} ${howtobuild} + CACHE STRING "How to build plugin ${plugin}. Options are: NO STATIC DYNAMIC YES AUTO.") + ENDIF() + + IF (NOT PLUGIN_${plugin} MATCHES "^(NO|YES|AUTO|STATIC|DYNAMIC)$") + MESSAGE(FATAL_ERROR "Invalid value for PLUGIN_${plugin}") ENDIF() - IF(ARG_STORAGE_ENGINE) SET(with_var "WITH_${plugin}_STORAGE_ENGINE" ) ELSE() @@ -95,7 +108,6 @@ MACRO(MYSQL_ADD_PLUGIN) IF(NOT ARG_DEPENDENCIES) SET(ARG_DEPENDENCIES) ENDIF() - SET(BUILD_PLUGIN 1) IF(NOT ARG_MODULE_OUTPUT_NAME) IF(ARG_STORAGE_ENGINE) @@ -105,10 +117,15 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() ENDIF() - # Build either static library or module - IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY) + IF(ARG_ONLY_IF AND NOT ${ARG_ONLY_IF}) + SET(ARG_DISABLED 1) + ENDIF() - IF(CMAKE_GENERATOR MATCHES "Makefiles") + # Build either static library or module + IF (PLUGIN_${plugin} MATCHES "(STATIC|AUTO|YES)" AND NOT ARG_MODULE_ONLY + AND NOT ARG_DISABLED) + + IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") # If there is a shared library from previous shared build, # remove it. This is done just for mysql-test-run.pl # so it does not try to use stale shared lib as plugin @@ -142,17 +159,15 @@ MACRO(MYSQL_ADD_PLUGIN) OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME}) ENDIF() + IF(ARG_LINK_LIBRARIES) + TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) + ENDIF() + # Update mysqld dependencies SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS} ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE) - IF(ARG_MANDATORY) - SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" - FORCE) - ELSE() - SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server" - FORCE) - ENDIF() + SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" FORCE) IF(ARG_MANDATORY) SET (mysql_mandatory_plugins @@ -163,14 +178,16 @@ MACRO(MYSQL_ADD_PLUGIN) "${mysql_optional_plugins} builtin_maria_${target}_plugin,") SET (mysql_optional_plugins ${mysql_optional_plugins} PARENT_SCOPE) ENDIF() - ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS) - + ELSEIF(PLUGIN_${plugin} MATCHES "(DYNAMIC|AUTO|YES)" + AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS + AND NOT ARG_DISABLED) + ADD_VERSION_INFO(${target} MODULE SOURCES) ADD_LIBRARY(${target} MODULE ${SOURCES}) DTRACE_INSTRUMENT(${target}) SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "" COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN") - TARGET_LINK_LIBRARIES (${target} mysqlservices) + TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES}) # Plugin uses symbols defined in mysqld executable. # Some operating systems like Windows and OSX and are pretty strict about @@ -180,15 +197,12 @@ MACRO(MYSQL_ADD_PLUGIN) # Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate # an additional dependency. IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") - TARGET_LINK_LIBRARIES (${target} mysqld ${ARG_LINK_LIBRARIES}) + TARGET_LINK_LIBRARIES (${target} mysqld) ENDIF() ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) - IF(NOT ARG_MODULE_ONLY) - # set cached variable, e.g with checkbox in GUI - SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server" - FORCE) - ENDIF() + UNSET(${with_var} CACHE) + SET_TARGET_PROPERTIES(${target} PROPERTIES OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}") # Install dynamic library @@ -213,18 +227,8 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT}) #INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT}) - ELSE() - IF(WITHOUT_${plugin}) - # Update cache variable - STRING(REPLACE "WITH_" "WITHOUT_" without_var ${with_var}) - SET(${without_var} ON CACHE BOOL "Don't build ${plugin}" - FORCE) - ENDIF() - SET(BUILD_PLUGIN 0) - ENDIF() - - IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) + ELSEIF(PLUGIN_${plugin} MATCHES "YES") + MESSAGE(FATAL_ERROR "Plugin ${plugin} cannot be built") ENDIF() GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 2a8d1f17fbc..949f39f66c2 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -152,6 +152,8 @@ MACRO (MYSQL_CHECK_SSL) FIND_LIBRARY(CRYPTO_LIBRARY NAMES crypto libeay32 HINTS ${OPENSSL_ROOT_DIR}/lib) + MARK_AS_ADVANCED(CRYPTO_LIBRARY OPENSSL_LIBRARIES OPENSSL_ROOT_DIR + OPENSSL_INCLUDE_DIR) IF (WITH_SSL_PATH) LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) ENDIF() diff --git a/config.h.cmake b/config.h.cmake index c48d17fada0..f7a5451c9a8 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -526,7 +526,6 @@ #cmakedefine ENABLED_LOCAL_INFILE 1 #cmakedefine ENABLED_PROFILING 1 #cmakedefine EXTRA_DEBUG 1 -#cmakedefine BACKUP_TEST 1 #cmakedefine CYBOZU 1 #cmakedefine USE_SYMDIR 1 diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index cf3a35cb1dd..50db83f2777 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -72,7 +72,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ENDIF() ENDIF() -IF(WITH_INNOBASE_STORAGE_ENGINE) +IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE) # Add path to the InnoDB headers INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include) # We use the InnoDB code directly in case the code changes. diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index bb6fdd69206..c2d44bf4db1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1900,7 +1900,7 @@ sub collect_mysqld_features { # they are listed in the --help output as # --archive[=name] Enable or disable ARCHIVE plugin. Possible values are ON, OFF, FORCE (don't start if the plugin fails to load). push @optional_plugins, $1 - if /^ --([-a-z0-9]+)\[=name\] +Enable or disable \w+ plugin. Possible values are ON, OFF, FORCE/; + if /^ --([-a-z0-9]+)\[=name\] +Enable or disable \w+ plugin. One of: ON, OFF, FORCE/; next; } diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 3a6fa9a4673..a99aed61cd9 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -656,7 +656,7 @@ test.t2 984116287 drop table t1, t2; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_unequal +myisam_stats_method NULLS_UNEQUAL create table t1 (a int, key(a)); insert into t1 values (0),(1),(2),(3),(4); insert into t1 select NULL from t1; @@ -677,7 +677,7 @@ t1 1 a 1 a A 10 NULL NULL YES BTREE set myisam_stats_method=nulls_equal; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_equal +myisam_stats_method NULLS_EQUAL insert into t1 values (11); delete from t1 where a=11; analyze table t1; @@ -697,7 +697,7 @@ t1 1 a 1 a A 5 NULL NULL YES BTREE set myisam_stats_method=DEFAULT; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_unequal +myisam_stats_method NULLS_UNEQUAL insert into t1 values (11); delete from t1 where a=11; analyze table t1; @@ -718,7 +718,7 @@ drop table t1; set myisam_stats_method=nulls_ignored; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_ignored +myisam_stats_method NULLS_IGNORED create table t1 ( a char(3), b char(4), c char(5), d char(6), key(a,b,c,d) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 6641f359553..fbb1ec4b0a9 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -39,8 +39,7 @@ The following options may be given as the first argument: increase this to get more performance --binlog-checksum=name Type of BINLOG_CHECKSUM_ALG. Include checksum for log - events in the binary log. Possible values are NONE and - CRC32; default is NONE. + events in the binary log. One of: NONE, CRC32 --binlog-commit-wait-count=# If non-zero, binlog write will wait at most binlog_commit_wait_usec microseconds for at least this @@ -71,10 +70,7 @@ The following options may be given as the first argument: statements where only row-based is correct: those which involve user-defined functions (i.e. UDFs) or the UUID() function; for those, row-based binary logging is - automatically used. If NDBCLUSTER is enabled and - binlog-format is MIXED, the format switches to row-based - and back implicitly per each query accessing an - NDBCLUSTER table + automatically used. --binlog-ignore-db=name Tells the master that updates to the given database should not be logged to the binary log. @@ -114,11 +110,11 @@ The following options may be given as the first argument: --collation-server=name Set the default collation. --completion-type=name - The transaction completion type, one of NO_CHAIN, CHAIN, + The transaction completion type. One of: NO_CHAIN, CHAIN, RELEASE --concurrent-insert[=name] - Use concurrent insert with MyISAM. Possible values are - NEVER, AUTO, ALWAYS + Use concurrent insert with MyISAM. One of: NEVER, AUTO, + ALWAYS --console Write error output on screen; don't remove the console window on windows. --core-file Write core on errors. @@ -137,9 +133,8 @@ The following options may be given as the first argument: Short timeout for the two-step deadlock detection (in microseconds) --default-regex-flags=name - Default flags for the regex library. Syntax: - default-regex-flags='[flag[,flag[,flag...]]]'. See the - manual for the complete list of valid flags + Default flags for the regex library. Any combination of: + DOTALL, DUPNAMES, EXTENDED, EXTRA, MULTILINE, UNGREEDY --default-storage-engine=name The default storage engine for new tables --default-time-zone=name @@ -150,7 +145,7 @@ The following options may be given as the first argument: --default-week-format=# The default week format used by WEEK() functions --delay-key-write[=name] - Type of DELAY_KEY_WRITE + Type of DELAY_KEY_WRITE. One of: OFF, ON, ALL --delayed-insert-limit=# After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT @@ -252,7 +247,7 @@ The following options may be given as the first argument: (unless the user has SUPER privilege) --init-file=name Read SQL commands from this file at startup --init-rpl-role=name - Set the replication role. + Set the replication role. One of: MASTER, SLAVE --init-slave=name Command(s) that are executed by a slave server each time the SQL thread starts --interactive-timeout=# @@ -329,8 +324,8 @@ The following options may be given as the first argument: not specified then 'datadir'/'log-basename'.err or the 'pid-file' path with extension .err is used --log-isam[=name] Log all MyISAM changes to file. - --log-output=name Syntax: log-output=value[,value...], where "value" could - be TABLE, FILE or NONE + --log-output=name How logs should be written. Any combination of: NONE, + FILE, TABLE --log-queries-not-using-indexes Log queries that are executed without benefit of any index to the slow log if it is open @@ -343,10 +338,9 @@ The following options may be given as the first argument: Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open. --log-slow-filter=name - Log only certain types of queries. Multiple flags can be - specified, separated by commas. Valid values are admin, - slave, filesort, filesort_on_disk, full_join, full_scan, - query_cache, query_cache_miss, tmp_table, + Log only certain types of queries. Any combination of: + admin, filesort, filesort_on_disk, full_join, full_scan, + query_cache, query_cache_miss, tmp_table, tmp_table_on_disk --log-slow-rate-limit=# Write to slow log every #th slow query. Set to 1 to log @@ -356,8 +350,8 @@ The following options may be given as the first argument: Log slow statements executed by slave thread to the slow log if it is open. --log-slow-verbosity=name - log-slow-verbosity=[value[,value ...]] where value is one - of 'innodb', 'query_plan', 'explain' + Verbosity level for the slow log. Any combination of: + innodb, query_plan, explain --log-tc=name Path to transaction coordinator log (used for transactions that affect more than one storage engine, when binary log is disabled). @@ -458,9 +452,9 @@ The following options may be given as the first argument: Restricts the total memory used for memory mapping of MySQL tables --myisam-recover-options[=name] - Syntax: myisam-recover-options[=option[,option...]], - where option can be DEFAULT, BACKUP, BACKUP_ALL, FORCE, - QUICK, or OFF + Specifies how corrupted tables should be automatically + repaired. Any combination of: DEFAULT, BACKUP, FORCE, + QUICK, BACKUP_ALL, OFF --myisam-repair-threads=# If larger than 1, when repairing a MyISAM table all indexes will be created in parallel, with one thread per @@ -489,8 +483,9 @@ The following options may be given as the first argument: See also --old-mode --old-alter-table Use old, non-optimized alter table --old-mode=name Used to emulate old behavior from earlier MariaDB or - MySQL versions. Syntax: old_mode=mode[,mode[,mode...]]. - See the manual for the complete list of valid old modes + MySQL versions. Any combination of: + NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO, + ZERO_DATE_TIME_CAST --old-passwords Use old password encryption method (needed for 4.0 and older clients) --old-style-user-limits @@ -524,19 +519,20 @@ The following options may be given as the first argument: Controls number of record samples to check condition selectivity --optimizer-switch=name - optimizer_switch=option=val[,option=val...], where option - is one of {derived_merge, derived_with_keys, firstmatch, - in_to_exists, engine_condition_pushdown, - index_condition_pushdown, index_merge, - index_merge_intersection, index_merge_sort_intersection, - index_merge_sort_union, index_merge_union, - join_cache_bka, join_cache_hashed, - join_cache_incremental, loosescan, materialization, mrr, - mrr_cost_based, mrr_sort_keys, optimize_join_buffer_size, - outer_join_with_cache, partial_match_rowid_merge, - partial_match_table_scan, semijoin, semijoin_with_cache, - subquery_cache, table_elimination, extended_keys, - exists_to_in } and val is one of {on, off, default} + Fine-tune the optimizer behavior. Takes a comma-separated + list of option=value pairs, where value is on, off, or + default, and options are: index_merge, index_merge_union, + index_merge_sort_union, index_merge_intersection, + index_merge_sort_intersection, engine_condition_pushdown, + index_condition_pushdown, derived_merge, + derived_with_keys, firstmatch, loosescan, materialization, + in_to_exists, semijoin, partial_match_rowid_merge, + partial_match_table_scan, subquery_cache, mrr, + mrr_cost_based, mrr_sort_keys, outer_join_with_cache, + semijoin_with_cache, join_cache_incremental, + join_cache_hashed, join_cache_bka, + optimize_join_buffer_size, table_elimination, + extended_keys, exists_to_in --optimizer-use-condition-selectivity=# Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial @@ -689,9 +685,9 @@ The following options may be given as the first argument: in an incremental way. It can be specified many times, adding more plugins every time. --plugin-maturity=name - The lowest desirable plugin maturity (unknown, - experimental, alpha, beta, gamma, or stable). Plugins - less mature than that will not be installed or loaded. + The lowest desirable plugin maturity. Plugins less mature + than that will not be installed or loaded. One of: + unknown, experimental, alpha, beta, gamma, stable -P, --port=# Port number to use for connection or 0 to default to, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306), whatever comes first @@ -934,11 +930,10 @@ The following options may be given as the first argument: transaction in case it failed with a deadlock or elapsed lock wait timeout, before giving up and stopping --slave-type-conversions=name - Set of slave type conversions that are enabled. Legal - values are: ALL_LOSSY to enable lossy conversions and - ALL_NON_LOSSY to enable non-lossy conversions. If the - variable is assigned the empty set, no conversions are - allowed and it is expected that the types match exactly. + Set of slave type conversions that are enabled. If the + variable is empty, no conversions are allowed and it is + expected that the types match exactly. Any combination + of: ALL_LOSSY, ALL_NON_LOSSY --slow-launch-time=# If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be @@ -955,8 +950,18 @@ The following options may be given as the first argument: --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of this size - --sql-mode=name Syntax: sql-mode=mode[,mode[,mode...]]. See the manual - for the complete list of valid sql modes + --sql-mode=name Sets the sql mode. Any combination of: REAL_AS_FLOAT, + PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, + IGNORE_BAD_TABLE_OPTIONS, ONLY_FULL_GROUP_BY, + NO_UNSIGNED_SUBTRACTION, NO_DIR_IN_CREATE, POSTGRESQL, + ORACLE, MSSQL, DB2, MAXDB, NO_KEY_OPTIONS, + NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, MYSQL323, MYSQL40, + ANSI, NO_AUTO_VALUE_ON_ZERO, NO_BACKSLASH_ESCAPES, + STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, + NO_ZERO_DATE, ALLOW_INVALID_DATES, + ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, + NO_AUTO_CREATE_USER, HIGH_NOT_PRECEDENCE, + NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) --stored-program-cache=# @@ -987,8 +992,8 @@ The following options may be given as the first argument: --table-open-cache=# The number of cached open tables --tc-heuristic-recover=name - Decision to use in heuristic recover process. Possible - values are COMMIT or ROLLBACK. + Decision to use in heuristic recover process. One of: + COMMIT, ROLLBACK --thread-cache-size=# How many threads we should keep in a cache for reuse --thread-pool-idle-timeout=# @@ -1024,7 +1029,9 @@ The following options may be given as the first argument: Allocation block size for transactions to be stored in binary log --transaction-isolation=name - Default transaction isolation level. + Default transaction isolation level. One of: + READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, + SERIALIZABLE --transaction-prealloc-size=# Persistent buffer for transactions to be stored in binary log @@ -1039,8 +1046,8 @@ The following options may be given as the first argument: of the underlying table and the query uses a LIMIT clause (usually get from GUI tools) --use-stat-tables=name - Specifies how to use system statistics tables. Possible - values are NEVER, COMPLEMENTARY, PREFERABLY + Specifies how to use system statistics tables. One of: + NEVER, COMPLEMENTARY, PREFERABLY -u, --user=name Run mysqld daemon as user. --userstat Enables statistics gathering for USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS @@ -1196,7 +1203,7 @@ myisam-mmap-size 18446744073709551615 myisam-recover-options DEFAULT myisam-repair-threads 1 myisam-sort-buffer-size 134216704 -myisam-stats-method nulls_unequal +myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE net-buffer-length 16384 net-read-timeout 30 @@ -1282,7 +1289,7 @@ relay-log-purge TRUE relay-log-recovery FALSE relay-log-space-limit 0 replicate-annotate-row-events FALSE -replicate-events-marked-for-skip replicate +replicate-events-marked-for-skip REPLICATE replicate-same-server-id FALSE report-host (No default value) report-password (No default value) diff --git a/mysql-test/r/not_embedded_server.result b/mysql-test/r/not_embedded_server.result index 2295276099a..1cd54b131c3 100644 --- a/mysql-test/r/not_embedded_server.result +++ b/mysql-test/r/not_embedded_server.result @@ -1,4 +1,4 @@ -call mtr.add_suppression("Can't open and lock privilege tables: Table 'host' was not locked with LOCK TABLES"); +call mtr.add_suppression("Can't open and lock privilege tables: Table 'user' was not locked with LOCK TABLES"); SHOW VARIABLES like 'slave_skip_errors'; Variable_name Value slave_skip_errors OFF @@ -16,7 +16,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (c1 INT); LOCK TABLES t1 READ; FLUSH PRIVILEGES; -ERROR HY000: Table 'host' was not locked with LOCK TABLES +ERROR HY000: Table 'user' was not locked with LOCK TABLES UNLOCK TABLES; DROP TABLE t1; # diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result index 172e40cb40c..fe68229aaec 100644 --- a/mysql-test/r/sp-destruct.result +++ b/mysql-test/r/sp-destruct.result @@ -128,11 +128,8 @@ CREATE FUNCTION f1() RETURNS INT RETURN 1; RENAME TABLE mysql.procs_priv TO procs_priv_backup; FLUSH TABLE mysql.procs_priv; DROP FUNCTION f1; -ERROR 42S02: Table 'mysql.procs_priv' doesn't exist SHOW WARNINGS; Level Code Message -Error 1146 Table 'mysql.procs_priv' doesn't exist -Warning 1405 Failed to revoke all privileges to dropped routine # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; diff --git a/mysql-test/r/temp_table_frm.result b/mysql-test/r/temp_table_frm.result new file mode 100644 index 00000000000..ff809957a3d --- /dev/null +++ b/mysql-test/r/temp_table_frm.result @@ -0,0 +1,20 @@ +create table t1 select * from information_schema.session_status where variable_name like 'Opened%'; +create temporary table t2 (a int) engine=memory; +select variable_name, session_status.variable_value - t1.variable_value +from information_schema.session_status join t1 using (variable_name); +variable_name session_status.variable_value - t1.variable_value +OPENED_FILES 0 +OPENED_PLUGIN_LIBRARIES 0 +OPENED_TABLE_DEFINITIONS 2 +OPENED_TABLES 2 +OPENED_VIEWS 0 +truncate table t2; +select variable_name, session_status.variable_value - t1.variable_value +from information_schema.session_status join t1 using (variable_name); +variable_name session_status.variable_value - t1.variable_value +OPENED_FILES 0 +OPENED_PLUGIN_LIBRARIES 0 +OPENED_TABLE_DEFINITIONS 2 +OPENED_TABLES 2 +OPENED_VIEWS 0 +drop table t1; diff --git a/mysql-test/suite/rpl/r/rpl_skip_replication.result b/mysql-test/suite/rpl/r/rpl_skip_replication.result index 92b5fa5f629..586a104239a 100644 --- a/mysql-test/suite/rpl/r/rpl_skip_replication.result +++ b/mysql-test/suite/rpl/r/rpl_skip_replication.result @@ -8,22 +8,22 @@ ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) fo DROP USER'nonsuperuser'@'127.0.0.1'; SELECT @@global.replicate_events_marked_for_skip; @@global.replicate_events_marked_for_skip -replicate +REPLICATE SET GLOBAL replicate_events_marked_for_skip=FILTER_ON_SLAVE; ERROR HY000: This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first SELECT @@global.replicate_events_marked_for_skip; @@global.replicate_events_marked_for_skip -replicate +REPLICATE STOP SLAVE; SET SESSION replicate_events_marked_for_skip=FILTER_ON_MASTER; ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL SELECT @@global.replicate_events_marked_for_skip; @@global.replicate_events_marked_for_skip -replicate +REPLICATE SET GLOBAL replicate_events_marked_for_skip=FILTER_ON_MASTER; SELECT @@global.replicate_events_marked_for_skip; @@global.replicate_events_marked_for_skip -filter_on_master +FILTER_ON_MASTER START SLAVE; SELECT @@skip_replication; @@skip_replication diff --git a/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result b/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result index d2d96596a93..8e05db129dc 100644 --- a/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result @@ -1,47 +1,47 @@ SET @orig = @@global.innodb_checksum_algorithm; SELECT @orig; @orig -innodb +INNODB SET GLOBAL innodb_checksum_algorithm = 'crc32'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -crc32 +CRC32 SET GLOBAL innodb_checksum_algorithm = 'strict_crc32'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_crc32 +STRICT_CRC32 SET GLOBAL innodb_checksum_algorithm = 'innodb'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -innodb +INNODB SET GLOBAL innodb_checksum_algorithm = 'strict_innodb'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_innodb +STRICT_INNODB SET GLOBAL innodb_checksum_algorithm = 'none'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -none +NONE SET GLOBAL innodb_checksum_algorithm = 'strict_none'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_checksum_algorithm = ''; ERROR 42000: Variable 'innodb_checksum_algorithm' can't be set to the value of '' SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_checksum_algorithm = 'foobar'; ERROR 42000: Variable 'innodb_checksum_algorithm' can't be set to the value of 'foobar' SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_checksum_algorithm = 123; ERROR 42000: Variable 'innodb_checksum_algorithm' can't be set to the value of '123' SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_checksum_algorithm = @orig; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm -innodb +INNODB diff --git a/mysql-test/suite/sys_vars/r/innodb_cleaner_lsn_age_factor_basic.result b/mysql-test/suite/sys_vars/r/innodb_cleaner_lsn_age_factor_basic.result index 6dd1b6dc489..65046d93344 100644 --- a/mysql-test/suite/sys_vars/r/innodb_cleaner_lsn_age_factor_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_cleaner_lsn_age_factor_basic.result @@ -1,17 +1,17 @@ SET @start_value = @@GLOBAL.innodb_cleaner_lsn_age_factor; SELECT @@GLOBAL.innodb_cleaner_lsn_age_factor; @@GLOBAL.innodb_cleaner_lsn_age_factor -high_checkpoint +HIGH_CHECKPOINT SELECT @@SESSION.innodb_cleaner_lsn_age_factor; ERROR HY000: Variable 'innodb_cleaner_lsn_age_factor' is a GLOBAL variable SET GLOBAL innodb_cleaner_lsn_age_factor='legacy'; SELECT @@GLOBAL.innodb_cleaner_lsn_age_factor; @@GLOBAL.innodb_cleaner_lsn_age_factor -legacy +LEGACY SET GLOBAL innodb_cleaner_lsn_age_factor='high_checkpoint'; SELECT @@GLOBAL.innodb_cleaner_lsn_age_factor; @@GLOBAL.innodb_cleaner_lsn_age_factor -high_checkpoint +HIGH_CHECKPOINT SET GLOBAL innodb_cleaner_lsn_age_factor=1.1; ERROR 42000: Incorrect argument type to variable 'innodb_cleaner_lsn_age_factor' SET GLOBAL innodb_cleaner_lsn_age_factor=1e1; diff --git a/mysql-test/suite/sys_vars/r/innodb_empty_free_list_algorithm_basic.result b/mysql-test/suite/sys_vars/r/innodb_empty_free_list_algorithm_basic.result index f95553e3fa2..0730055d104 100644 --- a/mysql-test/suite/sys_vars/r/innodb_empty_free_list_algorithm_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_empty_free_list_algorithm_basic.result @@ -1,17 +1,17 @@ SET @start_value = @@GLOBAL.innodb_empty_free_list_algorithm; SELECT @@GLOBAL.innodb_empty_free_list_algorithm; @@GLOBAL.innodb_empty_free_list_algorithm -backoff +BACKOFF SELECT @@SESSION.innodb_empty_free_list_algorithm; ERROR HY000: Variable 'innodb_empty_free_list_algorithm' is a GLOBAL variable SET GLOBAL innodb_empty_free_list_algorithm='legacy'; SELECT @@GLOBAL.innodb_empty_free_list_algorithm; @@GLOBAL.innodb_empty_free_list_algorithm -legacy +LEGACY SET GLOBAL innodb_empty_free_list_algorithm='backoff'; SELECT @@GLOBAL.innodb_empty_free_list_algorithm; @@GLOBAL.innodb_empty_free_list_algorithm -backoff +BACKOFF SET GLOBAL innodb_empty_free_list_algorithm=1.1; ERROR 42000: Incorrect argument type to variable 'innodb_empty_free_list_algorithm' SET GLOBAL innodb_empty_free_list_algorithm=1e1; diff --git a/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result b/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result index 4ad0ce8d78e..17e67d2b861 100644 --- a/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result @@ -1,17 +1,17 @@ SET @start_value = @@GLOBAL.innodb_foreground_preflush; SELECT @@GLOBAL.innodb_foreground_preflush; @@GLOBAL.innodb_foreground_preflush -exponential_backoff +EXPONENTIAL_BACKOFF SELECT @@SESSION.innodb_foreground_preflush; ERROR HY000: Variable 'innodb_foreground_preflush' is a GLOBAL variable SET GLOBAL innodb_foreground_preflush='sync_preflush'; SELECT @@GLOBAL.innodb_foreground_preflush; @@GLOBAL.innodb_foreground_preflush -sync_preflush +SYNC_PREFLUSH SET GLOBAL innodb_foreground_preflush='exponential_backoff'; SELECT @@GLOBAL.innodb_foreground_preflush; @@GLOBAL.innodb_foreground_preflush -exponential_backoff +EXPONENTIAL_BACKOFF SET GLOBAL innodb_foreground_preflush=1.1; ERROR 42000: Incorrect argument type to variable 'innodb_foreground_preflush' SET GLOBAL innodb_foreground_preflush=1e1; diff --git a/mysql-test/suite/sys_vars/r/innodb_log_checksum_algorithm_basic.result b/mysql-test/suite/sys_vars/r/innodb_log_checksum_algorithm_basic.result index cb03046c84d..4497e8f208a 100644 --- a/mysql-test/suite/sys_vars/r/innodb_log_checksum_algorithm_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_log_checksum_algorithm_basic.result @@ -1,47 +1,47 @@ SET @orig = @@global.innodb_log_checksum_algorithm; SELECT @orig; @orig -innodb +INNODB SET GLOBAL innodb_log_checksum_algorithm = 'crc32'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -crc32 +CRC32 SET GLOBAL innodb_log_checksum_algorithm = 'strict_crc32'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_crc32 +STRICT_CRC32 SET GLOBAL innodb_log_checksum_algorithm = 'innodb'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -innodb +INNODB SET GLOBAL innodb_log_checksum_algorithm = 'strict_innodb'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_innodb +STRICT_INNODB SET GLOBAL innodb_log_checksum_algorithm = 'none'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -none +NONE SET GLOBAL innodb_log_checksum_algorithm = 'strict_none'; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_log_checksum_algorithm = ''; ERROR 42000: Variable 'innodb_log_checksum_algorithm' can't be set to the value of '' SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_log_checksum_algorithm = 'foobar'; ERROR 42000: Variable 'innodb_log_checksum_algorithm' can't be set to the value of 'foobar' SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_log_checksum_algorithm = 123; ERROR 42000: Variable 'innodb_log_checksum_algorithm' can't be set to the value of '123' SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -strict_none +STRICT_NONE SET GLOBAL innodb_log_checksum_algorithm = @orig; SELECT @@global.innodb_log_checksum_algorithm; @@global.innodb_log_checksum_algorithm -innodb +INNODB diff --git a/mysql-test/suite/sys_vars/r/myisam_stats_method_basic.result b/mysql-test/suite/sys_vars/r/myisam_stats_method_basic.result index 15725e757d5..e9150338317 100644 --- a/mysql-test/suite/sys_vars/r/myisam_stats_method_basic.result +++ b/mysql-test/suite/sys_vars/r/myisam_stats_method_basic.result @@ -1,22 +1,22 @@ SET @global_start_value = @@global.myisam_stats_method; SELECT @global_start_value; @global_start_value -nulls_unequal +NULLS_UNEQUAL SET @session_start_value = @@session.myisam_stats_method; SELECT @session_start_value; @session_start_value -nulls_unequal +NULLS_UNEQUAL '#--------------------FN_DYNVARS_097_01------------------------#' SET @@global.myisam_stats_method = nulls_equal; SET @@global.myisam_stats_method = DEFAULT; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL SET @@session.myisam_stats_method = nulls_equal; SET @@session.myisam_stats_method = DEFAULT; SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL '#---------------------FN_DYNVARS_097_02-------------------------#' SET @@global.myisam_stats_method = NULL; ERROR 42000: Variable 'myisam_stats_method' can't be set to the value of 'NULL' @@ -30,28 +30,28 @@ ERROR 42000: Variable 'myisam_stats_method' can't be set to the value of '' SET @@global.myisam_stats_method = 'nulls_equal'; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_equal +NULLS_EQUAL SET @@global.myisam_stats_method = 'nulls_unequal'; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL SET @@global.myisam_stats_method = 'nulls_ignored'; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_ignored +NULLS_IGNORED 'Bug: Value of nulls_ignored is not documented. Its ordinal value is 2' SET @@session.myisam_stats_method = 'nulls_equal'; SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_equal +NULLS_EQUAL SET @@session.myisam_stats_method = 'nulls_unequal'; SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL SET @@session.myisam_stats_method = 'nulls_ignored'; SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_ignored +NULLS_IGNORED '#--------------------FN_DYNVARS_097_04-------------------------#' SET @@global.myisam_stats_method = -1; ERROR 42000: Variable 'myisam_stats_method' can't be set to the value of '-1' @@ -81,15 +81,15 @@ WHERE VARIABLE_NAME='myisam_stats_method'; SET @@global.myisam_stats_method = 0; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL SET @@global.myisam_stats_method = 1; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_equal +NULLS_EQUAL SET @@global.myisam_stats_method = 2; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_ignored +NULLS_IGNORED SET @@global.myisam_stats_method = 0.4; ERROR 42000: Incorrect argument type to variable 'myisam_stats_method' SET @@global.myisam_stats_method = 3; @@ -98,11 +98,11 @@ ERROR 42000: Variable 'myisam_stats_method' can't be set to the value of '3' SET @@global.myisam_stats_method = TRUE; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_equal +NULLS_EQUAL SET @@global.myisam_stats_method = FALSE; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL '#---------------------FN_DYNVARS_097_09----------------------#' SET myisam_stats_method = 'nulls_equal'; SET session.myisam_stats_method = 'nulls_equal'; @@ -112,16 +112,16 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SET session myisam_stats_method = 'nulls_equal'; SELECT @@myisam_stats_method; @@myisam_stats_method -nulls_equal +NULLS_EQUAL SET global myisam_stats_method = 'nulls_equal'; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_equal +NULLS_EQUAL SET @@global.myisam_stats_method = @global_start_value; SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL SET @@session.myisam_stats_method = @session_start_value; SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_unequal +NULLS_UNEQUAL diff --git a/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result b/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result index 5efdeeedc4b..978c8c2d5b2 100644 --- a/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result +++ b/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result @@ -5,10 +5,10 @@ SET @@global.myisam_stats_method = nulls_equal; 'connection con1' SELECT @@global.myisam_stats_method; @@global.myisam_stats_method -nulls_equal +NULLS_EQUAL SELECT @@session.myisam_stats_method; @@session.myisam_stats_method -nulls_equal +NULLS_EQUAL '#--------------------FN_DYNVARS_097_02-------------------------#' 'connection default' DROP TABLE IF EXISTS t1; @@ -53,7 +53,7 @@ t1 1 a 1 a A 5 NULL NULL YES BTREE SET myisam_stats_method = nulls_ignored; SHOW VARIABLES LIKE 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_ignored +myisam_stats_method NULLS_IGNORED DROP TABLE t1; CREATE TABLE t1 ( a CHAR(3), b CHAR(4), c CHAR(5), d CHAR(6), diff --git a/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_basic.result b/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_basic.result index 8bc7c845e0b..3fb7719c729 100644 --- a/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_basic.result +++ b/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_basic.result @@ -4,7 +4,7 @@ SET @save_replicate_events_marked_for_skip = @@GLOBAL.replicate_events_marked_for_skip; SELECT @save_replicate_events_marked_for_skip; @save_replicate_events_marked_for_skip -replicate +REPLICATE # Scope. SET @@SESSION.replicate_events_marked_for_skip = ""; ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL @@ -14,22 +14,22 @@ ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable SET @@GLOBAL.replicate_events_marked_for_skip=filter_on_master; SELECT @@GLOBAL.replicate_events_marked_for_skip; @@GLOBAL.replicate_events_marked_for_skip -filter_on_master +FILTER_ON_MASTER SET @@GLOBAL.replicate_events_marked_for_skip=filter_on_slave; SELECT @@GLOBAL.replicate_events_marked_for_skip; @@GLOBAL.replicate_events_marked_for_skip -filter_on_slave +FILTER_ON_SLAVE SET @@GLOBAL.replicate_events_marked_for_skip=replicate; SELECT @@GLOBAL.replicate_events_marked_for_skip; @@GLOBAL.replicate_events_marked_for_skip -replicate +REPLICATE SET @@GLOBAL.replicate_events_marked_for_skip=filter; ERROR 42000: Variable 'replicate_events_marked_for_skip' can't be set to the value of 'filter' SELECT @@GLOBAL.replicate_events_marked_for_skip; @@GLOBAL.replicate_events_marked_for_skip -replicate +REPLICATE SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_events_marked_for_skip'; VARIABLE_NAME VARIABLE_VALUE -REPLICATE_EVENTS_MARKED_FOR_SKIP replicate +REPLICATE_EVENTS_MARKED_FOR_SKIP REPLICATE # Cleanup. SET @@GLOBAL.replicate_events_marked_for_skip = @save_replicate_events_marked_for_skip; diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test index e74da3a8ff4..f22bf8cd7b5 100644 --- a/mysql-test/t/not_embedded_server.test +++ b/mysql-test/t/not_embedded_server.test @@ -6,7 +6,7 @@ # End of 4.1 tests -call mtr.add_suppression("Can't open and lock privilege tables: Table 'host' was not locked with LOCK TABLES"); +call mtr.add_suppression("Can't open and lock privilege tables: Table 'user' was not locked with LOCK TABLES"); # # Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index e109f88e3f9..52bbce6c484 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -214,7 +214,6 @@ RENAME TABLE mysql.procs_priv TO procs_priv_backup; FLUSH TABLE mysql.procs_priv; # DROP FUNCTION used to cause an assert. ---error ER_NO_SUCH_TABLE DROP FUNCTION f1; SHOW WARNINGS; diff --git a/mysql-test/t/temp_table_frm.test b/mysql-test/t/temp_table_frm.test new file mode 100644 index 00000000000..f78de71a756 --- /dev/null +++ b/mysql-test/t/temp_table_frm.test @@ -0,0 +1,13 @@ +# +# MDEV-4260 Don't create frm files for temporary tables +# +create table t1 select * from information_schema.session_status where variable_name like 'Opened%'; +create temporary table t2 (a int) engine=memory; +select variable_name, session_status.variable_value - t1.variable_value +from information_schema.session_status join t1 using (variable_name); +let $tmpdir= `select @@tmpdir`; +--list_files $tmpdir/ #sql* +truncate table t2; +select variable_name, session_status.variable_value - t1.variable_value +from information_schema.session_status join t1 using (variable_name); +drop table t1; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 2e97417340d..abcfcfc41cc 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -1300,6 +1300,48 @@ static uint print_name(const struct my_option *optp) return s - optp->name; } +/** prints option comment with indentation and wrapping. + + The comment column starts at startpos, and has width of width + Current cursor position is curpos, returns new cursor position + + @note can print one character beyond width! +*/ +static uint print_comment(const char *comment, + int curpos, int startpos, int width) +{ + const char *end= strend(comment); + int endpos= startpos + width; + + for (; curpos < startpos; curpos++) + putchar(' '); + + if (*comment == '.' || *comment == ',') + { + putchar(*comment); + comment++; + curpos++; + } + + while (end - comment > endpos - curpos) + { + const char *line_end; + for (line_end= comment + endpos - curpos; + line_end > comment && *line_end != ' '; + line_end--); + for (; comment < line_end; comment++) + putchar(*comment); + while (*comment == ' ') + comment++; /* skip the space, as a newline will take it's place now */ + putchar('\n'); + for (curpos= 0; curpos < startpos; curpos++) + putchar(' '); + } + printf("%s", comment); + return curpos + (end - comment); +} + + /* function: my_print_options @@ -1309,12 +1351,12 @@ static uint print_name(const struct my_option *optp) void my_print_help(const struct my_option *options) { uint col, name_space= 22, comment_space= 57; - const char *line_end; const struct my_option *optp; DBUG_ENTER("my_print_help"); for (optp= options; optp->name; optp++) { + const char *typelib_help= 0; if (!optp->comment) continue; if (optp->id && optp->id < 256) @@ -1353,29 +1395,46 @@ void my_print_help(const struct my_option *options) optp->arg_type == OPT_ARG ? "]" : ""); col+= (optp->arg_type == OPT_ARG) ? 5 : 3; } - if (col > name_space && optp->comment && *optp->comment) + } + if (optp->comment && *optp->comment) + { + uint count; + + if (col > name_space) { putchar('\n'); col= 0; } - } - for (; col < name_space; col++) - putchar(' '); - if (optp->comment && *optp->comment) - { - const char *comment= optp->comment, *end= strend(comment); - while ((uint) (end - comment) > comment_space) - { - for (line_end= comment + comment_space; *line_end != ' '; line_end--); - for (; comment != line_end; comment++) - putchar(*comment); - comment++; /* skip the space, as a newline will take it's place now */ - putchar('\n'); - for (col= 0; col < name_space; col++) - putchar(' '); + col= print_comment(optp->comment, col, name_space, comment_space); + + switch (optp->var_type & GET_TYPE_MASK) { + case GET_ENUM: + typelib_help= ". One of: "; + count= optp->typelib->count; + break; + case GET_SET: + typelib_help= ". Any combination of: "; + count= optp->typelib->count; + break; + case GET_FLAGSET: + typelib_help= ". Takes a comma-separated list of option=value pairs, " + "where value is on, off, or default, and options are: "; + count= optp->typelib->count - 1; + break; + } + if (typelib_help && + strstr(optp->comment, optp->typelib->type_names[0]) == NULL) + { + int i; + col= print_comment(typelib_help, col, name_space, comment_space); + col= print_comment(optp->typelib->type_names[0], col, name_space, comment_space); + for (i= 1; i < count; i++) + { + col= print_comment(", ", col, name_space, comment_space); + col= print_comment(optp->typelib->type_names[i], col, name_space, comment_space); + } } - printf("%s", comment); } putchar('\n'); if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL) diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt index 51317527c77..055e188c45b 100644 --- a/plugin/auth_pam/CMakeLists.txt +++ b/plugin/auth_pam/CMakeLists.txt @@ -4,10 +4,10 @@ INCLUDE (CheckFunctionExists) CHECK_INCLUDE_FILES (security/pam_appl.h HAVE_PAM_APPL_H) CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP) -IF(HAVE_PAM_APPL_H) - IF(HAVE_STRNDUP) - ADD_DEFINITIONS(-DHAVE_STRNDUP) - ENDIF(HAVE_STRNDUP) - MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam MODULE_ONLY) -ENDIF(HAVE_PAM_APPL_H) +IF(HAVE_STRNDUP) + ADD_DEFINITIONS(-DHAVE_STRNDUP) +ENDIF(HAVE_STRNDUP) + +MYSQL_ADD_PLUGIN(auth_pam auth_pam.c ONLY_IF HAVE_PAM_APPL_H + LINK_LIBRARIES pam MODULE_ONLY) diff --git a/plugin/auth_socket/CMakeLists.txt b/plugin/auth_socket/CMakeLists.txt index ae7dbffe2ae..2c5a9c89fcb 100644 --- a/plugin/auth_socket/CMakeLists.txt +++ b/plugin/auth_socket/CMakeLists.txt @@ -35,5 +35,8 @@ IF (NOT HAVE_PEERCRED) ENDIF() IF(HAVE_PEERCRED OR HAVE_SOCKPEERCRED) - MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY) + SET(AUTH_SOCKET_OK 1) ENDIF() + +MYSQL_ADD_PLUGIN(auth_socket auth_socket.c ONLY_IF AUTH_SOCKET_OK MODULE_ONLY) + diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt index 9807eadbe34..a243ba07751 100644 --- a/plugin/feedback/CMakeLists.txt +++ b/plugin/feedback/CMakeLists.txt @@ -14,10 +14,10 @@ IF(HAVE_NETDB_H) ENDIF(HAVE_NETDB_H) IF(WIN32) - MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES} - LINK_LIBRARIES ${SSL_LIBRARIES} - STATIC_ONLY DEFAULT) -ELSE(WIN32) - MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES} - LINK_LIBRARIES ${SSL_LIBRARIES}) + SET(MAYBE_STATIC_ONLY STATIC_ONLY) ENDIF(WIN32) + +MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES} + LINK_LIBRARIES ${SSL_LIBRARIES} + ${MAYBE_STATIC_ONLY} DEFAULT) + diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index fc1dbf4dde4..36d1fa3e9f7 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -242,7 +242,7 @@ static TYPELIB events_typelib= array_elements(event_names) - 1, "", event_names, NULL }; static MYSQL_SYSVAR_SET(events, events, PLUGIN_VAR_RQCMDARG, - "Specifies the set of events to monitor. Can be CONNECT, QUERY, TABLE.", + "Specifies the set of events to monitor", NULL, NULL, 0, &events_typelib); #define OUTPUT_SYSLOG 0 #define OUTPUT_FILE 1 diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index e865edc46c0..d3a7861269c 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -88,7 +88,7 @@ IF(MALLOC_LIB) INSTALL(FILES ${MALLOC_LIB} DESTINATION ${INSTALL_LIBDIR} OPTIONAL) ENDIF() -IF(CMAKE_GENERATOR MATCHES "Makefiles") +IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") # Strip maintainer mode options if necessary STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}") STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") diff --git a/sql/handler.h b/sql/handler.h index 5cff169b295..1e4fe5557b6 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1369,7 +1369,6 @@ handlerton *ha_default_tmp_handlerton(THD *thd); #define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter #define HTON_CAN_RECREATE (1 << 2) //Delete all is used for truncate #define HTON_HIDDEN (1 << 3) //Engine does not appear in lists -#define HTON_FLUSH_AFTER_RENAME (1 << 4) #define HTON_NOT_USER_SELECTABLE (1 << 5) #define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported #define HTON_SUPPORT_LOG_TABLES (1 << 7) //Engine supports log tables diff --git a/sql/log.cc b/sql/log.cc index dafe89ac7f0..75a895e25f8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -9569,8 +9569,7 @@ static MYSQL_SYSVAR_ENUM( binlog_checksum_options, PLUGIN_VAR_RQCMDARG, "Type of BINLOG_CHECKSUM_ALG. Include checksum for " - "log events in the binary log. Possible values are NONE and CRC32; " - "default is NONE.", + "log events in the binary log", NULL, binlog_checksum_update, BINLOG_CHECKSUM_ALG_OFF, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fca084ad54e..1817d1cca9d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6965,7 +6965,7 @@ struct my_option my_long_options[]= &master_retry_count, &master_retry_count, 0, GET_ULONG, REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION - {"init-rpl-role", 0, "Set the replication role.", + {"init-rpl-role", 0, "Set the replication role", &rpl_status, &rpl_status, &rpl_role_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ @@ -7093,8 +7093,8 @@ struct my_option my_long_options[]= &global_system_variables.sysdate_is_now, 0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"tc-heuristic-recover", 0, - "Decision to use in heuristic recover process. Possible values are COMMIT " - "or ROLLBACK.", &tc_heuristic_recover, &tc_heuristic_recover, + "Decision to use in heuristic recover process", + &tc_heuristic_recover, &tc_heuristic_recover, &tc_heuristic_recover_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"temp-pool", 0, #if (ENABLE_TEMP_POOL) @@ -7106,7 +7106,7 @@ struct my_option my_long_options[]= &use_temp_pool, &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"transaction-isolation", 0, - "Default transaction isolation level.", + "Default transaction isolation level", &global_system_variables.tx_isolation, &global_system_variables.tx_isolation, &tx_isolation_typelib, GET_ENUM, REQUIRED_ARG, ISO_REPEATABLE_READ, 0, 0, 0, 0, 0}, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5e8e0e7a4e8..eff05745628 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -380,7 +380,7 @@ class ACL_PROXY_USER :public ACL_ACCESS MYSQL_PROXIES_PRIV_PROXIED_USER, MYSQL_PROXIES_PRIV_WITH_GRANT, MYSQL_PROXIES_PRIV_GRANTOR, - MYSQL_PROXIES_PRIV_TIMESTAMP } old_acl_proxy_users; + MYSQL_PROXIES_PRIV_TIMESTAMP } proxy_table_fields; public: ACL_PROXY_USER () {}; @@ -745,8 +745,8 @@ static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host); static bool update_user_table(THD *thd, TABLE *table, const char *host, const char *user, const char *new_password, uint new_password_len); -static my_bool acl_load(THD *thd, TABLE_LIST *tables); -static my_bool grant_load(THD *thd, TABLE_LIST *tables); +static bool acl_load(THD *thd, TABLE_LIST *tables); +static bool grant_load(THD *thd, TABLE_LIST *tables); static inline void get_grantor(THD *thd, char* grantor); static bool add_role_user_mapping(const char *uname, const char *hname, const char *rname); @@ -759,6 +759,57 @@ static int traverse_role_graph_down(ACL_USER_BASE *, void *, int (*) (ACL_USER_BASE *, void *), int (*) (ACL_USER_BASE *, ACL_ROLE *, void *)); +/* + Enumeration of ACL/GRANT tables in the mysql database +*/ +enum enum_acl_tables +{ + USER_TABLE, + DB_TABLE, + TABLES_PRIV_TABLE, + COLUMNS_PRIV_TABLE, +#define FIRST_OPTIONAL_TABLE HOST_TABLE + HOST_TABLE, + PROCS_PRIV_TABLE, + PROXIES_PRIV_TABLE, + ROLES_MAPPING_TABLE, + TABLES_MAX // <== always the last +}; +// bits for open_grant_tables +static const int Table_user= 1 << USER_TABLE; +static const int Table_db= 1 << DB_TABLE; +static const int Table_tables_priv= 1 << TABLES_PRIV_TABLE; +static const int Table_columns_priv= 1 << COLUMNS_PRIV_TABLE; +static const int Table_host= 1 << HOST_TABLE; +static const int Table_procs_priv= 1 << PROCS_PRIV_TABLE; +static const int Table_proxies_priv= 1 << PROXIES_PRIV_TABLE; +static const int Table_roles_mapping= 1 << ROLES_MAPPING_TABLE; + +static int open_grant_tables(THD *thd, TABLE_LIST *tables, + enum thr_lock_type lock_type, int tables_to_open); + +const LEX_STRING acl_table_names[]= // matches enum_acl_tables +{ + { C_STRING_WITH_LEN("user") }, + { C_STRING_WITH_LEN("db") }, + { C_STRING_WITH_LEN("tables_priv") }, + { C_STRING_WITH_LEN("columns_priv") }, + { C_STRING_WITH_LEN("host") }, + { C_STRING_WITH_LEN("procs_priv") }, + { C_STRING_WITH_LEN("proxies_priv") }, + { C_STRING_WITH_LEN("roles_mapping") } +}; + +/** check if the table was opened, issue an error otherwise */ +static int no_such_table(TABLE_LIST *tl) +{ + if (tl->table) + return 0; + + my_error(ER_NO_SUCH_TABLE, MYF(0), tl->db, tl->alias); + return 1; +} + /* Enumeration of various ACL's and Hashes used in handle_grant_struct() */ @@ -919,10 +970,10 @@ static bool get_YN_as_bool(Field *field) 1 Could not initialize grant's */ -my_bool acl_init(bool dont_read_acl_tables) +bool acl_init(bool dont_read_acl_tables) { THD *thd; - my_bool return_val; + bool return_val; DBUG_ENTER("acl_init"); acl_cache= new Hash_filo(ACL_CACHE_SIZE, 0, 0, @@ -1006,11 +1057,11 @@ static bool set_user_plugin (ACL_USER *user, int password_len) TRUE Error */ -static my_bool acl_load(THD *thd, TABLE_LIST *tables) +static bool acl_load(THD *thd, TABLE_LIST *tables) { TABLE *table; READ_RECORD read_record_info; - my_bool return_val= TRUE; + bool return_val= TRUE; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; char tmp_name[SAFE_NAME_LEN+1]; int password_length; @@ -1023,10 +1074,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) init_sql_alloc(&acl_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); (void) my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST), 20, 50, MYF(0)); - if (tables[0].table) // "host" table may not exist (e.g. in MySQL 5.6.7+) + if ((table= tables[HOST_TABLE].table)) // "host" table may not exist (e.g. in MySQL 5.6.7+) { - if (init_read_record(&read_record_info, thd, table= tables[0].table, - NULL, 1, 1, FALSE)) + if (init_read_record(&read_record_info, thd, table, NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); while (!(read_record_info.read_record(&read_record_info))) @@ -1080,7 +1130,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) } freeze_size(&acl_hosts); - if (init_read_record(&read_record_info, thd, table=tables[1].table, + if (init_read_record(&read_record_info, thd, table=tables[USER_TABLE].table, NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); @@ -1323,7 +1373,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) end_read_record(&read_record_info); freeze_size(&acl_users); - if (init_read_record(&read_record_info, thd, table=tables[2].table, + if (init_read_record(&read_record_info, thd, table=tables[DB_TABLE].table, NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); @@ -1391,9 +1441,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) (void) my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100, MYF(0)); - if (tables[3].table) + if ((table= tables[PROXIES_PRIV_TABLE].table)) { - if (init_read_record(&read_record_info, thd, table= tables[3].table, + if (init_read_record(&read_record_info, thd, table, NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); @@ -1421,10 +1471,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) } freeze_size(&acl_proxy_users); - if (tables[4].table) + if ((table= tables[ROLES_MAPPING_TABLE].table)) { - if (init_read_record(&read_record_info, thd, table= tables[4].table, - NULL, 1, 1, FALSE)) + if (init_read_record(&read_record_info, thd, table, NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); /* account for every role mapping */ @@ -1516,42 +1565,23 @@ void acl_free(bool end) TRUE Failure */ -my_bool acl_reload(THD *thd) +bool acl_reload(THD *thd) { - TABLE_LIST tables[5]; + TABLE_LIST tables[TABLES_MAX]; DYNAMIC_ARRAY old_acl_hosts, old_acl_users, old_acl_dbs, old_acl_proxy_users; HASH old_acl_roles, old_acl_roles_mappings; MEM_ROOT old_mem; - my_bool return_val= TRUE; + int result; DBUG_ENTER("acl_reload"); /* To avoid deadlocks we should obtain table locks before obtaining acl_cache->lock mutex. */ - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("host"), "host", TL_READ); - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_READ); - tables[2].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("db"), "db", TL_READ); - tables[3].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("proxies_priv"), - "proxies_priv", TL_READ); - tables[4].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("roles_mapping"), - "roles_mapping", TL_READ); - tables[0].next_local= tables[0].next_global= tables + 1; - tables[1].next_local= tables[1].next_global= tables + 2; - tables[2].next_local= tables[2].next_global= tables + 3; - tables[3].next_local= tables[3].next_global= tables + 4; - tables[0].open_type= tables[1].open_type= tables[2].open_type= - tables[3].open_type= tables[4].open_type= OT_BASE_ONLY; - tables[0].open_strategy= tables[3].open_strategy= - tables[4].open_strategy= TABLE_LIST::OPEN_IF_EXISTS; - - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) + if ((result= open_grant_tables(thd, tables, TL_READ, Table_host | + Table_user | Table_db | Table_proxies_priv | Table_roles_mapping))) { + DBUG_ASSERT(result <= 0); /* Execution might have been interrupted; only print the error message if an error condition has been raised. @@ -1575,7 +1605,7 @@ my_bool acl_reload(THD *thd) delete_dynamic(&acl_wild_hosts); my_hash_free(&acl_check_hosts); - if ((return_val= acl_load(thd, tables))) + if ((result= acl_load(thd, tables))) { // Error. Revert to old list DBUG_PRINT("error",("Reverting to old privileges")); acl_free(); /* purecov: inspected */ @@ -1601,7 +1631,7 @@ my_bool acl_reload(THD *thd) mysql_mutex_unlock(&acl_cache->lock); end: close_mysql_tables(thd); - DBUG_RETURN(return_val); + DBUG_RETURN(result); } /* @@ -2558,15 +2588,13 @@ int check_change_password(THD *thd, const char *host, const char *user, bool change_password(THD *thd, const char *host, const char *user, char *new_password) { - TABLE_LIST tables; - TABLE *table; - Rpl_filter *rpl_filter; + TABLE_LIST tables[TABLES_MAX]; /* Buffer should be extended when password length is extended. */ char buff[512]; ulong query_length; enum_binlog_format save_binlog_format; uint new_password_len= (uint) strlen(new_password); - bool result= 1; + int result; DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", host,user,new_password)); @@ -2575,28 +2603,10 @@ bool change_password(THD *thd, const char *host, const char *user, if (check_change_password(thd, host, user, new_password, new_password_len)) DBUG_RETURN(1); - tables.init_one_table("mysql", 5, "user", 4, "user", TL_WRITE); + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user))) + DBUG_RETURN(result != 1); -#ifdef HAVE_REPLICATION - /* - GRANT and REVOKE are applied the slave in/exclusion rules as they are - some kind of updates to the mysql.% tables. - */ - if (thd->slave_thread && - (rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter)->is_on()) - { - /* - The tables must be marked "updating" so that tables_ok() takes them into - account in tests. It's ok to leave 'updating' set after tables_ok. - */ - tables.updating= 1; - /* Thanks to bzero, tables.next==0 */ - if (!(thd->spcont || rpl_filter->tables_ok(0, &tables))) - DBUG_RETURN(0); - } -#endif - if (!(table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) - DBUG_RETURN(1); + result= 1; /* This statement will be replicated as a statement, even when using @@ -2629,7 +2639,7 @@ bool change_password(THD *thd, const char *host, const char *user, push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_SET_PASSWORD_AUTH_PLUGIN, ER(ER_SET_PASSWORD_AUTH_PLUGIN)); - if (update_user_table(thd, table, + if (update_user_table(thd, tables[USER_TABLE].table, safe_str(acl_user->host.hostname), safe_str(acl_user->user.str), new_password, new_password_len)) @@ -3293,12 +3303,6 @@ static int replace_db_table(TABLE *table, const char *db, uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_db_table"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); - DBUG_RETURN(-1); - } - /* Check if there is such a user in user table in memory? */ if (!find_user_wild(combo.host.str,combo.user.str)) { @@ -3569,12 +3573,6 @@ replace_proxies_priv_table(THD *thd, TABLE *table, const LEX_USER *user, DBUG_ENTER("replace_proxies_priv_table"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); - DBUG_RETURN(-1); - } - /* Check if there is such a user in user table in memory? */ if (!find_user_wild(user->host.str,user->user.str)) { @@ -4366,12 +4364,6 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, HASH *hash= is_proc ? &proc_priv_hash : &func_priv_hash; DBUG_ENTER("replace_routine_table"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); - DBUG_RETURN(-1); - } - if (revoke_grant && !grant_name->init_privs) // only inherited role privs { my_hash_delete(hash, (uchar*) grant_name); @@ -4669,7 +4661,7 @@ static int traverse_role_graph_impl(ACL_USER_BASE *user, void *context, Iterate through the neighbours until a first valid jump-to neighbour is found */ - my_bool found= FALSE; + bool found= FALSE; uint i; DYNAMIC_ARRAY *array= (DYNAMIC_ARRAY *)(((char*)current) + offset); @@ -5391,20 +5383,14 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, bool revoke_grant) { ulong column_priv= 0; + int result; List_iterator str_list (user_list); LEX_USER *Str, *tmp_Str; - TABLE_LIST tables[3]; + TABLE_LIST tables[TABLES_MAX]; bool create_new_users=0; char *db_name, *table_name; - Rpl_filter *rpl_filter; DBUG_ENTER("mysql_table_grant"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), - "--skip-grant-tables"); /* purecov: inspected */ - DBUG_RETURN(TRUE); /* purecov: inspected */ - } if (rights & ~TABLE_ACLS) { my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), @@ -5466,38 +5452,14 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, } } - /* open the mysql.tables_priv and mysql.columns_priv tables */ - - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_WRITE); - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("tables_priv"), - "tables_priv", TL_WRITE); - tables[2].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("columns_priv"), - "columns_priv", TL_WRITE); - tables[0].next_local= tables[0].next_global= tables+1; - /* Don't open column table if we don't need it ! */ - if (column_priv || (revoke_grant && ((rights & COL_ACLS) || columns.elements))) - tables[1].next_local= tables[1].next_global= tables+2; - -#ifdef HAVE_REPLICATION /* - GRANT and REVOKE are applied the slave in/exclusion rules as they are - some kind of updates to the mysql.% tables. + Open the mysql.user and mysql.tables_priv tables. + Don't open column table if we don't need it ! */ - if (thd->slave_thread && - (rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter)->is_on()) - { - /* - The tables must be marked "updating" so that tables_ok() takes them into - account in tests. - */ - tables[0].updating= tables[1].updating= tables[2].updating= 1; - if (!(thd->spcont || rpl_filter->tables_ok(0, tables))) - DBUG_RETURN(FALSE); - } -#endif + int maybe_columns_priv= 0; + if (column_priv || + (revoke_grant && ((rights & COL_ACLS) || columns.elements))) + maybe_columns_priv= Table_columns_priv; /* The lock api is depending on the thd->lex variable which needs to be @@ -5511,15 +5473,16 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, this value corresponds to the statement being executed. */ thd->lex->sql_command= backup.sql_command; - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - { // Should never happen + + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | + Table_tables_priv | maybe_columns_priv))) + { thd->lex->restore_backup_query_tables_list(&backup); - DBUG_RETURN(TRUE); /* purecov: deadcode */ + DBUG_RETURN(result != 1); } if (!revoke_grant) create_new_users= test_if_create_new_users(thd); - bool result= FALSE; mysql_rwlock_wrlock(&LOCK_grant); mysql_mutex_lock(&acl_cache->lock); MEM_ROOT *old_root= thd->mem_root; @@ -5539,7 +5502,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (copy_and_check_auth(Str, tmp_Str, thd->lex)) error= -1; else - error=replace_user_table(thd, tables[0].table, *Str, + error=replace_user_table(thd, tables[USER_TABLE].table, *Str, 0, revoke_grant, create_new_users, MY_TEST(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER)); @@ -5610,17 +5573,18 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, /* update table and columns */ - if (replace_table_table(thd, grant_table, tables[1].table, *Str, - db_name, table_name, + if (replace_table_table(thd, grant_table, tables[TABLES_PRIV_TABLE].table, + *Str, db_name, table_name, rights, column_priv, revoke_grant)) { /* Should only happen if table is crashed */ result= TRUE; /* purecov: deadcode */ } - else if (tables[2].table) + else if (tables[COLUMNS_PRIV_TABLE].table) { - if (replace_column_table(grant_table, tables[2].table, *Str, columns, - db_name, table_name, rights, revoke_grant)) + if (replace_column_table(grant_table, tables[COLUMNS_PRIV_TABLE].table, + *Str, columns, db_name, table_name, rights, + revoke_grant)) { result= TRUE; } @@ -5643,9 +5607,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (!result) /* success */ my_ok(thd); - /* Tables are automatically closed */ thd->lex->restore_backup_query_tables_list(&backup); - /* Restore the state of binlog format */ DBUG_RETURN(result); } @@ -5671,18 +5633,11 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, { List_iterator str_list (user_list); LEX_USER *Str, *tmp_Str; - TABLE_LIST tables[2]; - bool create_new_users=0, result=0; + TABLE_LIST tables[TABLES_MAX]; + bool create_new_users= 0, result; char *db_name, *table_name; - Rpl_filter *rpl_filter; DBUG_ENTER("mysql_routine_grant"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), - "--skip-grant-tables"); - DBUG_RETURN(TRUE); - } if (rights & ~PROC_ACLS) { my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), @@ -5696,36 +5651,9 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, DBUG_RETURN(TRUE); } - /* open the mysql.user and mysql.procs_priv tables */ - - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_WRITE); - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("procs_priv"), "procs_priv", TL_WRITE); - tables[0].next_local= tables[0].next_global= tables+1; - -#ifdef HAVE_REPLICATION - /* - GRANT and REVOKE are applied the slave in/exclusion rules as they are - some kind of updates to the mysql.% tables. - */ - if (thd->slave_thread && - (rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter)->is_on()) - { - /* - The tables must be marked "updating" so that tables_ok() takes them into - account in tests. - */ - tables[0].updating= tables[1].updating= 1; - if (!(thd->spcont || rpl_filter->tables_ok(0, tables))) - { - DBUG_RETURN(FALSE); - } - } -#endif - - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - DBUG_RETURN(TRUE); + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | + Table_procs_priv))) + DBUG_RETURN(result != 1); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); @@ -5748,7 +5676,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, continue; } /* Create user if needed */ - error=replace_user_table(thd, tables[0].table, *Str, + error=replace_user_table(thd, tables[USER_TABLE].table, *Str, 0, revoke_grant, create_new_users, MY_TEST(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER)); @@ -5783,8 +5711,9 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, } } - if (replace_routine_table(thd, grant_name, tables[1].table, *Str, - db_name, table_name, is_proc, rights, + if (no_such_table(tables + PROCS_PRIV_TABLE) || + replace_routine_table(thd, grant_name, tables[PROCS_PRIV_TABLE].table, + *Str, db_name, table_name, is_proc, rights, revoke_grant) != 0) { result= TRUE; @@ -5902,7 +5831,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) entries for the command to be valid */ DBUG_ASSERT(list.elements >= 2); - bool result= 0; + int result; bool create_new_user, no_auto_create_user; String wrong_users; LEX_USER *user, *granted_role; @@ -5923,16 +5852,10 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) no_auto_create_user= MY_TEST(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER); - TABLE_LIST tables[2]; - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("roles_mapping"), - "roles_mapping", TL_WRITE); - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_WRITE); - tables[0].next_local= tables[0].next_global= tables+1; - - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - DBUG_RETURN(TRUE); /* purecov: deadcode */ + TABLE_LIST tables[TABLES_MAX]; + if ((result= open_grant_tables(thd, tables, TL_WRITE, + Table_user | Table_roles_mapping))) + DBUG_RETURN(result != 1); mysql_rwlock_wrlock(&LOCK_grant); mysql_mutex_lock(&acl_cache->lock); @@ -6028,7 +5951,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) user_combo.user = username; /* create the user if it does not exist */ - if (replace_user_table(thd, tables[1].table, user_combo, 0, + if (replace_user_table(thd, tables[USER_TABLE].table, user_combo, 0, false, create_new_user, no_auto_create_user)) { @@ -6094,7 +6017,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) } /* write into the roles_mapping table */ - if (replace_roles_mapping_table(tables[0].table, + if (replace_roles_mapping_table(tables[ROLES_MAPPING_TABLE].table, &username, &hostname, &rolename, thd->lex->with_admin_option, hash_entry, revoke)) @@ -6144,18 +6067,10 @@ bool mysql_grant(THD *thd, const char *db, List &list, List_iterator str_list (list); LEX_USER *Str, *tmp_Str, *proxied_user= NULL; char tmp_db[SAFE_NAME_LEN+1]; - bool create_new_users=0; - TABLE_LIST tables[2]; - Rpl_filter *rpl_filter; + bool create_new_users=0, result; + TABLE_LIST tables[TABLES_MAX]; DBUG_ENTER("mysql_grant"); - if (!initialized) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), - "--skip-grant-tables"); /* purecov: tested */ - DBUG_RETURN(TRUE); /* purecov: tested */ - } - if (lower_case_table_names && db) { char *end= strnmov(tmp_db,db, sizeof(tmp_db)); @@ -6174,42 +6089,9 @@ bool mysql_grant(THD *thd, const char *db, List &list, proxied_user= str_list++; } - /* open the mysql.user and mysql.db or mysql.proxies_priv tables */ - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_WRITE); - if (is_proxy) - - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("proxies_priv"), - "proxies_priv", - TL_WRITE); - else - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("db"), - "db", - TL_WRITE); - tables[0].next_local= tables[0].next_global= tables+1; - -#ifdef HAVE_REPLICATION - /* - GRANT and REVOKE are applied the slave in/exclusion rules as they are - some kind of updates to the mysql.% tables. - */ - if (thd->slave_thread && - (rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter)->is_on()) - { - /* - The tables must be marked "updating" so that tables_ok() takes them into - account in tests. - */ - tables[0].updating= tables[1].updating= 1; - if (!(thd->spcont || rpl_filter->tables_ok(0, tables))) - DBUG_RETURN(FALSE); - } -#endif - - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - DBUG_RETURN(TRUE); /* purecov: deadcode */ + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | + (is_proxy ? Table_proxies_priv : Table_db)))) + DBUG_RETURN(result != 1); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); @@ -6228,7 +6110,6 @@ bool mysql_grant(THD *thd, const char *db, List &list, DBUG_ASSERT(proxied_user->host.length); // not a Role } - int result=0; while ((tmp_Str = str_list++)) { if (!(Str= get_current_user(thd, tmp_Str, false))) @@ -6240,7 +6121,7 @@ bool mysql_grant(THD *thd, const char *db, List &list, if (copy_and_check_auth(Str, tmp_Str, thd->lex)) result= -1; else - if (replace_user_table(thd, tables[0].table, *Str, + if (replace_user_table(thd, tables[USER_TABLE].table, *Str, (!db ? rights : 0), revoke_grant, create_new_users, MY_TEST(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER))) @@ -6250,7 +6131,7 @@ bool mysql_grant(THD *thd, const char *db, List &list, ulong db_rights= rights & DB_ACLS; if (db_rights == rights) { - if (replace_db_table(tables[1].table, db, *Str, db_rights, + if (replace_db_table(tables[DB_TABLE].table, db, *Str, db_rights, revoke_grant)) result= -1; } @@ -6262,9 +6143,11 @@ bool mysql_grant(THD *thd, const char *db, List &list, } else if (is_proxy) { - if (replace_proxies_priv_table (thd, tables[1].table, Str, proxied_user, - rights & GRANT_ACL ? TRUE : FALSE, - revoke_grant)) + if (no_such_table(tables + PROXIES_PRIV_TABLE) || + replace_proxies_priv_table (thd, tables[PROXIES_PRIV_TABLE].table, + Str, proxied_user, + rights & GRANT_ACL ? TRUE : FALSE, + revoke_grant)) result= -1; } if (Str->is_role()) @@ -6310,10 +6193,10 @@ void grant_free(void) @retval 1 Could not initialize grant subsystem. */ -my_bool grant_init() +bool grant_init() { THD *thd; - my_bool return_val; + bool return_val; DBUG_ENTER("grant_init"); if (!(thd= new THD)) @@ -6343,10 +6226,10 @@ my_bool grant_init() @retval TRUE Error */ -static my_bool grant_load(THD *thd, TABLE_LIST *tables) +static bool grant_load(THD *thd, TABLE_LIST *tables) { MEM_ROOT *memex_ptr; - my_bool return_val= 1; + bool return_val= 1; TABLE *t_table, *c_table, *p_table; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, @@ -6365,9 +6248,9 @@ static my_bool grant_load(THD *thd, TABLE_LIST *tables) 0,0,0, (my_hash_get_key) get_grant_table, 0,0); init_sql_alloc(&grant_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); - t_table= tables[0].table; - c_table= tables[1].table; - p_table= tables[2].table; // this can be NULL + t_table= tables[TABLES_PRIV_TABLE].table; + c_table= tables[COLUMNS_PRIV_TABLE].table; + p_table= tables[PROCS_PRIV_TABLE].table; // this can be NULL if (t_table->file->ha_index_init(0, 1)) goto end_index_init; @@ -6516,38 +6399,22 @@ my_bool role_propagate_grants_action(void *ptr, void *unused __attribute__((unus @retval TRUE Error */ -my_bool grant_reload(THD *thd) +bool grant_reload(THD *thd) { - TABLE_LIST tables[3]; + TABLE_LIST tables[TABLES_MAX]; HASH old_column_priv_hash, old_proc_priv_hash, old_func_priv_hash; MEM_ROOT old_mem; - my_bool return_val= 1; + int result; DBUG_ENTER("grant_reload"); - /* Don't do anything if running with --skip-grant-tables */ - if (!initialized) - DBUG_RETURN(0); - - tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("tables_priv"), - "tables_priv", TL_READ); - tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("columns_priv"), - "columns_priv", TL_READ); - tables[2].init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("procs_priv"), - "procs_priv", TL_READ); - tables[0].next_local= tables[0].next_global= tables+1; - tables[1].next_local= tables[1].next_global= tables+2; - tables[0].open_type= tables[1].open_type= tables[2].open_type= OT_BASE_ONLY; - tables[2].open_strategy= TABLE_LIST::OPEN_IF_EXISTS; - /* To avoid deadlocks we should obtain table locks before obtaining LOCK_grant rwlock. */ - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - goto end; + + if ((result= open_grant_tables(thd, tables, TL_READ, Table_tables_priv | + Table_columns_priv | Table_procs_priv))) + DBUG_RETURN(result != 1); mysql_rwlock_wrlock(&LOCK_grant); grant_version++; @@ -6561,7 +6428,7 @@ my_bool grant_reload(THD *thd) */ old_mem= grant_memroot; - if ((return_val= grant_load(thd, tables))) + if ((result= grant_load(thd, tables))) { // Error. Revert to old hash DBUG_PRINT("error",("Reverting to old privileges")); grant_free(); /* purecov: deadcode */ @@ -6586,8 +6453,7 @@ my_bool grant_reload(THD *thd) close_mysql_tables(thd); -end: - DBUG_RETURN(return_val); + DBUG_RETURN(result); } @@ -6642,7 +6508,7 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, Security_context *sctx= thd->security_ctx; uint i; ulong orig_want_access= want_access; - my_bool locked= 0; + bool locked= 0; GRANT_TABLE *grant_table; GRANT_TABLE *grant_table_role= NULL; DBUG_ENTER("check_grant"); @@ -7417,7 +7283,7 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant, /* Help function for mysql_show_grants */ static void add_user_option(String *grant, long value, const char *name, - my_bool is_signed) + bool is_signed) { if (value) { @@ -7818,13 +7684,13 @@ static bool show_global_privileges(THD *thd, ACL_USER_BASE *acl_entry, if (want_access & GRANT_ACL) global.append(STRING_WITH_LEN(" GRANT OPTION")); add_user_option(&global, acl_user->user_resource.questions, - "MAX_QUERIES_PER_HOUR", 0); + "MAX_QUERIES_PER_HOUR", false); add_user_option(&global, acl_user->user_resource.updates, - "MAX_UPDATES_PER_HOUR", 0); + "MAX_UPDATES_PER_HOUR", false); add_user_option(&global, acl_user->user_resource.conn_per_hour, - "MAX_CONNECTIONS_PER_HOUR", 0); + "MAX_CONNECTIONS_PER_HOUR", false); add_user_option(&global, acl_user->user_resource.user_conn, - "MAX_USER_CONNECTIONS", 1); + "MAX_USER_CONNECTIONS", true); } } @@ -8203,98 +8069,66 @@ void get_mqh(const char *user, const char *host, USER_CONN *uc) } /* - Open the grant tables. + Initialize a TABLE_LIST array and open grant tables - SYNOPSIS - open_grant_tables() - thd The current thread. - tables (out) The 7 elements array for the opened tables. + All tables will be opened with the same lock type, either read or write. - DESCRIPTION - Tables are numbered as follows: - 0 user - 1 db - 2 tables_priv - 3 columns_priv - 4 procs_priv - 5 proxies_priv - 6 roles_mapping - - RETURN - 1 Skip GRANT handling during replication. - 0 OK. - < 0 Error. + @retval 1 replication filters matched. Abort the operation, but return OK (!) + @retval 0 tables were opened successfully + @retval -1 error, tables could not be opened */ -#define GRANT_TABLES 7 -static int open_grant_tables(THD *thd, TABLE_LIST *tables) +static int open_grant_tables(THD *thd, TABLE_LIST *tables, + enum thr_lock_type lock_type, int tables_to_open) { - Rpl_filter *rpl_filter; DBUG_ENTER("open_grant_tables"); - if (!initialized) + /* + We can read privilege tables even when !initialized. + This can be acl_load() - server startup or FLUSH PRIVILEGES + */ + if (lock_type >= TL_WRITE_ALLOW_WRITE && !initialized) { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); DBUG_RETURN(-1); } - tables->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("user"), "user", TL_WRITE); - (tables+1)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("db"), "db", TL_WRITE); - (tables+2)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("tables_priv"), - "tables_priv", TL_WRITE); - (tables+3)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("columns_priv"), - "columns_priv", TL_WRITE); - (tables+4)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("procs_priv"), - "procs_priv", TL_WRITE); - (tables+5)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("proxies_priv"), - "proxies_priv", TL_WRITE); - (tables+5)->open_strategy= TABLE_LIST::OPEN_IF_EXISTS; - (tables+6)->init_one_table(C_STRING_WITH_LEN("mysql"), - C_STRING_WITH_LEN("roles_mapping"), - "roles_mapping", TL_WRITE); - (tables+6)->open_strategy= TABLE_LIST::OPEN_IF_EXISTS; - - - tables->next_local= tables->next_global= tables + 1; - (tables+1)->next_local= (tables+1)->next_global= tables + 2; - (tables+2)->next_local= (tables+2)->next_global= tables + 3; - (tables+3)->next_local= (tables+3)->next_global= tables + 4; - (tables+4)->next_local= (tables+4)->next_global= tables + 5; - (tables+5)->next_local= (tables+5)->next_global= tables + 6; + int prev= -1; + bzero(tables, sizeof(TABLE_LIST) * TABLES_MAX); + for (int cur=TABLES_MAX-1, mask= 1 << cur; mask; cur--, mask >>= 1) + { + if ((tables_to_open & mask) == 0) + continue; + tables[cur].init_one_table(C_STRING_WITH_LEN("mysql"), + acl_table_names[cur].str, + acl_table_names[cur].length, + acl_table_names[cur].str, lock_type); + tables[cur].open_type= OT_BASE_ONLY; + if (lock_type >= TL_WRITE_ALLOW_WRITE) + tables[cur].updating= 1; + if (cur >= FIRST_OPTIONAL_TABLE) + tables[cur].open_strategy= TABLE_LIST::OPEN_IF_EXISTS; + if (prev != -1) + tables[cur].next_local= tables[cur].next_global= & tables[prev]; + prev= cur; + } #ifdef HAVE_REPLICATION - /* - GRANT and REVOKE are applied the slave in/exclusion rules as they are - some kind of updates to the mysql.% tables. - */ - if (thd->slave_thread && - (rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter)->is_on()) + if (lock_type >= TL_WRITE_ALLOW_WRITE && thd->slave_thread && !thd->spcont) { /* - The tables must be marked "updating" so that tables_ok() takes them into - account in tests. + GRANT and REVOKE are applied the slave in/exclusion rules as they are + some kind of updates to the mysql.% tables. */ - tables[0].updating= tables[1].updating= tables[2].updating= - tables[3].updating= tables[4].updating= tables[5].updating= - tables[6].updating= 1; - if (!(thd->spcont || rpl_filter->tables_ok(0, tables))) + Rpl_filter *rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter; + if (rpl_filter->is_on() && !rpl_filter->tables_ok(0, tables)) DBUG_RETURN(1); - tables[0].updating= tables[1].updating= tables[2].updating= - tables[3].updating= tables[4].updating= tables[5].updating= - tables[6].updating= 0; } #endif - if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - { // This should never happen + if (open_and_lock_tables(thd, tables + prev, FALSE, + MYSQL_LOCK_IGNORE_TIMEOUT)) DBUG_RETURN(-1); - } DBUG_RETURN(0); } @@ -8371,7 +8205,7 @@ static int modify_grant_table(TABLE *table, Field *host_field, } /* - Handle the roles_mappings privilege table + Handle the roles_mapping privilege table */ static int handle_roles_mappings_table(TABLE *table, bool drop, LEX_USER *user_from, LEX_USER *user_to) @@ -8392,7 +8226,7 @@ static int handle_roles_mappings_table(TABLE *table, bool drop, Field *user_field= table->field[1]; Field *role_field= table->field[2]; - DBUG_PRINT("info", ("Rewriting entry in roles_mappings table: %s@%s", + DBUG_PRINT("info", ("Rewriting entry in roles_mapping table: %s@%s", user_from->user.str, user_from->host.str)); table->use_all_columns(); if ((error= table->file->ha_rnd_init(1))) @@ -8472,14 +8306,6 @@ static int handle_roles_mappings_table(TABLE *table, bool drop, Delete from grant table if drop is true. Update in grant table if drop is false and user_to is not NULL. Search in grant table if drop is false and user_to is NULL. - Tables are numbered as follows: - 0 user - 1 db - 2 tables_priv - 3 columns_priv - 4 procs_priv - 5 proxies_priv - 6 roles_mapping RETURN > 0 At least one record matched. @@ -8487,14 +8313,16 @@ static int handle_roles_mappings_table(TABLE *table, bool drop, < 0 Error. */ -static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, +static int handle_grant_table(TABLE_LIST *tables, + enum enum_acl_tables table_no, bool drop, LEX_USER *user_from, LEX_USER *user_to) { int result= 0; int error; TABLE *table= tables[table_no].table; Field *host_field= table->field[0]; - Field *user_field= table->field[table_no && table_no != 5 ? 2 : 1]; + Field *user_field= table->field[table_no == USER_TABLE || + table_no == PROXIES_PRIV_TABLE ? 1 : 2]; const char *host_str= user_from->host.str; const char *user_str= user_from->user.str; const char *host; @@ -8504,14 +8332,14 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, DBUG_ENTER("handle_grant_table"); THD *thd= current_thd; - if (table_no == 6) + if (table_no == ROLES_MAPPING_TABLE) { result= handle_roles_mappings_table(table, drop, user_from, user_to); DBUG_RETURN(result); } table->use_all_columns(); - if (! table_no) // mysql.user table + if (table_no == USER_TABLE) // mysql.user table { /* The 'user' table has an unique index on (host, user). @@ -8587,7 +8415,7 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, user= safe_str(get_field(thd->mem_root, user_field)); #ifdef EXTRA_DEBUG - if (table_no != 5) + if (table_no != PROXIES_PRIV_TABLE) { DBUG_PRINT("loop",("scan fields: '%s'@'%s' '%s' '%s' '%s'", user, host, @@ -9011,7 +8839,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle db table. */ - if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, DB_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9031,7 +8859,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle stored routines table. */ - if ((found= handle_grant_table(tables, 4, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, PROCS_PRIV_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch in-memory array. */ result= -1; @@ -9059,7 +8887,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle tables table. */ - if ((found= handle_grant_table(tables, 2, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, TABLES_PRIV_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch columns and in-memory array. */ result= -1; @@ -9075,7 +8903,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle columns table. */ - if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, COLUMNS_PRIV_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9092,9 +8920,9 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle proxies_priv table. */ - if (tables[5].table) + if (tables[PROXIES_PRIV_TABLE].table) { - if ((found= handle_grant_table(tables, 5, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, PROXIES_PRIV_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9110,10 +8938,10 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } } - /* Handle roles_mappings table. */ - if (tables[6].table) + /* Handle roles_mapping table. */ + if (tables[ROLES_MAPPING_TABLE].table) { - if ((found= handle_grant_table(tables, 6, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, ROLES_MAPPING_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9130,7 +8958,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle user table. */ - if ((found= handle_grant_table(tables, 0, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(tables, USER_TABLE, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9169,7 +8997,7 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) String wrong_users; LEX_USER *user_name; List_iterator user_list(list); - TABLE_LIST tables[GRANT_TABLES]; + TABLE_LIST tables[TABLES_MAX]; bool some_users_created= FALSE; DBUG_ENTER("mysql_create_user"); DBUG_PRINT("entry", ("Handle as %s", handle_as_role ? "role" : "user")); @@ -9178,7 +9006,10 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) DBUG_RETURN(TRUE); /* CREATE USER may be skipped on replication client. */ - if ((result= open_grant_tables(thd, tables))) + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | Table_db | + Table_tables_priv | Table_columns_priv | + Table_procs_priv | Table_proxies_priv | + Table_roles_mapping))) DBUG_RETURN(result != 1); mysql_rwlock_wrlock(&LOCK_grant); @@ -9223,7 +9054,7 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) } some_users_created= TRUE; - if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0)) + if (replace_user_table(thd, tables[USER_TABLE].table, *user_name, 0, 0, 1, 0)) { append_user(thd, &wrong_users, user_name); result= TRUE; @@ -9244,7 +9075,7 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) if (grantee) add_role_user_mapping(grantee, role); - if (replace_roles_mapping_table(tables[6].table, + if (replace_roles_mapping_table(tables[ROLES_MAPPING_TABLE].table, &thd->lex->definer->user, &thd->lex->definer->host, &user_name->user, true, @@ -9295,14 +9126,17 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) String wrong_users; LEX_USER *user_name, *tmp_user_name; List_iterator user_list(list); - TABLE_LIST tables[GRANT_TABLES]; + TABLE_LIST tables[TABLES_MAX]; bool some_users_deleted= FALSE; ulonglong old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("mysql_drop_user"); DBUG_PRINT("entry", ("Handle as %s", handle_as_role ? "role" : "user")); /* DROP USER may be skipped on replication client. */ - if ((result= open_grant_tables(thd, tables))) + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | Table_db | + Table_tables_priv | Table_columns_priv | + Table_procs_priv | Table_proxies_priv | + Table_roles_mapping))) DBUG_RETURN(result != 1); thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; @@ -9385,12 +9219,15 @@ bool mysql_rename_user(THD *thd, List &list) LEX_USER *user_from, *tmp_user_from; LEX_USER *user_to, *tmp_user_to; List_iterator user_list(list); - TABLE_LIST tables[GRANT_TABLES]; + TABLE_LIST tables[TABLES_MAX]; bool some_users_renamed= FALSE; DBUG_ENTER("mysql_rename_user"); /* RENAME USER may be skipped on replication client. */ - if ((result= open_grant_tables(thd, tables))) + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | Table_db | + Table_tables_priv | Table_columns_priv | + Table_procs_priv | Table_proxies_priv | + Table_roles_mapping))) DBUG_RETURN(result != 1); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); @@ -9472,10 +9309,13 @@ bool mysql_revoke_all(THD *thd, List &list) uint counter, revoked, is_proc; int result; ACL_DB *acl_db; - TABLE_LIST tables[GRANT_TABLES]; + TABLE_LIST tables[TABLES_MAX]; DBUG_ENTER("mysql_revoke_all"); - if ((result= open_grant_tables(thd, tables))) + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | Table_db | + Table_tables_priv | Table_columns_priv | + Table_procs_priv | Table_proxies_priv | + Table_roles_mapping))) DBUG_RETURN(result != 1); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); @@ -9501,7 +9341,8 @@ bool mysql_revoke_all(THD *thd, List &list) continue; } - if (replace_user_table(thd, tables[0].table, *lex_user, ~(ulong)0, 1, 0, 0)) + if (replace_user_table(thd, tables[USER_TABLE].table, *lex_user, + ~(ulong)0, 1, 0, 0)) { result= -1; continue; @@ -9527,7 +9368,7 @@ bool mysql_revoke_all(THD *thd, List &list) if (!strcmp(lex_user->user.str, user) && !strcmp(lex_user->host.str, host)) { - if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, + if (!replace_db_table(tables[DB_TABLE].table, acl_db->db, *lex_user, ~(ulong)0, 1)) { /* @@ -9557,10 +9398,10 @@ bool mysql_revoke_all(THD *thd, List &list) if (!strcmp(lex_user->user.str,user) && !strcmp(lex_user->host.str, host)) { - if (replace_table_table(thd,grant_table,tables[2].table,*lex_user, - grant_table->db, - grant_table->tname, - ~(ulong)0, 0, 1)) + if (replace_table_table(thd, grant_table, + tables[TABLES_PRIV_TABLE].table, + *lex_user, grant_table->db, + grant_table->tname, ~(ulong)0, 0, 1)) { result= -1; } @@ -9572,11 +9413,10 @@ bool mysql_revoke_all(THD *thd, List &list) continue; } List columns; - if (!replace_column_table(grant_table,tables[3].table, *lex_user, - columns, - grant_table->db, - grant_table->tname, - ~(ulong)0, 1)) + if (!replace_column_table(grant_table, + tables[COLUMNS_PRIV_TABLE].table, + *lex_user, columns, grant_table->db, + grant_table->tname, ~(ulong)0, 1)) { revoked= 1; continue; @@ -9601,11 +9441,10 @@ bool mysql_revoke_all(THD *thd, List &list) if (!strcmp(lex_user->user.str,user) && !strcmp(lex_user->host.str, host)) { - if (replace_routine_table(thd,grant_proc,tables[4].table,*lex_user, - grant_proc->db, - grant_proc->tname, - is_proc, - ~(ulong)0, 1) == 0) + if (replace_routine_table(thd, grant_proc, + tables[PROCS_PRIV_TABLE].table, *lex_user, + grant_proc->db, grant_proc->tname, + is_proc, ~(ulong)0, 1) == 0) { revoked= 1; continue; @@ -9638,9 +9477,8 @@ bool mysql_revoke_all(THD *thd, List &list) ROLE_GRANT_PAIR *pair = find_role_grant_pair(&lex_user->user, &lex_user->host, &role_grant->user); - if (replace_roles_mapping_table(tables[6].table, - &lex_user->user, - &lex_user->host, + if (replace_roles_mapping_table(tables[ROLES_MAPPING_TABLE].table, + &lex_user->user, &lex_user->host, &role_grant->user, false, pair, true)) { result= -1; //Something went wrong @@ -9769,12 +9607,15 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, { uint counter, revoked; int result; - TABLE_LIST tables[GRANT_TABLES]; + TABLE_LIST tables[TABLES_MAX]; HASH *hash= is_proc ? &proc_priv_hash : &func_priv_hash; Silence_routine_definer_errors error_handler; DBUG_ENTER("sp_revoke_privileges"); - if ((result= open_grant_tables(thd, tables))) + if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user | Table_db | + Table_tables_priv | Table_columns_priv | + Table_procs_priv | Table_proxies_priv | + Table_roles_mapping))) DBUG_RETURN(result != 1); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); @@ -9799,7 +9640,8 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, lex_user.user.length= strlen(grant_proc->user); lex_user.host.str= safe_str(grant_proc->host.hostname); lex_user.host.length= strlen(lex_user.host.str); - if (replace_routine_table(thd,grant_proc,tables[4].table,lex_user, + if (replace_routine_table(thd, grant_proc, + tables[PROCS_PRIV_TABLE].table, lex_user, grant_proc->db, grant_proc->tname, is_proc, ~(ulong)0, 1) == 0) { diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 1aeb123153e..3f628b5a082 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -197,8 +197,8 @@ static inline int access_denied_error_code(int passwd_used) /* prototypes */ bool hostname_requires_resolving(const char *hostname); -my_bool acl_init(bool dont_read_acl_tables); -my_bool acl_reload(THD *thd); +bool acl_init(bool dont_read_acl_tables); +bool acl_reload(THD *thd); void acl_free(bool end=0); ulong acl_get(const char *host, const char *ip, const char *user, const char *db, my_bool db_is_pattern); @@ -220,9 +220,9 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table, List &user_list, bool mysql_routine_grant(THD *thd, TABLE_LIST *table, bool is_proc, List &user_list, ulong rights, bool revoke, bool write_to_binlog); -my_bool grant_init(); +bool grant_init(); void grant_free(void); -my_bool grant_reload(THD *thd); +bool grant_reload(THD *thd); bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, bool any_combination_will_do, uint number, bool no_errors); bool check_grant_column (THD *thd, GRANT_INFO *grant, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 055806609e7..d60506dcad7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5508,6 +5508,7 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables, @param thd Thread context. @param hton Storage engine of the table, if known, or NULL otherwise. + @param frm frm image @param path Path (without .frm) @param db Database name. @param table_name Table name. @@ -5527,6 +5528,7 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables, */ TABLE *open_table_uncached(THD *thd, handlerton *hton, + LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name, bool add_to_temporary_tables_list, @@ -5561,7 +5563,17 @@ TABLE *open_table_uncached(THD *thd, handlerton *hton, strend(saved_cache_key)+1, tmp_path); share->db_plugin= ha_lock_engine(thd, hton); - if (open_table_def(thd, share, GTS_TABLE | GTS_USE_DISCOVERY)) + /* + Use the frm image, if possible, open the file otherwise. + + The image might be unavailable in ALTER TABLE, when the discovering + engine took over the ownership (see TABLE::read_frm_image). + */ + int res= frm->str + ? share->init_from_binary_frm_image(thd, false, frm->str, frm->length) + : open_table_def(thd, share, GTS_TABLE | GTS_USE_DISCOVERY); + + if (res) { /* No need to lock share->mutex as this is not needed for tmp tables */ free_table_share(share); diff --git a/sql/sql_base.h b/sql/sql_base.h index 61442843a39..6f8e9c1c03b 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -127,7 +127,8 @@ bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias, bool get_key_map_from_key_list(key_map *map, TABLE *table, List *index_list); -TABLE *open_table_uncached(THD *thd, handlerton *hton, const char *path, +TABLE *open_table_uncached(THD *thd, handlerton *hton, + LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name, bool add_to_temporary_tables_list, bool open_in_engine); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2828567fbc3..b2dd38ad720 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3597,7 +3597,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, options[0].typelib= options[1].typelib= &global_plugin_typelib; strxnmov(comment, max_comment_len, "Enable or disable ", plugin_name, - " plugin. Possible values are ON, OFF, FORCE (don't start " + " plugin. One of: ON, OFF, FORCE (don't start " "if the plugin fails to load).", NullS); options[0].comment= comment; /* diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 56a3a1861c5..80ac0978834 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4847,7 +4847,7 @@ int create_table_impl(THD *thd, THD::temporary_tables list. */ - TABLE *table= open_table_uncached(thd, create_info->db_type, path, + TABLE *table= open_table_uncached(thd, create_info->db_type, frm, path, db, table_name, true, true); if (!table) @@ -8691,7 +8691,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, // We assume that the table is non-temporary. DBUG_ASSERT(!table->s->tmp_table); - if (!(altered_table= open_table_uncached(thd, new_db_type, + if (!(altered_table= open_table_uncached(thd, new_db_type, &frm, alter_ctx.get_tmp_path(), alter_ctx.new_db, alter_ctx.tmp_name, @@ -8845,7 +8845,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (create_info->tmp_table()) { - if (!open_table_uncached(thd, new_db_type, + if (!open_table_uncached(thd, new_db_type, &frm, alter_ctx.get_tmp_path(), alter_ctx.new_db, alter_ctx.tmp_name, true, true)) @@ -8867,7 +8867,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { /* table is a normal table: Create temporary table in same directory */ /* Open our intermediate table. */ - new_table= open_table_uncached(thd, new_db_type, alter_ctx.get_tmp_path(), + new_table= open_table_uncached(thd, new_db_type, &frm, + alter_ctx.get_tmp_path(), alter_ctx.new_db, alter_ctx.tmp_name, true, true); } @@ -9073,24 +9074,6 @@ end_inplace: if (write_bin_log(thd, true, thd->query(), thd->query_length())) DBUG_RETURN(true); - if (ha_check_storage_engine_flag(old_db_type, HTON_FLUSH_AFTER_RENAME)) - { - /* - For the alter table to be properly flushed to the logs, we - have to open the new table. If not, we get a problem on server - shutdown. But we do not need to attach MERGE children. - */ - TABLE *t_table; - t_table= open_table_uncached(thd, new_db_type, alter_ctx.get_new_path(), - alter_ctx.new_db, alter_ctx.new_name, - false, true); - if (t_table) - intern_close_table(t_table); - else - sql_print_warning("Could not open table %s.%s after rename\n", - alter_ctx.new_db, alter_ctx.table_name); - ha_flush_logs(old_db_type); - } table_list->table= NULL; // For query cache query_cache_invalidate3(thd, table_list, false); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index fe2ea02a8e2..e98679b1d51 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -261,52 +261,6 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, } -/* - Close and recreate a temporary table. In case of success, - write truncate statement into the binary log if in statement - mode. - - @param thd Thread context. - @param table The temporary table. - - @retval FALSE Success. - @retval TRUE Error. -*/ - -static bool recreate_temporary_table(THD *thd, TABLE *table) -{ - bool error= TRUE; - TABLE_SHARE *share= table->s; - handlerton *table_type= table->s->db_type(); - TABLE *new_table; - DBUG_ENTER("recreate_temporary_table"); - - table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); - - /* Don't free share. */ - close_temporary_table(thd, table, FALSE, FALSE); - - dd_recreate_table(thd, share->db.str, share->table_name.str, - share->normalized_path.str); - - if ((new_table= open_table_uncached(thd, table_type, share->path.str, - share->db.str, - share->table_name.str, true, true))) - { - error= FALSE; - thd->thread_specific_used= TRUE; - new_table->s->table_creation_was_logged= share->table_creation_was_logged; - } - else - rm_temporary_table(table_type, share->path.str); - - free_table_share(share); - my_free(table); - - DBUG_RETURN(error); -} - - /* Handle locking a base table for truncate. @@ -441,30 +395,10 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) /* If it is a temporary table, no need to take locks. */ if (is_temporary_table(table_ref)) { - TABLE *tmp_table= table_ref->table; - /* In RBR, the statement is not binlogged if the table is temporary. */ binlog_stmt= !thd->is_current_stmt_binlog_format_row(); - /* Note that a temporary table cannot be partitioned. */ - if (ha_check_storage_engine_flag(tmp_table->s->db_type(), - HTON_CAN_RECREATE)) - { - if ((error= recreate_temporary_table(thd, tmp_table))) - binlog_stmt= FALSE; /* No need to binlog failed truncate-by-recreate. */ - - DBUG_ASSERT(! thd->transaction.stmt.modified_non_trans_table); - } - else - { - /* - The engine does not support truncate-by-recreate. Open the - table and invoke the handler truncate. In such a manner this - can in fact open several tables if it's a temporary MyISAMMRG - table. - */ - error= handler_truncate(thd, table_ref, TRUE); - } + error= handler_truncate(thd, table_ref, TRUE); /* No need to invalidate the query cache, queries with temporary diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index cf92a5e6197..913ae9d4d4f 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -483,9 +483,7 @@ static Sys_var_enum Sys_binlog_format( "based binary logging except for those statements where only row-" "based is correct: those which involve user-defined functions (i.e. " "UDFs) or the UUID() function; for those, row-based binary logging is " - "automatically used. If NDBCLUSTER is enabled and binlog-format is " - "MIXED, the format switches to row-based and back implicitly per each " - "query accessing an NDBCLUSTER table", + "automatically used.", SESSION_VAR(binlog_format), CMD_LINE(REQUIRED_ARG, OPT_BINLOG_FORMAT), binlog_format_names, DEFAULT(BINLOG_FORMAT_STMT), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_format_check), @@ -649,8 +647,7 @@ static Sys_var_struct Sys_character_set_filesystem( static const char *completion_type_names[]= {"NO_CHAIN", "CHAIN", "RELEASE", 0}; static Sys_var_enum Sys_completion_type( - "completion_type", "The transaction completion type, one of " - "NO_CHAIN, CHAIN, RELEASE", + "completion_type", "The transaction completion type", SESSION_VAR(completion_type), CMD_LINE(REQUIRED_ARG), completion_type_names, DEFAULT(0)); @@ -717,8 +714,7 @@ static Sys_var_struct Sys_collation_server( static const char *concurrent_insert_names[]= {"NEVER", "AUTO", "ALWAYS", 0}; static Sys_var_enum Sys_concurrent_insert( - "concurrent_insert", "Use concurrent insert with MyISAM. Possible " - "values are NEVER, AUTO, ALWAYS", + "concurrent_insert", "Use concurrent insert with MyISAM", GLOBAL_VAR(myisam_concurrent_insert), CMD_LINE(OPT_ARG), concurrent_insert_names, DEFAULT(1)); @@ -2196,37 +2192,7 @@ static bool fix_optimizer_switch(sys_var *self, THD *thd, } static Sys_var_flagset Sys_optimizer_switch( "optimizer_switch", - "optimizer_switch=option=val[,option=val...], where option is one of {" - "derived_merge, " - "derived_with_keys, " - "firstmatch, " - "in_to_exists, " - "engine_condition_pushdown, " - "index_condition_pushdown, " - "index_merge, " - "index_merge_intersection, " - "index_merge_sort_intersection, " - "index_merge_sort_union, " - "index_merge_union, " - "join_cache_bka, " - "join_cache_hashed, " - "join_cache_incremental, " - "loosescan, " - "materialization, " - "mrr, " - "mrr_cost_based, " - "mrr_sort_keys, " - "optimize_join_buffer_size, " - "outer_join_with_cache, " - "partial_match_rowid_merge, " - "partial_match_table_scan, " - "semijoin, " - "semijoin_with_cache, " - "subquery_cache, " - "table_elimination, " - "extended_keys, " - "exists_to_in " - "} and val is one of {on, off, default}", + "Fine-tune the optimizer behavior", SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG), optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), @@ -2546,12 +2512,8 @@ static const char *thread_handling_names[]= static Sys_var_enum Sys_thread_handling( "thread_handling", - "Define threads usage for handling queries, one of " - "one-thread-per-connection, no-threads" -#ifdef HAVE_POOL_OF_THREADS - ", pool-of-threads" -#endif - , READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG), + "Define threads usage for handling queries", + READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG), thread_handling_names, DEFAULT(DEFAULT_THREAD_HANDLING) ); @@ -2758,11 +2720,9 @@ static Sys_var_enum Slave_run_triggers_for_rbr( static const char *slave_type_conversions_name[]= {"ALL_LOSSY", "ALL_NON_LOSSY", 0}; static Sys_var_set Slave_type_conversions( "slave_type_conversions", - "Set of slave type conversions that are enabled. Legal values are:" - " ALL_LOSSY to enable lossy conversions and" - " ALL_NON_LOSSY to enable non-lossy conversions." - " If the variable is assigned the empty set, no conversions are" - " allowed and it is expected that the types match exactly.", + "Set of slave type conversions that are enabled." + " If the variable is empty, no conversions are" + " allowed and it is expected that the types match exactly", GLOBAL_VAR(slave_type_conversions_options), CMD_LINE(REQUIRED_ARG), slave_type_conversions_name, DEFAULT(0)); @@ -2785,7 +2745,7 @@ static Sys_var_mybool Sys_master_verify_checksum( /* These names must match RPL_SKIP_XXX #defines in slave.h. */ static const char *replicate_events_marked_for_skip_names[]= { - "replicate", "filter_on_slave", "filter_on_master", 0 + "REPLICATE", "FILTER_ON_SLAVE", "FILTER_ON_MASTER", 0 }; bool @@ -2931,8 +2891,7 @@ export bool sql_mode_string_representation(THD *thd, ulonglong sql_mode, */ static Sys_var_set Sys_sql_mode( "sql_mode", - "Syntax: sql-mode=mode[,mode[,mode...]]. See the manual for the " - "complete list of valid sql modes", + "Sets the sql mode", SESSION_VAR(sql_mode), CMD_LINE(REQUIRED_ARG), sql_mode_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_mode), ON_UPDATE(fix_sql_mode)); @@ -2957,9 +2916,7 @@ export bool old_mode_string_representation(THD *thd, ulonglong sql_mode, */ static Sys_var_set Sys_old_behavior( "old_mode", - "Used to emulate old behavior from earlier MariaDB or MySQL versions. " - "Syntax: old_mode=mode[,mode[,mode...]]. " - "See the manual for the complete list of valid old modes", + "Used to emulate old behavior from earlier MariaDB or MySQL versions", SESSION_VAR(old_behavior), CMD_LINE(REQUIRED_ARG), old_mode_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG); @@ -4009,8 +3966,7 @@ static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type) static const char *log_output_names[] = { "NONE", "FILE", "TABLE", NULL}; static Sys_var_set Sys_log_output( - "log_output", "Syntax: log-output=value[,value...], " - "where \"value\" could be TABLE, FILE or NONE", + "log_output", "How logs should be written", GLOBAL_VAR(log_output_options), CMD_LINE(REQUIRED_ARG), log_output_names, DEFAULT(LOG_FILE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_empty_set), ON_UPDATE(fix_log_output)); @@ -4494,9 +4450,8 @@ export const char *plugin_maturity_names[]= { "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 }; static Sys_var_enum Sys_plugin_maturity( "plugin_maturity", - "The lowest desirable plugin maturity " - "(unknown, experimental, alpha, beta, gamma, or stable). " - "Plugins less mature than that will not be installed or loaded.", + "The lowest desirable plugin maturity. " + "Plugins less mature than that will not be installed or loaded", READ_ONLY GLOBAL_VAR(plugin_maturity), CMD_LINE(REQUIRED_ARG), plugin_maturity_names, DEFAULT(MariaDB_PLUGIN_MATURITY_UNKNOWN)); @@ -4567,10 +4522,7 @@ static const char *log_slow_filter_names[]= }; static Sys_var_set Sys_log_slow_filter( "log_slow_filter", - "Log only certain types of queries. Multiple " - "flags can be specified, separated by commas. Valid values are admin, " - "slave, filesort, filesort_on_disk, full_join, full_scan, query_cache, " - "query_cache_miss, tmp_table, tmp_table_on_disk", + "Log only certain types of queries", SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG), log_slow_filter_names, DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1))); @@ -4608,9 +4560,7 @@ int default_regex_flags_pcre(const THD *thd) } static Sys_var_set Sys_default_regex_flags( "default_regex_flags", - "Default flags for the regex library. " - "Syntax: default-regex-flags='[flag[,flag[,flag...]]]'. " - "See the manual for the complete list of valid flags", + "Default flags for the regex library", SESSION_VAR(default_regex_flags), CMD_LINE(REQUIRED_ARG), default_regex_flags_names, DEFAULT(0)); @@ -4627,8 +4577,7 @@ static const char *log_slow_verbosity_names[]= { "innodb", "query_plan", "explain", 0 }; static Sys_var_set Sys_log_slow_verbosity( "log_slow_verbosity", - "log-slow-verbosity=[value[,value ...]] where value is one of " - "'innodb', 'query_plan', 'explain' ", + "Verbosity level for the slow log", SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG), log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT)); @@ -4694,8 +4643,7 @@ const char *use_stat_tables_modes[] = {"NEVER", "COMPLEMENTARY", "PREFERABLY", 0}; static Sys_var_enum Sys_optimizer_use_stat_tables( "use_stat_tables", - "Specifies how to use system statistics tables. Possible values are " - "NEVER, COMPLEMENTARY, PREFERABLY", + "Specifies how to use system statistics tables", SESSION_VAR(use_stat_tables), CMD_LINE(REQUIRED_ARG), use_stat_tables_modes, DEFAULT(0)); diff --git a/sql/unireg.cc b/sql/unireg.cc index b7ac8b17c38..3eb7a8ce5eb 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -354,8 +354,7 @@ int rea_create_table(THD *thd, LEX_CUSTRING *frm, { DBUG_ENTER("rea_create_table"); - // TODO don't write frm for temp tables - if (no_ha_create_table || create_info->tmp_table()) + if (no_ha_create_table) { if (writefrm(path, db, table_name, true, frm->str, frm->length)) goto err_frm; diff --git a/storage/cassandra/CMakeLists.txt b/storage/cassandra/CMakeLists.txt index 9fdf61908db..e47e654d18e 100644 --- a/storage/cassandra/CMakeLists.txt +++ b/storage/cassandra/CMakeLists.txt @@ -12,20 +12,19 @@ ${Thrift_INCLUDE_DIR} # this may be set # Verify that thrift linking library is found SET(Thrift_LIB_PATHS ${Thrift_LIB_PATHS} /usr/local/lib /opt/local/lib /opt/lib) FIND_LIBRARY(Thrift_LIBS NAMES thrift PATHS ${Thrift_LIB_PATHS} ${Thrift_LIB}) + +MARK_AS_ADVANCED(Thrift_LIBS Thrift_INCLUDE_DIRS) + IF(EXISTS ${Thrift_LIBS}) GET_FILENAME_COMPONENT(LINK_DIR ${Thrift_LIBS} PATH ABSOLUTE) -ELSE() - RETURN() -ENDIF() + INCLUDE_DIRECTORIES(AFTER ${Thrift_INCLUDE_DIRS}/..) + SET(CMAKE_REQUIRED_INCLUDES ${Thrift_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(AFTER ${Thrift_INCLUDE_DIRS}/..) -SET(CMAKE_REQUIRED_INCLUDES ${Thrift_INCLUDE_DIRS}) + STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - -SET(CMAKE_REQUIRED_INCLUDES "${Thrift_INCLUDE_DIRS}/..") -CHECK_CXX_SOURCE_COMPILES( + SET(CMAKE_REQUIRED_INCLUDES "${Thrift_INCLUDE_DIRS}/..") + CHECK_CXX_SOURCE_COMPILES( " #include #include @@ -34,24 +33,25 @@ int main() { return 0; } " CASSANDRASE_OK) +ENDIF() -IF(CASSANDRASE_OK) - SET(cassandra_sources - ha_cassandra.cc - ha_cassandra.h - cassandra_se.h - cassandra_se.cc - gen-cpp/Cassandra.cpp - gen-cpp/cassandra_types.h - gen-cpp/cassandra_types.cpp - gen-cpp/cassandra_constants.h - gen-cpp/cassandra_constants.cpp - gen-cpp/Cassandra.h) +SET(cassandra_sources + ha_cassandra.cc + ha_cassandra.h + cassandra_se.h + cassandra_se.cc + gen-cpp/Cassandra.cpp + gen-cpp/cassandra_types.h + gen-cpp/cassandra_types.cpp + gen-cpp/cassandra_constants.h + gen-cpp/cassandra_constants.cpp + gen-cpp/Cassandra.h) - LINK_DIRECTORIES(${LINK_DIR}) +LINK_DIRECTORIES(${LINK_DIR}) - SET(CASSANDRA_DEB_FILES "usr/lib/mysql/plugin/ha_cassandra.so" PARENT_SCOPE) +SET(CASSANDRA_DEB_FILES "usr/lib/mysql/plugin/ha_cassandra.so" PARENT_SCOPE) - MYSQL_ADD_PLUGIN(cassandra ${cassandra_sources} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES thrift COMPONENT cassandra-engine) +MYSQL_ADD_PLUGIN(cassandra ${cassandra_sources} STORAGE_ENGINE + ONLY_IF CASSANDRASE_OK + MODULE_ONLY LINK_LIBRARIES thrift COMPONENT cassandra-engine) -ENDIF(CASSANDRASE_OK) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index f8db000a486..41956e5f398 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -232,6 +232,8 @@ IF(CONNECT_WITH_ODBC) DOC "Specify the ODBC driver manager library here." ) + mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR) + IF(ODBC_INCLUDE_DIR AND ODBC_LIBRARY) set(CMAKE_REQUIRED_LIBRARIES ${ODBC_LIBRARY}) set(CMAKE_REQUIRED_INCLUDES ${ODBC_INCLUDE_DIR}) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 370d4528ead..a2e23ec6985 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -225,12 +225,12 @@ static TYPELIB innodb_stats_method_typelib = { /** Possible values for system variable "innodb_checksum_algorithm". */ static const char* innodb_checksum_algorithm_names[] = { - "crc32", - "strict_crc32", - "innodb", - "strict_innodb", - "none", - "strict_none", + "CRC32", + "STRICT_CRC32", + "INNODB", + "STRICT_INNODB", + "NONE", + "STRICT_NONE", NullS }; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 081e90f89f7..de901ba3b7b 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -217,9 +217,7 @@ static MYSQL_SYSVAR_ULONG(group_commit_interval, maria_group_commit_interval, static MYSQL_SYSVAR_ENUM(log_purge_type, log_purge_type, PLUGIN_VAR_RQCMDARG, - "Specifies how Aria transactional log will be purged. " - "Possible values of name are \"immediate\", \"external\" " - "and \"at_flush\"", + "Specifies how Aria transactional log will be purged", NULL, NULL, TRANSLOG_PURGE_IMMIDIATE, &maria_translog_purge_type_typelib); @@ -251,9 +249,7 @@ static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit, 100, 1, 100, 1); static MYSQL_SYSVAR_SET(recover, maria_recover_options, PLUGIN_VAR_OPCMDARG, - "Specifies how corrupted tables should be automatically repaired." - " Possible values are one or more of \"NORMAL\" (the default), " - "\"BACKUP\", \"FORCE\", or \"QUICK\".", + "Specifies how corrupted tables should be automatically repaired", NULL, NULL, HA_RECOVER_DEFAULT, &maria_recover_typelib); static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG, @@ -268,13 +264,11 @@ static MYSQL_THDVAR_ULONGLONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG, static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG, "Specifies how Aria index statistics collection code should treat " - "NULLs. Possible values are \"nulls_unequal\", \"nulls_equal\", " - "and \"nulls_ignored\".", 0, 0, 0, &maria_stats_method_typelib); + "NULLs", 0, 0, 0, &maria_stats_method_typelib); static MYSQL_SYSVAR_ENUM(sync_log_dir, sync_log_dir, PLUGIN_VAR_RQCMDARG, "Controls syncing directory after log file growth and new file " - "creation. Possible values are \"never\", \"newfile\" and " - "\"always\").", NULL, NULL, TRANSLOG_SYNC_DIR_NEWFILE, + "creation", NULL, NULL, TRANSLOG_SYNC_DIR_NEWFILE, &maria_sync_log_dir_typelib); #ifdef USE_ARIA_FOR_TMP_TABLES diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index bc4c5139810..d1be84d3792 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -42,8 +42,8 @@ const char *myisam_recover_names[] = TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"", myisam_recover_names, NULL}; -const char *myisam_stats_method_names[] = {"nulls_unequal", "nulls_equal", - "nulls_ignored", NullS}; +const char *myisam_stats_method_names[] = {"NULLS_UNEQUAL", "NULLS_EQUAL", + "NULLS_IGNORED", NullS}; TYPELIB myisam_stats_method_typelib= { array_elements(myisam_stats_method_names) - 1, "", myisam_stats_method_names, NULL}; @@ -66,8 +66,7 @@ static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size, myisam_max_temp_length, static MYSQL_SYSVAR_SET(recover_options, myisam_recover_options, PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_READONLY, - "Syntax: myisam-recover-options[=option[,option...]], where option can be " - "DEFAULT, BACKUP, BACKUP_ALL, FORCE, QUICK, or OFF", + "Specifies how corrupted tables should be automatically repaired", NULL, NULL, 1, &myisam_recover_typelib); static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG, diff --git a/storage/oqgraph/CMakeLists.txt b/storage/oqgraph/CMakeLists.txt index 151082469a9..7e10081a08a 100644 --- a/storage/oqgraph/CMakeLists.txt +++ b/storage/oqgraph/CMakeLists.txt @@ -1,9 +1,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +FUNCTION(CHECK_OQGRAPH) MESSAGE(STATUS "Configuring OQGraph") FIND_PACKAGE(Boost) IF(NOT Boost_FOUND) - MESSAGE(STATUS "Boost not found. OQGraph will not be compiled") + MESSAGE(STATUS "Boost not found. OQGraph will not be compiled") RETURN() ENDIF() INCLUDE_DIRECTORIES(BEFORE ${Boost_INCLUDE_DIRS}) @@ -37,26 +38,29 @@ ENDIF() IF(BOOST_OK) ADD_DEFINITIONS(-DHAVE_OQGRAPH) IF(MSVC) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" PARENT_SCOPE) # Fix problem with judy not finding inttypes.h on Windows: ADD_DEFINITIONS(-DJU_WIN) ELSE(MSVC) # Fix lp bug 1221555 with -fpermissive, so that errors in gcc 4.7 become warnings for the time being - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive") STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fno-strict-aliasing -fpermissive" PARENT_SCOPE) ENDIF(MSVC) ADD_DEFINITIONS(-DBOOST_NO_RTTI=1 -DBOOST_NO_TYPEID=1 -DBOOST_DISABLE_ASSERTS=1) - - MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc - oqgraph_shim.cc oqgraph_thunk.cc oqgraph_judy.cc - STORAGE_ENGINE - MODULE_ONLY - RECOMPILE_FOR_EMBEDDED - COMPONENT oqgraph-engine - LINK_LIBRARIES ${Judy_LIBRARIES}) MESSAGE(STATUS "OQGraph OK") ELSE(BOOST_OK) MESSAGE(STATUS "Requisites for OQGraph not met. OQGraph will not be compiled") ENDIF(BOOST_OK) +ENDFUNCTION() + +CHECK_OQGRAPH() +MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc graphcore-graph.cc + oqgraph_shim.cc oqgraph_thunk.cc oqgraph_judy.cc + STORAGE_ENGINE + ONLY_IF BOOST_OK + MODULE_ONLY + RECOMPILE_FOR_EMBEDDED + COMPONENT oqgraph-engine + LINK_LIBRARIES ${Judy_LIBRARIES}) diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index b5993f85656..7dcf96a2ac2 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -10,6 +10,7 @@ int main() { return 0; } ENDIF() IF(NOT TOKUDB_OK OR WITHOUT_TOKUDB OR WITHOUT_TOKUDB_STORAGE_ENGINE) + MYSQL_ADD_PLUGIN(tokudb DISABLED) RETURN() ENDIF() diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index fa3ed7b6899..cd2caaed6a1 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -32,6 +32,7 @@ IF(UNIX) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) ENDIF() FIND_LIBRARY(AIO_LIBRARY aio) + MARK_AS_ADVANCED(AIO_LIBRARY) IF(AIO_LIBRARY) CHECK_LIBRARY_EXISTS(${AIO_LIBRARY} io_queue_init "" HAVE_LIBAIO) IF(HAVE_LIBAIO AND HAVE_LIBAIO_H) @@ -402,17 +403,12 @@ SET(INNOBASE_SOURCES ut/ut0vec.cc ut/ut0wqueue.cc) -IF(WITH_INNODB) - # Legacy option - SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) -ENDIF() - -IF(XTRADB_OK) - MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE - DEFAULT - RECOMPILE_FOR_EMBEDDED - LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT}) -ELSE() +IF(NOT XTRADB_OK) MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") ENDIF() +MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE + DEFAULT ONLY_IF XTRADB_OK + RECOMPILE_FOR_EMBEDDED + LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT}) + diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index cf39f84b55f..28915098d6c 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -231,12 +231,12 @@ static TYPELIB innodb_stats_method_typelib = { /** Possible values for system variables "innodb_checksum_algorithm" and "innodb_log_checksum_algorithm". */ static const char* innodb_checksum_algorithm_names[] = { - "crc32", - "strict_crc32", - "innodb", - "strict_innodb", - "none", - "strict_none", + "CRC32", + "STRICT_CRC32", + "INNODB", + "STRICT_INNODB", + "NONE", + "STRICT_NONE", NullS }; @@ -251,8 +251,8 @@ static TYPELIB innodb_checksum_algorithm_typelib = { /** Possible values for system variable "innodb_cleaner_lsn_age_factor". */ static const char* innodb_cleaner_lsn_age_factor_names[] = { - "legacy", - "high_checkpoint", + "LEGACY", + "HIGH_CHECKPOINT", NullS }; @@ -266,8 +266,8 @@ static TYPELIB innodb_cleaner_lsn_age_factor_typelib = { /** Possible values for system variable "innodb_foreground_preflush". */ static const char* innodb_foreground_preflush_names[] = { - "sync_preflush", - "exponential_backoff", + "SYNC_PREFLUSH", + "EXPONENTIAL_BACKOFF", NullS }; @@ -281,8 +281,8 @@ static TYPELIB innodb_foreground_preflush_typelib = { /** Possible values for system variable "innodb_empty_free_list_algorithm". */ static const char* innodb_empty_free_list_algorithm_names[] = { - "legacy", - "backoff", + "LEGACY", + "BACKOFF", NullS }; @@ -17185,9 +17185,7 @@ static MYSQL_SYSVAR_ENUM(log_checksum_algorithm, srv_log_checksum_algorithm, static MYSQL_SYSVAR_BOOL(checksums, innobase_use_checksums, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "DEPRECATED. Use innodb_checksum_algorithm=NONE instead of setting " - "this to OFF. " - "Enable InnoDB checksums validation (enabled by default). " - "Disable with --skip-innodb-checksums.", + "this to OFF", NULL, NULL, TRUE); static MYSQL_SYSVAR_ULONG(log_block_size, innobase_log_block_size, @@ -18028,8 +18026,7 @@ static MYSQL_SYSVAR_UINT(change_buffer_max_size, static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method, PLUGIN_VAR_RQCMDARG, "Specifies how InnoDB index statistics collection code should " - "treat NULLs. Possible values are NULLS_EQUAL (default), " - "NULLS_UNEQUAL and NULLS_IGNORED", + "treat NULLs", NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib); #ifdef UNIV_DEBUG @@ -18194,7 +18191,7 @@ static MYSQL_SYSVAR_ENUM(corrupt_table_action, srv_pass_corrupt_table, "Warn corruptions of user tables as 'corrupt table' instead of not crashing itself, " "when used with file_per_table. " "All file io for the datafile after detected as corrupt are disabled, " - "except for the deletion. Possible options are 'assert', 'warn' & 'salvage'", + "except for the deletion", NULL, NULL, 0, &corrupt_table_action_typelib); static MYSQL_SYSVAR_BOOL(locking_fake_changes, srv_fake_changes_locks,