diff options
279 files changed, 5013 insertions, 2684 deletions
diff --git a/.bzrignore b/.bzrignore index d50c31d58a0..5b2789733fc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -380,6 +380,7 @@ libmysqld/pack.c libmysqld/password.c libmysqld/procedure.cc libmysqld/protocol.cc +libmysqld/protocol_cursor.cc libmysqld/records.cc libmysqld/repl_failsafe.cc libmysqld/set_var.cc @@ -389,6 +390,7 @@ libmysqld/sp.cc libmysqld/sp_cache.cc libmysqld/sp_head.cc libmysqld/sp_pcontext.cc +libmysqld/sp_rcontext.cc libmysqld/spatial.cc libmysqld/sql_acl.cc libmysqld/sql_analyse.cc @@ -644,5 +646,3 @@ vio/test-ssl vio/test-sslclient vio/test-sslserver vio/viotest-ssl -libmysqld/protocol_cursor.cc -libmysqld/sp_rcontext.cc diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index b23648e4d91..f8cf19b2132 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-berkeley-db --with-innodb --without-isam --with-embedded-server --with-openssl" +extra_configs="$extra_configs --with-berkeley-db --with-innodb --without-isam --with-embedded-server --with-openssl --with-raid" . "$path/FINISH.sh" diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index c2609f031a2..af321a0e3c3 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -51,6 +51,7 @@ jani@janikt.pp.saunalahti.fi jani@rhols221.adsl.netsonic.fi jani@rhols221.arenanet.fi jani@ua126d19.elisa.omakaista.fi +jani@ua167d18.elisa.omakaista.fi jcole@abel.spaceapes.com jcole@main.burghcom.com jcole@mugatu.spaceapes.com diff --git a/Docs/Makefile.am b/Docs/Makefile.am index f14aaace1bb..606279f967e 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING ../COPYING.LIB \ +txt_files: ../INSTALL-SOURCE ../COPYING \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt CLEAN_FILES: $(BUILD_SOURCES) @@ -201,10 +201,7 @@ INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ ../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ - -../COPYING.LIB: mysql.info $(GT) - perl -w $(GT) mysql.info "LGPL license" "Function Index" > $@ + perl -w $(GT) mysql.info "GPL license" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt index aeb3a12c263..e567d5676aa 100644 --- a/Docs/mysqld_error.txt +++ b/Docs/mysqld_error.txt @@ -1,6 +1,8 @@ /* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */ +character-set=latin1 + #define ER_HASHCHK 1000 "hashchk", #define ER_NISAMCHK 1001 @@ -14,11 +16,11 @@ #define ER_CANT_CREATE_TABLE 1005 "Can't create table '%-.64s' (errno: %d)", #define ER_CANT_CREATE_DB 1006 -"Can't create database '%-.64s'. (errno: %d)", +"Can't create database '%-.64s' (errno: %d)", #define ER_DB_CREATE_EXISTS 1007 -"Can't create database '%-.64s'. Database exists", +"Can't create database '%-.64s'; database exists", #define ER_DB_DROP_EXISTS 1008 -"Can't drop database '%-.64s'. Database doesn't exist", +"Can't drop database '%-.64s'; database doesn't exist", #define ER_DB_DROP_DELETE 1009 "Error dropping database (can't delete '%-.64s', errno: %d)", #define ER_DB_DROP_RMDIR 1010 @@ -34,7 +36,7 @@ #define ER_CANT_LOCK 1015 "Can't lock file (errno: %d)", #define ER_CANT_OPEN_FILE 1016 -"Can't open file: '%-.64s'. (errno: %d)", +"Can't open file: '%-.64s' (errno: %d)", #define ER_FILE_NOT_FOUND 1017 "Can't find file: '%-.64s' (errno: %d)", #define ER_CANT_READ_DIR 1018 @@ -44,7 +46,7 @@ #define ER_CHECKREAD 1020 "Record has changed since last read in table '%-.64s'", #define ER_DISK_FULL 1021 -"Disk full (%s). Waiting for someone to free some space....", +"Disk full (%s). Waiting for someone to free some space...", #define ER_DUP_KEY 1022 "Can't write, duplicate key in table '%-.64s'", #define ER_ERROR_ON_CLOSE 1023 @@ -62,17 +64,17 @@ #define ER_FORM_NOT_FOUND 1029 "View '%-.64s' doesn't exist for '%-.64s'", #define ER_GET_ERRNO 1030 -"Got error %d from table handler", +"Got error %d from storage engine", #define ER_ILLEGAL_HA 1031 -"Table handler for '%-.64s' doesn't have this option", +"Table storage engine for '%-.64s' doesn't have this option", #define ER_KEY_NOT_FOUND 1032 "Can't find record in '%-.64s'", #define ER_NOT_FORM_FILE 1033 "Incorrect information in file: '%-.64s'", #define ER_NOT_KEYFILE 1034 -"Incorrect key file for table: '%-.64s'. Try to repair it", +"Incorrect key file for table: '%-.64s'; try to repair it", #define ER_OLD_KEYFILE 1035 -"Old key file for table '%-.64s'; Repair it!", +"Old key file for table '%-.64s'; repair it!", #define ER_OPEN_AS_READONLY 1036 "Table '%-.64s' is read only", #define ER_OUTOFMEMORY 1037 @@ -90,9 +92,9 @@ #define ER_HANDSHAKE_ERROR 1043 "Bad handshake", #define ER_DBACCESS_DENIED_ERROR 1044 -"Access denied for user: '%-.32s@%-.64s' to database '%-.64s'", +"Access denied for user: '%-.32s'@'%-.64s' to database '%-.64s'", #define ER_ACCESS_DENIED_ERROR 1045 -"Access denied for user: '%-.32s@%-.64s' (Using password: %s)", +"Access denied for user: '%-.32s'@'%-.64s' (Using password: %s)", #define ER_NO_DB_ERROR 1046 "No Database Selected", #define ER_UNKNOWN_COM_ERROR 1047 @@ -154,7 +156,7 @@ #define ER_WRONG_AUTO_KEY 1075 "Incorrect table definition; There can only be one auto column and it must be defined as a key", #define ER_READY 1076 -"%s: ready for connections\n", +"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n", #define ER_NORMAL_SHUTDOWN 1077 "%s: Normal shutdown\n", #define ER_GOT_SIGNAL 1078 @@ -170,7 +172,7 @@ #define ER_WRONG_FIELD_TERMINATORS 1083 "Field separator argument is not what is expected. Check the manual", #define ER_BLOBS_AND_NO_TERMINATED 1084 -"You can't use fixed rowlength with BLOBs. Please use 'fields terminated by'.", +"You can't use fixed rowlength with BLOBs. Please use 'fields terminated by'", #define ER_TEXTFILE_NOT_READABLE 1085 "The file '%-.64s' must be in the database directory or be readable by all", #define ER_FILE_EXISTS_ERROR 1086 @@ -180,15 +182,15 @@ #define ER_ALTER_INFO 1088 "Records: %ld Duplicates: %ld", #define ER_WRONG_SUB_KEY 1089 -"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the table handler doesn't support unique sub keys", +"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the storage engine doesn't support unique sub keys", #define ER_CANT_REMOVE_ALL_FIELDS 1090 "You can't delete all columns with ALTER TABLE. Use DROP TABLE instead", #define ER_CANT_DROP_FIELD_OR_KEY 1091 "Can't DROP '%-.64s'. Check that column/key exists", #define ER_INSERT_INFO 1092 "Records: %ld Duplicates: %ld Warnings: %ld", -#define ER_INSERT_TABLE_USED 1093 -"INSERT TABLE '%-.64s' isn't allowed in FROM table list", +#define ER_UPDATE_TABLE_USED 1093 +"You can't specify target table '%-.64s' for update in FROM clause", #define ER_NO_SUCH_THREAD 1094 "Unknown thread id: %lu", #define ER_KILL_DENIED_ERROR 1095 @@ -204,13 +206,13 @@ #define ER_TABLE_NOT_LOCKED 1100 "Table '%-.64s' was not locked with LOCK TABLES", #define ER_BLOB_CANT_HAVE_DEFAULT 1101 -"BLOB column '%-.64s' can't have a default value", +"BLOB/TEXT column '%-.64s' can't have a default value", #define ER_WRONG_DB_NAME 1102 "Incorrect database name '%-.100s'", #define ER_WRONG_TABLE_NAME 1103 "Incorrect table name '%-.100s'", #define ER_TOO_BIG_SELECT 1104 -"The SELECT would examine too many records and probably take a very long time. Check your WHERE and use SET OPTION SQL_BIG_SELECTS=1 if the SELECT is ok", +"The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok", #define ER_UNKNOWN_ERROR 1105 "Unknown error", #define ER_UNKNOWN_PROCEDURE 1106 @@ -238,7 +240,7 @@ #define ER_TOO_MANY_FIELDS 1117 "Too many columns", #define ER_TOO_BIG_ROWSIZE 1118 -"Too big row size. The maximum row size, not counting BLOBs, is %d. You have to change some fields to BLOBs", +"Too big row size. The maximum row size for the used table type, not counting BLOBs, is %ld. You have to change some fields to TEXT or BLOBs", #define ER_STACK_OVERRUN 1119 "Thread stack overrun: Used: %ld of a %ld stack. Use 'mysqld -O thread_stack=#' to specify a bigger stack if needed", #define ER_WRONG_OUTER_JOIN 1120 @@ -286,11 +288,11 @@ #define ER_NONEXISTING_GRANT 1141 "There is no such grant defined for user '%-.32s' on host '%-.64s'", #define ER_TABLEACCESS_DENIED_ERROR 1142 -"%-.16s command denied to user: '%-.32s@%-.64s' for table '%-.64s'", +"%-.16s command denied to user: '%-.32s'@'%-.64s' for table '%-.64s'", #define ER_COLUMNACCESS_DENIED_ERROR 1143 -"%-.16s command denied to user: '%-.32s@%-.64s' for column '%-.64s' in table '%-.64s'", +"%-.16s command denied to user: '%-.32s'@'%-.64s' for column '%-.64s' in table '%-.64s'", #define ER_ILLEGAL_GRANT_FOR_TABLE 1144 -"Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used.", +"Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used", #define ER_GRANT_WRONG_HOST_OR_USER 1145 "The host or user argument to GRANT is too long", #define ER_NO_SUCH_TABLE 1146 @@ -332,17 +334,17 @@ #define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164 "The used table type doesn't support AUTO_INCREMENT columns", #define ER_DELAYED_INSERT_TABLE_LOCKED 1165 -"INSERT DELAYED can't be used with table '%-.64s', because it is locked with LOCK TABLES", +"INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", #define ER_WRONG_COLUMN_NAME 1166 "Incorrect column name '%-.100s'", #define ER_WRONG_KEY_COLUMN 1167 -"The used table handler can't index column '%-.64s'", +"The used storage engine can't index column '%-.64s'", #define ER_WRONG_MRG_TABLE 1168 "All tables in the MERGE table are not identically defined", #define ER_DUP_UNIQUE 1169 "Can't write, because of unique constraint, to table '%-.64s'", #define ER_BLOB_KEY_WITHOUT_LENGTH 1170 -"BLOB column '%-.64s' used in key specification without a key length", +"BLOB/TEXT column '%-.64s' used in key specification without a key length", #define ER_PRIMARY_CANT_HAVE_NULL 1171 "All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead", #define ER_TOO_MANY_ROWS 1172 @@ -358,7 +360,7 @@ #define ER_CHECK_NO_SUCH_TABLE 1177 "Can't open table", #define ER_CHECK_NOT_IMPLEMENTED 1178 -"The handler for the table doesn't support %s", +"The storage engine for the table doesn't support %s", #define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 "You are not allowed to execute this command in a transaction", #define ER_ERROR_DURING_COMMIT 1180 @@ -372,7 +374,7 @@ #define ER_NEW_ABORTING_CONNECTION 1184 "Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)", #define ER_DUMP_NOT_IMPLEMENTED 1185 -"The handler for the table does not support binary table dump", +"The storage engine for the table does not support binary table dump", #define ER_FLUSH_MASTER_BINLOG_CLOSED 1186 "Binlog closed, cannot RESET MASTER", #define ER_INDEX_REBUILD 1187 @@ -394,13 +396,13 @@ #define ER_CRASHED_ON_REPAIR 1195 "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", #define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 -"Warning: Some non-transactional changed tables couldn't be rolled back", +"Some non-transactional changed tables couldn't be rolled back", #define ER_TRANS_CACHE_FULL 1197 -"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again", #define ER_SLAVE_MUST_STOP 1198 -"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation cannot be performed with a running slave, run STOP SLAVE first", #define ER_SLAVE_NOT_RUNNING 1199 -"This operation requires a running slave, configure slave and do SLAVE START", +"This operation requires a running slave, configure slave and do START SLAVE", #define ER_BAD_SLAVE 1200 "The server is not configured as slave, fix in config file or with CHANGE MASTER TO", #define ER_MASTER_INFO 1201 @@ -424,19 +426,19 @@ #define ER_WRONG_ARGUMENTS 1210 "Wrong arguments to %s", #define ER_NO_PERMISSION_TO_CREATE_USER 1211 -"%-.32s@%-.64s is not allowed to create new users", +"'%-.32s'@'%-.64s' is not allowed to create new users", #define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 -"Incorrect table definition; All MERGE tables must be in the same database", +"Incorrect table definition; all MERGE tables must be in the same database", #define ER_LOCK_DEADLOCK 1213 "Deadlock found when trying to get lock; Try restarting transaction", -#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214 +#define ER_TABLE_CANT_HANDLE_FT 1214 "The used table type doesn't support FULLTEXT indexes", #define ER_CANNOT_ADD_FOREIGN 1215 "Cannot add foreign key constraint", #define ER_NO_REFERENCED_ROW 1216 -"Cannot add a child row: a foreign key constraint fails", +"Cannot add or update a child row: a foreign key constraint fails", #define ER_ROW_IS_REFERENCED 1217 -"Cannot delete a parent row: a foreign key constraint fails", +"Cannot delete or update a parent row: a foreign key constraint fails", #define ER_CONNECT_TO_MASTER 1218 "Error connecting to master: %-.128s", #define ER_QUERY_ON_MASTER 1219 @@ -475,3 +477,97 @@ "This version of MySQL doesn't yet support '%s'", #define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 "Got fatal error %d: '%-.128s' from master when reading data from binary log", +#define ER_SLAVE_IGNORED_TABLE 1237 +"Slave SQL thread ignored the query because of replicate-*-table rules", +#define ER_WRONG_FK_DEF 1238 +"Wrong foreign key definition for '%-.64s': %s", +#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1239 +"Key reference and table reference doesn't match", +#define ER_OPERAND_COLUMNS 1240 +"Operand should contain %d column(s)", +#define ER_SUBQUERY_NO_1_ROW 1241 +"Subquery returns more than 1 row", +#define ER_UNKNOWN_STMT_HANDLER 1242 +"Unknown prepared statement handler (%ld) given to %s", +#define ER_CORRUPT_HELP_DB 1243 +"Help database is corrupt or does not exist", +#define ER_CYCLIC_REFERENCE 1244 +"Cyclic reference on subqueries", +#define ER_AUTO_CONVERT 1245 +"Converting column '%s' from %s to %s", +#define ER_ILLEGAL_REFERENCE 1246 +"Reference '%-.64s' not supported (%s)", +#define ER_DERIVED_MUST_HAVE_ALIAS 1247 +"Every derived table must have it's own alias", +#define ER_SELECT_REDUCED 1248 +"Select %u was reduced during optimisation", +#define ER_TABLENAME_NOT_ALLOWED_HERE 1249 +"Table '%-.64s' from one of SELECT's can not be used in %-.32s", +#define ER_NOT_SUPPORTED_AUTH_MODE 1250 +"Client does not support authentication protocol requested by server; consider upgrading MySQL client", +#define ER_SPATIAL_CANT_HAVE_NULL 1251 +"All parts of a SPATIAL KEY must be NOT NULL", +#define ER_COLLATION_CHARSET_MISMATCH 1252 +"COLLATION '%s' is not valid for CHARACTER SET '%s'", +#define ER_SLAVE_WAS_RUNNING 1253 +"Slave is already running", +#define ER_SLAVE_WAS_NOT_RUNNING 1254 +"Slave has already been stopped", +#define ER_TOO_BIG_FOR_UNCOMPRESS 1255 +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)", +#define ER_ZLIB_Z_MEM_ERROR 1256 +"ZLIB: Not enough memory available for zlib", +#define ER_ZLIB_Z_BUF_ERROR 1257 +"ZLIB: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", +#define ER_ZLIB_Z_DATA_ERROR 1258 +"ZLIB: Input data was corrupted for zlib", +#define ER_CUT_VALUE_GROUP_CONCAT 1259 +"%d line(s) was(were) cut by group_concat()", +#define ER_WARN_TOO_FEW_RECORDS 1260 +"Record count is fewer than the column count at row %ld"; +#define ER_WARN_TOO_MANY_RECORDS 1261 +"Record count is more than the column count at row %ld"; +#define ER_WARN_NULL_TO_NOTNULL 1262 +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; +#define ER_WARN_DATA_OUT_OF_RANGE 1263 +"Data truncated, out of range for column '%s' at row %ld"; +#define ER_WARN_DATA_TRUNCATED 1264 +"Data truncated for column '%s' at row %ld", +#define ER_WARN_USING_OTHER_HANDLER 1265 +"Using storage engine %s for table '%s'", +#define ER_CANT_AGGREGATE_2COLLATIONS 1266 +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", +#define ER_DROP_USER 1267 +"Can't drop one or more of the requested users", +#define ER_REVOKE_GRANTS 1268 +"Can't revoke all privileges, grant for one or more of the requested users", +#define ER_CANT_AGGREGATE_3COLLATIONS 1269 +"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", +#define ER_CANT_AGGREGATE_NCOLLATIONS 1270 +"Illegal mix of collations for operation '%s'", +#define ER_VARIABLE_IS_NOT_STRUCT 1271 +"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +#define ER_UNKNOWN_COLLATION 1272 +"Unknown collation: '%-.64s'", +#define ER_SLAVE_IGNORED_SSL_PARAMS 1273 +"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support. They can be used later when MySQL slave with SSL will be started.", +#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1274 +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format", +#define ER_WARN_FIELD_RESOLVED 1275 +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", +#define ER_BAD_SLAVE_UNTIL_COND 1276 +"Wrong parameter or combination of parameters for START SLAVE UNTIL", +#define ER_MISSING_SKIP_SLAVE 1277 +"It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL. Otherwise you will get problems if you get an unexpected slave's mysqld restart", +#define ER_UNTIL_COND_IGNORED 1278 +"SQL thread is not to be started so UNTIL options are ignored", +#define ER_WRONG_NAME_FOR_INDEX 1279 +"Incorrect index name '%-.100s'", +#define ER_WRONG_NAME_FOR_CATALOG 1280 +"Incorrect catalog name '%-.100s'", +#define ER_WARN_QC_RESIZE 1281 +"Query cache failed to set size %lu, new query cache size is %lu", +#define ER_BAD_FT_COLUMN 1282 +"Column '%-.64s' cannot be part of FULLTEXT index", +#define ER_UNKNOWN_KEY_CACHE 1283 +"Unknown key cache '%-.100s'", diff --git a/Makefile.am b/Makefile.am index 56e5b78ea90..4e4c2da8082 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,15 +19,13 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory -EXTRA_DIST = INSTALL-SOURCE README \ - COPYING COPYING.LIB zlib +EXTRA_DIST = INSTALL-SOURCE README COPYING zlib SUBDIRS = . include @docs_dirs@ \ @readline_topdir@ sql-common \ @thread_dirs@ pstack @sql_client_dirs@ \ - @sql_server_dirs@ scripts man tests \ + @sql_server_dirs@ scripts man tests SSL\ BUILD @netware_dir@ os2 @libmysqld_dirs@ \ @bench_dirs@ support-files @fs_dirs@ @tools_dirs@ - # Relink after clean linked_sources = linked_client_sources linked_server_sources \ diff --git a/SSL/Makefile.am b/SSL/Makefile.am new file mode 100644 index 00000000000..bd3aad1e3b2 --- /dev/null +++ b/SSL/Makefile.am @@ -0,0 +1,24 @@ +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to create Makefile.in + +EXTRA_DIST= NOTES cacert.pem client-cert.pem client-key.pem \ + client-req.pem run-client run-server server-cert.pem \ + server-key.pem server-req.pem + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index 2e9e1729bed..4f2cbbb5614 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -42,8 +42,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /WX /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -69,7 +69,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 685c9ae1a15..4a9d52232ca 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -100,6 +100,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/comp_err/comp_err.dsp b/VC++Files/comp_err/comp_err.dsp index deaf0627262..d9fc740ced8 100644 --- a/VC++Files/comp_err/comp_err.dsp +++ b/VC++Files/comp_err/comp_err.dsp @@ -38,7 +38,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCSN" /D "DBUG_OFF" /D "_WINDOWS" /D "__WIN__" /D "_MT" /FR /YX /FD /c +# ADD CPP /nologo /G6 /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCSN" /D "DBUG_OFF" /D "_WINDOWS" /D "__WIN__" /D "_MT" /YX /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/innobase/innobase.dsp b/VC++Files/innobase/innobase.dsp index 9985ec7e454..42d7001bdd4 100644 --- a/VC++Files/innobase/innobase.dsp +++ b/VC++Files/innobase/innobase.dsp @@ -43,8 +43,8 @@ RSC=rc.exe # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "__NT__" /D "WIN32" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /GX /Z7 /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MTd /W3 /GX /Z7 /Od /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c +# SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe @@ -68,7 +68,7 @@ LIB32=xilink6.exe -lib # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 8ab15a03110..6b76a6147ff 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -119,6 +119,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/libmysqld/examples/test_libmysqld.dsp b/VC++Files/libmysqld/examples/test_libmysqld.dsp index 0f4b09d963e..6707b8cd8ee 100644 --- a/VC++Files/libmysqld/examples/test_libmysqld.dsp +++ b/VC++Files/libmysqld/examples/test_libmysqld.dsp @@ -7,24 +7,24 @@ CFG=test_libmysqld - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "test_libmysqld.mak".
-!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "test_libmysqld.mak" CFG="test_libmysqld - Win32 Release"
-!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are:
-!MESSAGE +!MESSAGE !MESSAGE "test_libmysqld - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE +!MESSAGE # Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe RSC=rc.exe
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
@@ -38,13 +38,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DBUG_OFF" /FR /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DBUG_OFF" /YX /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x416 /d "NDEBUG"
# ADD RSC /l 0x416 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMTD" /out:"Release/mysql-server.exe"
# Begin Target
diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 953761be297..c753b0d8fe7 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -43,7 +43,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /D "__WIN__" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /D "__WIN__" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x416 /d "NDEBUG"
@@ -70,6 +71,7 @@ LINK32=xilink6.exe # PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MT /W3 /Z7 /Od /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /I "../zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c +# SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x416 /d "_DEBUG"
@@ -186,7 +188,6 @@ SOURCE=..\sql\item_create.cpp # Begin Source File
SOURCE=..\sql\item_func.cpp
-# ADD CPP /I "../zlib" # End Source File
# Begin Source File
diff --git a/VC++Files/libmysqltest/mytest.c b/VC++Files/libmysqltest/mytest.c index ceecbb19902..9af8c486e40 100644 --- a/VC++Files/libmysqltest/mytest.c +++ b/VC++Files/libmysqltest/mytest.c @@ -40,7 +40,7 @@ main( int argc, char * argv[] ) MYSQL_ROW row ;
//....just curious....
- printf( "sizeof( MYSQL ) == %d\n", sizeof( MYSQL ) ) ;
+ printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ; if ( argc == 2 )
{
strcpy( szDB, argv[ 1 ] ) ;
@@ -49,27 +49,31 @@ main( int argc, char * argv[] ) {
strcpy( szDB, "mysql" ) ;
printf("Some mysql struct information (size and offset):\n");
- printf("net:\t%3d %3d\n",sizeof(myData->net),offsetof(MYSQL,net));
- printf("host:\t%3d %3d\n",sizeof(myData->host),offsetof(MYSQL,host));
- printf("port:\t%3d %3d\n",sizeof(myData->port),offsetof(MYSQL,port));
- printf("protocol_version:\t%3d %3d\n",sizeof(myData->protocol_version),
- offsetof(MYSQL,protocol_version));
- printf("thread_id:\t%3d %3d\n",sizeof(myData->thread_id),
- offsetof(MYSQL,thread_id));
- printf("affected_rows:\t%3d %3d\n",sizeof(myData->affected_rows),
- offsetof(MYSQL,affected_rows));
- printf("packet_length:\t%3d %3d\n",sizeof(myData->packet_length),
- offsetof(MYSQL,packet_length));
- printf("status:\t%3d %3d\n",sizeof(myData->status),
- offsetof(MYSQL,status));
- printf("fields:\t%3d %3d\n",sizeof(myData->fields),
- offsetof(MYSQL,fields));
- printf("field_alloc:\t%3d %3d\n",sizeof(myData->field_alloc),
- offsetof(MYSQL,field_alloc));
- printf("free_me:\t%3d %3d\n",sizeof(myData->free_me),
- offsetof(MYSQL,free_me));
- printf("options:\t%3d %3d\n",sizeof(myData->options),
- offsetof(MYSQL,options));
+ printf("net:\t%3d %3d\n",(int) sizeof(myData->net), + (int) offsetof(MYSQL,net)); + printf("host:\t%3d %3d\n",(int) sizeof(myData->host), + (int) offsetof(MYSQL,host)); + printf("port:\t%3d %3d\n", (int) sizeof(myData->port), + (int) offsetof(MYSQL,port)); + printf("protocol_version:\t%3d %3d\n", + (int) sizeof(myData->protocol_version), + (int) offsetof(MYSQL,protocol_version)); + printf("thread_id:\t%3d %3d\n",(int) sizeof(myData->thread_id), + (int) offsetof(MYSQL,thread_id)); + printf("affected_rows:\t%3d %3d\n",(int) sizeof(myData->affected_rows), + (int) offsetof(MYSQL,affected_rows)); + printf("packet_length:\t%3d %3d\n",(int) sizeof(myData->packet_length), + (int) offsetof(MYSQL,packet_length)); + printf("status:\t%3d %3d\n",(int) sizeof(myData->status), + (int) offsetof(MYSQL,status)); + printf("fields:\t%3d %3d\n",(int) sizeof(myData->fields), + (int) offsetof(MYSQL,fields)); + printf("field_alloc:\t%3d %3d\n",(int) sizeof(myData->field_alloc), + (int) offsetof(MYSQL,field_alloc)); + printf("free_me:\t%3d %3d\n",(int) sizeof(myData->free_me), + (int) offsetof(MYSQL,free_me)); + printf("options:\t%3d %3d\n",(int) sizeof(myData->options), + (int) offsetof(MYSQL,options)); puts("");
}
}
diff --git a/VC++Files/myisam/myisam.dsp b/VC++Files/myisam/myisam.dsp index 38cac3a0aba..0b386997e5e 100644 --- a/VC++Files/myisam/myisam.dsp +++ b/VC++Files/myisam/myisam.dsp @@ -25,7 +25,7 @@ CFG=myisam - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisam - Win32 Release" @@ -47,7 +47,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\myisam.lib" @@ -70,7 +70,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_Debug\myisam.lib" @@ -169,6 +169,10 @@ SOURCE=.\mi_key.c # End Source File # Begin Source File +SOURCE=.\mi_keycache.c +# End Source File +# Begin Source File + SOURCE=.\mi_locking.c # End Source File # Begin Source File diff --git a/VC++Files/myisamchk/myisamchk.dsp b/VC++Files/myisamchk/myisamchk.dsp index 0c8e7c00f1a..000e1c11215 100644 --- a/VC++Files/myisamchk/myisamchk.dsp +++ b/VC++Files/myisamchk/myisamchk.dsp @@ -25,7 +25,7 @@ CFG=myisamchk - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisamchk - Win32 Release" @@ -42,14 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/myisamchk.exe" @@ -74,7 +74,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/myisamchk.exe" /pdbtype:sept diff --git a/VC++Files/myisamlog/myisamlog.dsp b/VC++Files/myisamlog/myisamlog.dsp index 6df65add63c..f251712127b 100644 --- a/VC++Files/myisamlog/myisamlog.dsp +++ b/VC++Files/myisamlog/myisamlog.dsp @@ -42,7 +42,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe diff --git a/VC++Files/myisampack/myisampack.dsp b/VC++Files/myisampack/myisampack.dsp index cdfc44331ea..d4d05ec4591 100644 --- a/VC++Files/myisampack/myisampack.dsp +++ b/VC++Files/myisampack/myisampack.dsp @@ -25,7 +25,7 @@ CFG=myisampack - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisampack - Win32 Release" @@ -42,13 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../myisam" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /machine:I386 @@ -73,7 +74,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 4ff8c1df3fc..ea391362b84 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -251,6 +251,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -275,6 +278,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -311,6 +317,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### diff --git a/VC++Files/mysqlmanager/MySqlManager.dsp b/VC++Files/mysqlmanager/MySqlManager.dsp index c6108acfc8f..7f92e091904 100644 --- a/VC++Files/mysqlmanager/MySqlManager.dsp +++ b/VC++Files/mysqlmanager/MySqlManager.dsp @@ -43,8 +43,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX /O1 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu +# ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /WX /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" diff --git a/VC++Files/mysqlshutdown/mysqlshutdown.dsp b/VC++Files/mysqlshutdown/mysqlshutdown.dsp index d4dd389e99d..f1ea7c7d934 100644 --- a/VC++Files/mysqlshutdown/mysqlshutdown.dsp +++ b/VC++Files/mysqlshutdown/mysqlshutdown.dsp @@ -44,7 +44,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /W3 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -72,8 +72,8 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /W3 /Z7 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /G6 /W3 /Z7 /Od /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# SUBTRACT CPP /Fr /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 533d4212e2b..1ec566b5216 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX +# SUBTRACT CPP /WX /Fr /YX # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -117,7 +117,7 @@ SOURCE=.\array.c !ELSEIF "$(CFG)" == "mysys - Win32 Debug" -# ADD CPP /FR +# SUBTRACT CPP /Fr !ELSEIF "$(CFG)" == "mysys - Win32 Max" @@ -126,6 +126,10 @@ SOURCE=.\array.c # End Source File # Begin Source File +SOURCE=".\charset-def.c" +# End Source File +# Begin Source File + SOURCE=.\charset.c # End Source File # Begin Source File @@ -190,6 +194,10 @@ SOURCE=.\mf_keycache.c # End Source File # Begin Source File +SOURCE=.\mf_keycaches.c +# End Source File +# Begin Source File + SOURCE=.\mf_loadpath.c # End Source File # Begin Source File @@ -290,6 +298,10 @@ SOURCE=.\my_copy.c # End Source File # Begin Source File +SOURCE=.\my_crc32.c +# End Source File +# Begin Source File + SOURCE=.\my_create.c # End Source File # Begin Source File diff --git a/client/client_priv.h b/client/client_priv.h index d655619516d..f6d766b7ef9 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -40,4 +40,4 @@ enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_DELETE_MASTER_LOGS, OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL, OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION, - OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER }; + OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH }; diff --git a/client/mysql.cc b/client/mysql.cc index 9129b7dfaa3..7ae30cc5688 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include <locale.h> #endif -const char *VER= "14.2"; +const char *VER= "14.3"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -134,7 +134,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, - default_charset_used= 0; + default_charset_used= 0, opt_secure_auth= 0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; @@ -623,6 +623,9 @@ static struct my_option my_long_options[] = {"max_join_size", OPT_MAX_JOIN_SIZE, "", (gptr*) &max_join_size, (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, 0}, + {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" + " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth, + (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -706,7 +709,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } break; } - break; + break; case 'A': rehash= 0; break; @@ -1621,7 +1624,8 @@ com_go(String *buffer,char *line __attribute__((unused))) char buff[200], time_buff[32], *pos; MYSQL_RES *result; ulong timer, warnings; - uint error=0; + uint error= 0; + int err= 0; if (!status.batch) { @@ -1665,79 +1669,84 @@ com_go(String *buffer,char *line __attribute__((unused))) buffer->length(0); // Remove query on error return error; } - error=0; buffer->length(0); - if (quick) - { - if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) - return put_error(&mysql); - } - else + do { - error= mysql_store_result_for_lazy(&result); - if (error) - return error; - } - - if (verbose >= 3 || !opt_silent) - mysql_end_timer(timer,time_buff); - else - time_buff[0]=0; - if (result) - { - if (!mysql_num_rows(result) && ! quick) + if (quick) { - strmov(buff, "Empty set"); + if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) + return put_error(&mysql); } else { - init_pager(); - if (opt_html) - print_table_data_html(result); - else if (opt_xml) - print_table_data_xml(result); - else if (vertical) - print_table_data_vertically(result); - else if (opt_silent && verbose <= 2 && !output_tables) - print_tab_data(result); + error= mysql_store_result_for_lazy(&result); + if (error) + return error; + } + + if (verbose >= 3 || !opt_silent) + mysql_end_timer(timer,time_buff); + else + time_buff[0]=0; + if (result) + { + if (!mysql_num_rows(result) && ! quick) + { + strmov(buff, "Empty set"); + } else - print_table_data(result); - sprintf(buff,"%ld %s in set", - (long) mysql_num_rows(result), - (long) mysql_num_rows(result) == 1 ? "row" : "rows"); - end_pager(); + { + init_pager(); + if (opt_html) + print_table_data_html(result); + else if (opt_xml) + print_table_data_xml(result); + else if (vertical) + print_table_data_vertically(result); + else if (opt_silent && verbose <= 2 && !output_tables) + print_tab_data(result); + else + print_table_data(result); + sprintf(buff,"%ld %s in set", + (long) mysql_num_rows(result), + (long) mysql_num_rows(result) == 1 ? "row" : "rows"); + end_pager(); + } } - } - else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) - strmov(buff,"Query OK"); - else - sprintf(buff,"Query OK, %ld %s affected", - (long) mysql_affected_rows(&mysql), - (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); - - pos=strend(buff); - if ((warnings= mysql_warning_count(&mysql))) - { - *pos++= ','; - *pos++= ' '; - pos=int2str(warnings, pos, 10); - pos=strmov(pos, " warning"); - if (warnings != 1) - *pos++= 's'; - } - strmov(pos, time_buff); - put_info(buff,INFO_RESULT); - if (mysql_info(&mysql)) - put_info(mysql_info(&mysql),INFO_RESULT); - put_info("",INFO_RESULT); // Empty row - - if (result && !mysql_eof(result)) /* Something wrong when using quick */ + else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) + strmov(buff,"Query OK"); + else + sprintf(buff,"Query OK, %ld %s affected", + (long) mysql_affected_rows(&mysql), + (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); + + pos=strend(buff); + if ((warnings= mysql_warning_count(&mysql))) + { + *pos++= ','; + *pos++= ' '; + pos=int2str(warnings, pos, 10); + pos=strmov(pos, " warning"); + if (warnings != 1) + *pos++= 's'; + } + strmov(pos, time_buff); + put_info(buff,INFO_RESULT); + if (mysql_info(&mysql)) + put_info(mysql_info(&mysql),INFO_RESULT); + put_info("",INFO_RESULT); // Empty row + + if (result && !mysql_eof(result)) /* Something wrong when using quick */ + error= put_error(&mysql); + else if (unbuffered) + fflush(stdout); + mysql_free_result(result); + } while (!(err= mysql_next_result(&mysql))); + if (err >= 1) error= put_error(&mysql); - else if (unbuffered) - fflush(stdout); - mysql_free_result(result); + return error; /* New command follows */ } @@ -2416,6 +2425,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) } strmake(delimiter, tmp, sizeof(delimiter) - 1); delimiter_length= strlen(delimiter); + delimiter_str= delimiter; return 0; } @@ -2546,6 +2556,8 @@ sql_real_connect(char *host,char *database,char *user,char *password, } if (opt_compress) mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); + if (opt_secure_auth) + mysql_options(&mysql, MYSQL_SECURE_AUTH, (char *) &opt_secure_auth); if (using_opt_local_infile) mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile); #ifdef HAVE_OPENSSL diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f870c92cb6d..35f0db76ad6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -34,6 +34,7 @@ ulong server_id = 0; ulong bytes_sent = 0L, bytes_received = 0L; ulong mysqld_net_retry_count = 10L; uint test_flags = 0; +static uint opt_protocol= 0; static FILE *result_file; @@ -233,6 +234,10 @@ static struct my_option my_long_options[] = {"position", 'j', "Start reading the binlog at position N.", (gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"protocol", OPT_MYSQL_PROTOCOL, + "The protocol of connection (tcp,socket,pipe,memory).", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"read-from-remote-server", 'R', "Read binary logs from a MySQL server", @@ -285,7 +290,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -369,6 +374,17 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'R': remote_opt= 1; break; + case OPT_MYSQL_PROTOCOL: + { + if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) == + ~(ulong) 0) + { + fprintf(stderr, "Unknown option to protocol: %s\n", argument); + exit(1); + } + break; + } + break; case 'V': print_version(); exit(0); @@ -398,9 +414,11 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { MYSQL *local_mysql = mysql_init(NULL); - if(!local_mysql) + if (!local_mysql) die("Failed on mysql_init"); + if (opt_protocol) + mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) die("failed on connect: %s", mysql_error(local_mysql)); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 00767ae98a7..1768d948373 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -309,6 +309,8 @@ static int get_options(int *argc, char ***argv) else what_to_do = DO_CHECK; } + + /* TODO: This variable is not yet used */ if (!(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) exit(1); diff --git a/client/mysqltest.c b/client/mysqltest.c index 11ffbb95a3a..9c70e61f85a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -119,7 +119,6 @@ static FILE** cur_file; static FILE** file_stack_end; static uint lineno_stack[MAX_INCLUDE_DEPTH]; static char TMPDIR[FN_REFLEN]; -static int *block_ok_stack_end; static int *cur_block, *block_stack_end; static int block_stack[BLOCK_STACK_DEPTH]; @@ -1500,7 +1499,6 @@ int do_connect(struct st_query* q) char* p=q->first_argument; char buff[FN_REFLEN]; int con_port; - int con_error; int free_con_sock = 0; DBUG_ENTER("do_connect"); @@ -1565,9 +1563,9 @@ int do_connect(struct st_query* q) /* Special database to allow one to connect without a database name */ if (con_db && !strcmp(con_db,"*NO-ONE*")) con_db=0; - if ((con_error = safe_connect(&next_con->mysql, con_host, - con_user, con_pass, - con_db, con_port, con_sock ? con_sock: 0))) + if ((safe_connect(&next_con->mysql, con_host, + con_user, con_pass, + con_db, con_port, con_sock ? con_sock: 0))) die("Could not open connection '%s': %s", con_name, mysql_error(&next_con->mysql)); @@ -2034,12 +2032,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), int parse_args(int argc, char **argv) { - int ho_error; - load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + if ((handle_options(&argc, &argv, my_long_options, get_one_option))) exit(1); if (argc > 1) @@ -2470,7 +2466,6 @@ int main(int argc, char **argv) memset(block_stack, 0, sizeof(block_stack)); block_stack_end = block_stack + BLOCK_STACK_DEPTH; memset(block_ok_stack, 0, sizeof(block_stack)); - block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH; cur_block = block_stack; block_ok = block_ok_stack; *block_ok = 1; diff --git a/configure.in b/configure.in index 4d1d44a931d..812261a7c95 100644 --- a/configure.in +++ b/configure.in @@ -2820,7 +2820,7 @@ AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile dnl libmysql_r/Makefile libmysqld/Makefile libmysqld/examples/Makefile dnl libmysql/Makefile client/Makefile dnl pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl - sql-common/Makefile dnl + sql-common/Makefile SSL/Makefile dnl merge/Makefile dbug/Makefile scripts/Makefile dnl include/Makefile sql-bench/Makefile tools/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl diff --git a/heap/hp_test1.c b/heap/hp_test1.c index 96399fe4f2e..dd696528eb8 100644 --- a/heap/hp_test1.c +++ b/heap/hp_test1.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { if (i == remove_ant) { VOID(heap_close(file)) ; return (0) ; } sprintf(key,"%6d",(j=(int) ((rand() & 32767)/32767.*25))); - if ((error = heap_rkey(file,record,0,key,0,6))) + if ((error = heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT))) { if (verbose || (flags[j] == 1 || (error && my_errno != HA_ERR_KEY_NOT_FOUND))) @@ -119,7 +119,7 @@ int main(int argc, char **argv) sprintf(key,"%6d",i); bmove(record+1,key,6); my_errno=0; - error=heap_rkey(file,record,0,key,0,6); + error=heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT); if (verbose || (error == 0 && flags[i] != 1) || (error && (flags[i] != 0 || my_errno != HA_ERR_KEY_NOT_FOUND))) diff --git a/heap/hp_test2.c b/heap/hp_test2.c index 97fe1471ca1..2de49bcb66b 100644 --- a/heap/hp_test2.c +++ b/heap/hp_test2.c @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) if (j != 0) { sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) if (!key1[j]) continue; sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) printf("- Read first key - next - delete - next -> last\n"); DBUG_PRINT("progpos",("first - next - delete - next -> last")); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) goto err; if (heap_rnext(file,record3)) goto err; if (heap_delete(file,record3)) goto err; @@ -513,7 +513,7 @@ int main(int argc, char *argv[]) } printf("- Read through all keys with first-next-last-prev\n"); ant=0; - for (error=heap_rkey(file,record,0,key,6,0); + for (error=heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT); ! error ; error=heap_rnext(file,record)) ant++; @@ -550,7 +550,8 @@ int main(int argc, char *argv[]) { if (error == 0) { - if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,0)) + if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8, + HA_READ_KEY_EXACT)) { printf("can't find key3: \"%.8s\"\n", record+keyinfo[2].seg[0].start); diff --git a/include/Makefile.am b/include/Makefile.am index 2ec06d71fbe..3adbb31f235 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -21,7 +21,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ errmsg.h my_global.h my_net.h my_alloc.h \ my_getopt.h sslopt-longopts.h my_dir.h typelib.h \ - sslopt-vars.h sslopt-case.h sql_common.h \ + sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ sql_state.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-os2.h config-netware.h \ nisam.h heap.h merge.h my_bitmap.h\ diff --git a/include/errmsg.h b/include/errmsg.h index a354c125e36..24326b1efef 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -87,3 +87,4 @@ extern const char *client_errors[]; /* Error messages */ #define CR_CONN_UNKNOW_PROTOCOL 2046 #define CR_INVALID_CONN_HANDLE 2047 #define CR_MYSQL_SERVER_INIT_MISSED 2048 +#define CR_SECURE_AUTH 2049 diff --git a/include/hash.h b/include/hash.h index 3c2ae32c70e..c7cc118b7bd 100644 --- a/include/hash.h +++ b/include/hash.h @@ -22,14 +22,15 @@ extern "C" { #endif +/* + Overhead to store an element in hash + Can be used to approximate memory consumption for a hash + */ +#define HASH_OVERHEAD (sizeof(char*)*2) + typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); typedef void (*hash_free_key)(void *); -typedef struct st_hash_info { - uint next; /* index to next key */ - byte *data; /* data for current entry */ -} HASH_LINK; - typedef struct st_hash { uint key_offset,key_length; /* Length of key if const length */ uint records,blength,current_record; diff --git a/include/keycache.h b/include/keycache.h new file mode 100644 index 00000000000..b882f3127f5 --- /dev/null +++ b/include/keycache.h @@ -0,0 +1,135 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* Key cache variable structures */ + +#ifndef _keycache_h +#define _keycache_h +C_MODE_START + +/* declare structures that is used by st_key_cache */ + +struct st_block_link; +typedef struct st_block_link BLOCK_LINK; +struct st_keycache_page; +typedef struct st_keycache_page KEYCACHE_PAGE; +struct st_hash_link; +typedef struct st_hash_link HASH_LINK; + +/* info about requests in a waiting queue */ +typedef struct st_keycache_wqueue +{ + struct st_my_thread_var *last_thread; /* circular list of waiting threads */ +} KEYCACHE_WQUEUE; + +#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ + +/* + The key cache structure + It also contains read-only statistics parameters. +*/ + +typedef struct st_key_cache +{ + my_bool key_cache_inited; + my_bool resize_in_flush; /* true during flush of resize operation */ + my_bool can_be_used; /* usage of cache for read/write is allowed */ + uint key_cache_shift; + ulong key_cache_mem_size; /* specified size of the cache memory */ + uint key_cache_block_size; /* size of the page buffer of a cache block */ + ulong min_warm_blocks; /* min number of warm blocks; */ + ulong age_threshold; /* age threshold for hot blocks */ + ulonglong keycache_time; /* total number of block link operations */ + uint hash_entries; /* max number of entries in the hash table */ + int hash_links; /* max number of hash links */ + int hash_links_used; /* number of hash links currently used */ + int disk_blocks; /* max number of blocks in the cache */ + ulong blocks_used; /* number of currently used blocks */ + ulong blocks_changed; /* number of currently dirty blocks */ + ulong warm_blocks; /* number of blocks in warm sub-chain */ + ulong cnt_for_resize_op; /* counter to block resize operation */ + long blocks_available; /* number of blocks available in the LRU chain */ + HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ + HASH_LINK *hash_link_root; /* memory for hash table links */ + HASH_LINK *free_hash_list; /* list of free hash links */ + BLOCK_LINK *block_root; /* memory for block links */ + byte HUGE_PTR *block_mem; /* memory for block buffers */ + BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ + BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ + pthread_mutex_t cache_lock; /* to lock access to the cache structure */ + KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */ + KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ + KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ + BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ + BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ + + /* + The following variables are and variables used to hold parameters for + initializing the key cache. + */ + + ulonglong param_buff_size; /* size the memory allocated for the cache */ + ulong param_block_size; /* size of the blocks in the key cache */ + ulong param_division_limit; /* min. percentage of warm blocks */ + ulong param_age_threshold; /* determines when hot block is downgraded */ + + /* Statistics variables */ + ulong global_blocks_used; /* number of currently used blocks */ + ulong global_blocks_changed; /* number of currently dirty blocks */ + ulong global_cache_w_requests;/* number of write requests (write hits) */ + ulong global_cache_write; /* number of writes from the cache to files */ + ulong global_cache_r_requests;/* number of read requests (read hits) */ + ulong global_cache_read; /* number of reads from files to the cache */ + int blocks; /* max number of blocks in the cache */ + my_bool in_init; /* Set to 1 in MySQL during init/resize */ +} KEY_CACHE; + +/* The default key cache */ +extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; + +extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold); +extern byte *key_cache_read(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int return_buffer); +extern int key_cache_insert(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length); +extern int key_cache_write(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int force_write); +extern int flush_key_blocks(KEY_CACHE *keycache, + int file, enum flush_type type); +extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup); + +/* Functions to handle multiple key caches */ +extern my_bool multi_keycache_init(void); +extern void multi_keycache_free(void); +extern KEY_CACHE *multi_key_cache_search(byte *key, uint length); +extern my_bool multi_key_cache_set(const byte *key, uint length, + KEY_CACHE *key_cache); +extern void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data); +C_MODE_END +#endif /* _keycache_h */ diff --git a/include/m_ctype.h b/include/m_ctype.h index e2b2f7f1668..0228b359111 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -335,6 +335,14 @@ uint my_instr_mb(struct charset_info_st *, extern my_bool my_parse_charset_xml(const char *bug, uint len, int (*add)(CHARSET_INFO *cs)); +#undef _U +#undef _L +#undef _NMR +#undef _SPC +#undef _PNT +#undef _CTR +#undef _B +#undef _X #define _U 01 /* Upper case */ #define _L 02 /* Lower case */ diff --git a/include/my_base.h b/include/my_base.h index a1744f37bc6..25521d7b13d 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -46,7 +46,6 @@ #define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */ #define HA_OPEN_ABORT_IF_CRASHED 16 #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ -#define HA_OPEN_TO_ASSIGN 64 /* Open for key cache assignment */ /* The following is parameter to ha_rkey() how to use key */ @@ -133,7 +132,7 @@ enum ha_extra_function { HA_EXTRA_RETRIEVE_ALL_COLS, HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ - HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ + HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */ }; /* The following is parameter to ha_panic() */ diff --git a/include/my_global.h b/include/my_global.h index 94263892ebd..af9065edcd8 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -695,7 +695,8 @@ typedef long long my_ptrdiff_t; #endif #endif #if defined(__IBMC__) || defined(__IBMCPP__) -#define STDCALL _System _Export +/* This was _System _Export but caused a lot of warnings on _AIX43 */ +#define STDCALL #elif !defined( STDCALL) #define STDCALL #endif diff --git a/include/my_pthread.h b/include/my_pthread.h index a4ea88b20f0..44e6edcddec 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -468,7 +468,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); typedef struct st_safe_mutex_t { pthread_mutex_t global,mutex; - char *file; + const char *file; uint line,count; pthread_t thread; #ifdef SAFE_MUTEX_DETECT_DESTROY @@ -487,7 +487,7 @@ typedef struct st_safe_mutex_info_t { struct st_safe_mutex_info_t *next; struct st_safe_mutex_info_t *prev; - char *init_file; + const char *init_file; uint32 init_line; } safe_mutex_info_t; #endif /* SAFE_MUTEX_DETECT_DESTROY */ diff --git a/include/my_sys.h b/include/my_sys.h index 25c450e5d2b..59d5767d204 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -160,7 +160,7 @@ extern char *my_strdup_with_length(const byte *from, uint length, #endif #ifdef HAVE_ALLOCA -#if defined(_AIX) && !defined(__GNUC__) +#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) @@ -226,9 +226,8 @@ extern void add_compiled_collation(CHARSET_INFO *cs); extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests, my_cache_read; extern ulong my_blocks_used, my_blocks_changed; -extern uint key_cache_block_size; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern my_bool key_cache_inited, my_init_done; +extern my_bool my_init_done; /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), @@ -266,8 +265,7 @@ enum cache_type enum flush_type { - FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE, - FLUSH_REMOVE + FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE }; typedef struct st_record_cache /* Used when cacheing records */ @@ -506,44 +504,6 @@ my_off_t my_b_append_tell(IO_CACHE* info); typedef uint32 ha_checksum; -/* Pointer to a key cache data structure (see the key cache module) */ -typedef struct st_key_cache* KEY_CACHE_HANDLE; - -/* Key cache variable structure */ -/* - The structure contains the parameters of a key cache that can - be set and undated by regular set global statements. - It also contains read-only statistics parameters. - If the corresponding key cache data structure has been already - created the variable contains the key cache handle. - The variables are put into a named list called key_caches. - At present the variables are only added to this list. -*/ -typedef struct st_key_cache_var -{ - ulonglong buff_size; /* size the memory allocated for the cache */ - ulong block_size; /* size of the blocks in the key cache */ - ulong division_limit; /* min. percentage of warm blocks */ - ulong age_threshold; /* determines when hot block is downgraded */ - KEY_CACHE_HANDLE cache; /* handles for the current and registered */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong cache_w_requests; /* number of write requests (write hits) */ - ulong cache_write; /* number of writes from the cache to files */ - ulong cache_r_requests; /* number of read requests (read hits) */ - ulong cache_read; /* number of reads from files to the cache */ - int blocks; /* max number of blocks in the cache */ - my_bool in_init; /* Set to 1 in MySQL during init/resize */ - struct st_key_cache_asmt *assign_list; /* list of assignments to the cache */ - int assignments; /* number of not completed assignments */ - void (*action)(void *); /* optional call back function */ - void *extra_info; /* ptr to extra info */ -} KEY_CACHE_VAR; - - -extern KEY_CACHE_HANDLE *dflt_keycache; -extern KEY_CACHE_VAR dflt_key_cache_var; - #include <my_alloc.h> /* Prototypes for mysys and my_func functions */ @@ -683,33 +643,6 @@ extern int flush_write_cache(RECORD_CACHE *info); extern long my_clock(void); extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); -extern int init_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR* env); -extern int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, ulong use_mem); -extern void change_key_cache_param(KEY_CACHE_HANDLE keycache); -extern byte *key_cache_read(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int return_buffer); -extern int key_cache_insert(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte *buff, uint length); -extern int key_cache_write(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int force_write); -extern int flush_key_blocks(KEY_CACHE_HANDLE keycache, - int file, enum flush_type type); -extern void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup); -extern my_bool multi_keycache_init(void); -extern void multi_keycache_free(void); -extern KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length); -extern my_bool multi_key_cache_set(const byte *key, uint length, - KEY_CACHE_HANDLE *key_cache); -extern void multi_key_cache_change(KEY_CACHE_HANDLE *old_data, - KEY_CACHE_HANDLE *new_data); extern sig_handler my_set_alarm_variable(int signo); extern void my_string_ptr_sort(void *base,uint items,size_s size); diff --git a/include/myisam.h b/include/myisam.h index 52f2948aaef..2285f996464 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -28,6 +28,9 @@ extern "C" { #ifndef _m_ctype_h #include <m_ctype.h> #endif +#ifndef _keycache_h +#include "keycache.h" +#endif #include "my_handler.h" /* defines used by myisam-funktions */ @@ -315,6 +318,7 @@ typedef struct st_mi_check_param ulonglong auto_increment_value; ulonglong max_data_file_length; ulonglong keys_in_use; + ulonglong max_record_length; my_off_t search_after_block; my_off_t new_file_pos,key_file_blocks; my_off_t keydata,totaldata,key_blocks,start_check_pos; @@ -408,9 +412,9 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows); void mi_flush_bulk_insert(MI_INFO *info, uint inx); void mi_end_bulk_insert(MI_INFO *info); int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map, - KEY_CACHE_VAR *key_cache); -void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache); + KEY_CACHE *key_cache); +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves); #ifdef __cplusplus diff --git a/include/mysql.h b/include/mysql.h index 2098ed0516a..fd0330b35da 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -145,7 +145,7 @@ enum mysql_option MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, - MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP + MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH }; struct st_mysql_options { @@ -184,6 +184,8 @@ struct st_mysql_options { #endif enum mysql_option methods_to_use; char *client_ip; + /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */ + my_bool secure_auth; }; enum mysql_status @@ -535,10 +537,10 @@ typedef struct st_mysql_stmt char *query; /* query buffer */ MEM_ROOT mem_root; /* root allocations */ my_ulonglong last_fetched_column; /* last fetched column */ - unsigned long param_count; /* parameters count */ - unsigned long field_count; /* fields count */ unsigned long stmt_id; /* Id for prepared statement */ unsigned int last_errno; /* error code */ + unsigned int param_count; /* parameters count */ + unsigned int field_count; /* fields count */ enum PREP_STMT_STATE state; /* statement state */ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ char sqlstate[SQLSTATE_LENGTH+1]; @@ -552,27 +554,27 @@ typedef struct st_mysql_stmt typedef struct st_mysql_methods { - my_bool (STDCALL *read_query_result)(MYSQL *mysql); - my_bool (STDCALL *advanced_command)(MYSQL *mysql, - enum enum_server_command command, - const char *header, - unsigned long header_length, - const char *arg, - unsigned long arg_length, - my_bool skip_check); - MYSQL_DATA *(STDCALL *read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields); - MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql); - void (STDCALL *fetch_lengths)(unsigned long *to, - MYSQL_ROW column, unsigned int field_count); + my_bool (*read_query_result)(MYSQL *mysql); + my_bool (*advanced_command)(MYSQL *mysql, + enum enum_server_command command, + const char *header, + unsigned long header_length, + const char *arg, + unsigned long arg_length, + my_bool skip_check); + MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields); + MYSQL_RES * (*use_result)(MYSQL *mysql); + void (*fetch_lengths)(unsigned long *to, + MYSQL_ROW column, unsigned int field_count); #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql); - my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (STDCALL *stmt_execute)(MYSQL_STMT *stmt); - MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt); - int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row); - void (STDCALL *free_embedded_thd)(MYSQL *mysql); - const char *(STDCALL *read_statistic)(MYSQL *mysql); + MYSQL_FIELD * (*list_fields)(MYSQL *mysql); + my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (*stmt_execute)(MYSQL_STMT *stmt); + MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt); + int (*unbuffered_fetch)(MYSQL *mysql, char **row); + void (*free_embedded_thd)(MYSQL *mysql); + const char *(*read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; @@ -604,7 +606,7 @@ MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); my_bool STDCALL mysql_more_results(MYSQL *mysql); -my_bool STDCALL mysql_next_result(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); diff --git a/include/mysql_com.h b/include/mysql_com.h index 28a649876da..0c4a3e5fca9 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -118,7 +118,7 @@ enum enum_server_command #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ #define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ #define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ -#define CLIENT_REMEMBER_OPTIONS (1L << 31) +#define CLIENT_REMEMBER_OPTIONS ((ulong) (1L << 31)) #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index 31bf2bdd00d..095531d527d 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -19,6 +19,7 @@ #define MYSQL_PORT @MYSQL_TCP_PORT@ #define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@" #define MYSQL_CONFIG_NAME "my" +#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@" /* mysqld compile time options */ #endif /* _CUSTOMCONFIG_ */ diff --git a/include/mysqld_error.h b/include/mysqld_error.h index e25424a8bb1..6b2e5115a4e 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -300,37 +300,37 @@ #define ER_WARN_QC_RESIZE 1281 #define ER_BAD_FT_COLUMN 1282 #define ER_UNKNOWN_KEY_CACHE 1283 -/* 5.0 */ -#define ER_SP_NO_RECURSIVE_CREATE 1284 -#define ER_SP_ALREADY_EXISTS 1285 -#define ER_SP_DOES_NOT_EXIST 1286 -#define ER_SP_DROP_FAILED 1287 -#define ER_SP_STORE_FAILED 1288 -#define ER_SP_LILABEL_MISMATCH 1289 -#define ER_SP_LABEL_REDEFINE 1290 -#define ER_SP_LABEL_MISMATCH 1291 -#define ER_SP_UNINIT_VAR 1292 -#define ER_SP_BADSELECT 1293 -#define ER_SP_BADRETURN 1294 -#define ER_SP_BADSTATEMENT 1295 -#define ER_UPDATE_LOG_DEPRECATED_IGNORED 1296 -#define ER_UPDATE_LOG_DEPRECATED_TRANSLATED 1297 -#define ER_QUERY_INTERRUPTED 1298 -#define ER_SP_WRONG_NO_OF_ARGS 1299 -#define ER_SP_COND_MISMATCH 1300 -#define ER_SP_NORETURN 1301 -#define ER_SP_NORETURNEND 1302 -#define ER_SP_BAD_CURSOR_QUERY 1303 -#define ER_SP_BAD_CURSOR_SELECT 1304 -#define ER_SP_CURSOR_MISMATCH 1305 -#define ER_SP_CURSOR_ALREADY_OPEN 1306 -#define ER_SP_CURSOR_NOT_OPEN 1307 -#define ER_SP_UNDECLARED_VAR 1308 -#define ER_SP_WRONG_NO_OF_FETCH_ARGS 1309 -#define ER_SP_FETCH_NO_DATA 1310 -#define ER_SP_DUP_PARAM 1311 -#define ER_SP_DUP_VAR 1312 -#define ER_SP_DUP_COND 1313 -#define ER_SP_DUP_CURS 1314 -#define ER_SP_CANT_ALTER 1315 -#define ER_ERROR_MESSAGES 316 +#define ER_WARN_HOSTNAME_WONT_WORK 1284 +#define ER_SP_NO_RECURSIVE_CREATE 1285 +#define ER_SP_ALREADY_EXISTS 1286 +#define ER_SP_DOES_NOT_EXIST 1287 +#define ER_SP_DROP_FAILED 1288 +#define ER_SP_STORE_FAILED 1289 +#define ER_SP_LILABEL_MISMATCH 1290 +#define ER_SP_LABEL_REDEFINE 1291 +#define ER_SP_LABEL_MISMATCH 1292 +#define ER_SP_UNINIT_VAR 1293 +#define ER_SP_BADSELECT 1294 +#define ER_SP_BADRETURN 1295 +#define ER_SP_BADSTATEMENT 1296 +#define ER_UPDATE_LOG_DEPRECATED_IGNORED 1297 +#define ER_UPDATE_LOG_DEPRECATED_TRANSLATED 1298 +#define ER_QUERY_INTERRUPTED 1299 +#define ER_SP_WRONG_NO_OF_ARGS 1300 +#define ER_SP_COND_MISMATCH 1301 +#define ER_SP_NORETURN 1302 +#define ER_SP_NORETURNEND 1303 +#define ER_SP_BAD_CURSOR_QUERY 1304 +#define ER_SP_BAD_CURSOR_SELECT 1305 +#define ER_SP_CURSOR_MISMATCH 1306 +#define ER_SP_CURSOR_ALREADY_OPEN 1307 +#define ER_SP_CURSOR_NOT_OPEN 1308 +#define ER_SP_UNDECLARED_VAR 1309 +#define ER_SP_WRONG_NO_OF_FETCH_ARGS 1310 +#define ER_SP_FETCH_NO_DATA 1311 +#define ER_SP_DUP_PARAM 1312 +#define ER_SP_DUP_VAR 1313 +#define ER_SP_DUP_COND 1314 +#define ER_SP_DUP_CURS 1315 +#define ER_SP_CANT_ALTER 1316 +#define ER_ERROR_MESSAGES 317 diff --git a/include/sql_common.h b/include/sql_common.h index 1f442339c4f..fef573f7450 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -22,9 +22,6 @@ extern const char *not_error_sqlstate; extern "C" { #endif -ulong STDCALL net_field_length(uchar **packet); -my_ulonglong net_field_length_ll(uchar **packet); - MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, my_bool default_value, uint server_capabilities); void free_rows(MYSQL_DATA *cur); @@ -34,7 +31,7 @@ void end_server(MYSQL *mysql); my_bool mysql_reconnect(MYSQL *mysql); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check); diff --git a/include/violite.h b/include/violite.h index 37c5abbbe67..e8f30288d34 100644 --- a/include/violite.h +++ b/include/violite.h @@ -177,7 +177,7 @@ struct st_vio void (*viodelete)(Vio*); int (*vioerrno)(Vio*); int (*read)(Vio*, gptr, int); - int (*write)(Vio*, gptr, int); + int (*write)(Vio*, const gptr, int); int (*vioblocking)(Vio*, my_bool, my_bool *); my_bool (*is_blocking)(Vio*); int (*viokeepalive)(Vio*, my_bool); diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 3d11cbe1748..686c35d1300 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -600,8 +600,8 @@ btr_page_get_father_for_rec( "InnoDB: father ptr page no %lu, child page no %lu\n", (UT_LIST_GET_FIRST(tree->tree_indexes))->table_name, (UT_LIST_GET_FIRST(tree->tree_indexes))->name, - btr_node_ptr_get_child_page_no(node_ptr), - buf_frame_get_page_no(page)); + (unsigned long) btr_node_ptr_get_child_page_no(node_ptr), + (unsigned long) buf_frame_get_page_no(page)); page_rec_print(page_rec_get_next(page_get_infimum_rec(page))); page_rec_print(node_ptr); @@ -877,7 +877,9 @@ btr_page_reorganize_low( "InnoDB: Error: page old data size %lu new data size %lu\n" "InnoDB: Error: page old max ins size %lu new max ins size %lu\n" "InnoDB: Make a detailed bug report and send it to mysql@lists.mysql.com\n", - data_size1, data_size2, max_ins_size1, max_ins_size2); + (unsigned long) data_size1, (unsigned long) data_size2, + (unsigned long) max_ins_size1, + (unsigned long) max_ins_size2); } buf_frame_free(new_page); @@ -2356,8 +2358,10 @@ btr_index_rec_validate( "InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n" "InnoDB: has %lu fields, should have %lu\n", index->name, index->table_name, - buf_frame_get_page_no(page), (ulint)(rec - page), - rec_get_n_fields(rec), n); + (unsigned long) buf_frame_get_page_no(page), + (unsigned long) (rec - page), + (unsigned long) rec_get_n_fields(rec), + (unsigned long) n); if (!dump_on_error) { @@ -2390,9 +2394,11 @@ btr_index_rec_validate( "InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n" "InnoDB: field %lu len is %lu, should be %lu\n", index->name, index->table_name, - buf_frame_get_page_no(page), - (ulint)(rec - page), - i, len, dtype_get_fixed_size(type)); + (unsigned long) buf_frame_get_page_no(page), + (unsigned long) (rec - page), + (unsigned long) i, + (unsigned long) len, + (unsigned long) dtype_get_fixed_size(type)); if (!dump_on_error) { @@ -2541,7 +2547,7 @@ loop: fprintf(stderr, "InnoDB: Error on pages %lu and %lu in index %s table %s\n", buf_frame_get_page_no(page), - right_page_no, + (unsigned long) right_page_no, index->name, index->table_name); fprintf(stderr, @@ -2581,7 +2587,7 @@ loop: &mtr)) { fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); fprintf(stderr, @@ -2596,7 +2602,7 @@ loop: fprintf(stderr, "InnoDB: node ptr child page n:o %lu\n", - btr_node_ptr_get_child_page_no(node_ptr)); + (unsigned long) btr_node_ptr_get_child_page_no(node_ptr)); rec_sprintf(err_buf, 900, btr_page_get_father_for_rec(tree, page, @@ -2679,7 +2685,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); @@ -2699,7 +2705,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); @@ -2717,7 +2723,7 @@ loop: fprintf(stderr, "InnoDB: Error on page %lu in index %s table %s\n", - buf_frame_get_page_no(page), + (unsigned long) buf_frame_get_page_no(page), index->name, index->table_name); buf_page_print(father_page); diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index 5743ba54544..93e9e815c99 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -874,8 +874,8 @@ btr_cur_optimistic_insert( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to insert to table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); dtuple_print(entry); } @@ -978,7 +978,8 @@ calculate_sizes_again: fprintf(stderr, "InnoDB: Error: cannot insert tuple %s to index %s of table %s\n" "InnoDB: max insert size %lu\n", - err_buf, index->name, index->table->name, max_size); + err_buf, index->name, index->table->name, + (unsigned long) max_size); mem_free(err_buf); } @@ -1343,8 +1344,8 @@ btr_cur_update_sec_rec_in_place( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -1407,8 +1408,8 @@ btr_cur_update_in_place( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -1509,8 +1510,8 @@ btr_cur_optimistic_update( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to update table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -2059,8 +2060,8 @@ btr_cur_del_mark_set_clust_rec( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to del mark table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), index->table_name, index->name); rec_print(rec); } @@ -2199,8 +2200,8 @@ btr_cur_del_mark_set_sec_rec( if (btr_cur_print_record_ops && thr) { printf( "Trx with id %lu %lu going to del mark table %s index %s\n", - ut_dulint_get_high(thr_get_trx(thr)->id), - ut_dulint_get_low(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_high(thr_get_trx(thr)->id), + (unsigned long) ut_dulint_get_low(thr_get_trx(thr)->id), cursor->index->table_name, cursor->index->name); rec_print(rec); } diff --git a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c index f0d41018948..76c94d1a918 100644 --- a/innobase/dict/dict0boot.c +++ b/innobase/dict/dict0boot.c @@ -332,8 +332,12 @@ dict_boot(void) dict_mem_table_add_col(table, (char *) "PAGE_NO", DATA_INT, 0, 4, 0); /* The '+ 2' below comes from the 2 system fields */ - ut_ad(DICT_SYS_INDEXES_PAGE_NO_FIELD == 6 + 2); - ut_ad(DICT_SYS_INDEXES_SPACE_NO_FIELD == 5 + 2); +#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2 +#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2" +#endif +#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2 +#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2" +#endif table->id = DICT_INDEXES_ID; dict_table_add_to_cache(table); diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index a9ae59fbd50..b45eec8e4cf 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -84,7 +84,8 @@ completes, we decrement the count and return the file node to the LRU-list if the count drops to zero. */ /* When mysqld is run, the default directory "." is the mysqld datadir, -but in ibbackup we must set it explicitly */ +but in the MySQL Embedded Server Library and ibbackup it is not the default +directory, and we must set the base file path explicitly */ char* fil_path_to_mysql_datadir = (char*)"."; ulint fil_n_pending_log_flushes = 0; @@ -1567,7 +1568,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, name, ut_strlen(name) + 1); + mlog_catenate_string(mtr, (byte*) name, ut_strlen(name) + 1); if (type == MLOG_FILE_RENAME) { log_ptr = mlog_open(mtr, 30); @@ -1576,7 +1577,8 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, new_name, ut_strlen(new_name) + 1); + mlog_catenate_string(mtr, (byte*) new_name, + ut_strlen(new_name) + 1); } } #endif @@ -1630,7 +1632,7 @@ fil_op_log_parse_or_replay( return(NULL); } - name = ptr; + name = (char*) ptr; ptr += name_len; @@ -1649,7 +1651,7 @@ fil_op_log_parse_or_replay( return(NULL); } - new_name = ptr; + new_name = (char*) ptr; ptr += new_name_len; } @@ -1696,7 +1698,9 @@ fil_op_log_parse_or_replay( if (fil_get_space_id_for_table(new_name) == ULINT_UNDEFINED) { - ut_a(fil_rename_tablespace(name, space_id, + /* We do not care of the old name, that is + why we pass NULL as the first argument */ + ut_a(fil_rename_tablespace(NULL, space_id, new_name)); } } @@ -1956,7 +1960,9 @@ fil_rename_tablespace( /*==================*/ /* out: TRUE if success */ char* old_name, /* in: old table name in the standard - databasename/tablename format of InnoDB */ + databasename/tablename format of InnoDB, or + NULL if we do the rename based on the space + id only */ ulint id, /* in: space id */ char* new_name) /* in: new table name in the standard databasename/tablename format of InnoDB */ @@ -1967,9 +1973,15 @@ fil_rename_tablespace( fil_node_t* node; ulint count = 0; char* path = NULL; + ibool old_name_was_specified = TRUE; char old_path[OS_FILE_MAX_PATH]; ut_a(id != 0); + + if (old_name == NULL) { + old_name = (char*)"(name not specified)"; + old_name_was_specified = FALSE; + } retry: count++; @@ -2038,16 +2050,19 @@ retry: } /* Check that the old name in the space is right */ - - ut_a(strlen(old_name) + strlen(fil_path_to_mysql_datadir) - < OS_FILE_MAX_PATH - 10); - sprintf(old_path, "%s/%s.ibd", fil_path_to_mysql_datadir, old_name); - - srv_normalize_path_for_win(old_path); + if (old_name_was_specified) { + ut_a(strlen(old_name) + strlen(fil_path_to_mysql_datadir) + < OS_FILE_MAX_PATH - 10); + sprintf(old_path, "%s/%s.ibd", fil_path_to_mysql_datadir, + old_name); + srv_normalize_path_for_win(old_path); - ut_a(strcmp(space->name, old_path) == 0); - ut_a(strcmp(node->name, old_path) == 0); + ut_a(strcmp(space->name, old_path) == 0); + ut_a(strcmp(node->name, old_path) == 0); + } else { + sprintf(old_path, "%s", space->name); + } /* Rename the tablespace and the node in the memory cache */ @@ -2066,8 +2081,6 @@ retry: goto func_exit; } - /* printf("Renaming tablespace %s to %s id %lu\n", path, old_path, id); - */ success = os_file_rename(old_path, path); if (!success) { diff --git a/innobase/include/btr0btr.ic b/innobase/include/btr0btr.ic index 16057d2c8a6..301a73b3444 100644 --- a/innobase/include/btr0btr.ic +++ b/innobase/include/btr0btr.ic @@ -203,7 +203,7 @@ btr_node_ptr_get_child_page_no( if (page_no == 0) { fprintf(stderr, "InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n", - (ulint)(rec - buf_frame_align(rec))); + (unsigned long)(rec - buf_frame_align(rec))); buf_page_print(buf_frame_align(rec)); } diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic index 281bb1ea527..eb22bae7ff0 100644 --- a/innobase/include/buf0buf.ic +++ b/innobase/include/buf0buf.ic @@ -219,8 +219,8 @@ buf_block_align( "InnoDB: corruption. If this happens in an InnoDB database recovery,\n" "InnoDB: you can look from section 6.1 at http://www.innodb.com/ibman.html\n" "InnoDB: how to force recovery.\n", - (ulint)ptr, (ulint)frame_zero, - (ulint)(buf_pool->high_end)); + (long)ptr, (long)frame_zero, + (long)(buf_pool->high_end)); ut_a(0); } @@ -255,8 +255,8 @@ buf_frame_align( "InnoDB: corruption. If this happens in an InnoDB database recovery,\n" "InnoDB: you can look from section 6.1 at http://www.innodb.com/ibman.html\n" "InnoDB: how to force recovery.\n", - (ulint)ptr, (ulint)(buf_pool->frame_zero), - (ulint)(buf_pool->high_end)); + (long)ptr, (long)(buf_pool->frame_zero), + (long)(buf_pool->high_end)); ut_a(0); } diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h index 0ed012c489a..310336af38e 100644 --- a/innobase/include/fil0fil.h +++ b/innobase/include/fil0fil.h @@ -329,7 +329,9 @@ fil_rename_tablespace( /*==================*/ /* out: TRUE if success */ char* old_name, /* in: old table name in the standard - databasename/tablename format of InnoDB */ + databasename/tablename format of InnoDB, or + NULL if we do the rename based on the space + id only */ ulint id, /* in: space id */ char* new_name); /* in: new table name in the standard databasename/tablename format of InnoDB */ diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 4a9fae90f07..5f2d6e3ed21 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -282,6 +282,15 @@ os_file_delete( /*===========*/ /* out: TRUE if success */ char* name); /* in: file path as a null-terminated string */ + +/*************************************************************************** +Deletes a file if it exists. The file has to be closed before calling this. */ + +ibool +os_file_delete_if_exists( +/*=====================*/ + /* out: TRUE if success */ + char* name); /* in: file path as a null-terminated string */ /*************************************************************************** Renames a file (can also move it to another directory). It is safest that the file is closed before calling this function. */ @@ -379,6 +388,23 @@ os_file_read( offset */ ulint n); /* in: number of bytes to read */ /*********************************************************************** +Requests a synchronous positioned read operation. This function does not do +any error handling. In case of error it returns FALSE. */ + +ibool +os_file_read_no_error_handling( +/*===========================*/ + /* out: TRUE if request was + successful, FALSE if fail */ + os_file_t file, /* in: handle to a file */ + void* buf, /* in: buffer where to read */ + ulint offset, /* in: least significant 32 bits of file + offset where to read */ + ulint offset_high,/* in: most significant 32 bits of + offset */ + ulint n); /* in: number of bytes to read */ + +/*********************************************************************** Requests a synchronous write operation. */ ibool diff --git a/innobase/include/row0sel.ic b/innobase/include/row0sel.ic index 9005624b6ca..994638790c0 100644 --- a/innobase/include/row0sel.ic +++ b/innobase/include/row0sel.ic @@ -77,7 +77,7 @@ open_step( if (err != DB_SUCCESS) { /* SQL error detected */ - printf("SQL error %lu\n", err); + printf("SQL error %lu\n", (unsigned long) err); ut_error; que_thr_handle_error(thr, err, NULL, 0); diff --git a/innobase/include/row0upd.ic b/innobase/include/row0upd.ic index 7015b2eda13..1878431d1a4 100644 --- a/innobase/include/row0upd.ic +++ b/innobase/include/row0upd.ic @@ -86,8 +86,8 @@ upd_field_set_field_no( fprintf(stderr, "InnoDB: Error: trying to access field %lu in table %s\n" "InnoDB: index %s, but index has only %lu fields\n", - field_no, index->table_name, index->name, - dict_index_get_n_fields(index)); + (unsigned long) field_no, index->table_name, index->name, + (unsigned long) dict_index_get_n_fields(index)); } dtype_copy(dfield_get_type(&(upd_field->new_val)), diff --git a/innobase/include/trx0rseg.ic b/innobase/include/trx0rseg.ic index 423447d5566..6b242b66c09 100644 --- a/innobase/include/trx0rseg.ic +++ b/innobase/include/trx0rseg.ic @@ -63,7 +63,7 @@ trx_rsegf_get_nth_undo( { if (n >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: trying to get slot %lu of rseg\n", n); + "InnoDB: Error: trying to get slot %lu of rseg\n", (unsigned long) n); ut_a(0); } @@ -84,7 +84,7 @@ trx_rsegf_set_nth_undo( { if (n >= TRX_RSEG_N_SLOTS) { fprintf(stderr, - "InnoDB: Error: trying to set slot %lu of rseg\n", n); + "InnoDB: Error: trying to set slot %lu of rseg\n", (unsigned long) n); ut_a(0); } diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index b6d4eba9f9b..fe5b4f9c096 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -346,6 +346,7 @@ os_file_handle_error( return(FALSE); } else if (err == OS_FILE_AIO_RESOURCES_RESERVED) { + return(TRUE); } else if (err == OS_FILE_ALREADY_EXISTS) { @@ -369,6 +370,68 @@ os_file_handle_error( } /******************************************************************** +Does error handling when a file operation fails. */ +static +ibool +os_file_handle_error_no_exit( +/*=========================*/ + /* out: TRUE if we should retry the + operation */ + os_file_t file, /* in: file pointer */ + char* name, /* in: name of a file or NULL */ + const char* operation)/* in: operation */ +{ + ulint err; + + UT_NOT_USED(file); + + err = os_file_get_last_error(FALSE); + + if (err == OS_FILE_DISK_FULL) { + /* We only print a warning about disk full once */ + + if (os_has_said_disk_full) { + + return(FALSE); + } + + if (name) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Encountered a problem with file %s\n", name); + } + + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Disk is full. Try to clean the disk to free space.\n"); + + os_has_said_disk_full = TRUE; + + fflush(stderr); + + return(FALSE); + + } else if (err == OS_FILE_AIO_RESOURCES_RESERVED) { + + return(TRUE); + + } else if (err == OS_FILE_ALREADY_EXISTS) { + + return(FALSE); + } else { + if (name) { + fprintf(stderr, "InnoDB: File name %s\n", name); + } + + fprintf(stderr, "InnoDB: File operation call: '%s'.\n", + operation); + return (FALSE); + } + + return(FALSE); /* not reached */ +} + +/******************************************************************** Creates the seek mutexes used in positioned reads and writes. */ void @@ -409,7 +472,7 @@ os_file_opendir( ut_a(strlen(dirname) < OS_FILE_MAX_PATH); strcpy(path, dirname); - strcpy(path + strlen(path), "\\"); + strcpy(path + strlen(path), "\\*"); /* Note that in Windows opening the 'directory stream' also retrieves the first entry in the directory. Since it is '.', that is no problem, @@ -457,7 +520,7 @@ os_file_closedir( ret = FindClose(dir); if (!ret) { - os_file_handle_error(NULL, NULL, "closedir"); + os_file_handle_error_no_exit(NULL, NULL, "closedir"); return(-1); } @@ -469,7 +532,7 @@ os_file_closedir( ret = closedir(dir); if (ret) { - os_file_handle_error(0, NULL, "closedir"); + os_file_handle_error_no_exit(0, NULL, "closedir"); } return(ret); @@ -538,8 +601,8 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */ return(1); } else { - os_file_handle_error(NULL, dirname, "readdir_next_file"); - + os_file_handle_error_no_exit(NULL, dirname, + "readdir_next_file"); return(-1); } #else @@ -570,7 +633,7 @@ next_file: ret = stat(full_path, &statinfo); if (ret) { - os_file_handle_error(0, full_path, "stat"); + os_file_handle_error_no_exit(0, full_path, "stat"); ut_free(full_path); @@ -1064,6 +1127,67 @@ try_again: } /*************************************************************************** +Deletes a file if it exists. The file has to be closed before calling this. */ + +ibool +os_file_delete_if_exists( +/*=====================*/ + /* out: TRUE if success */ + char* name) /* in: file path as a null-terminated string */ +{ +#ifdef __WIN__ + BOOL ret; + ulint count = 0; +loop: + /* In Windows, deleting an .ibd file may fail if ibbackup is copying + it */ + + ret = DeleteFile((LPCTSTR)name); + + if (ret) { + return(TRUE); + } + + if (GetLastError() == ERROR_PATH_NOT_FOUND) { + /* the file does not exist, this not an error */ + + return(TRUE); + } + + count++; + + if (count > 100 && 0 == (count % 10)) { + fprintf(stderr, +"InnoDB: Warning: cannot delete file %s\n" +"InnoDB: Are you running ibbackup to back up the file?\n", name); + + os_file_get_last_error(TRUE); /* print error information */ + } + + os_thread_sleep(1000000); /* sleep for a second */ + + if (count > 2000) { + + return(FALSE); + } + + goto loop; +#else + int ret; + + ret = unlink((const char*)name); + + if (ret != 0 && errno != ENOENT) { + os_file_handle_error(0, name, "delete"); + + return(FALSE); + } + + return(TRUE); +#endif +} + +/*************************************************************************** Deletes a file. The file has to be closed before calling this. */ ibool @@ -1747,6 +1871,92 @@ error_handling: } /*********************************************************************** +Requests a synchronous positioned read operation. This function does not do +any error handling. In case of error it returns FALSE. */ + +ibool +os_file_read_no_error_handling( +/*===========================*/ + /* out: TRUE if request was + successful, FALSE if fail */ + os_file_t file, /* in: handle to a file */ + void* buf, /* in: buffer where to read */ + ulint offset, /* in: least significant 32 bits of file + offset where to read */ + ulint offset_high, /* in: most significant 32 bits of + offset */ + ulint n) /* in: number of bytes to read */ +{ +#ifdef __WIN__ + BOOL ret; + DWORD len; + DWORD ret2; + DWORD low; + DWORD high; + ibool retry; + ulint i; + + ut_a((offset & 0xFFFFFFFFUL) == offset); + + os_n_file_reads++; + os_bytes_read_since_printout += n; + +try_again: + ut_ad(file); + ut_ad(buf); + ut_ad(n > 0); + + low = offset; + high = offset_high; + + /* Protect the seek / read operation with a mutex */ + i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; + + os_mutex_enter(os_file_seek_mutexes[i]); + + ret2 = SetFilePointer(file, low, &high, FILE_BEGIN); + + if (ret2 == 0xFFFFFFFF && GetLastError() != NO_ERROR) { + + os_mutex_exit(os_file_seek_mutexes[i]); + + goto error_handling; + } + + ret = ReadFile(file, buf, n, &len, NULL); + + os_mutex_exit(os_file_seek_mutexes[i]); + + if (ret && len == n) { + return(TRUE); + } +#else + ibool retry; + ssize_t ret; + + os_bytes_read_since_printout += n; + +try_again: + ret = os_file_pread(file, buf, n, offset, offset_high); + + if ((ulint)ret == n) { + + return(TRUE); + } +#endif +#ifdef __WIN__ +error_handling: +#endif + retry = os_file_handle_error_no_exit(file, NULL, "read"); + + if (retry) { + goto try_again; + } + + return(FALSE); +} + +/*********************************************************************** Requests a synchronous write operation. */ ibool diff --git a/innobase/pars/pars0opt.c b/innobase/pars/pars0opt.c index 4faf83b47a3..9b0495a01cd 100644 --- a/innobase/pars/pars0opt.c +++ b/innobase/pars/pars0opt.c @@ -1235,7 +1235,8 @@ opt_print_query_plan( printf( "Table %s index %s; exact m. %lu, match %lu, end conds %lu\n", plan->table->name, plan->index->name, - plan->n_exact_match, n_fields, - UT_LIST_GET_LEN(plan->end_conds)); + (unsigned long) plan->n_exact_match, + (unsigned long) n_fields, + (unsigned long) UT_LIST_GET_LEN(plan->end_conds)); } } diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c index 3f28a4b40a5..7e4babd43ef 100644 --- a/innobase/que/que0que.c +++ b/innobase/que/que0que.c @@ -513,7 +513,7 @@ que_graph_free_recursive( if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, "que_thr struct appears corrupt; magic n %lu\n", - thr->magic_n); + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); ut_a(0); } @@ -625,7 +625,7 @@ que_graph_free_recursive( default: fprintf(stderr, "que_node struct appears corrupt; type %lu\n", - que_node_get_type(node)); + (unsigned long) que_node_get_type(node)); mem_analyze_corruption((byte*)node); ut_a(0); } @@ -1105,7 +1105,8 @@ que_thr_move_to_run_state_for_mysql( { if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, - "que_thr struct appears corrupt; magic n %lu\n", thr->magic_n); + "que_thr struct appears corrupt; magic n %lu\n", + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); @@ -1141,7 +1142,8 @@ que_thr_stop_for_mysql_no_error( if (thr->magic_n != QUE_THR_MAGIC_N) { fprintf(stderr, - "que_thr struct appears corrupt; magic n %lu\n", thr->magic_n); + "que_thr struct appears corrupt; magic n %lu\n", + (unsigned long) thr->magic_n); mem_analyze_corruption((byte*)thr); @@ -1216,7 +1218,8 @@ que_node_print_info( str = (char *) "UNKNOWN NODE TYPE"; } - printf("Node type %lu: %s, address %lx\n", type, str, addr); + printf("Node type %lu: %s, address %lx\n", (unsigned long) type, str, + (unsigned long) addr); } /************************************************************************** diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 9987804f03e..1f709025759 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -995,7 +995,7 @@ srv_console( srv_dec_thread_count(SRV_CONSOLE); } - return(0); + return(0); /* Not reached */ } /************************************************************************* @@ -3286,7 +3286,7 @@ suspend_thread: os_thread_exit(NULL); #ifndef __WIN__ - return(NULL); + return(NULL); /* Not reached */ #else return(0); #endif diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 3f375b66c4f..69ddaec0619 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -441,7 +441,7 @@ io_handler_thread( os_thread_exit(NULL); #ifndef __WIN__ - return(NULL); + return(NULL); /* Not reached */ #else return(0); #endif diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index 89412003485..177c5db7413 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -589,7 +589,7 @@ trx_sys_update_mysql_binlog_offset( mlog_write_string(sys_header + field + TRX_SYS_MYSQL_LOG_NAME, - file_name, 1 + ut_strlen(file_name), mtr); + (byte*) file_name, 1 + ut_strlen(file_name), mtr); } if (mach_read_from_4(sys_header + field diff --git a/isam/_locking.c b/isam/_locking.c index 0ffb46a81f8..e19804549e5 100644 --- a/isam/_locking.c +++ b/isam/_locking.c @@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type) else count= --share->w_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_KEEP)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_KEEP)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) if (end_io_cache(&info->rec_cache)) @@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info) share->state.uniq != info->last_uniq) { /* Keyfile has changed */ if (share->state.process != share->this_process) - VOID(flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)); + VOID(flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)); share->last_process=share->state.process; info->last_loop= share->state.loop; info->last_uniq= share->state.uniq; diff --git a/isam/_page.c b/isam/_page.c index 60f1dfb0ce6..e31115e624f 100644 --- a/isam/_page.c +++ b/isam/_page.c @@ -27,7 +27,7 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t page, uchar *buff, int return_buffer) { uchar *tmp; - tmp=(uchar*) key_cache_read(*dflt_keycache, + tmp=(uchar*) key_cache_read(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS,(byte*) buff, (uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length, @@ -84,7 +84,7 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, length=keyinfo->base.block_length; } #endif - return (key_cache_write(*dflt_keycache, + return (key_cache_write(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS, (byte*) buff,length, (uint) keyinfo->base.block_length, @@ -102,7 +102,7 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos) old_link=info->s->state.key_del[keynr]; info->s->state.key_del[keynr]=(ulong) pos; - DBUG_RETURN(key_cache_write(*dflt_keycache, + DBUG_RETURN(key_cache_write(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &old_link, sizeof(long), @@ -131,7 +131,7 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo) } else { - if (!key_cache_read(*dflt_keycache, + if (!key_cache_read(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &info->s->state.key_del[keynr], (uint) sizeof(long), diff --git a/isam/close.c b/isam/close.c index 37b35e450ae..37425653a5d 100644 --- a/isam/close.c +++ b/isam/close.c @@ -57,7 +57,7 @@ int nisam_close(register N_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)) error=my_errno; if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) error = my_errno; diff --git a/isam/extra.c b/isam/extra.c index 3bf1dd012ed..421404311c8 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -215,7 +215,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) info->s->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ - if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) { diff --git a/isam/isamchk.c b/isam/isamchk.c index e59da07e85b..4e7ab7ec854 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -286,8 +286,8 @@ static struct my_option my_long_options[] = "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"block-search", 'b', "For debugging.", (gptr*) &search_after_block, - (gptr*) &search_after_block, 0, GET_ULONG, REQUIRED_ARG, NI_POS_ERROR, 0, - 0, 0, 0, 0}, + (gptr*) &search_after_block, 0, GET_ULONG, REQUIRED_ARG, + (longlong) NI_POS_ERROR, 0, 0, 0, 0, 0}, {"silent", 's', "Only print errors. One can use two -s to make isamchk very silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -516,8 +516,8 @@ static int nisamchk(my_string filename) if (!rep_quick) { if (testflag & T_EXTEND) - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE, - use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE, + use_buffers,0,0)); VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1, MYF(MY_WME))); @@ -1460,8 +1460,7 @@ my_string name; printf("Data records: %lu\n",(ulong) share->state.records); } - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers,0,0)); if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) goto err; @@ -1889,12 +1888,12 @@ static void lock_memory(void) static int flush_blocks(file) File file; { - if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,file,FLUSH_RELEASE)) { print_error("%d when trying to write bufferts",my_errno); return(1); } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); return 0; } /* flush_blocks */ @@ -1938,8 +1937,7 @@ int write_info; if (share->state.key_root[sort_key] == NI_POS_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/isam/isamdef.h b/isam/isamdef.h index 54656b6842e..7d89730fe32 100644 --- a/isam/isamdef.h +++ b/isam/isamdef.h @@ -24,6 +24,7 @@ #else #include <my_no_pthread.h> #endif +#include <keycache.h> #ifdef my_write #undef my_write /* We want test if disk full */ diff --git a/isam/isamlog.c b/isam/isamlog.c index d8ea9d4ed80..75a35ef9704 100644 --- a/isam/isamlog.c +++ b/isam/isamlog.c @@ -329,8 +329,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0,0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && !my_b_read(&cache,(byte*) head,9)) @@ -622,7 +622,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -642,7 +642,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/isam/panic.c b/isam/panic.c index de765f50e62..7af979a5104 100644 --- a/isam/panic.c +++ b/isam/panic.c @@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag) if (info->s->base.options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*dflt_keycache,info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,info->s->kfile,FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/isam/test2.c b/isam/test2.c index 67b411d1bbf..14a40f39865 100644 --- a/isam/test2.c +++ b/isam/test2.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) goto err; printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,512,IO_SIZE*16,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,512,IO_SIZE*16,0,0); /* Use a small cache */ if (locking) nisam_lock_database(file,F_WRLCK); if (write_cacheing) @@ -674,7 +674,7 @@ end: puts("Locking used"); if (use_blob) puts("blobs used"); - end_key_cache(&dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/isam/test3.c b/isam/test3.c index 1b867ba0348..9195fcbf1b6 100644 --- a/isam/test3.c +++ b/isam/test3.c @@ -20,6 +20,7 @@ #include "nisam.h" #include <sys/types.h> +#include <keycache.h> #ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif @@ -173,7 +174,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache,512,65536L,0); + init_key_cache(dflt_key_cache,512,65536L,0,0); printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 582f9613ee0..3798eaa3544 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -43,18 +43,18 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -MYSQL * STDCALL +MYSQL * cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag); -void STDCALL cli_mysql_close(MYSQL *mysql); +void cli_mysql_close(MYSQL *mysql); -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql); -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +MYSQL_FIELD * cli_list_fields(MYSQL *mysql); +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields); -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt); -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row); -const char * STDCALL cli_read_statistic(MYSQL *mysql); +int cli_stmt_execute(MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt); +int cli_unbuffered_fetch(MYSQL *mysql, char **row); +const char * cli_read_statistic(MYSQL *mysql); diff --git a/libmysql/conf_to_src.c b/libmysql/conf_to_src.c index 95ffcf1cb2b..8d931309abb 100644 --- a/libmysql/conf_to_src.c +++ b/libmysql/conf_to_src.c @@ -16,9 +16,9 @@ /* can't use -lmysys because this prog is used to create -lstrings */ + +#include <my_global.h> #include <ctype.h> -#include <stdio.h> -#include <stdlib.h> #include <string.h> #include <unistd.h> diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 148625129b5..4dfcfe6a1d3 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -72,7 +72,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; /* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ @@ -128,7 +129,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; #else /* ENGLISH */ @@ -182,7 +184,8 @@ const char *client_errors[]= "Can't open shared memory. Can't send the request event to server (%lu)", "Wrong or unknown protocol", "Invalid connection handle", - "mysql_server_init wasn't called" + "mysql_server_init wasn't called", + "Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)" }; #endif diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index caa47ba7aad..b3ae6034520 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -15,10 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> -#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) -#include <winsock.h> -#include <odbcinst.h> -#endif #include <my_sys.h> #include <mysys_err.h> #include <m_string.h> @@ -811,29 +807,33 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, const char* passwd) { MYSQL* child; - if (!(child = mysql_init(0))) - return 0; + DBUG_ENTER("spawn_init"); + if (!(child= mysql_init(0))) + DBUG_RETURN(0); - child->options.user = my_strdup((user) ? user : - (parent->user ? parent->user : - parent->options.user), MYF(0)); - child->options.password = my_strdup((passwd) ? passwd : - (parent->passwd ? - parent->passwd : - parent->options.password), MYF(0)); - child->options.port = port; - child->options.host = my_strdup((host) ? host : - (parent->host ? - parent->host : - parent->options.host), MYF(0)); + child->options.user= my_strdup((user) ? user : + (parent->user ? parent->user : + parent->options.user), MYF(0)); + child->options.password= my_strdup((passwd) ? passwd : + (parent->passwd ? + parent->passwd : + parent->options.password), MYF(0)); + child->options.port= port; + child->options.host= my_strdup((host) ? host : + (parent->host ? + parent->host : + parent->options.host), MYF(0)); if (parent->db) - child->options.db = my_strdup(parent->db, MYF(0)); + child->options.db= my_strdup(parent->db, MYF(0)); else if (parent->options.db) - child->options.db = my_strdup(parent->options.db, MYF(0)); - - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; + child->options.db= my_strdup(parent->options.db, MYF(0)); - return child; + /* + rpl_pivot is set to 1 in mysql_init(); Reset it as we are not doing + replication here + */ + child->rpl_pivot= 0; + DBUG_RETURN(child); } @@ -846,9 +846,6 @@ STDCALL mysql_set_master(MYSQL* mysql, const char* host, mysql_close(mysql->master); if (!(mysql->master = spawn_init(mysql, host, port, user, passwd))) return 1; - mysql->master->rpl_pivot = 0; - mysql->master->options.rpl_parse = 0; - mysql->master->options.rpl_probe = 0; return 0; } @@ -973,16 +970,16 @@ mysql_list_tables(MYSQL *mysql, const char *wild) DBUG_RETURN (mysql_store_result(mysql)); } -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql) +MYSQL_FIELD *cli_list_fields(MYSQL *mysql) { MYSQL_DATA *query; if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, protocol_41(mysql) ? 8 : 6))) return NULL; - mysql->field_count= query->rows; + mysql->field_count= (uint) query->rows; return unpack_fields(query,&mysql->field_alloc, - query->rows, 1, mysql->server_capabilities); + mysql->field_count, 1, mysql->server_capabilities); } @@ -1112,7 +1109,7 @@ mysql_dump_debug_info(MYSQL *mysql) DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); } -const char * STDCALL cli_read_statistic(MYSQL *mysql) +const char *cli_read_statistic(MYSQL *mysql) { mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ if (!mysql->net.read_pos[0]) @@ -1589,7 +1586,7 @@ static my_bool my_realloc_str(NET *net, ulong length) 1 error */ -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) { uchar *pos; uint field_count; @@ -2010,7 +2007,8 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length) DBUG_RETURN(0); } -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt) + +int cli_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("cli_stmt_execute"); @@ -2985,12 +2983,13 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) return 0; } -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row) +int cli_unbuffered_fetch(MYSQL *mysql, char **row) { if (packet_error == net_safe_read(mysql)) return 1; - *row= (mysql->net.read_pos[0] == 254) ? NULL : (mysql->net.read_pos+1); + *row= ((mysql->net.read_pos[0] == 254) ? NULL : + (char*) (mysql->net.read_pos+1)); return 0; } @@ -3108,7 +3107,7 @@ no_data: Read all rows of data from server (binary format) */ -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt) +MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt) { ulong pkt_len; uchar *cp; @@ -3318,7 +3317,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt) my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt) { MYSQL *mysql; - DBUG_ENTER("mysql_stmt_close"); + DBUG_ENTER("mysql_stmt_free_result"); DBUG_ASSERT(stmt != 0); @@ -3499,10 +3498,18 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql) Reads and returns the next query results */ -my_bool STDCALL mysql_next_result(MYSQL *mysql) +int STDCALL mysql_next_result(MYSQL *mysql) { DBUG_ENTER("mysql_next_result"); + if (mysql->status != MYSQL_STATUS_READY) + { + strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.last_error, + ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + DBUG_RETURN(1); + } + mysql->net.last_error[0]= 0; mysql->net.last_errno= 0; strmov(mysql->net.sqlstate, not_error_sqlstate); @@ -3511,9 +3518,10 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql) if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); - DBUG_RETURN(0); + DBUG_RETURN(-1); /* No more results */ } + MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql) { return (*mysql->methods->use_result)(mysql); diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index 265e31fafdb..60c29a99762 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -19,7 +19,7 @@ target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -## LIBS = @LIBS@ +LIBS = @LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f3b593f7341..f48a12b6f28 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -61,10 +61,11 @@ typedef struct st_ftb_expr FTB_EXPR; struct st_ftb_expr { FTB_EXPR *up; - byte *quot, *qend; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ float weight; float cur_weight; + byte *quot, *qend; uint flags; uint yesses; /* number of "yes" words matched */ uint nos; /* number of "no" words matched */ @@ -77,6 +78,7 @@ typedef struct st_ftb_word FTB_EXPR *up; MI_KEYDEF *keyinfo; my_off_t docid[2]; /* for index search and for scan */ +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ my_off_t key_root; float weight; uint ndepth; @@ -166,11 +168,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end, ftbw->word[0]=w.len; if (param.yesno > 0) up->ythresh++; queue_insert(& ftb->queue, (byte *)ftbw); -#ifdef TO_BE_REMOVED - /* after removing the following line, - ftb->with_scan handling can be simplified (no longer a bitmap) */ ftb->with_scan|=(param.trunc & FTB_FLAG_TRUNC); -#endif break; case 2: /* left bracket */ ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)); @@ -251,7 +249,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) } /* going up to the first-level tree to continue search there */ - _mi_dpointer(info, ftbw->word+ftbw->off+HA_FT_WLEN, ftbw->key_root); + _mi_dpointer(info, (uchar*) (ftbw->word+ftbw->off+HA_FT_WLEN), + ftbw->key_root); ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->off=0; @@ -298,13 +297,15 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbw->flags & FTB_FLAG_TRUNC) { /* - special treatment for truncation operator :(( - 1. +trunc* and there're other (not +trunc*) words + special treatment for truncation operator + 1. there are some (besides this) +words | no need to search in the index, it can never ADD new rows | to the result, and to remove half-matched rows we do scan anyway 2. -trunc* | same as 1. - 3. trunc* + 3. in 1 and 2, +/- need not be on the same expr. level, + but can be on any upper level, as in +word +(trunc1* trunc2*) + 4. otherwise | We have to index-search for this prefix. | It may cause duplicates, as in the index (sorted by <word,docid>) | <aaaa,row1> @@ -312,22 +313,31 @@ static void _ftb_init_index_search(FT_INFO *ftb) | <aacc,row1> | Searching for "aa*" will find row1 twice... */ - if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */ - (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */ - ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */ - { - ftbw->docid[0]=HA_POS_ERROR; - ftbw->up->yweaks++; - continue; - } - else /* 3 */ + FTB_EXPR *ftbe; + for (ftbe=(FTB_EXPR*)ftbw; + ftbe->up && !(ftbe->up->flags & FTB_FLAG_TRUNC); + ftbe->up->flags|= FTB_FLAG_TRUNC, ftbe=ftbe->up) { - if (!is_tree_inited(& ftb->no_dupes)) - init_tree(&ftb->no_dupes,0,0,sizeof(my_off_t), - _ftb_no_dupes_cmp, 0, NULL, NULL); - else - reset_tree(& ftb->no_dupes); + if (ftbe->flags & FTB_FLAG_NO || /* 2 */ + ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ + { + FTB_EXPR *top_ftbe=ftbe->up->up; + ftbw->docid[0]=HA_POS_ERROR; + for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) + if (ftbe->flags & FTB_FLAG_YES) + ftbe->yweaks++; + ftbe=0; + break; + } } + if (!ftbe) + continue; + /* 3 */ + if (!is_tree_inited(& ftb->no_dupes)) + init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), + _ftb_no_dupes_cmp,0,0,0); + else + reset_tree(& ftb->no_dupes); } if (_ft2_search(ftb, ftbw, 1)) diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 5591a6ddb3e..8c40878cf00 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -80,7 +80,7 @@ int main(int argc,char *argv[]) if (argc < 2) usage(); - init_key_cache(dflt_keycache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT,0); + init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED))) goto err; @@ -172,9 +172,9 @@ int main(int argc,char *argv[]) if (dump) { if (subkeys>=0) - printf("%9qx %20.7f %s\n",info->lastpos,weight,buf); + printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); @@ -189,12 +189,12 @@ int main(int argc,char *argv[]) if ((ulong) count >= total/2) break; } - printf("Total rows: %qu\nTotal words: %lu\n" + printf("Total rows: %lu\nTotal words: %lu\n" "Unique words: %lu\nLongest word: %lu chars (%s)\n" "Median length: %u\n" "Average global weight: %f\n" "Most common word: %lu times, weight: %f (%s)\n", - (ulonglong)info->state->records, total, uniq, maxlen, buf_maxlen, + (long) info->state->records, total, uniq, maxlen, buf_maxlen, inx, avg_gws/uniq, max_doc_cnt, min_gws, buf_min_gws); } if (lstats) diff --git a/myisam/ft_update.c b/myisam/ft_update.c index a87f239b8f8..b94a174b292 100644 --- a/myisam/ft_update.c +++ b/myisam/ft_update.c @@ -304,7 +304,7 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) my_off_t root; DYNAMIC_ARRAY *da=info->ft1_to_ft2; MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo; - uchar *key_ptr=dynamic_array_ptr(da, 0), *end; + uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end; uint length, key_length; DBUG_ENTER("_mi_ft_convert_to_ft2"); @@ -329,13 +329,13 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) DBUG_RETURN(-1); /* inserting the rest of key values */ - end=dynamic_array_ptr(da, da->elements); + end= (uchar*) dynamic_array_ptr(da, da->elements); for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength) if(_mi_ck_real_write_btree(info, keyinfo, key_ptr, 0, &root, SEARCH_SAME)) DBUG_RETURN(-1); /* now, writing the word key entry */ - ft_intXstore(key+key_length, -da->elements); + ft_intXstore(key+key_length, - (int) da->elements); _mi_dpointer(info, key+key_length+HA_FT_WLEN, root); DBUG_RETURN(_mi_ck_real_write_btree(info, diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 4f8fc9b981a..c077e267dde 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -77,6 +77,7 @@ void myisamchk_init(MI_CHECK *param) param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); param->start_check_pos=0; + param->max_record_length= LONGLONG_MAX; param->key_cache_block_size= KEY_CACHE_BLOCK_SIZE; } @@ -242,7 +243,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) if (next_link > info->state->key_file_length || next_link & (info->s->blocksize-1)) DBUG_RETURN(1); - if (!(buff=key_cache_read(*info->s->key_cache, + if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, (byte*) info->buff, myisam_block_size, block_size, 1))) @@ -262,7 +263,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) } /* check_k_link */ - /* Kontrollerar storleken p} filerna */ + /* Check sizes of files */ int chk_size(MI_CHECK *param, register MI_INFO *info) { @@ -273,8 +274,9 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) if (!(param->testflag & T_SILENT)) puts("- check file-size"); - flush_key_blocks(*info->s->key_cache, - info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */ + /* The following is needed if called externally (not from myisamchk) */ + flush_key_blocks(info->s->key_cache, + info->s->kfile, FLUSH_FORCE_WRITE); size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); if ((skr=(my_off_t) info->state->key_file_length) != size) @@ -502,7 +504,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */ else param->record_checksum=0; - DBUG_RETURN(0); + DBUG_RETURN(result); } /* chk_key */ @@ -522,7 +524,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(temp_buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for keyblock"); DBUG_RETURN(-1); } @@ -711,7 +713,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0)))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for record"); DBUG_RETURN(-1); } records=del_blocks=0; @@ -814,16 +816,17 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) goto next; } mi_check_print_error(param,"Wrong bytesec: %d-%d-%d at linkstart: %s", - block_info.header[0],block_info.header[1], - block_info.header[2], - llstr(start_block,llbuff)); + block_info.header[0],block_info.header[1], + block_info.header[2], + llstr(start_block,llbuff)); goto err2; } if (info->state->data_file_length < block_info.filepos+ block_info.block_len) { - mi_check_print_error(param,"Recordlink that points outside datafile at %s", - llstr(pos,llbuff)); + mi_check_print_error(param, + "Recordlink that points outside datafile at %s", + llstr(pos,llbuff)); got_error=1; break; } @@ -834,9 +837,9 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) pos=block_info.filepos+block_info.block_len; if (block_info.rec_len > (uint) info->s->base.max_pack_length) { - mi_check_print_error(param,"Found too long record (%d) at %s", - block_info.rec_len, - llstr(start_recpos,llbuff)); + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -845,8 +848,10 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(to= mi_alloc_rec_buff(info, block_info.rec_len, &info->rec_buff))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(start_recpos,llbuff)); + mi_check_print_error(param, + "Not enough memory (%lu) for blob at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -857,9 +862,11 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } if (left_length < block_info.data_len) { - mi_check_print_error(param,"Found too long record at %s", - llstr(start_recpos,llbuff)); - got_error=1; break; + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.data_len, + llstr(start_recpos,llbuff)); + got_error=1; + break; } if (_mi_read_cache(¶m->read_cache,(byte*) to,block_info.filepos, (uint) block_info.data_len, @@ -1142,9 +1149,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + if (!param->using_global_keycache) - VOID(init_key_cache(dflt_keycache, param->key_cache_block_size, - param->use_buffers, &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size, + param->use_buffers, 0, 0)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -1163,7 +1173,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } @@ -1355,6 +1365,7 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); } @@ -1365,7 +1376,7 @@ err: VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); VOID(end_io_cache(&info->rec_cache)); - got_error|=flush_blocks(param, *share->key_cache, share->kfile); + got_error|=flush_blocks(param, share->key_cache, share->kfile); if (!got_error && param->testflag & T_UNPACK) { share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD; @@ -1501,7 +1512,7 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file) +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) { if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) { @@ -1564,7 +1575,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); old_state= share->state; /* save state if not stored */ @@ -1625,7 +1636,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for key block"); DBUG_RETURN(-1); } if (!_mi_fetch_keypage(info,keyinfo,pagepos,DFLT_INIT_HITS,buff,0)) @@ -1811,6 +1822,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); if (!(sort_info.key_block= @@ -1834,7 +1848,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } if (!rep_quick) @@ -1874,7 +1888,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -1884,7 +1898,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2076,7 +2090,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, memcpy( &share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2182,6 +2196,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); if (!(sort_info.key_block= alloc_key_blocks(param, @@ -2237,7 +2254,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -2247,7 +2264,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2267,17 +2284,19 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, rec_length=share->base.min_block_length; else rec_length=share->base.pack_reclength; + /* + +1 below is required hack for parallel repair mode. + The info->state->records value, that is compared later + to sort_info.max_records and cannot exceed it, is + increased in sort_key_write. In mi_repair_by_sort, sort_key_write + is called after sort_key_read, where the comparison is performed, + but in parallel mode master thread can call sort_key_write + before some other repair thread calls sort_key_read. + Furthermore I'm not even sure +1 would be enough. + May be sort_info.max_records shold be always set to max value in + parallel mode. + */ sort_info.max_records= - /* +1 below is required hack for parallel repair mode. - The info->state->records value, that is compared later - to sort_info.max_records and cannot exceed it, is - increased in sort_key_write. In mi_repair_by_sort, sort_key_write - is called after sort_key_read, where the comparison is performed, - but in parallel mode master thread can call sort_key_write - before some other repair thread calls sort_key_read. - Furthermore I'm not even sure +1 would be enough. - May be sort_info.max_records shold be always set to max value in - parallel mode. */ ((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records + 1: (ha_rows) (sort_info.filelength/rec_length+1)); @@ -2291,7 +2310,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, (sizeof(MI_SORT_PARAM) + share->base.pack_reclength), MYF(MY_ZEROFILL)))) { - mi_check_print_error(param,"Not enough memory!"); + mi_check_print_error(param,"Not enough memory for key!"); goto err; } total_key_length=0; @@ -2483,7 +2502,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, memcpy(&share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2847,9 +2866,20 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(sort_param->start_recpos,llbuff)); - DBUG_RETURN(1); + if (param->max_record_length >= block_info.rec_len) + { + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + DBUG_RETURN(1); + } + else + { + mi_check_print_info(param,"Not enough memory for blob at %s (need %lu); Row skipped", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + goto try_next; + } } } else @@ -2857,14 +2887,16 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (left_length < block_info.data_len || ! block_info.data_len) { - mi_check_print_info(param,"Found block with too small length at %s; Skipped", + mi_check_print_info(param, + "Found block with too small length at %s; Skipped", llstr(sort_param->start_recpos,llbuff)); goto try_next; } if (block_info.filepos + block_info.data_len > sort_param->read_cache.end_of_file) { - mi_check_print_info(param,"Found block that points outside data file at %s", + mi_check_print_info(param, + "Found block that points outside data file at %s", llstr(sort_param->start_recpos,llbuff)); goto try_next; } @@ -3269,30 +3301,28 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) ft_buf->buf=0; return error; } - else - { - /* flushing buffer */ - if ((error=sort_ft_buf_flush(sort_param))) - return error; -word_init_ft_buf: - a_len+=val_len; - memcpy(ft_buf->lastkey, a, a_len); - ft_buf->buf=ft_buf->lastkey+a_len; - ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); - /* 32 is just a safety margin here - (at least max(val_len, sizeof(nod_flag)) should be there). - May be better performance could be achieved if we'd put - (sort_info->keyinfo->block_length-32)/XXX - instead. - TODO: benchmark the best value for XXX. - */ + /* flushing buffer */ + if ((error=sort_ft_buf_flush(sort_param))) + return error; - return 0; - } - return -1; /* impossible */ +word_init_ft_buf: + a_len+=val_len; + memcpy(ft_buf->lastkey, a, a_len); + ft_buf->buf=ft_buf->lastkey+a_len; + /* + 32 is just a safety margin here + (at least max(val_len, sizeof(nod_flag)) should be there). + May be better performance could be achieved if we'd put + (sort_info->keyinfo->block_length-32)/XXX + instead. + TODO: benchmark the best value for XXX. + */ + ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); + return 0; } /* sort_ft_key_write */ + /* get pointer to record from a key */ static my_off_t get_record_for_key(MI_INFO *info, MI_KEYDEF *keyinfo, @@ -3499,7 +3529,7 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, buffer_length+IO_SIZE)*blocks, MYF(0)))) { - mi_check_print_error(param,"Not Enough memory for sort-key-blocks"); + mi_check_print_error(param,"Not enough memory for sort-key-blocks"); return(0); } for (i=0 ; i < blocks ; i++) diff --git a/myisam/mi_close.c b/myisam/mi_close.c index 66d5b08bbc4..deb0ccee8f3 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*share->key_cache, share->kfile, + flush_key_blocks(share->key_cache, share->kfile, share->temporary ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error=my_errno; diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index f21b0e928b6..a55d5b2a5ca 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -241,7 +241,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (info->ft1_to_ft2) { /* we're in ft1->ft2 conversion mode. Saving key data */ - insert_dynamic(info->ft1_to_ft2, lastkey+off); + insert_dynamic(info->ft1_to_ft2, (char*) (lastkey+off)); } else { diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 357df9ebe3e..3033249886f 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info) If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache */ - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) goto err; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 327d795d17b..10f52f1e39a 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -33,15 +33,11 @@ Used when function is one of: HA_EXTRA_WRITE_CACHE HA_EXTRA_CACHE - HA_EXTRA_BULK_INSERT_BEGIN - If extra_arg is 0, then the default cache size is used. - HA_EXTRA_BULK_INSERT_FLUSH - extra_arg is a a pointer to which index to flush (uint*) - RETURN VALUES - 0 ok + RETURN VALUES + 0 ok + # error */ - int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { int error=0; @@ -283,7 +279,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); - if (flush_key_blocks(*share->keycache, share->kfile, + if (flush_key_blocks(share->key_cache, share->kfile, (function == HA_EXTRA_FORCE_REOPEN ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { @@ -329,7 +325,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_FLUSH: if (!share->temporary) - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_KEEP); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP); #ifdef HAVE_PWRITE _mi_decrement_open_count(info); #endif diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index c6fd1801740..99a2fd6db15 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -49,19 +49,19 @@ int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map __attribute__((unused)), - KEY_CACHE_VAR *key_cache) + KEY_CACHE *key_cache) { int error= 0; MYISAM_SHARE* share= info->s; DBUG_ENTER("mi_assign_to_key_cache"); DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", - share->key_cache, &key_cache->cache)); + share->key_cache, key_cache)); /* Skip operation if we didn't change key cache. This can happen if we call this for all open instances of the same table */ - if (*share->key_cache == key_cache->cache) + if (share->key_cache == key_cache) DBUG_RETURN(0); /* @@ -76,7 +76,7 @@ int mi_assign_to_key_cache(MI_INFO *info, in the old key cache. */ - if (flush_key_blocks(*share->key_cache, share->kfile, FLUSH_REMOVE)) + if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)) { error= my_errno; mi_mark_crashed(info); /* Mark that table must be checked */ @@ -90,18 +90,24 @@ int mi_assign_to_key_cache(MI_INFO *info, (This can never fail as there is never any not written data in the new key cache) */ - (void) flush_key_blocks(key_cache->cache, share->kfile, FLUSH_REMOVE); + (void) flush_key_blocks(key_cache, share->kfile, FLUSH_RELEASE); /* + ensure that setting the key cache and changing the multi_key_cache + is done atomicly + */ + pthread_mutex_lock(&share->intern_lock); + /* Tell all threads to use the new key cache This should be seen at the lastes for the next call to an myisam function. */ - share->key_cache= &key_cache->cache; + share->key_cache= key_cache; /* store the key cache in the global hash structure for future opens */ if (multi_key_cache_set(share->unique_file_name, share->unique_name_length, share->key_cache)) error= my_errno; + pthread_mutex_unlock(&share->intern_lock); DBUG_RETURN(error); } @@ -127,8 +133,8 @@ int mi_assign_to_key_cache(MI_INFO *info, */ -void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { LIST *pos; DBUG_ENTER("mi_change_key_cache"); @@ -141,7 +147,7 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, { MI_INFO *info= (MI_INFO*) pos->data; MYISAM_SHARE *share= info->s; - if (share->key_cache == &old_key_cache->cache) + if (share->key_cache == old_key_cache) mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache); } @@ -150,6 +156,6 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, MyISAM list structure to ensure that another thread is not trying to open a new table that will be associted with the old key cache */ - multi_key_cache_change(&old_key_cache->cache, &new_key_cache->cache); + multi_key_cache_change(old_key_cache, new_key_cache); pthread_mutex_unlock(&THR_LOCK_myisam); } diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 2056b018a16..67ccca52d08 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -61,7 +61,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) count= --share->w_locks; --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - !share->delay_key_write && flush_key_blocks(*share->key_cache, + !share->delay_key_write && flush_key_blocks(share->key_cache, share->kfile,FLUSH_KEEP)) { error=my_errno; @@ -389,7 +389,7 @@ int _mi_test_if_changed(register MI_INFO *info) { /* Keyfile has changed */ DBUG_PRINT("info",("index file changed")); if (share->state.process != share->this_process) - VOID(flush_key_blocks(*share->key_cache, share->kfile, FLUSH_RELEASE)); + VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)); share->last_process=share->state.process; info->last_unique= share->state.unique; info->last_loop= share->state.update_count; diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 0aae267e05e..c70209c2da6 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -32,7 +32,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_ENTER("_mi_fetch_keypage"); DBUG_PRINT("enter",("page: %ld",page)); - tmp=(uchar*) key_cache_read(*info->s->key_cache, + tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, @@ -52,7 +52,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", tmp, keyinfo->block_length); + DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; my_errno = HA_ERR_CRASHED; tmp = 0; @@ -95,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, length=keyinfo->block_length; } #endif - DBUG_RETURN((key_cache_write(*info->s->key_cache, + DBUG_RETURN((key_cache_write(info->s->key_cache, info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || @@ -117,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, info->s->state.key_del[keyinfo->block_size]=pos; mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; - DBUG_RETURN(key_cache_write(*info->s->key_cache, + DBUG_RETURN(key_cache_write(info->s->key_cache, info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, @@ -146,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level) } else { - if (!key_cache_read(*info->s->key_cache, + if (!key_cache_read(info->s->key_cache, info->s->kfile, pos, level, buff, (uint) sizeof(buff), diff --git a/myisam/mi_panic.c b/myisam/mi_panic.c index cefb3423ccc..78698d88c54 100644 --- a/myisam/mi_panic.c +++ b/myisam/mi_panic.c @@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag) if (info->s->options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 3219c00b0e2..5e03d489efe 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -69,7 +69,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; do @@ -87,7 +87,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (mi_test_if_nod(buff)) { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; @@ -99,7 +99,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } else { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, length)) goto err; @@ -108,11 +108,11 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } while (pos != key_file_length); - my_free(buff, MYF(0)); + my_free((char*) buff, MYF(0)); DBUG_RETURN(0); err: - my_free(buff, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(my_errno= errno); } diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index c1b76408a7c..64ffbe2db1d 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -50,7 +50,7 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); if (key_cacheing) - init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0); get_options(argc,argv); exit(run_test("test1")); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 5918a2485b0..d3c3cc2c492 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,key_cache_block_size,key_cache_size,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); if (locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) } } if (key_cacheing) - resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2); + resize_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size*2,0,0); if (!silent) printf("- Delete\n"); @@ -829,7 +829,7 @@ reads: %10lu\n", my_cache_r_requests, my_cache_read); #endif } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/myisam/mi_test3.c b/myisam/mi_test3.c index baeaba7bf24..dca04a9a64b 100644 --- a/myisam/mi_test3.c +++ b/myisam/mi_test3.c @@ -177,7 +177,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache, KEY_CACHE_BLOCK_SIZE, 65536L,0); + init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 86c45e0692f..d13ba6c2c4e 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -521,7 +521,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, we cannot easily dispatch an empty page here */ b+=blen+ft2len+2; for (a=anc_buff+a_length ; b < a ; b+=ft2len+2) - insert_dynamic(info->ft1_to_ft2, b); + insert_dynamic(info->ft1_to_ft2, (char*) b); /* fixing the page's length - it contains only one key now */ mi_putint(anc_buff,2+blen+ft2len+2,0); diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 5193a817a3a..d65fac009f8 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -110,7 +110,8 @@ int main(int argc, char **argv) VOID(fflush(stderr)); if ((check_param.error_printed | check_param.warning_printed) && (check_param.testflag & T_FORCE_CREATE) && - (!(check_param.testflag & (T_REP | T_SORT_RECORDS | T_SORT_INDEX)))) + (!(check_param.testflag & (T_REP | T_REP_BY_SORT | T_SORT_RECORDS | + T_SORT_INDEX)))) { uint old_testflag=check_param.testflag; if (!(check_param.testflag & T_REP)) @@ -153,7 +154,7 @@ enum options_mc { OPT_KEY_CACHE_BLOCK_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN, - OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT + OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT, OPT_MAX_RECORD_LENGTH }; static struct my_option my_long_options[] = @@ -215,6 +216,11 @@ static struct my_option my_long_options[] = (gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, + {"max-record-length", OPT_MAX_RECORD_LENGTH, + "Skip rows bigger than this if myisamchk can't allocate memory to hold it", + (gptr*) &check_param.max_record_length, + (gptr*) &check_param.max_record_length, + 0, GET_ULL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0}, {"medium-check", 'm', "Faster than extend-check, but only finds 99.99% of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -321,13 +327,13 @@ static struct my_option my_long_options[] = { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void print_version(void) { - printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, + printf("%s Ver 2.7 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -394,6 +400,9 @@ static void usage(void) -k, --keys-used=# Tell MyISAM to update only some specific keys. # is a\n\ bit mask of which keys to use. This can be used to\n\ get faster inserts.\n\ + --max-record-length=#\n\ + Skip rows bigger than this if myisamchk can't allocate\n\ + memory to hold it.\n\ -r, --recover Can fix almost anything except unique keys that aren't\n\ unique.\n\ -n, --sort-recover Forces recovering with sorting even if the temporary\n\ @@ -1032,8 +1041,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) !(param->testflag & (T_FAST | T_FORCE_CREATE))) { if (param->testflag & (T_EXTEND | T_MEDIUM)) - VOID(init_key_cache(dflt_keycache,opt_key_cache_block_size, - param->use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, + param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1047,7 +1056,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) error|=chk_data_link(param, info, param->testflag & T_EXTEND); - error|=flush_blocks(param, *share->key_cache, share->kfile); + error|=flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(¶m->read_cache)); } if (!error) @@ -1456,8 +1465,8 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache, opt_key_cache_block_size, param->use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, + 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) @@ -1571,7 +1580,7 @@ err: my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); sort_info.buff=0; share->state.sortkey=sort_key; - DBUG_RETURN(flush_blocks(param, *share->key_cache, share->kfile) | + DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) | got_error); } /* sort_records */ diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 20574e43ac3..3788eeca1e3 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -166,7 +166,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ char *data_file_name, /* Resolved path names from symlinks */ *index_file_name; byte *file_map; /* mem-map of file if possible */ - KEY_CACHE_HANDLE *key_cache; /* ref to the current key cache */ + KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; int (*read_record)(struct st_myisam_info*, my_off_t, byte*); @@ -713,7 +713,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param); #ifdef THREAD pthread_handler_decl(thr_find_all_keys,arg); #endif -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file); +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); int sort_write_record(MI_SORT_PARAM *sort_param); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index fbe8b675821..c9b00be7d9e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -71,7 +71,7 @@ static void printf_log(const char *str,...); static bool cmp_filename(struct file_info *file_info,my_string name); static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0, - recover=0,prefix_remove=0,opt_processes=0,opt_myisam_with_debug=0; + recover=0,prefix_remove=0,opt_processes=0; static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0; static ulong com_count[10][3],number_of_commands=(ulong) ~0L, isamlog_process; @@ -201,9 +201,6 @@ static void get_options(register int *argc, register char ***argv) update=1; recover++; break; - case 'D': - opt_myisam_with_debug=1; - break; case 'P': opt_processes=1; break; @@ -333,8 +330,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0, 0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && @@ -648,7 +645,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -668,7 +665,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(*dflt_keycache, 1); + end_key_cache(dflt_key_cache, 1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 5ca57248204..93edde33bdb 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -51,7 +51,7 @@ struct st_file_buffer { char *buffer,*pos,*end; my_off_t pos_in_file; int bits; - uint byte; + uint current_byte; }; struct st_huff_tree; @@ -1912,7 +1912,7 @@ static void init_file_buffer(File file, pbool read_buffer) file_buffer.pos=file_buffer.buffer; file_buffer.bits=BITS_SAVED; } - file_buffer.byte=0; + file_buffer.current_byte=0; } @@ -1961,13 +1961,13 @@ static void write_bits (register ulong value, register uint bits) { if ((file_buffer.bits-=(int) bits) >= 0) { - file_buffer.byte|=value << file_buffer.bits; + file_buffer.current_byte|=value << file_buffer.bits; } else { reg3 uint byte_buff; bits= (uint) -file_buffer.bits; - byte_buff=file_buffer.byte | (uint) (value >> bits); + byte_buff=file_buffer.current_byte | (uint) (value >> bits); #if BITS_SAVED == 32 *file_buffer.pos++= (byte) (byte_buff >> 24) ; *file_buffer.pos++= (byte) (byte_buff >> 16) ; @@ -1993,7 +1993,7 @@ static void write_bits (register ulong value, register uint bits) if (file_buffer.pos >= file_buffer.end) VOID(flush_buffer((uint) ~0)); file_buffer.bits=(int) (BITS_SAVED - bits); - file_buffer.byte=(uint) (value << (BITS_SAVED - bits)); + file_buffer.current_byte=(uint) (value << (BITS_SAVED - bits)); } return; } @@ -2005,7 +2005,7 @@ static void flush_bits (void) uint bits,byte_buff; bits=(file_buffer.bits) & ~7; - byte_buff = file_buffer.byte >> bits; + byte_buff = file_buffer.current_byte >> bits; bits=BITS_SAVED - bits; while (bits > 0) { @@ -2013,7 +2013,7 @@ static void flush_bits (void) *file_buffer.pos++= (byte) (uchar) (byte_buff >> bits) ; } file_buffer.bits=BITS_SAVED; - file_buffer.byte=0; + file_buffer.current_byte=0; return; } diff --git a/myisam/sort.c b/myisam/sort.c index 4617dec46f4..6f255881a42 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, char* key, uint sort_length, uint count); -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs); +inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file, byte *bufs); /* Creates a index of sorted keys @@ -622,21 +622,25 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, DBUG_RETURN(0); } /* write_keys */ -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) + +inline int my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs) { int err; - uint16 len = _mi_keylength(info->keyinfo,bufs); + uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs); - if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) + /* The following is safe as this is a local file */ + if ((err= my_b_write(to_file, (byte*)&len, sizeof(len)))) return (err); - if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) + if ((err= my_b_write(to_file,bufs, (uint) len))) return (err); return (0); } -static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys, - uint count, BUFFPEK *buffpek, IO_CACHE *tempfile) +static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, + register uchar **sort_keys, + uint count, BUFFPEK *buffpek, + IO_CACHE *tempfile) { uchar **end; int err; @@ -653,7 +657,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if ((err= my_var_write(info,tempfile,*sort_keys))) + if ((err= my_var_write(info,tempfile, (byte*) *sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -816,7 +820,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, for (idx=1;idx<=count;idx++) { int err; - if ((err= my_var_write(info,to_file,bufs))) + if ((err= my_var_write(info,to_file, (byte*) bufs))) return (err); bufs=bufs+sort_length; } diff --git a/myisam/sp_test.c b/myisam/sp_test.c index c4847217efd..16a97771887 100644 --- a/myisam/sp_test.c +++ b/myisam/sp_test.c @@ -271,7 +271,8 @@ int run_test(const char *filename) create_key(key, nrecords*upd); print_key(key," INTERSECT\n"); - hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,0); + hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0, + HA_READ_KEY_EXACT); printf(" %ld rows\n", (long) hrows); @@ -351,7 +352,7 @@ static void print_record(char * record, my_off_t offs,const char * tail) printf(" len=%d ",len); memcpy_fixed(&ptr,pos,sizeof(char*)); if(ptr) - rtree_PrintWKB(ptr,SPDIMS); + rtree_PrintWKB((uchar*) ptr,SPDIMS); else printf("<NULL> "); printf(" offs=%ld ",(long int)offs); @@ -406,7 +407,7 @@ static void create_linestring(char *record,uint rownr) pos++; memset(blob_key,0,sizeof(blob_key)); - tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints,blob_key); + tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key); int4store(pos,tmp); pos+=4; diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh index ca6d393e3b4..d8bdd91c59f 100644 --- a/mysql-test/install_test_db.sh +++ b/mysql-test/install_test_db.sh @@ -12,11 +12,13 @@ if [ x$1 = x"-bin" ]; then BINARY_DIST=1 fix_bin=mysql-test scriptdir=../bin + libexecdir=../libexec else execdir=../sql bindir=../client fix_bin=. scriptdir=../scripts + libexecdir=../libexec fi vardir=var @@ -36,8 +38,13 @@ EXTRA_ARG="" if test ! -x $execdir/mysqld then - echo "mysqld is missing - looked in $execdir" - exit 1 + if test ! -x $libexecdir/mysqld + then + echo "mysqld is missing - looked in $execdir and in $libexecdir" + exit 1 + else + execdir=$libexecdir + fi fi # On IRIX hostname is in /usr/bsd so add this to the path diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 02d97d646a4..29cd7a05f7d 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1,7 +1,7 @@ -#! /bin/sh +#!/bin/sh # mysql-test-run - originally written by Matt Wagner <matt@mysql.com> # modified by Sasha Pachev <sasha@mysql.com> -# Sligtly updated by Monty +# Slightly updated by Monty # Cleaned up again by Matt # Fixed by Sergei # :-) @@ -1172,7 +1172,7 @@ run_testcase () slave_master_info_file=$TESTDIR/$tname.slave-mi echo $tname > $CURRENT_TEST SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` - if [ $USE_MANAGER = 1 ] ; then + if [ "$USE_MANAGER" = 1 ] ; then many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)` fi diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 93214ae8479..4c6e1645451 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -18,9 +18,11 @@ select -(0-3),round(-(0-3)), round(9999999999999999999); -(0-3) round(-(0-3)) round(9999999999999999999) 3 3 10000000000000000000 create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 18446744073709551615 select * from t1 where a=18446744073709551615; @@ -29,6 +31,8 @@ a delete from t1 where a=18446744073709551615; select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 drop table t1; create table t1 ( a int not null default 1, big bigint ); @@ -70,3 +74,13 @@ select * from t1 limit 9999999999; id a 9999999999 1 drop table t1; +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); +insert into t1 values ('10000000000000000000'); +select * from t1; +quantity +-8446744073709551616 +10000000000000000000 +10000000000000000000 +drop table t1; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 9b03422f54c..e9d432de077 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -90,19 +90,21 @@ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4, CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, -CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 +CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, +CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c2` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c3` char(1) default NULL, - `c4` char(1) default NULL, - `c5` char(3) default NULL, - `c6` char(3) default NULL, - `c7` double(3,1) default NULL, - `c8` double(3,1) default NULL + `c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c3` char(1) NOT NULL default '', + `c4` char(1) NOT NULL default '', + `c5` char(3) NOT NULL default '', + `c6` char(3) NOT NULL default '', + `c7` double(3,1) NOT NULL default '0.0', + `c8` double(3,1) NOT NULL default '0.0', + `c9` double(3,1) default NULL ) TYPE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT CASE diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result index 633bb2fa252..086e1360b0c 100644 --- a/mysql-test/r/count_distinct3.result +++ b/mysql-test/r/count_distinct3.result @@ -5,3 +5,4 @@ COUNT(*) 4181000 SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; DROP TABLE t1; +set @@read_buffer_size=default; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 28f06f0bf47..8661e32d4bb 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1,4 +1,5 @@ drop table if exists t1,t2,t3; +drop database if exists test_$1; create table t1 (b char(0)); insert into t1 values (""),(null); select * from t1; @@ -302,9 +303,6 @@ t3 CREATE TABLE `t3` ( select * from t3; id name drop table t2, t3; -drop database if exists test_$1; -Warnings: -Note 1008 Can't drop database 'test_$1'; database doesn't exist create database test_$1; create table test_$1.t3 like t1; create temporary table t3 like test_$1.t3; @@ -404,14 +402,13 @@ d date 0000-00-00 e char(1) f datetime 0000-00-00 00:00:00 g time 00:00:00 -h mediumblob +h longblob dd time 00:00:00 select * from t2; a b c d e f g h dd 1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 drop table t1, t2; -drop database if exists test_$1; create database test_$1; use test_$1; select database(); diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 346d086f34c..ee4fa074477 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -120,7 +120,7 @@ date format str_to_date 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -144,7 +144,7 @@ date format con 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -168,7 +168,7 @@ date format datetime 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -192,7 +192,7 @@ date format date2 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 15 September 2001 %d %M %Y 2001-09-15 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 15 MAY 2001 %d %b %Y 2001-05-15 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 @@ -330,3 +330,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")` +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +date_format(d,"%d") +14 +14 +drop table t1; diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 6d322078018..bb268cd1094 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -228,3 +228,20 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where drop table t1; +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +a a +1 1 +2 1 +1 2 +2 2 +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +1 PRIMARY <derived4> ALL NULL NULL NULL NULL 2 +4 DERIVED t1 ALL NULL NULL NULL NULL 2 +5 UNION t1 ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 +3 UNION t1 ALL NULL NULL NULL NULL 2 +drop table t1; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 5cb4263f649..191331e7a2a 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -161,6 +161,23 @@ Only MyISAM tables support collections Function MATCH ... AGAINST() is used to do a search some test foobar implements vector space model drop table t1; +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +a +aaa10 bbb20 +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +a +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +a +aaa10 bbb20 +drop table t1; CREATE TABLE t1 ( id int(11), ticket int(11), diff --git a/mysql-test/r/fulltext_left_join.result b/mysql-test/r/fulltext_left_join.result index 6875a517718..d215ea0cea8 100644 --- a/mysql-test/r/fulltext_left_join.result +++ b/mysql-test/r/fulltext_left_join.result @@ -41,4 +41,12 @@ venue_id venue_text dt name entity_id select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; venue_id venue_text dt name entity_id 1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL drop table t1,t2; diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result index 63a0ebc4086..7de111549bb 100644 --- a/mysql-test/r/index_merge.result +++ b/mysql-test/r/index_merge.result @@ -76,13 +76,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where explain select * from t0 where key2 = 45 or key1 is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where +1 SIMPLE t0 range i1,i2 i2 4 NULL 1 Using where explain select * from t0 where key2=10 or key3=3 or key4 <=> null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where explain select * from t0 where key2=10 or key3=3 or key4 is null; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 ALL i2,i3,i4 NULL NULL NULL 1024 Using where +1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or (key3=10) or (key4 <=> null); id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 3a1f68fb6c1..165f1522378 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -91,7 +91,7 @@ grp a c id a c d NULL NULL NULL NULL NULL NULL explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 9de9fdce2db..f4decd3b79e 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -142,3 +142,14 @@ a b c d 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 drop table t1; +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values +(1,1), (2,2), (3,3), (4,4), (5,5), (6,6), +(7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +explain select * from t1 where a between 2 and 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 4 NULL 2 Using where +explain select * from t1 where a between 2 and 3 or b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx idx 4 NULL 2 Using where +drop table t1; diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index db747e3a7eb..a37f7e3c485 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -580,3 +580,7 @@ FieldKey LongVal StringVal 3 2 1 3 3 3 DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; diff --git a/mysql-test/r/raid.result b/mysql-test/r/raid.result index fd47a9451f6..6e16757a43d 100644 --- a/mysql-test/r/raid.result +++ b/mysql-test/r/raid.result @@ -1,7 +1,8 @@ -create database test_raid; -create table test_raid.r1 (i int) raid_type=1; -drop database test_raid; DROP TABLE IF EXISTS t1,t2; +DROP DATABASE IF EXISTS test_$1; +create database test_$1; +create table test_$1.r1 (i int) raid_type=1; +drop database test_$1; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c char(255) not null @@ -99,7 +100,6 @@ count(*) 450 DROP TABLE t2; /* variable rows */ -DROP TABLE IF EXISTS t2; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c varchar(255) not null diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 1b66f442a9a..0c8f2cb5323 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -279,6 +279,16 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; create table t1 (id int(10) primary key); insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); select id from t1 where id in (2,5,9) ; diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index 98ad998f2ed..8cbbe3ab0e8 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -1,22 +1,22 @@ reset master; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master change master to master_host='127.0.0.1'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # drop table if exists t1; create table t1 (n int); diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result new file mode 100644 index 00000000000..a6342d47b49 --- /dev/null +++ b/mysql-test/r/rpl_change_master.result @@ -0,0 +1,32 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +select get_lock("a",5); +get_lock("a",5) +1 +create table t1(n int); +insert into t1 values(1+get_lock("a",15)*0); +insert into t1 values(2); +stop slave; +select * from t1; +n +1 +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # +change master to master_user='root'; +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # +select release_lock("a"); +release_lock("a") +1 +start slave; +select * from t1; +n +1 +2 +drop table t1; diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result index 41c5ebe47e1..3e234d4ef59 100644 --- a/mysql-test/r/rpl_empty_master_crash.result +++ b/mysql-test/r/rpl_empty_master_crash.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master load table t1 from master; ERROR 08S01: Error connecting to master: Master is not configured load table t1 from master; diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result index 2baa69d4aad..8d5bbf91561 100644 --- a/mysql-test/r/rpl_error_ignored_table.result +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -8,7 +8,7 @@ create table t1 (a int primary key); insert into t1 values (1),(1); ERROR 23000: Duplicate entry '1' for key 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 213 slave-relay-bin.000002 257 master-bin.000001 Yes Yes test.t1 0 0 213 257 None 0 No # show tables like 't1'; Tables_in_test (t1) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index e0f85210616..6992b635672 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -13,5 +13,5 @@ master_password='',master_port=SLAVE_PORT; start slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 79 4 None 0 No # diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 092b14cacfb..65fc9d1b415 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -21,7 +21,7 @@ day id category name 2003-03-22 2161 c asdf 2003-03-22 2416 a bbbbb show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB slave-bin.000001 964 drop table t1; drop table t2; @@ -32,7 +32,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; set global sql_slave_skip_counter=1; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1311 slave-relay-bin.000002 1355 master-bin.000001 Yes Yes 0 0 1311 1355 None 0 No # set sql_log_bin=0; delete from t1; @@ -42,8 +42,8 @@ stop slave; change master to master_user='test'; change master to master_user='root'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1442 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1442 4 None 0 No # +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1419 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1419 4 None 0 No # set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; @@ -53,7 +53,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; stop slave; reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), @@ -63,6 +63,6 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 491 drop table t2; diff --git a/mysql-test/r/rpl_loaddata_rule_m.result b/mysql-test/r/rpl_loaddata_rule_m.result index ed0c96bbfe1..a34453b0a2b 100644 --- a/mysql-test/r/rpl_loaddata_rule_m.result +++ b/mysql-test/r/rpl_loaddata_rule_m.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; drop database if exists mysqltest; -reset master; +stop slave; create database mysqltest; create table t1(a int, b int, unique(b)); use mysqltest; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 6860067a2d4..2f8a54369c9 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -95,7 +95,7 @@ slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1) slave-bin.000002 122 Query 1 122 use `test`; drop table t1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 098fb056cc6..10c78272de6 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -5,10 +5,10 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_log_pos=73; @@ -16,20 +16,20 @@ start slave; stop slave; change master to master_log_pos=73; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 48 master-bin.000001 No Yes 0 0 73 48 None 0 No # stop slave; change master to master_log_pos=173; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0 No # show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 create table if not exists t1 (n int); drop table if exists t1; diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 2d08ca6e3a3..5c3360b0f66 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -15,7 +15,7 @@ select @@global.max_relay_log_size; 4096 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000014 1221 master-bin.000001 Yes Yes 0 0 50477 1221 None 0 No # stop slave; reset slave; @@ -25,7 +25,7 @@ select @@global.max_relay_log_size; 20480 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000004 9457 master-bin.000001 Yes Yes 0 0 50477 9457 None 0 No # stop slave; reset slave; @@ -35,27 +35,27 @@ select @@global.max_relay_log_size; 0 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000008 1283 master-bin.000001 Yes Yes 0 0 50477 1283 None 0 No # stop slave; reset slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset slave; start slave; flush logs; create table t1 (a int); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50535 slave-relay-bin.000009 62 master-bin.000001 Yes Yes 0 0 50535 62 None 0 No # flush logs; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50583 slave-relay-bin.000010 52 master-bin.000001 Yes Yes 0 0 50583 52 None 0 No # flush logs; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000002 4 diff --git a/mysql-test/r/rpl_openssl.result b/mysql-test/r/rpl_openssl.result index 32760f2c870..ad7251fd631 100644 --- a/mysql-test/r/rpl_openssl.result +++ b/mysql-test/r/rpl_openssl.result @@ -19,12 +19,12 @@ select * from t1; t 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 289 slave-relay-bin.000001 108 master-bin.000001 Yes Yes 0 0 289 108 None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # stop slave; change master to master_user='root',master_password='', master_ssl=0; start slave; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 337 slave-relay-bin.000001 96 master-bin.000001 Yes Yes 0 0 337 96 None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result index 24a0b1af541..9dd51eaba4d 100644 --- a/mysql-test/r/rpl_redirect.result +++ b/mysql-test/r/rpl_redirect.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; SHOW SLAVE STATUS; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master SHOW SLAVE HOSTS; Server_id Host Port Rpl_recovery_rank Master_id 2 127.0.0.1 SLAVE_PORT 2 1 diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 271ee9cefa1..43de4a67ce9 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -27,5 +27,5 @@ select * from t11; ERROR 42S02: Table 'test.t11' doesn't exist drop table if exists t1,t2,t11; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1325 None 0 No # diff --git a/mysql-test/r/rpl_reset_slave.result b/mysql-test/r/rpl_reset_slave.result index e1fbf12786d..42d41533cb0 100644 --- a/mysql-test/r/rpl_reset_slave.result +++ b/mysql-test/r/rpl_reset_slave.result @@ -5,20 +5,20 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_user='test'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 79 4 None 0 No # reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; reset slave; diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 4e31164f2ec..87ebf870f38 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -15,7 +15,7 @@ insert into temp_table values ("testing temporary tables"); create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 None 0 No # select * from t1; s @@ -56,7 +56,7 @@ Log_name master-bin.000003 insert into t2 values (65); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 None 0 No # select * from t2; m @@ -74,13 +74,13 @@ Log_name master-bin.000003 master-bin.000004 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000004 2886 select * from t4; a testing temporary tables part 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000004 2886 slave-relay-bin.000001 7891 master-bin.000004 Yes Yes 0 0 2886 7891 None 0 No # lock tables t3 read; select count(*) from t3 where n >= 4; diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result index caca15ab4ef..39b754dec47 100644 --- a/mysql-test/r/rpl_trunc_binlog.result +++ b/mysql-test/r/rpl_trunc_binlog.result @@ -9,5 +9,5 @@ flush logs; reset slave; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No # diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 3ee902cfc09..c179351551d 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -30,7 +30,7 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-bin.000001 244 No # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; @@ -40,22 +40,22 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 # Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; select * from t2; n 1 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 537 master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 # Relay slave-relay-bin.000002 537 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=561; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 649 master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 # Master master-bin.000001 561 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 5f755592452..a1ac2a85b6e 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -35,7 +35,7 @@ call foo(); ERROR 42000: PROCEDURE foo does not exist drop procedure if exists foo; Warnings: -Warning 1286 PROCEDURE foo does not exist +Warning 1287 PROCEDURE foo does not exist show create procedure foo; ERROR 42000: PROCEDURE foo does not exist create procedure foo() @@ -71,7 +71,7 @@ declare y int; set x = y; end; Warnings: -Warning 1292 Referring to uninitialized variable y +Warning 1293 Referring to uninitialized variable y drop procedure foo; create procedure foo() begin diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index e8bc7b85e98..a419f4a0565 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -618,7 +618,7 @@ create procedure hndlr4() begin declare x int default 0; declare val int; # No default -declare continue handler for 1310 set x=1; +declare continue handler for sqlstate '02000' set x=1; select data into val from test.t3 where id='z' limit 1; # No hits insert into test.t3 values ('z', val); end; @@ -631,7 +631,7 @@ drop procedure hndlr4; create procedure cur1() begin declare done int default 0; -declare continue handler for 1310 set done = 1; +declare continue handler for sqlstate '02000' set done = 1; declare c cursor for select * from test.t2; declare a char(16); declare b int; @@ -658,7 +658,7 @@ create table t3 ( s char(16), i int ); create procedure cur2() begin declare done int default 0; -declare continue handler for 1310 set done = 1; +declare continue handler for sqlstate '02000' set done = 1; declare c1 cursor for select id,data from test.t1; declare c2 cursor for select i from test.t2; open c1; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 177baa84e0f..0f7d5bb5d43 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -149,10 +149,10 @@ select (select a from t1 where t1.a=t2.b), a from t2; (select a from t1 where t1.a=t2.b) a NULL 1 NULL 2 -select (select a from t1), a from t2; -(select a from t1) a -2 1 -2 2 +select (select a from t1), a, (select 1 union select 2 limit 1) from t2; +(select a from t1) a (select 1 union select 2 limit 1) +2 1 1 +2 2 1 select (select a from t3), a from t2; (select a from t3) a NULL 1 diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index c31d1019d89..a56fe3e1462 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` ( `b` char(16) NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' drop database mysqltest; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index d1147e55119..c521aa0296c 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -508,5 +508,5 @@ drop table t1; create table t1 select load_file('../../std_data/words.dat'); show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -load_file('../../std_data/words.dat') mediumblob NULL YES NULL select,insert,update,references +load_file('../../std_data/words.dat') longblob NULL YES NULL select,insert,update,references drop table t1; diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index b665f78bbce..512df8fbaa9 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -271,8 +271,8 @@ Field Type Collation Null Key Default Extra Privileges Comment auto bigint(17) unsigned NULL PRI 0 select,insert,update,references t1 bigint(1) NULL 0 select,insert,update,references t2 char(1) latin1_swedish_ci select,insert,update,references -t3 mediumtext latin1_swedish_ci select,insert,update,references -t4 mediumtext latin1_bin select,insert,update,references +t3 longtext latin1_swedish_ci select,insert,update,references +t4 longtext latin1_bin select,insert,update,references select * from t2; auto t1 t2 t3 t4 11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 00eddd596cf..241b9847c02 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -53,7 +53,7 @@ select 0,'#' union select a,b from t1 union all select a,b from t2 union select 4 d 5 f 6 e -7 g +7 gg select a,b from t1 union select a,b from t1; a b 1 a @@ -449,10 +449,10 @@ INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1", SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; id_master id text1 text2 1 1 NULL ABCDE -1 1 bar1 -1 2 bar2 +1 1 foo1 bar1 +1 2 foo2 bar2 1 3 NULL bar3 -1 4 bar4 +1 4 foo4 bar4 SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; id_master id text1 text2 1 1 ABCDE ABCDE @@ -523,3 +523,303 @@ pla_id matintnum 105 c 0 0 drop table t1, t2; +create table t1 SELECT "a" as a UNION select "aa" as a; +select * from t1; +a +a +aa +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT 12 as a UNION select "aa" as a; +select * from t1; +a +12 +aa +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(2) NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT 12 as a UNION select 12.2 as a; +select * from t1; +a +12.0 +12.2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` double(4,1) NOT NULL default '0.0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); +create table t1 SELECT it2 from t2 UNION select it1 from t2; +select * from t1; +it2 +1 +NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `it2` tinyint(4) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT it2 from t2 UNION select i from t2; +select * from t1; +it2 +1 +3 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `it2` int(11) NOT NULL default '0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT i from t2 UNION select f from t2; +select * from t1; +i +3 +1.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select d from t2; +select * from t1; +f +1.5 +2.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT ib from t2 UNION select f from t2; +select * from t1; +ib +4 +1.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ib` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT ib from t2 UNION select d from t2; +select * from t1; +ib +4 +2.5 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ib` double default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select y from t2; +select * from t1; +f +1.5 +1972 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` float default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT f from t2 UNION select da from t2; +select * from t1; +f +1.5 +1972-10-22 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` char(12) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT y from t2 UNION select da from t2; +select * from t1; +y +1972 +1972-10-22 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `y` char(10) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT y from t2 UNION select dt from t2; +select * from t1; +y +1972 +1972-10-22 11:50:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `y` char(19) binary default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT da from t2 UNION select dt from t2; +select * from t1; +da +1972-10-22 00:00:00 +1972-10-22 11:50:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `da` datetime default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select sc from t2; +select * from t1; +dt +1972-10-22 11:50:00 +testc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` char(19) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select sv from t2; +select * from t1; +dt +1972-10-22 11:50:00 +testv +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` char(19) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sc from t2 UNION select sv from t2; +select * from t1; +sc +testc +testv +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sc` varchar(10) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT dt from t2 UNION select b from t2; +select * from t1; +dt +1972-10-22 11:50:00 +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` longblob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sv from t2 UNION select b from t2; +select * from t1; +sv +testv +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sv` longblob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; +select * from t1; +i +3 +2.5 +tetetetetest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` blob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT sv from t2 UNION select tx from t2; +select * from t1; +sv +testv +teeeeeeeeeeeest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `sv` text +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 SELECT b from t2 UNION select tx from t2; +select * from t1; +b +tetetetetest +teeeeeeeeeeeest +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` longblob +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1,t2; +create table t1 (d decimal(10,1)); +create table t2 (d decimal(10,9)); +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +select * from t3; +d +1.234567800 +100000000.0 +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `d` decimal(10,9) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1,t2,t3; +create table t1 select 1 union select -1; +select * from t1; +1 +1 +-1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `1` bigint(1) NOT NULL default '0' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 select _latin1"test" union select _latin2"testt" ; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'UNION' +create table t1 select _latin2"test" union select _latin2"testt" ; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `test` char(5) character set latin2 NOT NULL default '' +) TYPE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (s char(200)); +insert into t1 values (repeat("1",200)); +create table t2 select * from t1; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +set local tmp_table_size=1024; +select count(*) from (select * from t1 union all select * from t2 order by 1) b; +count(*) +21 +select count(*) from t1; +count(*) +8 +select count(*) from t2; +count(*) +13 +drop table t1,t2; +set local tmp_table_size=default; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 612c1f53bcf..fc3dc4eddcd 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -101,3 +101,22 @@ drop table t1; select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b 10 2 1 10 2 1 10 2 1 10 2 1 +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; +@a:=0 +0 +select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +@a @a:=@a+count(*) count(*) @a +0 1 1 0 +0 2 2 0 +0 3 3 0 +select @a:=0; +@a:=0 +0 +select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +@a+0 @a:=@a+0+count(*) count(*) @a+0 +0 1 1 0 +1 3 2 0 +3 6 3 0 +drop table t1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 88f796f8c4e..3e7e6af7408 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -360,7 +360,7 @@ set sql_log_bin=1; set sql_log_off=1; set sql_log_update=1; Warnings: -Note 1296 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. +Note 1297 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. set sql_low_priority_updates=1; set sql_max_join_size=200; select @@sql_max_join_size,@@max_join_size; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 9ac44c8ba0a..5c977983087 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -22,7 +22,7 @@ select -(0-3),round(-(0-3)), round(9999999999999999999); # create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; select * from t1 where a=18446744073709551615; # select * from t1 where a='18446744073709551615'; @@ -54,3 +54,17 @@ insert into t1 values (null,1); select * from t1; select * from t1 limit 9999999999; drop table t1; + +# +# Item_uint::save_to_field() +# BUG#1845 +# This can't be fixed in MySQL 4.0 without loosing precisions for bigints +# + +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); +insert into t1 values ('10000000000000000000'); +select * from t1; +drop table t1; + diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 9a1b6b6bbfe..9377c6c4aef 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -57,7 +57,8 @@ CREATE TABLE t1 SELECT CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, - CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 + CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, + CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index e6cc98d47df..9d2bb0d139a 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -21,6 +21,7 @@ while ($1) INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); dec $1; } +set @@read_buffer_size=2*1024*1024; CREATE TABLE t2 SELECT * FROM t1; INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; @@ -53,3 +54,5 @@ SELECT COUNT(*) FROM t1; SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; --enable_result_log DROP TABLE t1; + +set @@read_buffer_size=default; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 0c1280751bc..dc4d2701bee 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -4,6 +4,7 @@ --disable_warnings drop table if exists t1,t2,t3; +drop database if exists test_$1; --enable_warnings create table t1 (b char(0)); @@ -57,6 +58,7 @@ select 1ea10.1a20,1e+ 1e+10 from 1ea10; drop table 1ea10; create table t1 (t1.index int); drop table t1; +# Test that we get warning for this drop database if exists test_$1; create database test_$1; create table test_$1.$test1 (a$1 int, $b int, c$ int); @@ -245,7 +247,6 @@ drop table t3; show create table t3; select * from t3; drop table t2, t3; -drop database if exists test_$1; create database test_$1; create table test_$1.t3 like t1; create temporary table t3 like test_$1.t3; @@ -326,9 +327,6 @@ drop table t1, t2; # Bug #1209 # ---disable_warnings -drop database if exists test_$1; ---enable_warnings create database test_$1; use test_$1; select database(); diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index d9219d3ac2e..7b88c0ecf72 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -200,3 +200,12 @@ select get_format(DATE, 'TEST') as a; select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA')); explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001"); + +# +# Test of date_format() +# + +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +drop table t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index ee50ffda476..caf673d95c1 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -132,3 +132,9 @@ insert into t1 VALUES(1,1,1), (2,2,1); select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; drop table t1; + +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +drop table t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index a0292740c8d..38c09682bac 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -81,6 +81,17 @@ select * from t1; drop table t1; # +# why to scan strings for trunc* +# +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +drop table t1; + +# # Check bug reported by Matthias Urlichs # diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index 855649923c4..e3083ddc4e1 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -41,5 +41,7 @@ create table t2 (name varchar(255) not null default '', entity_id int(11) not nu insert into t2 (name, entity_id) values ('aberdeen town hall', 1), ('glasgow royal concert hall', 2), ('queen\'s hall, edinburgh', 3); select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen' in boolean mode) and dt = '2003-05-23 19:30:00'; select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; drop table t1,t2; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 314587feda6..26f7cbf22a0 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -3,7 +3,7 @@ # It would be nice to make this a replication test, but in 4.0 the # slave is always with --skip-innodb in the testsuite. I (Guilhem) however # did some tests manually on a slave; tables are replicated fine and -# Exec_master_log_pos advances as expected. +# Exec_Master_Log_Pos advances as expected. -- source include/have_innodb.inc diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 0be755ba7ad..5fa8f8a7651 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -86,3 +86,14 @@ INSERT INTO t1 (d) values (null),(null); select * from t1; drop table t1; +# +# Test to check elimination of IS NULL predicate for a non-nullable attribute +# (bug #1990) +# +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values + (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), + (7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +explain select * from t1 where a between 2 and 3; +explain select * from t1 where a between 2 and 3 or b is null; +drop table t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 702feedc3ce..ca4143fa1c9 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -365,3 +365,11 @@ SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; DROP TABLE t1; +# +# Bug #1945 - Crashing bug with bad User Variables in UPDATE ... ORDER BY ... +# +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; + diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test index 395a04615cb..0d6e851a153 100644 --- a/mysql-test/t/raid.test +++ b/mysql-test/t/raid.test @@ -9,6 +9,7 @@ enable_query_log; --disable_warnings DROP TABLE IF EXISTS t1,t2; +DROP DATABASE IF EXISTS test_$1; --enable_warnings # @@ -111,8 +112,8 @@ ALTER TABLE t1 DROP COLUMN x; ALTER TABLE t1 RENAME t2; select count(*) from t2; DROP TABLE t2; + /* variable rows */ -DROP TABLE IF EXISTS t2; CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c varchar(255) not null diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index a1d227459fd..bdbbce5cdfb 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -226,7 +226,18 @@ INSERT INTO t1 VALUES # we expect that optimizer will choose index on A EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +DROP TABLE t1; + +# +# Test error with +# +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +# -- First reports 3; second reports 6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); DROP TABLE t1; # test for a bug with in() and unique key diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test new file mode 100644 index 00000000000..e6452b5b619 --- /dev/null +++ b/mysql-test/t/rpl_change_master.test @@ -0,0 +1,30 @@ +source include/master-slave.inc; + +connection slave; +select get_lock("a",5); +connection master; +create table t1(n int); +insert into t1 values(1+get_lock("a",15)*0); +insert into t1 values(2); +save_master_pos; +connection slave; +--real_sleep 3; # can't sync_with_master as we should be blocked +stop slave; +select * from t1; +--replace_result $MASTER_MYPORT MASTER_MYPORT +--replace_column 1 # 33 # +show slave status; +change master to master_user='root'; +--replace_result $MASTER_MYPORT MASTER_MYPORT +--replace_column 1 # 33 # +show slave status; +# Will restart from after the values(2), which is bug +select release_lock("a"); +start slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test index ec3a9259e32..678dae13889 100644 --- a/mysql-test/t/rpl_loaddata_rule_m.test +++ b/mysql-test/t/rpl_loaddata_rule_m.test @@ -9,7 +9,7 @@ drop database if exists mysqltest; --enable_warnings connection slave; -reset master; +stop slave; # don't need slave for this test # Test logging on master diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test index 99f0a9fdde6..a28aed52ec8 100644 --- a/mysql-test/t/rpl_max_relay_size.test +++ b/mysql-test/t/rpl_max_relay_size.test @@ -76,7 +76,7 @@ sync_with_master; --replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT --replace_column 1 # 33 # show slave status; -# one more rotation, to be sure Relay_log_space is correctly updated +# one more rotation, to be sure Relay_Log_Space is correctly updated flush logs; connection master; drop table t1; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 78213c6a750..7560d56af1c 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -101,7 +101,8 @@ show master logs; # we just tests if synonyms are accepted purge binary logs to 'master-bin.000002'; show binary logs; ---sleep 1; +# sleeping 10 seconds or more would make the slave believe connection is down +--real_sleep 1; purge master logs before now(); show binary logs; insert into t2 values (65); diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index 8b20a493826..9bc4ea4e7b1 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -38,7 +38,7 @@ start slave until master_log_file='master-no-such-bin.000001', master_log_pos=29 select * from t1; sleep 2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; # try replicate all until second insert to t2; @@ -46,7 +46,7 @@ start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; sleep 2; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; # clean up @@ -62,7 +62,7 @@ start slave until master_log_file='master-bin.000001', master_log_pos=561; sleep 2; # here the sql slave thread should be stopped --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 33 # +--replace_column 1 # 9 # 23 # 33 # show slave status; #testing various error conditions diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 132a6b086c6..50a8b8c8768 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -32,18 +32,18 @@ create function func1() returns int return 42| # Can't create recursively ---error 1284 +--error 1285 create procedure foo() create procedure bar() set @x=3| ---error 1284 +--error 1285 create procedure foo() create function bar() returns double return 2.3| # Already exists ---error 1285 +--error 1286 create procedure proc1() set @x = 42| ---error 1285 +--error 1286 create function func1() returns int return 42| @@ -51,39 +51,39 @@ drop procedure proc1| drop function func1| # Does not exist ---error 1286 +--error 1287 alter procedure foo| ---error 1286 +--error 1287 alter function foo| ---error 1286 +--error 1287 drop procedure foo| ---error 1286 +--error 1287 drop function foo| ---error 1286 +--error 1287 call foo()| drop procedure if exists foo| ---error 1286 +--error 1287 show create procedure foo| # LEAVE/ITERATE with no match ---error 1289 +--error 1290 create procedure foo() foo: loop leave bar; end loop| ---error 1289 +--error 1290 create procedure foo() foo: loop iterate bar; end loop| ---error 1289 +--error 1290 create procedure foo() foo: begin iterate foo; end| # Redefining label ---error 1290 +--error 1291 create procedure foo() foo: loop foo: loop @@ -92,7 +92,7 @@ foo: loop end loop foo| # End label mismatch ---error 1291 +--error 1292 create procedure foo() foo: loop set @x=2; @@ -113,17 +113,17 @@ begin select name from mysql.proc; select type from mysql.proc; end| ---error 1293 +--error 1294 call foo()| drop procedure foo| # RETURN in FUNCTION only ---error 1294 +--error 1295 create procedure foo() return 42| # Doesn't allow queries in FUNCTIONs (for now :-( ) ---error 1295 +--error 1296 create function foo() returns int begin declare x int; @@ -137,19 +137,19 @@ create procedure p(x int) create function f(x int) returns int return x+42| ---error 1299 +--error 1300 call p()| ---error 1299 +--error 1300 call p(1, 2)| ---error 1299 +--error 1300 select f()| ---error 1299 +--error 1300 select f(1, 2)| drop procedure p| drop function f| ---error 1300 +--error 1301 create procedure p(val int, out res int) begin declare x int default 0; @@ -163,7 +163,7 @@ begin end if; end| ---error 1300 +--error 1301 create procedure p(val int, out res int) begin declare x int default 0; @@ -178,7 +178,7 @@ begin end if; end| ---error 1301 +--error 1302 create function f(val int) returns int begin declare x int; @@ -196,12 +196,12 @@ begin end if; end| ---error 1302 +--error 1303 select f(10)| drop function f| ---error 1303 +--error 1304 create procedure p() begin declare c cursor for insert into test.t1 values ("foo", 42); @@ -210,7 +210,7 @@ begin close c; end| ---error 1304 +--error 1305 create procedure p() begin declare x int; @@ -220,7 +220,7 @@ begin close c; end| ---error 1305 +--error 1306 create procedure p() begin declare c cursor for select * from test.t; @@ -242,7 +242,7 @@ begin open c; close c; end| ---error 1306 +--error 1307 call p()| drop procedure p| @@ -254,11 +254,11 @@ begin close c; close c; end| ---error 1307 +--error 1308 call p()| drop procedure p| ---error 1286 +--error 1287 alter procedure bar3 sql security invoker| --error 1059 alter procedure bar3 name @@ -272,7 +272,7 @@ drop table if exists t1| create table t1 (val int, x float)| insert into t1 values (42, 3.1), (19, 1.2)| ---error 1308 +--error 1309 create procedure p() begin declare c cursor for select * from t1; @@ -292,7 +292,7 @@ begin fetch c into x; close c; end| ---error 1309 +--error 1310 call p()| drop procedure p| @@ -307,34 +307,34 @@ begin fetch c into x, y, z; close c; end| ---error 1309 +--error 1310 call p()| drop procedure p| ---error 1311 +--error 1312 create procedure p(in x int, x char(10)) begin end| ---error 1311 +--error 1312 create function p(x int, x char(10)) begin end| ---error 1312 +--error 1313 create procedure p() begin declare x float; declare x int; end| ---error 1313 +--error 1314 create procedure p() begin declare c condition for 1064; declare c condition for 1065; end| ---error 1314 +--error 1315 create procedure p() begin declare c cursor for select * from t1; @@ -358,7 +358,7 @@ drop procedure bug1965| # # BUG#1966 # ---error 1308 +--error 1309 select 1 into a| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index d8530b5130b..25657bd79e2 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -734,7 +734,7 @@ create procedure hndlr4() begin declare x int default 0; declare val int; # No default - declare continue handler for 1310 set x=1; + declare continue handler for sqlstate '02000' set x=1; select data into val from test.t3 where id='z' limit 1; # No hits @@ -753,7 +753,7 @@ drop procedure hndlr4| create procedure cur1() begin declare done int default 0; - declare continue handler for 1310 set done = 1; + declare continue handler for sqlstate '02000' set done = 1; declare c cursor for select * from test.t2; declare a char(16); declare b int; @@ -782,7 +782,7 @@ create table t3 ( s char(16), i int )| create procedure cur2() begin declare done int default 0; - declare continue handler for 1310 set done = 1; + declare continue handler for sqlstate '02000' set done = 1; declare c1 cursor for select id,data from test.t1; declare c2 cursor for select i from test.t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 3126c5d55af..f0df84a6a93 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -67,7 +67,7 @@ insert into t4 values (4,8),(3,8),(5,9); select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1; select (select a from t1 where t1.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.b), a from t2; -select (select a from t1), a from t2; +select (select a from t1), a, (select 1 union select 2 limit 1) from t2; select (select a from t3), a from t2; select * from t2 where t2.a=(select a from t1); insert into t3 values (6),(7),(3); diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 4be0cd0c6a2..f618c342936 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -65,7 +65,7 @@ drop table t1; # disable_query_log; ---error 1279,1279 +--error 1103,1103 create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam data directory="tmp"; # Check that we cannot link over a table from another database. @@ -75,7 +75,7 @@ create database mysqltest; --error 1,1 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="/this-dir-does-not-exist"; ---error 1279,1279 +--error 1103,1103 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="not-hard-path"; --error 1,1 diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 3cfdc14b0b8..e302378e117 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -302,3 +302,137 @@ insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd' insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0; drop table t1, t2; + +# +# types conversions +# +create table t1 SELECT "a" as a UNION select "aa" as a; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT 12 as a UNION select "aa" as a; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT 12 as a UNION select 12.2 as a; +select * from t1; +show create table t1; +drop table t1; + +create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); + +create table t1 SELECT it2 from t2 UNION select it1 from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT it2 from t2 UNION select i from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT i from t2 UNION select f from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select d from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT ib from t2 UNION select f from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT ib from t2 UNION select d from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select y from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT f from t2 UNION select da from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT y from t2 UNION select da from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT y from t2 UNION select dt from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT da from t2 UNION select dt from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select sc from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select sv from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT sc from t2 UNION select sv from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT dt from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT sv from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT sv from t2 UNION select tx from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT b from t2 UNION select tx from t2; +select * from t1; +show create table t1; +drop table t1,t2; +create table t1 (d decimal(10,1)); +create table t2 (d decimal(10,9)); +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +select * from t3; +show create table t3; +drop table t1,t2,t3; +create table t1 select 1 union select -1; +select * from t1; +show create table t1; +drop table t1; +-- error 1266 +create table t1 select _latin1"test" union select _latin2"testt" ; +create table t1 select _latin2"test" union select _latin2"testt" ; +show create table t1; +drop table t1; + +# +# conversion memory->disk table +# +# +# conversion memory->disk table +# +create table t1 (s char(200)); +insert into t1 values (repeat("1",200)); +create table t2 select * from t1; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +set local tmp_table_size=1024; +select count(*) from (select * from t1 union all select * from t2 order by 1) b; +select count(*) from t1; +select count(*) from t2; +drop table t1,t2; +set local tmp_table_size=default; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 8fe48641fed..39742d20c7c 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -60,3 +60,14 @@ drop table t1; # just for fun :) select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; + +# +# bug#1739 +# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it +# +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +drop table t1; + diff --git a/mysys/default.c b/mysys/default.c index b1d9e40a1c2..3a751eb4e29 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -251,6 +251,7 @@ int load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); exit(1); + return 0; /* Keep compiler happy */ } diff --git a/mysys/hash.c b/mysys/hash.c index 516fa171d7c..4ef8847363f 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -29,6 +29,11 @@ #define HIGHFIND 4 #define HIGHUSED 8 +typedef struct st_hash_info { + uint next; /* index to next key */ + byte *data; /* data for current entry */ +} HASH_LINK; + static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); @@ -36,7 +41,7 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); static uint calc_hash(HASH *hash,const byte *key,uint length) { ulong nr1=1, nr2=4; - hash->charset->coll->hash_sort(hash->charset,key,length,&nr1,&nr2); + hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2); return nr1; } @@ -211,7 +216,8 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) uint rec_keylength; byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); return (length && length != rec_keylength) || - my_strnncoll(hash->charset, rec_key, rec_keylength, key, length); + my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength, + (uchar*) key, length); } diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index d96d4c0db3c..b5c80d9482f 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -110,11 +110,29 @@ init_functions(IO_CACHE* info, enum cache_type type) } } - /* - ** if cachesize == 0 then use default cachesize (from s-file) - ** if file == -1 then real_open_cached_file() will be called. - ** returns 0 if ok - */ + +/* + Initialize an IO_CACHE object + + SYNOPSOS + init_io_cache() + info cache handler to initialize + file File that should be associated to to the handler + If == -1 then real_open_cached_file() + will be called when it's time to open file. + cachesize Size of buffer to allocate for read/write + If == 0 then use my_default_record_cache_size + type Type of cache + seek_offset Where cache should start reading/writing + use_async_io Set to 1 of we should use async_io (if avaiable) + cache_myflags Bitmap of differnt flags + MY_WME | MY_FAE | MY_NABP | MY_FNABP | + MY_DONT_CHECK_FILESIZE + + RETURN + 0 ok + # error +*/ int init_io_cache(IO_CACHE *info, File file, uint cachesize, enum cache_type type, my_off_t seek_offset, @@ -127,7 +145,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, (ulong) info, (int) type, (ulong) seek_offset)); info->file= file; - info->type=type; + info->type= 0; /* Don't set it until mutex are created */ info->pos_in_file= seek_offset; info->pre_close = info->pre_read = info->post_read = 0; info->arg = 0; @@ -138,9 +156,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, info->share=0; #endif - if (!cachesize) - if (! (cachesize= my_default_record_cache_size)) - DBUG_RETURN(1); /* No cache requested */ + if (!cachesize && !(cachesize= my_default_record_cache_size)) + DBUG_RETURN(1); /* No cache requested */ min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2; if (type == READ_CACHE || type == SEQ_READ_APPEND) { /* Assume file isn't growing */ @@ -201,6 +218,13 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, pthread_mutex_init(&info->append_buffer_lock,MY_MUTEX_INIT_FAST); #endif } +#if defined(SAFE_MUTEX) && defined(THREAD) + else + { + /* Clear mutex so that safe_mutex will notice that it's not initialized */ + bzero((char*) &info->append_buffer_lock, sizeof(info)); + } +#endif if (type == WRITE_CACHE) info->write_end= @@ -211,6 +235,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, /* End_of_file may be changed by user later */ info->end_of_file= end_of_file; info->error=0; + info->type= type; init_functions(info,type); #ifdef HAVE_AIOWAIT if (use_async_io && ! my_disable_async_io) @@ -1142,6 +1167,22 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) DBUG_RETURN(0); } +/* + Free an IO_CACHE object + + SYNOPSOS + end_io_cache() + info IO_CACHE Handle to free + + NOTES + It's currently safe to call this if one has called io_cache_init() + on the 'info' object, even if io_cache_init() failed. + This function is also safe to call twice with the same handle. + + RETURN + 0 ok + # Error +*/ int end_io_cache(IO_CACHE *info) { @@ -1164,7 +1205,10 @@ int end_io_cache(IO_CACHE *info) #endif if ((pre_close=info->pre_close)) + { (*pre_close)(info); + info->pre_close= 0; + } if (info->alloced_buffer) { info->alloced_buffer=0; diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index a45d967665a..f9b11e97f47 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -15,14 +15,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - These functions are to handle keyblock cacheing - for NISAM, MISAM and PISAM databases. + These functions handle keyblock cacheing for ISAM and MyISAM tables. + One cache can handle many files. It must contain buffers of the same blocksize. init_key_cache() should be used to init cache handler. */ #include "mysys_priv.h" +#include <keycache.h> #include "my_static.h" #include <m_string.h> #include <errno.h> @@ -85,28 +86,22 @@ typedef pthread_cond_t KEYCACHE_CONDVAR; -/* info about requests in a waiting queue */ -typedef struct st_keycache_wqueue -{ - struct st_my_thread_var *last_thread; /* circular list of waiting threads */ -} KEYCACHE_WQUEUE; - /* descriptor of the page in the key cache block buffer */ -typedef struct st_keycache_page +struct st_keycache_page { int file; /* file to which the page belongs to */ my_off_t filepos; /* position of the page in the file */ -} KEYCACHE_PAGE; +}; /* element in the chain of a hash table bucket */ -typedef struct st_hash_link +struct st_hash_link { struct st_hash_link *next, **prev; /* to connect links in the same bucket */ struct st_block_link *block; /* reference to the block for the page: */ File file; /* from such a file */ my_off_t diskpos; /* with such an offset */ uint requests; /* number of requests for the page */ -} HASH_LINK; /* offset is always alighed for key_cache_block_size */ +}; /* simple states of a block */ #define BLOCK_ERROR 1 /* an error occured when performing disk i/o */ @@ -122,7 +117,7 @@ typedef struct st_hash_link #define PAGE_WAIT_TO_BE_READ 2 /* key cache block */ -typedef struct st_block_link +struct st_block_link { struct st_block_link *next_used, **prev_used; /* to connect links in the LRU chain (ring) */ @@ -138,52 +133,19 @@ typedef struct st_block_link uint hits_left; /* number of hits left until promotion */ ulonglong last_hit_time; /* timestamp of the last hit */ KEYCACHE_CONDVAR *condvar; /* condition variable for 'no readers' event */ -} BLOCK_LINK; - -KEY_CACHE_VAR dflt_key_cache_var= -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -KEY_CACHE_HANDLE *dflt_keycache= &dflt_key_cache_var.cache; -#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ +KEY_CACHE dflt_key_cache_var; +KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; + #define FLUSH_CACHE 2000 /* sort this many blocks at once */ -typedef struct st_key_cache -{ - KEY_CACHE_VAR *env; /* pointer to key cache variables (if any) */ - my_bool key_cache_inited; - uint key_cache_shift; - ulong key_cache_mem_size; /* specified size of the cache memory */ - uint key_cache_block_size; /* size of the page buffer of a cache block */ - ulong min_warm_blocks; /* min number of warm blocks; */ - ulong age_threshold; /* age threshold for hot blocks */ - ulonglong keycache_time; /* total number of block link operations */ - uint hash_entries; /* max number of entries in the hash table */ - int hash_links; /* max number of hash links */ - int hash_links_used; /* number of hash links currently used */ - int disk_blocks; /* max number of blocks in the cache */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong warm_blocks; /* number of blocks in warm sub-chain */ -#if defined(KEYCACHE_DEBUG) - long blocks_available; /* number of blocks available in the LRU chain */ -#endif - HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ - HASH_LINK *hash_link_root; /* memory for hash table links */ - HASH_LINK *free_hash_list; /* list of free hash links */ - BLOCK_LINK *block_root; /* memory for block links */ - byte HUGE_PTR *block_mem; /* memory for block buffers */ - BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ - BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ - pthread_mutex_t cache_lock; /* to lock access to the cache structure */ - KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ - KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ - BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ - BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ -} KEY_CACHE; - -static int flush_all_key_blocks(KEY_CACHE_HANDLE keycache); +static int flush_all_key_blocks(KEY_CACHE *keycache); +static void link_into_queue(KEYCACHE_WQUEUE *wqueue, + struct st_my_thread_var *thread); +static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, + struct st_my_thread_var *thread); +static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block); static void test_key_cache(KEY_CACHE *keycache, const char *where, my_bool lock); @@ -202,10 +164,10 @@ static void test_key_cache(KEY_CACHE *keycache, static FILE *keycache_debug_log=NULL; static void keycache_debug_print _VARARGS((const char *fmt,...)); #define KEYCACHE_DEBUG_OPEN \ - keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") + if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") #define KEYCACHE_DEBUG_CLOSE \ - if (keycache_debug_log) fclose(keycache_debug_log) + if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; } #else #define KEYCACHE_DEBUG_OPEN #define KEYCACHE_DEBUG_CLOSE @@ -230,8 +192,8 @@ static long keycache_thread_id; KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id)) #define KEYCACHE_THREAD_TRACE_BEGIN(l) \ - { struct st_my_thread_var *thread_var =my_thread_var; \ - keycache_thread_id=my_thread_var->id; \ + { struct st_my_thread_var *thread_var= my_thread_var; \ + keycache_thread_id= my_thread_var->id; \ KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) } #define KEYCACHE_THREAD_TRACE_END(l) \ @@ -268,10 +230,10 @@ static int keycache_pthread_cond_broadcast(pthread_cond_t *cond); static uint next_power(uint value) { - uint old_value=1; + uint old_value= 1; while (value) { - old_value=value; + old_value= value; value&= value-1; } return (old_value << 1); @@ -282,77 +244,59 @@ static uint next_power(uint value) Initialize a key cache SYNOPSIS - init_ky_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the key cache - env ref to other parameters of the key cache, if any + init_key_cache() + keycache pointer to a key cache data structure + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the key cache + division_limit division limit (may be zero) + age_threshold age threshold (may be zero) RETURN VALUE number of blocks in the key cache, if successful, 0 - otherwise. NOTES. - If pkeycache points to an undefined handle (NULL), a new KEY_CACHE - data structure is created and a pointer to it is returned as a new - key cache handle, otherwise *pkeycache is considered as a reused - handle for a key cache with new blocks. + if keycache->key_cache_inited != 0 we assume that the key cache + is already initialized. This is for now used by myisamchk, but shouldn't + be something that a program should rely on! + It's assumed that no two threads call this function simultaneously referring to the same key cache handle. */ -int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR *env) +int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { uint blocks, hash_links, length; int error; - KEY_CACHE *keycache; DBUG_ENTER("init_key_cache"); DBUG_ASSERT(key_cache_block_size >= 512); - if (!(keycache= (KEY_CACHE *) *pkeycache) && - !(keycache= (KEY_CACHE *) my_malloc(sizeof(KEY_CACHE), - MYF(MY_ZEROFILL)))) - DBUG_RETURN(0); - - keycache->env= env; - KEYCACHE_DEBUG_OPEN; if (keycache->key_cache_inited && keycache->disk_blocks > 0) { DBUG_PRINT("warning",("key cache already in use")); DBUG_RETURN(0); } - if (env && ! keycache->key_cache_inited) - { - env->cache_w_requests= env->cache_r_requests= 0; - env->cache_read= env->cache_write=0; - } + keycache->global_cache_w_requests= keycache->global_cache_r_requests= 0; + keycache->global_cache_read= keycache->global_cache_write= 0; + keycache->disk_blocks= -1; if (! keycache->key_cache_inited) { keycache->key_cache_inited= 1; - keycache->disk_blocks= -1; + keycache->in_init= 0; pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); - keycache->key_cache_shift= my_bit_log2(key_cache_block_size); - keycache->key_cache_mem_size= use_mem; - keycache->key_cache_block_size= key_cache_block_size; - DBUG_PRINT("info", ("key_cache_block_size: %u", - key_cache_block_size)); + keycache->resize_queue.last_thread= NULL; } - /* - These are safety deallocations: actually we always call the - function after having called end_key_cache that deallocates - these memory itself. - */ - if (keycache->block_mem) - my_free_lock((gptr) keycache->block_mem, MYF(0)); - keycache->block_mem= NULL; - if (keycache->block_root) - my_free((gptr) keycache->block_root, MYF(0)); - keycache->block_root= NULL; + keycache->key_cache_mem_size= use_mem; + keycache->key_cache_block_size= key_cache_block_size; + keycache->key_cache_shift= my_bit_log2(key_cache_block_size); + DBUG_PRINT("info", ("key_cache_block_size: %u", + key_cache_block_size)); blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); @@ -412,48 +356,47 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, keycache->hash_links_used= 0; keycache->free_hash_list= NULL; keycache->blocks_used= keycache->blocks_changed= 0; - if (env) - env->blocks_used= env->blocks_changed= 0; -#if defined(KEYCACHE_DEBUG) - keycache->blocks_available=0; -#endif + + keycache->global_blocks_used= keycache->global_blocks_changed= 0; + keycache->blocks_available=0; /* For debugging */ + /* The LRU chain is empty after initialization */ keycache->used_last= NULL; keycache->used_ins= NULL; keycache->keycache_time= 0; keycache->warm_blocks= 0; - keycache->min_warm_blocks= (env && env->division_limit ? - blocks * env->division_limit / 100 + 1 : + keycache->min_warm_blocks= (division_limit ? + blocks * division_limit / 100 + 1 : blocks); - keycache->age_threshold= (env && env->age_threshold ? - blocks * env->age_threshold / 100 : + keycache->age_threshold= (age_threshold ? + blocks * age_threshold / 100 : blocks); + keycache->cnt_for_resize_op= 0; + keycache->resize_in_flush= 0; + keycache->can_be_used= 1; + keycache->waiting_for_hash_link.last_thread= NULL; keycache->waiting_for_block.last_thread= NULL; DBUG_PRINT("exit", - ("disk_blocks: %d block_root: %lx hash_entries: %d hash_root: %lx \ - hash_links: %d hash_link_root %lx", + ("disk_blocks: %d block_root: %lx hash_entries: %d\ + hash_root: %lx hash_links: %d hash_link_root %lx", keycache->disk_blocks, keycache->block_root, keycache->hash_entries, keycache->hash_root, keycache->hash_links, keycache->hash_link_root)); + bzero((gptr) keycache->changed_blocks, + sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); + bzero((gptr) keycache->file_blocks, + sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); } - bzero((gptr) keycache->changed_blocks, - sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); - bzero((gptr) keycache->file_blocks, - sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); - - if (env) - env->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; - *pkeycache= keycache; - DBUG_PRINT("exit", ("key_cache: %lx", keycache)); + + keycache->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; DBUG_RETURN((int) blocks); err: error= my_errno; keycache->disk_blocks= 0; - if (env) - env->blocks= 0; + keycache->blocks= 0; if (keycache->block_mem) { my_free_lock((gptr) keycache->block_mem, MYF(0)); @@ -465,6 +408,7 @@ err: keycache->block_root= NULL; } my_errno= error; + keycache->can_be_used= 0; DBUG_RETURN(0); } @@ -474,9 +418,11 @@ err: SYNOPSIS resize_key_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the new key cache + keycache pointer to a key cache data structure + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the new key cache + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE number of blocks in the key cache, if successful, @@ -484,45 +430,108 @@ err: NOTES. The function first compares the memory size and the block size parameters - with the corresponding parameters of the key cache referred by - *pkeycache. If they differ the function free the the memory allocated - for the old key cache blocks by calling the end_key_cache function - and then rebuilds the key cache with new blocks by calling init_key_cache. + with the key cache values. + + If they differ the function free the the memory allocated for the + old key cache blocks by calling the end_key_cache function and + then rebuilds the key cache with new blocks by calling + init_key_cache. + + The function starts the operation only when all other threads + performing operations with the key cache let her to proceed + (when cnt_for_resize=0). */ -int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem) +int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { int blocks; - KEY_CACHE *keycache= *pkeycache; + struct st_my_thread_var *thread; + KEYCACHE_WQUEUE *wqueue; DBUG_ENTER("resize_key_cache"); - if (key_cache_block_size == keycache->key_cache_block_size && - use_mem == keycache->key_cache_mem_size) - return keycache->disk_blocks; + if (!keycache->key_cache_inited) + DBUG_RETURN(keycache->disk_blocks); + + if(key_cache_block_size == keycache->key_cache_block_size && + use_mem == keycache->key_cache_mem_size) + { + change_key_cache_param(keycache, division_limit, age_threshold); + DBUG_RETURN(keycache->disk_blocks); + } keycache_pthread_mutex_lock(&keycache->cache_lock); + + wqueue= &keycache->resize_queue; + thread= my_thread_var; + link_into_queue(wqueue, thread); + + while (wqueue->last_thread->next != thread) + { + keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); + } + + keycache->resize_in_flush= 1; if (flush_all_key_blocks(keycache)) { /* TODO: if this happens, we should write a warning in the log file ! */ - keycache_pthread_mutex_unlock(&keycache->cache_lock); - return 0; + keycache->resize_in_flush= 0; + blocks= 0; + keycache->can_be_used= 0; + goto finish; } + keycache->resize_in_flush= 0; + keycache->can_be_used= 0; + while (keycache->cnt_for_resize_op) + { + keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); + } + + end_key_cache(keycache, 0); /* Don't free mutex */ + /* The following will work even if use_mem is 0 */ + blocks= init_key_cache(keycache, key_cache_block_size, use_mem, + division_limit, age_threshold); + +finish: + unlink_from_queue(wqueue, thread); + /* Signal for the next resize request to proceeed if any */ + if (wqueue->last_thread) + keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); keycache_pthread_mutex_unlock(&keycache->cache_lock); - end_key_cache(keycache, 0); - /* the following will work even if memory is 0 */ - blocks= init_key_cache(pkeycache, key_cache_block_size, use_mem, - keycache->env); return blocks; } /* + Increment counter blocking resize key cache operation +*/ +static inline void inc_counter_for_resize_op(KEY_CACHE *keycache) +{ + keycache->cnt_for_resize_op++; +} + + +/* + Decrement counter blocking resize key cache operation; + Signal the operation to proceed when counter becomes equal zero +*/ +static inline void dec_counter_for_resize_op(KEY_CACHE *keycache) +{ + struct st_my_thread_var *last_thread; + if (!--keycache->cnt_for_resize_op && + (last_thread= keycache->resize_queue.last_thread)) + keycache_pthread_cond_signal(&last_thread->next->suspend); +} + +/* Change the key cache parameters SYNOPSIS change_key_cache_param() - keycache the key cache handle + keycache pointer to a key cache data structure + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE none @@ -530,24 +539,22 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, NOTES. Presently the function resets the key cache parameters concerning midpoint insertion strategy - division_limit and - age_threshold. It corresponding values are passed through - the keycache->env structure. + age_threshold. */ -void change_key_cache_param(KEY_CACHE_HANDLE keycache) +void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold) { - KEY_CACHE_VAR *env= keycache->env; DBUG_ENTER("change_key_cache_param"); - if (env) - { - if (env->division_limit) - keycache->min_warm_blocks= (keycache->disk_blocks * - env->division_limit / 100 + 1); - if (env->age_threshold) - keycache->age_threshold= (keycache->disk_blocks * - env->age_threshold / 100); - } + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (division_limit) + keycache->min_warm_blocks= (keycache->disk_blocks * + division_limit / 100 + 1); + if (age_threshold) + keycache->age_threshold= (keycache->disk_blocks * + age_threshold / 100); + keycache_pthread_mutex_unlock(&keycache->cache_lock); DBUG_VOID_RETURN; } @@ -557,26 +564,21 @@ void change_key_cache_param(KEY_CACHE_HANDLE keycache) SYNOPSIS end_key_cache() - pkeycache in/out pointer to the key cache handle - cleanup <-> the key cache data structure is freed as well + keycache key cache handle + cleanup Complete free (Free also mutex for key cache) RETURN VALUE none - - NOTES. - If the cleanup parameter is TRUE the data structure with all associated - elements are freed completely - Otherwise only memory used by the key cache blocks is freed. */ -void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup) +void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { - KEY_CACHE_VAR *env; DBUG_ENTER("end_key_cache"); DBUG_PRINT("enter", ("key_cache: %lx", keycache)); - if (!keycache) + if (!keycache->key_cache_inited) DBUG_VOID_RETURN; + if (keycache->disk_blocks > 0) { if (keycache->block_mem) @@ -587,22 +589,22 @@ void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup) keycache->block_root= NULL; } keycache->disk_blocks= -1; + /* Reset blocks_changed to be safe if flush_all_key_blocks is called */ + keycache->blocks_changed= 0; } - KEYCACHE_DEBUG_CLOSE; - keycache->key_cache_inited= 0; - if ((env= keycache->env)) - { - DBUG_PRINT("status", - ("used: %d changed: %d w_requests: %ld \ - writes: %ld r_requests: %ld reads: %ld", - env->blocks_used, env->blocks_changed, - env->cache_w_requests, env->cache_write, - env->cache_r_requests, env->cache_read)); - } + + DBUG_PRINT("status", + ("used: %d changed: %d w_requests: %ld \ +writes: %ld r_requests: %ld reads: %ld", + keycache->global_blocks_used, keycache->global_blocks_changed, + keycache->global_cache_w_requests, keycache->global_cache_write, + keycache->global_cache_r_requests, keycache->global_cache_read)); + if (cleanup) { pthread_mutex_destroy(&keycache->cache_lock); - my_free((gptr) keycache, MYF(0)); + keycache->key_cache_inited= 0; + KEYCACHE_DEBUG_CLOSE; } DBUG_VOID_RETURN; } /* end_key_cache */ @@ -730,8 +732,8 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue, static void release_queue(KEYCACHE_WQUEUE *wqueue) { - struct st_my_thread_var *last=wqueue->last_thread; - struct st_my_thread_var *next=last->next; + struct st_my_thread_var *last= wqueue->last_thread; + struct st_my_thread_var *next= last->next; struct st_my_thread_var *thread; do { @@ -786,8 +788,7 @@ static void link_to_file_list(KEY_CACHE *keycache, { block->status&= ~BLOCK_CHANGED; keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; } } @@ -805,8 +806,7 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, &keycache->changed_blocks[FILE_HASH(block->hash_link->file)]); block->status|=BLOCK_CHANGED; keycache->blocks_changed++; - if (keycache->env) - keycache->env->blocks_changed++; + keycache->global_blocks_changed++; } @@ -1051,7 +1051,7 @@ static inline void remove_reader(BLOCK_LINK *block) static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block) { - struct st_my_thread_var *thread=my_thread_var; + struct st_my_thread_var *thread= my_thread_var; while (block->hash_link->requests) { block->condvar= &thread->suspend; @@ -1089,7 +1089,7 @@ static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) hash_link->block= NULL; if (keycache->waiting_for_hash_link.last_thread) { - /* Signal that A free hash link appeared */ + /* Signal that a free hash link has appeared */ struct st_my_thread_var *last_thread= keycache->waiting_for_hash_link.last_thread; struct st_my_thread_var *first_thread= last_thread->next; @@ -1275,9 +1275,57 @@ restart: block->hash_link == hash_link && (block->status & BLOCK_READ)) page_status= PAGE_READ; - if (page_status == PAGE_READ && (block->status & BLOCK_IN_SWITCH)) + if (wrmode && keycache->resize_in_flush) + { + /* This is a write request during the flush phase of a resize operation */ + + if (page_status != PAGE_READ) + { + /* We don't need the page in the cache: we are going to write on disk */ + hash_link->requests--; + unlink_hash(keycache, hash_link); + return 0; + } + if (!(block->status & BLOCK_IN_FLUSH)) + { + hash_link->requests--; + /* + Remove block to invalidate the page in the block buffer + as we are going to write directly on disk. + Although we have an exlusive lock for the updated key part + the control can be yieded by the current thread as we might + have unfinished readers of other key parts in the block + buffer. Still we are guaranteed not to have any readers + of the key part we are writing into until the block is + removed from the cache as we set the BLOCL_REASSIGNED + flag (see the code below that handles reading requests). + */ + free_block(keycache, block); + return 0; + } + /* Wait intil the page is flushed on disk */ + hash_link->requests--; + { + struct st_my_thread_var *thread= my_thread_var; + add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); + do + { + keycache_pthread_cond_wait(&thread->suspend, + &keycache->cache_lock); + } + while(thread->next); + } + /* Invalidate page in the block if it has not been done yet */ + if (block->status) + free_block(keycache, block); + return 0; + } + + if (page_status == PAGE_READ && + (block->status & (BLOCK_IN_SWITCH | BLOCK_REASSIGNED))) { /* This is a request for a page to be removed from cache */ + KEYCACHE_DBUG_PRINT("find_key_block", ("request for old page in block %u",BLOCK_NUMBER(block))); /* @@ -1328,8 +1376,7 @@ restart: block->offset= keycache->key_cache_block_size; block->requests= 1; keycache->blocks_used++; - if (keycache->env) - keycache->env->blocks_used++; + keycache->global_blocks_used++; keycache->warm_blocks++; block->hits_left= init_hits_left; block->last_hit_time= 0; @@ -1342,10 +1389,11 @@ restart: else { /* There are no never used blocks, use a block from the LRU chain */ + /* - Wait until a new block is added to the LRU chain; - several threads might wait here for the same page, - all of them must get the same block + Wait until a new block is added to the LRU chain; + several threads might wait here for the same page, + all of them must get the same block */ if (! keycache->used_last) @@ -1401,8 +1449,7 @@ restart: block->hash_link->diskpos+ block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; } block->status|= BLOCK_REASSIGNED; @@ -1441,8 +1488,7 @@ restart: PAGE_READ : PAGE_WAIT_TO_BE_READ; } } - if (keycache->env) - keycache->env->cache_read++; + keycache->global_cache_read++; } else { @@ -1582,42 +1628,48 @@ static void read_block(KEY_CACHE *keycache, have to be a multiple of key_cache_block_size; */ -byte *key_cache_read(KEY_CACHE_HANDLE keycache, +byte *key_cache_read(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), int return_buffer __attribute__((unused))) { int error=0; + uint offset= 0; + byte *start= buff; DBUG_ENTER("key_cache_read"); DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file, (ulong) filepos, length)); - if (keycache && keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); - byte *start= buff; uint read_length; uint status; int page_st; -#ifndef THREAD - if (block_length > keycache->key_cache_block_size || offset) - return_buffer=0; -#endif - /* Read data in key_cache_block_size increments */ - filepos-= offset; do { + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (!keycache->can_be_used) + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + filepos-= offset; +#ifndef THREAD + if (block_length > keycache->key_cache_block_size || offset) + return_buffer=0; +#endif + + inc_counter_for_resize_op(keycache); + keycache->global_cache_r_requests++; block=find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { @@ -1667,35 +1719,33 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, */ unreg_request(keycache, block, 1); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); if (status & BLOCK_ERROR) DBUG_RETURN((byte *) 0); #ifndef THREAD + /* This is only true if we where able to read everything in one block */ if (return_buffer) - return (block->buffer); + return (block->buffer); #endif - buff+= read_length; filepos+= read_length; - offset= 0; } while ((length-= read_length)); DBUG_RETURN(start); } - /* Key cache is not used */ - if (keycache && keycache->env) - { - statistic_increment(keycache->env->cache_r_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_read, - &keycache->cache_lock); - } - if (my_pread(file, (byte*) buff, length, filepos, MYF(MY_NABP))) +no_key_cache: /* Key cache is not used */ + + /* We can't use mutex here as the key cache may not be initialized */ + keycache->global_cache_r_requests++; + keycache->global_cache_read++; + if (my_pread(file, (byte*) buff, length, filepos+offset, MYF(MY_NABP))) error= 1; - DBUG_RETURN(error? (byte*) 0 : buff); + DBUG_RETURN(error ? (byte*) 0 : start); } @@ -1703,20 +1753,23 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, Insert a block of file data from a buffer into key cache SYNOPSIS - key_cache_insert() - keycache pointer to a key cache data structure - file handler for the file to insert data from - filepos position of the block of data in the file to insert - level determines the weight of the data - buff buffer to read data from - length length of the data in the buffer + keycache pointer to a key cache data structure + file handler for the file to insert data from + filepos position of the block of data in the file to insert + level determines the weight of the data + buff buffer to read data from + length length of the data in the buffer + + NOTES + This is used by MyISAM to move all blocks from a index file to the key + cache RETURN VALUE 0 if a success, 1 - otherwise. */ -int key_cache_insert(KEY_CACHE_HANDLE keycache, +int key_cache_insert(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length) { @@ -1724,24 +1777,32 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file,(ulong) filepos, length)); - if (keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); uint read_length; int page_st; + int error; - /* Read data into key cache from buff in key_cache_block_size increments */ - filepos-= offset; do { + uint offset; + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (!keycache->can_be_used) + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + DBUG_RETURN(0); + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Read data into key cache from buff in key_cache_block_size incr. */ + filepos-= offset; + + inc_counter_for_resize_op(keycache); + keycache->global_cache_r_requests++; block= find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { @@ -1770,14 +1831,17 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, */ unreg_request(keycache, block, 1); + error= (block->status & BLOCK_ERROR); + + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (block->status & BLOCK_ERROR) + if (error) DBUG_RETURN(1); buff+= read_length; filepos+= read_length; - offset=0; } while ((length-= read_length)); } @@ -1812,7 +1876,7 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, have to be a multiple of key_cache_block_size; */ -int key_cache_write(KEY_CACHE_HANDLE keycache, +int key_cache_write(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), @@ -1829,9 +1893,7 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, if (!dont_write) { /* Force writing from buff into disk */ - if (keycache && keycache->env) - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); + keycache->global_cache_write++; if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL))) DBUG_RETURN(1); } @@ -1841,24 +1903,47 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, test_key_cache(keycache, "start of key_cache_write", 1);); #endif - if (keycache && keycache->disk_blocks > 0) + if (keycache->can_be_used) { /* Key cache is used */ uint read_length; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); int page_st; - /* Write data in key_cache_block_size increments */ - filepos-= offset; do { + uint offset; + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (!keycache->can_be_used) + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } read_length= length > keycache->key_cache_block_size ? - keycache->key_cache_block_size : length; + keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_w_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Write data in key_cache_block_size increments */ + filepos-= offset; + + inc_counter_for_resize_op(keycache); + keycache->global_cache_w_requests++; block= find_key_block(keycache, file, filepos, level, 1, &page_st); + if (!block) + { + /* It happens only for requests submitted during resize operation */ + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); + if (dont_write) + { + keycache->global_cache_w_requests++; + keycache->global_cache_write++; + if (my_pwrite(file, (byte*) buff, length, filepos, + MYF(MY_NABP | MY_WAIT_IF_FULL))) + error=1; + } + goto next_block; + } + if (block->status != BLOCK_ERROR && page_st != PAGE_READ && (offset || read_length < keycache->key_cache_block_size)) read_block(keycache, block, @@ -1900,32 +1985,31 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, break; } - keycache_pthread_mutex_unlock(&keycache->cache_lock); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); + + next_block: buff+= read_length; filepos+= read_length; offset= 0; } while ((length-= read_length)); + goto end; } - else + +no_key_cache: + /* Key cache is not used */ + if (dont_write) { - /* Key cache is not used */ - if (dont_write) - { - if (keycache && keycache->env) - { - statistic_increment(keycache->env->cache_w_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); - } - if (my_pwrite(file, (byte*) buff, length, filepos, - MYF(MY_NABP | MY_WAIT_IF_FULL))) - error=1; - } + keycache->global_cache_w_requests++; + keycache->global_cache_write++; + if (my_pwrite(file, (byte*) buff, length, filepos, + MYF(MY_NABP | MY_WAIT_IF_FULL))) + error=1; } +end: #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("exec", test_key_cache(keycache, "end of key_cache_write", 1);); @@ -2007,20 +2091,24 @@ static int flush_cached_blocks(KEY_CACHE *keycache, block->hash_link->diskpos+ block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; if (error) { block->status|= BLOCK_ERROR; if (!last_errno) last_errno= errno ? errno : -1; } + /* + Let to proceed for possible waiting requests to write to the block page. + It might happen only during an operation to resize the key cache. + */ + if (block->wqueue[COND_FOR_SAVED].last_thread) + release_queue(&block->wqueue[COND_FOR_SAVED]); /* type will never be FLUSH_IGNORE_CHANGED here */ if (! (type == FLUSH_KEEP || type == FLUSH_FORCE_WRITE)) { keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } else @@ -2053,10 +2141,9 @@ static int flush_cached_blocks(KEY_CACHE *keycache, 1 error */ -static int flush_key_blocks_int(KEY_CACHE_HANDLE keycache, +static int flush_key_blocks_int(KEY_CACHE *keycache, File file, enum flush_type type) { - KEY_CACHE_VAR *env; BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; int last_errno= 0; DBUG_ENTER("flush_key_blocks_int"); @@ -2161,8 +2248,7 @@ restart: { /* It's a temporary file */ keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } } @@ -2227,9 +2313,6 @@ restart: } } - if (type == FLUSH_REMOVE && (env= keycache->env) && (env->action)) - (*env->action)((void *) env); - #ifndef DBUG_OFF DBUG_EXECUTE("check_keycache", test_key_cache(keycache, "end of flush_key_blocks", 0);); @@ -2257,18 +2340,20 @@ restart: 1 error */ -int flush_key_blocks(KEY_CACHE_HANDLE key_cache, +int flush_key_blocks(KEY_CACHE *keycache, File file, enum flush_type type) { int res; DBUG_ENTER("flush_key_blocks"); - DBUG_PRINT("enter", ("key_cache: %lx", key_cache)); + DBUG_PRINT("enter", ("keycache: %lx", keycache)); - if (!key_cache || !key_cache->disk_blocks) + if (keycache->disk_blocks <= 0) DBUG_RETURN(0); - keycache_pthread_mutex_lock(&key_cache->cache_lock); - res= flush_key_blocks_int(key_cache, file, type); - keycache_pthread_mutex_unlock(&key_cache->cache_lock); + keycache_pthread_mutex_lock(&keycache->cache_lock); + inc_counter_for_resize_op(keycache); + res= flush_key_blocks_int(keycache, file, type); + dec_counter_for_resize_op(keycache); + keycache_pthread_mutex_unlock(&keycache->cache_lock); DBUG_RETURN(res); } diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 1d770e17719..806f83dc7d8 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -23,6 +23,7 @@ */ #include "mysys_priv.h" +#include <keycache.h> #include <hash.h> #include <m_string.h> @@ -295,7 +296,7 @@ static SAFE_HASH key_cache_hash; my_bool multi_keycache_init(void) { - return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_keycache); + return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache); } @@ -321,11 +322,11 @@ void multi_keycache_free(void) key cache to use */ -KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length) +KEY_CACHE *multi_key_cache_search(byte *key, uint length) { if (!key_cache_hash.hash.records) - return dflt_keycache; - return (KEY_CACHE_HANDLE*) safe_hash_search(&key_cache_hash, key, length); + return dflt_key_cache; + return (KEY_CACHE*) safe_hash_search(&key_cache_hash, key, length); } @@ -346,14 +347,14 @@ KEY_CACHE_HANDLE *multi_key_cache_search(byte *key, uint length) my_bool multi_key_cache_set(const byte *key, uint length, - KEY_CACHE_HANDLE *key_cache) + KEY_CACHE *key_cache) { return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache); } -void multi_key_cache_change(KEY_CACHE_HANDLE *old_data, - KEY_CACHE_HANDLE *new_data) +void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data) { safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data); } diff --git a/mysys/mf_wcomp.c b/mysys/mf_wcomp.c index 62a5a02eaea..c2a103688f2 100644 --- a/mysys/mf_wcomp.c +++ b/mysys/mf_wcomp.c @@ -74,7 +74,7 @@ int wild_compare(register const char *str, register const char *wildstr, DBUG_RETURN(0); /* '*' as last char: OK */ if ((cmp= *wildstr) == wild_prefix && wildstr[1] && !str_is_pattern) cmp=wildstr[1]; - for(;;str++) + for (;;str++) { while (*str && *str != cmp) str++; @@ -83,7 +83,7 @@ int wild_compare(register const char *str, register const char *wildstr, if (wild_compare(str,wildstr,str_is_pattern) == 0) DBUG_RETURN (0); } - DBUG_RETURN(1); + /* We will never come here */ } } DBUG_RETURN (*str != 0); diff --git a/mysys/my_append.c b/mysys/my_append.c index dc5ed084bb3..c3549c670c3 100644 --- a/mysys/my_append.c +++ b/mysys/my_append.c @@ -18,10 +18,10 @@ #include "mysys_priv.h" #include <sys/stat.h> #include <m_string.h> -#if defined(HAVE_SYS_UTIME_H) -#include <sys/utime.h> -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include <utime.h> +#elif defined(HAVE_SYS_UTIME_H) +#include <sys/utime.h> #elif !defined(HPUX10) struct utimbuf { time_t actime; diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 84eda781a09..03f3feb54d3 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -18,10 +18,10 @@ #include "mysys_priv.h" #include <sys/stat.h> #include <m_string.h> -#if defined(HAVE_SYS_UTIME_H) -#include <sys/utime.h> -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include <utime.h> +#elif defined(HAVE_SYS_UTIME_H) +#include <sys/utime.h> #elif !defined(HPUX10) #include <time.h> struct utimbuf { diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 7fa8c9d4fa1..76f8f6bf852 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -83,7 +83,7 @@ int handle_options(int *argc, char ***argv, char *)) { uint opt_found, argvpos= 0, length, i; - my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, + my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; char **pos, **pos_end, *optend, *prev_found, *opt_str, key_name[FN_REFLEN]; @@ -104,7 +104,6 @@ int handle_options(int *argc, char ***argv, char *argument= 0; must_be_var= 0; set_maximum_value= 0; - special_used= 0; option_is_loose= 0; cur_arg++; /* skip '-' */ @@ -202,7 +201,6 @@ int handle_options(int *argc, char ***argv, /* We were called with a special prefix, we can reuse opt_found */ - special_used= 1; opt_str+= (special_opt_prefix_lengths[i] + 1); if (i == OPT_LOOSE) option_is_loose= 1; @@ -332,8 +330,6 @@ int handle_options(int *argc, char ***argv, else /* If argument differs from 0, enable option, else disable */ *((my_bool*) value)= (my_bool) atoi(optend) != 0; } - (*argc)--; - continue; } else if (optp->arg_type == REQUIRED_ARG && !optend) { diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 9ba03cd9526..9af360424b0 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -19,10 +19,10 @@ #include <my_dir.h> #include <m_string.h> #include "mysys_err.h" -#if defined(HAVE_SYS_UTIME_H) -#include <sys/utime.h> -#elif defined(HAVE_UTIME_H) +#if defined(HAVE_UTIME_H) #include <utime.h> +#elif defined(HAVE_SYS_UTIME_H) +#include <sys/utime.h> #elif !defined(HPUX10) struct utimbuf { time_t actime; diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 3abac2dc737..8ebe5be22e8 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -54,12 +54,15 @@ void safe_mutex_global_init(void) int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr __attribute__((unused)), - const char *file __attribute__((unused)), - uint line __attribute__((unused))) + const char *file, + uint line) { bzero((char*) mp,sizeof(*mp)); pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK); pthread_mutex_init(&mp->mutex,attr); + /* Mark that mutex is initialized */ + mp->file= file; + mp->line= line; #ifdef SAFE_MUTEX_DETECT_DESTROY /* @@ -70,7 +73,7 @@ int safe_mutex_init(safe_mutex_t *mp, { struct st_safe_mutex_info_t *info =mp->info; - info->init_file= (char *) file; + info->init_file= file; info->init_line= line; info->prev= NULL; info->next= NULL; @@ -92,6 +95,15 @@ int safe_mutex_init(safe_mutex_t *mp, int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) { int error; + if (!mp->file) + { + fprintf(stderr, + "safe_mutex: Trying to lock unitialized mutex at %s, line %d\n", + file, line); + fflush(stderr); + abort(); + } + pthread_mutex_lock(&mp->global); if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) { @@ -117,7 +129,7 @@ line %d more than 1 time\n", file,line); abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -204,7 +216,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -242,7 +254,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -252,6 +264,14 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) { int error=0; + if (!mp->file) + { + fprintf(stderr, + "safe_mutex: Trying to destroy unitialized mutex at %s, line %d\n", + file, line); + fflush(stderr); + abort(); + } if (mp->count != 0) { fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n", @@ -268,6 +288,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) if (pthread_mutex_destroy(&mp->mutex)) error=1; #endif + mp->file= 0; /* Mark destroyed */ #ifdef SAFE_MUTEX_DETECT_DESTROY if (mp->info) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index f93d88dc025..9510eef5469 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -87,7 +87,7 @@ done # Non platform-specific doc files: DOC_FILES=" \ - COPYING COPYING.LIB README LICENSE.doc \ + COPYING README LICENSE.doc \ Docs/mysqlbug.txt \ "; diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index e164f8c15dd..d83548d0061 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -282,7 +282,7 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING COPYING.LIB ChangeLog README \ +for i in COPYING ChangeLog README \ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ diff --git a/scripts/mysql_prepare_privilege_tables_for_5.sql b/scripts/mysql_prepare_privilege_tables_for_5.sql new file mode 100644 index 00000000000..a9b6d43aee0 --- /dev/null +++ b/scripts/mysql_prepare_privilege_tables_for_5.sql @@ -0,0 +1,53 @@ + +use mysql; + +-- +-- merging `host` table and `db` +-- + +UPDATE IGNORE host SET Host='%' WHERE Host=''; +DELETE FROM host WHERE Host=''; + +INSERT IGNORE INTO db (User, Host, Select_priv, Insert_priv, Update_priv, + Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, + Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv) + SELECT d.User, h.Host, + (d.Select_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Insert_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Update_priv = 'Y' || h.Update_priv = 'Y') + 1, + (d.Delete_priv = 'Y' || h.Delete_priv = 'Y') + 1, + (d.Create_priv = 'Y' || h.Create_priv = 'Y') + 1, + (d.Drop_priv = 'Y' || h.Drop_priv = 'Y') + 1, + (d.Grant_priv = 'Y' || h.Grant_priv = 'Y') + 1, + (d.References_priv = 'Y' || h.References_priv = 'Y') + 1, + (d.Index_priv = 'Y' || h.Index_priv = 'Y') + 1, + (d.Alter_priv = 'Y' || h.Alter_priv = 'Y') + 1, + (d.Create_tmp_table_priv = 'Y' || h.Create_tmp_table_priv = 'Y') + 1, + (d.Lock_tables_priv = 'Y' || h.Lock_tables_priv = 'Y') + 1 + FROM db d, host h WHERE d.Host = ''; + +UPDATE IGNORE db SET Host='%' WHERE Host = ''; +DELETE FROM db WHERE Host=''; + +TRUNCATE TABLE host; + +-- +-- Adding missing users to `user` table +-- +-- note that invalid password causes the user to be skipped during the +-- load of grand tables (at mysqld startup) thus three following inserts +-- do not affect anything + +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM db; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM tables_priv; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM columns_priv; + +SELECT DISTINCT +"There are user accounts with the username 'PUBLIC'. In the SQL-1999 +(or later) standard this name is reserved for PUBLIC role and can +not be used as a valid user name. Consider renaming these accounts before +upgrading to MySQL-5.0. +These accounts are:" x +FROM user WHERE user='PUBLIC'; +SELECT CONCAT(user,'@',host) FROM user WHERE user='PUBLIC'; + diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 699e74834e3..75ef63ecdd0 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -286,7 +286,7 @@ Release Notes: * --old_server: mysqlaccess will now use a full where clause when retrieving information from the MySQL-server. If you are connecting to an old server (before v3.21) - use the option --old_server. + then use the option --old_server. 2.03 : (1998-02-27) - bugfix: * in Host::MatchTemplate: incorrect match if host-field was left empty. diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 1ac5f29723b..d61551ffb3b 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -509,7 +509,7 @@ All benchmarks takes the following options: --socket='socket' If the database supports connecting through a Unix socket, - use this socket to connect + then use this socket to connect --regions This is a test specific option that is only used when debugging a test. diff --git a/sql-common/client.c b/sql-common/client.c index c6abfb0ba91..374cbb29112 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -55,12 +55,6 @@ my_bool net_flush(NET *net); #else /*EMBEDDED_LIBRARY*/ #define CLI_MYSQL_REAL_CONNECT mysql_real_connect #endif /*EMBEDDED_LIBRARY*/ - -#if !defined(MYSQL_SERVER) && (defined(__WIN__) || defined(_WIN32) || defined(_WIN64)) - -#include <winsock.h> -#include <odbcinst.h> -#endif /* !defined(MYSQL_SERVER) && (defined(__WIN__) ... */ #include <my_sys.h> #include <mysys_err.h> #include <m_string.h> @@ -634,7 +628,7 @@ void free_rows(MYSQL_DATA *cur) } } -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check) @@ -789,7 +783,7 @@ static const char *default_options[]= "connect-timeout", "local-infile", "disable-local-infile", "replication-probe", "enable-reads-from-master", "repl-parse-query", "ssl-cipher", "max-allowed-packet", "protocol", "shared-memory-base-name", - "multi-results", "multi-queries", + "multi-results", "multi-queries", "secure-auth", NullS }; @@ -997,6 +991,9 @@ void mysql_read_default_options(struct st_mysql_options *options, case 31: options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS; break; + case 32: /* secure-auth */ + options->secure_auth= TRUE; + break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); } @@ -1014,7 +1011,8 @@ void mysql_read_default_options(struct st_mysql_options *options, else the lengths are calculated from the offset between pointers. **************************************************************************/ -static void STDCALL cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) +static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, + unsigned int field_count) { ulong *prev_length; byte *start=0; @@ -1145,8 +1143,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* Read all rows (fields or data) from server */ -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields) +MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields) { uint field; ulong pkt_len; @@ -1240,7 +1238,8 @@ MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, { mysql->warning_count= uint2korr(cp+1); mysql->server_status= uint2korr(cp+3); - DBUG_PRINT("info",("warning_count: %ld", mysql->warning_count)); + DBUG_PRINT("info",("status: %u warning_count: %u", + mysql->server_status, mysql->warning_count)); } DBUG_PRINT("exit",("Got %d rows",result->rows)); DBUG_RETURN(result); @@ -1402,8 +1401,8 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) before calling mysql_real_connect ! */ -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql); -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql); +static my_bool cli_mysql_read_query_result(MYSQL *mysql); +static MYSQL_RES *cli_mysql_use_result(MYSQL *mysql); static MYSQL_METHODS client_methods= { @@ -1457,8 +1456,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, user ? user : "(Null)")); /* Don't give sigpipe errors if the client doesn't want them */ - mysql->methods= &client_methods; set_sigpipe(mysql); + mysql->methods= &client_methods; net->vio = 0; /* If something goes wrong */ mysql->client_flag=0; /* For handshake */ @@ -1478,7 +1477,11 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!host || !host[0]) host=mysql->options.host; if (!user || !user[0]) + { user=mysql->options.user; + if (!user) + user= ""; + } if (!passwd) { passwd=mysql->options.password; @@ -1486,6 +1489,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!passwd) passwd=getenv("MYSQL_PWD"); /* get it from environment */ #endif + if (!passwd) + passwd= ""; } if (!db || !db[0]) db=mysql->options.db; @@ -1747,6 +1752,14 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, else mysql->server_capabilities&= ~CLIENT_SECURE_CONNECTION; + if (mysql->options.secure_auth && passwd[0] && + !(mysql->server_capabilities & CLIENT_SECURE_CONNECTION)) + { + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error, ER(net->last_errno=CR_SECURE_AUTH)); + goto error; + } + charset_number= mysql->server_language; /* Set character set */ @@ -1798,8 +1811,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, } /* Save connection information */ - if (!user) user=""; - if (!passwd) passwd=""; if (!my_multi_malloc(MYF(0), &mysql->host_info, (uint) strlen(host_info)+1, &mysql->host, (uint) strlen(host)+1, @@ -2227,7 +2238,7 @@ void STDCALL mysql_close(MYSQL *mysql) DBUG_VOID_RETURN; } -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql) +static my_bool cli_mysql_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; @@ -2252,6 +2263,9 @@ get_info: { mysql->affected_rows= net_field_length_ll(&pos); mysql->insert_id= net_field_length_ll(&pos); + DBUG_PRINT("info",("affected_rows: %lu insert_id: %lu", + (ulong) mysql->affected_rows, + (ulong) mysql->insert_id)); if (protocol_41(mysql)) { mysql->server_status=uint2korr(pos); pos+=2; @@ -2259,10 +2273,11 @@ get_info: } else if (mysql->server_capabilities & CLIENT_TRANSACTIONS) { + /* MySQL 4.0 protocol */ mysql->server_status=uint2korr(pos); pos+=2; mysql->warning_count= 0; } - DBUG_PRINT("info",("status: %ld warning_count: %ld", + DBUG_PRINT("info",("status: %u warning_count: %u", mysql->server_status, mysql->warning_count)); if (pos < mysql->net.read_pos+length && net_field_length(&pos)) mysql->info=(char*) pos; @@ -2402,7 +2417,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql) have to wait for the client (and will not wait more than 30 sec/packet). **************************************************************************/ -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql) +static MYSQL_RES * cli_mysql_use_result(MYSQL *mysql) { MYSQL_RES *result; DBUG_ENTER("cli_mysql_use_result"); @@ -2540,6 +2555,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME)); #endif + break; case MYSQL_OPT_USE_REMOTE_CONNECTION: case MYSQL_OPT_USE_EMBEDDED_CONNECTION: case MYSQL_OPT_GUESS_CONNECTION: @@ -2547,6 +2563,10 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) break; case MYSQL_SET_CLIENT_IP: mysql->options.client_ip= my_strdup(arg, MYF(MY_WME)); + break; + case MYSQL_SECURE_AUTH: + mysql->options.secure_auth= *(my_bool *) arg; + break; default: DBUG_RETURN(1); } diff --git a/sql-common/pack.c b/sql-common/pack.c index e31e596ae7a..ed79143a04b 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -78,23 +78,40 @@ my_ulonglong net_field_length_ll(uchar **packet) #endif } +/* + Store an integer with simple packing into a output package + + SYNOPSIS + net_store_length() + pkg Store the packed integer here + length integers to store + + NOTES + This is mostly used to store lengths of strings. + We have to cast the result for the LL() becasue of a bug in Forte CC + compiler. + + RETURN + Position in 'pkg' after the packed length +*/ + char * net_store_length(char *pkg, ulonglong length) { uchar *packet=(uchar*) pkg; - if (length < LL(251)) + if (length < (ulonglong) LL(251)) { *packet=(uchar) length; return (char*) packet+1; } /* 251 is reserved for NULL */ - if (length < LL(65536)) + if (length < (ulonglong) LL(65536)) { *packet++=252; int2store(packet,(uint) length); return (char*) packet+2; } - if (length < LL(16777216)) + if (length < (ulonglong) LL(16777216)) { *packet++=253; int3store(packet,(ulong) length); diff --git a/sql/derror.cc b/sql/derror.cc index ad7432f7675..53d0dc5b7e5 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -75,6 +75,7 @@ Please install the latest version of this file.",name); goto err1; } + /* TODO: Convert the character set to server system character set */ if (!(cset= get_charset(head[30],MYF(MY_WME)))) { sql_print_error("Character set #%d is not supported for messagefile '%s'", diff --git a/sql/field.cc b/sql/field.cc index befa9993b05..23f6e1232b6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -169,6 +169,128 @@ static inline uint field_length_without_space(const char *ptr, uint length) return (uint) (end-ptr); } +/* + Tables of filed type compatibility. + + There are tables for every type, table consist of list of types in which + given type can be converted without data lost, list should be ended with + FIELD_CAST_STOP +*/ +static Field::field_cast_enum field_cast_decimal[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_tiny[]= +{Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, + Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_short[]= +{Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_medium[]= +{Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_long[]= +{Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_longlong[]= +{Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_float[]= +{Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_double[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_null[]= +{Field::FIELD_CAST_DECIMAL, Field::FIELD_CAST_TINY, Field::FIELD_CAST_SHORT, + Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_TIMESTAMP, Field::FIELD_CAST_YEAR, + Field::FIELD_CAST_DATE, Field::FIELD_CAST_NEWDATE, + Field::FIELD_CAST_TIME, Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, + Field::FIELD_CAST_GEOM, Field::FIELD_CAST_ENUM, Field::FIELD_CAST_SET, + Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_timestamp[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_year[]= +{Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, + Field::FIELD_CAST_LONGLONG, + Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_date[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_newdate[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_time[]= +{Field::FIELD_CAST_DATETIME, + Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_datetime[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_string[]= +{Field::FIELD_CAST_VARSTRING, Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_varstring[]= +{Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_blob[]= +{Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_geom[]= +{Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_enum[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +static Field::field_cast_enum field_cast_set[]= +{Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING, + Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP}; +// Array of pointers on conversion table for all fields types casting +static Field::field_cast_enum *field_cast_array[]= +{0, //FIELD_CAST_STOP + field_cast_decimal, field_cast_tiny, field_cast_short, + field_cast_medium, field_cast_long, field_cast_longlong, + field_cast_float, field_cast_double, + field_cast_null, + field_cast_timestamp, field_cast_year, field_cast_date, field_cast_newdate, + field_cast_time, field_cast_datetime, + field_cast_string, field_cast_varstring, field_cast_blob, + field_cast_geom, field_cast_enum, field_cast_set +}; + + +bool Field::field_cast_compatible(Field::field_cast_enum type) +{ + DBUG_ASSERT(type != FIELD_CAST_STOP); + Field::field_cast_enum *array= field_cast_array[field_cast_type()]; + uint i= 0; + Field::field_cast_enum tp; + do + { + tp= array[i++]; + if (tp == type) + return 1; + } while (tp != FIELD_CAST_STOP); + return 0; +} + + /**************************************************************************** ** Functions for the base classes ** This is an unpacked number. @@ -2850,7 +2972,7 @@ String *Field_timestamp::val_str(String *val_buffer, struct tm tm_tmp; val_buffer->alloc(field_length+1); - char *to=(char*) val_buffer->ptr(),*end=to+field_length; + char *to= (char*) val_buffer->ptr(); val_buffer->length(field_length); #ifdef WORDS_BIGENDIAN @@ -3635,7 +3757,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) ltime->month= (tmp >> 5) & 15; ltime->year= (tmp >> 9); ltime->time_type=TIMESTAMP_DATE; - ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; + ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0; return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0; } @@ -3987,7 +4109,6 @@ longlong Field_string::val_int(void) String *Field_string::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { - char *end=ptr+field_length; uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length); val_ptr->set((const char*) ptr, length, field_charset); return val_ptr; diff --git a/sql/field.h b/sql/field.h index 692e64d1146..0b6ba7dde09 100644 --- a/sql/field.h +++ b/sql/field.h @@ -61,6 +61,17 @@ public: GEOM_GEOMETRYCOLLECTION = 7 }; enum imagetype { itRAW, itMBR}; + enum field_cast_enum + { + FIELD_CAST_STOP, FIELD_CAST_DECIMAL, FIELD_CAST_TINY, FIELD_CAST_SHORT, + FIELD_CAST_MEDIUM, FIELD_CAST_LONG, FIELD_CAST_LONGLONG, + FIELD_CAST_FLOAT, FIELD_CAST_DOUBLE, + FIELD_CAST_NULL, + FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE, + FIELD_CAST_TIME, FIELD_CAST_DATETIME, + FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB, + FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET + }; utype unireg_check; uint32 field_length; // Length of field @@ -230,6 +241,8 @@ public: virtual bool has_charset(void) const { return FALSE; } virtual void set_charset(CHARSET_INFO *charset) { } void set_warning(const unsigned int level, const unsigned int code); + virtual field_cast_enum field_cast_type()= 0; + bool field_cast_compatible(field_cast_enum type); friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, ulonglong auto_increment_value); @@ -334,6 +347,7 @@ public: void overflow(bool negative); bool zero_pack() const { return 0; } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_DECIMAL; } }; @@ -369,6 +383,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 1; } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_TINY; } }; @@ -404,6 +419,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 2; } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_SHORT; } }; @@ -434,6 +450,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_MEDIUM; } }; @@ -469,6 +486,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_LONG; } }; @@ -507,6 +525,7 @@ public: uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool store_for_compare() { return 1; } + field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; } }; #endif @@ -540,6 +559,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_FLOAT; } }; @@ -573,6 +593,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_DOUBLE; } }; @@ -606,6 +627,7 @@ public: uint32 pack_length() const { return 0; } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } + field_cast_enum field_cast_type() { return FIELD_CAST_NULL; } }; @@ -649,6 +671,7 @@ public: } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; } }; @@ -674,6 +697,7 @@ public: String *val_str(String*,String *); bool send_binary(Protocol *protocol); void sql_type(String &str) const; + field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; } }; @@ -706,6 +730,7 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } + field_cast_enum field_cast_type() { return FIELD_CAST_DATE; } }; class Field_newdate :public Field_str { @@ -737,6 +762,7 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + field_cast_enum field_cast_type() { return FIELD_CAST_NEWDATE; } }; @@ -770,6 +796,7 @@ public: void sql_type(String &str) const; bool store_for_compare() { return 1; } bool zero_pack() const { return 1; } + field_cast_enum field_cast_type() { return FIELD_CAST_TIME; } }; @@ -807,6 +834,7 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); + field_cast_enum field_cast_type() { return FIELD_CAST_DATETIME; } }; @@ -851,6 +879,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_STRING; } bool has_charset(void) const { return TRUE; } + field_cast_enum field_cast_type() { return FIELD_CAST_STRING; } }; @@ -894,6 +923,7 @@ public: uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return FIELD_TYPE_VAR_STRING; } bool has_charset(void) const { return TRUE; } + field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; } }; @@ -911,7 +941,7 @@ public: struct st_table *table_arg, CHARSET_INFO *cs) :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, table_arg, cs), - geom_flag(true), packlength(3) + geom_flag(true), packlength(4) { flags|= BLOB_FLAG; } @@ -983,6 +1013,7 @@ public: uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } + field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; } }; @@ -1011,6 +1042,7 @@ public: void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); + field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; } }; @@ -1052,6 +1084,7 @@ public: bool optimize_range(uint idx) { return 0; } bool eq_def(Field *field); bool has_charset(void) const { return TRUE; } + field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; } }; @@ -1077,6 +1110,7 @@ public: void sql_type(String &str) const; enum_field_types real_type() const { return FIELD_TYPE_SET; } bool has_charset(void) const { return TRUE; } + field_cast_enum field_cast_type() { return FIELD_CAST_SET; } }; diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index fb4061b31e0..ae0267b98f3 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -248,7 +248,8 @@ ha_rows ha_heap::records_in_range(int inx, } } -int ha_heap::create(const char *name, TABLE *table, + +int ha_heap::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { uint key, parts, mem_per_row= 0; @@ -259,17 +260,17 @@ int ha_heap::create(const char *name, TABLE *table, char buff[FN_REFLEN]; int error; - for (key= parts= 0; key < table->keys; key++) - parts+= table->key_info[key].key_parts; + for (key= parts= 0; key < table_arg->keys; key++) + parts+= table_arg->key_info[key].key_parts; - if (!(keydef= (HP_KEYDEF*) my_malloc(table->keys * sizeof(HP_KEYDEF) + + if (!(keydef= (HP_KEYDEF*) my_malloc(table_arg->keys * sizeof(HP_KEYDEF) + parts * sizeof(HA_KEYSEG), MYF(MY_WME)))) return my_errno; - seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table->keys); - for (key= 0; key < table->keys; key++) + seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table_arg->keys); + for (key= 0; key < table_arg->keys; key++) { - KEY *pos= table->key_info+key; + KEY *pos= table_arg->key_info+key; KEY_PART_INFO *key_part= pos->key_part; KEY_PART_INFO *key_part_end= key_part + pos->key_parts; @@ -303,7 +304,7 @@ int ha_heap::create(const char *name, TABLE *table, if (field->null_ptr) { seg->null_bit= field->null_bit; - seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]); + seg->null_pos= (uint) (field->null_ptr - (uchar*) table_arg->record[0]); } else { @@ -317,7 +318,7 @@ int ha_heap::create(const char *name, TABLE *table, } } } - mem_per_row+= MY_ALIGN(table->reclength + 1, sizeof(char*)); + mem_per_row+= MY_ALIGN(table_arg->reclength + 1, sizeof(char*)); max_rows = (ha_rows) (current_thd->variables.max_heap_table_size / mem_per_row); HP_CREATE_INFO hp_create_info; @@ -326,10 +327,11 @@ int ha_heap::create(const char *name, TABLE *table, hp_create_info.auto_increment= (create_info->auto_increment_value ? create_info->auto_increment_value - 1 : 0); error= heap_create(fn_format(buff,name,"","",4+2), - table->keys,keydef, table->reclength, - (ulong) ((table->max_rows < max_rows && table->max_rows) ? - table->max_rows : max_rows), - (ulong) table->min_rows, &hp_create_info); + table_arg->keys,keydef, table_arg->reclength, + (ulong) ((table_arg->max_rows < max_rows && + table_arg->max_rows) ? + table_arg->max_rows : max_rows), + (ulong) table_arg->min_rows, &hp_create_info); my_free((gptr) keydef, MYF(0)); if (file) info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); @@ -337,6 +339,7 @@ int ha_heap::create(const char *name, TABLE *table, return (error); } + void ha_heap::update_create_info(HA_CREATE_INFO *create_info) { table->file->info(HA_STATUS_AUTO); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index c10eec73274..cbbb0d96d22 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -46,6 +46,7 @@ InnoDB */ #include "ha_innodb.h" pthread_mutex_t innobase_mutex; +bool innodb_inited= 0; /* Store MySQL definition of 'byte': in Linux it is char while InnoDB uses unsigned char; the header univ.i which we include next defines @@ -75,6 +76,7 @@ extern "C" { #include "../innobase/include/btr0cur.h" #include "../innobase/include/btr0btr.h" #include "../innobase/include/fsp0fsp.h" +#include "../innobase/include/fil0fil.h" } #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ @@ -546,7 +548,6 @@ innobase_query_caching_of_table_permitted( { ibool is_autocommit; trx_t* trx; - char* ptr; char norm_name[1000]; ut_a(full_name_len < 999); @@ -606,7 +607,7 @@ innobase_query_caching_of_table_permitted( #ifdef __WIN__ /* Put to lower case */ - ptr = norm_name; + char* ptr = norm_name; while (*ptr != '\0') { *ptr = tolower(*ptr); @@ -739,6 +740,7 @@ innobase_init(void) if (mysql_embedded) { default_path = mysql_real_data_home; + fil_path_to_mysql_datadir = mysql_real_data_home; } else { /* It's better to use current lib, to keep paths short */ current_dir[0] = FN_CURLIB; @@ -899,6 +901,7 @@ innobase_init(void) (void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0, (hash_get_key) innobase_get_key, 0, 0); pthread_mutex_init(&innobase_mutex, MY_MUTEX_INIT_FAST); + innodb_inited= 1; /* If this is a replication slave and we needed to do a crash recovery, set the master binlog position to what InnoDB internally knew about @@ -926,21 +929,21 @@ innobase_end(void) /*==============*/ /* out: TRUE if error */ { - int err; + int err= 0; DBUG_ENTER("innobase_end"); - err = innobase_shutdown_for_mysql(); - hash_free(&innobase_open_tables); - my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); - pthread_mutex_destroy(&innobase_mutex); - - if (err != DB_SUCCESS) { - - DBUG_RETURN(1); + if (innodb_inited) + { + innodb_inited= 0; + if (innobase_shutdown_for_mysql() != DB_SUCCESS) + err= 1; + hash_free(&innobase_open_tables); + my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); + pthread_mutex_destroy(&innobase_mutex); } - DBUG_RETURN(0); + DBUG_RETURN(err); } /******************************************************************** @@ -1391,7 +1394,6 @@ ha_innobase::open( uint test_if_locked) /* in: not used */ { dict_table_t* ib_table; - int error = 0; char norm_name[1000]; DBUG_ENTER("ha_innobase::open"); @@ -1534,7 +1536,7 @@ ha_innobase::open( fprintf(stderr, "InnoDB: Warning: table %s key_used_on_scan is %lu even though there is no\n" "InnoDB: primary key inside InnoDB.\n", - name, (ulint)key_used_on_scan); + name, (ulong)key_used_on_scan); } } @@ -3214,7 +3216,7 @@ ha_innobase::position( if (len != ref_length) { fprintf(stderr, "InnoDB: Error: stored ref len is %lu, but table ref len is %lu\n", - (ulint)len, (ulint)ref_length); + (ulong)len, (ulong)ref_length); } } @@ -3638,7 +3640,7 @@ ha_innobase::discard_or_import_tablespace( my_bool discard) /* in: TRUE if discard, else import */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - dict_table_t* table; + dict_table_t* dict_table; trx_t* trx; int err; @@ -3648,13 +3650,13 @@ ha_innobase::discard_or_import_tablespace( ut_a(prebuilt->trx == (trx_t*) current_thd->transaction.all.innobase_tid); - table = prebuilt->table; + dict_table = prebuilt->table; trx = prebuilt->trx; if (discard) { - err = row_discard_tablespace_for_mysql(table->name, trx); + err = row_discard_tablespace_for_mysql(dict_table->name, trx); } else { - err = row_import_tablespace_for_mysql(table->name, trx); + err = row_import_tablespace_for_mysql(dict_table->name, trx); } if (err == DB_SUCCESS) { @@ -4185,7 +4187,8 @@ ha_innobase::info( "InnoDB: .frm files from different installations? See section\n" "InnoDB: 15.1 at http://www.innodb.com/ibman.html\n", index->name, - ib_table->name, index->n_uniq, + ib_table->name, + (unsigned long) index->n_uniq, j + 1); break; } diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc index 94e394e7665..9915c182e26 100644 --- a/sql/ha_isammrg.cc +++ b/sql/ha_isammrg.cc @@ -157,7 +157,7 @@ void ha_isammrg::info(uint flag) deleted = (ha_rows) info.deleted; data_file_length=info.data_file_length; errkey = info.errkey; - table->keys_in_use=0; // No keys yet + table->keys_in_use.clear_all(); // No keys yet table->db_options_in_use = info.options; mean_rec_length=info.reclength; block_size=0; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 09f034b27bf..6356f209ba2 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -226,7 +226,6 @@ err: int ha_myisam::open(const char *name, int mode, uint test_if_locked) { - KEY_CACHE_VAR *key_cache; if (!(file=mi_open(name, mode, test_if_locked))) return (my_errno ? my_errno : -1); @@ -698,7 +697,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) { - KEY_CACHE_VAR *new_key_cache= check_opt->key_cache; + KEY_CACHE *new_key_cache= check_opt->key_cache; const char *errmsg= 0; int error= HA_ADMIN_OK; ulonglong map= ~(ulonglong) 0; @@ -721,13 +720,10 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) if ((error= mi_assign_to_key_cache(file, map, new_key_cache))) { - switch (error) { - default: - char buf[80]; - my_snprintf(buf, sizeof(buf), - "Failed to flush to index file (errno: %d)", error); - errmsg= buf; - } + char buf[80]; + my_snprintf(buf, sizeof(buf), + "Failed to flush to index file (errno: %d)", error); + errmsg= buf; error= HA_ADMIN_CORRUPT; } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index a834ace7032..3cd5d96d5f3 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -39,7 +39,6 @@ const char **ha_myisammrg::bas_ext() const int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { char name_buff[FN_REFLEN]; - KEY_CACHE_VAR *key_cache; DBUG_PRINT("info", ("ha_myisammrg::open")); if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode, @@ -312,11 +311,11 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, static void split_file_name(const char *file_name, LEX_STRING *db, LEX_STRING *name) { - uint name_length, dir_length, prefix_length; + uint dir_length, prefix_length; char buff[FN_REFLEN]; db->length= 0; - name_length= (uint) (strmake(buff, file_name, sizeof(buff)-1) - buff); + strmake(buff, file_name, sizeof(buff)-1); dir_length= dirname_length(buff); if (dir_length > 1) { diff --git a/sql/handler.cc b/sql/handler.cc index 96444f97da8..ac14f383eab 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1171,20 +1171,22 @@ void st_ha_check_opt::init() /* Init a key cache if it has not been initied before */ -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) { DBUG_ENTER("ha_init_key_cache"); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!init_key_cache(&key_cache->cache, + DBUG_RETURN(!init_key_cache(key_cache, tmp_block_size, tmp_buff_size, - key_cache)); + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1192,18 +1194,21 @@ int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) /* Resize key cache */ -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) +int ha_resize_key_cache(KEY_CACHE *key_cache) { DBUG_ENTER("ha_resize_key_cache"); - if (key_cache->cache) + if (key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!resize_key_cache(&key_cache->cache, tmp_block_size, - tmp_buff_size)); + DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1211,29 +1216,31 @@ int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) /* Change parameters for key cache (like size) */ -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache) +int ha_change_key_cache_param(KEY_CACHE *key_cache) { - if (key_cache->cache) - change_key_cache_param(key_cache->cache); + if (key_cache->key_cache_inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + change_key_cache_param(key_cache, division_limit, age_threshold); + } return 0; } /* Free memory allocated by a key cache */ -int ha_end_key_cache(KEY_CACHE_VAR *key_cache) +int ha_end_key_cache(KEY_CACHE *key_cache) { - if (key_cache->cache) - { - end_key_cache(key_cache->cache, 1); // Can never fail - key_cache->cache= 0; - } + end_key_cache(key_cache, 1); // Can never fail return 0; } /* Move all tables from one key cache to another one */ -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { mi_change_key_cache(old_key_cache, new_key_cache); return 0; diff --git a/sql/handler.h b/sql/handler.h index f4ae45fafe3..49c7e9d06c5 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -22,6 +22,7 @@ #endif #include <ft_global.h> +#include <keycache.h> #ifndef NO_HASH #define NO_HASH /* Not yet implemented */ @@ -181,14 +182,13 @@ typedef struct st_ha_create_information struct st_table; typedef struct st_table TABLE; -typedef struct st_key_cache_asmt KEY_CACHE_ASMT; typedef struct st_ha_check_opt { ulong sort_buffer_size; uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ - KEY_CACHE_VAR *key_cache; /* new key cache when changing key cache */ + KEY_CACHE *key_cache; /* new key cache when changing key cache */ void init(); } HA_CHECK_OPT; @@ -395,10 +395,10 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_delete_table(enum db_type db_type, const char *path); void ha_drop_database(char* path); -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache); -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache); -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache); -int ha_end_key_cache(KEY_CACHE_VAR *key_cache); +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); +int ha_resize_key_cache(KEY_CACHE *key_cache); +int ha_change_key_cache_param(KEY_CACHE *key_cache); +int ha_end_key_cache(KEY_CACHE *key_cache); int ha_start_stmt(THD *thd); int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, my_off_t end_offset); @@ -412,5 +412,5 @@ int ha_autocommit_or_rollback(THD *thd, int error); void ha_set_spin_retries(uint retries); bool ha_flush_logs(void); int ha_recovery_logging(THD *thd, bool on); -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache); +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); diff --git a/sql/hostname.cc b/sql/hostname.cc index 5c4bde99256..c9cb2a43963 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -61,23 +61,27 @@ bool hostname_cache_init() { host_entry tmp; uint offset= (uint) ((char*) (&tmp.ip) - (char*) &tmp); - (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW); - if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset, sizeof(struct in_addr),NULL, (hash_free_key) free, &my_charset_latin1))) return 1; hostname_cache->clear(); + (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW); return 0; } void hostname_cache_free() { - (void) pthread_mutex_destroy(&LOCK_hostname); - delete hostname_cache; + if (hostname_cache) + { + (void) pthread_mutex_destroy(&LOCK_hostname); + delete hostname_cache; + hostname_cache= 0; + } } + static void add_hostname(struct in_addr *in,const char *name) { if (!(specialflag & SPECIAL_NO_HOST_CACHE)) diff --git a/sql/item.cc b/sql/item.cc index 5091ea87bee..5f9a9d4a657 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -333,7 +333,7 @@ void Item_field::set_field(Field *field_par) const char *Item_ident::full_name() const { char *tmp; - if (!table_name) + if (!table_name || !field_name) return field_name ? field_name : name ? name : "tmp_field"; if (db_name && db_name[0]) { @@ -533,7 +533,7 @@ String *Item_null::val_str(String *str) void Item_param::set_null() { DBUG_ENTER("Item_param::set_null"); - maybe_null= null_value= 1; + maybe_null= null_value= value_is_set= 1; DBUG_VOID_RETURN; } @@ -542,6 +542,7 @@ void Item_param::set_int(longlong i) DBUG_ENTER("Item_param::set_int"); int_value= (longlong)i; item_type= INT_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("integer: %lld", int_value)); DBUG_VOID_RETURN; } @@ -551,6 +552,7 @@ void Item_param::set_double(double value) DBUG_ENTER("Item_param::set_double"); real_value=value; item_type= REAL_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("double: %lg", real_value)); DBUG_VOID_RETURN; } @@ -561,6 +563,7 @@ void Item_param::set_value(const char *str, uint length) DBUG_ENTER("Item_param::set_value"); str_value.copy(str,length,default_charset()); item_type= STRING_ITEM; + value_is_set= 1; DBUG_PRINT("info", ("string: %s", str_value.ptr())); DBUG_VOID_RETURN; } @@ -582,6 +585,7 @@ void Item_param::set_time(TIME *tm, timestamp_type type) item_is_time= true; item_type= STRING_ITEM; + value_is_set= 1; } @@ -589,6 +593,7 @@ void Item_param::set_longdata(const char *str, ulong length) { str_value.append(str,length); long_data_supplied= 1; + value_is_set= 1; } @@ -1254,6 +1259,15 @@ int Item_string::save_in_field(Field *field, bool no_conversions) -1 : 0; } +int Item_uint::save_in_field(Field *field, bool no_conversions) +{ + /* + TODO: To be fixed when wen have a + field->store(longlong, unsigned_flag) method + */ + return Item_int::save_in_field(field, no_conversions); +} + int Item_int::save_in_field(Field *field, bool no_conversions) { @@ -1411,7 +1425,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_FLOAT: { float nr; - nr= val(); + nr= (float) val(); if (!null_value) result= protocol->store(nr, decimals, buffer); break; @@ -1717,7 +1731,9 @@ bool Item_insert_value::eq(const Item *item, bool binary_cmp) const } -bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) +bool Item_insert_value::fix_fields(THD *thd, + struct st_table_list *table_list, + Item **items) { bool res= arg->fix_fields(thd, table_list, items); if (res) @@ -1748,10 +1764,10 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I } else { - Field *field=field_arg->field; + Field *tmp_field= field_arg->field; /* charset doesn't matter here, it's to avoid sigsegv only */ - set_field(new Field_null(0,0,Field::NONE,field->field_name,field->table, - &my_charset_bin)); + set_field(new Field_null(0, 0, Field::NONE, tmp_field->field_name, + tmp_field->table, &my_charset_bin)); } return 0; } @@ -1931,6 +1947,8 @@ void Item_cache_str::store(Item *item) } collation.set(item->collation); } + + double Item_cache_str::val() { int err; @@ -1940,6 +1958,8 @@ double Item_cache_str::val() else return (double)0; } + + longlong Item_cache_str::val_int() { int err; @@ -1950,6 +1970,7 @@ longlong Item_cache_str::val_int() return (longlong)0; } + bool Item_cache_row::allocate(uint num) { item_count= num; @@ -1958,6 +1979,7 @@ bool Item_cache_row::allocate(uint num) (Item_cache **) thd->calloc(sizeof(Item_cache *)*item_count))); } + bool Item_cache_row::setup(Item * item) { example= item; @@ -1974,6 +1996,7 @@ bool Item_cache_row::setup(Item * item) return 0; } + void Item_cache_row::store(Item * item) { null_value= 0; @@ -1985,6 +2008,7 @@ void Item_cache_row::store(Item * item) } } + void Item_cache_row::illegal_method_call(const char *method) { DBUG_ENTER("Item_cache_row::illegal_method_call"); @@ -1994,6 +2018,7 @@ void Item_cache_row::illegal_method_call(const char *method) DBUG_VOID_RETURN; } + bool Item_cache_row::check_cols(uint c) { if (c != item_count) @@ -2004,6 +2029,7 @@ bool Item_cache_row::check_cols(uint c) return 0; } + bool Item_cache_row::null_inside() { for (uint i= 0; i < item_count; i++) @@ -2023,6 +2049,7 @@ bool Item_cache_row::null_inside() return 0; } + void Item_cache_row::bring_value() { for (uint i= 0; i < item_count; i++) @@ -2030,6 +2057,132 @@ void Item_cache_row::bring_value() return; } + +Item_type_holder::Item_type_holder(THD *thd, Item *item) + :Item(thd, *item), item_type(item->result_type()) +{ + DBUG_ASSERT(item->fixed); + + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ + if (item->type() == Item::FIELD_ITEM) + field_example= ((Item_field*) item)->field; + else + field_example= 0; + collation.set(item->collation); +} + + +/* + STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT + + ROW_RESULT should never appear in Item_type_holder::join_types, + but it is included in following table just to make table full + (there DBUG_ASSERT in function to catch ROW_RESULT) +*/ +static Item_result type_convertor[4][4]= +{{STRING_RESULT, STRING_RESULT, STRING_RESULT, ROW_RESULT}, + {STRING_RESULT, REAL_RESULT, REAL_RESULT, ROW_RESULT}, + {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT}, + {ROW_RESULT, ROW_RESULT, ROW_RESULT, ROW_RESULT}}; + +bool Item_type_holder::join_types(THD *thd, Item *item) +{ + bool change_field= 0, skip_store_field= 0; + Item_result new_type= type_convertor[item_type][item->result_type()]; + + // we have both fields + if (field_example && item->type() == Item::FIELD_ITEM) + { + Field *field= ((Item_field *)item)->field; + if (field_example->field_cast_type() != field->field_cast_type()) + { + if (!(change_field= + field_example->field_cast_compatible(field->field_cast_type()))) + { + /* + if old field can't store value of 'worse' new field we will make + decision about result field type based only on Item result type + */ + if (!field->field_cast_compatible(field_example->field_cast_type())) + skip_store_field= 1; + } + } + } + + // size/type should be changed + if (change_field || + (new_type != item_type) || + (max_length < item->max_length) || + ((new_type == INT_RESULT) && + (decimals < item->decimals)) || + (!maybe_null && item->maybe_null) || + (item_type == STRING_RESULT && new_type == STRING_RESULT && + !my_charset_same(collation.collation, item->collation.collation))) + { + // new field has some parameters worse then current + skip_store_field|= (change_field && + (max_length > item->max_length) || + ((new_type == INT_RESULT) && + (decimals > item->decimals)) || + (maybe_null && !item->maybe_null) || + (item_type == STRING_RESULT && + new_type == STRING_RESULT && + !my_charset_same(collation.collation, + item->collation.collation))); + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ + if (skip_store_field || item->type() != Item::FIELD_ITEM) + field_example= 0; + else + field_example= ((Item_field*) item)->field; + + const char *old_cs= collation.collation->name, + *old_derivation= collation.derivation_name(); + if (item_type == STRING_RESULT && collation.aggregate(item->collation)) + { + my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), + old_cs, old_derivation, + item->collation.collation->name, + item->collation.derivation_name(), + "UNION"); + return 1; + } + + max_length= max(max_length, item->max_length); + decimals= max(decimals, item->decimals); + maybe_null|= item->maybe_null; + item_type= new_type; + } + DBUG_ASSERT(item_type != ROW_RESULT); + return 0; +} + + +double Item_type_holder::val() +{ + DBUG_ASSERT(0); // should never be called + return 0.0; +} + + +longlong Item_type_holder::val_int() +{ + DBUG_ASSERT(0); // should never be called + return 0; +} + + +String *Item_type_holder::val_str(String*) +{ + DBUG_ASSERT(0); // should never be called + return 0; +} + /***************************************************************************** ** Instantiate templates *****************************************************************************/ diff --git a/sql/item.h b/sql/item.h index f3500f97366..92fe50ecc02 100644 --- a/sql/item.h +++ b/sql/item.h @@ -99,7 +99,7 @@ public: COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM, PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM, FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM, - SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM}; + SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER}; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; @@ -175,7 +175,17 @@ public: virtual cond_result eq_cmp_result() const { return COND_OK; } inline uint float_length(uint decimals_par) const { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} + /* + Returns true if this is constant (during query execution, i.e. its value + will not change until next fix_fields) and its value is known. + */ virtual bool const_item() const { return used_tables() == 0; } + /* + Returns true if this is constant but its value may be not known yet. + (Can be used for parameters of prep. stmts or of stored procedures.) + */ + virtual bool const_during_execution() const + { return (used_tables() & ~PARAM_TABLE_BIT) == 0; } virtual void print(String *str_arg) { str_arg->append(full_name()); } void print_item_w_name(String *); virtual void update_used_tables() {} @@ -427,6 +437,7 @@ public: class Item_param :public Item { public: + bool value_is_set; longlong int_value; double real_value; TIME ltime; @@ -445,6 +456,7 @@ public: item_result_type = STRING_RESULT; item_is_time= false; long_data_supplied= false; + value_is_set= 0; } enum Type type() const { return item_type; } double val(); @@ -472,6 +484,13 @@ public: String *query_val_str(String *str); enum_field_types field_type() const { return MYSQL_TYPE_STRING; } Item *new_item() { return new Item_param(pos_in_query); } + /* + If value for parameter was not set we treat it as non-const + so noone will use parameters value in fix_fields still + parameter is constant during execution. + */ + virtual table_map used_tables() const + { return value_is_set ? (table_map)0 : PARAM_TABLE_BIT; } void print(String *str) { str->append('?'); } }; @@ -480,17 +499,17 @@ class Item_int :public Item public: const longlong value; Item_int(int32 i,uint length=11) :value((longlong) i) - { max_length=length;} + { max_length=length; fixed= 1; } #ifdef HAVE_LONG_LONG Item_int(longlong i,uint length=21) :value(i) - { max_length=length;} + { max_length=length; fixed= 1;} #endif Item_int(const char *str_arg,longlong i,uint length) :value(i) - { max_length=length; name=(char*) str_arg;} + { max_length=length; name=(char*) str_arg; fixed= 1; } Item_int(const char *str_arg) : value(str_arg[0] == '-' ? strtoll(str_arg,(char**) 0,10) : (longlong) strtoull(str_arg,(char**) 0,10)) - { max_length= (uint) strlen(str_arg); name=(char*) str_arg;} + { max_length= (uint) strlen(str_arg); name=(char*) str_arg; fixed= 1; } enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } @@ -513,6 +532,7 @@ public: double val() { return ulonglong2double((ulonglong)value); } String *val_str(String*); Item *new_item() { return new Item_uint(name,max_length); } + int save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd, struct st_table_list *list, Item **item) { bool res= Item::fix_fields(thd, list, item); @@ -919,14 +939,14 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { if (!arg) { - field->set_default(); + field_arg->set_default(); return 0; } - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } @@ -956,9 +976,9 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } @@ -1086,6 +1106,28 @@ public: void bring_value(); }; + +/* + Used to store type. name, length of Item for UNIONS & derived table +*/ +class Item_type_holder: public Item +{ +protected: + Item_result item_type; + Field *field_example; +public: + Item_type_holder(THD*, Item*); + + Item_result result_type () const { return item_type; } + enum Type type() const { return TYPE_HOLDER; } + double val(); + longlong val_int(); + String *val_str(String*); + bool join_types(THD *thd, Item *); + Field *example() { return field_example; } +}; + + extern Item_buff *new_Item_buff(Item *item); extern Item_result item_cmp_type(Item_result a,Item_result b); extern Item *resolve_const_item(Item *item,Item *cmp_item); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 76cec7b6615..ff1d359ec3f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -397,13 +397,12 @@ int Arg_comparator::compare_row() int Arg_comparator::compare_e_row() { - int res= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { - if ((res= !comparators[i].compare())) + if (!comparators[i].compare()) return 0; } return 1; @@ -1096,8 +1095,10 @@ void Item_func_case::fix_length_and_dec() return; - // Aggregate first expression and all THEN expression types - // and collations when string comparison + /* + Aggregate first expression and all THEN expression types + and collations when string comparison + */ if (first_expr_num != -1) { agg[0]= args[first_expr_num]; @@ -1110,7 +1111,7 @@ void Item_func_case::fix_length_and_dec() return; } - if (!else_expr_num != -1 || args[else_expr_num]->maybe_null) + if (else_expr_num == -1 || args[else_expr_num]->maybe_null) maybe_null=1; max_length=0; @@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec() } } + /* TODO: Fix this so that it prints the whole CASE expression */ void Item_func_case::print(String *str) @@ -1375,6 +1377,7 @@ cmp_item* cmp_item::get_comparator(Item *item) return 0; // to satisfy compiler :) } + cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); @@ -1395,27 +1398,46 @@ cmp_item* cmp_item_row::make_same() return new cmp_item_row(); } + +cmp_item_row::~cmp_item_row() +{ + DBUG_ENTER("~cmp_item_row"); + DBUG_PRINT("enter",("this: %lx", this)); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + if (comparators[i]) + delete comparators[i]; + } + } + DBUG_VOID_RETURN; +} + + void cmp_item_row::store_value(Item *item) { - THD *thd= current_thd; + DBUG_ENTER("cmp_item_row::store_value"); n= item->cols(); - if ((comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n))) + if (!comparators) + comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n); + if (comparators) { item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= cmp_item::get_comparator(item->el(i)))) - { - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!comparators[i]) + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed + comparators[i]->store_value(item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; + DBUG_VOID_RETURN; } + void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) { cmp_item_row *tmpl= (cmp_item_row*) t; @@ -1430,19 +1452,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= tmpl->comparators[i]->make_same())) - { - comparators[i]->store_value_by_template(tmpl->comparators[i], - item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= tmpl->comparators[i]->make_same())) + break; // new failed + comparators[i]->store_value_by_template(tmpl->comparators[i], + item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + int cmp_item_row::cmp(Item *arg) { arg->null_value= 0; @@ -1454,25 +1474,31 @@ int cmp_item_row::cmp(Item *arg) bool was_null= 0; arg->bring_value(); for (uint i=0; i < n; i++) + { if (comparators[i]->cmp(arg->el(i))) { if (!arg->el(i)->null_value) return 1; was_null= 1; } + } return (arg->null_value= was_null); } + int cmp_item_row::compare(cmp_item *c) { - int res; cmp_item_row *cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) + { + int res; if ((res= comparators[i]->compare(cmp->comparators[i]))) return res; + } return 0; } + bool Item_func_in::nulls_in_row() { Item **arg,**arg_end; @@ -1484,6 +1510,7 @@ bool Item_func_in::nulls_in_row() return 0; } + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -1491,6 +1518,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (unsigned char *) y->ptr(),y->length()); } + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; @@ -1512,7 +1540,6 @@ void Item_func_in::fix_length_and_dec() { switch (cmp_type) { case STRING_RESULT: - uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, cmp_collation.collation); break; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index cf14fbc17ea..9d567bbc01b 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -41,24 +41,24 @@ public: Arg_comparator(Item **a1, Item **a2): a(a1), b(a2) {}; int set_compare_func(Item_bool_func2 *owner, Item_result type); - inline int set_compare_func(Item_bool_func2 *owner) + inline int set_compare_func(Item_bool_func2 *owner_arg) { - return set_compare_func(owner, item_cmp_type((*a)->result_type(), - (*b)->result_type())); + return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(), + (*b)->result_type())); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2, Item_result type) { a= a1; b= a2; - return set_compare_func(owner, type); + return set_compare_func(owner_arg, type); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2) { - return set_cmp_func(owner, a1, a2, item_cmp_type((*a1)->result_type(), - (*a2)->result_type())); + return set_cmp_func(owner_arg, a1, a2, item_cmp_type((*a1)->result_type(), + (*a2)->result_type())); } inline int compare() { return (this->*func)(); } @@ -638,17 +638,7 @@ class cmp_item_row :public cmp_item uint n; public: cmp_item_row(): comparators(0), n(0) {} - ~cmp_item_row() - { - if (comparators) - { - for (uint i= 0; i < n; i++) - { - if (comparators[i]) - delete comparators[i]; - } - } - } + ~cmp_item_row(); void store_value(Item *item); int cmp(Item *arg); int compare(cmp_item *arg); @@ -694,7 +684,7 @@ public: cmp_item_string *cmp= (cmp_item_string *)c; return sortcmp(value_res, cmp->value_res, cmp_charset); } - cmp_item * make_same() + cmp_item *make_same() { return new cmp_item_sort_string_in_static(cmp_charset); } @@ -715,7 +705,10 @@ class Item_func_in :public Item_int_func } longlong val_int(); void fix_length_and_dec(); - ~Item_func_in() {} + ~Item_func_in() + { + cleanup(); /* This is not called by Item::~Item() */ + } void cleanup() { delete array; @@ -753,6 +746,7 @@ public: if (!args[0]->maybe_null) { used_tables_cache= 0; /* is always false */ + const_item_cache= 1; cached_value= (longlong) 0; } else diff --git a/sql/item_func.cc b/sql/item_func.cc index 4337ee631f4..9dd654f305e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1668,7 +1668,7 @@ bool udf_handler::get_arguments() String *udf_handler::val_str(String *str,String *save_str) { - uchar is_null=0; + uchar is_null_tmp=0; ulong res_length; if (get_arguments()) @@ -1685,9 +1685,9 @@ String *udf_handler::val_str(String *str,String *save_str) return 0; } } - char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, &is_null, - &error); - if (is_null || !res || error) // The !res is for safety + char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, + &is_null_tmp, &error); + if (is_null_tmp || !res || error) // The !res is for safety { return 0; } @@ -2365,9 +2365,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, bool Item_func_set_user_var::check() { - bool res; DBUG_ENTER("Item_func_set_user_var::check"); - LINT_INIT(res); switch (cached_result_type) { case REAL_RESULT: @@ -2746,6 +2744,7 @@ void Item_func_match::init_search(bool no_order) bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) { Item *item; + LINT_INIT(item); // Safe as arg_count is > 1 maybe_null=1; join_key=0; @@ -2756,7 +2755,8 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) modifications to find_best and auto_close as complement to auto_init code above. */ - if (Item_func::fix_fields(thd, tlist, ref) || !args[0]->const_item()) + if (Item_func::fix_fields(thd, tlist, ref) || + !args[0]->const_during_execution()) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"AGAINST"); return 1; @@ -2770,11 +2770,15 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) args[i]= item= *((Item_ref *)item)->ref; if (item->type() != Item::FIELD_ITEM) key=NO_SUCH_KEY; - used_tables_cache|=item->used_tables(); } - /* check that all columns come from the same table */ - if (my_count_bits(used_tables_cache) != 1) + /* + Check that all columns come from the same table. + We've already checked that columns in MATCH are fields so + PARAM_TABLE_BIT can only appear from AGAINST argument. + */ + if ((used_tables_cache & ~PARAM_TABLE_BIT) != item->used_tables()) key=NO_SUCH_KEY; + if (key == NO_SUCH_KEY && !(flags & FT_BOOL)) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); @@ -3056,7 +3060,6 @@ longlong Item_func_is_free_lock::val_int() String *res=args[0]->val_str(&value); THD *thd=current_thd; ULL *ull; - int error=0; null_value=0; if (!res || !res->length()) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dfaf3001a19..f40d38dd4a8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -324,7 +324,6 @@ null: void Item_func_concat::fix_length_and_dec() { - bool first_coll= 1; max_length=0; if (agg_arg_collations(collation, args, arg_count)) @@ -2018,7 +2017,7 @@ void Item_func_lpad::fix_length_and_dec() String *Item_func_lpad::val_str(String *str) { - uint32 res_byte_length,res_char_length,pad_byte_length,pad_char_length; + uint32 res_char_length,pad_char_length; ulong count= (long) args[1]->val_int(), byte_count; String a1,a3; String *res= args[0]->val_str(&a1); @@ -2028,7 +2027,6 @@ String *Item_func_lpad::val_str(String *str) goto err; null_value=0; - res_byte_length= res->length(); res_char_length= res->numchars(); if (count <= res_char_length) @@ -2037,7 +2035,6 @@ String *Item_func_lpad::val_str(String *str) return res; } - pad_byte_length= pad->length(); pad_char_length= pad->numchars(); byte_count= count * collation.collation->mbmaxlen; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 3ed137d0731..6f5e2e492e7 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -306,8 +306,7 @@ void Item_singlerow_subselect::fix_length_and_dec() } else { - THD *thd= current_thd; - if (!(row= (Item_cache**)thd->alloc(sizeof(Item_cache*)*max_columns))) + if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*max_columns))) return; engine->fix_length_and_dec(row); value= *row; @@ -550,8 +549,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX *select_lex= join->select_lex; - THD *thd= join->thd; - thd->where= "scalar IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "scalar IN/ALL/ANY subquery"; if (select_lex->item_list.elements > 1) { @@ -595,7 +594,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, select_lex->item_list.empty(); select_lex->item_list.push_back(item); - if (item->fix_fields(thd, join->tables_list, &item)) + if (item->fix_fields(thd_tmp, join->tables_list, &item)) { DBUG_RETURN(RES_ERROR); } @@ -609,14 +608,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, subs= new Item_maxmin_subselect(this, select_lex, func->l_op()); } // left expression belong to outer select - SELECT_LEX *current= thd->lex->current_select, *up; - thd->lex->current_select= up= current->return_after_parsing(); - if (left_expr->fix_fields(thd, up->get_table_list(), &left_expr)) + SELECT_LEX *current= thd_tmp->lex->current_select, *up; + thd_tmp->lex->current_select= up= current->return_after_parsing(); + if (left_expr->fix_fields(thd_tmp, up->get_table_list(), &left_expr)) { - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; substitution= func->create(left_expr, subs); DBUG_RETURN(RES_OK); } @@ -627,16 +626,16 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex->current_select, *up; + SELECT_LEX *current= thd_tmp->lex->current_select, *up; - thd->lex->current_select= up= current->return_after_parsing(); + thd_tmp->lex->current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; /* As far as Item_ref_in_optimizer do not substitude itself on fix_fields @@ -664,7 +663,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, this->full_name())); join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -688,7 +687,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, new Item_cond_and(having, join->having) : having); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -699,7 +699,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, } item->name= (char *)in_additional_cond; join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->conds)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->conds)) DBUG_RETURN(RES_ERROR); } else @@ -711,7 +711,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, (char *)"<no matter>", (char *)"<result>")); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -725,11 +726,11 @@ Item_in_subselect::single_value_transformer(JOIN *join, // fix_field of item will be done in time of substituting substitution= item; have_to_be_excluded= 1; - if (thd->lex->describe) + if (thd_tmp->lex->describe) { char warn_buff[MYSQL_ERRMSG_SIZE]; sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + push_warning(thd_tmp, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SELECT_REDUCED, warn_buff); } DBUG_RETURN(RES_REDUCE); @@ -739,13 +740,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, DBUG_RETURN(RES_OK); } + Item_subselect::trans_res Item_in_subselect::row_value_transformer(JOIN *join) { DBUG_ENTER("Item_in_subselect::row_value_transformer"); - THD *thd= join->thd; - thd->where= "row IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "row IN/ALL/ANY subquery"; SELECT_LEX *select_lex= join->select_lex; @@ -761,22 +763,22 @@ Item_in_subselect::row_value_transformer(JOIN *join) SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex->current_select, *up; - thd->lex->current_select= up= current->return_after_parsing(); + SELECT_LEX *current= thd_tmp->lex->current_select, *up; + thd_tmp->lex->current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex->current_select= current; + thd_tmp->lex->current_select= current; unit->uncacheable|= UNCACHEABLE_DEPENDENT; } uint n= left_expr->cols(); select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; - select_lex->setup_ref_array(thd, + select_lex->setup_ref_array(thd_tmp, select_lex->order_list.elements + select_lex->group_list.elements); Item *item= 0; @@ -802,7 +804,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) { join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -812,7 +814,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) else { join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->having)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->having)) DBUG_RETURN(RES_ERROR); } DBUG_RETURN(RES_OK); @@ -880,7 +882,7 @@ subselect_single_select_engine(st_select_lex *select, unit->select_limit_cnt= unit->global_parameters->select_limit+ unit->global_parameters ->offset_limit; if (unit->select_limit_cnt < unit->global_parameters->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; // no limit + unit->select_limit_cnt= HA_POS_ERROR; // no limit if (unit->select_limit_cnt == HA_POS_ERROR) select_lex->options&= ~OPTION_FOUND_ROWS; unit->item= item; @@ -889,17 +891,17 @@ subselect_single_select_engine(st_select_lex *select, subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, - select_subselect *result, - Item_subselect *item) - :subselect_engine(item, result) + select_subselect *result_arg, + Item_subselect *item_arg) + :subselect_engine(item_arg, result_arg) { unit= u; - if (!result) - //out of memory + if (!result_arg) //out of memory current_thd->fatal_error(); - unit->item= item; + unit->item= item_arg; } + int subselect_single_select_engine::prepare() { if (prepared) @@ -907,8 +909,7 @@ int subselect_single_select_engine::prepare() join= new JOIN(thd, select_lex->item_list, select_lex->options, result); if (!join || !result) { - //out of memory - thd->fatal_error(); + thd->fatal_error(); //out of memory return 1; } prepared= 1; @@ -924,7 +925,7 @@ int subselect_single_select_engine::prepare() (ORDER*) select_lex->group_list.first, select_lex->having, (ORDER*) 0, select_lex, - select_lex->master_unit(), 0)) + select_lex->master_unit())) return 1; thd->lex->current_select= save_select; return 0; @@ -932,7 +933,7 @@ int subselect_single_select_engine::prepare() int subselect_union_engine::prepare() { - return unit->prepare(thd, result, 0); + return unit->prepare(thd, result); } int subselect_uniquesubquery_engine::prepare() @@ -942,12 +943,12 @@ int subselect_uniquesubquery_engine::prepare() return 1; } -static Item_result set_row(SELECT_LEX *select_lex, Item * item, +static Item_result set_row(List<Item> &item_list, Item *item, Item_cache **row, bool *maybe_null) { Item_result res_type= STRING_RESULT; Item *sel_item; - List_iterator_fast<Item> li(select_lex->item_list); + List_iterator_fast<Item> li(item_list); for (uint i= 0; (sel_item= li++); i++) { item->max_length= sel_item->max_length; @@ -962,7 +963,7 @@ static Item_result set_row(SELECT_LEX *select_lex, Item * item, row[i]->collation.set(sel_item->collation); } } - if (select_lex->item_list.elements > 1) + if (item_list.elements > 1) res_type= ROW_RESULT; return res_type; } @@ -970,7 +971,7 @@ static Item_result set_row(SELECT_LEX *select_lex, Item * item, void subselect_single_select_engine::fix_length_and_dec(Item_cache **row) { DBUG_ASSERT(row || select_lex->item_list.elements==1); - res_type= set_row(select_lex, item, row, &maybe_null); + res_type= set_row(select_lex->item_list, item, row, &maybe_null); item->collation.set(row[0]->collation); if (cols() != 1) maybe_null= 0; @@ -981,44 +982,11 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) DBUG_ASSERT(row || unit->first_select()->item_list.elements==1); if (unit->first_select()->item_list.elements == 1) - { - uint32 mlen= 0, len; - Item *sel_item= 0; - for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) - { - List_iterator_fast<Item> li(sl->item_list); - Item *s_item= li++; - if ((len= s_item->max_length) > mlen) - mlen= len; - if (!sel_item) - sel_item= s_item; - maybe_null= s_item->maybe_null; - } - item->max_length= mlen; - res_type= sel_item->result_type(); - item->decimals= sel_item->decimals; - if (row) - { - if (!(row[0]= Item_cache::get_cache(res_type))) - return; - row[0]->set_len_n_dec(mlen, sel_item->decimals); - } - } + res_type= set_row(unit->types, item, row, &maybe_null); else { - SELECT_LEX *sl= unit->first_select(); bool fake= 0; - res_type= set_row(sl, item, row, &fake); - for (sl= sl->next_select(); sl; sl= sl->next_select()) - { - List_iterator_fast<Item> li(sl->item_list); - Item *sel_item; - for (uint i= 0; (sel_item= li++); i++) - { - if (sel_item->max_length > row[i]->max_length) - row[i]->max_length= sel_item->max_length; - } - } + res_type= set_row(unit->types, item, row, &fake); } } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 3637e025d3c..8444dc7bf66 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -263,7 +263,7 @@ public: virtual ~subselect_engine() {}; // to satisfy compiler // set_thd should be called before prepare() - void set_thd(THD *thd) { this->thd= thd; } + void set_thd(THD *thd_arg) { thd= thd_arg; } THD * get_thd() { return thd; } virtual int prepare()= 0; virtual void fix_length_and_dec(Item_cache** row)= 0; @@ -328,11 +328,11 @@ protected: public: // constructor can assign THD because it will be called after JOIN::prepare - subselect_uniquesubquery_engine(THD *thd, st_join_table *tab_arg, + subselect_uniquesubquery_engine(THD *thd_arg, st_join_table *tab_arg, Item_subselect *subs, Item *where) :subselect_engine(subs, 0), tab(tab_arg), cond(where) { - set_thd(thd); + set_thd(thd_arg); } ~subselect_uniquesubquery_engine(); int prepare(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f179e2c40d1..a3d652d2fe1 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -104,16 +104,16 @@ Item *Item_sum::get_tmp_table_item(THD *thd) Item_sum* sum_item= (Item_sum *) copy_or_same(thd); if (sum_item && sum_item->result_field) // If not a const sum func { - Field *result_field= sum_item->result_field; + Field *result_field_tmp= sum_item->result_field; for (uint i=0 ; i < sum_item->arg_count ; i++) { Item *arg= sum_item->args[i]; if (!arg->const_item()) { if (arg->type() == Item::FIELD_ITEM) - ((Item_field*) arg)->field= result_field++; + ((Item_field*) arg)->field= result_field_tmp++; else - sum_item->args[i]= new Item_field(result_field++); + sum_item->args[i]= new Item_field(result_field_tmp++); } } } @@ -1642,10 +1642,8 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, original= 0; quick_group= 0; mark_as_sum_func(); - item_thd= current_thd; - SELECT_LEX *select_lex= item_thd->lex->current_select; order= 0; - group_concat_max_len= item_thd->variables.group_concat_max_len; + group_concat_max_len= current_thd->variables.group_concat_max_len; arg_show_fields= arg_count_field= is_select->elements; @@ -1791,6 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->allow_sum_func= 0; maybe_null= 0; + item_thd= thd; for (i= 0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) @@ -1969,6 +1968,7 @@ String* Item_func_group_concat::val_str(String* str) return &result; } + void Item_func_group_concat::print(String *str) { str->append("group_concat(", 13); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index bcb7ddb1054..a5372a4ae60 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -137,14 +137,12 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, static bool extract_date_time(DATE_TIME_FORMAT *format, const char *val, uint length, TIME *l_time) { - int weekday= 0, yearday= 0, daypart= 0, len; + int weekday= 0, yearday= 0, daypart= 0; int week_number= -1; CHARSET_INFO *cs= &my_charset_bin; int error= 0; bool usa_time= 0; bool sunday_first= 0; - uint part_len= 0; - const char *val_ptr= val; const char *val_end= val + length; const char *ptr= format->format.str; const char *end= ptr+ format->format.length; @@ -237,7 +235,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, /* Second part */ case 'f': tmp= (char*) val_end; - l_time->second_part= my_strtoll10(val, &tmp, &error); + l_time->second_part= (int) my_strtoll10(val, &tmp, &error); val= tmp; break; @@ -673,7 +671,7 @@ longlong Item_func_month::val_int() String* Item_func_monthname::val_str(String* str) { - const char *name; + const char *month_name; uint month=(uint) Item_func_month::val_int(); if (!month) // This is also true for NULL @@ -682,8 +680,8 @@ String* Item_func_monthname::val_str(String* str) return (String*) 0; } null_value=0; - name= month_names[month-1]; - str->set(name, strlen(name), system_charset_info); + month_name= month_names[month-1]; + str->set(month_name, strlen(month_name), system_charset_info); return str; } @@ -1221,7 +1219,7 @@ String *Item_func_sec_to_time::val_str(String *str) sec= (uint) ((ulonglong) seconds % 3600); ltime.day= 0; - ltime.hour= seconds/3600; + ltime.hour= (uint) (seconds/3600); ltime.minute= sec/60; ltime.second= sec % 60; @@ -1385,7 +1383,6 @@ String *Item_func_from_unixtime::val_str(String *str) { struct tm tm_tmp,*start; time_t tmp=(time_t) args[0]->val_int(); - CHARSET_INFO *cs= &my_charset_bin; TIME ltime; if ((null_value=args[0]->null_value)) @@ -1759,6 +1756,7 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const return 1; } + void Item_typecast::print(String *str) { str->append("cast(", 5); @@ -1768,6 +1766,7 @@ void Item_typecast::print(String *str) str->append(')'); } + void Item_char_typecast::print(String *str) { str->append("cast(", 5); @@ -1851,9 +1850,8 @@ String *Item_datetime_typecast::val_str(String *str) if (!get_arg0_date(<ime,1) && !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, <ime, str)) - return str; + return str; -null_date: null_value=1; return 0; } @@ -1912,8 +1910,8 @@ String *Item_date_typecast::val_str(String *str) String *Item_func_makedate::val_str(String *str) { TIME l_time; - long daynr= args[1]->val_int(); - long yearnr= args[0]->val_int(); + long daynr= (long) args[1]->val_int(); + long yearnr= (long) args[0]->val_int(); long days; if (args[0]->null_value || args[1]->null_value || @@ -1921,7 +1919,7 @@ String *Item_func_makedate::val_str(String *str) goto err; days= calc_daynr(yearnr,1,1) + daynr - 1; - // Day number from year 0 to 9999-12-31 + /* Day number from year 0 to 9999-12-31 */ if (days >= 0 && days < MAX_DAY_NUMBER) { null_value=0; @@ -2125,7 +2123,8 @@ String *Item_func_timediff::val_str(String *str) microseconds= l_time1.second_part - l_sign*l_time2.second_part; seconds= ((longlong) days*86400L + l_time1.hour*3600L + l_time1.minute*60L + l_time1.second + microseconds/1000000L - - (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+l_time2.second)); + (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+ + l_time2.second)); l_time3.neg= 0; if (seconds < 0) @@ -2146,7 +2145,7 @@ String *Item_func_timediff::val_str(String *str) if ((l_time2.neg == l_time1.neg) && l_time1.neg) l_time3.neg= l_time3.neg ? 0 : 1; - calc_time_from_sec(&l_time3, seconds, microseconds); + calc_time_from_sec(&l_time3, (long) seconds, microseconds); if (!make_datetime(l_time1.second_part || l_time2.second_part ? TIME_MICROSECOND : TIME_ONLY, @@ -2168,9 +2167,9 @@ String *Item_func_maketime::val_str(String *str) { TIME ltime; - long hour= args[0]->val_int(); - long minute= args[1]->val_int(); - long second= args[2]->val_int(); + long hour= (long) args[0]->val_int(); + long minute= (long) args[1]->val_int(); + long second= (long) args[2]->val_int(); if ((null_value=(args[0]->null_value || args[1]->null_value || @@ -2186,9 +2185,9 @@ String *Item_func_maketime::val_str(String *str) ltime.neg= 1; hour= -hour; } - ltime.hour= (ulong)hour; - ltime.minute= (ulong)minute; - ltime.second= (ulong)second; + ltime.hour= (ulong) hour; + ltime.minute= (ulong) minute; + ltime.second= (ulong) second; make_time((DATE_TIME_FORMAT *) 0, <ime, str); return str; } diff --git a/sql/log.cc b/sql/log.cc index f8e7c5ecb4e..95ee4928971 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -179,7 +179,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, const char *new_name, const char *index_file_name_arg, enum cache_type io_cache_type_arg, bool no_auto_events_arg, - ulong max_size) + ulong max_size_arg) { char buff[512]; File file= -1, index_file_nr= -1; @@ -190,7 +190,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, last_time=query_start=0; write_error=0; - init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size); + init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size_arg); if (!(name=my_strdup(log_name,MYF(MY_WME)))) goto err; @@ -1682,7 +1682,7 @@ void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave) const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log, master_or_slave ? "Has read all relay log; waiting for \ -the I/O slave thread to update it" : +the slave I/O thread to update it" : "Has sent all binlog to slave; \ waiting for binlog to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7cf276cb31e..a393e80f978 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -432,8 +432,6 @@ bool check_stack_overrun(THD *thd,char *dummy); void table_cache_init(void); void table_cache_free(void); uint cached_tables(void); -void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt, - KEY_CACHE_VAR *new_key_cache); void kill_mysql(void); void close_connection(THD *thd, uint errcode, bool lock); bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, @@ -466,8 +464,8 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* table_list, int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, LEX_STRING *key_cache_name); int mysql_preload_keys(THD* thd, TABLE_LIST* table_list); -int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache); +int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache); bool check_simple_select(); @@ -484,7 +482,7 @@ int mysql_select(THD *thd, Item ***rref_pointer_array, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulong select_type, select_result *result, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, bool tables_and_fields_initied); + SELECT_LEX *select_lex); void free_underlaid_joins(THD *thd, SELECT_LEX *select); void fix_tables_pointers(SELECT_LEX *select_lex); void fix_tables_pointers(SELECT_LEX_UNIT *select_lex); @@ -493,7 +491,7 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type, select_result *result); int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied); + SELECT_LEX_UNIT *unit); int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s, TABLE_LIST *t); Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, @@ -677,7 +675,6 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, List<Item> &item, bool set_query_id, List<Item> *sum_func_list, bool allow_sum_func); -void unfix_item_list(List<Item> item_list); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_ftfuncs(SELECT_LEX* select); int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); @@ -870,8 +867,7 @@ extern SHOW_COMP_OPTION have_berkeley_db; extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct rand_struct sql_rand; -extern KEY_CACHE_VAR *sql_key_cache; -extern KEY_CACHE_HANDLE sql_key_cache_handle; +extern KEY_CACHE *sql_key_cache; extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0f2968b464e..1108be6e1b5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -358,7 +358,7 @@ struct system_variables max_system_variables; MY_TMPDIR mysql_tmpdir_list; MY_BITMAP temp_pool; -KEY_CACHE_VAR *sql_key_cache; +KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; @@ -1568,14 +1568,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", - (ulong) sql_key_cache->buff_size); + (ulong) sql_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ -bytes of memory\n", ((ulong) sql_key_cache->buff_size + +bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * max_connections)/ 1024); @@ -2044,7 +2044,6 @@ bool init_global_datetime_format(timestamp_type format_type, { /* Get command line option */ const char *str= opt_date_time_formats[format_type]; - DATE_TIME_FORMAT *format; if (!str) // No specified format { @@ -2075,6 +2074,8 @@ static int init_common_variables(const char *conf_file_name, int argc, max_system_variables.pseudo_thread_id= (ulong)~0; start_time=time((time_t*) 0); + if (init_thread_environment()) + return 1; mysql_init_variables(); #ifdef OS2 @@ -2117,8 +2118,6 @@ static int init_common_variables(const char *conf_file_name, int argc, load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; get_options(argc,argv); - if (init_thread_environment()) - return 1; if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) strcat(server_version,"-log"); DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, @@ -2379,7 +2378,7 @@ Now disabling --log-slave-updates."); /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache); /* We must set dflt_key_cache in case we are using ISAM tables */ - dflt_keycache= &sql_key_cache->cache; + dflt_key_cache= sql_key_cache; #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory && !geteuid()) @@ -3374,35 +3373,22 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg) #ifdef HAVE_SMEM pthread_handler_decl(handle_connections_shared_memory,arg) { -/* - event_connect_request is event object for start connection actions - event_connect_answer is event object for confirm, that server put data - handle_connect_file_map is file-mapping object, use for create shared memory - handle_connect_map is pointer on shared memory - handle_map is pointer on shared memory for client - event_server_wrote, - event_server_read, - event_client_wrote, - event_client_read are events for transfer data between server and client - handle_file_map is file-mapping object, use for create shared memory -*/ - HANDLE handle_connect_file_map = NULL; - char *handle_connect_map = NULL; - HANDLE event_connect_request = NULL; - HANDLE event_connect_answer = NULL; - ulong smem_buffer_length = shared_memory_buffer_length + 4; - ulong connect_number = 1; + /* file-mapping object, use for create shared memory */ + HANDLE handle_connect_file_map= 0; + char *handle_connect_map= 0; // pointer on shared memory + HANDLE event_connect_request= 0; // for start connection actions + HANDLE event_connect_answer= 0; + ulong smem_buffer_length= shared_memory_buffer_length + 4; + ulong connect_number= 1; my_bool error_allow; - THD *thd; char tmp[63]; char *suffix_pos; char connect_number_char[22], *p; - + const char *errmsg= 0; my_thread_init(); DBUG_ENTER("handle_connections_shared_memorys"); DBUG_PRINT("general",("Waiting for allocated shared memory.")); - /* The name of event and file-mapping events create agree next rule: shared_memory_base_name+unique_part @@ -3410,166 +3396,165 @@ pthread_handler_decl(handle_connections_shared_memory,arg) shared_memory_base_name is unique value for each server unique_part is unique value for each object (events and file-mapping) */ - suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS); + suffix_pos= strxmov(tmp,shared_memory_base_name,"_",NullS); strmov(suffix_pos, "CONNECT_REQUEST"); - if ((event_connect_request = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_connect_request= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create shared memory service ! The request event don't create."); + errmsg= "Could not create request event"; goto error; } strmov(suffix_pos, "CONNECT_ANSWER"); - if ((event_connect_answer = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_connect_answer= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create shared memory service ! The answer event don't create."); + errmsg="Could not create answer event"; goto error; } strmov(suffix_pos, "CONNECT_DATA"); - if ((handle_connect_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE, - 0,sizeof(connect_number),tmp)) == 0) + if ((handle_connect_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0, + PAGE_READWRITE, + 0,sizeof(connect_number), + tmp)) == 0) { - sql_perror("Can't create shared memory service ! File mapping don't create."); + errmsg= "Could not create file mapping"; goto error; } - if ((handle_connect_map = (char *)MapViewOfFile(handle_connect_file_map,FILE_MAP_WRITE,0,0, - sizeof(DWORD))) == 0) + if ((handle_connect_map= (char *)MapViewOfFile(handle_connect_file_map, + FILE_MAP_WRITE,0,0, + sizeof(DWORD))) == 0) { - sql_perror("Can't create shared memory service ! Map of memory don't create."); + errmsg= "Could not create shared memory service"; goto error; } - while (!abort_loop) { -/* - Wait a request from client -*/ + /* Wait a request from client */ WaitForSingleObject(event_connect_request,INFINITE); - error_allow = FALSE; - HANDLE handle_client_file_map = NULL; - char *handle_client_map = NULL; - HANDLE event_client_wrote = NULL; - HANDLE event_client_read = NULL; - HANDLE event_server_wrote = NULL; - HANDLE event_server_read = NULL; + HANDLE handle_client_file_map= 0; + char *handle_client_map= 0; + HANDLE event_client_wrote= 0; + HANDLE event_client_read= 0; // for transfer data server <-> client + HANDLE event_server_wrote= 0; + HANDLE event_server_read= 0; + THD *thd= 0; - p = int2str(connect_number, connect_number_char, 10); -/* - The name of event and file-mapping events create agree next rule: - shared_memory_base_name+unique_part+number_of_connection - Where: - shared_memory_base_name is uniquel value for each server - unique_part is unique value for each object (events and file-mapping) - number_of_connection is number of connection between server and client -*/ - suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,"_",NullS); + p= int2str(connect_number, connect_number_char, 10); + /* + The name of event and file-mapping events create agree next rule: + shared_memory_base_name+unique_part+number_of_connection + Where: + shared_memory_base_name is uniquel value for each server + unique_part is unique value for each object (events and file-mapping) + number_of_connection is connection-number between server and client + */ + suffix_pos= strxmov(tmp,shared_memory_base_name,"_",connect_number_char, + "_",NullS); strmov(suffix_pos, "DATA"); - if ((handle_client_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL, - PAGE_READWRITE,0,smem_buffer_length,tmp)) == 0) + if ((handle_client_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0, + PAGE_READWRITE,0, + smem_buffer_length, + tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! File mapping don't create."); - error_allow = TRUE; + errmsg= "Could not create file mapping"; goto errorconn; } - if ((handle_client_map = (char*)MapViewOfFile(handle_client_file_map,FILE_MAP_WRITE,0,0,smem_buffer_length)) == 0) + if ((handle_client_map= (char*)MapViewOfFile(handle_client_file_map, + FILE_MAP_WRITE,0,0, + smem_buffer_length)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! Map of memory don't create."); - error_allow = TRUE; + errmsg= "Could not create memory map"; goto errorconn; } - strmov(suffix_pos, "CLIENT_WROTE"); - if ((event_client_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_client_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! CW event don't create."); - error_allow = TRUE; + errmsg= "Could not create client write event"; goto errorconn; } - strmov(suffix_pos, "CLIENT_READ"); - if ((event_client_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_client_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! CR event don't create."); - error_allow = TRUE; + errmsg= "Could not create client read event"; goto errorconn; } - strmov(suffix_pos, "SERVER_READ"); - if ((event_server_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_server_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! SR event don't create."); - error_allow = TRUE; + errmsg= "Could not create server read event"; goto errorconn; } - strmov(suffix_pos, "SERVER_WROTE"); - if ((event_server_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) + if ((event_server_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0) { - sql_perror("Can't create connection with client in shared memory service ! SW event don't create."); - error_allow = TRUE; + errmsg= "Could not create server write event"; goto errorconn; } - - if (abort_loop) break; - if ( !(thd = new THD)) - { - error_allow = TRUE; + if (abort_loop) goto errorconn; - } - -/* -Send number of connection to client -*/ + if (!(thd= new THD)) + goto errorconn; + /* Send number of connection to client */ int4store(handle_connect_map, connect_number); - -/* - Send number of connection to client -*/ if (!SetEvent(event_connect_answer)) { - sql_perror("Can't create connection with client in shared memory service ! Can't send answer event."); - error_allow = TRUE; + errmsg= "Could not send answer event"; goto errorconn; } - -/* - Set event that client should receive data -*/ + /* Set event that client should receive data */ if (!SetEvent(event_client_read)) { - sql_perror("Can't create connection with client in shared memory service ! Can't set client to read's mode."); - error_allow = TRUE; + errmsg= "Could not set client to read mode"; goto errorconn; } - if (!(thd->net.vio = vio_new_win32shared_memory(&thd->net,handle_client_file_map,handle_client_map,event_client_wrote, - event_client_read,event_server_wrote,event_server_read)) || - my_net_init(&thd->net, thd->net.vio)) + if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net, + handle_client_file_map, + handle_client_map, + event_client_wrote, + event_client_read, + event_server_wrote, + event_server_read)) || + my_net_init(&thd->net, thd->net.vio)) { close_connection(thd, ER_OUT_OF_RESOURCES, 1); - delete thd; - error_allow = TRUE; + errmsg= 0; + goto errorconn; } - /* host name is unknown */ + thd->host= my_strdup(my_localhost,MYF(0)); /* Host is unknown */ + create_new_thread(thd); + connect_number++; + continue; + errorconn: - if (error_allow) + /* Could not form connection; Free used handlers/memort and retry */ + if (errmsg) { - if (!handle_client_map) UnmapViewOfFile(handle_client_map); - if (!handle_client_file_map) CloseHandle(handle_client_file_map); - if (!event_server_wrote) CloseHandle(event_server_wrote); - if (!event_server_read) CloseHandle(event_server_read); - if (!event_client_wrote) CloseHandle(event_client_wrote); - if (!event_client_read) CloseHandle(event_client_read); - continue; + char buff[180]; + strxmov(buff, "Can't create shared memory connection: ", errmsg, ".", + NullS); + sql_perror(buff); } - thd->host = my_strdup(my_localhost,MYF(0)); /* Host is unknown */ - create_new_thread(thd); - uint4korr(connect_number++); + if (handle_client_file_map) CloseHandle(handle_client_file_map); + if (handle_client_map) UnmapViewOfFile(handle_client_map); + if (event_server_wrote) CloseHandle(event_server_wrote); + if (event_server_read) CloseHandle(event_server_read); + if (event_client_wrote) CloseHandle(event_client_wrote); + if (event_client_read) CloseHandle(event_client_read); + delete thd; } + + /* End shared memory handling */ error: - if (!handle_connect_map) UnmapViewOfFile(handle_connect_map); - if (!handle_connect_file_map) CloseHandle(handle_connect_file_map); - if (!event_connect_answer) CloseHandle(event_connect_answer); - if (!event_connect_request) CloseHandle(event_connect_request); + if (errmsg) + { + char buff[180]; + strxmov(buff, "Can't create shared memory service: ", errmsg, ".", NullS); + sql_perror(buff); + } + if (handle_connect_map) UnmapViewOfFile(handle_connect_map); + if (handle_connect_file_map) CloseHandle(handle_connect_file_map); + if (event_connect_answer) CloseHandle(event_connect_answer); + if (event_connect_request) CloseHandle(event_connect_request); decrement_handler_count(); DBUG_RETURN(0); @@ -4370,26 +4355,26 @@ log and this option does nothing anymore.", IO_SIZE, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", - (gptr*) &dflt_key_cache_var.buff_size, + (gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", - (gptr*) &dflt_key_cache_var.block_size, + (gptr*) &dflt_key_cache_var.param_block_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", - (gptr*) &dflt_key_cache_var.division_limit, + (gptr*) &dflt_key_cache_var.param_division_limit, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"key_cache_division_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", - (gptr*) &dflt_key_cache_var.age_threshold, + (gptr*) &dflt_key_cache_var.param_age_threshold, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, @@ -4811,17 +4796,17 @@ struct show_var_st status_vars[]= { {"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG}, {"Handler_update", (char*) &ha_update_count, SHOW_LONG}, {"Handler_write", (char*) &ha_write_count, SHOW_LONG}, - {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.blocks_changed, + {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG}, - {"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used, + {"Key_blocks_used", (char*) &dflt_key_cache_var.global_blocks_used, SHOW_KEY_CACHE_LONG}, - {"Key_read_requests", (char*) &dflt_key_cache_var.cache_r_requests, + {"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests, SHOW_KEY_CACHE_LONG}, - {"Key_reads", (char*) &dflt_key_cache_var.cache_read, + {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, - {"Key_write_requests", (char*) &dflt_key_cache_var.cache_w_requests, + {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, - {"Key_writes", (char*) &dflt_key_cache_var.cache_write, + {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST}, @@ -4894,8 +4879,8 @@ struct show_var_st status_vars[]= { static void print_version(void) { - printf("%s Ver %s for %s on %s\n",my_progname, - server_version,SYSTEM_TYPE,MACHINE_TYPE); + printf("%s Ver %s for %s on %s (%s)\n",my_progname, + server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } static void use_help(void) @@ -5662,18 +5647,18 @@ mysql_getopt_value(const char *keyname, uint key_length, case OPT_KEY_CACHE_DIVISION_LIMIT: case OPT_KEY_CACHE_AGE_THRESHOLD: { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; if (!(key_cache= get_or_create_key_cache(keyname, key_length))) exit(1); switch (option->id) { case OPT_KEY_BUFFER_SIZE: - return (gptr*) &key_cache->buff_size; + return (gptr*) &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: - return (gptr*) &key_cache->block_size; + return (gptr*) &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: - return (gptr*) &key_cache->division_limit; + return (gptr*) &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: - return (gptr*) &key_cache->age_threshold; + return (gptr*) &key_cache->param_age_threshold; } } } @@ -5854,63 +5839,80 @@ static void fix_paths(void) */ #ifdef SET_RLIMIT_NOFILE + +#ifndef RLIM_INFINITY +#define RLIM_INFINITY ((uint) 0xffffffff) +#endif + static uint set_maximum_open_files(uint max_file_limit) { struct rlimit rlimit; - ulong old_cur; + uint old_cur; + DBUG_ENTER("set_maximum_open_files"); + DBUG_PRINT("enter",("files: %u", max_file_limit)); if (!getrlimit(RLIMIT_NOFILE,&rlimit)) { - old_cur=rlimit.rlim_cur; - if (rlimit.rlim_cur >= max_file_limit) // Nothing to do - return rlimit.rlim_cur; /* purecov: inspected */ - rlimit.rlim_cur=rlimit.rlim_max=max_file_limit; + old_cur= (uint) rlimit.rlim_cur; + DBUG_PRINT("info", ("rlim_cur: %u rlim_max: %u", + (uint) rlimit.rlim_cur, + (uint) rlimit.rlim_max)); + if (rlimit.rlim_cur >= max_file_limit || + rlimit.rlim_cur == RLIM_INFINITY) + DBUG_RETURN(rlimit.rlim_cur); /* purecov: inspected */ + rlimit.rlim_cur= rlimit.rlim_max= max_file_limit; if (setrlimit(RLIMIT_NOFILE,&rlimit)) { if (global_system_variables.log_warnings) - sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)", + sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %u (request: %u)", old_cur, max_file_limit); /* purecov: inspected */ - max_file_limit=old_cur; + max_file_limit= old_cur; } else { + rlimit.rlim_cur= 0; // Safety if next call fails (void) getrlimit(RLIMIT_NOFILE,&rlimit); - if ((uint) rlimit.rlim_cur != max_file_limit && + DBUG_PRINT("info", ("rlim_cur: %u", (uint) rlimit.rlim_cur)); + if ((uint) rlimit.rlim_cur < max_file_limit && global_system_variables.log_warnings) - sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)", - (ulong) rlimit.rlim_cur, + sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %u (request: %u)", + (uint) rlimit.rlim_cur, max_file_limit); /* purecov: inspected */ - max_file_limit=rlimit.rlim_cur; + max_file_limit= (uint) rlimit.rlim_cur; } } - return max_file_limit; + DBUG_PRINT("exit",("max_file_limit: %u", max_file_limit)); + DBUG_RETURN(max_file_limit); } #endif + #ifdef OS2 static uint set_maximum_open_files(uint max_file_limit) { - LONG cbReqCount; - ULONG cbCurMaxFH, cbCurMaxFH0; - APIRET ulrc; - - // get current limit - cbReqCount = 0; - DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); - - // set new limit - cbReqCount = max_file_limit - cbCurMaxFH0; - ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); - if (ulrc) { - sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", - cbCurMaxFH0); - cbCurMaxFH = cbCurMaxFH0; - } - - return cbCurMaxFH; + LONG cbReqCount; + ULONG cbCurMaxFH, cbCurMaxFH0; + APIRET ulrc; + DBUG_ENTER("set_maximum_open_files"); + + // get current limit + cbReqCount = 0; + DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); + + // set new limit + cbReqCount = max_file_limit - cbCurMaxFH0; + ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); + if (ulrc) { + sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", + cbCurMaxFH0); + cbCurMaxFH = cbCurMaxFH0; + } + + DBUG_RETURN(cbCurMaxFH); } #endif + /* Return a bitfield from a string of substrings separated by ',' returns ~(ulong) 0 on error. diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 593ed7c6f53..1e333e507bb 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -68,7 +68,7 @@ public: {} inline bool is_same(SEL_ARG *arg) { - if (type != arg->type) + if (type != arg->type || part != arg->part) return 0; if (type != KEY_RANGE) return 1; diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index ce650701347..03be9624cd8 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -83,7 +83,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) table_map removed_tables= 0, outer_tables= 0, used_tables= 0; table_map where_tables= 0; Item *item; - COND *org_conds= conds; int error; if (conds) diff --git a/sql/protocol.cc b/sql/protocol.cc index c28c1e1abb8..89aa7203e17 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -298,6 +298,12 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_length(pos, (ulonglong) id); if (thd->client_capabilities & CLIENT_PROTOCOL_41) { + DBUG_PRINT("info", + ("affected_rows: %lu id: %lu status: %u warning_count: %u", + (ulong) affected_rows, + (ulong) id, + (uint) (thd->server_status & 0xffff), + (uint) thd->total_warn_count)); int2store(pos,thd->server_status); pos+=2; @@ -315,6 +321,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_data((char*) pos, message, strlen(message)); VOID(my_net_write(net,buff,(uint) (pos-buff))); VOID(net_flush(net)); + /* We can't anymore send an error to the client */ + thd->net.report_error= 0; DBUG_VOID_RETURN; } @@ -494,7 +502,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) char buff[80]; String tmp((char*) buff,sizeof(buff),&my_charset_bin); Protocol_simple prot(thd); - String *packet= prot.storage_packet(); + String *local_packet= prot.storage_packet(); CHARSET_INFO *thd_charset= thd->variables.character_set_results; DBUG_ENTER("send_fields"); @@ -531,10 +539,10 @@ bool Protocol::send_fields(List<Item> *list, uint flag) cs, thd_charset) || prot.store(field.org_col_name, (uint) strlen(field.org_col_name), cs, thd_charset) || - packet->realloc(packet->length()+12)) + local_packet->realloc(local_packet->length()+12)) goto err; /* Store fixed length fields */ - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); *pos++= 12; // Length of packed fields int2store(pos, field.charsetnr); int4store(pos+2, field.length); @@ -551,9 +559,9 @@ bool Protocol::send_fields(List<Item> *list, uint flag) cs, thd_charset) || prot.store(field.col_name, (uint) strlen(field.col_name), cs, thd_charset) || - packet->realloc(packet->length()+10)) + local_packet->realloc(local_packet->length()+10)) goto err; - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); #ifdef TO_BE_DELETED_IN_6 if (!(thd->client_capabilities & CLIENT_LONG_FLAG)) @@ -580,7 +588,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag) pos+= 10; } } - packet->length((uint) (pos - packet->ptr())); + local_packet->length((uint) (pos - local_packet->ptr())); if (flag & 2) item->send(&prot, &tmp); // Send default value if (prot.write()) diff --git a/sql/protocol.h b/sql/protocol.h index 6aa9b6414ae..d2ec08c3cf4 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -44,9 +44,9 @@ protected: #endif public: Protocol() {} - Protocol(THD *thd) { init(thd); } + Protocol(THD *thd_arg) { init(thd_arg); } virtual ~Protocol() {} - void init(THD* thd); + void init(THD* thd_arg); virtual bool send_fields(List<Item> *list, uint flag); bool send_records_num(List<Item> *list, ulonglong records); bool store(I_List<i_string> *str_list); @@ -93,7 +93,7 @@ class Protocol_simple :public Protocol { public: Protocol_simple() {} - Protocol_simple(THD *thd) :Protocol(thd) {} + Protocol_simple(THD *thd_arg) :Protocol(thd_arg) {} virtual void prepare_for_resend(); virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -118,7 +118,7 @@ private: uint bit_fields; public: Protocol_prep() {} - Protocol_prep(THD *thd) :Protocol(thd) {} + Protocol_prep(THD *thd_arg) :Protocol(thd_arg) {} virtual bool prepare_for_send(List<Item> *item_list); virtual void prepare_for_resend(); #ifdef EMBEDDED_LIBRARY @@ -151,7 +151,7 @@ public: ulong row_count; Protocol_cursor() {} - Protocol_cursor(THD *thd, MEM_ROOT *ini_alloc) :Protocol_simple(thd), alloc(ini_alloc) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} bool prepare_for_send(List<Item> *item_list) { row_count= 0; @@ -171,7 +171,6 @@ void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); void send_eof(THD *thd, bool no_flush=0); bool send_old_password_request(THD *thd); -char *net_store_length(char *packet,ulonglong length); char *net_store_length(char *packet,uint length); char *net_store_data(char *to,const char *from, uint length); char *net_store_data(char *to,int32 from); diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index abb391fbd67..749b66785d4 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -30,7 +30,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) { List_iterator_fast<Item> it(*list); Item *item; - MYSQL_FIELD *field, *client_field; + MYSQL_FIELD *client_field; DBUG_ENTER("send_fields"); if (prepare_for_send(list)) @@ -73,9 +73,9 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) String tmp(buff, sizeof(buff), default_charset_info), *res; if (!(res=item->val_str(&tmp))) - client_field->def= strdup_root(alloc, ""); + client_field->def= (char*) ""; else - client_field->def= strdup_root(alloc, tmp.ptr()); + client_field->def= strmake_root(alloc, res->ptr(), res->length()); } else client_field->def=0; @@ -98,23 +98,23 @@ bool Protocol_cursor::write() MYSQL_FIELD *cur_field= fields; MYSQL_FIELD *fields_end= fields + field_count; MYSQL_ROWS *new_record; - byte **data; + byte **data_tmp; byte *to; new_record= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (field_count + 1)*sizeof(char *) + packet->length()); if (!new_record) goto err; - data= (byte **)(new_record + 1); - new_record->data= (char **)data; + data_tmp= (byte **)(new_record + 1); + new_record->data= (char **)data_tmp; - to= (byte *)data + (field_count + 1)*sizeof(char *); + to= (byte *)data_tmp + (field_count + 1)*sizeof(char *); - for (; cur_field < fields_end; ++cur_field, ++data) + for (; cur_field < fields_end; ++cur_field, ++data_tmp) { if ((len= net_field_length((uchar **)&cp)) == 0) { - *data= 0; + *data_tmp= 0; } else { @@ -123,7 +123,7 @@ bool Protocol_cursor::write() // TODO error signal send_error(thd, CR_MALFORMED_PACKET); return TRUE; } - *data= to; + *data_tmp= to; memcpy(to,(char*) cp,len); to[len]=0; to+=len+1; @@ -132,7 +132,7 @@ bool Protocol_cursor::write() cur_field->max_length=len; } } - *data= 0; + *data_tmp= 0; *prev_record= new_record; prev_record= &new_record->next; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 4d8d1380139..0efe57af0b0 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -254,7 +254,7 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg) it is reworked. Event's log_pos used to be preserved through log-slave-updates to make code in repl_failsafe.cc work (this function, SHOW NEW MASTER); but on the other side it caused unexpected - values in Exec_master_log_pos in A->B->C replication setup, + values in Exec_Master_Log_Pos in A->B->C replication setup, synchronization problems in master_pos_wait(), ... So we (Dmitri & Guilhem) removed it. @@ -623,7 +623,6 @@ err: int show_slave_hosts(THD* thd) { List<Item> field_list; - NET* net = &thd->net; Protocol *protocol= thd->protocol; DBUG_ENTER("show_slave_hosts"); @@ -909,7 +908,12 @@ int load_master_data(THD* thd) // don't hit the magic number if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE) active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; - flush_master_info(active_mi); + /* + Relay log's IO_CACHE may not be inited (even if we are sure that some + host was specified; there could have been a problem when replication + started, which led to relay log's IO_CACHE to not be inited. + */ + flush_master_info(active_mi, 0); } mysql_free_result(master_status_res); } diff --git a/sql/set_var.cc b/sql/set_var.cc index dfbe7d60741..5912862f23b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -93,7 +93,7 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length); +static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); @@ -145,14 +145,14 @@ sys_var_thd_ulong sys_join_buffer_size("join_buffer_size", &SV::join_buff_size); sys_var_key_buffer_size sys_key_buffer_size("key_buffer_size"); sys_var_key_cache_long sys_key_cache_block_size("key_cache_block_size", - offsetof(KEY_CACHE_VAR, - block_size)); + offsetof(KEY_CACHE, + param_block_size)); sys_var_key_cache_long sys_key_cache_division_limit("key_cache_division_limit", - offsetof(KEY_CACHE_VAR, - division_limit)); + offsetof(KEY_CACHE, + param_division_limit)); sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold", - offsetof(KEY_CACHE_VAR, - age_threshold)); + offsetof(KEY_CACHE, + param_age_threshold)); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings); @@ -550,7 +550,6 @@ struct show_var_st init_vars[]= { {"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR}, {"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL}, {"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR}, - {"bdb_version", (char*) DB_VERSION_STRING, SHOW_CHAR}, #endif {sys_binlog_cache_size.name,(char*) &sys_binlog_cache_size, SHOW_SYS}, {sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS}, @@ -741,6 +740,12 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {"version", server_version, SHOW_CHAR}, +#ifdef HAVE_BERKELEY_DB + {"version_bdb", (char*) DB_VERSION_STRING, SHOW_CHAR}, +#endif + {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, + {"version_compile_machine", (char*) MACHINE_TYPE, SHOW_CHAR}, + {"version_compile_os", (char*) SYSTEM_TYPE, SHOW_CHAR}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {NullS, NullS, SHOW_LONG} }; @@ -1779,15 +1784,14 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type) LEX_STRING default_key_cache_base= {(char *) "default", 7 }; -static KEY_CACHE_VAR zero_key_cache= - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static KEY_CACHE zero_key_cache; -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) +KEY_CACHE *get_key_cache(LEX_STRING *cache_name) { safe_mutex_assert_owner(&LOCK_global_system_variables); if (!cache_name || ! cache_name->length) cache_name= &default_key_cache_base; - return ((KEY_CACHE_VAR*) find_named(&key_caches, + return ((KEY_CACHE*) find_named(&key_caches, cache_name->str, cache_name->length, 0)); } @@ -1795,7 +1799,7 @@ KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - KEY_CACHE_VAR *key_cache= get_key_cache(base); + KEY_CACHE *key_cache= get_key_cache(base); if (!key_cache) key_cache= &zero_key_cache; return (byte*) key_cache + offset ; @@ -1806,7 +1810,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; LEX_STRING *base_name= &var->base; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; bool error= 0; /* If no basename, assume it's for the key cache named 'default' */ @@ -1841,14 +1845,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) if (key_cache == sql_key_cache) goto end; // Ignore default key cache - if (key_cache->cache) // If initied + if (key_cache->key_cache_inited) // If initied { /* Move tables using this key cache to the default key cache and clear the old key cache. */ NAMED_LIST *list; - key_cache= (KEY_CACHE_VAR *) find_named(&key_caches, base_name->str, + key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str, base_name->length, &list); key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); @@ -1863,13 +1867,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) goto end; } - key_cache->buff_size= (ulonglong) getopt_ull_limit_value(tmp, option_limits); + key_cache->param_buff_size= + (ulonglong) getopt_ull_limit_value(tmp, option_limits); /* If key cache didn't existed initialize it, else resize it */ key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) error= (bool) (ha_init_key_cache("", key_cache)); else error= (bool)(ha_resize_key_cache(key_cache)); @@ -1885,7 +1890,7 @@ end: bool sys_var_key_cache_long::update(THD *thd, set_var *var) { - ulong tmp= var->value->val_int(); + ulong tmp= (ulong) var->value->val_int(); LEX_STRING *base_name= &var->base; bool error= 0; @@ -1893,7 +1898,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var) base_name= &default_key_cache_base; pthread_mutex_lock(&LOCK_global_system_variables); - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); + KEY_CACHE *key_cache= get_key_cache(base_name); if (!key_cache && !(key_cache= create_key_cache(base_name->str, base_name->length))) @@ -2439,7 +2444,6 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, ulong val; char buff[256]; String tmp(buff, sizeof(buff), &my_charset_latin1); - my_bool found= 0; tmp.length(0); val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : @@ -2569,13 +2573,13 @@ void delete_elements(I_List<NAMED_LIST> *list, /* Key cache functions */ -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) +static KEY_CACHE *create_key_cache(const char *name, uint length) { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("create_key_cache"); DBUG_PRINT("enter",("name: %.*s", length, name)); - if ((key_cache= (KEY_CACHE_VAR*) my_malloc(sizeof(KEY_CACHE_VAR), + if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE), MYF(MY_ZEROFILL | MY_WME)))) { if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) @@ -2591,19 +2595,19 @@ static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) We don't set 'buff_size' as this is used to enable the key cache */ - key_cache->block_size= dflt_key_cache_var.block_size; - key_cache->division_limit= dflt_key_cache_var.division_limit; - key_cache->age_threshold= dflt_key_cache_var.age_threshold; + key_cache->param_block_size= dflt_key_cache_var.param_block_size; + key_cache->param_division_limit= dflt_key_cache_var.param_division_limit; + key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold; } } DBUG_RETURN(key_cache); } -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) +KEY_CACHE *get_or_create_key_cache(const char *name, uint length) { LEX_STRING key_cache_name; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; key_cache_name.str= (char *) name; key_cache_name.length= length; @@ -2615,21 +2619,21 @@ KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) } -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +void free_key_cache(const char *name, KEY_CACHE *key_cache) { ha_end_key_cache(key_cache); my_free((char*) key_cache, MYF(0)); } -bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)) +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) { I_List_iterator<NAMED_LIST> it(key_caches); NAMED_LIST *element; while ((element= it++)) { - KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) element->data; + KEY_CACHE *key_cache= (KEY_CACHE *) element->data; func(element->name, key_cache); } return 0; diff --git a/sql/set_var.h b/sql/set_var.h index a4c3b546fe0..58ae53190e0 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -560,7 +560,7 @@ class sys_var_key_buffer_size :public sys_var_key_cache_param { public: sys_var_key_buffer_size(const char *name_arg) - :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE_VAR, buff_size)) + :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE, param_buff_size)) {} bool update(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_LONGLONG; } @@ -755,7 +755,7 @@ public: my_free((char*) name, MYF(0)); } friend bool process_key_caches(int (* func) (const char *name, - KEY_CACHE_VAR *)); + KEY_CACHE *)); friend void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, gptr)); }; @@ -788,6 +788,9 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, NAMED_LIST **found); /* key_cache functions */ -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name); -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache); +KEY_CACHE *get_key_cache(LEX_STRING *cache_name); +KEY_CACHE *get_or_create_key_cache(const char *name, uint length); +void free_key_cache(const char *name, KEY_CACHE *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); +void delete_elements(I_List<NAMED_LIST> *list, + void (*free_element)(const char*, gptr)); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 4dba54823ec..5cf1dd2a47c 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -296,6 +296,7 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 07cbc84be14..69e14c6acf3 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -290,6 +290,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 8731c94fcdd..386ff34ef59 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -298,6 +298,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 9f93925a1ac..2e159d40e40 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -287,6 +287,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 0365cb776fb..e03f60ac040 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -292,6 +292,7 @@ character-set=latin7 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 7a8ff9d3c8c..b3591e2f4ab 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -287,6 +287,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index e465cb3f899..6a404b2083f 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -299,6 +299,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 6bbcae1bca0..47cb5125dbb 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -287,6 +287,7 @@ character-set=greek "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 73203da9826..cbe34d19fe1 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -289,6 +289,7 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index a99e381521e..6f7aaaec669 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -287,6 +287,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index fb85ae593d3..ee9a546cb11 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -289,6 +289,7 @@ character-set=ujis "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 50415a9b051..6aa94a4482a 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -287,6 +287,7 @@ character-set=euckr "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 9409c82e06e..65faac4365c 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -289,6 +289,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index f14abb40111..26d0bae406f 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -289,6 +289,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index dcf2369f727..55e3d9dc1dc 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -291,6 +291,7 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index ea002431020..519434c24b5 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -288,6 +288,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 8f279b86731..5c6ecd8ddd7 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -291,6 +291,7 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index b4e33c2e26e..6f0dd2d9ac7 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -289,6 +289,7 @@ character-set=koi8r "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 074714047de..e9be8102e0e 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -282,6 +282,7 @@ character-set=cp1250 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 39aca7893a9..af3eae4f97b 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -295,6 +295,7 @@ character-set=latin2 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 465fc98d60f..b799ce54bec 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -289,6 +289,7 @@ character-set=latin1 "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index a1e06d2bde7..40fc31dfdb3 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -287,6 +287,7 @@ character-set=latin1 "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu", "Kolumn '%-.64s' kan inte vara del av ett FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index ddf632e0dbd..e0d42d6264b 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -292,6 +292,7 @@ character-set=koi8u "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", "Unknown key cache '%-.100s'", +"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Can't create a %s from within another stored routine" "%s %s already exists" "%s %s does not exist" diff --git a/sql/slave.cc b/sql/slave.cc index c531d3cc4f7..695e0b2c2c4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1367,32 +1367,9 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) } /* - The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. It is - notable that the last kilobytes of it (8 kB for example) may live in - memory, not on disk (depending on what the thread using it does). While - this is efficient, it has a side-effect one must know: - The size of the relay log on disk (displayed by 'ls -l' on Unix) can be a - few kilobytes less than one would expect by doing SHOW SLAVE STATUS; this - happens when only the IO thread is started (not the SQL thread). The - "missing" kilobytes are in memory, are preserved during 'STOP SLAVE; START - SLAVE IO_THREAD', and are flushed to disk when the slave's mysqld stops. So - this does not cause any bug. Example of how disk size grows by leaps: - - Read_Master_Log_Pos: 7811 -rw-rw---- 1 guilhem qq 4 Jun 5 16:19 gbichot2-relay-bin.002 - ...later... - Read_Master_Log_Pos: 9744 -rw-rw---- 1 guilhem qq 8192 Jun 5 16:27 gbichot2-relay-bin.002 - - See how 4 is less than 7811 and 8192 is less than 9744. - - WARNING: this is risky because the slave can stay like this for a long - time; then if it has a power failure, master.info says the I/O thread has - read until 9744 while the relay-log contains only until 8192 (the - in-memory part from 8192 to 9744 has been lost), so the SQL slave thread - will miss some events, silently breaking replication. - Ideally we would like to flush master.info only when we know that the relay - log has no in-memory tail. - Note that the above problem may arise only when only the IO thread is - started, which is unlikely. + The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. + Note that the I/O thread flushes it to disk after writing every event, in + flush_master_info(mi, 1). */ /* @@ -1578,7 +1555,7 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) save_proc_info= thd->enter_cond(&rli->log_space_cond, &rli->log_space_lock, "\ -Waiting for the SQL slave thread to free enough relay log space"); +Waiting for the slave SQL thread to free enough relay log space"); while (rli->log_space_limit < rli->log_space_total && !(slave_killed=io_slave_killed(thd,mi)) && !rli->ignore_log_space_limit) @@ -1849,7 +1826,7 @@ file '%s')", fname); mi->inited = 1; // now change cache READ -> WRITE - must do this before flush_master_info reinit_io_cache(&mi->file, WRITE_CACHE,0L,0,1); - if ((error=test(flush_master_info(mi)))) + if ((error=test(flush_master_info(mi, 1)))) sql_print_error("Failed to flush master info file"); pthread_mutex_unlock(&mi->data_lock); DBUG_RETURN(error); @@ -1964,7 +1941,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->user))); field_list.push_back(new Item_return_int("Master_Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Connect_retry", 10, + field_list.push_back(new Item_return_int("Connect_Retry", 10, MYSQL_TYPE_LONG)); field_list.push_back(new Item_empty_string("Master_Log_File", FN_REFLEN)); @@ -1978,24 +1955,24 @@ int show_master_info(THD* thd, MASTER_INFO* mi) FN_REFLEN)); field_list.push_back(new Item_empty_string("Slave_IO_Running", 3)); field_list.push_back(new Item_empty_string("Slave_SQL_Running", 3)); - field_list.push_back(new Item_empty_string("Replicate_do_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_do_table", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23)); - field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24)); - field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table", + field_list.push_back(new Item_empty_string("Replicate_Do_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Do_Table", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_Table", 23)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Do_Table", 24)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Ignore_Table", 28)); - field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_error", 20)); - field_list.push_back(new Item_return_int("Skip_counter", 10, + field_list.push_back(new Item_return_int("Last_Errno", 4, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string("Last_Error", 20)); + field_list.push_back(new Item_return_int("Skip_Counter", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Exec_master_log_pos", 10, + field_list.push_back(new Item_return_int("Exec_Master_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_return_int("Relay_log_space", 10, + field_list.push_back(new Item_return_int("Relay_Log_Space", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Until_condition", 6)); + field_list.push_back(new Item_empty_string("Until_Condition", 6)); field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Until_Log_pos", 10, + field_list.push_back(new Item_return_int("Until_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); field_list.push_back(new Item_empty_string("Master_SSL_Allowed", 7)); field_list.push_back(new Item_empty_string("Master_SSL_CA_File", @@ -2008,7 +1985,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->ssl_cipher))); field_list.push_back(new Item_empty_string("Master_SSL_Key", sizeof(mi->ssl_key))); - field_list.push_back(new Item_return_int("Seconds_behind_master", 10, + field_list.push_back(new Item_return_int("Seconds_Behind_Master", 10, MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, 1)) @@ -2099,7 +2076,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) } -bool flush_master_info(MASTER_INFO* mi) +bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache) { IO_CACHE* file = &mi->file; char lbuf[22]; @@ -2107,6 +2084,30 @@ bool flush_master_info(MASTER_INFO* mi) DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos)); /* + Flush the relay log to disk. If we don't do it, then the relay log while + have some part (its last kilobytes) in memory only, so if the slave server + dies now, with, say, from master's position 100 to 150 in memory only (not + on disk), and with position 150 in master.info, then when the slave + restarts, the I/O thread will fetch binlogs from 150, so in the relay log + we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the + SQL thread will jump from 100 to 150, and replication will silently break. + + When we come to this place in code, relay log may or not be initialized; + the caller is responsible for setting 'flush_relay_log_cache' accordingly. + */ + if (flush_relay_log_cache) + flush_io_cache(mi->rli.relay_log.get_log_file()); + + /* + We flushed the relay log BEFORE the master.info file, because if we crash + now, we will get a duplicate event in the relay log at restart. If we + flushed in the other order, we would get a hole in the relay log. + And duplicate is better than hole (with a duplicate, in later versions we + can add detection and scrap one event; with a hole there's nothing we can + do). + */ + + /* In certain cases this code may create master.info files that seems corrupted, because of extra lines filled with garbage in the end file (this happens if new contents take less space than previous @@ -2290,7 +2291,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, DBUG_PRINT("info",("Waiting for master update")); const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for the SQL slave thread to \ + "Waiting for the slave SQL thread to \ advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it @@ -2361,7 +2362,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL; /* - It's nonsense to constraint the slave threads with max_join_size; if a + It's nonsense to constrain the slave threads with max_join_size; if a query succeeded on master, we HAVE to execute it. */ thd->variables.max_join_size= HA_POS_ERROR; @@ -2981,7 +2982,7 @@ reconnect done to recover from failed read"); sql_print_error("Slave I/O thread could not queue event from master"); goto err; } - flush_master_info(mi); + flush_master_info(mi, 1); /* sure that we can flush the relay log */ /* See if the relay logs take too much space. We don't lock mi->rli.log_space_lock here; this dirty read saves time @@ -3121,9 +3122,10 @@ slave_begin: Reset errors for a clean start (otherwise, if the master is idle, the SQL thread may execute no Query_log_event, so the error will remain even though there's no problem anymore). Do not reset the master timestamp - (imagine the slave has caught everything, the STOP SLAVE and START SLAVE: as - we are not sure that we are going to receive a query, we want to remember - the last master timestamp (to say how many seconds behind we are now. + (imagine the slave has caught everything, the STOP SLAVE and START SLAVE: + as we are not sure that we are going to receive a query, we want to + remember the last master timestamp (to say how many seconds behind we are + now. But the master timestamp is reset by RESET SLAVE & CHANGE MASTER. */ clear_slave_error(rli); @@ -3796,8 +3798,6 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli) error=1; if (flush_io_cache(file)) error=1; - if (flush_io_cache(rli->cur_log)) // QQ Why this call ? - error=1; return error; } diff --git a/sql/slave.h b/sql/slave.h index f8093826f58..e42b93a47ef 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -461,7 +461,7 @@ typedef struct st_table_rule_ent int init_slave(); void init_slave_skip_errors(const char* arg); -bool flush_master_info(MASTER_INFO* mi); +bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache); bool flush_relay_log_info(RELAY_LOG_INFO* rli); int register_slave_on_master(MYSQL* mysql); int terminate_slave_threads(MASTER_INFO* mi, int thread_mask, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 78a92193b5d..f4048fd9775 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -139,6 +139,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) READ_RECORD read_record_info; MYSQL_LOCK *lock; my_bool return_val=1; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; + DBUG_ENTER("acl_init"); if (!acl_cache) @@ -198,6 +200,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) host.access= get_access(table,2); host.access= fix_rights_for_db(host.access); host.sort= get_sort(2,host.host.hostname,host.db); + if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) + { + sql_print_error("Warning: 'host' entry '%s|%s' " + "ignored in --skip-name-resolve mode.", + host.host.hostname, host.db, host.host.hostname); + continue; + } #ifndef TO_BE_REMOVED if (table->fields == 8) { // Without grant @@ -259,6 +268,14 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ACL_USER user; update_hostname(&user.host, get_field(&mem, table->field[0])); user.user= get_field(&mem, table->field[1]); + if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) + { + sql_print_error("Warning: 'user' entry '%s@%s' " + "ignored in --skip-name-resolve mode.", + user.user, user.host.hostname, user.host.hostname); + continue; + } + const char *password= get_field(&mem, table->field[2]); uint password_len= password ? strlen(password) : 0; set_user_salt(&user, password, password_len); @@ -353,6 +370,13 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) continue; } db.user=get_field(&mem, table->field[2]); + if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) + { + sql_print_error("Warning: 'db' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", + db.db, db.user, db.host.hostname, db.host.hostname); + continue; + } db.access=get_access(table,3); db.access=fix_rights_for_db(db.access); db.sort=get_sort(3,db.host.hostname,db.db,db.user); @@ -632,8 +656,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (acl_user) { /* OK. User found and password checked continue validation */ - Vio *vio=thd->net.vio; #ifdef HAVE_OPENSSL + Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; #endif @@ -1256,6 +1280,25 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, (ip && !wild_compare(ip,host->hostname,0))); } +bool hostname_requires_resolving(const char *hostname) +{ + char cur; + if (!hostname) + return false; + int namelen= strlen(hostname); + int lhlen= strlen(my_localhost); + if ((namelen == lhlen) && + !my_strnncoll(&my_charset_latin1, (const uchar *)hostname, namelen, + (const uchar *)my_localhost, strlen(my_localhost))) + return false; + for (; (cur=*hostname); hostname++) + { + if ((cur != '%') && (cur != '_') && (cur != '.') && + ((cur < '0') || (cur > '9'))) + return true; + } + return false; +} /* Update grants in the user and database privilege tables @@ -2443,6 +2486,7 @@ my_bool grant_init(THD *org_thd) MYSQL_LOCK *lock; my_bool return_val= 1; TABLE *t_table, *c_table; + bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; DBUG_ENTER("grant_init"); grant_option = FALSE; @@ -2492,13 +2536,31 @@ my_bool grant_init(THD *org_thd) do { GRANT_TABLE *mem_check; - if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || - mem_check->ok() && my_hash_insert(&column_priv_hash,(byte*) mem_check)) + if (!(mem_check=new GRANT_TABLE(t_table,c_table)) || mem_check->ok()) { /* This could only happen if we are out memory */ grant_option= FALSE; /* purecov: deadcode */ goto end_unlock; } + + if (check_no_resolve) + { + if (hostname_requires_resolving(mem_check->host)) + { + char buff[MAX_FIELD_WIDTH]; + sql_print_error("Warning: 'tables_priv' entry '%s %s@%s' " + "ignored in --skip-name-resolve mode.", + mem_check->tname, mem_check->user, + mem_check->host, mem_check->host); + continue; + } + } + + if (my_hash_insert(&column_priv_hash,(byte*) mem_check)) + { + grant_option= FALSE; + goto end_unlock; + } } while (!t_table->file->index_next(t_table->record[0])); @@ -3456,7 +3518,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) { uint counter; int result; - ACL_USER *acl_user; ACL_DB *acl_db; + ACL_DB *acl_db; TABLE_LIST tables[4]; DBUG_ENTER("mysql_revoke_all"); @@ -3470,7 +3532,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) List_iterator <LEX_USER> user_list(list); while ((lex_user=user_list++)) { - if (!(acl_user= check_acl_user(lex_user, &counter))) + if (!check_acl_user(lex_user, &counter)) { sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists", lex_user->user.str, diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 7e96f2eaff1..8b8115b10db 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -131,6 +131,7 @@ public: /* prototypes */ +bool hostname_requires_resolving(const char *hostname); my_bool acl_init(THD *thd, bool dont_read_acl_tables); void acl_reload(THD *thd); void acl_free(bool end=0); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index abaa77a4b4d..5b347267adb 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -35,7 +35,6 @@ HASH assign_cache; static int open_unireg_entry(THD *thd,TABLE *entry,const char *db, const char *name, const char *alias); static void free_cache_entry(TABLE *entry); -static void free_assign_entry(KEY_CACHE_ASMT *key_cache_asmt); static void mysql_rm_tmp_tables(void); @@ -1933,7 +1932,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, } } else if (!table_name && (item->eq(find,0) || - find->name && + find->name && item->name && !my_strcasecmp(system_charset_info, item->name,find->name))) { @@ -2024,20 +2023,6 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, DBUG_RETURN(test(thd->net.report_error)); } -/* - Mark all items in list as not fixed (0 assigned to 'fixed' field) - - SYNOPSYS - unfix_item_list() - item_list - list of items -*/ -void unfix_item_list(List<Item> item_list) -{ - Item *item; - List_iterator_fast<Item> it(item_list); - while ((item= it++)) - item->walk(&Item::remove_fixed, 0); -} /* Remap table numbers if INSERT ... SELECT diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index e5e50c180bf..0274cd700da 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -29,7 +29,7 @@ template <uint default_width> class Bitmap public: Bitmap() { init(); } Bitmap(Bitmap& from) { *this=from; } - Bitmap(uint prefix_to_set) { init(prefix_to_set); } + explicit Bitmap(uint prefix_to_set) { init(prefix_to_set); } void init() { bitmap_init(&map, buffer, default_width, 0); } void init(uint prefix_to_set) { init(); set_prefix(prefix_to_set); } uint length() const { return default_width; } @@ -91,7 +91,7 @@ template <> class Bitmap<64> ulonglong map; public: Bitmap<64>() { } - Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } + explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } void init() { } void init(uint prefix_to_set) { set_prefix(prefix_to_set); } uint length() const { return 64; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e2d1069975b..39305a724bb 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -94,8 +94,8 @@ THD::THD():user_time(0), is_fatal_error(0), lex= &main_lex; host=user=priv_user=db=query=ip=0; host_or_ip= "connecting host"; - locked=some_tables_deleted=no_errors=password= - query_start_used=prepare_command=0; + locked=some_tables_deleted=no_errors=password= 0; + query_start_used= 0; count_cuted_fields= CHECK_FIELD_IGNORE; killed= NOT_KILLED; db_length=query_length=col_access=0; @@ -1047,9 +1047,9 @@ bool select_dump::send_eof() return error; } -select_subselect::select_subselect(Item_subselect *item) +select_subselect::select_subselect(Item_subselect *item_arg) { - this->item=item; + item= item_arg; } bool select_singlerow_subselect::send_data(List<Item> &items) @@ -1269,3 +1269,14 @@ bool select_dumpvar::send_eof() ::send_ok(thd,row_count); return 0; } + +/**************************************************************************** + TMP_TABLE_PARAM +****************************************************************************/ + +void TMP_TABLE_PARAM::init() +{ + field_count= sum_func_count= func_count= hidden_field_count= 0; + group_parts= group_length= group_null_parts= 0; + quick_group= 1; +} diff --git a/sql/sql_class.h b/sql/sql_class.h index f9d74f8b4da..457c77a3a04 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -619,7 +619,6 @@ public: my_error(killed_errno(), MYF(0)); } - bool prepare_command; bool tmp_table_used; bool charset_is_system_charset, charset_is_collation_connection; bool slow_command; @@ -913,7 +912,12 @@ public: class TMP_TABLE_PARAM :public Sql_alloc { - public: +private: + /* Prevent use of these (not safe because of lists and copy_field) */ + TMP_TABLE_PARAM(const TMP_TABLE_PARAM &); + void operator=(TMP_TABLE_PARAM &); + +public: List<Item> copy_funcs; List<Item> save_copy_funcs; List_iterator_fast<Item> copy_funcs_it; @@ -938,6 +942,7 @@ class TMP_TABLE_PARAM :public Sql_alloc { cleanup(); } + void init(void); inline void cleanup(void) { if (copy_field) /* Fix for Intel compiler */ @@ -963,6 +968,7 @@ class select_union :public select_result { bool send_data(List<Item> &items); bool send_eof(); bool flush(); + void set_table(TABLE *tbl) { table= tbl; } }; /* Base subselect interface class */ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 22c6cc1f6f7..a057e0be967 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -264,7 +264,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) char path[FN_REFLEN+16]; long result=1; int error = 0; - uint create_options = create_info ? create_info->options : 0; DBUG_ENTER("mysql_alter_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -438,7 +437,6 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, char filePath[FN_REFLEN]; TABLE_LIST *tot_list=0, **tot_list_next; List<String> raid_dirs; - DBUG_ENTER("mysql_rm_known_files"); DBUG_PRINT("enter",("path: %s", org_path)); @@ -514,17 +512,24 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, deleted++; } } + List_iterator<String> it(raid_dirs); + String *dir; + if (thd->killed || (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, 1))) { + /* Free memory for allocated raid dirs */ + while ((dir= it++)) + delete dir; my_dirend(dirp); DBUG_RETURN(-1); } - List_iterator<String> it(raid_dirs); - String *dir; while ((dir= it++)) + { if (rmdir(dir->c_ptr()) < 0) found_other_files++; + delete dir; + } my_dirend(dirp); /* diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 719686a56c3..e8f1c5d87de 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -62,16 +62,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *org_table_list) { - SELECT_LEX *select_cursor= unit->first_select(); - List<Item> item_list; + SELECT_LEX *first_select= unit->first_select(); TABLE *table; int res; select_union *derived_result; - TABLE_LIST *tables= (TABLE_LIST *)select_cursor->table_list.first; - TMP_TABLE_PARAM tmp_table_param; - bool is_union= select_cursor->next_select() && - select_cursor->next_select()->linkage == UNION_TYPE; - bool is_subsel= select_cursor->first_inner_unit() ? 1: 0; + TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; + bool is_union= first_select->next_select() && + first_select->next_select()->linkage == UNION_TYPE; + bool is_subsel= first_select->first_inner_unit() ? 1: 0; SELECT_LEX *save_current_select= lex->current_select; DBUG_ENTER("mysql_derived"); @@ -112,16 +110,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - lex->current_select= select_cursor; - TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; - /* Setting up. A must if a join or IGNORE, USE or similar are utilised */ - if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, - select_cursor->with_wild)) - { - res= -1; + if (!(derived_result= new select_union(0))) + DBUG_RETURN(1); // out of memory + + // st_select_lex_unit::prepare correctly work for single select + if ((res= unit->prepare(thd, derived_result))) goto exit; - } /* This is done in order to redo all field optimisations when any of the @@ -133,30 +127,16 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - item_list= select_cursor->item_list; - select_cursor->with_wild= 0; - if (select_cursor->setup_ref_array(thd, - select_cursor->order_list.elements + - select_cursor->group_list.elements) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, - item_list, 0, 0, 1)) - { - res= -1; - goto exit; - } - // Item list should be fix_fielded yet another time in JOIN::prepare - unfix_item_list(item_list); - - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= item_list.elements; + derived_result->tmp_table_param.init(); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, - (ORDER*) 0, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, - (select_cursor->options | thd->options | + (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, org_table_list->alias))) @@ -164,70 +144,67 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, res= -1; goto exit; } - - if ((derived_result=new select_union(table))) + derived_result->set_table(table); + + unit->offset_limit_cnt= first_select->offset_limit; + unit->select_limit_cnt= first_select->select_limit+ + first_select->offset_limit; + if (unit->select_limit_cnt < first_select->select_limit) + unit->select_limit_cnt= HA_POS_ERROR; + if (unit->select_limit_cnt == HA_POS_ERROR) + first_select->options&= ~OPTION_FOUND_ROWS; + + if (is_union) + res= mysql_union(thd, lex, derived_result, unit); + else + res= mysql_select(thd, &first_select->ref_pointer_array, + (TABLE_LIST*) first_select->table_list.first, + first_select->with_wild, + first_select->item_list, first_select->where, + (first_select->order_list.elements+ + first_select->group_list.elements), + (ORDER *) first_select->order_list.first, + (ORDER *) first_select->group_list.first, + first_select->having, (ORDER*) NULL, + (first_select->options | thd->options | + SELECT_NO_UNLOCK), + derived_result, unit, first_select); + + if (!res) { - derived_result->tmp_table_param=tmp_table_param; - unit->offset_limit_cnt= select_cursor->offset_limit; - unit->select_limit_cnt= select_cursor->select_limit+ - select_cursor->offset_limit; - if (unit->select_limit_cnt < select_cursor->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; - if (unit->select_limit_cnt == HA_POS_ERROR) - select_cursor->options&= ~OPTION_FOUND_ROWS; - - if (is_union) - res= mysql_union(thd, lex, derived_result, unit, 1); + /* + Here we entirely fix both TABLE_LIST and list of SELECT's as + there were no derived tables + */ + if (derived_result->flush()) + res= 1; else - res= mysql_select(thd, &select_cursor->ref_pointer_array, - (TABLE_LIST*) select_cursor->table_list.first, - select_cursor->with_wild, - select_cursor->item_list, select_cursor->where, - (select_cursor->order_list.elements+ - select_cursor->group_list.elements), - (ORDER *) select_cursor->order_list.first, - (ORDER *) select_cursor->group_list.first, - select_cursor->having, (ORDER*) NULL, - (select_cursor->options | thd->options | - SELECT_NO_UNLOCK), - derived_result, unit, select_cursor, 1); - - if (!res) { - /* - Here we entirely fix both TABLE_LIST and list of SELECT's as - there were no derived tables - */ - if (derived_result->flush()) - res= 1; - else - { - org_table_list->real_name=table->real_name; - org_table_list->table=table; - table->derived_select_number= select_cursor->select_number; - table->tmp_table= TMP_TABLE; + org_table_list->real_name=table->real_name; + org_table_list->table=table; + table->derived_select_number= first_select->select_number; + table->tmp_table= TMP_TABLE; #ifndef NO_EMBEDDED_ACCESS_CHECKS - org_table_list->grant.privilege= SELECT_ACL; + org_table_list->grant.privilege= SELECT_ACL; #endif - if (lex->describe) + if (lex->describe) + { + // to fix a problem in EXPLAIN + if (tables) { - // to fix a problem in EXPLAIN - if (tables) - { - for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) - if (cursor->table_list) - cursor->table_list->table=cursor->table; - } + for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) + if (cursor->table_list) + cursor->table_list->table=cursor->table; } - else - unit->exclude_tree(); - org_table_list->db= (char *)""; - // Force read of table stats in the optimizer - table->file->info(HA_STATUS_VARIABLE); } + else + unit->exclude_tree(); + org_table_list->db= (char *)""; + // Force read of table stats in the optimizer + table->file->info(HA_STATUS_VARIABLE); } - delete derived_result; } + if (res) free_tmp_table(thd, table); else @@ -238,6 +215,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } exit: + delete derived_result; lex->current_select= save_current_select; close_thread_tables(thd, 0, 1); } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 3676f4644d2..c94d5e52bcf 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -102,6 +102,7 @@ void mysql_reset_errors(THD *thd) MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *msg) { + DBUG_ENTER("push_warning"); if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); @@ -122,7 +123,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, } thd->warn_count[(uint) level]++; thd->total_warn_count++; - return err; + DBUG_RETURN(err); } /* diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 78e8c877c45..405cfdb5bdc 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -253,7 +253,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, continue; if (num_rows >= offset_limit) { - String *packet = &thd->packet; Item *item; protocol->prepare_for_resend(); it.rewind(); @@ -298,7 +297,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, !my_strcasecmp(system_charset_info, (is_alias ? table->table_name : table->real_name), table_name)) + { + if (table->version != refresh_version) + { + VOID(pthread_mutex_lock(&LOCK_open)); + if (close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + continue; + } break; + } ptr= &(table->next); } return ptr; diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 6af4ffde0e1..c40133c04a8 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -524,7 +524,7 @@ int send_header_2(Protocol *protocol, bool for_category) same as strcmp */ -int string_ptr_cmp(const void* ptr1, const void* ptr2) +extern "C" int string_ptr_cmp(const void* ptr1, const void* ptr2) { String *str1= *(String**)ptr1; String *str2= *(String**)ptr2; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 28324de11da..67afc355153 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1467,6 +1467,8 @@ void select_insert::send_error(uint errcode,const char *err) bool select_insert::send_eof() { int error,error2; + DBUG_ENTER("select_insert::send_eof"); + if (!(error=table->file->extra(HA_EXTRA_NO_CACHE))) error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); @@ -1499,20 +1501,18 @@ bool select_insert::send_eof() table->file->print_error(error,MYF(0)); //TODO error should be sent at the query processing end ::send_error(thd); - return 1; + DBUG_RETURN(1); } + + char buff[160]; + if (info.handle_duplicates == DUP_IGNORE) + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else - { - char buff[160]; - if (info.handle_duplicates == DUP_IGNORE) - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - else - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) info.deleted, (ulong) thd->cuted_fields); - ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); - return 0; - } + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) info.deleted, (ulong) thd->cuted_fields); + ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); + DBUG_RETURN(0); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 6ed8d23ab95..a67ee2385b9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -454,7 +454,7 @@ int yylex(void *arg, void *yythd) reg1 uchar c; int tokval, result_state; uint length; - enum my_lex_states state,prev_state; + enum my_lex_states state; LEX *lex= (((THD *)yythd)->lex); YYSTYPE *yylval=(YYSTYPE*) arg; CHARSET_INFO *cs= ((THD *) yythd)->charset(); @@ -463,7 +463,7 @@ int yylex(void *arg, void *yythd) lex->yylval=yylval; // The global state lex->tok_start=lex->tok_end=lex->ptr; - prev_state=state=lex->next_state; + state=lex->next_state; lex->next_state=MY_LEX_OPERATOR_OR_IDENT; LINT_INIT(c); for (;;) @@ -1197,7 +1197,7 @@ void st_select_lex_unit::exclude_level() */ void st_select_lex_unit::exclude_tree() { - SELECT_LEX_UNIT *units= 0, **units_last= &units; + SELECT_LEX_UNIT *units= 0; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { // unlink current level from global SELECTs list @@ -1292,28 +1292,6 @@ bool st_select_lex::test_limit() return(0); } - - - - - - - - - - - - - - - - - - - - - - /* Interface method of table list creation for query @@ -1333,18 +1311,14 @@ bool st_select_lex::test_limit() 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, - TABLE_LIST **result, +bool st_select_lex_unit::create_total_list(THD *thd_arg, st_lex *lex, + TABLE_LIST **result_arg, bool check_derived) { - *result= 0; - for (SELECT_LEX_UNIT *unit= this; unit; unit= unit->next_unit()) - { - if ((res= unit->create_total_list_n_last_return(thd, lex, &result, - check_derived))) - return res; - } - return 0; + *result_arg= 0; + res= create_total_list_n_last_return(thd_arg, lex, &result_arg, + check_derived); + return res; } /* @@ -1367,12 +1341,14 @@ bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, - TABLE_LIST ***result, - bool check_derived) +bool st_select_lex_unit:: +create_total_list_n_last_return(THD *thd_arg, + st_lex *lex, + TABLE_LIST ***result_arg, + bool check_derived) { TABLE_LIST *slave_list_first=0, **slave_list_last= &slave_list_first; - TABLE_LIST **new_table_list= *result, *aux; + TABLE_LIST **new_table_list= *result_arg, *aux; SELECT_LEX *sl= (SELECT_LEX*)slave; /* @@ -1391,7 +1367,7 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if (sl->order_list.first && sl->next_select() && !sl->braces && sl->linkage != GLOBAL_OPTIONS_TYPE) { - net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY"); + net_printf(thd_arg,ER_WRONG_USAGE,"UNION","ORDER BY"); return 1; } @@ -1409,12 +1385,12 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if ((aux= (TABLE_LIST*) sl->table_list.first)) { - TABLE_LIST *next; - for (; aux; aux= next) + TABLE_LIST *next_table; + for (; aux; aux= next_table) { TABLE_LIST *cursor; - next= aux->next; - for (cursor= **result; cursor; cursor= cursor->next) + next_table= aux->next; + for (cursor= **result_arg; cursor; cursor= cursor->next) if (!strcmp(cursor->db, aux->db) && !strcmp(cursor->real_name, aux->real_name) && !strcmp(cursor->alias, aux->alias)) @@ -1446,7 +1422,7 @@ end: *new_table_list= slave_list_first; new_table_list= slave_list_last; } - *result= new_table_list; + *result_arg= new_table_list; return 0; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8f879f12b10..4199bb18548 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -306,7 +306,6 @@ class JOIN; class select_union; class st_select_lex_unit: public st_select_lex_node { protected: - List<Item> item_list; TABLE_LIST result_table_list; select_union *union_result; TABLE *table; /* temporary table using for appending UNION results */ @@ -316,9 +315,19 @@ protected: ulong found_rows_for_union; bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) - executed, // already executed - t_and_f; // used for transferring tables_and_fields_initied UNIT:: methods + executed; // already executed + public: + // list of fields which points to temporary table for union + List<Item> item_list; + /* + list of types of items inside union (used for union & derived tables) + + Item_type_holders from which this list consist may have pointers to Field, + pointers is valid only after preparing SELECTS of this unit and before + any SELECT of this unit execution + */ + List<Item> types; /* Pointer to 'last' select or pointer to unit where stored global parameters for union @@ -353,7 +362,7 @@ public: void exclude_tree(); /* UNION methods */ - int prepare(THD *thd, select_result *result, bool tables_and_fields_initied); + int prepare(THD *thd, select_result *result); int exec(); int cleanup(); diff --git a/sql/sql_list.h b/sql/sql_list.h index b276c68c16a..bac4a2a8655 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -313,9 +313,9 @@ public: List_iterator_fast(List<T> &a) : base_list_iterator(a) {} inline T* operator++(int) { return (T*) base_list_iterator::next_fast(); } inline void rewind(void) { base_list_iterator::rewind(); } - void sublist(List<T> &list, uint el) + void sublist(List<T> &list_arg, uint el_arg) { - base_list_iterator::sublist(list, el); + base_list_iterator::sublist(list_arg, el_arg); } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 17ab42f979e..14d686a5613 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -140,7 +140,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, USER_RESOURCES *mqh) { int return_val=0; - uint temp_len, user_len, host_len; + uint temp_len, user_len; char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; struct user_conn *uc; @@ -148,7 +148,6 @@ static int get_or_create_user_conn(THD *thd, const char *user, DBUG_ASSERT(host != 0); user_len=strlen(user); - host_len=strlen(host); temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, @@ -2734,7 +2733,7 @@ mysql_execute_command(THD *thd) (ORDER *)NULL, select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, - result, unit, select_lex, 0); + result, unit, select_lex); if (thd->net.report_error) res= -1; delete result; @@ -3196,6 +3195,19 @@ mysql_execute_command(THD *thd) } } } + if (specialflag & SPECIAL_NO_RESOLVE) + { + LEX_USER *user; + List_iterator <LEX_USER> user_list(lex->users_list); + while ((user=user_list++)) + { + if (hostname_requires_resolving(user->host.str)) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_HOSTNAME_WONT_WORK, + ER(ER_WARN_HOSTNAME_WONT_WORK), + user->host.str); + } + } if (tables) { if (grant_option && check_grant(thd, @@ -4593,8 +4605,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, LEX_STRING *alias, ulong table_options, thr_lock_type lock_type, - List<String> *use_index, - List<String> *ignore_index, + List<String> *use_index_arg, + List<String> *ignore_index_arg, LEX_STRING *option) { register TABLE_LIST *ptr; @@ -4650,12 +4662,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX); ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES); ptr->derived= table->sel; - if (use_index) - ptr->use_index=(List<String> *) thd->memdup((gptr) use_index, - sizeof(*use_index)); - if (ignore_index) - ptr->ignore_index=(List<String> *) thd->memdup((gptr) ignore_index, - sizeof(*ignore_index)); + if (use_index_arg) + ptr->use_index=(List<String> *) thd->memdup((gptr) use_index_arg, + sizeof(*use_index_arg)); + if (ignore_index_arg) + ptr->ignore_index=(List<String> *) thd->memdup((gptr) ignore_index_arg, + sizeof(*ignore_index_arg)); ptr->option= option ? option->str : 0; /* check that used name is unique */ if (lock_type != TL_IGNORE) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index f09a8b32470..7715ab01044 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -427,8 +427,10 @@ static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos) Item_param *param; DBUG_ENTER("insert_params_withlog"); - String str, *res, *query= new String(stmt->query->alloced_length()); - query->copy(*stmt->query); + String str, query, *res; + + if (query.copy(*stmt->query)) + DBUG_RETURN(1); ulong param_no= 0; uint32 length= 0; @@ -452,16 +454,14 @@ static bool insert_params_withlog(PREP_STMT *stmt, uchar *pos, uchar *read_pos) res= param->query_val_str(&str); } } - if (query->replace(param->pos_in_query+length, 1, *res)) + if (query.replace(param->pos_in_query+length, 1, *res)) DBUG_RETURN(1); length+= res->length()-1; param_no++; } - if (alloc_query(stmt->thd, (char *)query->ptr(), query->length()+1)) + if (alloc_query(thd, (char *)query.ptr(), query.length()+1)) DBUG_RETURN(1); - - query->free(); DBUG_RETURN(0); } @@ -683,7 +683,7 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables, if (join->prepare(&select_lex->ref_pointer_array, tables, wild_num, conds, og_num, order, group, having, proc, - select_lex, unit, 0)) + select_lex, unit)) DBUG_RETURN(1); if (send_prep_stmt(stmt, fields.elements) || thd->protocol_simple.send_fields(&fields, 0) || @@ -786,7 +786,6 @@ static bool parse_prepare_query(PREP_STMT *stmt, mysql_init_query(thd); LEX *lex=lex_start(thd, (uchar*) packet, length); lex->safe_to_cache_query= 0; - thd->prepare_command= TRUE; thd->lex->param_count= 0; if (!yyparse((void *)thd) && !thd->is_fatal_error) error= send_prepare_results(stmt); @@ -1067,10 +1066,9 @@ void mysql_stmt_reset(THD *thd, char *packet) void mysql_stmt_free(THD *thd, char *packet) { ulong stmt_id= uint4korr(packet); - PREP_STMT *stmt; DBUG_ENTER("mysql_stmt_free"); - if (!(stmt=find_prepared_statement(thd, stmt_id, "close"))) + if (!find_prepared_statement(thd, stmt_id, "close")) { send_error(thd); // Not seen by the client DBUG_VOID_RETURN; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index cc64ca1aa2b..c0ee4277128 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -961,8 +961,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id) int change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; - const char* errmsg=0; - bool need_relay_log_purge=1; + const char* errmsg= 0; + bool need_relay_log_purge= 1; DBUG_ENTER("change_master"); lock_slave_threads(mi); @@ -1055,7 +1055,41 @@ int change_master(THD* thd, MASTER_INFO* mi) mi->rli.group_relay_log_pos= mi->rli.event_relay_log_pos= lex_mi->relay_log_pos; } - flush_master_info(mi); + /* + If user did specify neither host nor port nor any log name nor any log + pos, i.e. he specified only user/password/master_connect_retry, he probably + wants replication to resume from where it had left, i.e. from the + coordinates of the **SQL** thread (imagine the case where the I/O is ahead + of the SQL; restarting from the coordinates of the I/O would lose some + events which is probably unwanted when you are just doing minor changes + like changing master_connect_retry). + A side-effect is that if only the I/O thread was started, this thread may + restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a + much more unlikely situation than the one we are fixing here). + Note: coordinates of the SQL thread must be read here, before the + 'if (need_relay_log_purge)' block which resets them. + */ + if (!lex_mi->host && !lex_mi->port && + !lex_mi->log_file_name && !lex_mi->pos && + need_relay_log_purge) + { + /* + Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is + not initialized), so we use a max(). + What happens to mi->rli.master_log_pos during the initialization stages + of replication is not 100% clear, so we guard against problems using + max(). + */ + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, + mi->rli.group_master_log_pos); + strmake(mi->master_log_name, mi->rli.group_master_log_name, + sizeof(mi->master_log_name)-1); + } + /* + Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never + a slave before). + */ + flush_master_info(mi, 0); if (need_relay_log_purge) { relay_log_purge= 1; @@ -1087,10 +1121,21 @@ int change_master(THD* thd, MASTER_INFO* mi) } mi->rli.group_master_log_pos = mi->master_log_pos; DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + + /* + Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, + so restore them to good values. If we left them to ''/0, that would work; + but that would fail in the case of 2 successive CHANGE MASTER (without a + START SLAVE in between): because first one would set the coords in mi to + the good values of those in rli, the set those in rli to ''/0, then + second CHANGE MASTER would set the coords in mi to those of rli, i.e. to + ''/0: we have lost all copies of the original good coordinates. + That's why we always save good coords in rli. + */ mi->rli.group_master_log_pos= mi->master_log_pos; strmake(mi->rli.group_master_log_name,mi->master_log_name, sizeof(mi->rli.group_master_log_name)-1); + if (!mi->rli.group_master_log_name[0]) // uninitialized case mi->rli.group_master_log_pos=0; @@ -1251,8 +1296,8 @@ int show_binlog_info(THD* thd) field_list.push_back(new Item_empty_string("File", FN_REFLEN)); field_list.push_back(new Item_return_int("Position",20, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Binlog_do_db",255)); - field_list.push_back(new Item_empty_string("Binlog_ignore_db",255)); + field_list.push_back(new Item_empty_string("Binlog_Do_DB",255)); + field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255)); if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(-1); @@ -1291,9 +1336,7 @@ int show_binlogs(THD* thd) { IO_CACHE *index_file; char fname[FN_REFLEN]; - NET* net = &thd->net; List<Item> field_list; - String *packet = &thd->packet; uint length; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 53aed32d0c6..748e2c38cf3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -184,7 +184,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) fix_tables_pointers(lex->all_selects_list); if (select_lex->next_select()) - res=mysql_union(thd, lex, result, &lex->unit, 0); + res=mysql_union(thd, lex, result, &lex->unit); else res= mysql_select(thd, &select_lex->ref_pointer_array, (TABLE_LIST*) select_lex->table_list.first, @@ -197,7 +197,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) select_lex->having, (ORDER*) lex->proc_list.first, select_lex->options | thd->options, - result, &(lex->unit), &(lex->select_lex), 0); + result, &(lex->unit), &(lex->select_lex)); /* Don't set res if it's -1 as we may want this later */ DBUG_PRINT("info",("res: %d report_error: %d", res, @@ -292,9 +292,8 @@ JOIN::prepare(Item ***rref_pointer_array, uint wild_num, COND *conds_init, uint og_num, ORDER *order_init, ORDER *group_init, Item *having_init, - ORDER *proc_param_init, SELECT_LEX *select, - SELECT_LEX_UNIT *unit, - bool tables_and_fields_initied) + ORDER *proc_param_init, SELECT_LEX *select_lex_arg, + SELECT_LEX_UNIT *unit_arg) { DBUG_ENTER("JOIN::prepare"); @@ -304,16 +303,14 @@ JOIN::prepare(Item ***rref_pointer_array, having= having_init; proc_param= proc_param_init; tables_list= tables_init; - select_lex= select; + select_lex= select_lex_arg; select_lex->join= this; - union_part= (unit->first_select()->next_select() != 0); + union_part= (unit_arg->first_select()->next_select() != 0); /* Check that all tables, fields, conds and order are ok */ - if ((tables_and_fields_initied ? 0 : (setup_tables(tables_list) || - setup_wild(thd, tables_list, - fields_list, - &all_fields, wild_num))) || + if (setup_tables(tables_list) || + setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) || select_lex->setup_ref_array(thd, og_num) || setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1, &all_fields, 1) || @@ -380,14 +377,14 @@ JOIN::prepare(Item ***rref_pointer_array, DBUG_RETURN(-1); } } - TABLE_LIST *table; - for (table=tables_list ; table ; table=table->next) + TABLE_LIST *table_ptr; + for (table_ptr= tables_list ; table_ptr ; table_ptr= table_ptr->next) tables++; } { /* Caclulate the number of groups */ send_group_parts= 0; - for (ORDER *group= group_list ; group ; group= group->next) + for (ORDER *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next) send_group_parts++; } @@ -427,13 +424,13 @@ JOIN::prepare(Item ***rref_pointer_array, ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : - unit->select_limit_cnt); + unit_arg->select_limit_cnt); /* select_limit is used to decide if we are likely to scan the whole table */ - select_limit= unit->select_limit_cnt; + select_limit= unit_arg->select_limit_cnt; if (having || (select_options & OPTION_FOUND_ROWS)) select_limit= HA_POS_ERROR; - do_send_rows = (unit->select_limit_cnt) ? 1 : 0; - this->unit= unit; + do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0; + unit= unit_arg; #ifdef RESTRICTED_GROUP if (sum_func_count && !group_list && (func_count || field_count)) @@ -442,7 +439,7 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; } #endif - if (!procedure && result->prepare(fields_list, unit)) + if (!procedure && result->prepare(fields_list, unit_arg)) goto err; /* purecov: inspected */ if (select_lex->olap == ROLLUP_TYPE && rollup_init()) @@ -668,20 +665,20 @@ JOIN::optimize() if (const_tables && !thd->locked_tables && !(select_options & SELECT_NO_UNLOCK)) { - TABLE **table, **end; - for (table=this->table, end=table + const_tables ; - table != end; - table++) + TABLE **curr_table, **end; + for (curr_table= table, end=curr_table + const_tables ; + curr_table != end; + curr_table++) { /* BDB tables require that we call index_end() before doing an unlock */ - if ((*table)->key_read) + if ((*curr_table)->key_read) { - (*table)->key_read=0; - (*table)->file->extra(HA_EXTRA_NO_KEYREAD); + (*curr_table)->key_read=0; + (*curr_table)->file->extra(HA_EXTRA_NO_KEYREAD); } - (*table)->file->index_end(); + (*curr_table)->file->index_end(); } - mysql_unlock_some_tables(thd, this->table, const_tables); + mysql_unlock_some_tables(thd, table, const_tables); } /* Among the equal fields belonging to the same multiple equality @@ -1049,18 +1046,18 @@ JOIN::optimize() if (exec_tmp_table1->distinct) { table_map used_tables= thd->used_tables; - JOIN_TAB *join_tab= this->join_tab+tables-1; + JOIN_TAB *last_join_tab= join_tab+tables-1; do { - if (used_tables & join_tab->table->map) + if (used_tables & last_join_tab->table->map) break; - join_tab->not_used_in_distinct=1; - } while (join_tab-- != this->join_tab); + last_join_tab->not_used_in_distinct=1; + } while (last_join_tab-- != join_tab); /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ if (order && skip_sort_order) { /* Should always succeed */ - if (test_if_skip_sort_order(&this->join_tab[const_tables], + if (test_if_skip_sort_order(&join_tab[const_tables], order, unit->select_limit_cnt, 0)) order=0; } @@ -1479,26 +1476,27 @@ JOIN::exec() { // Some tables may have been const curr_join->tmp_having->update_used_tables(); - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables]; - table_map used_tables= curr_join->const_table_map | table->table->map; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables]; + table_map used_tables= (curr_join->const_table_map | + curr_table->table->map); Item* sort_table_cond= make_cond_for_table(curr_join->tmp_having, used_tables, used_tables); if (sort_table_cond) { - if (!table->select) - if (!(table->select= new SQL_SELECT)) + if (!curr_table->select) + if (!(curr_table->select= new SQL_SELECT)) DBUG_VOID_RETURN; - if (!table->select->cond) - table->select->cond= sort_table_cond; + if (!curr_table->select->cond) + curr_table->select->cond= sort_table_cond; else // This should never happen - if (!(table->select->cond= new Item_cond_and(table->select->cond, - sort_table_cond))) + if (!(curr_table->select->cond= + new Item_cond_and(curr_table->select->cond, sort_table_cond))) DBUG_VOID_RETURN; - table->select_cond=table->select->cond; - table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(table->select->cond, + curr_table->select_cond= curr_table->select->cond; + curr_table->select_cond->top_level_item(); + DBUG_EXECUTE("where",print_where(curr_table->select->cond, "select and having");); curr_join->tmp_having= make_cond_for_table(curr_join->tmp_having, ~ (table_map) 0, @@ -1515,9 +1513,9 @@ JOIN::exec() We can abort sorting after thd->select_limit rows if we there is no WHERE clause for any tables after the sorted one. */ - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables+1]; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables+1]; JOIN_TAB *end_table= &curr_join->join_tab[tables]; - for (; table < end_table ; table++) + for (; curr_table < end_table ; curr_table++) { /* table->keyuse is set in the case there was an original WHERE clause @@ -1525,7 +1523,8 @@ JOIN::exec() table->on_expr tells us that it was a LEFT JOIN and there will be at least one row generated from the table. */ - if (table->select_cond || (table->keyuse && !table->on_expr)) + if (curr_table->select_cond || + (curr_table->keyuse && !curr_table->on_expr)) { /* We have to sort all rows */ curr_join->select_limit= HA_POS_ERROR; @@ -1603,11 +1602,11 @@ JOIN::cleanup() delete select; delete_dynamic(&keyuse); delete procedure; - for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit(); - unit != 0; - unit= unit->next_unit()) + for (SELECT_LEX_UNIT *lex_unit= select_lex->first_inner_unit(); + lex_unit != 0; + lex_unit= lex_unit->next_unit()) { - error|= unit->cleanup(); + error|= lex_unit->cleanup(); } DBUG_RETURN(error); } @@ -1619,7 +1618,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulong select_options, select_result *result, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, bool tables_and_fields_initied) + SELECT_LEX *select_lex) { int err; bool free_join= 1; @@ -1629,26 +1628,31 @@ mysql_select(THD *thd, Item ***rref_pointer_array, if (select_lex->join != 0) { join= select_lex->join; - if (select_lex->linkage != GLOBAL_OPTIONS_TYPE) + // is it single SELECT in derived table, called in derived table creation + if (select_lex->linkage != DERIVED_TABLE_TYPE || + (select_options & SELECT_DESCRIBE)) { - //here is EXPLAIN of subselect or derived table - join->result= result; - if (!join->procedure && result->prepare(join->fields_list, unit)) + if (select_lex->linkage != GLOBAL_OPTIONS_TYPE) { - DBUG_RETURN(-1); + //here is EXPLAIN of subselect or derived table + join->result= result; + if (!join->procedure && result->prepare(join->fields_list, unit)) + { + DBUG_RETURN(-1); + } } - } - else - { - if (join->prepare(rref_pointer_array, tables, wild_num, - conds, og_num, order, group, having, proc_param, - select_lex, unit, tables_and_fields_initied)) + else { - goto err; + if (join->prepare(rref_pointer_array, tables, wild_num, + conds, og_num, order, group, having, proc_param, + select_lex, unit)) + { + goto err; + } } + free_join= 0; } join->select_options= select_options; - free_join= 0; } else { @@ -1657,7 +1661,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, thd->used_tables=0; // Updated by setup_fields if (join->prepare(rref_pointer_array, tables, wild_num, conds, og_num, order, group, having, proc_param, - select_lex, unit, tables_and_fields_initied)) + select_lex, unit)) { goto err; } @@ -5050,10 +5054,11 @@ COND *eliminate_not_funcs(COND *cond) static COND * optimize_cond(COND *conds,Item::cond_result *cond_value) { + DBUG_ENTER("optimize_cond"); if (!conds) { *cond_value= Item::COND_TRUE; - return conds; + DBUG_RETURN(conds); } DBUG_EXECUTE("where",print_where(conds,"original");); /* change field = field to field = const for each found field = const */ @@ -5065,7 +5070,7 @@ optimize_cond(COND *conds,Item::cond_result *cond_value) DBUG_EXECUTE("where",print_where(conds,"after const change");); conds=remove_eq_conds(conds,cond_value) ; DBUG_EXECUTE("info",print_where(conds,"after remove");); - return conds; + DBUG_RETURN(conds); } @@ -5299,6 +5304,115 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) ****************************************************************************/ /* + Create field for temporary table from given field + + SYNOPSIS + create_tmp_field_from_field() + thd Thread handler + org_field field from which new field will be created + item Item to create a field for + table Temporary table + modify_item 1 if item->result_field should point to new item. + This is relevent for how fill_record() is going to + work: + If modify_item is 1 then fill_record() will update + the record in the original table. + If modify_item is 0 then fill_record() will update + the temporary table + + RETURN + 0 on error + new_created field +*/ +static Field* create_tmp_field_from_field(THD *thd, + Field* org_field, + Item *item, + TABLE *table, + bool modify_item) +{ + Field *new_field; + + // The following should always be true + if ((new_field= org_field->new_field(&thd->mem_root,table))) + { + if (modify_item) + ((Item_field *)item)->result_field= new_field; + else + new_field->field_name= item->name; + if (org_field->maybe_null()) + new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join + if (org_field->type() == FIELD_TYPE_VAR_STRING) + table->db_create_options|= HA_OPTION_PACK_RECORD; + } + return new_field; +} + +/* + Create field for temporary table using type of given item + + SYNOPSIS + create_tmp_field_from_item() + thd Thread handler + item Item to create a field for + table Temporary table + copy_func If set and item is a function, store copy of item + in this array + modify_item 1 if item->result_field should point to new item. + This is relevent for how fill_record() is going to + work: + If modify_item is 1 then fill_record() will update + the record in the original table. + If modify_item is 0 then fill_record() will update + the temporary table + + RETURN + 0 on error + new_created field +*/ +static Field* create_tmp_field_from_item(THD *thd, + Item *item, + TABLE *table, + Item ***copy_func, + bool modify_item) +{ + bool maybe_null=item->maybe_null; + Field *new_field; + LINT_INIT(new_field); + + switch (item->result_type()) { + case REAL_RESULT: + new_field=new Field_double(item->max_length, maybe_null, + item->name, table, item->decimals); + break; + case INT_RESULT: + new_field=new Field_longlong(item->max_length, maybe_null, + item->name, table, item->unsigned_flag); + break; + case STRING_RESULT: + if (item->max_length > 255) + new_field= new Field_blob(item->max_length, maybe_null, + item->name, table, + item->collation.collation); + else + new_field= new Field_string(item->max_length, maybe_null, + item->name, table, + item->collation.collation); + break; + case ROW_RESULT: + default: + // This case should never be choosen + DBUG_ASSERT(0); + new_field= 0; // to satisfy compiler (uninitialized variable) + break; + } + if (copy_func && item->is_result_field()) + *((*copy_func)++) = item; // Save for copy_funcs + if (modify_item) + item->set_result_field(new_field); + return new_field; +} + +/* Create field for temporary table SYNOPSIS @@ -5309,6 +5423,8 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) type Type of item (normally item->type) copy_func If set and item is a function, store copy of item in this array + from_field if field will be created using other field as example, + pointer example field will be written here group 1 if we are going to do a relative group by on result modify_item 1 if item->result_field should point to new item. This is relevent for how fill_record() is going to @@ -5375,24 +5491,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, return 0; // Error } case Item::FIELD_ITEM: - { - Field *org_field=((Item_field*) item)->field,*new_field; - - *from_field=org_field; - // The following should always be true - if ((new_field= org_field->new_field(&thd->mem_root,table))) - { - if (modify_item) - ((Item_field*) item)->result_field= new_field; - else - new_field->field_name=item->name; - if (org_field->maybe_null()) - new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join - if (org_field->type()==FIELD_TYPE_VAR_STRING) - table->db_create_options|= HA_OPTION_PACK_RECORD; - } - return new_field; - } + return create_tmp_field_from_field(thd, (*from_field= + ((Item_field*) item)->field), + item, table, modify_item); case Item::FUNC_ITEM: case Item::COND_ITEM: case Item::FIELD_AVG_ITEM: @@ -5406,40 +5507,14 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::REF_ITEM: case Item::NULL_ITEM: case Item::VARBIN_ITEM: + return create_tmp_field_from_item(thd, item, table, + copy_func, modify_item); + case Item::TYPE_HOLDER: { - bool maybe_null=item->maybe_null; - Field *new_field; - LINT_INIT(new_field); - - switch (item->result_type()) { - case REAL_RESULT: - new_field=new Field_double(item->max_length,maybe_null, - item->name,table,item->decimals); - break; - case INT_RESULT: - new_field=new Field_longlong(item->max_length,maybe_null, - item->name,table, item->unsigned_flag); - break; - case STRING_RESULT: - if (item->max_length > 255) - new_field= new Field_blob(item->max_length,maybe_null, - item->name,table,item->collation.collation); - else - new_field= new Field_string(item->max_length,maybe_null, - item->name,table,item->collation.collation); - break; - case ROW_RESULT: - default: - // This case should never be choosen - DBUG_ASSERT(0); - new_field= 0; // to satisfy compiler (uninitialized variable) - break; - } - if (copy_func && item->is_result_field()) - *((*copy_func)++) = item; // Save for copy_funcs - if (modify_item) - item->set_result_field(new_field); - return new_field; + Field *example= ((Item_type_holder *)item)->example(); + if (example) + return create_tmp_field_from_field(thd, example, item, table, 0); + return create_tmp_field_from_item(thd, item, table, copy_func, 0); } default: // Dosen't have to be stored return 0; @@ -7994,7 +8069,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) entry->file->info(HA_STATUS_VARIABLE); if (entry->db_type == DB_TYPE_HEAP || (!entry->blob_fields && - ((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records < + ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records < thd->variables.sortbuff_size))) error=remove_dup_with_hash_index(join->thd, entry, field_count, first_field, @@ -8504,8 +8579,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, Item *itemptr=*order->item; if (itemptr->type() == Item::INT_ITEM) { /* Order by position */ - Item *item=0; - uint count= (uint) ((Item_int*)itemptr)->value; if (!count || count > fields.elements) { @@ -9078,10 +9151,10 @@ bool JOIN::alloc_func_list() } -bool JOIN::make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields, +bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_fields, bool before_group_by) { - List_iterator_fast<Item> it(all_fields); + List_iterator_fast<Item> it(field_list); Item_sum **func; Item *item; DBUG_ENTER("make_sum_func_list"); @@ -9100,7 +9173,7 @@ bool JOIN::make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields, if (before_group_by && rollup.state == ROLLUP::STATE_INITED) { rollup.state= ROLLUP::STATE_READY; - if (rollup_make_fields(all_fields, send_fields, &func)) + if (rollup_make_fields(field_list, send_fields, &func)) DBUG_RETURN(TRUE); // Should never happen } else if (rollup.state == ROLLUP::STATE_NONE) @@ -9403,12 +9476,12 @@ bool JOIN::rollup_init() */ for (i= 0 ; i < send_group_parts ; i++) { - List<Item> *fields= &rollup.fields[i]; - fields->empty(); + List<Item> *rollup_fields= &rollup.fields[i]; + rollup_fields->empty(); rollup.ref_pointer_arrays[i]= ref_array; ref_array+= all_fields.elements; for (j=0 ; j < fields_list.elements ; j++) - fields->push_back(rollup.item_null); + rollup_fields->push_back(rollup.item_null); } return 0; } @@ -9419,8 +9492,8 @@ bool JOIN::rollup_init() SYNOPSIS rollup_make_fields() - all_fields List of all fields (hidden and real ones) - fields Pointer to selected fields + fields_arg List of all fields (hidden and real ones) + sel_fields Pointer to selected fields func Store here a pointer to all fields IMPLEMENTATION: @@ -9432,11 +9505,11 @@ bool JOIN::rollup_init() 1 on error */ -bool JOIN::rollup_make_fields(List<Item> &all_fields, List<Item> &fields, +bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, Item_sum ***func) { - List_iterator_fast<Item> it(all_fields); - Item *first_field= fields.head(); + List_iterator_fast<Item> it(fields_arg); + Item *first_field= sel_fields.head(); uint level; /* @@ -9471,7 +9544,7 @@ bool JOIN::rollup_make_fields(List<Item> &all_fields, List<Item> &fields, ORDER *start_group; /* Point to first hidden field */ - Item **ref_array= ref_array_start + all_fields.elements-1; + Item **ref_array= ref_array_start + fields_arg.elements-1; /* Remember where the sum functions ends for the previous level */ sum_funcs_end[pos+1]= *func; @@ -9511,10 +9584,10 @@ bool JOIN::rollup_make_fields(List<Item> &all_fields, List<Item> &fields, else if (real_fields) { /* Check if this is something that is part of this group by */ - ORDER *group; - for (group= start_group ; group ; group= group->next) + ORDER *group_tmp; + for (group_tmp= start_group ; group_tmp ; group_tmp= group_tmp->next) { - if (*group->item == item) + if (*group_tmp->item == item) { /* This is an element that is used by the GROUP BY and should be @@ -9621,7 +9694,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, DBUG_ENTER("select_describe"); DBUG_PRINT("info", ("Select 0x%lx, type %s, message %s", (ulong)join->select_lex, join->select_lex->type, - message)); + message ? message : "NULL")); /* Don't log this into the slow query log */ select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); join->unit->offset_limit_cnt= 0; @@ -9900,7 +9973,7 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type, select_lex->having, (ORDER*) thd->lex->proc_list.first, select_lex->options | thd->options | SELECT_DESCRIBE, - result, unit, select_lex, 0); + result, unit, select_lex); DBUG_RETURN(res); } @@ -9989,8 +10062,8 @@ void st_select_lex::print(THD *thd, String *str) next_on= 0; } - TABLE_LIST *next; - if ((next= table->next)) + TABLE_LIST *next_table; + if ((next_table= table->next)) { if (table->outer_join & JOIN_TYPE_RIGHT) { @@ -9999,9 +10072,9 @@ void st_select_lex::print(THD *thd, String *str) table->on_expr) next_on= table->on_expr; } - else if (next->straight) + else if (next_table->straight) str->append(" straight_join ", 15); - else if (next->outer_join & JOIN_TYPE_LEFT) + else if (next_table->outer_join & JOIN_TYPE_LEFT) str->append(" left join ", 11); else str->append(" join ", 6); @@ -10009,17 +10082,17 @@ void st_select_lex::print(THD *thd, String *str) } } - //where - Item *where= this->where; + // Where + Item *cur_where= where; if (join) - where= join->conds; - if (where) + cur_where= join->conds; + if (cur_where) { str->append(" where ", 7); - where->print(str); + cur_where->print(str); } - //group by & olap + // group by & olap if (group_list.elements) { str->append(" group by ", 10); @@ -10037,15 +10110,15 @@ void st_select_lex::print(THD *thd, String *str) } } - //having - Item *having= this->having; + // having + Item *cur_having= having; if (join) - having= join->having; + cur_having= join->having; - if (having) + if (cur_having) { str->append(" having ", 8); - having->print(str); + cur_having->print(str); } if (order_list.elements) diff --git a/sql/sql_select.h b/sql/sql_select.h index 352378b7dff..bcf9ff6ff1e 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -166,11 +166,23 @@ class JOIN :public Sql_alloc JOIN *tmp_join; // copy of this JOIN to be used with temporary tables ROLLUP rollup; // Used with rollup - bool select_distinct, //Is select distinct? - no_order, simple_order, simple_group, - skip_sort_order, need_tmp, - hidden_group_fields, - buffer_result; + bool select_distinct; // Set if SELECT DISTINCT + + /* + simple_xxxxx is set if ORDER/GROUP BY doesn't include any references + to other tables than the first non-constant table in the JOIN. + It's also set if ORDER/GROUP BY is empty. + */ + bool simple_order, simple_group; + /* + Is set only in case if we have a GROUP BY clause + and no ORDER BY after constant elimination of 'order'. + */ + bool no_order; + /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ + bool skip_sort_order; + + bool need_tmp, hidden_group_fields, buffer_result; DYNAMIC_ARRAY keyuse; Item::cond_result cond_value; List<Item> all_fields; // to store all fields that used in query @@ -196,14 +208,14 @@ class JOIN :public Sql_alloc bool union_part; // this subselect is part of union bool optimized; // flag to avoid double optimization in EXPLAIN - JOIN(THD *thd_arg, List<Item> &fields, ulong select_options_arg, + JOIN(THD *thd_arg, List<Item> &fields_arg, ulong select_options_arg, select_result *result_arg) - :fields_list(fields) + :fields_list(fields_arg) { - init(thd_arg, fields, select_options_arg, result_arg); + init(thd_arg, fields_arg, select_options_arg, result_arg); } - void init(THD *thd_arg, List<Item> &fields, ulong select_options_arg, + void init(THD *thd_arg, List<Item> &fields_arg, ulong select_options_arg, select_result *result_arg) { join_tab= join_tab_save= 0; @@ -236,8 +248,8 @@ class JOIN :public Sql_alloc hidden_group_fields= 0; /*safety*/ buffer_result= test(select_options & OPTION_BUFFER_RESULT) && !test(select_options & OPTION_FOUND_ROWS); - all_fields= fields; - fields_list= fields; + all_fields= fields_arg; + fields_list= fields_arg; error= 0; select= 0; ref_pointer_array= items0= items1= items2= items3= 0; @@ -246,7 +258,7 @@ class JOIN :public Sql_alloc optimized= 0; cond_equal= 0; - fields_list= fields; + fields_list= fields_arg; bzero((char*) &keyuse,sizeof(keyuse)); tmp_table_param.copy_field=0; tmp_table_param.end_write_records= HA_POS_ERROR; @@ -256,7 +268,7 @@ class JOIN :public Sql_alloc int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, SELECT_LEX *select, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied); + SELECT_LEX_UNIT *unit); int optimize(); int reinit(); void exec(); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8a11c1de9d4..c176be53c21 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -702,7 +702,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, restore_record(table,default_values); // Get empty record Field **ptr,*field; - String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { if (!wild || !wild[0] || @@ -892,7 +891,6 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list,1)) DBUG_RETURN(1); - String *packet= &thd->packet; KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); for (uint i=0 ; i < table->keys ; i++,key_info++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4cc2842e2e7..100f8775445 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1629,7 +1629,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, LEX_STRING *key_cache_name) { HA_CHECK_OPT check_opt; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("mysql_assign_to_keycache"); check_opt.init(); @@ -1644,8 +1644,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, check_opt.key_cache= key_cache; DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, "assign_to_keycache", TL_READ_NO_INSERT, 0, - HA_OPEN_TO_ASSIGN, 0, - &handler::assign_to_keycache)); + 0, 0, &handler::assign_to_keycache)); } @@ -1674,14 +1673,14 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, 0 ok */ -int reassign_keycache_tables(THD *thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache) +int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache) { DBUG_ENTER("reassign_keycache_tables"); DBUG_ASSERT(src_cache != dst_cache); DBUG_ASSERT(src_cache->in_init); - src_cache->buff_size= 0; // Free key cache + src_cache->param_buff_size= 0; // Free key cache ha_resize_key_cache(src_cache); ha_change_key_cache(src_cache, dst_cache); DBUG_RETURN(0); @@ -1946,7 +1945,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ulonglong next_insert_id; uint save_time_stamp,db_create_options, used_fields; enum db_type old_db_type,new_db_type; - thr_lock_type lock_type; DBUG_ENTER("mysql_alter_table"); thd->proc_info="init"; @@ -2786,7 +2784,6 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) for (table= tables; table; table= table->next) { char table_name[NAME_LEN*2+2]; - bool fatal_error= 0; TABLE *t; strxmov(table_name, table->db ,".", table->real_name, NullS); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index bd527a4154a..cd493fcac30 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -333,9 +333,9 @@ end: } -static int print_key_cache_status(const char *name, KEY_CACHE_VAR *key_cache) +static int print_key_cache_status(const char *name, KEY_CACHE *key_cache) { - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { printf("%s: Not in use\n", name); } @@ -353,11 +353,11 @@ writes: %10lu\n\ r_requests: %10lu\n\ reads: %10lu\n\n", name, - (ulong) key_cache->buff_size, key_cache->block_size, - key_cache->division_limit, key_cache->age_threshold, - key_cache->blocks_used,key_cache->blocks_changed, - key_cache->cache_w_requests,key_cache->cache_write, - key_cache->cache_r_requests,key_cache->cache_read); + (ulong) key_cache->param_buff_size, key_cache->param_block_size, + key_cache->param_division_limit, key_cache->param_age_threshold, + key_cache->global_blocks_used,key_cache->global_blocks_changed, + key_cache->global_cache_w_requests,key_cache->global_cache_write, + key_cache->global_cache_r_requests,key_cache->global_cache_read); } return 0; } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 8900d48ee4f..25620229844 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -25,11 +25,11 @@ #include "sql_select.h" int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, bool tables_and_fields_initied) + SELECT_LEX_UNIT *unit) { DBUG_ENTER("mysql_union"); int res= 0; - if (!(res= unit->prepare(thd, result, tables_and_fields_initied))) + if (!(res= unit->prepare(thd, result))) res= unit->exec(); res|= unit->cleanup(); DBUG_RETURN(res); @@ -59,12 +59,6 @@ select_union::~select_union() int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u) { unit= u; - if (not_describe && list.elements != table->fields) - { - my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, - ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0)); - return -1; - } return 0; } @@ -112,12 +106,12 @@ bool select_union::flush() } -int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, - bool tables_and_fields_initied) +int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) { - SELECT_LEX *lex_select_save= thd->lex->current_select; - SELECT_LEX *select_cursor,*sl; - DBUG_ENTER("st_select_lex_unit::prepare"); + SELECT_LEX *lex_select_save= thd_arg->lex->current_select; + SELECT_LEX *sl, *first_select; + select_result *tmp_result; + DBUG_ENTER("st_select_lex_unit::prepare"); /* result object should be reassigned even if preparing already done for @@ -129,75 +123,32 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, DBUG_RETURN(0); prepared= 1; res= 0; - found_rows_for_union= first_select_in_union()->options & OPTION_FOUND_ROWS; - TMP_TABLE_PARAM tmp_table_param; - t_and_f= tables_and_fields_initied; - bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); - thd->lex->current_select= sl= select_cursor= first_select_in_union(); + thd_arg->lex->current_select= sl= first_select= first_select_in_union(); + found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; + /* Global option */ - if (t_and_f) + + if (first_select->next_select()) { - // Item list and tables will be initialized by mysql_derived - item_list= select_cursor->item_list; + if (!(tmp_result= union_result= new select_union(0))) + goto err; + union_result->not_describe= 1; + union_result->tmp_table_param.init(); } else { - item_list.empty(); - TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; - - if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, - select_cursor->with_wild)) - goto err; - List_iterator<Item> it(select_cursor->item_list); - Item *item; - item_list= select_cursor->item_list; - select_cursor->with_wild= 0; - if (select_cursor->setup_ref_array(thd, - select_cursor->order_list.elements + - select_cursor->group_list.elements) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, - item_list, 0, 0, 1)) - goto err; - // Item list should be fix_fielded yet another time in JOIN::prepare - unfix_item_list(item_list); - - t_and_f= 1; - while((item=it++)) - { - item->maybe_null=1; - if (item->type() == Item::FIELD_ITEM) - ((class Item_field *)item)->field->table->maybe_null=1; - } + tmp_result= sel_result; + // single select should be processed like select in p[arantses + first_select->braces= 1; } - tmp_table_param.field_count=item_list.elements; - if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, - (ORDER*) 0, !union_option, - 1, (select_cursor->options | thd->options | - TMP_TABLE_ALL_COLUMNS), - HA_POS_ERROR, (char*) ""))) - goto err; - table->file->extra(HA_EXTRA_WRITE_CACHE); - table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - bzero((char*) &result_table_list,sizeof(result_table_list)); - result_table_list.db= (char*) ""; - result_table_list.real_name=result_table_list.alias= (char*) "union"; - result_table_list.table=table; - - if (!(union_result=new select_union(table))) - goto err; - - union_result->not_describe=1; - union_result->tmp_table_param=tmp_table_param; - for (;sl; sl= sl->next_select()) { - JOIN *join= new JOIN(thd, sl->item_list, - sl->options | thd->options | SELECT_NO_UNLOCK, - union_result); - thd->lex->current_select= sl; + JOIN *join= new JOIN(thd_arg, sl->item_list, + sl->options | thd_arg->options | SELECT_NO_UNLOCK, + tmp_result); + thd_arg->lex->current_select= sl; offset_limit_cnt= sl->offset_limit; select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) @@ -215,29 +166,80 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, (ORDER*) sl->group_list.first, sl->having, (ORDER*) NULL, - sl, this, t_and_f); - t_and_f= 0; - if (res || thd->is_fatal_error) + sl, this); + if (res || thd_arg->is_fatal_error) goto err; + if (sl == first_select) + { + types.empty(); + List_iterator_fast<Item> it(sl->item_list); + Item *item_tmp; + while ((item_tmp= it++)) + { + types.push_back(new Item_type_holder(thd_arg, item_tmp)); + } + + if (thd_arg->is_fatal_error) + goto err; // out of memory + } + else + { + if (types.elements != sl->item_list.elements) + { + my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, + ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0)); + goto err; + } + List_iterator_fast<Item> it(sl->item_list); + List_iterator_fast<Item> tp(types); + Item *type, *item_tmp; + while ((type= tp++, item_tmp= it++)) + { + if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp)) + DBUG_RETURN(-1); + } + } } - item_list.empty(); - thd->lex->current_select= lex_select_save; + if (first_select->next_select()) { - List_iterator<Item> it(select_cursor->item_list); - Field **field; + union_result->tmp_table_param.field_count= types.elements; + if (!(table= create_tmp_table(thd_arg, + &union_result->tmp_table_param, types, + (ORDER*) 0, !union_option, 1, + (first_select_in_union()->options | + thd_arg->options | + TMP_TABLE_ALL_COLUMNS), + HA_POS_ERROR, (char*) ""))) + goto err; + table->file->extra(HA_EXTRA_WRITE_CACHE); + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + bzero((char*) &result_table_list, sizeof(result_table_list)); + result_table_list.db= (char*) ""; + result_table_list.real_name= result_table_list.alias= (char*) "union"; + result_table_list.table= table; + union_result->set_table(table); - for (field= table->field; *field; field++) + item_list.empty(); + thd_arg->lex->current_select= lex_select_save; { - (void) it++; - if (item_list.push_back(new Item_field(*field))) - DBUG_RETURN(-1); + Field **field; + for (field= table->field; *field; field++) + { + if (item_list.push_back(new Item_field(*field))) + DBUG_RETURN(-1); + } } } + else + first_select->braces= 0; // remove our changes + + thd_arg->lex->current_select= lex_select_save; + + DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0); - DBUG_RETURN(res || thd->is_fatal_error ? 1 : 0); err: - thd->lex->current_select= lex_select_save; + thd_arg->lex->current_select= lex_select_save; DBUG_RETURN(-1); } @@ -372,7 +374,7 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options= thd->options; + ulong options_tmp= thd->options; thd->lex->current_select= fake_select_lex; offset_limit_cnt= global_parameters->offset_limit; select_limit_cnt= global_parameters->select_limit + @@ -381,9 +383,9 @@ int st_select_lex_unit::exec() if (select_limit_cnt < global_parameters->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) - options&= ~OPTION_FOUND_ROWS; + options_tmp&= ~OPTION_FOUND_ROWS; else if (found_rows_for_union && !thd->lex->describe) - options|= OPTION_FOUND_ROWS; + options_tmp|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list= &empty_list; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) @@ -418,8 +420,8 @@ int st_select_lex_unit::exec() global_parameters->order_list.elements, (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, - options | SELECT_NO_UNLOCK, - result, this, fake_select_lex, 0); + options_tmp | SELECT_NO_UNLOCK, + result, this, fake_select_lex); if (!res) thd->limit_found_rows = (ulonglong)table->file->records + add_rows; /* diff --git a/sql/sql_update.cc b/sql/sql_update.cc index a70e784f42a..058c0b6ce7d 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -468,7 +468,7 @@ int mysql_multi_update(THD *thd, conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, (ORDER *)NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, - result, unit, select_lex, 0); + result, unit, select_lex); delete result; DBUG_RETURN(res); } @@ -488,7 +488,8 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, Connect fields with tables and create list of tables that are updated */ -int multi_update::prepare(List<Item> ¬_used_values, SELECT_LEX_UNIT *unit) +int multi_update::prepare(List<Item> ¬_used_values, + SELECT_LEX_UNIT *lex_unit) { TABLE_LIST *table_ref; SQL_LIST update; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1b06b7f34f3..cd08e702cd5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -727,7 +727,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); insert_values update delete truncate rename show describe load alter optimize keycache preload flush reset purge begin commit rollback savepoint - slave master_def master_defs master_file_def + slave master_def master_defs master_file_def slave_until_opts repair restore backup analyze check start checksum field_list field_list_item field_spec kill column_def key_def keycache_list assign_to_keycache preload_list preload_keys @@ -1777,7 +1777,7 @@ sp_case: { /* Simple case: <caseval> = <whenval> */ LEX_STRING ivar; - ivar.str= "_tmp_"; + ivar.str= (char *)"_tmp_"; ivar.length= 5; Item *var= (Item*) new Item_splocal(ivar, ctx->current_framesize()-1); @@ -5435,7 +5435,7 @@ param_marker: '?' { LEX *lex=Lex; - if (YYTHD->prepare_command) + if (YYTHD->command == COM_PREPARE) { lex->param_list.push_back($$=new Item_param((uint)(lex->tok_start-(uchar *)YYTHD->query))); lex->param_count++; diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 1db2124bcee..d00e57df5a1 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -112,7 +112,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) found_pos= pos; } } - return(found_count == 1 && part_match ? found_count : 0); + return(found_count == 1 && part_match ? found_pos : 0); } diff --git a/sql/time.cc b/sql/time.cc index e696918dee3..fe22b80d59d 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -357,7 +357,6 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) const char *end=str+length; const uchar *format_position; bool found_delimitier= 0, found_space= 0; - DATE_TIME_FORMAT *format; DBUG_ENTER("str_to_TIME"); DBUG_PRINT("ENTER",("str: %.*s",length,str)); diff --git a/strings/bmove512.c b/strings/bmove512.c index 30ac4b744b6..d4c748fe0ff 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -37,7 +37,7 @@ #define LONG ulonglong #endif -void bmove512(register gptr to, register const gptr from, register uint length) +void bmove512(gptr to, const gptr from, register uint length) { reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length); diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index b21740f9dbb..d5ffa15ee0c 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -14,18 +14,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> - #include <my_global.h> +#include <m_string.h> #include <m_ctype.h> +#include <fcntl.h> #include <my_xml.h> - #define ROW_LEN 16 #define ROW16_LEN 8 #define MAX_BUF 16*1024 diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index fd5e58ad8a7..a2edc33b3d2 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -472,13 +472,13 @@ static uchar *thai2sortable(const uchar *tstr, uint len, uint *out_length) const uchar *p= tstr; uchar *outBuf; uchar *pRight1, *pRight2, *pRight3; - uchar *pLeft1, *pLeft2, *pLeft3; + uchar *pLeft2, *pLeft3; uint bufSize; uint RightSize; bufSize= (uint) (len + 1) * BUFFER_MULTIPLY; RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= + if (!(outBuf= pRight1= (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) { /* @@ -608,8 +608,8 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen(s1), s2, - strlen(s1)); + return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen((char*) s1), + s2, strlen((char*) s1)); } diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index f795ef64728..6319fbb4d9f 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -18,6 +18,7 @@ #include <my_sys.h> #include <m_string.h> +#undef ULONGLONG_MAX #define ULONGLONG_MAX (~(ulonglong) 0) #define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) #define INIT_CNT 9 @@ -81,7 +82,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) unsigned long i, j, k; ulonglong li; int negative; - long cutoff, cutoff2, cutoff3; + ulong cutoff, cutoff2, cutoff3; s= nptr; /* If fixed length string */ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 661748adab9..59006a187d0 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -120,7 +120,6 @@ Este pacote contém medições de desempenho de scripts e dados do MySQL. %package devel Release: %{release} -Requires: %{name}-client Summary: MySQL - Development header files and libraries Group: Applications/Databases Summary(pt_BR): MySQL - Medições de desempenho @@ -446,7 +445,7 @@ fi %files server %defattr(755 root, root) -%doc %attr(644, root, root) COPYING COPYING.LIB README +%doc %attr(644, root, root) COPYING README %doc %attr(644, root, root) Docs/manual.{html,ps,texi,txt} Docs/manual_toc.html %doc %attr(644, root, root) support-files/my-*.cnf @@ -569,6 +568,11 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Fri Nov 21 2003 Lenz Grimmer <lenz@mysql.com> + +- removed dependency on MySQL-client from the MySQL-devel subpackage + as it is not really required. (BUG 1610) + * Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com> - Fixed BUG 1162 (removed macro names from the changelog) diff --git a/tests/client_test.c b/tests/client_test.c index 03c9c1ff3ae..048935d2efb 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -72,60 +72,55 @@ static double total_time; static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void check_errcode(const unsigned int err); static void client_disconnect(); #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myerrno(n) check_errcode(n) - -#define myassert(exp) assert(exp) -#define myassert_r(exp) assert(!(exp)) #define myquery(r) \ { \ if (r) \ myerror(NULL); \ - myassert(r == 0); \ + assert(r == 0); \ } #define myquery_r(r) \ { \ if (r) \ myerror(NULL); \ -myassert_r(r == 0); \ +assert(r != 0); \ } #define mystmt(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert(r == 0);\ +assert(r == 0);\ } #define mystmt_r(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert_r(r == 0);\ +assert(r != 0);\ } #define mystmt_init(stmt) \ { \ if ( stmt == 0) \ myerror(NULL); \ -myassert(stmt != 0); \ +assert(stmt != 0); \ } #define mystmt_init_r(stmt) \ { \ if (stmt == 0) \ myerror(NULL);\ -myassert(stmt == 0);\ +assert(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);myassert(TRUE);} -#define mytest_r(x) if (x) {myerror(NULL);myassert(TRUE);} +#define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} +#define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} /******************************************************** * print the error message * @@ -143,16 +138,6 @@ static void print_error(const char *msg) else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } -static void check_errcode(const unsigned int err) -{ - if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); - else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); - myassert(mysql_errno(mysql) == err); -} - static void print_st_error(MYSQL_STMT *stmt, const char *msg) { if (stmt && mysql_stmt_errno(stmt)) @@ -523,7 +508,7 @@ static void verify_col_data(const char *table, const char *col, } fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", row[field], exp_data); - myassert(strcmp(row[field],exp_data) == 0); + assert(strcmp(row[field],exp_data) == 0); mysql_free_result(result); } @@ -556,15 +541,15 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout,"\n charsetnr:`%d`", field->charsetnr); fprintf(stdout,"\n default :`%s`\t(expected: `%s`)", field->def ? field->def : "(null)", def ? def: "(null)"); fprintf(stdout,"\n"); - myassert(strcmp(field->name,name) == 0); - myassert(strcmp(field->org_name,org_name) == 0); - myassert(field->type == type); - myassert(strcmp(field->table,table) == 0); - myassert(strcmp(field->org_table,org_table) == 0); - myassert(strcmp(field->db,db) == 0); - myassert(field->length == length); + assert(strcmp(field->name,name) == 0); + assert(strcmp(field->org_name,org_name) == 0); + assert(field->type == type); + assert(strcmp(field->table,table) == 0); + assert(strcmp(field->org_table,org_table) == 0); + assert(strcmp(field->db,db) == 0); + assert(field->length == length); if (def) - myassert(strcmp(field->def,def) == 0); + assert(strcmp(field->def,def) == 0); } /* @@ -575,7 +560,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) long param_count= mysql_param_count(stmt); fprintf(stdout,"\n total parameters in stmt: `%ld` (expected: `%ld`)", param_count, exp_count); - myassert(param_count == exp_count); + assert(param_count == exp_count); } /* @@ -586,7 +571,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) ulonglong affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -597,7 +582,7 @@ static void verify_affected_rows(ulonglong exp_count) ulonglong affected_rows= mysql_affected_rows(mysql); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -608,7 +593,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) uint field_count= mysql_num_fields(result); fprintf(stdout,"\n total fields in the result set: `%d` (expected: `%d`)", field_count, exp_count); - myassert(field_count == exp_count); + assert(field_count == exp_count); } /* @@ -630,7 +615,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); mysql_stmt_close(stmt); } @@ -1174,7 +1159,7 @@ static void test_prepare() myquery(rc); /* test the results now, only one row should exists */ - myassert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); + assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); stmt = mysql_prepare(mysql,"SELECT * FROM my_prepare",50); mystmt_init(stmt); @@ -1212,27 +1197,27 @@ static void test_prepare() fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); - myassert(tiny_data == o_tiny_data); - myassert(is_null[0] == 0); - myassert(length[0] == 1); + assert(tiny_data == o_tiny_data); + assert(is_null[0] == 0); + assert(length[0] == 1); - myassert(int_data == o_int_data); - myassert(length[2] == 4); + assert(int_data == o_int_data); + assert(length[2] == 4); - myassert(small_data == o_small_data); - myassert(length[3] == 2); + assert(small_data == o_small_data); + assert(length[3] == 2); - myassert(big_data == o_big_data); - myassert(length[4] == 8); + assert(big_data == o_big_data); + assert(length[4] == 8); - myassert(real_data == o_real_data); - myassert(length[5] == 4); + assert(real_data == o_real_data); + assert(length[5] == 4); - myassert(double_data == o_double_data); - myassert(length[6] == 8); + assert(double_data == o_double_data); + assert(length[6] == 8); - myassert(strcmp(data,str_data) == 0); - myassert(length[1] == len); + assert(strcmp(data,str_data) == 0); + assert(length[1] == len); o_int_data += 25; o_small_data += 10; @@ -1242,7 +1227,7 @@ static void test_prepare() } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -1333,7 +1318,7 @@ static void test_double_compare() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -1408,7 +1393,7 @@ static void test_null() myquery(rc); nData*= 2; - myassert(nData == my_stmt_result("SELECT * FROM test_null", 30)); + assert(nData == my_stmt_result("SELECT * FROM test_null", 30)); /* Fetch results */ bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -1431,12 +1416,12 @@ static void test_null() is_null[0]= is_null[1]= 0; while (mysql_fetch(stmt) != MYSQL_NO_DATA) { - myassert(is_null[0]); - myassert(is_null[1]); + assert(is_null[0]); + assert(is_null[1]); rc++; is_null[0]= is_null[1]= 0; } - myassert(rc == (int)nData); + assert(rc == (int)nData); mysql_stmt_close(stmt); } @@ -1490,7 +1475,7 @@ static void test_fetch_null() strmov((char *)query , "SELECT * FROM test_fetch_null"); - myassert(3 == my_stmt_result(query,50)); + assert(3 == my_stmt_result(query,50)); stmt = mysql_prepare(mysql, query, 50); mystmt_init(stmt); @@ -1509,14 +1494,14 @@ static void test_fetch_null() { fprintf(stdout, "\n data[%d] : %s", i, is_null[i] ? "NULL" : "NOT NULL"); - myassert(is_null[i]); + assert(is_null[i]); } fprintf(stdout, "\n data[%d]: %d", i, nData); - myassert(nData == 1000 || nData == 88 || nData == 389789); - myassert(is_null[i] == 0); - myassert(length[i] == 4); + assert(nData == 1000 || nData == 88 || nData == 389789); + assert(is_null[i] == 0); + assert(length[i] == 4); } - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -1651,7 +1636,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); rc = mysql_query(mysql,"DROP TABLE test_select"); @@ -1681,7 +1666,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -1757,7 +1742,7 @@ static void test_select() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1808,7 +1793,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"venu"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1824,7 +1809,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1840,7 +1825,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1886,7 +1871,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"1111"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1902,7 +1887,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1918,7 +1903,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); mysql_stmt_close(stmt); } @@ -1998,7 +1983,7 @@ static void test_bug1644() result= mysql_store_result(mysql); mytest(result); - myassert(3 == my_process_result_set(result)); + assert(3 == my_process_result_set(result)); mysql_data_seek(result, 0); @@ -2006,19 +1991,19 @@ static void test_bug1644() mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "22") == 0); + assert(strcmp(row[i], "22") == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(row[i] == 0); + assert(row[i] == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "88") == 0); + assert(strcmp(row[i], "88") == 0); } row= mysql_fetch_row(result); mytest_r(row); @@ -2084,7 +2069,7 @@ static void test_select_show() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -2170,7 +2155,7 @@ static void test_simple_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2256,7 +2241,7 @@ static void test_long_data() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); verify_col_data("test_long_data","col1","999"); @@ -2346,7 +2331,7 @@ static void test_long_data_str() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%d", i*5)); @@ -2435,7 +2420,7 @@ static void test_long_data_str1() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%ld",(long)i*length)); @@ -2526,7 +2511,7 @@ static void test_long_data_bin() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2614,7 +2599,7 @@ static void test_simple_delete() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -2720,7 +2705,7 @@ static void test_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2770,7 +2755,7 @@ static void test_prepare_noparam() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2840,17 +2825,17 @@ static void test_bind_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"MySQL")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"MySQL")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -2858,12 +2843,12 @@ static void test_bind_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -2972,19 +2957,19 @@ static void test_bind_result_ext() fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); - myassert(t_data == 19); - myassert(s_data == 2999); - myassert(i_data == 3999); - myassert(b_data == 4999999); - /*myassert(f_data == 2345.60);*/ - /*myassert(d_data == 5678.89563);*/ - myassert(strcmp(szData,"venu")==0); - myassert(strncmp(bData,"mysql",5)==0); - myassert(szLength == 4); - myassert(bLength == 5); + assert(t_data == 19); + assert(s_data == 2999); + assert(i_data == 3999); + assert(b_data == 4999999); + /*assert(f_data == 2345.60);*/ + /*assert(d_data == 5678.89563);*/ + assert(strcmp(szData,"venu")==0); + assert(strncmp(bData,"mysql",5)==0); + assert(szLength == 4); + assert(bLength == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3096,23 +3081,23 @@ static void test_bind_result_ext1() fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); - myassert(strcmp(t_data,"120")==0); - myassert(i_data == 3999); - myassert(f_data == 2); - myassert(strcmp(d_data,"58.89")==0); - myassert(b_data == 54); - - myassert(length[0] == 3); - myassert(length[1] == 4); - myassert(length[2] == 2); - myassert(length[3] == 1); - myassert(length[4] == 4); - myassert(length[5] == 5); - myassert(length[6] == 4); - myassert(length[7] == 8); + assert(strcmp(t_data,"120")==0); + assert(i_data == 3999); + assert(f_data == 2); + assert(strcmp(d_data,"58.89")==0); + assert(b_data == 54); + + assert(length[0] == 3); + assert(length[1] == 4); + assert(length[2] == 2); + assert(length[3] == 1); + assert(length[4] == 4); + assert(length[5] == 5); + assert(length[6] == 4); + assert(length[7] == 8); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3165,7 +3150,7 @@ static void bind_fetch(int row_count) mysql_stmt_close(stmt); - myassert(row_count == (int) + assert(row_count == (int) my_stmt_result("SELECT * FROM test_bind_fetch",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_fetch",50); @@ -3220,33 +3205,33 @@ static void bind_fetch(int row_count) rc= 10+row_count; for (i=0; i < 4; i++) { - myassert(data[i] == rc+i); - myassert(length[i] == bit); + assert(data[i] == rc+i); + assert(length[i] == bit); bit<<= 1; rc+= 12; } /* FLOAT */ rc+= i; - myassert((int)f_data == rc); - myassert(length[4] == 4); + assert((int)f_data == rc); + assert(length[4] == 4); /* DOUBLE */ rc+= 13; - myassert((int)d_data == rc); - myassert(length[5] == 8); + assert((int)d_data == rc); + assert(length[5] == 8); /* CHAR */ rc+= 13; { char buff[20]; long len= my_sprintf(buff, (buff, "%d", rc)); - myassert(strcmp(s_data,buff)==0); - myassert(length[6] == (ulong) len); + assert(strcmp(s_data,buff)==0); + assert(length[6] == (ulong) len); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3336,7 +3321,7 @@ static void test_fetch_date() bind[6].buffer_length= sizeof(ts_6); bind[6].length= &ts6_length; - myassert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); + assert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); stmt = mysql_prepare(mysql, "SELECT * FROM test_bind_result", 50); mystmt_init(stmt); @@ -3359,29 +3344,29 @@ static void test_fetch_date() fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); - myassert(strcmp(date,"2002-01-02")==0); - myassert(d_length == 10); + assert(strcmp(date,"2002-01-02")==0); + assert(d_length == 10); - myassert(strcmp(time,"12:49:00")==0); - myassert(t_length == 8); + assert(strcmp(time,"12:49:00")==0); + assert(t_length == 8); - myassert(strcmp(ts,"2002-01-02 17:46:59")==0); - myassert(ts_length == 19); + assert(strcmp(ts,"2002-01-02 17:46:59")==0); + assert(ts_length == 19); - myassert(year == 2010); - myassert(y_length == 4); + assert(year == 2010); + assert(y_length == 4); - myassert(strcmp(dt,"2010-07-10 00:00:00")==0); - myassert(dt_length == 19); + assert(strcmp(dt,"2010-07-10 00:00:00")==0); + assert(dt_length == 19); - myassert(ts_4[0] == '\0'); - myassert(ts4_length == 0); + assert(ts_4[0] == '\0'); + assert(ts4_length == 0); - myassert(strcmp(ts_6,"1999-12-29 00:00:00")==0); - myassert(ts6_length == 19); + assert(strcmp(ts_6,"1999-12-29 00:00:00")==0); + assert(ts6_length == 19); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3726,7 +3711,7 @@ static void test_prepare_ext() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(nData == (int)my_process_stmt_result(stmt)); + assert(nData == (int)my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -3769,7 +3754,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); /* with table name included with TRUE column name */ @@ -3779,7 +3764,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -3805,7 +3790,7 @@ static void test_warnings() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -3908,7 +3893,7 @@ static void test_insert() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -4074,18 +4059,18 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt1); fprintf(stdout,"\n mysql_close_stmt(1) returned: %d", rc); - myassert(rc == 0); + assert(rc == 0); mysql_close(lmysql); /* it should free all open stmts(stmt3, 2 and 1) */ #if NOT_VALID rc= mysql_stmt_close(stmt3); fprintf(stdout,"\n mysql_close_stmt(3) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); rc= mysql_stmt_close(stmt2); fprintf(stdout,"\n mysql_close_stmt(2) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); #endif count= 100; @@ -4105,7 +4090,7 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt_x); fprintf(stdout,"\n mysql_close_stmt(x) returned: %d", rc); - myassert( rc == 0); + assert( rc == 0); rc = mysql_query(mysql,"SELECT id FROM test_stmt_close"); myquery(rc); @@ -4113,7 +4098,7 @@ static void test_stmt_close() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -4161,9 +4146,9 @@ static void test_set_variable() fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; - myassert(strcmp(var,"max_error_count") == 0); + assert(strcmp(var,"max_error_count") == 0); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); stmt = mysql_prepare(mysql, "set max_error_count=?", 50); mystmt_init(stmt); @@ -4189,10 +4174,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count : %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* restore back to default */ set_count= def_count; @@ -4206,10 +4191,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); mysql_stmt_close(stmt1); @@ -4265,12 +4250,12 @@ static void test_insert_meta() field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - myassert(strcmp(field->name,"col1")==0); + assert(strcmp(field->name,"col1")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - myassert(strcmp(field->name,"col3")==0); + assert(strcmp(field->name,"col3")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4329,15 +4314,15 @@ static void test_update_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col3")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col3")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4394,15 +4379,15 @@ static void test_select_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col2")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col2")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4448,7 +4433,7 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, "test_dateformat"); - myassert(strcmp(field->table, "test_dateformat")==0); + assert(strcmp(field->table, "test_dateformat")==0); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4465,7 +4450,7 @@ static void test_func_fields() field = mysql_fetch_field(result); mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, ""); - myassert(field->table[0] == '\0'); + assert(field->table[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4483,8 +4468,8 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); fprintf(stdout,"\n field org name: `%s` (expected: `%s`)",field->org_name,""); - myassert(strcmp(field->name, "YEAR")==0); - myassert(field->org_name[0] == '\0'); + assert(strcmp(field->name, "YEAR")==0); + assert(field->org_name[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4552,11 +4537,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"mysql")==0); + assert(id == 10); + assert(strcmp(name,"mysql")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* alter the table schema now */ stmt1 = mysql_prepare(mysql,"DELETE FROM test_multi_table WHERE id = ? AND name=?",100); @@ -4580,11 +4565,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"updated")==0); + assert(id == 10); + assert(strcmp(name,"updated")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt1); mystmt(stmt1, rc); @@ -4597,9 +4582,9 @@ static void test_multi_stmt() mystmt(stmt, rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); - myassert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); + assert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); mysql_stmt_close(stmt); mysql_stmt_close(stmt2); @@ -4750,7 +4735,7 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - myassert(2 == my_stmt_result("SELECT * FROM test_table",50)); + assert(2 == my_stmt_result("SELECT * FROM test_table",50)); /* DROP THE TABLE */ if (mysql_query(mysql,"DROP TABLE test_table")) @@ -4811,87 +4796,135 @@ static void test_prepare_alter() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); + assert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); mysql_stmt_close(stmt); } /******************************************************** -* to test the support of multi-query executions * +* to test the support of multi-statement executions * *********************************************************/ -static void test_multi_query() + +static void test_multi_statements() { - MYSQL *l_mysql, *org_mysql; + MYSQL *mysql_local; MYSQL_RES *result; int rc; - const char *query= "DROP TABLE IF EXISTS test_multi_tab;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(xxxx) VALUES(10);\ - UPDATE test_multi_tab SET id=10 WHERE unkown_col=10;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(id) VALUES(10),(20);\ - INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ - SELECT * FROM test_multi_tab;\ - UPDATE test_multi_tab SET unknown_col=100 WHERE id=100;\ - UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ - DELETE FROM test_multi_tab WHERE name='new;name';\ - SELECT * FROM test_multi_tab;\ - DELETE FROM test_multi_tab WHERE id=10;\ - SELECT * FROM test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE IF EXISTS test_multi_tab"; - uint count, rows[16]={0,1054,1054,1050,2,1,3,1054,2,2,1,1,0,0,1051,0}, exp_value; - - myheader("test_multi_query"); + const char *query="\ +DROP TABLE IF EXISTS test_multi_tab;\ +CREATE TABLE test_multi_tab(id int,name char(20));\ +INSERT INTO test_multi_tab(id) VALUES(10),(20);\ +INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ +SELECT * FROM test_multi_tab;\ +UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ +DELETE FROM test_multi_tab WHERE name='new;name';\ +SELECT * FROM test_multi_tab;\ +DELETE FROM test_multi_tab WHERE id=10;\ +SELECT * FROM test_multi_tab;\ +DROP TABLE test_multi_tab;\ +select 1;\ +DROP TABLE IF EXISTS test_multi_tab"; + uint count, exp_value; + uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0}; + + myheader("test_multi_statements"); + /* + First test that we get an error for multi statements + (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) + */ rc = mysql_query(mysql, query); /* syntax error */ myquery_r(rc); - myassert(0 == mysql_next_result(mysql)); - myassert(0 == mysql_more_results(mysql)); + assert(-1 == mysql_next_result(mysql)); + assert(0 == mysql_more_results(mysql)); - if (!(l_mysql = mysql_init(NULL))) + if (!(mysql_local = mysql_init(NULL))) { fprintf(stdout,"\n mysql_init() failed"); exit(1); } - if (!(mysql_real_connect(l_mysql,opt_host,opt_user, + + /* Create connection that supprot multi statements */ + if (!(mysql_real_connect(mysql_local,opt_host,opt_user, opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_STATEMENTS))) /* enable multi queries */ + opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout,"\n connection failed(%s)", mysql_error(l_mysql)); + fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); exit(1); - } - org_mysql= mysql; - mysql= l_mysql; + } - rc = mysql_query(mysql, query); + rc = mysql_query(mysql_local, query); myquery(rc); - count= exp_value= 0; - while (mysql_more_results(mysql) && count < array_elements(rows)) + for (count=0 ; count < array_elements(rows) ; count++) { fprintf(stdout,"\n Query %d: ", count); - if ((rc= mysql_next_result(mysql))) + if ((result= mysql_store_result(mysql_local))) + my_process_result_set(result); + else + fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)\n", + mysql_affected_rows(mysql_local), + mysql_warning_count(mysql_local)); + + exp_value= (uint) mysql_affected_rows(mysql_local); + if (rows[count] != exp_value) + { + fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + count, exp_value, rows[count]); + exit(1); + } + if (count != array_elements(rows) -1) { - exp_value= mysql_errno(mysql); - fprintf(stdout, "ERROR %d: %s", exp_value, mysql_error(mysql)); + if (!(rc= mysql_more_results(mysql_local))) + { + fprintf(stdout, + "mysql_more_result returned wrong value: %d for row %d\n", + rc, count); + exit(1); + } + if ((rc= mysql_next_result(mysql_local))) + { + exp_value= mysql_errno(mysql_local); + + exit(1); + } } else { - if ((result= mysql_store_result(mysql))) - my_process_result_set(result); - else - fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)", - mysql_affected_rows(mysql), - mysql_warning_count(mysql)); - exp_value= (uint) mysql_affected_rows(mysql); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); } - myassert(rows[count++] == exp_value); } - mysql= org_mysql; + + /* check that errors abort multi statements */ + + rc= mysql_query(mysql_local, "select 1+1+a;select 1+1"); + myquery_r(rc); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); + + rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + mysql_free_result(result); + assert(mysql_more_results(mysql_local) == 1); + assert(mysql_next_result(mysql_local) > 0); + + /* + Ensure that we can now do a simple query (this checks that the server is + not trying to send us the results for the last 'select 1' + */ + rc= mysql_query(mysql_local, "select 1+1+1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + my_process_result_set(result); + mysql_free_result(result); + + mysql_close(mysql_local); } @@ -4961,17 +4994,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)", nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -4979,12 +5012,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -4996,17 +5029,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -5014,12 +5047,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5069,7 +5102,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5081,7 +5114,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -5148,10 +5181,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 10); + assert(nData == 10); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); nData = 20; rc = mysql_execute(stmt); @@ -5165,10 +5198,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 20); + assert(nData == 20); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5242,11 +5275,11 @@ static void test_subselect() mysql_stmt_close(stmt); - myassert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); + assert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); strmov((char *)query , "SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=?)"); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); stmt = mysql_prepare(mysql, query, 150); mystmt_init(stmt); @@ -5265,10 +5298,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 1); + assert(id == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); id= 8; rc = mysql_execute(stmt); @@ -5278,10 +5311,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 0); + assert(id == 0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); #endif @@ -5356,7 +5389,7 @@ static void test_bind_date_conv(uint row_count) mysql_stmt_close(stmt); - myassert(row_count == my_stmt_result("SELECT * FROM test_date",50)); + assert(row_count == my_stmt_result("SELECT * FROM test_date",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_date",50); myquery(rc); @@ -5384,23 +5417,23 @@ static void test_bind_date_conv(uint row_count) tm[i].hour, tm[i].minute, tm[i].second, tm[i].second_part); - myassert(tm[i].year == 0 || tm[i].year == year+count); - myassert(tm[i].month == 0 || tm[i].month == month+count); - myassert(tm[i].day == 0 || tm[i].day == day+count); + assert(tm[i].year == 0 || tm[i].year == year+count); + assert(tm[i].month == 0 || tm[i].month == month+count); + assert(tm[i].day == 0 || tm[i].day == day+count); - myassert(tm[i].hour == 0 || tm[i].hour == hour+count); + assert(tm[i].hour == 0 || tm[i].hour == hour+count); /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine */ - /*myassert(tm[i].minute == 0 || tm[i].minute == minute+count); - myassert(tm[i].second == 0 || tm[i].second == sec+count);*/ + /*assert(tm[i].minute == 0 || tm[i].minute == minute+count); + assert(tm[i].second == 0 || tm[i].second == sec+count);*/ - myassert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); + assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5673,9 +5706,9 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(buffer[0] == 'M'); - myassert(buffer[1] == 'X'); - myassert(length == 5); + assert(buffer[0] == 'M'); + assert(buffer[1] == 'X'); + assert(length == 5); bind[0].buffer_length=8; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5684,8 +5717,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Database",8) == 0); - myassert(length == 8); + assert(strncmp(buffer,"Database",8) == 0); + assert(length == 8); bind[0].buffer_length=12; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5694,8 +5727,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strcmp(buffer,"Open-Source") == 0); - myassert(length == 11); + assert(strcmp(buffer,"Open-Source") == 0); + assert(length == 11); bind[0].buffer_length=6; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5704,8 +5737,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Popula",6) == 0); - myassert(length == 7); + assert(strncmp(buffer,"Popula",6) == 0); + assert(length == 7); mysql_stmt_close(stmt); } @@ -5736,7 +5769,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5749,7 +5782,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5762,7 +5795,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_stmt_close(stmt); /* run a direct query in the middle of a fetch */ @@ -5828,7 +5861,7 @@ static void test_fetch_nobuffs() rc++; fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)str[0]; @@ -5856,7 +5889,7 @@ static void test_fetch_nobuffs() fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); } fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); mysql_stmt_close(stmt); } @@ -5927,20 +5960,20 @@ static void test_ushort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == 35999); - myassert(s_length == 2); + assert(short_value == 35999); + assert(s_length == 2); - myassert(long_value == 35999); - myassert(l_length == 4); + assert(long_value == 35999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6011,20 +6044,20 @@ static void test_sshort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -5999); - myassert(s_length == 2); + assert(short_value == -5999); + assert(s_length == 2); - myassert(long_value == -5999); - myassert(l_length == 4); + assert(long_value == -5999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6095,20 +6128,20 @@ static void test_stiny_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -128); - myassert(s_length == 2); + assert(short_value == -128); + assert(s_length == 2); - myassert(long_value == -127); - myassert(l_length == 4); + assert(long_value == -127); + assert(l_length == 4); - myassert(longlong_value == 255); - myassert(ll_length == 8); + assert(longlong_value == 255); + assert(ll_length == 8); - myassert(tiny_value == 0); - myassert(t_length == 1); + assert(tiny_value == 0); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6133,7 +6166,7 @@ static void test_field_misc() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6152,7 +6185,7 @@ static void test_field_misc() result = mysql_get_metadata(stmt); mytest(result); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6183,7 +6216,7 @@ static void test_field_misc() fprintf(stdout,"\n default table type: %s(%ld)", table_type, type_length); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -6196,7 +6229,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@table_type","", /* field and its org name */ @@ -6216,7 +6249,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_error_count","", /* field and its org name */ @@ -6236,7 +6269,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_allowed_packet","", /* field and its org name */ @@ -6256,7 +6289,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@sql_warnings","", /* field and its org name */ @@ -6303,7 +6336,7 @@ static void test_set_option() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); @@ -6314,7 +6347,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(2 == my_process_stmt_result(stmt)); + assert(2 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -6329,7 +6362,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(4 == my_process_stmt_result(stmt)); + assert(4 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -6400,7 +6433,7 @@ static void test_prepare_grant() execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)",1); execute_prepare_query("INSERT INTO test_grant VALUES(NULL)",1); execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1",1); - myassert(4 == my_stmt_result("SELECT a FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT a FROM test_grant",50)); rc = mysql_query(mysql,"DELETE FROM test_grant"); myquery_r(rc); @@ -6411,18 +6444,18 @@ static void test_prepare_grant() rc = mysql_execute(stmt); myquery_r(rc); - myassert(4 == my_stmt_result("SELECT * FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT * FROM test_grant",50)); mysql_close(lmysql); mysql= org_mysql; rc = mysql_query(mysql,"delete from mysql.user where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } @@ -6476,7 +6509,7 @@ static void test_frm_bug() fprintf(stdout,"\n data directory: %s", data_dir); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); strxmov(test_frm,data_dir,"/",current_db,"/","test_frm_bug.frm",NullS); @@ -6496,7 +6529,7 @@ static void test_frm_bug() result = mysql_store_result(mysql); mytest(result);/* It can't be NULL */ - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_data_seek(result,0); @@ -6504,7 +6537,7 @@ static void test_frm_bug() mytest(row); fprintf(stdout,"\n Comment: %s", row[16]); - myassert(row[16] != 0); + assert(row[16] != 0); mysql_free_result(result); mysql_stmt_close(stmt); @@ -6562,10 +6595,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 8.0); + assert(data == 8.0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 5.61; rc = mysql_execute(stmt); @@ -6579,17 +6612,17 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 5.61); + assert(data == 5.61); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); is_null= 1; rc = mysql_execute(stmt); mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 10.22; is_null= 0; rc = mysql_execute(stmt); @@ -6603,10 +6636,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 10.22); + assert(data == 10.22); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6639,14 +6672,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 2 == my_process_stmt_result(stmt)); + assert( 2 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(6 == mysql_num_fields(result)); + assert(6 == mysql_num_fields(result)); verify_prepare_field(result,0,"Field","",MYSQL_TYPE_VAR_STRING, "","","",NAME_LEN,0); @@ -6675,14 +6708,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 1 == my_process_stmt_result(stmt)); + assert( 1 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(10 == mysql_num_fields(result)); + assert(10 == mysql_num_fields(result)); verify_prepare_field(result,0,"id","",MYSQL_TYPE_LONGLONG, "","","",3,0); @@ -6718,10 +6751,25 @@ static void test_explain_bug() mysql_stmt_close(stmt); } +#ifdef NOT_YET_WORKING + /* To test math functions bug #148 (reported by salle@mysql.com). */ + +#define myerrno(n) check_errcode(n) + +static void check_errcode(const unsigned int err) +{ + if (mysql->server_version) + fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + else + fprintf(stdout,"\n [MySQL]"); + fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + assert(mysql_errno(mysql) == err); +} + static void test_drop_temp() { int rc; @@ -6814,18 +6862,19 @@ static void test_drop_temp() rc = mysql_query(mysql,"drop database test_drop_temp_db"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.user where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } +#endif /* To test warnings for cuted rows @@ -6851,14 +6900,14 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 0); + assert(count == 0); rc = mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6866,7 +6915,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); rc = mysql_query(mysql, "INSERT INTO t1 VALUES('junk'),(876789)"); @@ -6874,7 +6923,7 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6882,7 +6931,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); } @@ -6985,44 +7034,44 @@ static void test_logs() fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(id == 9876); - myassert(length == 19); /* Due to VARCHAR(20) */ - myassert(strcmp(data,"MySQL - Open Source")==0); + assert(id == 9876); + assert(length == 19); /* Due to VARCHAR(20) */ + assert(strcmp(data,"MySQL - Open Source")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"'")==0); + assert(length == 1); + assert(strcmp(data,"'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"\"")==0); + assert(length == 1); + assert(strcmp(data,"\"")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - myassert(strcmp(data,"my\'sql\'")==0); + assert(length == 7); + assert(strcmp(data,"my\'sql\'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - /*myassert(strcmp(data,"my\"sql\"")==0); */ + assert(length == 7); + /*assert(strcmp(data,"my\"sql\"")==0); */ rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7089,10 +7138,10 @@ static void test_nstmts() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n total rows: %d", i); - myassert( i == total_stmts); + assert( i == total_stmts); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7189,7 +7238,7 @@ static void test_fetch_seek() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7249,17 +7298,17 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"abcd",4) == 0 && length == 10); + assert(strncmp(data,"abcd",4) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,5); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"fg",2) == 0 && length == 10); + assert(strncmp(data,"fg",2) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,9); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s (%ld)", data, length); - myassert(strncmp(data,"j",1) == 0 && length == 10); + assert(strncmp(data,"j",1) == 0 && length == 10); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7269,10 +7318,10 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); - myassert(is_null == 1); + assert(is_null == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7342,13 +7391,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"venu",4)==0 && l2 == 4); + assert(strncmp(c2,"venu",4)==0 && l2 == 4); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strcmp(c2,"venu")==0 && l2 == 4); + assert(strcmp(c2,"venu")==0 && l2 == 4); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7360,7 +7409,7 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 1 && l1 == 4); + assert(c1 == 1 && l1 == 4); rc = mysql_fetch_column(stmt,bind,10,0); mystmt_r(stmt,rc); @@ -7380,13 +7429,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"mysq",4)==0 && l2 == 5); + assert(strncmp(c2,"mysq",4)==0 && l2 == 5); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); - myassert(strcmp(c2,"mysql")==0 && l2 == 5); + assert(strcmp(c2,"mysql")==0 && l2 == 5); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7398,10 +7447,10 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 2 && l1 == 4); + assert(c1 == 2 && l1 == 4); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7427,7 +7476,7 @@ static void test_list_fields() result = mysql_list_fields(mysql, "test_list_fields",NULL); mytest(result); - myassert( 0 == my_process_result_set(result)); + assert( 0 == my_process_result_set(result)); verify_prepare_field(result,0,"c1","c1",MYSQL_TYPE_LONG, "test_list_fields","test_list_fields",current_db,11,"0"); @@ -7486,7 +7535,7 @@ static void test_mem_overun() rc = mysql_query(mysql,"select * from t_mem_overun"); myquery(rc); - myassert(1 == my_process_result(mysql)); + assert(1 == my_process_result(mysql)); stmt = mysql_prepare(mysql, "select * from t_mem_overun",30); mystmt_init(stmt); @@ -7498,7 +7547,7 @@ static void test_mem_overun() mytest(field_res); fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res)); - myassert( 1000 == mysql_num_fields(field_res)); + assert( 1000 == mysql_num_fields(field_res)); rc = mysql_stmt_store_result(stmt); mystmt(stmt,rc); @@ -7507,7 +7556,7 @@ static void test_mem_overun() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7562,7 +7611,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7577,7 +7626,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_query(mysql,"drop table test_free_result"); myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */ @@ -7644,7 +7693,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7659,7 +7708,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_stmt_free_result(stmt); mystmt(stmt,rc); @@ -7770,7 +7819,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row\n"); mysql_stmt_close(stmt); @@ -7793,7 +7842,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row"); mysql_stmt_close(stmt); @@ -7872,7 +7921,7 @@ static void test_ts() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert( 2== my_process_stmt_result(stmt)); + assert( 2== my_process_stmt_result(stmt)); field_count= mysql_num_fields(prep_res); mysql_free_result(prep_res); @@ -7899,11 +7948,148 @@ static void test_ts() row_count++; fprintf(stdout, "\n returned '%d' rows", row_count); - myassert(row_count == 2); + assert(row_count == 2); mysql_stmt_close(stmt); } } +/* + Test for bug #1500. +*/ +static void test_bug1500() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind[3]; + int rc; + long int_data[3]= {2,3,4}; + const char *data; + + myheader("test_bug1500"); + + rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_bg1500"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (i INT)"); + myquery(rc); + + rc= mysql_query(mysql,"INSERT INTO test_bg1500 VALUES (1),(2)"); + myquery(rc); + + rc= mysql_commit(mysql); + myquery(rc); + + stmt= mysql_prepare(mysql,"SELECT i FROM test_bg1500 WHERE i IN (?,?,?)",44); + mystmt_init(stmt); + verify_param_count(stmt,3); + + bind[0].buffer= (char *)int_data; + bind[0].buffer_type= FIELD_TYPE_LONG; + bind[0].is_null= 0; + bind[2]= bind[1]= bind[0]; + bind[1].buffer= (char *)(int_data + 1); + bind[2].buffer= (char *)(int_data + 2); + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + /* FIXME If we comment out next string server will crash :( */ + mysql_stmt_close(stmt); + + rc= mysql_query(mysql,"DROP TABLE test_bg1500"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s))"); + myquery(rc); + + rc= mysql_query(mysql, + "INSERT INTO test_bg1500 VALUES ('Gravedigger'), ('Greed'),('Hollow Dogs')"); + myquery(rc); + + rc= mysql_commit(mysql); + myquery(rc); + + stmt= mysql_prepare(mysql, + "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (?)",53); + mystmt_init(stmt); + + verify_param_count(stmt,1); + + data= "Dogs"; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *) data; + bind[0].buffer_length= strlen(data); + bind[0].is_null= 0; + bind[0].length= 0; + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + /* + FIXME If we comment out next string server will crash too :( + This is another manifestation of bug #1663 + */ + mysql_stmt_close(stmt); + + /* This should work too */ + stmt= mysql_prepare(mysql, + "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (CONCAT(?,'digger'))", 70); + mystmt_init(stmt); + + verify_param_count(stmt,1); + + data= "Grave"; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *) data; + bind[0].buffer_length= strlen(data); + bind[0].is_null= 0; + bind[0].length= 0; + + rc= mysql_bind_param(stmt, bind); + mystmt(stmt,rc); + + rc= mysql_execute(stmt); + mystmt(stmt,rc); + + assert(1 == my_process_stmt_result(stmt)); + + mysql_stmt_close(stmt); +} + +static void test_bug1946() +{ + MYSQL_STMT *stmt; + int rc; + const char *query= "INSERT INTO prepare_command VALUES (?)"; + + myheader("test_bug1946"); + + rc = mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); + myquery(rc); + + rc= mysql_query(mysql,"CREATE TABLE prepare_command(ID INT)"); + myquery(rc); + + stmt = mysql_prepare(mysql, query, strlen(query)); + mystmt_init(stmt); + rc= mysql_real_query(mysql, query, strlen(query)); + assert(rc != 0); + fprintf(stdout, "Got error (as expected):\n"); + myerror(NULL); + + mysql_stmt_close(stmt); + rc= mysql_query(mysql,"DROP TABLE prepare_command"); +} + /* Read and parse arguments and MySQL options from my.cnf @@ -8108,7 +8294,7 @@ int main(int argc, char **argv) test_stmt_close(); /* mysql_stmt_close() test -- hangs */ test_prepare_field_result(); /* prepare meta info */ test_multi_stmt(); /* multi stmt test */ - test_multi_query(); /* test multi query execution */ + test_multi_statements(); /* test multi statement execution */ test_store_result(); /* test the store_result */ test_store_result1(); /* test store result without buffers */ test_store_result2(); /* test store result for misc case */ @@ -8145,7 +8331,10 @@ int main(int argc, char **argv) test_ts(); /* test for timestamp BR#819 */ test_bug1115(); /* BUG#1115 */ test_bug1180(); /* BUG#1180 */ + test_bug1500(); /* BUG#1500 */ test_bug1644(); /* BUG#1644 */ + test_bug1946(); /* test that placeholders are allowed only in + prepared queries */ end_time= time((time_t *)0); total_time+= difftime(end_time, start_time); diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index b552b95ba6b..a1c55ac4c11 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -23,14 +23,15 @@ $opt_select_count=$opt_join_count=0; $opt_update=1;$opt_delete=0;
$opt_flush=$opt_check=$opt_repair=$opt_alter=0;
$opt_join_range=100;
+$opt_resize_interval=0; $opt_time=0; $opt_host=$opt_user=$opt_password=""; $opt_db="test"; +$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","skip-in","skip-drop",
"verbose","fast-insert","lock-tables","debug","fast","force","thread-factor=i",
"insert=i", "select=i", "join=i", "select-count=i", "join-count=i", "update=i", "delete=i",
- "flush=i", "check=i", "repair=i", "alter=i", "max-join_range=i", "time=i") || die "Aborted"; -$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these + "flush=i", "check=i", "repair=i", "alter=i", "resize-interval=i", "max-join_range=i", "time=i") || die "Aborted"; print "Test of multiple connections that test the following things:\n"; print "insert, select, delete, update, alter, check, repair and flush\n"; @@ -158,6 +159,11 @@ for ($i=0 ; $i < $opt_alter ; $i ++) test_alter() if (($pid=fork()) == 0); $work{$pid}="alter";
}
$threads+=$i;
+if ($opt_resize_interval != 0) +{ + test_resize() if (($pid=fork()) == 0); $work{$pid}="resize"; + $threads+=1; +} print "Started $threads threads\n"; @@ -590,6 +596,32 @@ sub test_flush exit(0); } +# +# Do a resize key cache every periodically +# + +sub test_resize +{ + my ($dbh, $key_buffer_size); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $count=0; + $key_buffer_size=1024*64; + while (!test_if_abort($dbh)) + { + sleep($opt_resize_interval); + $dbh->do("set global key_buffer_size=$key_buffer_size") || + die "Got error on resize key cache $DBI::errstr\n"; + $key_buffer_size+=1024*16; + $count++; + } + $dbh->disconnect; $dbh=0; + print "Test_resize: Executed $count times resize key cache\n"; + exit(0); +} # # Test all tables in a database diff --git a/vio/viosocket.c b/vio/viosocket.c index 31941a64102..9d5c7c0d890 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -249,8 +249,8 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port) } else { - size_socket addrLen = sizeof(struct sockaddr); - if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), + size_socket addrLen = sizeof(vio->remote); + if (getpeername(vio->sd, (struct sockaddr *) (&vio->remote), &addrLen) != 0) { DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno)); |