From f00257ddd0a2f392f9b80c9cd5c405017e3a9d63 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 00:51:37 +0200 Subject: [PATCH 01/78] Fixed compiler warnings detected by option -Wshadow and -Wunused: - Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind') --- BUILD/SETUP.sh | 9 +- BUILD/compile-pentium-gcov | 4 +- client/mysql.cc | 67 +- client/mysql_upgrade.c | 4 +- client/mysqlbinlog.cc | 62 +- client/mysqldump.c | 20 +- client/mysqltest.c | 134 +- client/sql_string.cc | 50 +- client/sql_string.h | 6 +- cmd-line-utils/readline/display.c | 2 +- cmd-line-utils/readline/histexpand.c | 8 +- cmd-line-utils/readline/input.c | 8 +- cmd-line-utils/readline/text.c | 6 +- cmd-line-utils/readline/vi_mode.c | 8 +- dbug/dbug_analyze.c | 54 +- extra/my_print_defaults.c | 9 +- extra/yassl/include/buffer.hpp | 3 + extra/yassl/include/crypto_wrapper.hpp | 6 + extra/yassl/include/yassl_imp.hpp | 17 +- extra/yassl/include/yassl_int.hpp | 1 + extra/yassl/src/crypto_wrapper.cpp | 2 + extra/yassl/taocrypt/benchmark/benchmark.cpp | 32 +- extra/yassl/taocrypt/include/algebra.hpp | 3 + extra/yassl/taocrypt/include/des.hpp | 1 + extra/yassl/taocrypt/include/hash.hpp | 1 + extra/yassl/taocrypt/include/hmac.hpp | 4 +- extra/yassl/taocrypt/include/modarith.hpp | 4 +- extra/yassl/taocrypt/include/modes.hpp | 4 +- extra/yassl/taocrypt/include/rsa.hpp | 34 +- extra/yassl/taocrypt/mySTL/list.hpp | 16 +- extra/yassl/taocrypt/src/aes.cpp | 11 +- extra/yassl/taocrypt/src/algebra.cpp | 6 +- extra/yassl/taocrypt/src/asn.cpp | 4 +- extra/yassl/taocrypt/test/test.cpp | 92 +- extra/yassl/testsuite/testsuite.cpp | 13 +- include/m_ctype.h | 2 +- include/my_pthread.h | 16 +- include/my_sys.h | 7 +- include/my_time.h | 10 +- include/mysql.h | 3 +- libmysql/libmysql.c | 240 +- libmysqld/lib_sql.cc | 3 +- myisam/ft_boolean_search.c | 16 +- myisam/mi_open.c | 6 +- myisam/mi_search.c | 14 +- myisam/mi_unique.c | 2 +- myisam/myisampack.c | 9 +- myisam/rt_index.c | 3 - myisam/sort.c | 6 +- mysql-test/r/mysqlcheck.result | 3 + mysql-test/r/mysqltest.result | 2 + mysql-test/t/mysql.test | 12 +- mysql-test/t/mysqlbinlog.test | 8 + mysql-test/t/mysqlcheck.test | 9 + mysql-test/t/mysqltest.test | 20 + mysys/default.c | 38 +- mysys/mf_iocache2.c | 26 +- mysys/mf_keycache.c | 5 +- mysys/my_bitmap.c | 6 +- mysys/sha1.c | 12 +- .../kernel/signaldata/ArbitSignalData.hpp | 2 + ndb/include/kernel/signaldata/DictTabInfo.hpp | 2 + ndb/include/ndbapi/NdbReceiver.hpp | 2 +- .../transporter/TransporterDefinitions.hpp | 5 + ndb/include/util/InputStream.hpp | 1 + ndb/include/util/OutputStream.hpp | 2 + ndb/include/util/SimpleProperties.hpp | 1 + ndb/include/util/SocketAuthenticator.hpp | 1 + ndb/include/util/SocketServer.hpp | 1 + ndb/src/common/mgmcommon/ConfigRetriever.cpp | 7 +- ndb/src/common/portlib/NdbTick.c | 4 +- .../common/transporter/SHM_Transporter.cpp | 4 +- .../common/transporter/TCP_Transporter.cpp | 4 +- .../common/transporter/TCP_Transporter.hpp | 1 + ndb/src/common/transporter/Transporter.cpp | 4 +- .../transporter/TransporterRegistry.cpp | 2 - ndb/src/common/util/Bitmask.cpp | 30 +- ndb/src/common/util/ConfigValues.cpp | 6 +- ndb/src/common/util/File.cpp | 4 +- ndb/src/common/util/Properties.cpp | 4 +- ndb/src/common/util/SocketClient.cpp | 2 +- ndb/src/common/util/random.c | 8 +- ndb/src/common/util/socket_io.cpp | 4 +- ndb/src/cw/cpcd/APIService.cpp | 1 - ndb/src/cw/cpcd/main.cpp | 2 - ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 8 +- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 5 - ndb/src/kernel/blocks/dbdict/Dbdict.hpp | 6 + ndb/src/kernel/blocks/dbdih/Dbdih.hpp | 3 + ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 3 + ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 9 - ndb/src/kernel/blocks/dbtc/Dbtc.hpp | 4 + ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 1 + ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 1 - ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp | 2 - ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp | 2 - ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp | 1 - ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp | 1 + ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 4 - ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp | 2 + ndb/src/kernel/blocks/qmgr/Qmgr.hpp | 2 + ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 2 - ndb/src/kernel/blocks/suma/Suma.cpp | 6 - ndb/src/kernel/blocks/suma/Suma.hpp | 1 + ndb/src/kernel/vm/MetaData.hpp | 1 + ndb/src/mgmapi/LocalConfig.cpp | 18 +- ndb/src/mgmapi/mgmapi.cpp | 13 +- ndb/src/mgmclient/CommandInterpreter.cpp | 3 - ndb/src/mgmsrv/ConfigInfo.cpp | 6 +- ndb/src/mgmsrv/ConfigInfo.hpp | 7 +- ndb/src/mgmsrv/InitConfigFileParser.cpp | 25 +- ndb/src/mgmsrv/MgmtSrvr.cpp | 8 +- ndb/src/mgmsrv/MgmtSrvr.hpp | 1 + ndb/src/mgmsrv/Services.cpp | 9 +- ndb/src/mgmsrv/main.cpp | 1 - ndb/src/ndbapi/ClusterMgr.hpp | 1 + ndb/src/ndbapi/Ndb.cpp | 2 - ndb/src/ndbapi/NdbBlob.cpp | 2 - ndb/src/ndbapi/NdbDictionaryImpl.cpp | 5 - ndb/src/ndbapi/NdbIndexOperation.cpp | 2 - ndb/src/ndbapi/NdbOperationDefine.cpp | 3 +- ndb/src/ndbapi/NdbOperationExec.cpp | 2 - ndb/src/ndbapi/NdbOperationSearch.cpp | 3 - ndb/src/ndbapi/NdbScanFilter.cpp | 1 + ndb/src/ndbapi/NdbScanOperation.cpp | 3 - ndb/src/ndbapi/SignalSender.cpp | 2 + ndb/src/ndbapi/ndb_cluster_connection.cpp | 1 - ndb/tools/delete_all.cpp | 2 + ndb/tools/desc.cpp | 2 + ndb/tools/drop_index.cpp | 2 + ndb/tools/drop_tab.cpp | 2 + ndb/tools/listTables.cpp | 2 + ndb/tools/ndb_config.cpp | 13 +- ndb/tools/restore/Restore.hpp | 3 +- ndb/tools/restore/consumer.hpp | 1 + ndb/tools/restore/restore_main.cpp | 12 +- ndb/tools/select_all.cpp | 4 +- ndb/tools/select_count.cpp | 2 + server-tools/instance-manager/commands.h | 1 + server-tools/instance-manager/guardian.cc | 6 +- .../instance-manager/instance_options.cc | 2 - .../instance-manager/mysql_connection.cc | 6 +- server-tools/instance-manager/options.cc | 16 +- server-tools/instance-manager/options.h | 1 + server-tools/instance-manager/parse.cc | 1 - server-tools/instance-manager/user_map.cc | 1 + server-tools/instance-manager/user_map.h | 1 + sql-common/client.c | 4 +- sql-common/my_time.c | 57 +- sql/field.cc | 197 +- sql/field.h | 54 +- sql/filesort.cc | 4 +- sql/ha_archive.cc | 20 +- sql/ha_archive.h | 4 +- sql/ha_federated.cc | 8 +- sql/ha_heap.cc | 28 +- sql/ha_myisam.cc | 88 +- sql/ha_myisammrg.cc | 28 +- sql/ha_ndbcluster.cc | 91 +- sql/handler.cc | 9 +- sql/item.cc | 63 +- sql/item.h | 37 +- sql/item_cmpfunc.cc | 77 +- sql/item_cmpfunc.h | 28 +- sql/item_func.cc | 20 +- sql/item_geofunc.cc | 5 +- sql/item_row.h | 2 +- sql/item_strfunc.cc | 15 +- sql/item_subselect.cc | 41 +- sql/item_subselect.h | 6 +- sql/item_sum.cc | 25 +- sql/item_timefunc.cc | 10 +- sql/log.cc | 55 +- sql/log_event.cc | 10 +- sql/log_event.h | 2 + sql/mysql_priv.h | 8 +- sql/mysqld.cc | 100 +- sql/net_serv.cc | 8 +- sql/opt_range.cc | 156 +- sql/opt_range.h | 2 +- sql/password.c | 7 +- sql/protocol.cc | 4 +- sql/repl_failsafe.cc | 12 +- sql/set_var.cc | 9 +- sql/set_var.h | 82 +- sql/slave.cc | 26 +- sql/sp_head.cc | 10 +- sql/sp_head.h | 9 +- sql/spatial.cc | 25 +- sql/spatial.h | 12 +- sql/sql_cache.h | 6 +- sql/sql_class.cc | 14 +- sql/sql_class.h | 34 +- sql/sql_derived.cc | 2 - sql/sql_insert.cc | 12 +- sql/sql_lex.cc | 37 +- sql/sql_lex.h | 3 +- sql/sql_load.cc | 6 +- sql/sql_parse.cc | 196 +- sql/sql_prepare.cc | 13 +- sql/sql_select.cc | 105 +- sql/sql_show.cc | 34 +- sql/sql_string.cc | 19 +- sql/sql_string.h | 3 +- sql/sql_table.cc | 55 +- sql/sql_trigger.cc | 17 +- sql/sql_trigger.h | 5 +- sql/sql_union.cc | 89 +- sql/sql_update.cc | 1 - sql/sql_view.cc | 1 - sql/sql_yacc.yy | 7 +- sql/table.cc | 62 +- sql/tztime.cc | 4 +- sql/unireg.cc | 14 +- strings/ctype-bin.c | 6 +- strings/ctype-cp932.c | 4 +- strings/ctype-eucjpms.c | 4 +- strings/ctype-mb.c | 64 +- strings/ctype-simple.c | 14 +- strings/ctype-sjis.c | 4 +- strings/ctype-uca.c | 26 +- strings/ctype-ujis.c | 4 +- strings/ctype-utf8.c | 4 +- strings/decimal.c | 27 +- strings/my_vsnprintf.c | 7 + strings/strtod.c | 27 +- tests/mysql_client_test.c | 2370 ++++++++--------- 227 files changed, 3249 insertions(+), 3058 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 6f3c4222ed2..27c468daa6a 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -49,11 +49,14 @@ SSL_LIBRARY=--with-yassl # If you are not using codefusion add "-Wpointer-arith" to WARNINGS # The following warning flag will give too many warnings: -# -Wshadow -Wunused -Winline (The later isn't usable in C++ as +# -Wunused -Winline (The later isn't usable in C++ as # __attribute()__ doesn't work with gnu C++) -global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings" -#debug_extra_warnings="-Wuninitialized" +global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable" +# +# For more warnings, uncomment the following line +# global_warnings="$global_warnings -Wshadow" + c_warnings="$global_warnings -Wunused" cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" base_max_configs="--with-innodb --with-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY" diff --git a/BUILD/compile-pentium-gcov b/BUILD/compile-pentium-gcov index b024bba49bf..26475824570 100755 --- a/BUILD/compile-pentium-gcov +++ b/BUILD/compile-pentium-gcov @@ -14,7 +14,9 @@ export LDFLAGS="-fprofile-arcs -ftest-coverage" # The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the # code with profiling information used by gcov. # the -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl. -extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -DDISABLE_TAO_ASM" +extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -DDISABLE_TAO_ASM $debug_cflags $max_cflags -DMYSQL_SERVER_SUFFIX=-gcov" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs --disable-shared $static_link" extra_configs="$extra_configs $max_configs" diff --git a/client/mysql.cc b/client/mysql.cc index cd24e1d5ce2..51adada260d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -132,7 +132,7 @@ typedef enum enum_info_type INFO_TYPE; static MYSQL mysql; /* The connection */ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, connected=0,opt_raw_data=0,unbuffered=0,output_tables=0, - rehash=1,skip_updates=0,safe_updates=0,one_database=0, + opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0, opt_compress=0, using_opt_local_infile=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, @@ -586,7 +586,8 @@ static struct my_option my_long_options[] = #endif {"auto-rehash", OPT_AUTO_REHASH, "Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.", - (gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + (gptr*) &opt_rehash, (gptr*) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, + 0, 0}, {"no-auto-rehash", 'A', "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -876,7 +877,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } break; case 'A': - rehash= 0; + opt_rehash= 0; break; case 'N': column_names= 0; @@ -1756,15 +1757,17 @@ char *rindex(const char *s,int c) static int reconnect(void) { + /* purecov: begin tested */ if (opt_reconnect) { put_info("No connection. Trying to reconnect...",INFO_INFO); (void) com_connect((String *) 0, 0); - if (rehash) + if (opt_rehash) com_rehash(NULL, NULL); } if (!connected) return put_info("Can't connect to the server\n",INFO_ERROR); + /* purecov: end */ return 0; } @@ -2929,7 +2932,7 @@ static int com_connect(String *buffer, char *line) { char *tmp, buff[256]; - bool save_rehash= rehash; + bool save_rehash= opt_rehash; int error; bzero(buff, sizeof(buff)); @@ -2953,13 +2956,16 @@ com_connect(String *buffer, char *line) } } else - rehash= 0; // Quick re-connect + { + /* Quick re-connect */ + opt_rehash= 0; /* purecov: tested */ + } buffer->length(0); // command used } else - rehash= 0; + opt_rehash= 0; error=sql_connect(current_host,current_db,current_user,opt_password,0); - rehash= save_rehash; + opt_rehash= save_rehash; if (connected) { @@ -3113,7 +3119,7 @@ com_use(String *buffer __attribute__((unused)), char *line) current_db=my_strdup(tmp,MYF(MY_WME)); #ifdef HAVE_READLINE if (select_db > 1) - build_completion_hash(rehash, 1); + build_completion_hash(opt_rehash, 1); #endif } @@ -3267,7 +3273,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, mysql.reconnect= 1; #endif #ifdef HAVE_READLINE - build_completion_hash(rehash, 1); + build_completion_hash(opt_rehash, 1); #endif return 0; } @@ -3312,8 +3318,8 @@ static int com_status(String *buffer __attribute__((unused)), char *line __attribute__((unused))) { - const char *status; - char buff[22]; + const char *status_str; + char buff[40]; ulonglong id; MYSQL_RES *result; LINT_INIT(result); @@ -3339,9 +3345,9 @@ com_status(String *buffer __attribute__((unused)), mysql_free_result(result); } #ifdef HAVE_OPENSSL - if ((status= mysql_get_ssl_cipher(&mysql))) + if ((status_str= mysql_get_ssl_cipher(&mysql))) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - status); + status_str); else #endif /* HAVE_OPENSSL */ tee_puts("SSL:\t\t\tNot in use", stdout); @@ -3400,23 +3406,20 @@ com_status(String *buffer __attribute__((unused)), tee_fprintf(stdout, "Protocol:\t\tCompressed\n"); #endif - if ((status=mysql_stat(&mysql)) && !mysql_error(&mysql)[0]) + if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0]) { ulong sec; - char buff[40]; - const char *pos= strchr(status,' '); + const char *pos= strchr(status_str,' '); /* print label */ - tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status), status); - if ((status=str2int(pos,10,0,LONG_MAX,(long*) &sec))) + tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str); + if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec))) { nice_time((double) sec,buff,0); tee_puts(buff, stdout); /* print nice time */ - while (*status == ' ') status++; /* to next info */ - } - if (status) - { + while (*status_str == ' ') + status_str++; /* to next info */ tee_putc('\n', stdout); - tee_puts(status, stdout); + tee_puts(status_str, stdout); } } if (safe_updates) @@ -3436,7 +3439,7 @@ select_limit, max_join_size); } static const char * -server_version_string(MYSQL *mysql) +server_version_string(MYSQL *con) { static char buf[MAX_SERVER_VERSION_LENGTH] = ""; @@ -3446,11 +3449,11 @@ server_version_string(MYSQL *mysql) char *bufp = buf; MYSQL_RES *result; - bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf); + bufp= strnmov(buf, mysql_get_server_info(con), sizeof buf); /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */ - if (!mysql_query(mysql, "select @@version_comment limit 1") && - (result = mysql_use_result(mysql))) + if (!mysql_query(con, "select @@version_comment limit 1") && + (result = mysql_use_result(con))) { MYSQL_ROW cur = mysql_fetch_row(result); if (cur && cur[0]) @@ -3540,10 +3543,10 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) static int -put_error(MYSQL *mysql) +put_error(MYSQL *con) { - return put_info(mysql_error(mysql), INFO_ERROR, mysql_errno(mysql), - mysql_sqlstate(mysql)); + return put_info(mysql_error(con), INFO_ERROR, mysql_errno(con), + mysql_sqlstate(con)); } @@ -3802,8 +3805,6 @@ static const char* construct_prompt() break; case 'D': char* dateTime; - time_t lclock; - lclock = time(NULL); dateTime = ctime(&lclock); processed_prompt.append(strtok(dateTime,"\n")); break; diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 520d87b5ed7..136958368a8 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -438,7 +438,7 @@ int main(int argc, char **argv) char *forced_defaults_file; char *forced_extra_defaults; - char *defaults_group_suffix; + char *local_defaults_group_suffix; const char *script_line; char *upgrade_defaults_path; char *defaults_to_use= NULL; @@ -455,7 +455,7 @@ int main(int argc, char **argv) /* Check if we are forced to use specific defaults */ get_defaults_options(argc, argv, &forced_defaults_file, &forced_extra_defaults, - &defaults_group_suffix); + &local_defaults_group_suffix); load_defaults("my", load_default_groups, &argc, &argv); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ff4e0b5a5cf..4637f5e1f77 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -92,13 +92,12 @@ static bool stop_passed= 0; This is because the event will be created (alloced) in read_log_event() (which returns a pointer) in check_header(). */ -Format_description_log_event* description_event; +Format_description_log_event* glob_description_event; static int dump_local_log_entries(const char* logname); static int dump_remote_log_entries(const char* logname); static int dump_log_entries(const char* logname); -static int dump_remote_file(NET* net, const char* fname); -static void die(const char* fmt, ...); +static void die(const char* fmt, ...) __attribute__ ((__noreturn__)); static MYSQL* safe_connect(); @@ -559,7 +558,7 @@ int process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, ce->print(result_file, print_event_info, TRUE); // If this binlog is not 3.23 ; why this test?? - if (description_event->binlog_version >= 3) + if (glob_description_event->binlog_version >= 3) { if (load_processor.process(ce)) break; // Error @@ -594,9 +593,9 @@ Create_file event for file_id: %u\n",exv->file_id); break; } case FORMAT_DESCRIPTION_EVENT: - delete description_event; - description_event= (Format_description_log_event*) ev; - print_event_info->common_header_len= description_event->common_header_len; + delete glob_description_event; + glob_description_event= (Format_description_log_event*) ev; + print_event_info->common_header_len= glob_description_event->common_header_len; ev->print(result_file, print_event_info); /* We don't want this event to be deleted now, so let's hide it (I @@ -802,7 +801,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 3.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); NETWARE_SET_SCREEN_MODE(1); } @@ -959,7 +958,7 @@ static int dump_log_entries(const char* logname) This is not as smart as check_header() (used for local log); it will not work for a binlog which mixes format. TODO: fix this. */ -static int check_master_version(MYSQL* mysql, +static int check_master_version(MYSQL *mysql_arg, Format_description_log_event **description_event) { @@ -967,26 +966,31 @@ static int check_master_version(MYSQL* mysql, MYSQL_ROW row; const char* version; - if (mysql_query(mysql, "SELECT VERSION()") || - !(res = mysql_store_result(mysql))) + if (mysql_query(mysql_arg, "SELECT VERSION()") || + !(res = mysql_store_result(mysql_arg))) { + /* purecov: begin inspected */ char errmsg[256]; - strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1); - mysql_close(mysql); + strmake(errmsg, mysql_error(mysql_arg), sizeof(errmsg)-1); + mysql_close(mysql_arg); die("Error checking master version: %s", errmsg); + /* purecov: end */ } if (!(row = mysql_fetch_row(res))) { + /* purecov: begin inspected */ mysql_free_result(res); mysql_close(mysql); die("Master returned no rows for SELECT VERSION()"); - return 1; + /* purecov: end */ } if (!(version = row[0])) { + /* purecov: begin inspected */ mysql_free_result(res); - mysql_close(mysql); + mysql_close(mysql_arg); die("Master reported NULL for the version"); + /* purecov: end */ } switch (*version) { @@ -1005,11 +1009,11 @@ static int check_master_version(MYSQL* mysql, *description_event= new Format_description_log_event(3); break; default: - sql_print_error("Master reported unrecognized MySQL version '%s'", - version); + /* purecov: begin inspected */ mysql_free_result(res); - mysql_close(mysql); - return 1; + mysql_close(mysql_arg); + die("Master reported unrecognized MySQL version '%s'", version); + /* purecov: end */ } mysql_free_result(res); return 0; @@ -1037,12 +1041,12 @@ static int dump_remote_log_entries(const char* logname) mysql= safe_connect(); net= &mysql->net; - if (check_master_version(mysql, &description_event)) + if (check_master_version(mysql, &glob_description_event)) { fprintf(stderr, "Could not find server version"); DBUG_RETURN(1); } - if (!description_event || !description_event->is_valid()) + if (!glob_description_event || !glob_description_event->is_valid()) { fprintf(stderr, "Invalid Format_description log event; \ could be out of memory"); @@ -1092,7 +1096,7 @@ could be out of memory"); len, net->read_pos[5])); if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 , len - 1, &error_msg, - description_event))) + glob_description_event))) { fprintf(stderr, "Could not construct log event object\n"); error= 1; @@ -1100,7 +1104,7 @@ could be out of memory"); } Log_event_type type= ev->get_type_code(); - if (description_event->binlog_version >= 3 || + if (glob_description_event->binlog_version >= 3 || (type != LOAD_EVENT && type != CREATE_FILE_EVENT)) { /* @@ -1306,14 +1310,14 @@ static int dump_local_log_entries(const char* logname) my_close(fd, MYF(MY_WME)); return 1; } - check_header(file, &description_event); + check_header(file, &glob_description_event); } else // reading from stdin; { if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) return 1; - check_header(file, &description_event); + check_header(file, &glob_description_event); if (start_position) { /* skip 'start_position' characters from stdin */ @@ -1331,7 +1335,7 @@ static int dump_local_log_entries(const char* logname) } } - if (!description_event || !description_event->is_valid()) + if (!glob_description_event || !glob_description_event->is_valid()) die("Invalid Format_description log event; could be out of memory"); if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE)) @@ -1344,14 +1348,14 @@ static int dump_local_log_entries(const char* logname) char llbuff[21]; my_off_t old_off = my_b_tell(file); - Log_event* ev = Log_event::read_log_event(file, description_event); + Log_event* ev = Log_event::read_log_event(file, glob_description_event); if (!ev) { /* if binlog wasn't closed properly ("in use" flag is set) don't complain about a corruption, but treat it as EOF and move to the next binlog. */ - if (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F) + if (glob_description_event->flags & LOG_EVENT_BINLOG_IN_USE_F) file->error= 0; else if (file->error) { @@ -1376,7 +1380,7 @@ end: if (fd >= 0) my_close(fd, MYF(MY_WME)); end_io_cache(file); - delete description_event; + delete glob_description_event; return error; } diff --git a/client/mysqldump.c b/client/mysqldump.c index 05765ef2a02..6ce01cbff86 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -112,7 +112,7 @@ static char compatible_mode_normal_str[255]; static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 -static uint opt_mysql_port= 0, err_len= 0, opt_master_data; +static uint opt_mysql_port= 0, opt_master_data; static my_string opt_mysql_unix_port=0; static int first_error=0; static DYNAMIC_STRING extended_row; @@ -724,6 +724,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *end= compatible_mode_normal_str; int i; ulong mode; + uint err_len; opt_quoted= 1; opt_set_charset= 0; @@ -861,11 +862,11 @@ static int get_options(int *argc, char ***argv) /* ** DB_error -- prints mysql error message and exits the program. */ -static void DB_error(MYSQL *mysql, const char *when) +static void DB_error(MYSQL *mysql_arg, const char *when) { DBUG_ENTER("DB_error"); fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname, - mysql_errno(mysql), mysql_error(mysql), when); + mysql_errno(mysql_arg), mysql_error(mysql_arg), when); fflush(stderr); safe_exit(EX_MYSQLERR); DBUG_VOID_RETURN; @@ -1193,7 +1194,7 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) ..., attribute_name_n, attribute_value_n, NullS) xml_file - output file sbeg - line beginning - send - line ending + line_end - line ending tag_name - XML tag name. first_attribute_name - tag and first attribute first_attribute_value - (Implied) value of first attribute @@ -1213,7 +1214,8 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) All attribute_value arguments will be quoted before output. */ -static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send, +static void print_xml_tag(FILE * xml_file, const char* sbeg, + const char* line_end, const char* tag_name, const char* first_attribute_name, ...) { @@ -1243,7 +1245,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send, va_end(arg_list); fputc('>', xml_file); - fputs(send, xml_file); + fputs(line_end, xml_file); check_io(xml_file); } @@ -1257,7 +1259,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send, sbeg - line beginning stag_atr - tag and attribute sval - value of attribute - send - line ending + line_end - line ending DESCRIPTION Print tag with one attribute to the xml_file. Format is: @@ -1269,7 +1271,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, const char* send, static void print_xml_null_tag(FILE * xml_file, const char* sbeg, const char* stag_atr, const char* sval, - const char* send) + const char* line_end) { fputs(sbeg, xml_file); fputs("<", xml_file); @@ -1277,7 +1279,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, fputs("\"", xml_file); print_quoted_xml(xml_file, sval, strlen(sval)); fputs("\" xsi:nil=\"true\" />", xml_file); - fputs(send, xml_file); + fputs(line_end, xml_file); check_io(xml_file); } diff --git a/client/mysqltest.c b/client/mysqltest.c index 318e5064ab8..210a89c024c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -85,10 +85,10 @@ enum { }; static int record= 0, opt_sleep= -1; -static char *db= 0, *pass= 0; -const char *user= 0, *host= 0, *unix_sock= 0, *opt_basedir= "./"; +static char *opt_db= 0, *opt_pass= 0; +const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./"; const char *opt_include= 0, *opt_charsets_dir; -static int port= 0; +static int opt_port= 0; static int opt_max_connect_retries; static my_bool opt_compress= 0, silent= 0, verbose= 0; static my_bool tty_password= 0; @@ -604,15 +604,14 @@ void check_command_args(struct st_command *command, int i; const char *ptr= arguments; const char *start; - DBUG_ENTER("check_command_args"); DBUG_PRINT("enter", ("num_args: %d", num_args)); + for (i= 0; i < num_args; i++) { const struct command_arg *arg= &args[i]; - switch (arg->type) - { + switch (arg->type) { /* A string */ case ARG_STRING: /* Skip leading spaces */ @@ -763,7 +762,7 @@ void free_used_memory() dynstr_free(&ds_progress); dynstr_free(&ds_warning_messages); free_all_replace(); - my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); + my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR)); free_defaults(default_argv); mysql_server_end(); free_re(); @@ -1286,7 +1285,7 @@ void var_set_errno(int sql_errno) void var_query_set(VAR *var, const char *query, const char** query_end) { - char* end = (char*)((query_end && *query_end) ? + char *end = (char*)((query_end && *query_end) ? *query_end : query + strlen(query)); MYSQL_RES *res; MYSQL_ROW row; @@ -1317,7 +1316,6 @@ void var_query_set(VAR *var, const char *query, const char** query_end) DYNAMIC_STRING result; uint i; ulong *lengths; - char *end; #ifdef NOT_YET MYSQL_FIELD *fields= mysql_fetch_fields(res); #endif @@ -2062,6 +2060,7 @@ void do_perl(struct st_command *command) int do_echo(struct st_command *command) { DYNAMIC_STRING ds_echo; + DBUG_ENTER("do_echo"); init_dynamic_string(&ds_echo, "", command->query_len, 256); do_eval(&ds_echo, command->first_argument, command->end, FALSE); @@ -2069,7 +2068,7 @@ int do_echo(struct st_command *command) dynstr_append_mem(&ds_res, "\n", 1); dynstr_free(&ds_echo); command->last_argument= command->end; - return(0); + DBUG_RETURN(0); } @@ -2365,7 +2364,6 @@ void do_let(struct st_command *command) char *p= command->first_argument; char *var_name, *var_name_end; DYNAMIC_STRING let_rhs_expr; - DBUG_ENTER("do_let"); init_dynamic_string(&let_rhs_expr, "", 512, 2048); @@ -3034,7 +3032,7 @@ int connect_n_handle_errors(struct st_command *command, void do_connect(struct st_command *command) { - int con_port= port; + int con_port= opt_port; char *con_options; bool con_ssl= 0, con_compress= 0; char *ptr; @@ -3170,13 +3168,12 @@ void do_connect(struct st_command *command) /* Use default db name */ if (ds_database.length == 0) - dynstr_set(&ds_database, db); + dynstr_set(&ds_database, opt_db); /* Special database to allow one to connect without a database name */ if (ds_database.length && !strcmp(ds_database.str,"*NO-ONE*")) dynstr_set(&ds_database, ""); - if (connect_n_handle_errors(command, &next_con->mysql, ds_host.str,ds_user.str, ds_password.str, ds_database.str, @@ -3600,7 +3597,7 @@ int read_line(char *buf, int size) void convert_to_format_v1(char* query) { int last_c_was_quote= 0; - char *p= query, *write= query; + char *p= query, *to= query; char *end= strend(query); char last_c; @@ -3608,7 +3605,7 @@ void convert_to_format_v1(char* query) { if (*p == '\n' && !last_c_was_quote) { - *write++ = *p++; /* Save the newline */ + *to++ = *p++; /* Save the newline */ /* Skip any spaces on next line */ while (*p && my_isspace(charset_info, *p)) @@ -3619,19 +3616,19 @@ void convert_to_format_v1(char* query) else if (*p == '\'' || *p == '"' || *p == '`') { last_c= *p; - *write++ = *p++; + *to++ = *p++; /* Copy anything until the next quote of same type */ while (*p && *p != last_c) - *write++ = *p++; + *to++ = *p++; - *write++ = *p++; + *to++ = *p++; last_c_was_quote= 1; } else { - *write++ = *p++; + *to++ = *p++; last_c_was_quote= 0; } } @@ -3749,19 +3746,17 @@ void check_eol_junk(const char *eol) Create a command from a set of lines SYNOPSIS - read_command() - command_ptr pointer where to return the new query + read_command() + command_ptr pointer where to return the new query DESCRIPTION - Converts lines returned by read_line into a command, this involves - parsing the first word in the read line to find the command type. - + Converts lines returned by read_line into a command, this involves + parsing the first word in the read line to find the command type. A -- comment may contain a valid query as the first word after the comment start. Thus it's always checked to see if that is the case. The advantage with this approach is to be able to execute commands terminated by new line '\n' regardless how many "delimiter" it contain. - */ #define MAX_QUERY (256*1024) /* 256K -- a test in sp-big is >128K */ @@ -3847,7 +3842,7 @@ static struct my_option my_long_options[] = {"cursor-protocol", OPT_CURSOR_PROTOCOL, "Use cursors for prepared statements.", (gptr*) &cursor_protocol, (gptr*) &cursor_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use.", (gptr*) &db, (gptr*) &db, 0, + {"database", 'D', "Database to use.", (gptr*) &opt_db, (gptr*) &opt_db, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", @@ -3856,7 +3851,7 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, + {"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &opt_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include, (gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -3870,8 +3865,8 @@ static struct my_option my_long_options[] = GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &port, - (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection.", (gptr*) &opt_port, + (gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication", (gptr*) &ps_protocol, (gptr*) &ps_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -3907,8 +3902,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Temporary directory where sockets are put.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login.", (gptr*) &user, (gptr*) &user, 0, GET_STR, - REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login.", (gptr*) &opt_user, (gptr*) &opt_user, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Write more.", (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", @@ -4035,8 +4030,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'p': if (argument) { - my_free(pass, MYF(MY_ALLOW_ZERO_PTR)); - pass= my_strdup(argument, MYF(MY_FAE)); + my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR)); + opt_pass= my_strdup(argument, MYF(MY_FAE)); while (*argument) *argument++= 'x'; /* Destroy argument */ tty_password= 0; } @@ -4073,7 +4068,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), exit(0); case '?': usage(); - exit(1); + exit(0); } return 0; } @@ -4093,9 +4088,9 @@ int parse_args(int argc, char **argv) exit(1); } if (argc == 1) - db= *argv; + opt_db= *argv; if (tty_password) - pass=get_tty_password(NullS); + opt_pass= get_tty_password(NullS); /* purify tested */ return 0; } @@ -4370,13 +4365,13 @@ void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, MYSQL_FIELD *fields, uint num_fields) { - MYSQL_BIND *bind; + MYSQL_BIND *my_bind; my_bool *is_null; ulong *length; uint i; /* Allocate array with bind structs, lengths and NULL flags */ - bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND), + my_bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND), MYF(MY_WME | MY_FAE | MY_ZEROFILL)); length= (ulong*) my_malloc(num_fields * sizeof(ulong), MYF(MY_WME | MY_FAE)); @@ -4387,25 +4382,25 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, for (i= 0; i < num_fields; i++) { uint max_length= fields[i].max_length + 1; - bind[i].buffer_type= MYSQL_TYPE_STRING; - bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE)); - bind[i].buffer_length= max_length; - bind[i].is_null= &is_null[i]; - bind[i].length= &length[i]; + my_bind[i].buffer_type= MYSQL_TYPE_STRING; + my_bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE)); + my_bind[i].buffer_length= max_length; + my_bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %lu", - i, bind[i].buffer_type, bind[i].buffer_length)); + i, my_bind[i].buffer_type, my_bind[i].buffer_length)); } - if (mysql_stmt_bind_result(stmt, bind)) + if (mysql_stmt_bind_result(stmt, my_bind)) die("mysql_stmt_bind_result failed: %d: %s", mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); while (mysql_stmt_fetch(stmt) == 0) { for (i= 0; i < num_fields; i++) - append_field(ds, i, &fields[i], (const char *) bind[i].buffer, - *bind[i].length, *bind[i].is_null); + append_field(ds, i, &fields[i], (const char *) my_bind[i].buffer, + *my_bind[i].length, *my_bind[i].is_null); if (!display_result_vertically) dynstr_append_mem(ds, "\n", 1); } @@ -4417,10 +4412,10 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, for (i= 0; i < num_fields; i++) { /* Free data for output */ - my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE)); + my_free((gptr)my_bind[i].buffer, MYF(MY_WME | MY_FAE)); } /* Free array with bind structs, lengths and NULL flags */ - my_free((gptr)bind , MYF(MY_WME | MY_FAE)); + my_free((gptr)my_bind , MYF(MY_WME | MY_FAE)); my_free((gptr)length , MYF(MY_WME | MY_FAE)); my_free((gptr)is_null , MYF(MY_WME | MY_FAE)); } @@ -4557,17 +4552,14 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) /* Run query using MySQL C API - SYNPOSIS - run_query_normal - mysql - mysql handle - command - currrent command pointer - flags -flags indicating wheter to SEND and/or REAP - query - query string to execute - query_len - length query string to execute - ds - output buffer wherte to store result form query - - RETURN VALUE - error - function will not return + SYNOPSIS + run_query_normal() + mysql mysql handle + command current command pointer + flags flags indicating if we should SEND and/or REAP + query query string to execute + query_len length query string to execute + ds output buffer where to store result form query */ void run_query_normal(struct st_connection *cn, struct st_command *command, @@ -5085,15 +5077,14 @@ int util_query(MYSQL* org_mysql, const char* query){ /* Run query + SYNPOSIS + run_query() + mysql mysql handle + command currrent command pointer + flags control the phased/stages of query execution to be performed if QUERY_SEND_FLAG bit is on, the query will be sent. If QUERY_REAP_FLAG is on the result will be read - for regular query, both bits must be on - - SYNPOSIS - run_query - mysql - mysql handle - command - currrent command pointer - */ void run_query(struct st_connection *cn, struct st_command *command, int flags) @@ -5108,6 +5099,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) my_bool view_created= 0, sp_created= 0; my_bool complete_query= ((flags & QUERY_SEND_FLAG) && (flags & QUERY_REAP_FLAG)); + DBUG_ENTER("run_query"); init_dynamic_string(&ds_warnings, NULL, 0, 256); @@ -5273,7 +5265,6 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) if (command->require_file[0]) { - /* A result file was specified for _this_ query and the output should be checked against an already existing file which has been specified using --require or --result @@ -5286,6 +5277,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) dynstr_free(&ds_result); if (command->type == Q_EVAL) dynstr_free(&eval_query); + DBUG_VOID_RETURN; } /****************************************************************************/ @@ -5612,8 +5604,8 @@ int main(int argc, char **argv) if (!(cur_con->name = my_strdup("default", MYF(MY_WME)))) die("Out of memory"); - safe_connect(&cur_con->mysql, cur_con->name, host, user, pass, - db, port, unix_sock); + safe_connect(&cur_con->mysql, cur_con->name, opt_host, opt_user, opt_pass, + opt_db, opt_port, unix_sock); /* Use all time until exit if no explicit 'start_timer' */ timer_start= timer_now(); @@ -5975,8 +5967,6 @@ int main(int argc, char **argv) if (result_file_name && ds_warning_messages.length) dump_warning_messages(); - dynstr_free(&ds_res); - timer_output(); free_used_memory(); my_end(MY_CHECK_ERROR); diff --git a/client/sql_string.cc b/client/sql_string.cc index 51f802e7465..9c75a206dfd 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -248,6 +248,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs) 0 No conversion needed 1 Either character set conversion or adding leading zeros (e.g. for UCS-2) must be done + + NOTE + to_cs may be NULL for "no conversion" if the system variable + character_set_results is NULL. */ bool String::needs_conversion(uint32 arg_length, @@ -256,7 +260,8 @@ bool String::needs_conversion(uint32 arg_length, uint32 *offset) { *offset= 0; - if ((to_cs == &my_charset_bin) || + if (!to_cs || + (to_cs == &my_charset_bin) || (to_cs == from_cs) || my_charset_same(from_cs, to_cs) || ((from_cs == &my_charset_bin) && @@ -613,27 +618,26 @@ skip: } /* -** replace substring with string -** If wrong parameter or not enough memory, do nothing + Replace substring with string + If wrong parameter or not enough memory, do nothing */ - bool String::replace(uint32 offset,uint32 arg_length,const String &to) { return replace(offset,arg_length,to.ptr(),to.length()); } bool String::replace(uint32 offset,uint32 arg_length, - const char *to,uint32 length) + const char *to, uint32 to_length) { - long diff = (long) length-(long) arg_length; + long diff = (long) to_length-(long) arg_length; if (offset+arg_length <= str_length) { if (diff < 0) { - if (length) - memcpy(Ptr+offset,to,length); - bmove(Ptr+offset+length,Ptr+offset+arg_length, + if (to_length) + memcpy(Ptr+offset,to,to_length); + bmove(Ptr+offset+to_length,Ptr+offset+arg_length, str_length-offset-arg_length); } else @@ -645,8 +649,8 @@ bool String::replace(uint32 offset,uint32 arg_length, bmove_upp(Ptr+str_length+diff,Ptr+str_length, str_length-offset-arg_length); } - if (length) - memcpy(Ptr+offset,to,length); + if (to_length) + memcpy(Ptr+offset,to,to_length); } str_length+=(uint32) diff; } @@ -819,8 +823,18 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, from++; wc= '?'; } + else if (cnvres > MY_CS_TOOSMALL) + { + /* + A correct multibyte sequence detected + But it doesn't have Unicode mapping. + */ + error_count++; + from+= (-cnvres); + wc= '?'; + } else - break; // Impossible char. + break; // Not enough characters outp: if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0) @@ -848,22 +862,22 @@ void String::print(String *str) switch (c) { case '\\': - str->append("\\\\", 2); + str->append(STRING_WITH_LEN("\\\\")); break; case '\0': - str->append("\\0", 2); + str->append(STRING_WITH_LEN("\\0")); break; case '\'': - str->append("\\'", 2); + str->append(STRING_WITH_LEN("\\'")); break; case '\n': - str->append("\\n", 2); + str->append(STRING_WITH_LEN("\\n")); break; case '\r': - str->append("\\r", 2); + str->append(STRING_WITH_LEN("\\r")); break; case 26: //Ctrl-Z - str->append("\\z", 2); + str->append(STRING_WITH_LEN("\\z")); break; default: str->append(c); diff --git a/client/sql_string.h b/client/sql_string.h index e284301b214..48c550bab17 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -24,6 +24,8 @@ #define NOT_FIXED_DEC 31 #endif +#define STRING_WITH_LEN(X) ((const char*) X), ((uint) (sizeof(X) - 1)) + class String; int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); @@ -77,13 +79,15 @@ public: { /* never called */ } ~String() { free(); } - inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; } + inline void set_charset(CHARSET_INFO *charset_arg) + { str_charset= charset_arg; } inline CHARSET_INFO *charset() const { return str_charset; } inline uint32 length() const { return str_length;} inline uint32 alloced_length() const { return Alloced_length;} inline char& operator [] (uint32 i) const { return Ptr[i]; } inline void length(uint32 len) { str_length=len ; } inline bool is_empty() { return (str_length == 0); } + inline void mark_as_const() { Alloced_length= 0;} inline const char *ptr() const { return Ptr; } inline char *c_ptr() { diff --git a/cmd-line-utils/readline/display.c b/cmd-line-utils/readline/display.c index 46b57325e33..ba410a1be17 100644 --- a/cmd-line-utils/readline/display.c +++ b/cmd-line-utils/readline/display.c @@ -426,7 +426,7 @@ rl_redisplay () #if defined (HANDLE_MULTIBYTE) wchar_t wc; size_t wc_bytes; - int wc_width; + int wc_width= 0; mbstate_t ps; int _rl_wrapped_multicolumn = 0; #endif diff --git a/cmd-line-utils/readline/histexpand.c b/cmd-line-utils/readline/histexpand.c index a09be00a859..0a45438990a 100644 --- a/cmd-line-utils/readline/histexpand.c +++ b/cmd-line-utils/readline/histexpand.c @@ -560,12 +560,12 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - int c, l; + int chr, l; l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY); - c = string[l]; + chr = string[l]; /* XXX - original patch had i - 1 ??? If i == 0 it would fail. */ - if (i && (c == '\'' || c == '"')) - quoted_search_delimiter = c; + if (i && (chr == '\'' || chr == '"')) + quoted_search_delimiter = chr; } else #endif /* HANDLE_MULTIBYTE */ diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c index b2f8016050d..818f2e8763d 100644 --- a/cmd-line-utils/readline/input.c +++ b/cmd-line-utils/readline/input.c @@ -529,17 +529,17 @@ _rl_read_mbchar (mbchar, size) may be FIRST. Used by the search functions, among others. Very similar to _rl_read_mbchar. */ int -_rl_read_mbstring (first, mb, mblen) +_rl_read_mbstring (first, mb, mb_len) int first; char *mb; - int mblen; + int mb_len; { int i, c; mbstate_t ps; c = first; - memset (mb, 0, mblen); - for (i = 0; i < mblen; i++) + memset (mb, 0, mb_len); + for (i = 0; i < mb_len; i++) { mb[i] = (char)c; memset (&ps, 0, sizeof (mbstate_t)); diff --git a/cmd-line-utils/readline/text.c b/cmd-line-utils/readline/text.c index 89457be37cd..cf9223df844 100644 --- a/cmd-line-utils/readline/text.c +++ b/cmd-line-utils/readline/text.c @@ -1002,12 +1002,12 @@ _rl_rubout_char (count, key) } else { - int orig_point; + int orig_point2; - orig_point = rl_point; + orig_point2 = rl_point; rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); c = rl_line_buffer[rl_point]; - rl_delete_text (rl_point, orig_point); + rl_delete_text (rl_point, orig_point2); } #endif /* HANDLE_MULTIBYTE */ diff --git a/cmd-line-utils/readline/vi_mode.c b/cmd-line-utils/readline/vi_mode.c index 4d1cc56117d..a277fe2c237 100644 --- a/cmd-line-utils/readline/vi_mode.c +++ b/cmd-line-utils/readline/vi_mode.c @@ -672,7 +672,7 @@ _rl_vi_change_mbchar_case (count) { wchar_t wc; char mb[MB_LEN_MAX+1]; - int mblen; + int local_mblen; mbstate_t ps; memset (&ps, 0, sizeof (mbstate_t)); @@ -695,9 +695,9 @@ _rl_vi_change_mbchar_case (count) /* Vi is kind of strange here. */ if (wc) { - mblen = wcrtomb (mb, wc, &ps); - if (mblen >= 0) - mb[mblen] = '\0'; + local_mblen = wcrtomb (mb, wc, &ps); + if (local_mblen >= 0) + mb[local_mblen] = '\0'; rl_begin_undo_group (); rl_delete (1, 0); rl_insert_text (mb); diff --git a/dbug/dbug_analyze.c b/dbug/dbug_analyze.c index f1caeea2be4..8cd0af4f7e0 100644 --- a/dbug/dbug_analyze.c +++ b/dbug/dbug_analyze.c @@ -309,7 +309,7 @@ FILE *inf; unsigned long fn_ssz; unsigned long lastuse; unsigned int pos; - unsigned long time; + unsigned long local_time; unsigned int oldpos; unsigned long oldtime; unsigned long oldchild; @@ -335,15 +335,15 @@ FILE *inf; */ while (pop (&oldpos, &oldtime, &oldchild)) { DBUG_PRINT ("popped", ("%lu %lu", oldtime, oldchild)); - time = fn_time - oldtime; + local_time = fn_time - oldtime; t = top (); - t -> children += time; + t -> children += local_time; DBUG_PRINT ("update", ("%s", modules[t -> pos].name)); DBUG_PRINT ("update", ("%lu", t -> children)); - time -= oldchild; - modules[oldpos].m_time += time; + local_time -= oldchild; + modules[oldpos].m_time += local_time; modules[oldpos].m_calls++; - tot_time += time; + tot_time += local_time; tot_calls++; if (pos == oldpos) { goto next_line; /* Should be a break2 */ @@ -355,11 +355,11 @@ FILE *inf; * it so that it works the next time too. */ t = top (); - time = fn_time - t -> time - t -> children; + local_time = fn_time - t -> time - t -> children; t -> time = fn_time; t -> children = 0; - modules[pos].m_time += time; + modules[pos].m_time += local_time; modules[pos].m_calls++; - tot_time += time; + tot_time += local_time; tot_calls++; break; case 'S': @@ -405,13 +405,13 @@ FILE *inf; * time of fn_time. */ while (pop (&oldpos,&oldtime,&oldchild)) { - time = fn_time - oldtime; + local_time = fn_time - oldtime; t = top (); - t -> children += time; - time -= oldchild; - modules[oldpos].m_time += time; + t -> children += local_time; + local_time -= oldchild; + modules[oldpos].m_time += local_time; modules[oldpos].m_calls++; - tot_time += time; + tot_time += local_time; tot_calls++; } DBUG_VOID_RETURN; @@ -472,17 +472,17 @@ unsigned long int *called, *timed; { char *name = m -> name; register unsigned int calls = m -> m_calls; - register unsigned long time = m -> m_time; + register unsigned long local_time = m -> m_time; register unsigned long stkuse = m -> m_stkuse; unsigned int import; double per_time = 0.0; double per_calls = 0.0; - double ms_per_call, ftime; + double ms_per_call, local_ftime; DBUG_ENTER ("out_item"); if (tot_time > 0) { - per_time = (double) (time * 100) / (double) tot_time; + per_time = (double) (local_time * 100) / (double) tot_time; } if (tot_calls > 0) { per_calls = (double) (calls * 100) / (double) tot_calls; @@ -491,18 +491,18 @@ unsigned long int *called, *timed; if (verbose) { fprintf (outf, "%6d\t%10.2f\t%11ld\t%10.2f %10d\t%-15s\n", - calls, per_calls, time, per_time, import, name); + calls, per_calls, local_time, per_time, import, name); } else { - ms_per_call = time; + ms_per_call = local_time; ms_per_call /= calls; - ftime = time; - ftime /= 1000; + local_ftime = local_time; + local_ftime /= 1000; fprintf(outf, "%8.2f%8.3f%8u%8.3f%8.2f%8u%8lu %-s\n", - per_time, ftime, calls, ms_per_call, per_calls, import, + per_time, local_ftime, calls, ms_per_call, per_calls, import, stkuse, name); } *called = calls; - *timed = time; + *timed = local_time; DBUG_VOID_RETURN; } @@ -517,7 +517,7 @@ FILE *outf; register unsigned int root; register unsigned long int *s_calls, *s_time; { - unsigned long int calls, time; + unsigned long int calls, local_time; DBUG_ENTER ("out_body"); DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time)); @@ -526,10 +526,10 @@ register unsigned long int *s_calls, *s_time; } else { while (root != MAXPROCS) { out_body (outf, s_table[root].lchild,s_calls,s_time); - out_item (outf, &modules[s_table[root].pos],&calls,&time); - DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, time)); + out_item (outf, &modules[s_table[root].pos],&calls,&local_time); + DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, local_time)); *s_calls += calls; - *s_time += time; + *s_time += local_time; root = s_table[root].rchild; } DBUG_PRINT ("out_body", ("%lu,%lu", *s_calls, *s_time)); diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index bcf8c7aed7c..b358e9246cd 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -49,15 +49,16 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"defaults-extra-file", 'e', "Read this file after the global /etc config file and before the config file in the users home directory.", - (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, - REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (gptr*) &my_defaults_extra_file, (gptr*) &my_defaults_extra_file, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"defaults-group-suffix", 'g', "In addition to the given groups, read also groups with this suffix", - (gptr*) &defaults_group_suffix, (gptr*) &defaults_group_suffix, + (gptr*) &my_defaults_group_suffix, (gptr*) &my_defaults_group_suffix, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"extra-file", 'e', "Synonym for --defaults-extra-file.", - (gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR, + (gptr*) &my_defaults_extra_file, + (gptr*) &my_defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"no-defaults", 'n', "Return an empty string (useful for scripts).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/yassl/include/buffer.hpp b/extra/yassl/include/buffer.hpp index c2709a8c847..43c1d1daf38 100644 --- a/extra/yassl/include/buffer.hpp +++ b/extra/yassl/include/buffer.hpp @@ -56,11 +56,13 @@ const uint AUTO = 0xFEEDBEEF; // Checking Policy should implement a check function that tests whether the // index is within the size limit of the array struct Check { + Check() {} void check(uint i, uint limit); }; struct NoCheck { + NoCheck() {} void check(uint, uint); }; @@ -198,6 +200,7 @@ inline void checked_delete(T* p) // sets pointer to zero so safe for std conatiners struct del_ptr_zero { + del_ptr_zero() {} template void operator()(T*& p) const { diff --git a/extra/yassl/include/crypto_wrapper.hpp b/extra/yassl/include/crypto_wrapper.hpp index 83cf3d26398..5a7d7a7a133 100644 --- a/extra/yassl/include/crypto_wrapper.hpp +++ b/extra/yassl/include/crypto_wrapper.hpp @@ -49,6 +49,7 @@ namespace yaSSL { // Digest policy should implement a get_digest, update, and get sizes for pad // and digest struct Digest : public virtual_base { + Digest() {} virtual void get_digest(byte*) = 0; virtual void get_digest(byte*, const byte*, unsigned int) = 0; virtual void update(const byte*, unsigned int) = 0; @@ -60,6 +61,7 @@ struct Digest : public virtual_base { // For use with NULL Digests struct NO_MAC : public Digest { + NO_MAC() {} void get_digest(byte*); void get_digest(byte*, const byte*, unsigned int); void update(const byte*, unsigned int); @@ -184,6 +186,7 @@ private: // BulkCipher policy should implement encrypt, decrypt, get block size, // and set keys for encrypt and decrypt struct BulkCipher : public virtual_base { + BulkCipher() {} virtual void encrypt(byte*, const byte*, unsigned int) = 0; virtual void decrypt(byte*, const byte*, unsigned int) = 0; virtual void set_encryptKey(const byte*, const byte* = 0) = 0; @@ -197,6 +200,7 @@ struct BulkCipher : public virtual_base { // For use with NULL Ciphers struct NO_Cipher : public BulkCipher { + NO_Cipher() {} void encrypt(byte*, const byte*, unsigned int) {} void decrypt(byte*, const byte*, unsigned int) {} void set_encryptKey(const byte*, const byte*) {} @@ -318,12 +322,14 @@ struct Auth : public virtual_base { virtual bool verify(const byte*, unsigned int, const byte*, unsigned int) = 0; virtual uint get_signatureLength() const = 0; + Auth() {} virtual ~Auth() {} }; // For use with NULL Authentication schemes struct NO_Auth : public Auth { + NO_Auth() {} void sign(byte*, const byte*, unsigned int, const RandomPool&) {} bool verify(const byte*, unsigned int, const byte*, unsigned int) { return true; } diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 180d7fe7fe1..8739e2dac7c 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -71,6 +71,7 @@ struct RecordLayerHeader { // base for all messages struct Message : public virtual_base { + Message() {} virtual input_buffer& set(input_buffer&) =0; virtual output_buffer& get(output_buffer&) const =0; @@ -185,6 +186,7 @@ private: class HandShakeBase : public virtual_base { int length_; public: + HandShakeBase() {} int get_length() const; void set_length(int); @@ -202,6 +204,7 @@ public: struct HelloRequest : public HandShakeBase { + HelloRequest() {} input_buffer& set(input_buffer& in); output_buffer& get(output_buffer& out) const; @@ -335,6 +338,7 @@ private: struct ServerKeyBase : public virtual_base { + ServerKeyBase() {} virtual ~ServerKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} @@ -345,15 +349,21 @@ struct ServerKeyBase : public virtual_base { // Server random number for FORTEZZA KEA struct Fortezza_Server : public ServerKeyBase { + Fortezza_Server() {} opaque r_s_[FORTEZZA_MAX]; }; struct SignatureBase : public virtual_base { + SignatureBase() {} virtual ~SignatureBase() {} }; -struct anonymous_sa : public SignatureBase {}; +struct anonymous_sa : public SignatureBase +{ +public: + anonymous_sa() {} +}; struct Hashes { @@ -363,11 +373,13 @@ struct Hashes { struct rsa_sa : public SignatureBase { + rsa_sa() {} Hashes hashes_; }; struct dsa_sa : public SignatureBase { + dsa_sa() {} uint8 sha_[SHA_LEN]; }; @@ -395,6 +407,7 @@ private: // Server's RSA exchange struct RSA_Server : public ServerKeyBase { + RSA_Server() {} ServerRSAParams params_; opaque* signature_; // signed rsa_sa hashes }; @@ -469,6 +482,7 @@ struct PreMasterSecret { struct ClientKeyBase : public virtual_base { + ClientKeyBase() {} virtual ~ClientKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} @@ -499,6 +513,7 @@ private: // Fortezza Key Parameters from page 29 // hard code lengths cause only used here struct FortezzaKeys : public ClientKeyBase { + FortezzaKeys() {} opaque y_c_ [128]; // client's Yc, public value opaque r_c_ [128]; // client's Rc opaque y_signature_ [40]; // DSS signed public key diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 0edff289b61..31f347299f7 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -235,6 +235,7 @@ struct BIGNUM { TaoCrypt::Integer), we need to explicitly state the namespace here to let gcc 2.96 deduce the correct type. */ + BIGNUM() {} yaSSL::Integer int_; void assign(const byte* b, uint s) { int_.assign(b,s); } }; diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index 7344a70b367..9f9d95d4046 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -557,6 +557,7 @@ void RandomPool::Fill(opaque* dst, uint sz) const // Implementation of DSS Authentication struct DSS::DSSImpl { + DSSImpl() {} void SetPublic (const byte*, unsigned int); void SetPrivate(const byte*, unsigned int); TaoCrypt::DSA_PublicKey publicKey_; @@ -629,6 +630,7 @@ bool DSS::verify(const byte* sha_digest, unsigned int /* shaSz */, // Implementation of RSA key interface struct RSA::RSAImpl { + RSAImpl() {} void SetPublic (const byte*, unsigned int); void SetPrivate(const byte*, unsigned int); TaoCrypt::RSA_PublicKey publicKey_; diff --git a/extra/yassl/taocrypt/benchmark/benchmark.cpp b/extra/yassl/taocrypt/benchmark/benchmark.cpp index bb725a90187..dd9d1b1ff0d 100644 --- a/extra/yassl/taocrypt/benchmark/benchmark.cpp +++ b/extra/yassl/taocrypt/benchmark/benchmark.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) const int megs = 5; // how much to test -const byte key[] = +const byte global_key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10, @@ -81,19 +81,19 @@ const byte iv[] = }; -byte plain [1024*1024]; -byte cipher[1024*1024]; +byte global_plain [1024*1024]; +byte global_cipher[1024*1024]; void bench_des() { DES_EDE3_CBC_Encryption enc; - enc.SetKey(key, 16, iv); + enc.SetKey(global_key, 16, iv); double start = current_time(); for(int i = 0; i < megs; i++) - enc.Process(plain, cipher, sizeof(plain)); + enc.Process(global_plain, global_cipher, sizeof(global_plain)); double total = current_time() - start; @@ -107,12 +107,12 @@ void bench_des() void bench_aes(bool show) { AES_CBC_Encryption enc; - enc.SetKey(key, 16, iv); + enc.SetKey(global_key, 16, iv); double start = current_time(); for(int i = 0; i < megs; i++) - enc.Process(plain, cipher, sizeof(plain)); + enc.Process(global_plain, global_cipher, sizeof(global_plain)); double total = current_time() - start; @@ -127,12 +127,12 @@ void bench_aes(bool show) void bench_twofish() { Twofish_CBC_Encryption enc; - enc.SetKey(key, 16, iv); + enc.SetKey(global_key, 16, iv); double start = current_time(); for(int i = 0; i < megs; i++) - enc.Process(plain, cipher, sizeof(plain)); + enc.Process(global_plain, global_cipher, sizeof(global_plain)); double total = current_time() - start; @@ -147,12 +147,12 @@ void bench_twofish() void bench_blowfish() { Blowfish_CBC_Encryption enc; - enc.SetKey(key, 16, iv); + enc.SetKey(global_key, 16, iv); double start = current_time(); for(int i = 0; i < megs; i++) - enc.Process(plain, cipher, sizeof(plain)); + enc.Process(global_plain, global_cipher, sizeof(global_plain)); double total = current_time() - start; @@ -166,12 +166,12 @@ void bench_blowfish() void bench_arc4() { ARC4 enc; - enc.SetKey(key, 16); + enc.SetKey(global_key, 16); double start = current_time(); for(int i = 0; i < megs; i++) - enc.Process(cipher, plain, sizeof(plain)); + enc.Process(global_cipher, global_plain, sizeof(global_plain)); double total = current_time() - start; @@ -191,7 +191,7 @@ void bench_md5() for(int i = 0; i < megs; i++) - hash.Update(plain, sizeof(plain)); + hash.Update(global_plain, sizeof(global_plain)); hash.Final(digest); @@ -213,7 +213,7 @@ void bench_sha() for(int i = 0; i < megs; i++) - hash.Update(plain, sizeof(plain)); + hash.Update(global_plain, sizeof(global_plain)); hash.Final(digest); @@ -241,7 +241,7 @@ void bench_ripemd() for(int i = 0; i < megs; i++) - hash.Update(plain, sizeof(plain)); + hash.Update(global_plain, sizeof(global_plain)); hash.Final(digest); diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 535ce2599c4..d03123851f2 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -47,6 +47,7 @@ class TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base public: typedef Integer Element; + AbstractGroup() {} virtual ~AbstractGroup() {} virtual bool Equal(const Element &a, const Element &b) const =0; @@ -100,6 +101,7 @@ private: class MultiplicativeGroupT : public AbstractGroup { public: + MultiplicativeGroupT() {} const AbstractRing& GetRing() const {return *m_pRing;} @@ -151,6 +153,7 @@ class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain : public AbstractRing { public: + AbstractEuclideanDomain() {} typedef Integer Element; virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a, diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp index 48bb1e9119d..35bbe3f30bf 100644 --- a/extra/yassl/taocrypt/include/des.hpp +++ b/extra/yassl/taocrypt/include/des.hpp @@ -42,6 +42,7 @@ enum { DES_BLOCK_SIZE = 8, DES_KEY_SIZE = 32 }; class BasicDES { public: + BasicDES() {} void SetKey(const byte*, word32, CipherDir dir); void RawProcessBlock(word32&, word32&) const; protected: diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp index e3030088e0e..6885e0f35b5 100644 --- a/extra/yassl/taocrypt/include/hash.hpp +++ b/extra/yassl/taocrypt/include/hash.hpp @@ -38,6 +38,7 @@ namespace TaoCrypt { // HASH class HASH : public virtual_base { public: + HASH() {} virtual ~HASH() {} virtual void Update(const byte*, word32) = 0; diff --git a/extra/yassl/taocrypt/include/hmac.hpp b/extra/yassl/taocrypt/include/hmac.hpp index b710c3aa499..7ea4cabbd47 100644 --- a/extra/yassl/taocrypt/include/hmac.hpp +++ b/extra/yassl/taocrypt/include/hmac.hpp @@ -116,11 +116,11 @@ void HMAC::KeyInnerHash() // Update template -void HMAC::Update(const byte* msg, word32 length) +void HMAC::Update(const byte* msg_arg, word32 length) { if (!innerHashKeyed_) KeyInnerHash(); - mac_.Update(msg, length); + mac_.Update(msg_arg, length); } diff --git a/extra/yassl/taocrypt/include/modarith.hpp b/extra/yassl/taocrypt/include/modarith.hpp index 47b91560657..425ab22dba0 100644 --- a/extra/yassl/taocrypt/include/modarith.hpp +++ b/extra/yassl/taocrypt/include/modarith.hpp @@ -44,8 +44,8 @@ public: typedef int RandomizationParameter; typedef Integer Element; - ModularArithmetic(const Integer &modulus = Integer::One()) - : modulus(modulus), result((word)0, modulus.reg_.size()) {} + ModularArithmetic(const Integer &modulus_arg = Integer::One()) + : modulus(modulus_arg), result((word)0, modulus_arg.reg_.size()) {} ModularArithmetic(const ModularArithmetic &ma) : AbstractRing(), diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 65b7318661e..c46ecb3b4ca 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -48,8 +48,8 @@ public: { cipher_.Process(c, p, sz); } void SetKey(const byte* k, word32 sz) { cipher_.SetKey(k, sz, DIR); } - void SetKey(const byte* k, word32 sz, const byte* iv) - { cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv); } + void SetKey(const byte* k, word32 sz, const byte* iv_arg) + { cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv_arg); } private: T cipher_; diff --git a/extra/yassl/taocrypt/include/rsa.hpp b/extra/yassl/taocrypt/include/rsa.hpp index 1b531b9d0c0..b11142fc85d 100644 --- a/extra/yassl/taocrypt/include/rsa.hpp +++ b/extra/yassl/taocrypt/include/rsa.hpp @@ -138,6 +138,7 @@ private: // block type 2 padding class RSA_BlockType2 { public: + RSA_BlockType2() {} void Pad(const byte*, word32, byte*, word32, RandomNumberGenerator&) const; word32 UnPad(const byte*, word32, byte*) const; @@ -147,6 +148,7 @@ public: // block type 1 padding class RSA_BlockType1 { public: + RSA_BlockType1() {} void Pad(const byte*, word32, byte*, word32, RandomNumberGenerator&) const; word32 UnPad(const byte*, word32, byte*) const; @@ -181,25 +183,27 @@ public: // Public Encrypt template -void RSA_Encryptor::Encrypt(const byte* plain, word32 sz, byte* cipher, - RandomNumberGenerator& rng) +void RSA_Encryptor::Encrypt(const byte* plain_arg, word32 sz, + byte* cipher_arg, + RandomNumberGenerator& rng_arg) { PK_Lengths lengths(key_.GetModulus()); assert(sz <= lengths.FixedMaxPlaintextLength()); ByteBlock paddedBlock(lengths.PaddedBlockByteLength()); - padding_.Pad(plain, sz, paddedBlock.get_buffer(), - lengths.PaddedBlockBitLength(), rng); + padding_.Pad(plain_arg, sz, paddedBlock.get_buffer(), + lengths.PaddedBlockBitLength(), rng_arg); key_.ApplyFunction(Integer(paddedBlock.get_buffer(), paddedBlock.size())). - Encode(cipher, lengths.FixedCiphertextLength()); + Encode(cipher_arg, lengths.FixedCiphertextLength()); } // Private Decrypt template -word32 RSA_Decryptor::Decrypt(const byte* cipher, word32 sz, byte* plain, - RandomNumberGenerator& rng) +word32 RSA_Decryptor::Decrypt(const byte* cipher_arg, word32 sz, + byte* plain_arg, + RandomNumberGenerator& rng_arg) { PK_Lengths lengths(key_.GetModulus()); assert(sz == lengths.FixedCiphertextLength()); @@ -208,29 +212,29 @@ word32 RSA_Decryptor::Decrypt(const byte* cipher, word32 sz, byte* plain, return 0; ByteBlock paddedBlock(lengths.PaddedBlockByteLength()); - Integer x = key_.CalculateInverse(rng, Integer(cipher, + Integer x = key_.CalculateInverse(rng_arg, Integer(cipher_arg, lengths.FixedCiphertextLength()).Ref()); if (x.ByteCount() > paddedBlock.size()) x = Integer::Zero(); // don't return false, prevents timing attack x.Encode(paddedBlock.get_buffer(), paddedBlock.size()); return padding_.UnPad(paddedBlock.get_buffer(), - lengths.PaddedBlockBitLength(), plain); + lengths.PaddedBlockBitLength(), plain_arg); } // Private SSL type (block 1) Encrypt template void RSA_Decryptor::SSL_Sign(const byte* message, word32 sz, byte* sig, - RandomNumberGenerator& rng) + RandomNumberGenerator& rng_arg) { RSA_PublicKey inverse; inverse.Initialize(key_.GetModulus(), key_.GetPrivateExponent()); RSA_Encryptor enc(inverse); // SSL Type - enc.Encrypt(message, sz, sig, rng); + enc.Encrypt(message, sz, sig, rng_arg); } -word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain); +word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain_arg); // Public SSL type (block 1) Decrypt @@ -238,10 +242,10 @@ template bool RSA_Encryptor::SSL_Verify(const byte* message, word32 sz, const byte* sig) { - ByteBlock plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength()); - SSL_Decrypt(key_, sig, plain.get_buffer()); + ByteBlock local_plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength()); + SSL_Decrypt(key_, sig, local_plain.get_buffer()); - if ( (memcmp(plain.get_buffer(), message, sz)) == 0) + if ( (memcmp(local_plain.get_buffer(), message, sz)) == 0) return true; return false; } diff --git a/extra/yassl/taocrypt/mySTL/list.hpp b/extra/yassl/taocrypt/mySTL/list.hpp index 831c5bbbbbd..1313e0427bb 100644 --- a/extra/yassl/taocrypt/mySTL/list.hpp +++ b/extra/yassl/taocrypt/mySTL/list.hpp @@ -238,7 +238,7 @@ void list::push_front(T t) template void list::pop_front() { - node* front = head_; + node* local_front = head_; if (head_ == 0) return; @@ -248,8 +248,8 @@ void list::pop_front() head_ = head_->next_; head_->prev_ = 0; } - destroy(front); - FreeMemory(front); + destroy(local_front); + FreeMemory(local_front); --sz_; } @@ -310,13 +310,13 @@ T list::back() const template typename list::node* list::look_up(T t) { - node* list = head_; + node* local_list = head_; - if (list == 0) return 0; + if (local_list == 0) return 0; - for (; list; list = list->next_) - if (list->value_ == t) - return list; + for (; local_list; local_list = local_list->next_) + if (local_list->value_ == t) + return local_list; return 0; } diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index 574a88a736c..98536c6c49d 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -111,13 +111,14 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) rounds_ = keylen/4 + 6; word32 temp, *rk = key_; - unsigned int i=0; GetUserKey(BigEndianOrder, rk, keylen/4, userKey, keylen); switch(keylen) { case 16: + { + unsigned int i=0; while (true) { temp = rk[3]; @@ -135,8 +136,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) rk += 4; } break; - + } case 24: + { + unsigned int i=0; while (true) // for (;;) here triggers a bug in VC60 SP4 w/ Pro Pack { temp = rk[ 5]; @@ -157,7 +160,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) } break; + } case 32: + { + unsigned int i=0; while (true) { temp = rk[ 7]; @@ -186,6 +192,7 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) } break; } + } if (dir_ == DECRYPTION) { diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 375cd6cd524..a81d5217b6b 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -189,10 +189,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x, struct WindowSlider { - WindowSlider(const Integer &exp, bool fastNegate, + WindowSlider(const Integer &exp_arg, bool fastNegate_arg, unsigned int windowSizeIn=0) - : exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn), - windowBegin(0), fastNegate(fastNegate), firstTime(true), + : exp(exp_arg), windowModulus(Integer::One()), windowSize(windowSizeIn), + windowBegin(0), fastNegate(fastNegate_arg), firstTime(true), finished(false) { if (windowSize == 0) diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index 3dc3638d85f..4d743bcc8a0 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -741,8 +741,8 @@ void CertDecoder::GetName(NameType nt) else { // skip source_.advance(oidSz + 1); - word32 length = GetLength(source_); - source_.advance(length); + word32 length2 = GetLength(source_); + source_.advance(length2); } } ptr[idx++] = 0; diff --git a/extra/yassl/taocrypt/test/test.cpp b/extra/yassl/taocrypt/test/test.cpp index 28ef73dfac8..75d20fe8f90 100644 --- a/extra/yassl/taocrypt/test/test.cpp +++ b/extra/yassl/taocrypt/test/test.cpp @@ -137,20 +137,20 @@ const byte msgTmp[] = { // "now is the time for all " w/o trailing 0 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20 }; -byte* msg = 0; // for block cipher input -byte* plain = 0; // for cipher decrypt comparison -byte* cipher = 0; // block output +byte* global_msg = 0; // for block cipher input +byte* global_plain = 0; // for cipher decrypt comparison +byte* global_cipher = 0; // block output void taocrypt_test(void* args) { ((func_args*)args)->return_code = -1; // error state - msg = NEW_TC byte[24]; - plain = NEW_TC byte[24]; - cipher = NEW_TC byte[24]; + global_msg = NEW_TC byte[24]; + global_plain = NEW_TC byte[24]; + global_cipher = NEW_TC byte[24]; - memcpy(msg, msgTmp, 24); + memcpy(global_msg, msgTmp, 24); int ret = 0; if ( (ret = sha_test()) ) @@ -228,9 +228,9 @@ void taocrypt_test(void* args) else printf( "PBKDF2 test passed!\n"); - tcArrayDelete(cipher); - tcArrayDelete(plain); - tcArrayDelete(msg); + tcArrayDelete(global_cipher); + tcArrayDelete(global_plain); + tcArrayDelete(global_msg); ((func_args*)args)->return_code = ret; } @@ -595,11 +595,11 @@ int des_test() const byte iv[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef }; enc.SetKey(key, sizeof(key)); - enc.Process(cipher, msg, sz); + enc.Process(global_cipher, global_msg, sz); dec.SetKey(key, sizeof(key)); - dec.Process(plain, cipher, sz); + dec.Process(global_plain, global_cipher, sz); - if (memcmp(plain, msg, sz)) + if (memcmp(global_plain, global_msg, sz)) return -50; const byte verify1[] = @@ -609,7 +609,7 @@ int des_test() 0x89,0x3d,0x51,0xec,0x4b,0x56,0x3b,0x53 }; - if (memcmp(cipher, verify1, sz)) + if (memcmp(global_cipher, verify1, sz)) return -51; // CBC mode @@ -617,11 +617,11 @@ int des_test() DES_CBC_Decryption dec2; enc2.SetKey(key, sizeof(key), iv); - enc2.Process(cipher, msg, sz); + enc2.Process(global_cipher, global_msg, sz); dec2.SetKey(key, sizeof(key), iv); - dec2.Process(plain, cipher, sz); + dec2.Process(global_plain, global_cipher, sz); - if (memcmp(plain, msg, sz)) + if (memcmp(global_plain, global_msg, sz)) return -52; const byte verify2[] = @@ -631,7 +631,7 @@ int des_test() 0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b }; - if (memcmp(cipher, verify2, sz)) + if (memcmp(global_cipher, verify2, sz)) return -53; // EDE3 CBC mode @@ -653,11 +653,11 @@ int des_test() }; enc3.SetKey(key3, sizeof(key3), iv3); - enc3.Process(cipher, msg, sz); + enc3.Process(global_cipher, global_msg, sz); dec3.SetKey(key3, sizeof(key3), iv3); - dec3.Process(plain, cipher, sz); + dec3.Process(global_plain, global_cipher, sz); - if (memcmp(plain, msg, sz)) + if (memcmp(global_plain, global_msg, sz)) return -54; const byte verify3[] = @@ -667,7 +667,7 @@ int des_test() 0x18,0xbc,0xbb,0x6d,0xd2,0xb1,0x16,0xda }; - if (memcmp(cipher, verify3, sz)) + if (memcmp(global_cipher, verify3, sz)) return -55; return 0; @@ -686,10 +686,10 @@ int aes_test() enc.SetKey(key, bs, iv); dec.SetKey(key, bs, iv); - enc.Process(cipher, msg, bs); - dec.Process(plain, cipher, bs); + enc.Process(global_cipher, global_msg, bs); + dec.Process(global_plain, global_cipher, bs); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -60; const byte verify[] = @@ -698,7 +698,7 @@ int aes_test() 0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb }; - if (memcmp(cipher, verify, bs)) + if (memcmp(global_cipher, verify, bs)) return -61; AES_ECB_Encryption enc2; @@ -707,10 +707,10 @@ int aes_test() enc2.SetKey(key, bs, iv); dec2.SetKey(key, bs, iv); - enc2.Process(cipher, msg, bs); - dec2.Process(plain, cipher, bs); + enc2.Process(global_cipher, global_msg, bs); + dec2.Process(global_plain, global_cipher, bs); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -62; const byte verify2[] = @@ -719,7 +719,7 @@ int aes_test() 0xc8,0x8c,0x33,0x3b,0xb5,0x8f,0x85,0xd1 }; - if (memcmp(cipher, verify2, bs)) + if (memcmp(global_cipher, verify2, bs)) return -63; return 0; @@ -738,10 +738,10 @@ int twofish_test() enc.SetKey(key, bs, iv); dec.SetKey(key, bs, iv); - enc.Process(cipher, msg, bs); - dec.Process(plain, cipher, bs); + enc.Process(global_cipher, global_msg, bs); + dec.Process(global_plain, global_cipher, bs); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -60; const byte verify[] = @@ -750,7 +750,7 @@ int twofish_test() 0x21,0x03,0x58,0x79,0x5F,0x02,0x27,0x2C }; - if (memcmp(cipher, verify, bs)) + if (memcmp(global_cipher, verify, bs)) return -61; Twofish_ECB_Encryption enc2; @@ -759,10 +759,10 @@ int twofish_test() enc2.SetKey(key, bs, iv); dec2.SetKey(key, bs, iv); - enc2.Process(cipher, msg, bs); - dec2.Process(plain, cipher, bs); + enc2.Process(global_cipher, global_msg, bs); + dec2.Process(global_plain, global_cipher, bs); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -62; const byte verify2[] = @@ -771,7 +771,7 @@ int twofish_test() 0xC4,0xCD,0x6B,0x91,0x14,0xC5,0x3A,0x09 }; - if (memcmp(cipher, verify2, bs)) + if (memcmp(global_cipher, verify2, bs)) return -63; return 0; @@ -790,10 +790,10 @@ int blowfish_test() enc.SetKey(key, 16, iv); dec.SetKey(key, 16, iv); - enc.Process(cipher, msg, bs * 2); - dec.Process(plain, cipher, bs * 2); + enc.Process(global_cipher, global_msg, bs * 2); + dec.Process(global_plain, global_cipher, bs * 2); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -60; const byte verify[] = @@ -802,7 +802,7 @@ int blowfish_test() 0xBC,0xD9,0x08,0xC4,0x94,0x6C,0x89,0xA3 }; - if (memcmp(cipher, verify, bs)) + if (memcmp(global_cipher, verify, bs)) return -61; Blowfish_ECB_Encryption enc2; @@ -811,10 +811,10 @@ int blowfish_test() enc2.SetKey(key, 16, iv); dec2.SetKey(key, 16, iv); - enc2.Process(cipher, msg, bs * 2); - dec2.Process(plain, cipher, bs * 2); + enc2.Process(global_cipher, global_msg, bs * 2); + dec2.Process(global_plain, global_cipher, bs * 2); - if (memcmp(plain, msg, bs)) + if (memcmp(global_plain, global_msg, bs)) return -62; const byte verify2[] = @@ -823,7 +823,7 @@ int blowfish_test() 0x8F,0xCE,0x39,0x32,0xDE,0xD7,0xBC,0x5B }; - if (memcmp(cipher, verify2, bs)) + if (memcmp(global_cipher, verify2, bs)) return -63; return 0; diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp index 49113a552cd..06e75153341 100644 --- a/extra/yassl/testsuite/testsuite.cpp +++ b/extra/yassl/testsuite/testsuite.cpp @@ -141,16 +141,17 @@ int test_openSSL_des() /* test des encrypt/decrypt */ char data[] = "this is my data "; int dataSz = strlen(data); - DES_key_schedule key[3]; + DES_key_schedule local_key[3]; byte iv[8]; EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1, - (byte*)key, iv); + (byte*)local_key, iv); byte cipher[16]; - DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[1], - &key[2], &iv, true); + DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, + &local_key[0], &local_key[1], + &local_key[2], &iv, true); byte plain[16]; - DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[1], &key[2], - &iv, false); + DES_ede3_cbc_encrypt(cipher, plain, 16, &local_key[0], &local_key[1], + &local_key[2], &iv, false); return 0; } diff --git a/include/m_ctype.h b/include/m_ctype.h index ffecadd9836..948507e8c59 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -91,7 +91,7 @@ typedef struct { uint beg; uint end; - uint mblen; + uint mb_len; } my_match_t; enum my_lex_states diff --git a/include/my_pthread.h b/include/my_pthread.h index 300291610d3..b6663dbe671 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -332,14 +332,14 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ we want to make sure that no such flags are set. */ #if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \ - DBUG_ASSERT((A) != 0); \ - sigemptyset(&set); \ - s.sa_handler = (B); \ - s.sa_mask = set; \ - s.sa_flags = 0; \ - rc= sigaction((A), &s, (struct sigaction *) NULL);\ - DBUG_ASSERT(rc == 0); \ +#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \ + DBUG_ASSERT((A) != 0); \ + sigemptyset(&l_set); \ + l_s.sa_handler = (B); \ + l_s.sa_mask = l_set; \ + l_s.sa_flags = 0; \ + l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\ + DBUG_ASSERT(l_rc == 0); \ } while (0) #elif defined(HAVE_SIGSET) && !defined(my_sigset) #define my_sigset(A,B) sigset((A),(B)) diff --git a/include/my_sys.h b/include/my_sys.h index 65bfb0b7e6a..99fc3d6c076 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -261,9 +261,10 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; extern char wild_many,wild_one,wild_prefix; extern const char *charsets_dir; -extern char *defaults_extra_file; -extern const char *defaults_group_suffix; -extern const char *defaults_file; +/* from default.c */ +extern char *my_defaults_extra_file; +extern const char *my_defaults_group_suffix; +extern const char *my_defaults_file; extern my_bool timed_mutexes; diff --git a/include/my_time.h b/include/my_time.h index 5361c47d57f..c5e71b7e70b 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -74,16 +74,16 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, uint flags, int *was_cut); longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, uint flags, int *was_cut); -ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *time); -ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *time); -ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *time); -ulonglong TIME_to_ulonglong(const MYSQL_TIME *time); +ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *); +ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *); +ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *); +ulonglong TIME_to_ulonglong(const MYSQL_TIME *); my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time, int *warning); -int check_time_range(struct st_mysql_time *time, int *warning); +int check_time_range(struct st_mysql_time *, int *warning); long calc_daynr(uint year,uint month,uint day); uint calc_days_in_year(uint year); diff --git a/include/mysql.h b/include/mysql.h index f2a82c99fc3..f40666a4d69 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -88,6 +88,7 @@ extern char *mysql_unix_port; #define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL) #define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) #define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR) +#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING) typedef struct st_mysql_field { @@ -784,7 +785,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned long length); int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt); int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt); -int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, +int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset); int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 8c4eb2279e1..85d185e244d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1730,7 +1730,7 @@ static int stmt_read_row_no_result_set(MYSQL_STMT *stmt, unsigned char **row); STMT_ATTR_UPDATE_MAX_LENGTH attribute is set. */ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); -static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); +static my_bool setup_one_fetch_function(MYSQL_BIND *, MYSQL_FIELD *field); /* Auxilary function used to reset statement handle. */ @@ -2166,7 +2166,7 @@ static void update_stmt_fields(MYSQL_STMT *stmt) MYSQL_FIELD *field= stmt->mysql->fields; MYSQL_FIELD *field_end= field + stmt->field_count; MYSQL_FIELD *stmt_field= stmt->fields; - MYSQL_BIND *bind= stmt->bind_result_done ? stmt->bind : 0; + MYSQL_BIND *my_bind= stmt->bind_result_done ? stmt->bind : 0; DBUG_ASSERT(stmt->field_count == stmt->mysql->field_count); @@ -2177,10 +2177,10 @@ static void update_stmt_fields(MYSQL_STMT *stmt) stmt_field->type = field->type; stmt_field->flags = field->flags; stmt_field->decimals = field->decimals; - if (bind) + if (my_bind) { /* Ignore return value: it should be 0 if bind_result succeeded. */ - (void) setup_one_fetch_function(bind++, stmt_field); + (void) setup_one_fetch_function(my_bind++, stmt_field); } } } @@ -3002,7 +3002,7 @@ static my_bool int_is_null_false= 0; mysql_stmt_bind_param() stmt statement handle The statement must be prepared with mysql_stmt_prepare(). - bind Array of mysql_stmt_param_count() bind parameters. + my_bind Array of mysql_stmt_param_count() bind parameters. This function doesn't check that size of this argument is >= mysql_stmt_field_count(): it's user's responsibility. @@ -3077,65 +3077,66 @@ static my_bool int_is_null_false= 0; to point to the buffer of given type. Finally, additional actions may be taken for some types or use cases: - Binding integer types. - For integer types you might also need to set MYSQL_BIND::is_unsigned - member. Set it to TRUE when binding unsigned char, unsigned short, - unsigned int, unsigned long, unsigned long long. + Binding integer types. + For integer types you might also need to set MYSQL_BIND::is_unsigned + member. Set it to TRUE when binding unsigned char, unsigned short, + unsigned int, unsigned long, unsigned long long. - Binding floating point types. - For floating point types you just need to set - MYSQL_BIND::buffer_type and MYSQL_BIND::buffer. The rest of the - members should be zero-initialized. + Binding floating point types. + For floating point types you just need to set + MYSQL_BIND::buffer_type and MYSQL_BIND::buffer. The rest of the + members should be zero-initialized. - Binding NULLs. - You might have a column always NULL, never NULL, or sometimes NULL. - For an always NULL column set MYSQL_BIND::buffer_type to - MYSQL_TYPE_NULL. The rest of the members just need to be - zero-initialized. For never NULL columns set MYSQL_BIND::is_null to - 0, or this has already been done if you zero-initialized the entire - structure. If you set MYSQL_TYPE::is_null to point to an - application buffer of type 'my_bool', then this buffer will be - checked on each execution: this way you can set the buffer to TRUE, - or any non-0 value for NULLs, and to FALSE or 0 for not NULL data. + Binding NULLs. + You might have a column always NULL, never NULL, or sometimes + NULL. For an always NULL column set MYSQL_BIND::buffer_type to + MYSQL_TYPE_NULL. The rest of the members just need to be + zero-initialized. For never NULL columns set + MYSQL_BIND::is_null to 0, or this has already been done if you + zero-initialized the entire structure. If you set + MYSQL_TYPE::is_null to point to an application buffer of type + 'my_bool', then this buffer will be checked on each execution: + this way you can set the buffer to TRUE, or any non-0 value for + NULLs, and to FALSE or 0 for not NULL data. - Binding text strings and sequences of bytes. - For strings, in addition to MYSQL_BIND::buffer_type and - MYSQL_BIND::buffer you need to set MYSQL_BIND::length or - MYSQL_BIND::buffer_length. - If 'length' is set, 'buffer_length' is ignored. 'buffer_length' - member should be used when size of string doesn't change between - executions. If you want to vary buffer length for each value, set - 'length' to point to an application buffer of type 'unsigned long' - and set this long to length of the string before each - mysql_stmt_execute(). + Binding text strings and sequences of bytes. + For strings, in addition to MYSQL_BIND::buffer_type and + MYSQL_BIND::buffer you need to set MYSQL_BIND::length or + MYSQL_BIND::buffer_length. If 'length' is set, 'buffer_length' + is ignored. 'buffer_length' member should be used when size of + string doesn't change between executions. If you want to vary + buffer length for each value, set 'length' to point to an + application buffer of type 'unsigned long' and set this long to + length of the string before each mysql_stmt_execute(). - Binding dates and times. - For binding dates and times prepared statements API provides clients - with MYSQL_TIME structure. A pointer to instance of this structure - should be assigned to MYSQL_BIND::buffer whenever MYSQL_TYPE_TIME, - MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME typecodes are used. When - typecode is MYSQL_TYPE_TIME, only members 'hour', 'minute', 'second' - and 'neg' (is time offset negative) are used. These members only - will be sent to the server. - MYSQL_TYPE_DATE implies use of 'year', 'month', 'day', 'neg'. - MYSQL_TYPE_DATETIME utilizes both parts of MYSQL_TIME structure. - You don't have to set MYSQL_TIME::time_type member: it's not used - when sending data to the server, typecode information is enough. - 'second_part' member can hold microsecond precision of time value, - but now it's only supported on protocol level: you can't store - microsecond in a column, or use in temporal calculations. However, - if you send a time value with microsecond part for 'SELECT ?', - statement, you'll get it back unchanged from the server. + Binding dates and times. + For binding dates and times prepared statements API provides + clients with MYSQL_TIME structure. A pointer to instance of this + structure should be assigned to MYSQL_BIND::buffer whenever + MYSQL_TYPE_TIME, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME typecodes + are used. When typecode is MYSQL_TYPE_TIME, only members + 'hour', 'minute', 'second' and 'neg' (is time offset negative) + are used. These members only will be sent to the server. + MYSQL_TYPE_DATE implies use of 'year', 'month', 'day', 'neg'. + MYSQL_TYPE_DATETIME utilizes both parts of MYSQL_TIME structure. + You don't have to set MYSQL_TIME::time_type member: it's not + used when sending data to the server, typecode information is + enough. 'second_part' member can hold microsecond precision of + time value, but now it's only supported on protocol level: you + can't store microsecond in a column, or use in temporal + calculations. However, if you send a time value with microsecond + part for 'SELECT ?', statement, you'll get it back unchanged + from the server. - Data conversion. - If conversion from host language type to data representation, - corresponding to SQL type, is required it's done on the server. - Data truncation is possible when conversion is lossy. For example, - if you supply MYSQL_TYPE_DATETIME value out of valid SQL type - TIMESTAMP range, the same conversion will be applied as if this - value would have been sent as string in the old protocol. - TODO: document how the server will behave in case of truncation/data - loss. + Data conversion. + If conversion from host language type to data representation, + corresponding to SQL type, is required it's done on the server. + Data truncation is possible when conversion is lossy. For + example, if you supply MYSQL_TYPE_DATETIME value out of valid + SQL type TIMESTAMP range, the same conversion will be applied as + if this value would have been sent as string in the old + protocol. TODO: document how the server will behave in case of + truncation/data loss. After variables were bound, you can repeatedly set/change their values and mysql_stmt_execute() the statement. @@ -3163,7 +3164,7 @@ static my_bool int_is_null_false= 0; 1 error, can be retrieved with mysql_stmt_error. */ -my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind) +my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *my_bind) { uint count=0; MYSQL_BIND *param, *end; @@ -3180,7 +3181,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind) } /* Allocated on prepare */ - memcpy((char*) stmt->params, (char*) bind, + memcpy((char*) stmt->params, (char*) my_bind, sizeof(MYSQL_BIND) * stmt->param_count); for (param= stmt->params, end= param+stmt->param_count; @@ -3343,8 +3344,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, } param= stmt->params+param_number; - if (param->buffer_type < MYSQL_TYPE_TINY_BLOB || - param->buffer_type > MYSQL_TYPE_STRING) + if (!IS_LONGDATA(param->buffer_type)) { /* Long data handling should be used only for string/binary types */ strmov(stmt->sqlstate, unknown_sqlstate); @@ -3508,7 +3508,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, This function should support all target buffer types: the rest of conversion functions can delegate conversion to it. */ - switch(param->buffer_type) { + switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ break; case MYSQL_TYPE_TINY: @@ -3850,32 +3850,32 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, static void fetch_datetime_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, - MYSQL_TIME *time) + MYSQL_TIME *my_time) { switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ break; case MYSQL_TYPE_DATE: - *(MYSQL_TIME *)(param->buffer)= *time; - *param->error= time->time_type != MYSQL_TIMESTAMP_DATE; + *(MYSQL_TIME *)(param->buffer)= *my_time; + *param->error= my_time->time_type != MYSQL_TIMESTAMP_DATE; break; case MYSQL_TYPE_TIME: - *(MYSQL_TIME *)(param->buffer)= *time; - *param->error= time->time_type != MYSQL_TIMESTAMP_TIME; + *(MYSQL_TIME *)(param->buffer)= *my_time; + *param->error= my_time->time_type != MYSQL_TIMESTAMP_TIME; break; case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: - *(MYSQL_TIME *)(param->buffer)= *time; + *(MYSQL_TIME *)(param->buffer)= *my_time; /* No error: time and date are compatible with datetime */ break; case MYSQL_TYPE_YEAR: - shortstore(param->buffer, time->year); + shortstore(param->buffer, my_time->year); *param->error= 1; break; case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: { - ulonglong value= TIME_to_ulonglong(time); + ulonglong value= TIME_to_ulonglong(my_time); fetch_float_with_conversion(param, field, ulonglong2double(value), DBL_DIG); break; @@ -3886,7 +3886,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param, case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: { - longlong value= (longlong) TIME_to_ulonglong(time); + longlong value= (longlong) TIME_to_ulonglong(my_time); fetch_long_with_conversion(param, field, value, TRUE); break; } @@ -3897,7 +3897,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param, fetch_string_with_conversion: */ char buff[MAX_DATE_STRING_REP_LENGTH]; - uint length= my_TIME_to_str(time, buff); + uint length= my_TIME_to_str(my_time, buff); /* Resort to string conversion */ fetch_string_with_conversion(param, (char *)buff, length); break; @@ -4263,6 +4263,8 @@ static my_bool is_binary_compatible(enum enum_field_types type1, static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) { + DBUG_ENTER("setup_one_fetch_function"); + /* Setup data copy functions for the different supported types */ switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* for dummy binds */ @@ -4327,7 +4329,9 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) param->fetch_result= fetch_result_str; break; default: - return TRUE; + DBUG_PRINT("error", ("Unknown param->buffer_type: %u", + (uint) param->buffer_type)); + DBUG_RETURN(TRUE); } if (! is_binary_compatible(param->buffer_type, field->type)) param->fetch_result= fetch_result_with_conversion; @@ -4396,9 +4400,10 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) param->skip_result= skip_result_string; break; default: - return TRUE; + DBUG_PRINT("error", ("Unknown field->type: %u", (uint) field->type)); + DBUG_RETURN(TRUE); } - return FALSE; + DBUG_RETURN(FALSE); } @@ -4406,7 +4411,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) Setup the bind buffers for resultset processing */ -my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) +my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *my_bind) { MYSQL_BIND *param, *end; MYSQL_FIELD *field; @@ -4430,8 +4435,9 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) is called from mysql_stmt_store_result. */ - if (stmt->bind != bind) - memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count); + if (stmt->bind != my_bind) + memcpy((char*) stmt->bind, (char*) my_bind, + sizeof(MYSQL_BIND) * bind_count); for (param= stmt->bind, end= param + bind_count, field= stmt->fields ; param < end ; @@ -4478,7 +4484,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) { - MYSQL_BIND *bind, *end; + MYSQL_BIND *my_bind, *end; MYSQL_FIELD *field; uchar *null_ptr, bit; int truncation_count= 0; @@ -4500,11 +4506,12 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) bit= 4; /* first 2 bits are reserved */ /* Copy complete row to application buffers */ - for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ; - bind < end ; - bind++, field++) + for (my_bind= stmt->bind, end= my_bind + stmt->field_count, + field= stmt->fields ; + my_bind < end ; + my_bind++, field++) { - *bind->error= 0; + *my_bind->error= 0; if (*null_ptr & bit) { /* @@ -4514,15 +4521,15 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) mysql_stmt_fetch_column, and in this case nullness of column will be lost. See mysql_stmt_fetch_column for details. */ - bind->row_ptr= NULL; - *bind->is_null= 1; + my_bind->row_ptr= NULL; + *my_bind->is_null= 1; } else { - *bind->is_null= 0; - bind->row_ptr= row; - (*bind->fetch_result)(bind, field, &row); - truncation_count+= *bind->error; + *my_bind->is_null= 0; + my_bind->row_ptr= row; + (*my_bind->fetch_result)(my_bind, field, &row); + truncation_count+= *my_bind->error; } if (!((bit<<=1) & 255)) { @@ -4579,7 +4586,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt) SYNOPSIS mysql_stmt_fetch_column() stmt Prepared statement handler - bind Where data should be placed. Should be filled in as + my_bind Where data should be placed. Should be filled in as when calling mysql_stmt_bind_result() column Column to fetch (first column is 0) ulong offset Offset in result data (to fetch blob in pieces) @@ -4589,7 +4596,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt) 1 error */ -int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, +int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *my_bind, uint column, ulong offset) { MYSQL_BIND *param= stmt->bind+column; @@ -4606,26 +4613,26 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, DBUG_RETURN(1); } - if (!bind->error) - bind->error= &bind->error_value; - *bind->error= 0; + if (!my_bind->error) + my_bind->error= &my_bind->error_value; + *my_bind->error= 0; if (param->row_ptr) { MYSQL_FIELD *field= stmt->fields+column; uchar *row= param->row_ptr; - bind->offset= offset; - if (bind->is_null) - *bind->is_null= 0; - if (bind->length) /* Set the length if non char/binary types */ - *bind->length= *param->length; + my_bind->offset= offset; + if (my_bind->is_null) + *my_bind->is_null= 0; + if (my_bind->length) /* Set the length if non char/binary types */ + *my_bind->length= *param->length; else - bind->length= ¶m->length_value; /* Needed for fetch_result() */ - fetch_result_with_conversion(bind, field, &row); + my_bind->length= ¶m->length_value; /* Needed for fetch_result() */ + fetch_result_with_conversion(my_bind, field, &row); } else { - if (bind->is_null) - *bind->is_null= 1; + if (my_bind->is_null) + *my_bind->is_null= 1; } DBUG_RETURN(0); } @@ -4697,7 +4704,7 @@ err: static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data) { - MYSQL_BIND *bind, *end; + MYSQL_BIND *my_bind, *end; MYSQL_FIELD *field; uchar *null_ptr, bit; uchar *row= (uchar*) data->data; @@ -4710,12 +4717,12 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data) bit= 4; /* first 2 bits are reserved */ /* Go through all fields and calculate metadata */ - for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ; - bind < end ; - bind++, field++) + for (my_bind= stmt->bind, end= my_bind + stmt->field_count, field= stmt->fields ; + my_bind < end ; + my_bind++, field++) { if (!(*null_ptr & bit)) - (*bind->skip_result)(bind, field, &row); + (*my_bind->skip_result)(my_bind, field, &row); DBUG_ASSERT(row <= row_end); if (!((bit<<=1) & 255)) { @@ -4779,16 +4786,17 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) We must initalize the bind structure to be able to calculate max_length */ - MYSQL_BIND *bind, *end; + MYSQL_BIND *my_bind, *end; MYSQL_FIELD *field; bzero((char*) stmt->bind, sizeof(*stmt->bind)* stmt->field_count); - for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields; - bind < end ; - bind++, field++) + for (my_bind= stmt->bind, end= my_bind + stmt->field_count, + field= stmt->fields; + my_bind < end ; + my_bind++, field++) { - bind->buffer_type= MYSQL_TYPE_NULL; - bind->buffer_length=1; + my_bind->buffer_type= MYSQL_TYPE_NULL; + my_bind->buffer_length=1; } if (mysql_stmt_bind_result(stmt, stmt->bind)) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index a88c0b135db..980a3611610 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -278,7 +278,6 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("emb_stmt_execute"); char header[5]; - MYSQL_DATA *res; THD *thd; int4store(header, stmt->stmt_id); @@ -1040,7 +1039,7 @@ void Protocol_simple::prepare_for_resend() data->embedded_info->prev_ptr= &cur->next; next_field=cur->data; next_mysql_field= data->embedded_info->fields_list; -err: + DBUG_VOID_RETURN; } diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 19f0ef77136..1519e24896c 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -491,7 +491,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ FT_SEG_ITERATOR ftsi; FTB_EXPR *ftbe; float weight=ftbw->weight; - int yn=ftbw->flags, ythresh, mode=(ftsi_orig != 0); + int yn_flag= ftbw->flags, ythresh, mode=(ftsi_orig != 0); my_off_t curdoc=ftbw->docid[mode]; for (ftbe=ftbw->up; ftbe; ftbe=ftbe->up) @@ -505,13 +505,13 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ } if (ftbe->nos) break; - if (yn & FTB_FLAG_YES) + if (yn_flag & FTB_FLAG_YES) { weight /= ftbe->ythresh; ftbe->cur_weight += weight; if ((int) ++ftbe->yesses == ythresh) { - yn=ftbe->flags; + yn_flag=ftbe->flags; weight=ftbe->cur_weight*ftbe->weight; if (mode && ftbe->phrase) { @@ -532,14 +532,14 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ break; } else - if (yn & FTB_FLAG_NO) + if (yn_flag & FTB_FLAG_NO) { /* NOTE: special sort function of queue assures that all - (yn & FTB_FLAG_NO) != 0 + (yn_flag & FTB_FLAG_NO) != 0 events for every particular subexpression will "auto-magically" happen BEFORE all the - (yn & FTB_FLAG_YES) != 0 events. So no + (yn_flag & FTB_FLAG_YES) != 0 events. So no already matched expression can become not-matched again. */ ++ftbe->nos; @@ -552,8 +552,8 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ ftbe->cur_weight += weight; if ((int) ftbe->yesses < ythresh) break; - if (!(yn & FTB_FLAG_WONLY)) - yn= ((int) ftbe->yesses++ == ythresh) ? ftbe->flags : FTB_FLAG_WONLY ; + if (!(yn_flag & FTB_FLAG_WONLY)) + yn_flag= ((int) ftbe->yesses++ == ythresh) ? ftbe->flags : FTB_FLAG_WONLY ; weight*= ftbe->weight; } } diff --git a/myisam/mi_open.c b/myisam/mi_open.c index bf20eb3f270..bbeadf91581 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -359,11 +359,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } else { - uint j; + uint k; share->keyinfo[i].seg=pos; - for (j=0; j < FT_SEGS; j++) + for (k=0; k < FT_SEGS; k++) { - *pos=ft_keysegs[j]; + *pos= ft_keysegs[k]; pos[0].language= pos[-1].language; if (!(pos[0].charset= pos[-1].charset)) { diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 05f8459a4b4..0ddab5bf414 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -471,9 +471,9 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, else { /* We have to compare k and vseg as if they were space extended */ - uchar *end= k+ (cmplen - len); - for ( ; k < end && *k == ' '; k++) ; - if (k == end) + uchar *k_end= k+ (cmplen - len); + for ( ; k < k_end && *k == ' '; k++) ; + if (k == k_end) goto cmp_rest; /* should never happen */ if (*k < (uchar) ' ') { @@ -485,15 +485,15 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, } else if (len > cmplen) { - uchar *end; + uchar *vseg_end; if ((nextflag & SEARCH_PREFIX) && key_len_left == 0) goto fix_flag; /* We have to compare k and vseg as if they were space extended */ - for (end=vseg + (len-cmplen) ; - vseg < end && *vseg == (uchar) ' '; + for (vseg_end= vseg + (len-cmplen) ; + vseg < vseg_end && *vseg == (uchar) ' '; vseg++, matched++) ; - DBUG_ASSERT(vseg < end); + DBUG_ASSERT(vseg < vseg_end); if (*vseg > (uchar) ' ') { diff --git a/myisam/mi_unique.c b/myisam/mi_unique.c index b698968127b..62aa4166793 100644 --- a/myisam/mi_unique.c +++ b/myisam/mi_unique.c @@ -57,7 +57,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey, MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH)) + bcmp((char*) info->lastkey, (char*) key_buff, MI_UNIQUE_HASH_LENGTH)) { info->page_changed=1; /* Can't optimize read next */ info->lastpos=lastpos; diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 912ed22d278..514a4888527 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2690,8 +2690,9 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) } case FIELD_VARCHAR: { - uint pack_length= HA_VARCHAR_PACKLENGTH(count->field_length-1); - ulong col_length= (pack_length == 1 ? (uint) *(uchar*) start_pos : + uint var_pack_length= HA_VARCHAR_PACKLENGTH(count->field_length-1); + ulong col_length= (var_pack_length == 1 ? + (uint) *(uchar*) start_pos : uint2korr(start_pos)); /* Empty varchar are encoded with a single 1 bit. */ if (!col_length) @@ -2701,7 +2702,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) } else { - byte *end=start_pos+pack_length+col_length; + byte *end= start_pos + var_pack_length + col_length; DBUG_PRINT("fields", ("FIELD_VARCHAR not empty, bits: 1")); write_bits(0,1); /* Write the varchar length. */ @@ -2709,7 +2710,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) col_length, count->length_bits)); write_bits(col_length,count->length_bits); /* Encode the varchar bytes. */ - for (start_pos+=pack_length ; start_pos < end ; start_pos++) + for (start_pos+= var_pack_length ; start_pos < end ; start_pos++) { DBUG_PRINT("fields", ("value: 0x%02x code: 0x%s bits: %2u bin: %s", diff --git a/myisam/rt_index.c b/myisam/rt_index.c index 1806476dc39..bb1c4723a17 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -628,8 +628,6 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) { - int res; - if ((old_root = _mi_new(info, keyinfo, DFLT_INIT_HITS)) == HA_OFFSET_ERROR) return -1; info->buff_used = 1; @@ -915,7 +913,6 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) for (i = 0; i < ReinsertList.n_pages; ++i) { uchar *page_buf; - uint nod_flag; uchar *k; uchar *last; diff --git a/myisam/sort.c b/myisam/sort.c index eebef888e4a..9c340648c4f 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -221,9 +221,9 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, if (my_b_inited(&tempfile_for_exceptions)) { - MI_INFO *index=info->sort_info->info; + MI_INFO *idx=info->sort_info->info; uint keyno=info->key; - uint key_length, ref_length=index->s->rec_reflength; + uint key_length, ref_length=idx->s->rec_reflength; if (!no_messages) printf(" - Adding exceptions\n"); /* purecov: tested */ @@ -236,7 +236,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, && !my_b_read(&tempfile_for_exceptions,(byte*)sort_keys, (uint) key_length)) { - if (_mi_ck_write(index,keyno,(uchar*) sort_keys,key_length-ref_length)) + if (_mi_ck_write(idx,keyno,(uchar*) sort_keys,key_length-ref_length)) goto err; } } diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index df0835b830c..b2820df8f4c 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -1,3 +1,6 @@ +DROP TABLE IF EXISTS t1; +drop view if exists v1; +drop database if exists client_test_db; mysql.columns_priv OK mysql.db OK mysql.func OK diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 1cfc482416e..e95cda316f4 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -413,6 +413,8 @@ mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 7: Con mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +show tables; +ERROR 3D000: No database selected Output from mysqltest-x.inc Output from mysqltest-x.inc Output from mysqltest-x.inc diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index cb4a5593de7..445a66dd1f9 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -44,7 +44,7 @@ unlock tables; drop table t1; # -# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\' +# BUG#16217 - MySQL client misinterprets multi-byte char as escape `\' # # new command \C or charset @@ -241,4 +241,14 @@ drop table t17583; --error 1 --exec $MYSQL test -e "\r test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1 +# +# Some coverage of not normally used parts +# + +--disable_query_log +--exec $MYSQL test -e "show status" 2>&1 > /dev/null +--exec $MYSQL --help 2>&1 > /dev/null +--exec $MYSQL --version 2>&1 > /dev/null +--enable_quary_log + --echo End of 5.0 tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 0691cb7c76b..d7acc2e87b2 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -134,6 +134,14 @@ flush logs; --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL select * from t5 /* must be (1),(1) */; +# +# Some coverage of not normally used parts +# +--disable_query_log +--exec $MYSQL_BINLOG --version 2>&1 > /dev/null +--exec $MYSQL_BINLOG --help 2>&1 > /dev/null +--enable_query_log + # clean up drop table t1, t2, t03, t04, t3, t4, t5; diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 338e16363ea..f4e18d4004f 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -1,3 +1,12 @@ +# Clean up after previous tests +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +drop view if exists v1; +drop database if exists client_test_db; +--enable_warnings + # Embedded server doesn't support external clients --source include/not_embedded.inc diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 3c20b38722f..122cd4a2194 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1243,8 +1243,16 @@ EOF connect (con1,localhost,root,,); connection default; connection con1; +disconnect con1; --enable_abort_on_error +# Test connect without a database +connect (con2,localhost,root,,*NO-ONE*); +--error ER_NO_DB_ERROR +show tables; +disconnect con2; +connection default; + # ---------------------------------------------------------------------------- # Test mysqltest arguments # ---------------------------------------------------------------------------- @@ -1562,5 +1570,17 @@ EOF --exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# Some coverage tests +# ---------------------------------------------------------------------------- + +--disable_query_log +--exec $MYSQL_TEST --help 2>&1 > /dev/null +--exec $MYSQL_TEST --version 2>&1 > /dev/null +--enable_quary_log +--disable_abort_on_error +--error 1 +--exec $MYSQL_TEST a b c 2>&1 > /dev/null +--enable_abort_on_error --echo End of tests diff --git a/mysys/default.c b/mysys/default.c index d93f4135e73..33c1a162525 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -42,9 +42,9 @@ #include #endif -const char *defaults_file=0; -const char *defaults_group_suffix=0; -char *defaults_extra_file=0; +const char *my_defaults_file=0; +const char *my_defaults_group_suffix=0; +char *my_defaults_extra_file=0; /* Which directories are searched for options (and in which order) */ @@ -117,7 +117,7 @@ static char *remove_end_comment(char *ptr); 0 ok 1 given cinf_file doesn't exist - The global variable 'defaults_group_suffix' is updated with value for + The global variable 'my_defaults_group_suffix' is updated with value for --defaults_group_suffix */ @@ -133,28 +133,28 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, *args_used+= get_defaults_options(*argc - *args_used, *argv + *args_used, (char **) &forced_default_file, (char **) &forced_extra_defaults, - (char **) &defaults_group_suffix); + (char **) &my_defaults_group_suffix); - if (! defaults_group_suffix) - defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV)); + if (! my_defaults_group_suffix) + my_defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV)); if (forced_extra_defaults) - defaults_extra_file= (char *) forced_extra_defaults; + my_defaults_extra_file= (char *) forced_extra_defaults; if (forced_default_file) - defaults_file= forced_default_file; + my_defaults_file= forced_default_file; /* We can only handle 'defaults-group-suffix' if we are called from load_defaults() as otherwise we can't know the type of 'func_ctx' */ - if (defaults_group_suffix && func == handle_default_option) + if (my_defaults_group_suffix && func == handle_default_option) { /* Handle --defaults-group-suffix= */ uint i; const char **extra_groups; - const uint instance_len= strlen(defaults_group_suffix); + const uint instance_len= strlen(my_defaults_group_suffix); struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx; char *ptr; TYPELIB *group= ctx->group; @@ -177,7 +177,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, /** Construct new group */ memcpy(ptr, extra_groups[i], len); - memcpy(ptr+len, defaults_group_suffix, instance_len+1); + memcpy(ptr+len, my_defaults_group_suffix, instance_len+1); } group->count*= 2; @@ -211,15 +211,15 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, if (search_default_file(func, func_ctx, *dirs, conf_file) < 0) goto err; } - else if (defaults_extra_file) + else if (my_defaults_extra_file) { if ((error= search_default_file_with_ext(func, func_ctx, "", "", - defaults_extra_file, 0)) < 0) + my_defaults_extra_file, 0)) < 0) goto err; /* Fatal error */ if (error > 0) { fprintf(stderr, "Could not open required defaults file: %s\n", - defaults_extra_file); + my_defaults_extra_file); goto err; } } @@ -867,8 +867,8 @@ void my_print_default_files(const char *conf_file) char *end; if (**dirs) pos= *dirs; - else if (defaults_extra_file) - pos= defaults_extra_file; + else if (my_defaults_extra_file) + pos= my_defaults_extra_file; else continue; end= convert_dirname(name, pos, NullS); @@ -894,14 +894,14 @@ void print_defaults(const char *conf_file, const char **groups) fputs(*groups,stdout); } - if (defaults_group_suffix) + if (my_defaults_group_suffix) { groups= groups_save; for ( ; *groups ; groups++) { fputc(' ',stdout); fputs(*groups,stdout); - fputs(defaults_group_suffix,stdout); + fputs(my_defaults_group_suffix,stdout); } } puts("\nThe following options may be given as the first argument:\n\ diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index f1ea21c2a47..1afa2dd6e10 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -322,10 +322,10 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(args, char *); - uint length = (uint) strlen(par); + uint length2 = (uint) strlen(par); /* TODO: implement minimum width and precision */ - out_length+=length; - if (my_b_write(info, par, length)) + out_length+= length2; + if (my_b_write(info, par, length2)) goto err; } else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */ @@ -338,32 +338,32 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ { register int iarg; - uint length; + uint length2; char buff[17]; iarg = va_arg(args, int); if (*fmt == 'd') - length= (uint) (int10_to_str((long) iarg,buff, -10) - buff); + length2= (uint) (int10_to_str((long) iarg,buff, -10) - buff); else - length= (uint) (int10_to_str((long) (uint) iarg,buff,10)- buff); - out_length+=length; - if (my_b_write(info, buff, length)) + length2= (uint) (int10_to_str((long) (uint) iarg,buff,10)- buff); + out_length+= length2; + if (my_b_write(info, buff, length2)) goto err; } else if ((*fmt == 'l' && fmt[1] == 'd') || fmt[1] == 'u') /* long parameter */ { register long iarg; - uint length; + uint length2; char buff[17]; iarg = va_arg(args, long); if (*++fmt == 'd') - length= (uint) (int10_to_str(iarg,buff, -10) - buff); + length2= (uint) (int10_to_str(iarg,buff, -10) - buff); else - length= (uint) (int10_to_str(iarg,buff,10)- buff); - out_length+=length; - if (my_b_write(info, buff, length)) + length2= (uint) (int10_to_str(iarg,buff,10)- buff); + out_length+= length2; + if (my_b_write(info, buff, length2)) goto err; } else diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index d658e6fe055..bbbda609b21 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -841,9 +841,10 @@ static inline void link_changed(BLOCK_LINK *block, BLOCK_LINK **phead) */ static void link_to_file_list(KEY_CACHE *keycache, - BLOCK_LINK *block, int file, my_bool unlink) + BLOCK_LINK *block, int file, + my_bool unlink_block) { - if (unlink) + if (unlink_block) unlink_changed(block); link_changed(block, &keycache->file_blocks[FILE_HASH(file)]); if (block->status & BLOCK_CHANGED) diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 25ff2651e90..921fc7799a7 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -124,10 +124,10 @@ void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit) my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit) { - uchar *byte= map->bitmap + (bitmap_bit / 8); + uchar *value= map->bitmap + (bitmap_bit / 8); uchar bit= 1 << ((bitmap_bit) & 7); - uchar res= (*byte) & bit; - *byte|= bit; + uchar res= (*value) & bit; + *value|= bit; return res; } diff --git a/mysys/sha1.c b/mysys/sha1.c index 110d24f8bfc..11c6c14bf8c 100644 --- a/mysys/sha1.c +++ b/mysys/sha1.c @@ -245,7 +245,7 @@ static void SHA1ProcessMessageBlock(SHA1_CONTEXT *context) uint32 temp; /* Temporary word value */ uint32 W[80]; /* Word sequence */ uint32 A, B, C, D, E; /* Word buffers */ - int index; + int idx; /* Initialize the first 16 words in the array W @@ -253,11 +253,11 @@ static void SHA1ProcessMessageBlock(SHA1_CONTEXT *context) for (t = 0; t < 16; t++) { - index=t*4; - W[t] = context->Message_Block[index] << 24; - W[t] |= context->Message_Block[index + 1] << 16; - W[t] |= context->Message_Block[index + 2] << 8; - W[t] |= context->Message_Block[index + 3]; + idx=t*4; + W[t] = context->Message_Block[idx] << 24; + W[t] |= context->Message_Block[idx + 1] << 16; + W[t] |= context->Message_Block[idx + 2] << 8; + W[t] |= context->Message_Block[idx + 3]; } diff --git a/ndb/include/kernel/signaldata/ArbitSignalData.hpp b/ndb/include/kernel/signaldata/ArbitSignalData.hpp index 34b73644a13..233f9bf0a78 100644 --- a/ndb/include/kernel/signaldata/ArbitSignalData.hpp +++ b/ndb/include/kernel/signaldata/ArbitSignalData.hpp @@ -32,6 +32,7 @@ private: Uint32 data[2]; public: + ArbitTicket() {} STATIC_CONST( DataLength = 2 ); STATIC_CONST( TextLength = DataLength * 8 ); // hex digits @@ -143,6 +144,7 @@ public: ArbitTicket ticket; // ticket NodeBitmask mask; // set of nodes + ArbitSignalData() {} STATIC_CONST( SignalLength = 3 + ArbitTicket::DataLength + NodeBitmask::Size ); inline bool match(ArbitSignalData& aData) const { diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 0a7f6aa3fb3..41cb21ebdc1 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -275,6 +275,7 @@ public: Uint32 MinRowsLow; Uint32 MinRowsHigh; + Table() {} void init(); }; @@ -335,6 +336,7 @@ public: Uint32 AttributeAutoIncrement; char AttributeDefaultValue[MAX_ATTR_DEFAULT_VALUE_SIZE]; + Attribute() {} void init(); inline diff --git a/ndb/include/ndbapi/NdbReceiver.hpp b/ndb/include/ndbapi/NdbReceiver.hpp index ff6debc7fd3..5ba5f7021b5 100644 --- a/ndb/include/ndbapi/NdbReceiver.hpp +++ b/ndb/include/ndbapi/NdbReceiver.hpp @@ -58,7 +58,7 @@ public: bool checkMagicNumber() const; - inline void next(NdbReceiver* next) { m_next = next;} + inline void next(NdbReceiver* next_arg) { m_next = next_arg;} inline NdbReceiver* next() { return m_next; } void setErrorCode(int); diff --git a/ndb/include/transporter/TransporterDefinitions.hpp b/ndb/include/transporter/TransporterDefinitions.hpp index e9c5ffa2c80..d72ea006ff6 100644 --- a/ndb/include/transporter/TransporterDefinitions.hpp +++ b/ndb/include/transporter/TransporterDefinitions.hpp @@ -117,6 +117,11 @@ struct SegmentedSectionPtr { Uint32 i; struct SectionSegment * p; + SegmentedSectionPtr() {} + SegmentedSectionPtr(Uint32 sz_arg, Uint32 i_arg, + struct SectionSegment *p_arg) + :sz(sz_arg), i(i_arg), p(p_arg) + {} void setNull() { p = 0;} bool isNull() const { return p == 0;} }; diff --git a/ndb/include/util/InputStream.hpp b/ndb/include/util/InputStream.hpp index 56c43686df1..29866aa3418 100644 --- a/ndb/include/util/InputStream.hpp +++ b/ndb/include/util/InputStream.hpp @@ -27,6 +27,7 @@ class InputStream { public: virtual ~InputStream() {} virtual char* gets(char * buf, int bufLen) = 0; + InputStream() {} }; class FileInputStream : public InputStream { diff --git a/ndb/include/util/OutputStream.hpp b/ndb/include/util/OutputStream.hpp index a834b577bb3..ccf88a72359 100644 --- a/ndb/include/util/OutputStream.hpp +++ b/ndb/include/util/OutputStream.hpp @@ -25,6 +25,7 @@ */ class OutputStream { public: + OutputStream() {} virtual ~OutputStream() {} virtual int print(const char * fmt, ...) = 0; virtual int println(const char * fmt, ...) = 0; @@ -61,6 +62,7 @@ public: class NullOutputStream : public OutputStream { public: + NullOutputStream() {} int print(const char * /* unused */, ...) { return 1;} int println(const char * /* unused */, ...) { return 1;} }; diff --git a/ndb/include/util/SimpleProperties.hpp b/ndb/include/util/SimpleProperties.hpp index b29e65e21da..c19780c2757 100644 --- a/ndb/include/util/SimpleProperties.hpp +++ b/ndb/include/util/SimpleProperties.hpp @@ -169,6 +169,7 @@ public: bool add(Uint16 key, Uint32 value); bool add(Uint16 key, const char * value); bool add(Uint16 key, const void* value, int len); + Writer() {} protected: virtual ~Writer() {} virtual bool reset() = 0; diff --git a/ndb/include/util/SocketAuthenticator.hpp b/ndb/include/util/SocketAuthenticator.hpp index 1b82567feaa..0c3de073b1e 100644 --- a/ndb/include/util/SocketAuthenticator.hpp +++ b/ndb/include/util/SocketAuthenticator.hpp @@ -20,6 +20,7 @@ class SocketAuthenticator { public: + SocketAuthenticator() {} virtual ~SocketAuthenticator() {}; virtual bool client_authenticate(int sockfd) = 0; virtual bool server_authenticate(int sockfd) = 0; diff --git a/ndb/include/util/SocketServer.hpp b/ndb/include/util/SocketServer.hpp index ea709bfecae..c4f7e8c0ade 100644 --- a/ndb/include/util/SocketServer.hpp +++ b/ndb/include/util/SocketServer.hpp @@ -60,6 +60,7 @@ public: */ class Service { public: + Service() {} virtual ~Service(){} /** diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index a0e3a4b74f3..e3fa68a11d6 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -155,12 +155,13 @@ ConfigRetriever::getConfig() { } ndb_mgm_configuration * -ConfigRetriever::getConfig(NdbMgmHandle m_handle) +ConfigRetriever::getConfig(NdbMgmHandle m_handle_arg) { - ndb_mgm_configuration * conf = ndb_mgm_get_configuration(m_handle,m_version); + ndb_mgm_configuration * conf = ndb_mgm_get_configuration(m_handle_arg, + m_version); if(conf == 0) { - setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle_arg)); return 0; } return conf; diff --git a/ndb/src/common/portlib/NdbTick.c b/ndb/src/common/portlib/NdbTick.c index d8f0b6ec27a..95843282797 100644 --- a/ndb/src/common/portlib/NdbTick.c +++ b/ndb/src/common/portlib/NdbTick.c @@ -61,9 +61,9 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ int res = gettimeofday(&tick_time, 0); if(secs==0) { - NDB_TICKS secs = tick_time.tv_sec; + NDB_TICKS local_secs = tick_time.tv_sec; *micros = tick_time.tv_usec; - *micros = secs*1000000+*micros; + *micros = local_secs*1000000+*micros; } else { * secs = tick_time.tv_sec; * micros = tick_time.tv_usec; diff --git a/ndb/src/common/transporter/SHM_Transporter.cpp b/ndb/src/common/transporter/SHM_Transporter.cpp index 93d718b8713..38685b6fdc7 100644 --- a/ndb/src/common/transporter/SHM_Transporter.cpp +++ b/ndb/src/common/transporter/SHM_Transporter.cpp @@ -32,7 +32,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, const char *lHostName, const char *rHostName, int r_port, - bool isMgmConnection, + bool isMgmConnection_arg, NodeId lNodeId, NodeId rNodeId, NodeId serverNodeId, @@ -41,7 +41,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, key_t _shmKey, Uint32 _shmSize) : Transporter(t_reg, tt_SHM_TRANSPORTER, - lHostName, rHostName, r_port, isMgmConnection, + lHostName, rHostName, r_port, isMgmConnection_arg, lNodeId, rNodeId, serverNodeId, 0, false, checksum, signalId), shmKey(_shmKey), diff --git a/ndb/src/common/transporter/TCP_Transporter.cpp b/ndb/src/common/transporter/TCP_Transporter.cpp index 5db12d3985c..152e4fe9cbc 100644 --- a/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/ndb/src/common/transporter/TCP_Transporter.cpp @@ -68,14 +68,14 @@ TCP_Transporter::TCP_Transporter(TransporterRegistry &t_reg, const char *lHostName, const char *rHostName, int r_port, - bool isMgmConnection, + bool isMgmConnection_arg, NodeId lNodeId, NodeId rNodeId, NodeId serverNodeId, bool chksm, bool signalId, Uint32 _reportFreq) : Transporter(t_reg, tt_TCP_TRANSPORTER, - lHostName, rHostName, r_port, isMgmConnection, + lHostName, rHostName, r_port, isMgmConnection_arg, lNodeId, rNodeId, serverNodeId, 0, false, chksm, signalId), m_sendBuffer(sendBufSize) diff --git a/ndb/src/common/transporter/TCP_Transporter.hpp b/ndb/src/common/transporter/TCP_Transporter.hpp index df4149531b4..59b2bf435fe 100644 --- a/ndb/src/common/transporter/TCP_Transporter.hpp +++ b/ndb/src/common/transporter/TCP_Transporter.hpp @@ -34,6 +34,7 @@ struct ReceiveBuffer { Uint32 sizeOfData; // In bytes Uint32 sizeOfBuffer; + ReceiveBuffer() {} bool init(int bytes); void destroy(); diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index b2ee75e4754..2882e080c8e 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -104,7 +104,7 @@ Transporter::connect_server(NDB_SOCKET_TYPE sockfd) { { struct sockaddr_in addr; SOCKET_SIZE_TYPE addrlen= sizeof(addr); - int r= getpeername(sockfd, (struct sockaddr*)&addr, &addrlen); + getpeername(sockfd, (struct sockaddr*)&addr, &addrlen); m_connect_address= (&addr)->sin_addr; } @@ -210,7 +210,7 @@ Transporter::connect_client(NDB_SOCKET_TYPE sockfd) { { struct sockaddr_in addr; SOCKET_SIZE_TYPE addrlen= sizeof(addr); - int r= getpeername(sockfd, (struct sockaddr*)&addr, &addrlen); + getpeername(sockfd, (struct sockaddr*)&addr, &addrlen); m_connect_address= (&addr)->sin_addr; } diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index cd78bc52027..cffce1c2cc6 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -1414,8 +1414,6 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, bool TransporterRegistry::start_service(SocketServer& socket_server) { - struct ndb_mgm_reply mgm_reply; - DBUG_ENTER("TransporterRegistry::start_service"); if (m_transporter_interface.size() > 0 && !nodeIdSpecified) { diff --git a/ndb/src/common/util/Bitmask.cpp b/ndb/src/common/util/Bitmask.cpp index 0aa39a37204..4db41dd38ae 100644 --- a/ndb/src/common/util/Bitmask.cpp +++ b/ndb/src/common/util/Bitmask.cpp @@ -1,21 +1,6 @@ #include #include -static -void print(const Uint32 src[], Uint32 len, Uint32 pos = 0) -{ - printf("b'"); - for(unsigned i = 0; i> 5, src, i+pos)) - printf("1"); - else - printf("0"); - if((i & 31) == 31) - printf(" "); - } -} - #ifndef __TEST_BITMASK__ void @@ -80,6 +65,21 @@ BitmaskImpl::setFieldImpl(Uint32 dst[], } #else +static +void print(const Uint32 src[], Uint32 len, Uint32 pos = 0) +{ + printf("b'"); + for(unsigned i = 0; i> 5, src, i+pos)) + printf("1"); + else + printf("0"); + if((i & 31) == 31) + printf(" "); + } +} + #define DEBUG 0 #include static void do_test(int bitmask_size); diff --git a/ndb/src/common/util/ConfigValues.cpp b/ndb/src/common/util/ConfigValues.cpp index ae4fbfd2f71..34d289e06dc 100644 --- a/ndb/src/common/util/ConfigValues.cpp +++ b/ndb/src/common/util/ConfigValues.cpp @@ -433,13 +433,13 @@ ConfigValuesFactory::put(const ConfigValues::Entry & entry){ if(count >= sz){ pos = hash(tmp, sz); count = 0; - Uint32 val = m_cfg->m_values[pos]; + Uint32 val2 = m_cfg->m_values[pos]; printf("key: %d, (key %% size): %d\n", entry.m_key, (entry.m_key % sz)); printf("pos: %d", pos); - while((val & KP_MASK) != tmp && val != CFV_KEY_FREE && count < sz){ + while((val2 & KP_MASK) != tmp && val2 != CFV_KEY_FREE && count < sz){ pos = nextHash(tmp, sz, pos, ++count); - val = m_cfg->m_values[pos]; + val2 = m_cfg->m_values[pos]; printf(" %d", pos); } printf("\n"); diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 056b7ff199b..5b65240e3ad 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -152,9 +152,9 @@ File_class::readChar(char* buf) } int -File_class::write(const void* buf, size_t size, size_t nitems) +File_class::write(const void* buf, size_t size_arg, size_t nitems) { - return ::fwrite(buf, size, nitems, m_file); + return ::fwrite(buf, size_arg, nitems, m_file); } int diff --git a/ndb/src/common/util/Properties.cpp b/ndb/src/common/util/Properties.cpp index 0edcda0e726..e8c71455918 100644 --- a/ndb/src/common/util/Properties.cpp +++ b/ndb/src/common/util/Properties.cpp @@ -628,11 +628,11 @@ PropertiesImpl::getPropsPut(const char * name, if(nvp == 0){ Properties * tmpP = new Properties(); PropertyImpl * tmpPI = new PropertyImpl(tmp2, tmpP); - PropertyImpl * nvp = put(tmpPI); + PropertyImpl * nvp2 = put(tmpPI); delete tmpP; free(tmp2); - return ((Properties*)nvp->value)->impl->getPropsPut(tmp+1, impl); + return ((Properties*)nvp2->value)->impl->getPropsPut(tmp+1, impl); } free(tmp2); if(nvp->valueType != PropertiesType_Properties){ diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp index f4f2babf312..fd93fc227f6 100644 --- a/ndb/src/common/util/SocketClient.cpp +++ b/ndb/src/common/util/SocketClient.cpp @@ -88,7 +88,7 @@ SocketClient::bind(const char* bindaddress, unsigned short localport) int ret = errno; NDB_CLOSE_SOCKET(m_sockfd); m_sockfd= NDB_INVALID_SOCKET; - return errno; + return ret; } if (::bind(m_sockfd, (struct sockaddr*)&local, sizeof(local)) == -1) diff --git a/ndb/src/common/util/random.c b/ndb/src/common/util/random.c index 21235763793..2098af98ad1 100644 --- a/ndb/src/common/util/random.c +++ b/ndb/src/common/util/random.c @@ -198,7 +198,7 @@ int initSequence(RandomSequence *seq, SequenceValues *inputValues) unsigned int i; unsigned int j; unsigned int totalLength; - unsigned int index; + unsigned int idx; if( !seq || !inputValues ) return(-1); @@ -220,12 +220,12 @@ int initSequence(RandomSequence *seq, SequenceValues *inputValues) /*----------------------*/ /* set the array values */ /*----------------------*/ - index = 0; + idx = 0; for(i = 0; inputValues[i].length != 0; i++) { for(j = 0; j < inputValues[i].length; j++ ) { - seq->values[index] = inputValues[i].value; - index++; + seq->values[idx] = inputValues[i].value; + idx++; } } diff --git a/ndb/src/common/util/socket_io.cpp b/ndb/src/common/util/socket_io.cpp index ba2794e4374..4e89be1379c 100644 --- a/ndb/src/common/util/socket_io.cpp +++ b/ndb/src/common/util/socket_io.cpp @@ -142,8 +142,8 @@ write_socket(NDB_SOCKET_TYPE socket, int timeout_millis, FD_SET(socket, &writeset); timeout.tv_sec = 1; timeout.tv_usec = 0; - const int selectRes = select(socket + 1, 0, &writeset, 0, &timeout); - if(selectRes != 1){ + const int selectRes2 = select(socket + 1, 0, &writeset, 0, &timeout); + if(selectRes2 != 1){ return -1; } } diff --git a/ndb/src/cw/cpcd/APIService.cpp b/ndb/src/cw/cpcd/APIService.cpp index e7a2092c15d..e30b1b8689e 100644 --- a/ndb/src/cw/cpcd/APIService.cpp +++ b/ndb/src/cw/cpcd/APIService.cpp @@ -390,7 +390,6 @@ CPCDAPISession::listProcesses(Parser_t::Context & /* unused */, void CPCDAPISession::showVersion(Parser_t::Context & /* unused */, const class Properties & args){ - Uint32 id; CPCD::RequestStatus rs; m_output->println("show version"); diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 137735c9e76..6963fd54a29 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -75,8 +75,6 @@ extern "C" static void sig_child(int signo, siginfo_t*, void*); const char *progname = "ndb_cpcd"; int main(int argc, char** argv){ - int save_argc= argc; - char** save_argv= argv; const char *load_default_groups[]= { "ndb_cpcd",0 }; MY_INIT(argv[0]); diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 44f9917438f..38fc6d0447b 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -1234,7 +1234,7 @@ Cmvmi::execTESTSIG(Signal* signal){ fprintf(stdout, "\n"); for(i = 0; iheader.m_noOfSections; i++){ - SegmentedSectionPtr ptr = {0,0,0}; + SegmentedSectionPtr ptr(0,0,0); ndbout_c("-- Section %d --", i); signal->getSection(ptr, i); ndbrequire(ptr.p != 0); @@ -1292,7 +1292,7 @@ Cmvmi::execTESTSIG(Signal* signal){ LinearSectionPtr ptr[3]; const Uint32 secs = signal->getNoOfSections(); for(i = 0; igetSection(sptr, i); ptr[i].sz = sptr.sz; ptr[i].p = new Uint32[sptr.sz]; @@ -1341,7 +1341,7 @@ Cmvmi::execTESTSIG(Signal* signal){ LinearSectionPtr ptr[3]; const Uint32 secs = signal->getNoOfSections(); for(i = 0; igetSection(sptr, i); ptr[i].sz = sptr.sz; ptr[i].p = new Uint32[sptr.sz]; @@ -1407,7 +1407,7 @@ Cmvmi::execTESTSIG(Signal* signal){ const Uint32 secs = signal->getNoOfSections(); memset(g_test, 0, sizeof(g_test)); for(i = 0; igetSection(sptr, i); g_test[i].sz = sptr.sz; g_test[i].p = new Uint32[sptr.sz]; diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 2eca2a76c45..871efd6b1ce 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -5068,11 +5068,6 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, tablePtr.p->minRowsLow = tableDesc.MinRowsLow; tablePtr.p->minRowsHigh = tableDesc.MinRowsHigh; - Uint64 maxRows = - (((Uint64)tablePtr.p->maxRowsHigh) << 32) + tablePtr.p->maxRowsLow; - Uint64 minRows = - (((Uint64)tablePtr.p->minRowsHigh) << 32) + tablePtr.p->minRowsLow; - tablePtr.p->frmLen = tableDesc.FrmLen; memcpy(tablePtr.p->frmData, tableDesc.FrmData, tableDesc.FrmLen); diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 82644826d5b..13b4f0279d3 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -132,6 +132,7 @@ public: * on disk. Index trigger ids are volatile. */ struct TableRecord : public MetaData::Table { + TableRecord() {} Uint32 maxRowsLow; Uint32 maxRowsHigh; Uint32 minRowsLow; @@ -251,6 +252,7 @@ public: * attributes. This is wrong but convenient. */ struct AttributeRecord : public MetaData::Attribute { + AttributeRecord() {} union { /** Pointer to the next attribute used by ArrayPool */ Uint32 nextPool; @@ -286,6 +288,7 @@ public: * trigger online creates the trigger in TC (if index) and LQH-TUP. */ struct TriggerRecord { + TriggerRecord() {} /** Trigger state */ enum TriggerState { @@ -865,6 +868,7 @@ private: * seize/release invokes ctor/dtor automatically. */ struct OpRecordCommon { + OpRecordCommon() {} Uint32 key; // key shared between master and slaves Uint32 nextHash; Uint32 prevHash; @@ -880,6 +884,7 @@ private: * Create table record */ struct CreateTableRecord : OpRecordCommon { + CreateTableRecord() {} Uint32 m_senderRef; Uint32 m_senderData; Uint32 m_coordinatorRef; @@ -918,6 +923,7 @@ private: * Drop table record */ struct DropTableRecord : OpRecordCommon { + DropTableRecord() {} DropTableReq m_request; Uint32 m_requestType; diff --git a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index 53e54e96d2b..aea23ce7c78 100644 --- a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -1289,6 +1289,7 @@ public: private: struct LcpState { + LcpState() {} LcpStatus lcpStatus; Uint32 lcpStatusUpdatedPlace; @@ -1395,6 +1396,7 @@ public: private: class MasterTakeOverState { public: + MasterTakeOverState() {} void set(LcpMasterTakeOverState s, Uint32 line) { state = s; updatePlace = line; } @@ -1482,6 +1484,7 @@ private: * SwitchReplicaRecord - Should only be used by master */ struct SwitchReplicaRecord { + SwitchReplicaRecord() {} void clear(){} Uint32 nodeId; diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 299cad16ec1..6900aec8c80 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -509,6 +509,7 @@ public: typedef Ptr DatabufPtr; struct ScanRecord { + ScanRecord() {} enum ScanState { SCAN_FREE = 0, WAIT_STORED_PROC_COPY = 1, @@ -2898,6 +2899,7 @@ public: * */ struct CommitAckMarker { + CommitAckMarker() {} Uint32 transid1; Uint32 transid2; @@ -2924,6 +2926,7 @@ public: void scanMarkers(Signal* signal, Uint32 tcNodeFail, Uint32 bucket, Uint32 i); struct Counters { + Counters() {} Uint32 operations; inline void clear(){ diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 4739450884c..bc615711dd3 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -7511,7 +7511,6 @@ Dblqh::get_acc_ptr_from_scan_record(ScanRecord* scanP, bool crash_flag) { Uint32* acc_ptr; - Uint32 attr_buf_rec, attr_buf_index; if (!((index < MAX_PARALLEL_OP_PER_SCAN) && index < scanP->scan_acc_index)) { ndbrequire(crash_flag); @@ -7556,7 +7555,6 @@ void Dblqh::execSCAN_FRAGREQ(Signal* signal) const Uint32 scanLockMode = ScanFragReq::getLockMode(reqinfo); const Uint8 keyinfo = ScanFragReq::getKeyinfoFlag(reqinfo); const Uint8 rangeScan = ScanFragReq::getRangeScanFlag(reqinfo); - const Uint8 tupScan = ScanFragReq::getTupScanFlag(reqinfo); ptrCheckGuard(tabptr, ctabrecFileSize, tablerec); if(tabptr.p->tableStatus != Tablerec::TABLE_DEFINED){ @@ -8942,9 +8940,6 @@ Uint32 Dblqh::sendKeyinfo20(Signal* signal, const Uint32 scanOp = scanP->m_curr_batch_size_rows; const Uint32 nodeId = refToNode(ref); const bool connectedToNode = getNodeInfo(nodeId).m_connected; - const Uint32 type = getNodeInfo(nodeId).m_type; - const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::REP); - const bool old_dest = (getNodeInfo(nodeId).m_version < MAKE_VERSION(3,5,0)); const bool longable = true; // TODO is_api && !old_dest; Uint32 * dst = keyInfo->keyData; @@ -9045,7 +9040,6 @@ void Dblqh::sendScanFragConf(Signal* signal, Uint32 scanCompleted) return; } ScanFragConf * conf = (ScanFragConf*)&signal->theData[0]; - NodeId tc_node_id= refToNode(tcConnectptr.p->clientBlockref); Uint32 trans_id1= tcConnectptr.p->transid[0]; Uint32 trans_id2= tcConnectptr.p->transid[1]; @@ -11331,7 +11325,6 @@ void Dblqh::sendAccContOp(Signal* signal) { LcpLocRecordPtr sacLcpLocptr; - int count = 0; sacLcpLocptr.i = lcpPtr.p->firstLcpLocAcc; do { ptrCheckGuard(sacLcpLocptr, clcpLocrecFileSize, lcpLocRecord); @@ -15033,8 +15026,6 @@ void Dblqh::execDEBUG_SIG(Signal* signal) 2.5 TEMPORARY VARIABLES ----------------------- */ - UintR tdebug; - jamEntry(); //logPagePtr.i = signal->theData[0]; //tdebug = logPagePtr.p->logPageWord[0]; diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index bf6ce7129ba..79becb1ec8c 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -304,6 +304,7 @@ public: /* WHEN THE TRIGGER IS DEACTIVATED. */ /* **************************************** */ struct TcDefinedTriggerData { + TcDefinedTriggerData() {} /** * Trigger id, used to identify the trigger */ @@ -957,6 +958,7 @@ public: /* ALL TABLES IN THE SYSTEM. */ /********************************************************/ struct TableRecord { + TableRecord() {} Uint32 currentSchemaVersion; Uint8 enabled; Uint8 dropping; @@ -1665,6 +1667,7 @@ private: UintR tcheckGcpId; struct TransCounters { + TransCounters() {} enum { Off, Timer, Started } c_trans_status; UintR cattrinfoCount; UintR ctransCount; @@ -1803,6 +1806,7 @@ private: */ public: struct CommitAckMarker { + CommitAckMarker() {} Uint32 transid1; Uint32 transid2; union { Uint32 nextPool; Uint32 nextHash; }; diff --git a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 0b66d9a45bb..17178a9681e 100644 --- a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -747,6 +747,7 @@ typedef Ptr RestartInfoRecordPtr; /* WHEN THE TRIGGER IS DEACTIVATED. */ /* **************************************** */ struct TupTriggerData { + TupTriggerData() {} /** * Trigger id, used by DICT/TRIX to identify the trigger diff --git a/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index 396404faa8c..56d63bc66f1 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -90,7 +90,6 @@ Dbtup::execNEXT_SCANREQ(Signal* signal) FragrecordPtr fragPtr; fragPtr.i = scan.m_fragPtrI[0]; ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord); - Fragrecord& frag = *fragPtr.p; switch (req->scanFlag) { case NextScanReq::ZSCAN_NEXT: jam(); diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp index 68a3e78ce9e..6138de2f7fa 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp @@ -402,8 +402,6 @@ Dbtux::nodePopUpScans(NodeHandle& node, unsigned pos) void Dbtux::nodeSlide(NodeHandle& dstNode, NodeHandle& srcNode, unsigned cnt, unsigned i) { - Frag& frag = dstNode.m_frag; - TreeHead& tree = frag.m_tree; ndbrequire(i <= 1); while (cnt != 0) { TreeEnt ent; diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp index 6d9385b3989..a8a83ffa7c4 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp @@ -705,7 +705,6 @@ Dbtux::scanFirst(ScanOpPtr scanPtr) debugOut << "Enter first scan " << scanPtr.i << " " << scan << endl; } #endif - TreeHead& tree = frag.m_tree; // set up index keys for this operation setKeyAttrs(frag); // scan direction 0, 1 @@ -986,7 +985,6 @@ Dbtux::scanVisible(ScanOpPtr scanPtr, TreeEnt ent) const Frag& frag = *c_fragPool.getPtr(scan.m_fragPtrI); Uint32 fragBit = ent.m_fragBit; Uint32 tableFragPtrI = frag.m_tupTableFragPtrI[fragBit]; - Uint32 fragId = frag.m_fragId | fragBit; Uint32 tupAddr = getTupAddr(frag, ent); Uint32 tupVersion = ent.m_tupVersion; // check for same tuple twice in row diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp index 5107a8d8e31..1ed24d1b694 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp @@ -213,7 +213,6 @@ Dbtux::treeRemove(Frag& frag, TreePos treePos) void Dbtux::treeRemoveInner(Frag& frag, NodeHandle lubNode, unsigned pos) { - TreeHead& tree = frag.m_tree; TreeEnt ent; // find g.l.b node NodeHandle glbNode(frag); diff --git a/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp b/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp index 7aa5be7a3cb..7d9fde5a500 100644 --- a/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp +++ b/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp @@ -83,6 +83,7 @@ public: */ struct StartRecord { + StartRecord() {} Uint64 m_startTime; void reset(); diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index af05eeb9e9a..a8a42884eac 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -819,7 +819,6 @@ Ndbcntr::trySystemRestart(Signal* signal){ */ const bool allNodes = c_start.m_waiting.equal(c_allDefinedNodes); const bool allClusterNodes = c_start.m_waiting.equal(c_clusterNodes); - const Uint64 now = NdbTick_CurrentMillisecond(); if(!allClusterNodes){ jam(); @@ -1391,7 +1390,6 @@ void Ndbcntr::execNODE_FAILREP(Signal* signal) const bool tMasterFailed = allFailed.get(cmasterNodeId); const bool tStarted = !failedStarted.isclear(); const bool tStarting = !failedStarting.isclear(); - const bool tWaiting = !failedWaiting.isclear(); if(tMasterFailed){ jam(); @@ -2472,8 +2470,6 @@ void Ndbcntr::execABORT_ALL_CONF(Signal* signal){ void Ndbcntr::execABORT_ALL_REF(Signal* signal){ jamEntry(); - AbortAllRef *abortAllRef = (AbortAllRef *)&signal->theData[0]; - AbortAllRef::ErrorCode errorCode = (AbortAllRef::ErrorCode) abortAllRef->errorCode; StopRef * const stopRef = (StopRef *)&signal->theData[0]; stopRef->senderData = c_stopRec.stopReq.senderData; diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp index 997bf40fe2a..a2e8d521051 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp @@ -107,6 +107,8 @@ class AsyncFile; class Request { public: + Request() {} + enum Action { open, close, diff --git a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp index e728ea81a7d..b68b7054d86 100644 --- a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp +++ b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp @@ -102,6 +102,7 @@ public: }; struct StartRecord { + StartRecord() {} void reset(){ m_startKey++; m_startNode = 0; @@ -170,6 +171,7 @@ public: }; struct ArbitRec { + ArbitRec() {} ArbitState state; // state bool newstate; // flag to initialize new state unsigned thread; // identifies a continueB "thread" diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 68e649d8ae0..3f5d4bf0601 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -846,7 +846,6 @@ void Qmgr::execCM_REGCONF(Signal* signal) jamEntry(); const CmRegConf * const cmRegConf = (CmRegConf *)&signal->theData[0]; - Uint32 presidentNodeId = cmRegConf->presidentNodeId; if (!ndbCompatible_ndb_ndb(NDB_VERSION, cmRegConf->presidentVersion)) { jam(); @@ -1271,7 +1270,6 @@ Qmgr::check_startup(Signal* signal) /** * Check for missing node group directly */ - char buf[100]; NdbNodeBitmask check; check.assign(c_definedNodes); check.bitANDC(c_start.m_starting_nodes); // Not connected nodes diff --git a/ndb/src/kernel/blocks/suma/Suma.cpp b/ndb/src/kernel/blocks/suma/Suma.cpp index 449436331e4..d2b006fd05a 100644 --- a/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/ndb/src/kernel/blocks/suma/Suma.cpp @@ -1435,7 +1435,6 @@ SumaParticipant::SyncRecord::nextScan(Signal* signal){ LocalDataBuffer<15> attrBuf(suma.c_dataBufferPool, head); ScanFragReq * req = (ScanFragReq *)signal->getDataPtrSend(); - const Uint32 parallelism = 16; const Uint32 attrLen = 5 + attrBuf.getSize(); req->senderData = m_subscriptionPtrI; @@ -1611,10 +1610,6 @@ SumaParticipant::execSCAN_HBREP(Signal* signal){ static Uint32 f_bufferLock = 0; static Uint32 f_buffer[SUMA_BUF_SZ]; -static Uint32 f_trigBufferSize = 0; -static Uint32 b_bufferLock = 0; -static Uint32 b_buffer[SUMA_BUF_SZ]; -static Uint32 b_trigBufferSize = 0; void SumaParticipant::execTRANSID_AI(Signal* signal){ @@ -1718,7 +1713,6 @@ SumaParticipant::execSUB_REMOVE_REQ(Signal* signal) { return; } - int count = 0; { jam(); SubscriberPtr i_subbPtr; diff --git a/ndb/src/kernel/blocks/suma/Suma.hpp b/ndb/src/kernel/blocks/suma/Suma.hpp index 5cf1c4d543f..1f2023635cc 100644 --- a/ndb/src/kernel/blocks/suma/Suma.hpp +++ b/ndb/src/kernel/blocks/suma/Suma.hpp @@ -209,6 +209,7 @@ public: friend struct SyncRecord; struct Subscription { + Subscription() {} Uint32 m_subscriberRef; Uint32 m_subscriberData; Uint32 m_senderRef; diff --git a/ndb/src/kernel/vm/MetaData.hpp b/ndb/src/kernel/vm/MetaData.hpp index 1000114a421..adf28fb702d 100644 --- a/ndb/src/kernel/vm/MetaData.hpp +++ b/ndb/src/kernel/vm/MetaData.hpp @@ -68,6 +68,7 @@ public: */ class Table { public: + Table() {} /* Table id (array index in DICT and other blocks) */ Uint32 tableId; diff --git a/ndb/src/mgmapi/LocalConfig.cpp b/ndb/src/mgmapi/LocalConfig.cpp index 75ad8b40a1f..eb1ea2b322a 100644 --- a/ndb/src/mgmapi/LocalConfig.cpp +++ b/ndb/src/mgmapi/LocalConfig.cpp @@ -74,9 +74,9 @@ LocalConfig::init(const char *connectString, //4. Check Ndb.cfg in NDB_HOME { bool fopenError; - char *buf= NdbConfig_NdbCfgName(1 /*true*/); - NdbAutoPtr tmp_aptr(buf); - if(readFile(buf, fopenError)) + char *buf2= NdbConfig_NdbCfgName(1 /*true*/); + NdbAutoPtr tmp_aptr(buf2); + if(readFile(buf2, fopenError)) DBUG_RETURN(true); if (!fopenError) DBUG_RETURN(false); @@ -85,9 +85,9 @@ LocalConfig::init(const char *connectString, //5. Check Ndb.cfg in cwd { bool fopenError; - char *buf= NdbConfig_NdbCfgName(0 /*false*/); - NdbAutoPtr tmp_aptr(buf); - if(readFile(buf, fopenError)) + char *buf2= NdbConfig_NdbCfgName(0 /*false*/); + NdbAutoPtr tmp_aptr(buf2); + if(readFile(buf2, fopenError)) DBUG_RETURN(true); if (!fopenError) DBUG_RETURN(false); @@ -95,9 +95,9 @@ LocalConfig::init(const char *connectString, //7. Check { - char buf[256]; - BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_PORT); - if(readConnectString(buf, "default connect string")) + char buf2[256]; + BaseString::snprintf(buf2, sizeof(buf2), "host=localhost:%s", NDB_PORT); + if(readConnectString(buf2, "default connect string")) DBUG_RETURN(true); } diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 8aa4f7213de..3531367740f 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -455,7 +455,6 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, LocalConfig &cfg= handle->cfg; NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET; Uint32 i; - int binderror = 0; SocketClient s(0, 0); if (!s.init()) { @@ -824,12 +823,12 @@ ndb_mgm_get_status(NdbMgmHandle handle) break; } - Vector split; - tmp.split(split, ":.", 4); - if(split.size() != 4) + Vector split2; + tmp.split(split2, ":.", 4); + if(split2.size() != 4) break; - const int id = atoi(split[1].c_str()); + const int id = atoi(split2[1].c_str()); if(id != nodeId){ ptr++; i++; @@ -837,9 +836,9 @@ ndb_mgm_get_status(NdbMgmHandle handle) ptr->node_id = id; } - split[3].trim(" \t\n"); + split2[3].trim(" \t\n"); - if(status_ackumulate(ptr,split[2].c_str(), split[3].c_str()) != 0) { + if(status_ackumulate(ptr,split2[2].c_str(), split2[3].c_str()) != 0) { break; } } diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 1dacd9689e8..6faa7677da9 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1550,7 +1550,6 @@ CommandInterpreter::executePurge(char* parameters) return -1; } - int i; char *str; if (ndb_mgm_purge_stale_sessions(m_mgmsrv, &str)) { @@ -1668,7 +1667,6 @@ CommandInterpreter::executeConnect(char* parameters, bool interactive) { BaseString *basestring = NULL; - int retval; disconnect(); if (!emptyString(parameters)) { basestring= new BaseString(parameters); @@ -2103,7 +2101,6 @@ CommandInterpreter::executeStatus(int processId, ndb_mgm_node_status status; Uint32 startPhase, version; - bool system; struct ndb_mgm_cluster_state *cl; cl = ndb_mgm_get_status(m_mgmsrv); diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index d4e72a7ff1d..6780c53a71e 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -2318,7 +2318,6 @@ ConfigInfo::ConfigInfo() break; case CI_BOOL: { - bool tmp_bool; require(InitConfigFileParser::convertStringToBool(param._default, default_bool)); require(p->put(param._fname, default_bool)); break; @@ -2326,7 +2325,6 @@ ConfigInfo::ConfigInfo() case CI_INT: case CI_INT64: { - Uint64 tmp_uint64; require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64)); require(p->put(param._fname, default_uint64)); break; @@ -2842,7 +2840,7 @@ applyDefaultValues(InitConfigFileParser::Context & ctx, Properties::Iterator it(defaults); for(const char * name = it.first(); name != NULL; name = it.next()){ - ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name); + (void) ctx.m_info->getStatus(ctx.m_currentInfo, name); if(!ctx.m_currentSection->contains(name)){ switch (ctx.m_info->getType(ctx.m_currentInfo, name)){ case ConfigInfo::CI_INT: @@ -3449,7 +3447,7 @@ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){ if(!ctx.m_currentInfo->get(n, &info)) continue; - Uint32 id = 0; + id = 0; info->get("Id", &id); if(id == KEY_INTERNAL) diff --git a/ndb/src/mgmsrv/ConfigInfo.hpp b/ndb/src/mgmsrv/ConfigInfo.hpp index 788619db7fe..fb4be836a53 100644 --- a/ndb/src/mgmsrv/ConfigInfo.hpp +++ b/ndb/src/mgmsrv/ConfigInfo.hpp @@ -27,8 +27,11 @@ * A MANDATORY parameters must be specified in the config file * An UNDEFINED parameter may or may not be specified in the config file */ -static const char* MANDATORY = (char*)~(UintPtr)0;// Default value for mandatory params. -static const char* UNDEFINED = 0; // Default value for undefined params. + +// Default value for mandatory params. +#define MANDATORY ((char*)~(UintPtr)0) +// Default value for undefined params. +#define UNDEFINED ((char*) 0) /** * @class ConfigInfo diff --git a/ndb/src/mgmsrv/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp index f937daf8620..7b4174b5eb5 100644 --- a/ndb/src/mgmsrv/InitConfigFileParser.cpp +++ b/ndb/src/mgmsrv/InitConfigFileParser.cpp @@ -690,34 +690,35 @@ load_defaults(Vector& options, const char* groups[]) BaseString extra_file; BaseString group_suffix; - const char *save_file = defaults_file; - char *save_extra_file = defaults_extra_file; - const char *save_group_suffix = defaults_group_suffix; + const char *save_file = my_defaults_file; + char *save_extra_file = my_defaults_extra_file; + const char *save_group_suffix = my_defaults_group_suffix; - if (defaults_file) + if (my_defaults_file) { - file.assfmt("--defaults-file=%s", defaults_file); + file.assfmt("--defaults-file=%s", my_defaults_file); argv[argc++] = file.c_str(); } - if (defaults_extra_file) + if (my_defaults_extra_file) { - extra_file.assfmt("--defaults-extra-file=%s", defaults_extra_file); + extra_file.assfmt("--defaults-extra-file=%s", my_defaults_extra_file); argv[argc++] = extra_file.c_str(); } - if (defaults_group_suffix) + if (my_defaults_group_suffix) { - group_suffix.assfmt("--defaults-group-suffix=%s", defaults_group_suffix); + group_suffix.assfmt("--defaults-group-suffix=%s", + my_defaults_group_suffix); argv[argc++] = group_suffix.c_str(); } char ** tmp = (char**)argv; int ret = load_defaults("my", groups, &argc, &tmp); - defaults_file = save_file; - defaults_extra_file = save_extra_file; - defaults_group_suffix = save_group_suffix; + my_defaults_file = save_file; + my_defaults_extra_file = save_extra_file; + my_defaults_group_suffix = save_group_suffix; if (ret == 0) { diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 766992af0cb..ff93936d450 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -101,6 +101,8 @@ MgmtSrvr::logLevelThread_C(void* m) extern EventLogger g_eventLogger; +#ifdef NOT_USED + static NdbOut& operator<<(NdbOut& out, const LogLevel & ll) { @@ -110,6 +112,7 @@ operator<<(NdbOut& out, const LogLevel & ll) out << "]"; return out; } +#endif void MgmtSrvr::logLevelThreadRun() @@ -1115,7 +1118,6 @@ int MgmtSrvr::sendSTOP_REQ(const Vector &node_ids, break; } case GSN_STOP_CONF:{ - const StopConf * const ref = CAST_CONSTPTR(StopConf, signal->getDataPtr()); const NodeId nodeId = refToNode(signal->header.theSendersBlockRef); #ifdef VM_TRACE ndbout_c("Node %d single user mode", nodeId); @@ -1145,8 +1147,6 @@ int MgmtSrvr::sendSTOP_REQ(const Vector &node_ids, break; } case GSN_NODE_FAILREP:{ - const NodeFailRep * const rep = - CAST_CONSTPTR(NodeFailRep, signal->getDataPtr()); break; } default: @@ -1334,7 +1334,7 @@ int MgmtSrvr::restartNodes(const Vector &node_ids, for (unsigned i = 0; i < node_ids.size(); i++) { - int result = start(node_ids[i]); + start(node_ids[i]); } return 0; } diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 17debb19f50..97840a5d89a 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -50,6 +50,7 @@ class Ndb_mgmd_event_service : public EventLoggerBase friend class MgmtSrvr; public: struct Event_listener : public EventLoggerBase { + Event_listener() {} NDB_SOCKET_TYPE m_socket; Uint32 m_parsable; }; diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index bf16aa03d04..ed1bd971479 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -646,14 +646,13 @@ MgmApiSession::getConfig_common(Parser_t::Context &, NdbMutex_Lock(m_mgmsrv.m_configMutex); const ConfigValues * cfg = &conf->m_configValues->m_config; - const Uint32 size = cfg->getPackedSize(); UtilBuffer src; cfg->pack(src); NdbMutex_Unlock(m_mgmsrv.m_configMutex); char *tmp_str = (char *) malloc(base64_needed_encoded_length(src.length())); - int res = base64_encode(src.get_data(), src.length(), tmp_str); + (void) base64_encode(src.get_data(), src.length(), tmp_str); m_output->println("get config reply"); m_output->println("result: Ok"); @@ -836,8 +835,6 @@ MgmApiSession::setClusterLogLevel(Parser::Context &, const char *reply= "set cluster loglevel reply"; Uint32 node, level, cat; BaseString errorString; - SetLogLevelOrd logLevel; - int result; DBUG_ENTER("MgmApiSession::setClusterLogLevel"); args.get("node", &node); args.get("category", &cat); @@ -884,7 +881,6 @@ MgmApiSession::setLogLevel(Parser::Context &, Uint32 node = 0, level = 0, cat; BaseString errorString; SetLogLevelOrd logLevel; - int result; logLevel.clear(); args.get("node", &node); args.get("category", &cat); @@ -1313,6 +1309,8 @@ MgmApiSession::setLogFilter(Parser_t::Context &ctx, m_output->println(""); } +#ifdef NOT_USED + static NdbOut& operator<<(NdbOut& out, const LogLevel & ll) { @@ -1322,6 +1320,7 @@ operator<<(NdbOut& out, const LogLevel & ll) out << "]"; return out; } +#endif void Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId){ diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 32b9de92d90..feda39b2123 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -195,7 +195,6 @@ static void usage() */ int main(int argc, char** argv) { - int mgm_connect_result; NDB_INIT(argv[0]); diff --git a/ndb/src/ndbapi/ClusterMgr.hpp b/ndb/src/ndbapi/ClusterMgr.hpp index d2bcc52f7e8..ab8d5ded2fc 100644 --- a/ndb/src/ndbapi/ClusterMgr.hpp +++ b/ndb/src/ndbapi/ClusterMgr.hpp @@ -180,6 +180,7 @@ private: ArbitSignalData data; NDB_TICKS timestamp; + ArbitSignal() {} inline void init(GlobalSignalNumber aGsn, const Uint32* aData) { gsn = aGsn; if (aData != NULL) diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 59a204be2a8..df8de2f818f 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -269,8 +269,6 @@ Ndb::waitUntilReady(int timeout) DBUG_ENTER("Ndb::waitUntilReady"); int secondsCounter = 0; int milliCounter = 0; - int noChecksSinceFirstAliveFound = 0; - int id; if (theInitState != Initialised) { // Ndb::init is not called diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index fdee8961337..91abcace4e9 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -389,8 +389,6 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) DBUG_ENTER("NdbBlob::setPartKeyValue"); DBUG_PRINT("info", ("dist=%u part=%u key=", getDistKey(part), part)); DBUG_DUMP("info", theKeyBuf.data, 4 * theTable->m_keyLenInWords); - Uint32* data = (Uint32*)theKeyBuf.data; - unsigned size = theTable->m_keyLenInWords; // TODO use attr ids after compatibility with 4.1.7 not needed if (anOp->equal("PK", theKeyBuf.data) == -1 || anOp->equal("DIST", getDistKey(part)) == -1 || diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index b91df24d8d7..314c072be76 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1521,11 +1521,6 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, tmpTab.MinRowsHigh = (Uint32)(impl.m_min_rows >> 32); tmpTab.MinRowsLow = (Uint32)(impl.m_min_rows & 0xFFFFFFFF); - Uint64 maxRows = - (((Uint64)tmpTab.MaxRowsHigh) << 32) + tmpTab.MaxRowsLow; - Uint64 minRows = - (((Uint64)tmpTab.MinRowsHigh) << 32) + tmpTab.MinRowsLow; - tmpTab.FragmentType = getKernelConstant(impl.m_fragmentType, fragmentTypeMapping, DictTabInfo::AllNodesSmallTable); diff --git a/ndb/src/ndbapi/NdbIndexOperation.cpp b/ndb/src/ndbapi/NdbIndexOperation.cpp index 853bab09c41..7c3af67f6e0 100644 --- a/ndb/src/ndbapi/NdbIndexOperation.cpp +++ b/ndb/src/ndbapi/NdbIndexOperation.cpp @@ -245,8 +245,6 @@ NdbIndexOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransactionId) // Simple state is set if start and commit is set and it is // a read request. Otherwise it is set to zero. //------------------------------------------------------------- - Uint8 tReadInd = (theOperationType == ReadRequest); - Uint8 tSimpleState = tReadInd & tSimpleAlt; //theNdbCon->theSimpleState = tSimpleState; tcKeyReq->transId1 = tTransId1; diff --git a/ndb/src/ndbapi/NdbOperationDefine.cpp b/ndb/src/ndbapi/NdbOperationDefine.cpp index 42dec161307..800fa29fb42 100644 --- a/ndb/src/ndbapi/NdbOperationDefine.cpp +++ b/ndb/src/ndbapi/NdbOperationDefine.cpp @@ -534,8 +534,7 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo, }//if const Uint32 totalSizeInWords = (sizeInBytes + 3)/4; // Including bits in last word const Uint32 sizeInWords = sizeInBytes / 4; // Excluding bits in last word - AttributeHeader& ah = AttributeHeader::init(&ahValue, tAttrId, - totalSizeInWords); + (void) AttributeHeader::init(&ahValue, tAttrId, totalSizeInWords); insertATTRINFO( ahValue ); /*********************************************************************** diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index 11713678478..b3281989bdc 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -177,8 +177,6 @@ NdbOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransId) // Simple state is set if start and commit is set and it is // a read request. Otherwise it is set to zero. //------------------------------------------------------------- - Uint8 tReadInd = (theOperationType == ReadRequest); - Uint8 tSimpleState = tReadInd & tSimpleIndicator; tcKeyReq->transId1 = tTransId1; tcKeyReq->transId2 = tTransId2; diff --git a/ndb/src/ndbapi/NdbOperationSearch.cpp b/ndb/src/ndbapi/NdbOperationSearch.cpp index ede3240e9f4..a2e966dab2d 100644 --- a/ndb/src/ndbapi/NdbOperationSearch.cpp +++ b/ndb/src/ndbapi/NdbOperationSearch.cpp @@ -67,7 +67,6 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo, register Uint32 tAttrId; - Uint32 tData; Uint32 tKeyInfoPosition; const char* aValue = aValuePassed; Uint64 tempData[512]; @@ -347,7 +346,6 @@ NdbOperation::insertKEYINFO(const char* aValue, Uint32 tEndPos; Uint32 tPos; Uint32 signalCounter; - Uint32 tData; /***************************************************************************** * Calculate the end position of the attribute in the key information. * @@ -514,7 +512,6 @@ NdbOperation::handle_distribution_key(const Uint64* value, Uint32 len) * Copy distribution key to linear memory */ NdbColumnImpl* const * cols = m_accessTable->m_columns.getBase(); - Uint32 len = 0; Uint64 tmp[1000]; Uint32 chunk = 8; diff --git a/ndb/src/ndbapi/NdbScanFilter.cpp b/ndb/src/ndbapi/NdbScanFilter.cpp index b39fd10fe95..421c01ed3e3 100644 --- a/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/ndb/src/ndbapi/NdbScanFilter.cpp @@ -32,6 +32,7 @@ class NdbScanFilterImpl { public: + NdbScanFilterImpl() {} struct State { NdbScanFilter::Group m_group; Uint32 m_popCount; diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 92a1e476b45..de7978be074 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -830,7 +830,6 @@ NdbScanOperation::doSendScan(int aProcessorId) tSignal = theSCAN_TABREQ; Uint32 tupKeyLen = theTupKeyLen; - Uint32 len = theTotalNrOfKeyWordInSignal; Uint32 aTC_ConnectPtr = theNdbCon->theTCConPtr; Uint64 transId = theNdbCon->theTransactionId; @@ -1300,8 +1299,6 @@ NdbIndexScanOperation::fix_get_values(){ Uint32 cnt = m_accessTable->getNoOfColumns() - 1; assert(cnt < NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY); - const NdbIndexImpl * idx = m_accessTable->m_index; - const NdbTableImpl * tab = m_currentTable; for(Uint32 i = 0; i & m_jobBuffer){ if(m_jobBuffer.size() > 0){ SimpleSignal * s = m_jobBuffer[0]; @@ -192,6 +193,7 @@ SignalSender::waitFor(Uint32 timeOutMillis){ class WaitForNode { public: + WaitForNode() {} Uint32 m_nodeId; SimpleSignal * check(Vector & m_jobBuffer){ Uint32 len = m_jobBuffer.size(); diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 3ae84125112..c3e6b3f850a 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -516,7 +516,6 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, struct ndb_mgm_reply mgm_reply; DBUG_ENTER("Ndb_cluster_connection::connect"); - const char* error = 0; do { if (m_impl.m_config_retriever == 0) DBUG_RETURN(-1); diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index a3d9ff4ccee..893c2ce33cc 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -44,9 +44,11 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname\n"\ "This program will delete all records in the specified table using scan delete.\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp index 934394e4d31..0f6856cd046 100644 --- a/ndb/tools/desc.cpp +++ b/ndb/tools/desc.cpp @@ -43,10 +43,12 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\ " ex: desc T1 T2 T4\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp index c10211a9108..18b6e5b55c1 100644 --- a/ndb/tools/drop_index.cpp +++ b/ndb/tools/drop_index.cpp @@ -37,9 +37,11 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "[]+\n"\ "This program will drop index(es) in Ndb\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 61df4ee9b34..38b043ddd9a 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -37,9 +37,11 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname\n"\ "This program will drop one table in Ndb\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index 8cc4e65586a..c097aeb1d6c 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -190,6 +190,7 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname\n"\ "This program list all system objects in NDB Cluster.\n"\ @@ -197,6 +198,7 @@ static void usage() " ex: ndb_show_tables -t 2 would show all UserTables\n"\ "To show all indexes for a table write table name as final argument\n"\ " ex: ndb_show_tables T1\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/ndb_config.cpp b/ndb/tools/ndb_config.cpp index 049e4599447..fe8b2f7a547 100644 --- a/ndb/tools/ndb_config.cpp +++ b/ndb/tools/ndb_config.cpp @@ -99,6 +99,7 @@ static void usage() { char desc[] = "This program will retreive config options for a ndb cluster\n"; + puts(desc); ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); @@ -113,12 +114,14 @@ struct Match { int m_key; BaseString m_value; + Match() {} virtual int eval(const Iter&); virtual ~Match() {} }; struct HostMatch : public Match { + HostMatch() {} virtual int eval(const Iter&); }; @@ -133,11 +136,13 @@ struct Apply struct NodeTypeApply : public Apply { + NodeTypeApply() {} virtual int apply(const Iter&); }; struct ConnectionTypeApply : public Apply { + ConnectionTypeApply() {} virtual int apply(const Iter&); }; @@ -296,10 +301,10 @@ parse_where(Vector& where, int &argc, char**& argv) Match m; if(g_host) { - HostMatch *m = new HostMatch; - m->m_key = CFG_NODE_HOST; - m->m_value.assfmt("%s", g_host); - where.push_back(m); + HostMatch *tmp = new HostMatch; + tmp->m_key = CFG_NODE_HOST; + tmp->m_value.assfmt("%s", g_host); + where.push_back(tmp); } if(g_type) diff --git a/ndb/tools/restore/Restore.hpp b/ndb/tools/restore/Restore.hpp index cf8feb7125c..aaf18e3aac6 100644 --- a/ndb/tools/restore/Restore.hpp +++ b/ndb/tools/restore/Restore.hpp @@ -26,7 +26,7 @@ #include #include -static const char * delimiter = ";"; // Delimiter in file dump +#define delimiter ";" const int FileNameLenC = 256; const int TableNameLenC = 256; @@ -359,6 +359,7 @@ public: m_values_e.push_back(m_values[i]); m_values.clear(); } + LogEntry() {} ~LogEntry() { Uint32 i; diff --git a/ndb/tools/restore/consumer.hpp b/ndb/tools/restore/consumer.hpp index 6a8ef29e295..330ed0520d1 100644 --- a/ndb/tools/restore/consumer.hpp +++ b/ndb/tools/restore/consumer.hpp @@ -21,6 +21,7 @@ class BackupConsumer { public: + BackupConsumer() {} virtual ~BackupConsumer() { } virtual bool init() { return true;} virtual bool table(const TableS &){return true;} diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp index eb0a8b8d139..55aedc13b04 100644 --- a/ndb/tools/restore/restore_main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -357,8 +357,8 @@ main(int argc, char** argv) while ((tuple = dataIter.getNextTuple(res= 1)) != 0) { if (checkSysTable(tuple->getTable()->getTableName())) - for(Uint32 i= 0; i < g_consumers.size(); i++) - g_consumers[i]->tuple(* tuple); + for(Uint32 j= 0; j < g_consumers.size(); j++) + g_consumers[j]->tuple(* tuple); } // while (tuple != NULL); if (res < 0) @@ -401,8 +401,8 @@ main(int argc, char** argv) while ((logEntry = logIter.getNextLogEntry(res= 0)) != 0) { if (checkSysTable(logEntry->m_table->getTableName())) - for(Uint32 i= 0; i < g_consumers.size(); i++) - g_consumers[i]->logEntry(* logEntry); + for(Uint32 j= 0; j < g_consumers.size(); j++) + g_consumers[j]->logEntry(* logEntry); } if (res < 0) { @@ -433,9 +433,9 @@ main(int argc, char** argv) } } } - for(Uint32 i= 0; i < g_consumers.size(); i++) + for(Uint32 j= 0; j < g_consumers.size(); j++) { - if (g_consumers[i]->has_temp_error()) + if (g_consumers[j]->has_temp_error()) { clearConsumers(); ndbout_c("\nRestore successful, but encountered temporary error, " diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp index 7bb3557d1ba..426ecc45a52 100644 --- a/ndb/tools/select_all.cpp +++ b/ndb/tools/select_all.cpp @@ -40,7 +40,7 @@ NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; static const char* _delimiter = "\t"; -static int _unqualified, _header, _parallelism, _useHexFormat, _lock, +static int _header, _parallelism, _useHexFormat, _lock, _order, _descending; const char *load_default_groups[]= { "mysql_cluster",0 }; @@ -76,6 +76,7 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname\n"\ "This program reads all records from one table in NDB Cluster\n"\ @@ -83,6 +84,7 @@ static void usage() "(It only print error messages if it encounters a permanent error.)\n"\ "It can also be used to dump the content of a table to file \n"\ " ex: select_all --no-header --delimiter=';' T4 > T4.data\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index 0d5d4684878..49438be728e 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -56,9 +56,11 @@ static struct my_option my_long_options[] = }; static void usage() { +#ifdef NOT_USED char desc[] = "tabname1 ... tabnameN\n"\ "This program will count the number of records in tables\n"; +#endif ndb_std_print_version(); print_defaults(MYSQL_CONFIG_NAME,load_default_groups); puts(""); diff --git a/server-tools/instance-manager/commands.h b/server-tools/instance-manager/commands.h index bfd38d34889..c7b3445d1f8 100644 --- a/server-tools/instance-manager/commands.h +++ b/server-tools/instance-manager/commands.h @@ -163,6 +163,7 @@ public: class Syntax_error : public Command { public: + Syntax_error() {} int execute(struct st_net *net, ulong connection_id); }; diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index 0a037b5b98a..0bcd40797a6 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -78,7 +78,7 @@ void Guardian_thread::request_shutdown() void Guardian_thread::process_instance(Instance *instance, GUARD_NODE *current_node, - LIST **guarded_instances, + LIST **guarded_instances_arg, LIST *node) { uint waitchild= (uint) Instance::DEFAULT_SHUTDOWN_DELAY; @@ -94,7 +94,7 @@ void Guardian_thread::process_instance(Instance *instance, /* this returns true if and only if an instance was stopped for sure */ if (instance->is_crashed()) - *guarded_instances= list_delete(*guarded_instances, node); + *guarded_instances_arg= list_delete(*guarded_instances_arg, node); else if ( (uint) (current_time - current_node->last_checked) > waitchild) { instance->kill_instance(SIGKILL); @@ -102,7 +102,7 @@ void Guardian_thread::process_instance(Instance *instance, Later we do node= node->next. This is ok, as we are only removing the node from the list. The pointer to the next one is still valid. */ - *guarded_instances= list_delete(*guarded_instances, node); + *guarded_instances_arg= list_delete(*guarded_instances_arg, node); } return; diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index f86f359959b..1e47119369f 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -222,8 +222,6 @@ err: int Instance_options::fill_log_options() { Buffer buff; - uint position= 0; - char **tmp_argv= argv; enum { MAX_LOG_OPTION_LENGTH= 256 }; char datadir[MAX_LOG_OPTION_LENGTH]; char hostname[MAX_LOG_OPTION_LENGTH]; diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc index a19914dfdd2..e52f70cf449 100644 --- a/server-tools/instance-manager/mysql_connection.cc +++ b/server-tools/instance-manager/mysql_connection.cc @@ -333,12 +333,12 @@ int Mysql_connection_thread::dispatch_command(enum enum_server_command command, { log_info("query for connection %lu : ----\n%s\n-------------------------", connection_id,packet); - if (Command *command= parse_command(&instance_map, packet)) + if (Command *com= parse_command(&instance_map, packet)) { int res= 0; log_info("query for connection %lu successefully parsed",connection_id); - res= command->execute(&net, connection_id); - delete command; + res= com->execute(&net, connection_id); + delete com; if (!res) log_info("query for connection %lu executed ok",connection_id); else diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index c6c709295bc..ec71b6495b8 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -313,27 +313,27 @@ int Options::load(int argc, char **argv) '.angel.pid'. */ - char *angel_pid_file_name; + char *local_angel_pid_file_name; char *base_name_ptr; char *ext_ptr; - angel_pid_file_name= (char *) malloc(strlen(Options::pid_file_name) + - ANGEL_PID_FILE_SUFFIX_LEN); + local_angel_pid_file_name= (char *) malloc(strlen(Options::pid_file_name) + + ANGEL_PID_FILE_SUFFIX_LEN); - strcpy(angel_pid_file_name, Options::pid_file_name); + strcpy(local_angel_pid_file_name, Options::pid_file_name); - base_name_ptr= strrchr(angel_pid_file_name, '/'); + base_name_ptr= strrchr(local_angel_pid_file_name, '/'); if (!base_name_ptr) - base_name_ptr= angel_pid_file_name + 1; + base_name_ptr= local_angel_pid_file_name + 1; ext_ptr= strrchr(base_name_ptr, '.'); if (ext_ptr) *ext_ptr= 0; - strcat(angel_pid_file_name, ANGEL_PID_FILE_SUFFIX); + strcat(local_angel_pid_file_name, ANGEL_PID_FILE_SUFFIX); - Options::angel_pid_file_name= angel_pid_file_name; + Options::angel_pid_file_name= local_angel_pid_file_name; } else { diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h index f32e106bd7a..9eb856de917 100644 --- a/server-tools/instance-manager/options.h +++ b/server-tools/instance-manager/options.h @@ -53,6 +53,7 @@ struct Options static char **saved_argv; int load(int argc, char **argv); + Options() {} void cleanup(); #ifdef __WIN__ int setup_windows_defaults(); diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc index 14b3db16b45..fa6b3beaae9 100644 --- a/server-tools/instance-manager/parse.cc +++ b/server-tools/instance-manager/parse.cc @@ -125,7 +125,6 @@ Command *parse_command(Instance_map *map, const char *text) uint option_value_len; const char *log_size; Command *command; - const char *saved_text= text; bool skip= false; const char *tmp; diff --git a/server-tools/instance-manager/user_map.cc b/server-tools/instance-manager/user_map.cc index 9cb15307131..c33224d4c6b 100644 --- a/server-tools/instance-manager/user_map.cc +++ b/server-tools/instance-manager/user_map.cc @@ -30,6 +30,7 @@ struct User char user[USERNAME_LENGTH + 1]; uint8 user_length; uint8 salt[SCRAMBLE_LENGTH]; + User() {} int init(const char *line); }; diff --git a/server-tools/instance-manager/user_map.h b/server-tools/instance-manager/user_map.h index 4134017dd9b..ae3896dce44 100644 --- a/server-tools/instance-manager/user_map.h +++ b/server-tools/instance-manager/user_map.h @@ -33,6 +33,7 @@ class User_map { public: + User_map() {} ~User_map(); int init(); diff --git a/sql-common/client.c b/sql-common/client.c index c8984e29a34..ef7d0132ffb 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2365,12 +2365,12 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { DYNAMIC_ARRAY *init_commands= mysql->options.init_commands; char **ptr= (char**)init_commands->buffer; - char **end= ptr + init_commands->elements; + char **end_command= ptr + init_commands->elements; my_bool reconnect=mysql->reconnect; mysql->reconnect=0; - for (; ptrminute >= 60 || time->second >= 60) + if (my_time->minute >= 60 || my_time->second >= 60) return 1; - hour= time->hour + (24*time->day); + hour= my_time->hour + (24*my_time->day); if (hour <= TIME_MAX_HOUR && - (hour != TIME_MAX_HOUR || time->minute != TIME_MAX_MINUTE || - time->second != TIME_MAX_SECOND || !time->second_part)) + (hour != TIME_MAX_HOUR || my_time->minute != TIME_MAX_MINUTE || + my_time->second != TIME_MAX_SECOND || !my_time->second_part)) return 0; - time->day= 0; - time->hour= TIME_MAX_HOUR; - time->minute= TIME_MAX_MINUTE; - time->second= TIME_MAX_SECOND; - time->second_part= 0; + my_time->day= 0; + my_time->hour= TIME_MAX_HOUR; + my_time->minute= TIME_MAX_MINUTE; + my_time->second= TIME_MAX_SECOND; + my_time->second_part= 0; *warning|= MYSQL_TIME_WARN_OUT_OF_RANGE; return 0; } @@ -1147,22 +1147,23 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, /* Convert time value to integer in YYYYMMDDHHMMSS format */ -ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *time) +ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time) { - return ((ulonglong) (time->year * 10000UL + - time->month * 100UL + - time->day) * ULL(1000000) + - (ulonglong) (time->hour * 10000UL + - time->minute * 100UL + - time->second)); + return ((ulonglong) (my_time->year * 10000UL + + my_time->month * 100UL + + my_time->day) * ULL(1000000) + + (ulonglong) (my_time->hour * 10000UL + + my_time->minute * 100UL + + my_time->second)); } /* Convert TIME value to integer in YYYYMMDD format */ -ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *time) +ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) { - return (ulonglong) (time->year * 10000UL + time->month * 100UL + time->day); + return (ulonglong) (my_time->year * 10000UL + my_time->month * 100UL + + my_time->day); } @@ -1172,11 +1173,11 @@ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *time) it's assumed that days have been converted to hours already. */ -ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *time) +ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time) { - return (ulonglong) (time->hour * 10000UL + - time->minute * 100UL + - time->second); + return (ulonglong) (my_time->hour * 10000UL + + my_time->minute * 100UL + + my_time->second); } @@ -1200,15 +1201,15 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *time) valid date either. */ -ulonglong TIME_to_ulonglong(const MYSQL_TIME *time) +ulonglong TIME_to_ulonglong(const MYSQL_TIME *my_time) { - switch (time->time_type) { + switch (my_time->time_type) { case MYSQL_TIMESTAMP_DATETIME: - return TIME_to_ulonglong_datetime(time); + return TIME_to_ulonglong_datetime(my_time); case MYSQL_TIMESTAMP_DATE: - return TIME_to_ulonglong_date(time); + return TIME_to_ulonglong_date(my_time); case MYSQL_TIMESTAMP_TIME: - return TIME_to_ulonglong_time(time); + return TIME_to_ulonglong_time(my_time); case MYSQL_TIMESTAMP_NONE: case MYSQL_TIMESTAMP_ERROR: return ULL(0); diff --git a/sql/field.cc b/sql/field.cc index e0b97e80ed4..b59684afdf0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1392,12 +1392,12 @@ my_decimal* Field_num::val_decimal(my_decimal *decimal_value) Field_str::Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, - struct st_table *table_arg,CHARSET_INFO *charset) + struct st_table *table_arg, CHARSET_INFO *charset_arg) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, table_arg) { - field_charset=charset; - if (charset->state & MY_CS_BINSORT) + field_charset= charset_arg; + if (charset_arg->state & MY_CS_BINSORT) flags|=BINARY_FLAG; field_derivation= DERIVATION_IMPLICIT; } @@ -1502,7 +1502,7 @@ bool Field::get_time(TIME *ltime) Needs to be changed if/when we want to support different time formats */ -int Field::store_time(TIME *ltime, timestamp_type type) +int Field::store_time(TIME *ltime, timestamp_type type_arg) { char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= (uint) my_TIME_to_str(ltime, buff); @@ -2197,13 +2197,13 @@ Field_new_decimal::Field_new_decimal(char *ptr_arg, Field_new_decimal::Field_new_decimal(uint32 len_arg, - bool maybe_null, + bool maybe_null_arg, const char *name, struct st_table *t_arg, uint8 dec_arg, bool unsigned_arg) :Field_num((char*) 0, len_arg, - maybe_null ? (uchar*) "": 0, 0, + maybe_null_arg ? (uchar*) "": 0, 0, NONE, name, t_arg, dec_arg, 0, unsigned_arg) @@ -2306,7 +2306,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value) int Field_new_decimal::store(const char *from, uint length, - CHARSET_INFO *charset) + CHARSET_INFO *charset_arg) { int err; my_decimal decimal_value; @@ -2314,7 +2314,7 @@ int Field_new_decimal::store(const char *from, uint length, if ((err= str2my_decimal(E_DEC_FATAL_ERROR & ~(E_DEC_OVERFLOW | E_DEC_BAD_NUM), - from, length, charset, &decimal_value)) && + from, length, charset_arg, &decimal_value)) && table->in_use->abort_on_warning) { /* Because "from" is not NUL-terminated and we use %s in the ER() */ @@ -3198,25 +3198,6 @@ void Field_medium::sql_type(String &res) const ** long int ****************************************************************************/ -/* - A helper function to check whether the next character - in the string "s" is MINUS SIGN. -*/ -#ifdef HAVE_CHARSET_ucs2 -static bool test_if_minus(CHARSET_INFO *cs, - const char *s, const char *e) -{ - my_wc_t wc; - return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-'; -} -#else -/* - If not UCS2 support is compiled then it is easier -*/ -#define test_if_minus(cs, s, e) (*s == '-') -#endif - - int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { long store_tmp; @@ -4807,7 +4788,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) } -int Field_time::store_time(TIME *ltime, timestamp_type type) +int Field_time::store_time(TIME *ltime, timestamp_type time_type) { long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L + (ltime->minute * 100 + ltime->second); @@ -5402,11 +5383,12 @@ int Field_newdate::store(longlong nr, bool unsigned_val) } -int Field_newdate::store_time(TIME *ltime,timestamp_type type) +int Field_newdate::store_time(TIME *ltime, timestamp_type time_type) { long tmp; int error= 0; - if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) + if (time_type == MYSQL_TIMESTAMP_DATE || + time_type == MYSQL_TIMESTAMP_DATETIME) { tmp=ltime->year*16*32+ltime->month*32+ltime->day; if (check_date(ltime, tmp != 0, @@ -5621,7 +5603,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val) } -int Field_datetime::store_time(TIME *ltime,timestamp_type type) +int Field_datetime::store_time(TIME *ltime,timestamp_type time_type) { longlong tmp; int error= 0; @@ -5629,7 +5611,8 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type) We don't perform range checking here since values stored in TIME structure always fit into DATETIME range. */ - if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) + if (time_type == MYSQL_TIMESTAMP_DATE || + time_type == MYSQL_TIMESTAMP_DATETIME) { tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+ (ltime->hour*10000L+ltime->minute*100+ltime->second)); @@ -6004,32 +5987,32 @@ int Field_str::store(double nr) char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; uint length; bool use_scientific_notation= TRUE; - uint char_length= field_length / charset()->mbmaxlen; + uint local_char_length= field_length / charset()->mbmaxlen; /* Check fabs(nr) against longest value that can be stored in field, which depends on whether the value is < 1 or not, and negative or not */ double anr= fabs(nr); int neg= (nr < 0.0) ? 1 : 0; - if (char_length > 4 && char_length < 32 && - (anr < 1.0 ? anr > 1/(log_10[max(0,(int) char_length-neg-2)]) /* -2 for "0." */ - : anr < log_10[char_length-neg]-1)) + if (local_char_length > 4 && local_char_length < 32 && + (anr < 1.0 ? anr > 1/(log_10[max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */ + : anr < log_10[local_char_length-neg]-1)) use_scientific_notation= FALSE; length= (uint) my_sprintf(buff, (buff, "%-.*g", (use_scientific_notation ? - max(0, (int)char_length-neg-5) : - char_length), + max(0, (int)local_char_length-neg-5) : + local_char_length), nr)); /* +1 below is because "precision" in %g above means the max. number of significant digits, not the output width. Thus the width can be larger than number of significant digits by 1 (for decimal point) - the test for char_length < 5 is for extreme cases, + the test for local_char_length < 5 is for extreme cases, like inserting 500.0 in char(1) */ - DBUG_ASSERT(char_length < 5 || length <= char_length+1); + DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1); return store((const char *) buff, length, charset()); } @@ -6146,10 +6129,11 @@ void Field_string::sql_type(String &res) const char *Field_string::pack(char *to, const char *from, uint max_length) { uint length= min(field_length,max_length); - uint char_length= max_length/field_charset->mbmaxlen; - if (length > char_length) - char_length= my_charpos(field_charset, from, from+length, char_length); - set_if_smaller(length, char_length); + uint local_char_length= max_length/field_charset->mbmaxlen; + if (length > local_char_length) + local_char_length= my_charpos(field_charset, from, from+length, + local_char_length); + set_if_smaller(length, local_char_length); while (length && from[length-1] == ' ') length--; *to++= (char) (uchar) length; @@ -6233,15 +6217,15 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length, int Field_string::pack_cmp(const char *key, uint length, my_bool insert_or_update) { - uint row_length, key_length; + uint row_length, local_key_length; char *end; if (length > 255) { - key_length= uint2korr(key); + local_key_length= uint2korr(key); key+= 2; } else - key_length= (uint) (uchar) *key++; + local_key_length= (uint) (uchar) *key++; /* Only use 'length' of key, not field_length */ end= ptr + length; @@ -6251,7 +6235,7 @@ int Field_string::pack_cmp(const char *key, uint length, return field_charset->coll->strnncollsp(field_charset, (const uchar*) ptr, row_length, - (const uchar*) key, key_length, + (const uchar*) key, local_key_length, insert_or_update); } @@ -6273,10 +6257,10 @@ uint Field_string::max_packed_col_length(uint max_length) Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type) { - Field *new_field; + Field *field; if (type() != MYSQL_TYPE_VAR_STRING || keep_type) - new_field= Field::new_field(root, new_table, keep_type); + field= Field::new_field(root, new_table, keep_type); else { @@ -6285,7 +6269,7 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table, This is done to ensure that ALTER TABLE will convert old VARCHAR fields to now VARCHAR fields. */ - new_field= new Field_varstring(field_length, maybe_null(), + field= new Field_varstring(field_length, maybe_null(), field_name, new_table, charset()); /* Normally orig_table is different from table only if field was created @@ -6293,9 +6277,9 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table, not applicable. But we still need to preserve the original field metadata for the client-server protocol. */ - new_field->orig_table= orig_table; + field->orig_table= orig_table; } - return new_field; + return field; } /**************************************************************************** @@ -6436,11 +6420,11 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr) int Field_varstring::key_cmp(const byte *key_ptr, uint max_key_length) { uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); - uint char_length= max_key_length / field_charset->mbmaxlen; + uint local_char_length= max_key_length / field_charset->mbmaxlen; - char_length= my_charpos(field_charset, ptr + length_bytes, - ptr + length_bytes + length, char_length); - set_if_smaller(length, char_length); + local_char_length= my_charpos(field_charset, ptr + length_bytes, + ptr + length_bytes + length, local_char_length); + set_if_smaller(length, local_char_length); return field_charset->coll->strnncollsp(field_charset, (const uchar*) ptr + length_bytes, length, @@ -6550,13 +6534,14 @@ char *Field_varstring::pack(char *to, const char *from, uint max_length) char *Field_varstring::pack_key(char *to, const char *key, uint max_length) { uint length= length_bytes == 1 ? (uint) (uchar) *key : uint2korr(key); - uint char_length= ((field_charset->mbmaxlen > 1) ? + uint local_char_length= ((field_charset->mbmaxlen > 1) ? max_length/field_charset->mbmaxlen : max_length); key+= length_bytes; - if (length > char_length) + if (length > local_char_length) { - char_length= my_charpos(field_charset, key, key+length, char_length); - set_if_smaller(length, char_length); + local_char_length= my_charpos(field_charset, key, key+length, + local_char_length); + set_if_smaller(length, local_char_length); } *to++= (char) (length & 255); if (max_length > 255) @@ -6652,11 +6637,12 @@ const char *Field_varstring::unpack(char *to, const char *from) } -int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length, +int Field_varstring::pack_cmp(const char *a, const char *b, + uint key_length_arg, my_bool insert_or_update) { uint a_length, b_length; - if (key_length > 255) + if (key_length_arg > 255) { a_length=uint2korr(a); a+= 2; b_length=uint2korr(b); b+= 2; @@ -6673,26 +6659,28 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length, } -int Field_varstring::pack_cmp(const char *b, uint key_length, +int Field_varstring::pack_cmp(const char *b, uint key_length_arg, my_bool insert_or_update) { char *a= ptr+ length_bytes; uint a_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); uint b_length; - uint char_length= ((field_charset->mbmaxlen > 1) ? - key_length / field_charset->mbmaxlen : key_length); + uint local_char_length= ((field_charset->mbmaxlen > 1) ? + key_length_arg / field_charset->mbmaxlen : + key_length_arg); - if (key_length > 255) + if (key_length_arg > 255) { b_length=uint2korr(b); b+= HA_KEY_BLOB_LENGTH; } else b_length= (uint) (uchar) *b++; - if (a_length > char_length) + if (a_length > local_char_length) { - char_length= my_charpos(field_charset, a, a+a_length, char_length); - set_if_smaller(a_length, char_length); + local_char_length= my_charpos(field_charset, a, a+a_length, + local_char_length); + set_if_smaller(a_length, local_char_length); } return field_charset->coll->strnncollsp(field_charset, @@ -6717,13 +6705,15 @@ uint Field_varstring::max_packed_col_length(uint max_length) } -void Field_varstring::get_key_image(char *buff, uint length, imagetype type) +void Field_varstring::get_key_image(char *buff, uint length, + imagetype type_arg) { uint f_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); - uint char_length= length / field_charset->mbmaxlen; + uint local_char_length= length / field_charset->mbmaxlen; char *pos= ptr+length_bytes; - char_length= my_charpos(field_charset, pos, pos + f_length, char_length); - set_if_smaller(f_length, char_length); + local_char_length= my_charpos(field_charset, pos, pos + f_length, + local_char_length); + set_if_smaller(f_length, local_char_length); /* Key is always stored with 2 bytes */ int2store(buff,f_length); memcpy(buff+HA_KEY_BLOB_LENGTH, pos, f_length); @@ -7106,13 +7096,13 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr, /* The following is used only when comparing a key */ -void Field_blob::get_key_image(char *buff, uint length, imagetype type) +void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg) { uint32 blob_length= get_length(ptr); char *blob; #ifdef HAVE_SPATIAL - if (type == itMBR) + if (type_arg == itMBR) { const char *dummy; MBR mbr; @@ -7140,10 +7130,10 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type) #endif /*HAVE_SPATIAL*/ get_ptr(&blob); - uint char_length= length / field_charset->mbmaxlen; - char_length= my_charpos(field_charset, blob, blob + blob_length, - char_length); - set_if_smaller(blob_length, char_length); + uint local_char_length= length / field_charset->mbmaxlen; + local_char_length= my_charpos(field_charset, blob, blob + blob_length, + local_char_length); + set_if_smaller(blob_length, local_char_length); if ((uint32) length > blob_length) { @@ -7172,9 +7162,10 @@ int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) uint blob_length=get_length(ptr); memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); CHARSET_INFO *cs= charset(); - uint char_length= max_key_length / cs->mbmaxlen; - char_length= my_charpos(cs, blob1, blob1+blob_length, char_length); - set_if_smaller(blob_length, char_length); + uint local_char_length= max_key_length / cs->mbmaxlen; + local_char_length= my_charpos(cs, blob1, blob1+blob_length, + local_char_length); + set_if_smaller(blob_length, local_char_length); return Field_blob::cmp(blob1, blob_length, (char*) key_ptr+HA_KEY_BLOB_LENGTH, uint2korr(key_ptr)); @@ -7296,11 +7287,11 @@ const char *Field_blob::unpack(char *to, const char *from) /* Keys for blobs are like keys on varchars */ -int Field_blob::pack_cmp(const char *a, const char *b, uint key_length, +int Field_blob::pack_cmp(const char *a, const char *b, uint key_length_arg, my_bool insert_or_update) { uint a_length, b_length; - if (key_length > 255) + if (key_length_arg > 255) { a_length=uint2korr(a); a+=2; b_length=uint2korr(b); b+=2; @@ -7317,19 +7308,19 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length, } -int Field_blob::pack_cmp(const char *b, uint key_length, +int Field_blob::pack_cmp(const char *b, uint key_length_arg, my_bool insert_or_update) { char *a; + uint a_length, b_length; memcpy_fixed(&a,ptr+packlength,sizeof(char*)); if (!a) - return key_length > 0 ? -1 : 0; - uint a_length=get_length(ptr); - uint b_length; + return key_length_arg > 0 ? -1 : 0; - if (key_length > 255) + a_length= get_length(ptr); + if (key_length_arg > 255) { - b_length=uint2korr(b); b+=2; + b_length= uint2korr(b); b+=2; } else b_length= (uint) (uchar) *b++; @@ -7346,13 +7337,14 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length) char *save=ptr; ptr=(char*) from; uint32 length=get_length(); // Length of from string - uint char_length= ((field_charset->mbmaxlen > 1) ? + uint local_char_length= ((field_charset->mbmaxlen > 1) ? max_length/field_charset->mbmaxlen : max_length); if (length) get_ptr((char**) &from); - if (length > char_length) - char_length= my_charpos(field_charset, from, from+length, char_length); - set_if_smaller(length, char_length); + if (length > local_char_length) + local_char_length= my_charpos(field_charset, from, from+length, + local_char_length); + set_if_smaller(length, local_char_length); *to++= (uchar) length; if (max_length > 255) // 2 byte length *to++= (uchar) (length >> 8); @@ -7439,7 +7431,7 @@ uint Field_blob::max_packed_col_length(uint max_length) #ifdef HAVE_SPATIAL -void Field_geom::get_key_image(char *buff, uint length, imagetype type) +void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg) { char *blob; const char *dummy; @@ -7537,7 +7529,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) goto err; wkb_type= uint4korr(from + SRID_SIZE + 1); if (wkb_type < (uint32) Geometry::wkb_point || - wkb_type > (uint32) Geometry::wkb_end) + wkb_type > (uint32) Geometry::wkb_last) goto err; Field_blob::store_length(length); if (table->copy_blobs || length <= MAX_FIELD_WIDTH) @@ -8161,7 +8153,7 @@ int Field_bit::cmp_offset(uint row_offset) } -void Field_bit::get_key_image(char *buff, uint length, imagetype type) +void Field_bit::get_key_image(char *buff, uint length, imagetype type_arg) { if (bit_len) { @@ -8323,7 +8315,7 @@ void create_field::create_length_to_internal_length(void) void create_field::init_for_tmp_table(enum_field_types sql_type_arg, - uint32 length_arg, uint32 decimals, + uint32 length_arg, uint32 decimals_arg, bool maybe_null, bool is_unsigned) { field_name= ""; @@ -8334,7 +8326,7 @@ void create_field::init_for_tmp_table(enum_field_types sql_type_arg, charset= &my_charset_bin; geom_type= Field::GEOM_GEOMETRY; pack_flag= (FIELDFLAG_NUMBER | - ((decimals & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) | + ((decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) | (maybe_null ? FIELDFLAG_MAYBE_NULL : 0) | (is_unsigned ? 0 : FIELDFLAG_DECIMAL)); } @@ -9039,12 +9031,13 @@ create_field::create_field(Field *old_field,Field *orig_field) maximum possible display length for blob SYNOPSIS - Field_blob::max_length() + Field_blob::max_display_length() RETURN length */ -uint32 Field_blob::max_length() + +uint32 Field_blob::max_display_length() { switch (packlength) { diff --git a/sql/field.h b/sql/field.h index 709630218b2..da23e7a55b5 100644 --- a/sql/field.h +++ b/sql/field.h @@ -154,12 +154,12 @@ public: virtual void reset_fields() {} virtual void set_default() { - my_ptrdiff_t offset = (my_ptrdiff_t) (table->s->default_values - + my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->s->default_values - table->record[0]); - memcpy(ptr, ptr + offset, pack_length()); + memcpy(ptr, ptr + l_offset, pack_length()); if (null_ptr) *null_ptr= ((*null_ptr & (uchar) ~null_bit) | - null_ptr[offset] & null_bit); + null_ptr[l_offset] & null_bit); } virtual bool binary() const { return 1; } virtual bool zero_pack() const { return 1; } @@ -236,7 +236,7 @@ public: { memcpy(buff,ptr,length); } inline void set_image(char *buff,uint length, CHARSET_INFO *cs) { memcpy(ptr,buff,length); } - virtual void get_key_image(char *buff, uint length, imagetype type) + virtual void get_key_image(char *buff, uint length, imagetype type_arg) { get_image(buff,length, &my_charset_bin); } virtual void set_key_image(char *buff,uint length) { set_image(buff,length, &my_charset_bin); } @@ -301,10 +301,10 @@ public: virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; } virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } - virtual void set_charset(CHARSET_INFO *charset) { } + virtual void set_charset(CHARSET_INFO *charset_arg) { } virtual enum Derivation derivation(void) const { return DERIVATION_IMPLICIT; } - virtual void set_derivation(enum Derivation derivation) { } + virtual void set_derivation(enum Derivation derivation_arg) { } bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code, int cuted_increment); bool check_int(const char *str, int length, const char *int_end, @@ -323,7 +323,7 @@ public: } int warn_if_overflow(int op_result); /* maximum possible display length */ - virtual uint32 max_length()= 0; + virtual uint32 max_display_length()= 0; /* convert decimal to longlong with overflow check */ longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag, int *err); @@ -390,12 +390,12 @@ public: int store(const char *to,uint length,CHARSET_INFO *cs)=0; uint size_of() const { return sizeof(*this); } CHARSET_INFO *charset(void) const { return field_charset; } - void set_charset(CHARSET_INFO *charset) { field_charset=charset; } + void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; } enum Derivation derivation(void) const { return field_derivation; } virtual void set_derivation(enum Derivation derivation_arg) { field_derivation= derivation_arg; } bool binary() const { return field_charset == &my_charset_bin; } - uint32 max_length() { return field_length; } + uint32 max_display_length() { return field_length; } friend class create_field; my_decimal *val_decimal(my_decimal *); }; @@ -409,9 +409,9 @@ public: Field_longstr(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, - struct st_table *table_arg,CHARSET_INFO *charset) + struct st_table *table_arg, CHARSET_INFO *charset_arg) :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, - field_name_arg, table_arg, charset) + field_name_arg, table_arg, charset_arg) {} int store_decimal(const my_decimal *d); @@ -462,7 +462,7 @@ public: void overflow(bool negative); bool zero_pack() const { return 0; } void sql_type(String &str) const; - uint32 max_length() { return field_length; } + uint32 max_display_length() { return field_length; } }; @@ -506,7 +506,7 @@ public: void sort_string(char *buff, uint length); bool zero_pack() const { return 0; } void sql_type(String &str) const; - uint32 max_length() { return field_length; } + uint32 max_display_length() { return field_length; } uint size_of() const { return sizeof(*this); } uint32 pack_length() const { return (uint32) bin_size; } }; @@ -539,7 +539,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 1; } void sql_type(String &str) const; - uint32 max_length() { return 4; } + uint32 max_display_length() { return 4; } }; @@ -575,7 +575,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 2; } void sql_type(String &str) const; - uint32 max_length() { return 6; } + uint32 max_display_length() { return 6; } }; @@ -606,7 +606,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; - uint32 max_length() { return 8; } + uint32 max_display_length() { return 8; } }; @@ -642,7 +642,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; - uint32 max_length() { return 11; } + uint32 max_display_length() { return 11; } }; @@ -681,7 +681,7 @@ public: uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } - uint32 max_length() { return 20; } + uint32 max_display_length() { return 20; } }; #endif @@ -716,7 +716,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; - uint32 max_length() { return 24; } + uint32 max_display_length() { return 24; } }; @@ -750,7 +750,7 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; - uint32 max_length() { return 53; } + uint32 max_display_length() { return 53; } }; @@ -782,7 +782,7 @@ public: uint32 pack_length() const { return 0; } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } - uint32 max_length() { return 4; } + uint32 max_display_length() { return 4; } }; @@ -1153,10 +1153,10 @@ public: packlength= 4; if (set_packlength) { - uint32 char_length= len_arg/cs->mbmaxlen; - packlength= char_length <= 255 ? 1 : - char_length <= 65535 ? 2 : - char_length <= 16777215 ? 3 : 4; + uint32 l_char_length= len_arg/cs->mbmaxlen; + packlength= l_char_length <= 255 ? 1 : + l_char_length <= 65535 ? 2 : + l_char_length <= 16777215 ? 3 : 4; } } enum_field_types type() const { return FIELD_TYPE_BLOB;} @@ -1234,7 +1234,7 @@ public: uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - uint32 max_length(); + uint32 max_display_length(); }; @@ -1350,7 +1350,7 @@ public: enum_field_types type() const { return FIELD_TYPE_BIT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; } uint32 key_length() const { return (uint32) (field_length + 7) / 8; } - uint32 max_length() { return field_length; } + uint32 max_display_length() { return field_length; } uint size_of() const { return sizeof(*this); } Item_result result_type () const { return INT_RESULT; } void reset(void) { bzero(ptr, bytes_in_rec); } diff --git a/sql/filesort.cc b/sql/filesort.cc index 38c941b30f4..89aaa8e8672 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -854,12 +854,14 @@ static void make_sortkey(register SORTPARAM *param, } else { - uchar *end= (uchar*) field->pack((char *) to, field->ptr); #ifdef HAVE_purify + uchar *end= (uchar*) field->pack((char *) to, field->ptr); uint length= (uint) ((to + addonf->length) - end); DBUG_ASSERT((int) length >= 0); if (length) bzero(end, length); +#else + (void) field->pack((char *) to, field->ptr); #endif } to+= addonf->length; diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index e3f979952e0..f0c59f131b9 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -380,10 +380,8 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows, bool dirty) See ha_example.cc for a longer description. */ -ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, - TABLE *table, int *rc) +ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) { - ARCHIVE_SHARE *share; char meta_file_name[FN_REFLEN]; uint length; char *tmp_name; @@ -411,8 +409,10 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, share->table_name= tmp_name; share->crashed= FALSE; share->archive_write_open= FALSE; - fn_format(share->data_file_name,table_name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME); - fn_format(meta_file_name,table_name,"",ARM,MY_REPLACE_EXT|MY_UNPACK_FILENAME); + fn_format(share->data_file_name,table_name,"",ARZ, + MY_REPLACE_EXT|MY_UNPACK_FILENAME); + fn_format(meta_file_name,table_name,"",ARM, + MY_REPLACE_EXT|MY_UNPACK_FILENAME); strmov(share->table_name,table_name); /* We will use this lock for rows. @@ -448,7 +448,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, Free the share. See ha_example.cc for a description. */ -int ha_archive::free_share(ARCHIVE_SHARE *share) +int ha_archive::free_share() { int rc= 0; DBUG_ENTER("ha_archive::free_share"); @@ -528,12 +528,14 @@ int ha_archive::open(const char *name, int mode, uint open_options) DBUG_PRINT("info", ("archive table was opened for crash %s", (open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no")); - share= get_share(name, table, &rc); + share= get_share(name, &rc); if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR)) { - free_share(share); + /* purecov: begin inspected */ + free_share(); DBUG_RETURN(rc); + /* purecov: end */ } else if (rc == HA_ERR_OUT_OF_MEM) { @@ -586,7 +588,7 @@ int ha_archive::close(void) if (gzclose(archive) == Z_ERRNO) rc= 1; /* then also close share */ - rc|= free_share(share); + rc|= free_share(); DBUG_RETURN(rc); } diff --git a/sql/ha_archive.h b/sql/ha_archive.h index 6c6b587dd2a..c9e384d092b 100644 --- a/sql/ha_archive.h +++ b/sql/ha_archive.h @@ -87,8 +87,8 @@ public: int get_row(gzFile file_to_read, byte *buf); int read_meta_file(File meta_file, ha_rows *rows); int write_meta_file(File meta_file, ha_rows rows, bool dirty); - ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table, int *rc); - int free_share(ARCHIVE_SHARE *share); + ARCHIVE_SHARE *get_share(const char *table_name, int *rc); + int free_share(); int init_archive_writer(); bool auto_repair() const { return 1; } // For the moment we just do this int read_data_header(gzFile file_to_read); diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 9abfcdc61c6..09f7ecb0296 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1097,7 +1097,7 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info, const key_range *start_key, const key_range *end_key, - bool records_in_range) + bool from_records_in_range) { bool both_not_null= (start_key != NULL && end_key != NULL) ? TRUE : FALSE; @@ -1165,7 +1165,7 @@ bool ha_federated::create_where_from_key(String *to, if (emit_key_part_name(&tmp, key_part)) DBUG_RETURN(1); - if (records_in_range) + if (from_records_in_range) { if (tmp.append(FEDERATED_GE)) DBUG_RETURN(1); @@ -1384,7 +1384,7 @@ static int free_share(FEDERATED_SHARE *share) ha_rows ha_federated::records_in_range(uint inx, key_range *start_key, - key_range *end_key) + key_range *end_key) { /* @@ -2062,7 +2062,7 @@ int ha_federated::index_init(uint keynr) int ha_federated::read_range_first(const key_range *start_key, const key_range *end_key, - bool eq_range, bool sorted) + bool eq_range_arg, bool sorted) { char sql_query_buffer[FEDERATED_QUERY_BUFFER_SIZE]; int retval; diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 3cf7593bd8a..b4593396059 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -318,11 +318,11 @@ int ha_heap::rnd_next(byte *buf) int ha_heap::rnd_pos(byte * buf, byte *pos) { int error; - HEAP_PTR position; + HEAP_PTR heap_position; statistic_increment(table->in_use->status_var.ha_read_rnd_count, &LOCK_status); - memcpy_fixed((char*) &position,pos,sizeof(HEAP_PTR)); - error=heap_rrnd(file, buf, position); + memcpy_fixed((char*) &heap_position, pos, sizeof(HEAP_PTR)); + error=heap_rrnd(file, buf, heap_position); table->status=error ? STATUS_NOT_FOUND: 0; return error; } @@ -334,19 +334,19 @@ void ha_heap::position(const byte *record) int ha_heap::info(uint flag) { - HEAPINFO info; - (void) heap_info(file,&info,flag); + HEAPINFO hp_info; + (void) heap_info(file,&hp_info,flag); - records = info.records; - deleted = info.deleted; - errkey = info.errkey; - mean_rec_length=info.reclength; - data_file_length=info.data_length; - index_file_length=info.index_length; - max_data_file_length= info.max_records* info.reclength; - delete_length= info.deleted * info.reclength; + records= hp_info.records; + deleted= hp_info.deleted; + errkey= hp_info.errkey; + mean_rec_length= hp_info.reclength; + data_file_length= hp_info.data_length; + index_file_length= hp_info.index_length; + max_data_file_length= hp_info.max_records* hp_info.reclength; + delete_length= hp_info.deleted * hp_info.reclength; if (flag & HA_STATUS_AUTO) - auto_increment_value= info.auto_increment; + auto_increment_value= hp_info.auto_increment; /* If info() is called for the first time after open(), we will still have to update the key statistics. Hoping that a table lock is now diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 19ec1b29da3..a53db517a4e 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -632,11 +632,11 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) } -int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) +int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize) { int error=0; uint local_testflag=param.testflag; - bool optimize_done= !optimize, statistics_done=0; + bool optimize_done= !do_optimize, statistics_done=0; const char *old_proc_info=thd->proc_info; char fixed_name[FN_REFLEN]; MYISAM_SHARE* share = file->s; @@ -660,7 +660,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) DBUG_RETURN(HA_ADMIN_FAILED); } - if (!optimize || + if (!do_optimize || ((file->state->del || share->state.split != file->state->records) && (!(param.testflag & T_QUICK) || !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) @@ -1295,47 +1295,47 @@ int ha_myisam::rnd_pos(byte * buf, byte *pos) void ha_myisam::position(const byte* record) { - my_off_t position=mi_position(file); - my_store_ptr(ref, ref_length, position); + my_off_t row_position= mi_position(file); + my_store_ptr(ref, ref_length, row_position); } int ha_myisam::info(uint flag) { - MI_ISAMINFO info; + MI_ISAMINFO misam_info; char name_buff[FN_REFLEN]; - (void) mi_status(file,&info,flag); + (void) mi_status(file,&misam_info,flag); if (flag & HA_STATUS_VARIABLE) { - records = info.records; - deleted = info.deleted; - data_file_length=info.data_file_length; - index_file_length=info.index_file_length; - delete_length = info.delete_length; - check_time = info.check_time; - mean_rec_length=info.mean_reclength; + records= misam_info.records; + deleted= misam_info.deleted; + data_file_length= misam_info.data_file_length; + index_file_length= misam_info.index_file_length; + delete_length= misam_info.delete_length; + check_time= misam_info.check_time; + mean_rec_length= misam_info.mean_reclength; } if (flag & HA_STATUS_CONST) { TABLE_SHARE *share= table->s; - max_data_file_length= info.max_data_file_length; - max_index_file_length= info.max_index_file_length; - create_time= info.create_time; - sortkey= info.sortkey; - ref_length= info.reflength; - share->db_options_in_use= info.options; + max_data_file_length= misam_info.max_data_file_length; + max_index_file_length= misam_info.max_index_file_length; + create_time= misam_info.create_time; + sortkey= misam_info.sortkey; + ref_length= misam_info.reflength; + share->db_options_in_use= misam_info.options; block_size= myisam_block_size; share->keys_in_use.set_prefix(share->keys); - share->keys_in_use.intersect_extended(info.key_map); + share->keys_in_use.intersect_extended(misam_info.key_map); share->keys_for_keyread.intersect(share->keys_in_use); - share->db_record_offset= info.record_offset; + share->db_record_offset= misam_info.record_offset; if (share->key_parts) memcpy((char*) table->key_info[0].rec_per_key, - (char*) info.rec_per_key, + (char*) misam_info.rec_per_key, sizeof(table->key_info[0].rec_per_key)*share->key_parts); - raid_type= info.raid_type; - raid_chunks= info.raid_chunks; - raid_chunksize= info.raid_chunksize; + raid_type= misam_info.raid_type; + raid_chunks= misam_info.raid_chunks; + raid_chunksize= misam_info.raid_chunksize; /* Set data_file_name and index_file_name to point at the symlink value @@ -1343,21 +1343,21 @@ int ha_myisam::info(uint flag) */ data_file_name=index_file_name=0; fn_format(name_buff, file->filename, "", MI_NAME_DEXT, 2); - if (strcmp(name_buff, info.data_file_name)) - data_file_name=info.data_file_name; + if (strcmp(name_buff, misam_info.data_file_name)) + data_file_name= misam_info.data_file_name; strmov(fn_ext(name_buff),MI_NAME_IEXT); - if (strcmp(name_buff, info.index_file_name)) - index_file_name=info.index_file_name; + if (strcmp(name_buff, misam_info.index_file_name)) + index_file_name= misam_info.index_file_name; } if (flag & HA_STATUS_ERRKEY) { - errkey = info.errkey; - my_store_ptr(dupp_ref, ref_length, info.dupp_key_pos); + errkey = misam_info.errkey; + my_store_ptr(dupp_ref, ref_length, misam_info.dupp_key_pos); } if (flag & HA_STATUS_TIME) - update_time = info.update_time; + update_time = misam_info.update_time; if (flag & HA_STATUS_AUTO) - auto_increment_value= info.auto_increment; + auto_increment_value= misam_info.auto_increment; return 0; } @@ -1427,7 +1427,7 @@ void ha_myisam::update_create_info(HA_CREATE_INFO *create_info) int ha_myisam::create(const char *name, register TABLE *table_arg, - HA_CREATE_INFO *info) + HA_CREATE_INFO *ha_create_info) { int error; uint i,j,recpos,minpos,fieldpos,temp_length,length, create_flags= 0; @@ -1605,20 +1605,22 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, create_info.max_rows= share->max_rows; create_info.reloc_rows= share->min_rows; create_info.with_auto_increment=found_real_auto_increment; - create_info.auto_increment=(info->auto_increment_value ? - info->auto_increment_value -1 : + create_info.auto_increment=(ha_create_info->auto_increment_value ? + ha_create_info->auto_increment_value -1 : (ulonglong) 0); create_info.data_file_length= ((ulonglong) share->max_rows * share->avg_row_length); - create_info.raid_type=info->raid_type; - create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks : + create_info.raid_type=ha_create_info->raid_type; + create_info.raid_chunks= (ha_create_info->raid_chunks ? + ha_create_info->raid_chunks : RAID_DEFAULT_CHUNKS); - create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize : + create_info.raid_chunksize= (ha_create_info->raid_chunksize ? + ha_create_info->raid_chunksize : RAID_DEFAULT_CHUNKSIZE); - create_info.data_file_name= info->data_file_name; - create_info.index_file_name= info->index_file_name; + create_info.data_file_name= ha_create_info->data_file_name; + create_info.index_file_name= ha_create_info->index_file_name; - if (info->options & HA_LEX_CREATE_TMP_TABLE) + if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE) create_flags|= HA_CREATE_TMP_TABLE; if (options & HA_OPTION_PACK_RECORD) create_flags|= HA_PACK_RECORD; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 5e613a63303..693297a8483 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -263,8 +263,8 @@ int ha_myisammrg::rnd_pos(byte * buf, byte *pos) void ha_myisammrg::position(const byte *record) { - ulonglong position= myrg_position(file); - my_store_ptr(ref, ref_length, (my_off_t) position); + ulonglong row_position= myrg_position(file); + my_store_ptr(ref, ref_length, (my_off_t) row_position); } @@ -277,25 +277,25 @@ ha_rows ha_myisammrg::records_in_range(uint inx, key_range *min_key, int ha_myisammrg::info(uint flag) { - MYMERGE_INFO info; - (void) myrg_status(file,&info,flag); + MYMERGE_INFO mrg_info; + (void) myrg_status(file,&mrg_info,flag); /* The following fails if one has not compiled MySQL with -DBIG_TABLES and one has more than 2^32 rows in the merge tables. */ - records = (ha_rows) info.records; - deleted = (ha_rows) info.deleted; + records = (ha_rows) mrg_info.records; + deleted = (ha_rows) mrg_info.deleted; #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 - if ((info.records >= (ulonglong) 1 << 32) || - (info.deleted >= (ulonglong) 1 << 32)) + if ((mrg_info.records >= (ulonglong) 1 << 32) || + (mrg_info.deleted >= (ulonglong) 1 << 32)) table->s->crashed= 1; #endif - data_file_length=info.data_file_length; - errkey = info.errkey; + data_file_length=mrg_info.data_file_length; + errkey = mrg_info.errkey; table->s->keys_in_use.set_prefix(table->s->keys); - table->s->db_options_in_use= info.options; + table->s->db_options_in_use= mrg_info.options; table->s->is_view= 1; - mean_rec_length= info.reclength; + mean_rec_length= mrg_info.reclength; /* The handler::block_size is used all over the code in index scan cost @@ -325,7 +325,7 @@ int ha_myisammrg::info(uint flag) #endif if (flag & HA_STATUS_CONST) { - if (table->s->key_parts && info.rec_per_key) + if (table->s->key_parts && mrg_info.rec_per_key) { #ifdef HAVE_purify /* @@ -338,7 +338,7 @@ int ha_myisammrg::info(uint flag) sizeof(table->key_info[0].rec_per_key) * table->s->key_parts); #endif memcpy((char*) table->key_info[0].rec_per_key, - (char*) info.rec_per_key, + (char*) mrg_info.rec_per_key, sizeof(table->key_info[0].rec_per_key) * min(file->keys, table->s->key_parts)); } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 2ef16ddacbf..7bbbb2f7bc0 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -362,11 +362,11 @@ int ha_ndbcluster::records_update() DBUG_ENTER("ha_ndbcluster::records_update"); int result= 0; - struct Ndb_local_table_statistics *info= + struct Ndb_local_table_statistics *local_info= (struct Ndb_local_table_statistics *)m_table_info; DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d", ((const NDBTAB *)m_table)->getTableId(), - info->no_uncommitted_rows_count)); + local_info->no_uncommitted_rows_count)); // if (info->records == ~(ha_rows)0) { Ndb *ndb= get_ndb(); @@ -377,16 +377,16 @@ int ha_ndbcluster::records_update() { mean_rec_length= stat.row_size; data_file_length= stat.fragment_memory; - info->records= stat.row_count; + local_info->records= stat.row_count; } } { THD *thd= current_thd; if (get_thd_ndb(thd)->error) - info->no_uncommitted_rows_count= 0; + local_info->no_uncommitted_rows_count= 0; } if(result==0) - records= info->records+ info->no_uncommitted_rows_count; + records= local_info->records+ local_info->no_uncommitted_rows_count; DBUG_RETURN(result); } @@ -404,17 +404,17 @@ void ha_ndbcluster::no_uncommitted_rows_init(THD *thd) if (m_ha_not_exact_count) return; DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_init"); - struct Ndb_local_table_statistics *info= + struct Ndb_local_table_statistics *local_info= (struct Ndb_local_table_statistics *)m_table_info; Thd_ndb *thd_ndb= get_thd_ndb(thd); - if (info->last_count != thd_ndb->count) + if (local_info->last_count != thd_ndb->count) { - info->last_count= thd_ndb->count; - info->no_uncommitted_rows_count= 0; - info->records= ~(ha_rows)0; + local_info->last_count= thd_ndb->count; + local_info->no_uncommitted_rows_count= 0; + local_info->records= ~(ha_rows)0; DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d", ((const NDBTAB *)m_table)->getTableId(), - info->no_uncommitted_rows_count)); + local_info->no_uncommitted_rows_count)); } DBUG_VOID_RETURN; } @@ -424,12 +424,12 @@ void ha_ndbcluster::no_uncommitted_rows_update(int c) if (m_ha_not_exact_count) return; DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_update"); - struct Ndb_local_table_statistics *info= + struct Ndb_local_table_statistics *local_info= (struct Ndb_local_table_statistics *)m_table_info; - info->no_uncommitted_rows_count+= c; + local_info->no_uncommitted_rows_count+= c; DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d", ((const NDBTAB *)m_table)->getTableId(), - info->no_uncommitted_rows_count)); + local_info->no_uncommitted_rows_count)); DBUG_VOID_RETURN; } @@ -1713,7 +1713,7 @@ int ha_ndbcluster::unique_index_read(const byte *key, inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) { DBUG_ENTER("fetch_next"); - int check; + int local_check; NdbTransaction *trans= m_active_trans; if (m_lock_tuple) @@ -1724,15 +1724,17 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) LOCK WITH SHARE MODE) and row was not explictly unlocked with unlock_row() call */ - NdbConnection *trans= m_active_trans; + NdbConnection *con_trans= m_active_trans; NdbOperation *op; // Lock row DBUG_PRINT("info", ("Keeping lock on scanned row")); if (!(op= m_active_cursor->lockCurrentTuple())) { + /* purecov: begin inspected */ m_lock_tuple= false; - ERR_RETURN(trans->getNdbError()); + ERR_RETURN(con_trans->getNdbError()); + /* purecov: end */ } m_ops_pending++; } @@ -1753,7 +1755,7 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) m_blobs_pending= FALSE; } - if ((check= cursor->nextResult(contact_ndb, m_force_send)) == 0) + if ((local_check= cursor->nextResult(contact_ndb, m_force_send)) == 0) { /* Explicitly lock tuple if "select for update" or @@ -1764,7 +1766,7 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) m_lock.type == TL_READ_WITH_SHARED_LOCKS); DBUG_RETURN(0); } - else if (check == 1 || check == 2) + else if (local_check == 1 || local_check == 2) { // 1: No more records // 2: No more cached records @@ -1794,13 +1796,13 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) } m_ops_pending= 0; } - contact_ndb= (check == 2); + contact_ndb= (local_check == 2); } else { DBUG_RETURN(-1); } - } while (check == 2); + } while (local_check == 2); DBUG_RETURN(1); } @@ -2132,8 +2134,7 @@ int ha_ndbcluster::write_row(byte *record) NdbTransaction *trans= m_active_trans; NdbOperation *op; int res; - THD *thd= current_thd; - + THD *thd= table->in_use; DBUG_ENTER("write_row"); has_auto_increment= (table->next_number_field && record == table->record[0]); @@ -2144,7 +2145,6 @@ int ha_ndbcluster::write_row(byte *record) */ if (has_auto_increment) { - THD *thd= table->in_use; int error; m_skip_auto_increment= FALSE; @@ -2206,8 +2206,6 @@ int ha_ndbcluster::write_row(byte *record) } else { - int res; - if ((res= set_primary_key_from_record(op, record))) return res; } @@ -2628,8 +2626,6 @@ void ha_ndbcluster::print_results() DBUG_ENTER("print_results"); #ifndef DBUG_OFF - const NDBTAB *tab= (const NDBTAB*) m_table; - if (!_db_on_) DBUG_VOID_RETURN; @@ -4098,15 +4094,15 @@ static int create_ndb_column(NDBCOL &col, col.setCharset(cs); } // Use "<=" even if "<" is the exact condition - if (field->max_length() <= (1 << 8)) + if (field->max_display_length() <= (1 << 8)) goto mysql_type_tiny_blob; - else if (field->max_length() <= (1 << 16)) + else if (field->max_display_length() <= (1 << 16)) { col.setInlineSize(256); col.setPartSize(2000); col.setStripeSize(16); } - else if (field->max_length() <= (1 << 24)) + else if (field->max_display_length() <= (1 << 24)) goto mysql_type_medium_blob; else goto mysql_type_long_blob; @@ -4240,14 +4236,14 @@ static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) int ha_ndbcluster::create(const char *name, TABLE *form, - HA_CREATE_INFO *info) + HA_CREATE_INFO *create_info) { NDBTAB tab; NDBCOL col; uint pack_length, length, i, pk_length= 0; const void *data, *pack_data; char name2[FN_HEADLEN]; - bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE); + bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE); DBUG_ENTER("ha_ndbcluster::create"); DBUG_PRINT("enter", ("name: %s", name)); @@ -4274,7 +4270,7 @@ int ha_ndbcluster::create(const char *name, DBUG_PRINT("table", ("name: %s", m_tabname)); tab.setName(m_tabname); - tab.setLogging(!(info->options & HA_LEX_CREATE_TMP_TABLE)); + tab.setLogging(!(create_info->options & HA_LEX_CREATE_TMP_TABLE)); // Save frm data for this table if (readfrm(name, &data, &length)) @@ -4293,7 +4289,7 @@ int ha_ndbcluster::create(const char *name, DBUG_PRINT("info", ("name: %s, type: %u, pack_length: %d", field->field_name, field->real_type(), field->pack_length())); - if ((my_errno= create_ndb_column(col, field, info))) + if ((my_errno= create_ndb_column(col, field, create_info))) DBUG_RETURN(my_errno); tab.addColumn(col); if (col.getPrimaryKey()) @@ -4328,13 +4324,13 @@ int ha_ndbcluster::create(const char *name, case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: { - NdbDictionary::Column * col= tab.getColumn(i); - int size= pk_length + (col->getPartSize()+3)/4 + 7; + NdbDictionary::Column * column= tab.getColumn(i); + int size= pk_length + (column->getPartSize()+3)/4 + 7; if (size > NDB_MAX_TUPLE_SIZE_IN_WORDS && (pk_length+7) < NDB_MAX_TUPLE_SIZE_IN_WORDS) { size= NDB_MAX_TUPLE_SIZE_IN_WORDS - pk_length - 7; - col->setPartSize(4*size); + column->setPartSize(4*size); } /** * If size > NDB_MAX and pk_length+7 >= NDB_MAX @@ -5959,7 +5955,6 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, Uint64 sum_row_size= 0; Uint64 sum_mem= 0; NdbScanOperation*pOp; - NdbResultSet *rs; int check; if ((pTrans= ndb->startTransaction()) == NULL) @@ -6128,7 +6123,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, int res; KEY* key_info= table->key_info + active_index; - NDB_INDEX_TYPE index_type= get_index_type(active_index); + NDB_INDEX_TYPE cur_index_type= get_index_type(active_index); ulong reclength= table->s->reclength; NdbOperation* op; Thd_ndb *thd_ndb= get_thd_ndb(current_thd); @@ -6186,7 +6181,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, for (; multi_range_currstart_key.length == key_info->key_length && multi_range_curr->start_key.flag == HA_READ_KEY_EXACT)) @@ -6775,14 +6770,14 @@ void ndb_serialize_cond(const Item *item, void *arg) if (context->supported) { - Ndb_rewrite_context *rewrite_context= context->rewrite_stack; - const Item_func *func_item; + Ndb_rewrite_context *rewrite_context2= context->rewrite_stack; + const Item_func *rewrite_func_item; // Check if we are rewriting some unsupported function call - if (rewrite_context && - (func_item= rewrite_context->func_item) && - rewrite_context->count++ == 0) + if (rewrite_context2 && + (rewrite_func_item= rewrite_context2->func_item) && + rewrite_context2->count++ == 0) { - switch (func_item->functype()) { + switch (rewrite_func_item->functype()) { case Item_func::BETWEEN: /* Rewrite @@ -6809,7 +6804,7 @@ void ndb_serialize_cond(const Item *item, void *arg) if (context->expecting(item->type())) { // This is the | item, save it in the rewrite context - rewrite_context->left_hand_item= item; + rewrite_context2->left_hand_item= item; if (item->type() == Item::FUNC_ITEM) { Item_func *func_item= (Item_func *) item; diff --git a/sql/handler.cc b/sql/handler.cc index ae314afb991..2429217418c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -122,11 +122,6 @@ handlerton isam_hton = { "ISAM", SHOW_OPTION_NO, "Obsolete storage engine", DB_TYPE_ISAM, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, HTON_NO_FLAGS }; - -/* static functions defined in this file */ - -static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES; - /* number of entries in handlertons[] */ ulong total_ha; /* number of storage engines (from handlertons[]) that support 2pc */ @@ -714,7 +709,7 @@ int ha_commit_trans(THD *thd, bool all) } DBUG_EXECUTE_IF("crash_commit_after_prepare", abort();); if (error || (is_real_trans && xid && - (error= !(cookie= tc_log->log(thd, xid))))) + (error= !(cookie= tc_log->log_xid(thd, xid))))) { ha_rollback_trans(thd, all); error= 1; @@ -722,7 +717,7 @@ int ha_commit_trans(THD *thd, bool all) } DBUG_EXECUTE_IF("crash_commit_after_log", abort();); } - error=ha_commit_one_phase(thd, all) ? cookie ? 2 : 1 : 0; + error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0; DBUG_EXECUTE_IF("crash_commit_before_unlog", abort();); if (cookie) tc_log->unlog(cookie, xid); diff --git a/sql/item.cc b/sql/item.cc index 6f0d2ff59a3..ff78355abd2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -26,10 +26,6 @@ #include "sql_trigger.h" #include "sql_select.h" -static void mark_as_dependent(THD *thd, - SELECT_LEX *last, SELECT_LEX *current, - Item_ident *item); - const String my_null_string("NULL", 4, default_charset_info); /****************************************************************************/ @@ -1683,7 +1679,7 @@ void Item_field::set_field(Field *field_par) field=result_field=field_par; // for easy coding with fields maybe_null=field->maybe_null(); decimals= field->decimals(); - max_length= field_par->max_length(); + max_length= field_par->max_display_length(); table_name= *field_par->table_name; field_name= field_par->field_name; db_name= field_par->table->s->db; @@ -2398,21 +2394,22 @@ void Item_param::set_decimal(const char *str, ulong length) the fact that even wrong value sent over binary protocol fits into MAX_DATE_STRING_REP_LENGTH buffer. */ -void Item_param::set_time(TIME *tm, timestamp_type type, uint32 max_length_arg) +void Item_param::set_time(TIME *tm, timestamp_type time_type, + uint32 max_length_arg) { DBUG_ENTER("Item_param::set_time"); value.time= *tm; - value.time.time_type= type; + value.time.time_type= time_type; if (value.time.year > 9999 || value.time.month > 12 || value.time.day > 31 || - type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23 || + time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23 || value.time.minute > 59 || value.time.second > 59) { char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= my_TIME_to_str(&value.time, buff); - make_truncated_value_warning(current_thd, buff, length, type, 0); + make_truncated_value_warning(current_thd, buff, length, time_type, 0); set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR); } @@ -2877,7 +2874,7 @@ bool Item_param::basic_const_item() const Item * -Item_param::new_item() +Item_param::clone_item() { /* see comments in the header file */ switch (state) { @@ -3484,28 +3481,29 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) thd->lex->in_sum_func->nest_level == thd->lex->current_select->nest_level) { - Item::Type type= (*reference)->type(); + Item::Type ref_type= (*reference)->type(); set_if_bigger(thd->lex->in_sum_func->max_arg_level, select->nest_level); set_field(*from_field); fixed= 1; mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, this, - ((type == REF_ITEM || type == FIELD_ITEM) ? + ((ref_type == REF_ITEM || + ref_type == FIELD_ITEM) ? (Item_ident*) (*reference) : 0)); return 0; } } else { - Item::Type type= (*reference)->type(); + Item::Type ref_type= (*reference)->type(); prev_subselect_item->used_tables_cache|= (*reference)->used_tables(); prev_subselect_item->const_item_cache&= (*reference)->const_item(); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, this, - ((type == REF_ITEM || type == FIELD_ITEM) ? + ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ? (Item_ident*) (*reference) : 0)); /* @@ -4021,7 +4019,7 @@ Item *Item_field::replace_equal_field(byte *arg) void Item::init_make_field(Send_field *tmp_field, - enum enum_field_types field_type) + enum enum_field_types field_type_arg) { char *empty_name= (char*) ""; tmp_field->db_name= empty_name; @@ -4033,7 +4031,7 @@ void Item::init_make_field(Send_field *tmp_field, tmp_field->flags= (maybe_null ? 0 : NOT_NULL_FLAG) | (my_binary_compare(collation.collation) ? BINARY_FLAG : 0); - tmp_field->type=field_type; + tmp_field->type= field_type_arg; tmp_field->length=max_length; tmp_field->decimals=decimals; if (unsigned_flag) @@ -4048,12 +4046,12 @@ void Item::make_field(Send_field *tmp_field) void Item_empty_string::make_field(Send_field *tmp_field) { - enum_field_types type= FIELD_TYPE_VAR_STRING; + enum_field_types f_type= FIELD_TYPE_VAR_STRING; if (max_length >= 16777216) - type= FIELD_TYPE_LONG_BLOB; + f_type= FIELD_TYPE_LONG_BLOB; else if (max_length >= 65536) - type= FIELD_TYPE_MEDIUM_BLOB; - init_make_field(tmp_field, type); + f_type= FIELD_TYPE_MEDIUM_BLOB; + init_make_field(tmp_field, f_type); } @@ -4387,7 +4385,7 @@ bool Item_int::eq(const Item *arg, bool binary_cmp) const } -Item *Item_int_with_ref::new_item() +Item *Item_int_with_ref::clone_item() { DBUG_ASSERT(ref->const_item()); /* @@ -4652,10 +4650,10 @@ bool Item_null::send(Protocol *protocol, String *packet) bool Item::send(Protocol *protocol, String *buffer) { bool result; - enum_field_types type; + enum_field_types f_type; LINT_INIT(result); // Will be set if null_value == 0 - switch ((type=field_type())) { + switch ((f_type=field_type())) { default: case MYSQL_TYPE_NULL: case MYSQL_TYPE_DECIMAL: @@ -4734,7 +4732,7 @@ bool Item::send(Protocol *protocol, String *buffer) get_date(&tm, TIME_FUZZY_DATE); if (!null_value) { - if (type == MYSQL_TYPE_DATE) + if (f_type == MYSQL_TYPE_DATE) return protocol->store_date(&tm); else result= protocol->store(&tm); @@ -4931,7 +4929,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) goto error; if (from_field == view_ref_found) { - Item::Type type= (*reference)->type(); + Item::Type refer_type= (*reference)->type(); prev_subselect_item->used_tables_cache|= (*reference)->used_tables(); prev_subselect_item->const_item_cache&= @@ -4939,7 +4937,8 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) DBUG_ASSERT((*reference)->type() == REF_ITEM); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, this, - ((type == REF_ITEM || type == FIELD_ITEM) ? + ((refer_type == REF_ITEM || + refer_type == FIELD_ITEM) ? (Item_ident*) (*reference) : 0)); /* @@ -5677,8 +5676,9 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items) { table_grants->want_privilege= want_privilege; - if (check_grant_column(thd, table_grants, triggers->table->s->db, - triggers->table->s->table_name, field_name, + if (check_grant_column(thd, table_grants, triggers->trigger_table->s->db, + triggers->trigger_table->s->table_name, + field_name, strlen(field_name), thd->security_ctx)) return TRUE; } @@ -5796,7 +5796,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) DBUG_ASSERT(item_row->cols() == comp_item_row->cols()); col= item_row->cols(); while (col-- > 0) - resolve_const_item(thd, item_row->addr(col), comp_item_row->el(col)); + resolve_const_item(thd, item_row->addr(col), + comp_item_row->element_index(col)); break; } /* Fallthrough */ @@ -6064,7 +6065,7 @@ bool Item_cache_row::setup(Item * item) return 1; for (uint i= 0; i < item_count; i++) { - Item *el= item->el(i); + Item *el= item->element_index(i); Item_cache *tmp; if (!(tmp= values[i]= Item_cache::get_cache(el->result_type()))) return 1; @@ -6080,7 +6081,7 @@ void Item_cache_row::store(Item * item) item->bring_value(); for (uint i= 0; i < item_count; i++) { - values[i]->store(item->el(i)); + values[i]->store(item->element_index(i)); null_value|= values[i]->null_value; } } diff --git a/sql/item.h b/sql/item.h index 63d89113ec1..075972923a5 100644 --- a/sql/item.h +++ b/sql/item.h @@ -651,7 +651,7 @@ public: */ virtual bool basic_const_item() const { return 0; } /* cloning of constant items (0 if it is not const) */ - virtual Item *new_item() { return 0; } + virtual Item *clone_item() { return 0; } 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;} @@ -777,7 +777,7 @@ public: virtual bool collect_item_field_processor(byte * arg) { return 0; } virtual bool find_item_in_field_list_processor(byte *arg) { return 0; } virtual bool change_context_processor(byte *context) { return 0; } - virtual bool reset_query_id_processor(byte *query_id) { return 0; } + virtual bool reset_query_id_processor(byte *query_id_arg) { return 0; } virtual bool is_expensive_processor(byte *arg) { return 0; } virtual bool subst_argument_checker(byte **arg) { @@ -801,11 +801,11 @@ public: For SP local variable returns address of pointer to Item representing its current value and pointer passed via parameter otherwise. */ - virtual Item **this_item_addr(THD *thd, Item **addr) { return addr; } + virtual Item **this_item_addr(THD *thd, Item **addr_arg) { return addr_arg; } // Row emulation virtual uint cols() { return 1; } - virtual Item* el(uint i) { return this; } + virtual Item* element_index(uint i) { return this; } virtual Item** addr(uint i) { return 0; } virtual bool check_cols(uint c); // It is not row => null inside is impossible @@ -1071,7 +1071,8 @@ class Item_name_const : public Item Item *value_item; Item *name_item; public: - Item_name_const(Item *name, Item *val): value_item(val), name_item(name) + Item_name_const(Item *name_arg, Item *val): + value_item(val), name_item(name_arg) { Item::maybe_null= TRUE; } @@ -1290,7 +1291,7 @@ public: Item *equal_fields_propagator(byte *arg); bool set_no_const_sub(byte *arg); Item *replace_equal_field(byte *arg); - inline uint32 max_disp_length() { return field->max_length(); } + inline uint32 max_disp_length() { return field->max_display_length(); } Item_field *filed_for_view_update() { return this; } Item *safe_charset_converter(CHARSET_INFO *tocs); int fix_outer_field(THD *thd, Field **field, Item **reference); @@ -1324,7 +1325,7 @@ public: /* to prevent drop fixed flag (no need parent cleanup call) */ void cleanup() {} bool basic_const_item() const { return 1; } - Item *new_item() { return new Item_null(name); } + Item *clone_item() { return new Item_null(name); } bool is_null() { return 1; } void print(String *str) { str->append(STRING_WITH_LEN("NULL")); } Item *safe_charset_converter(CHARSET_INFO *tocs); @@ -1471,7 +1472,7 @@ public: basic_const_item returned TRUE. */ Item *safe_charset_converter(CHARSET_INFO *tocs); - Item *new_item(); + Item *clone_item(); /* Implement by-value equality evaluation if parameter value is set and is a basic constant (integer, real or string). @@ -1503,7 +1504,7 @@ public: String *val_str(String*); int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } - Item *new_item() { return new Item_int(name,value,max_length); } + Item *clone_item() { return new Item_int(name,value,max_length); } // to prevent drop fixed flag (no need parent cleanup call) void cleanup() {} void print(String *str); @@ -1523,7 +1524,7 @@ public: double val_real() { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); } String *val_str(String*); - Item *new_item() { return new Item_uint(name,max_length); } + Item *clone_item() { return new Item_uint(name,max_length); } int save_in_field(Field *field, bool no_conversions); void print(String *str); Item_num *neg (); @@ -1554,7 +1555,7 @@ public: my_decimal *val_decimal(my_decimal *val) { return &decimal_value; } int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } - Item *new_item() + Item *clone_item() { return new Item_decimal(name, &decimal_value, decimals, max_length); } @@ -1612,7 +1613,7 @@ public: bool basic_const_item() const { return 1; } // to prevent drop fixed flag (no need parent cleanup call) void cleanup() {} - Item *new_item() + Item *clone_item() { return new Item_float(name, value, decimals, max_length); } Item_num *neg() { value= -value; return this; } void print(String *str); @@ -1697,7 +1698,7 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } bool basic_const_item() const { return 1; } bool eq(const Item *item, bool binary_cmp) const; - Item *new_item() + Item *clone_item() { return new Item_string(name, str_value.ptr(), str_value.length(), collation.collation); @@ -1748,9 +1749,9 @@ class Item_return_int :public Item_int { enum_field_types int_field_type; public: - Item_return_int(const char *name, uint length, + Item_return_int(const char *name_arg, uint length, enum_field_types field_type_arg) - :Item_int(name, 0, length), int_field_type(field_type_arg) + :Item_int(name_arg, 0, length), int_field_type(field_type_arg) { unsigned_flag=1; } @@ -2012,7 +2013,7 @@ public: { return ref->save_in_field(field, no_conversions); } - Item *new_item(); + Item *clone_item(); virtual Item *real_item() { return ref; } }; @@ -2445,8 +2446,8 @@ public: enum Item_result result_type() const { return ROW_RESULT; } uint cols() { return item_count; } - Item* el(uint i) { return values[i]; } - Item** addr(uint i) { return (Item **) (values + i); } + Item *element_index(uint i) { return values[i]; } + Item **addr(uint i) { return (Item **) (values + i); } bool check_cols(uint c); bool null_inside(); void bring_value(); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index bc31a7203a4..d5af3988b38 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -260,7 +260,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item) void Item_bool_func2::fix_length_and_dec() { max_length= 1; // Function returns 0 or 1 - THD *thd= current_thd; + THD *thd; /* As some compare functions are generated after sql_yacc, @@ -298,12 +298,13 @@ void Item_bool_func2::fix_length_and_dec() return; } + thd= current_thd; if (!thd->is_context_analysis_only()) { - Item *real_item= args[0]->real_item(); - if (real_item->type() == FIELD_ITEM) + Item *arg_real_item= args[0]->real_item(); + if (arg_real_item->type() == FIELD_ITEM) { - Field *field=((Item_field*) real_item)->field; + Field *field=((Item_field*) arg_real_item)->field; if (field->can_be_compared_as_longlong()) { if (convert_constant_item(thd, field,&args[1])) @@ -315,10 +316,10 @@ void Item_bool_func2::fix_length_and_dec() } } } - real_item= args[1]->real_item(); - if (real_item->type() == FIELD_ITEM /* && !real_item->const_item() */) + arg_real_item= args[1]->real_item(); + if (arg_real_item->type() == FIELD_ITEM) { - Field *field=((Item_field*) real_item)->field; + Field *field=((Item_field*) arg_real_item)->field; if (field->can_be_compared_as_longlong()) { if (convert_constant_item(thd, field,&args[0])) @@ -354,9 +355,9 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) return 1; for (uint i=0; i < n; i++) { - if ((*a)->el(i)->cols() != (*b)->el(i)->cols()) + if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols()) { - my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->el(i)->cols()); + my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols()); return 1; } comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i)); @@ -741,10 +742,10 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref) uint n= cache->cols(); for (uint i= 0; i < n; i++) { - if (args[0]->el(i)->used_tables()) - ((Item_cache *)cache->el(i))->set_used_tables(OUTER_REF_TABLE_BIT); + if (args[0]->element_index(i)->used_tables()) + ((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT); else - ((Item_cache *)cache->el(i))->set_used_tables(0); + ((Item_cache *)cache->element_index(i))->set_used_tables(0); } used_tables_cache= args[0]->used_tables(); } @@ -815,7 +816,7 @@ longlong Item_in_optimizer::val_int() subselect and see if it has produced any rows. */ ((Item_in_subselect*)args[1])->enable_pushed_conds= FALSE; - longlong tmp= args[1]->val_bool_result(); + (void) args[1]->val_bool_result(); result_for_null_param= null_value= !((Item_in_subselect*)args[1])->engine->no_rows(); ((Item_in_subselect*)args[1])->enable_pushed_conds= TRUE; @@ -932,15 +933,15 @@ longlong Item_func_strcmp::val_int() void Item_func_interval::fix_length_and_dec() { - use_decimal_comparison= (row->el(0)->result_type() == DECIMAL_RESULT) || - (row->el(0)->result_type() == INT_RESULT); + use_decimal_comparison= (row->element_index(0)->result_type() == DECIMAL_RESULT) || + (row->element_index(0)->result_type() == INT_RESULT); if (row->cols() > 8) { bool consts=1; for (uint i=1 ; consts && i < row->cols() ; i++) { - consts&= row->el(i)->const_item(); + consts&= row->element_index(i)->const_item(); } if (consts && @@ -951,7 +952,7 @@ void Item_func_interval::fix_length_and_dec() { for (uint i=1 ; i < row->cols(); i++) { - Item *el= row->el(i); + Item *el= row->element_index(i); interval_range *range= intervals + (i-1); if ((el->result_type() == DECIMAL_RESULT) || (el->result_type() == INT_RESULT)) @@ -976,7 +977,7 @@ void Item_func_interval::fix_length_and_dec() { for (uint i=1 ; i < row->cols(); i++) { - intervals[i-1].dbl= row->el(i)->val_real(); + intervals[i-1].dbl= row->element_index(i)->val_real(); } } } @@ -1016,15 +1017,15 @@ longlong Item_func_interval::val_int() if (use_decimal_comparison) { - dec= row->el(0)->val_decimal(&dec_buf); - if (row->el(0)->null_value) + dec= row->element_index(0)->val_decimal(&dec_buf); + if (row->element_index(0)->null_value) return -1; my_decimal2double(E_DEC_FATAL_ERROR, dec, &value); } else { - value= row->el(0)->val_real(); - if (row->el(0)->null_value) + value= row->element_index(0)->val_real(); + if (row->element_index(0)->null_value) return -1; } @@ -1060,16 +1061,16 @@ longlong Item_func_interval::val_int() for (i=1 ; i < row->cols() ; i++) { - Item *el= row->el(i); + Item *el= row->element_index(i); if (use_decimal_comparison && ((el->result_type() == DECIMAL_RESULT) || (el->result_type() == INT_RESULT))) { - my_decimal e_dec_buf, *e_dec= row->el(i)->val_decimal(&e_dec_buf); + my_decimal e_dec_buf, *e_dec= row->element_index(i)->val_decimal(&e_dec_buf); if (my_decimal_cmp(e_dec, dec) > 0) return i-1; } - else if (row->el(i)->val_real() > value) + else if (row->element_index(i)->val_real() > value) return i-1; } return i-1; @@ -1792,7 +1793,9 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref) buff should match stack usage from Item_func_case::val_int() -> Item_func_case::find_item() */ +#ifndef EMBEDDED_LIBRARY char buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2]; +#endif bool res= Item_func::fix_fields(thd, ref); /* Call check_stack_overrun after fix_fields to be sure that stack variable @@ -2255,11 +2258,11 @@ void cmp_item_row::store_value(Item *item) { if (!comparators[i]) if (!(comparators[i]= - cmp_item::get_comparator(item->el(i)->result_type(), - item->el(i)->collation.collation))) + cmp_item::get_comparator(item->element_index(i)->result_type(), + item->element_index(i)->collation.collation))) break; // new failed - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; + comparators[i]->store_value(item->element_index(i)); + item->null_value|= item->element_index(i)->null_value; } } DBUG_VOID_RETURN; @@ -2284,8 +2287,8 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) 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; + item->element_index(i)); + item->null_value|= item->element_index(i)->null_value; } } } @@ -2303,9 +2306,9 @@ int cmp_item_row::cmp(Item *arg) arg->bring_value(); for (uint i=0; i < n; i++) { - if (comparators[i]->cmp(arg->el(i))) + if (comparators[i]->cmp(arg->element_index(i))) { - if (!arg->el(i)->null_value) + if (!arg->element_index(i)->null_value) return 1; was_null= 1; } @@ -2316,11 +2319,11 @@ int cmp_item_row::cmp(Item *arg) int cmp_item_row::compare(cmp_item *c) { - cmp_item_row *cmp= (cmp_item_row *) c; + cmp_item_row *l_cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) { int res; - if ((res= comparators[i]->compare(cmp->comparators[i]))) + if ((res= comparators[i]->compare(l_cmp->comparators[i]))) return res; } return 0; @@ -2347,8 +2350,8 @@ int cmp_item_decimal::cmp(Item *arg) int cmp_item_decimal::compare(cmp_item *arg) { - cmp_item_decimal *cmp= (cmp_item_decimal*) arg; - return my_decimal_cmp(&value, &cmp->value); + cmp_item_decimal *l_cmp= (cmp_item_decimal*) arg; + return my_decimal_cmp(&value, &l_cmp->value); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index acad1e51bc9..b75f5f764a6 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -841,10 +841,10 @@ public: return (value_res ? (res ? sortcmp(value_res, res, cmp_charset) : 1) : (res ? -1 : 0)); } - int compare(cmp_item *c) + int compare(cmp_item *ci) { - cmp_item_string *cmp= (cmp_item_string *)c; - return sortcmp(value_res, cmp->value_res, cmp_charset); + cmp_item_string *l_cmp= (cmp_item_string *) ci; + return sortcmp(value_res, l_cmp->value_res, cmp_charset); } cmp_item *make_same(); }; @@ -862,10 +862,10 @@ public: { return value != arg->val_int(); } - int compare(cmp_item *c) + int compare(cmp_item *ci) { - cmp_item_int *cmp= (cmp_item_int *)c; - return (value < cmp->value) ? -1 : ((value == cmp->value) ? 0 : 1); + cmp_item_int *l_cmp= (cmp_item_int *)ci; + return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1); } cmp_item *make_same(); }; @@ -883,10 +883,10 @@ public: { return value != arg->val_real(); } - int compare(cmp_item *c) + int compare(cmp_item *ci) { - cmp_item_real *cmp= (cmp_item_real *)c; - return (value < cmp->value)? -1 : ((value == cmp->value) ? 0 : 1); + cmp_item_real *l_cmp= (cmp_item_real *) ci; + return (value < l_cmp->value)? -1 : ((value == l_cmp->value) ? 0 : 1); } cmp_item *make_same(); }; @@ -951,10 +951,10 @@ public: DBUG_ASSERT(0); return 1; } - int compare(cmp_item *c) + int compare(cmp_item *ci) { - cmp_item_string *cmp= (cmp_item_string *)c; - return sortcmp(value_res, cmp->value_res, cmp_charset); + cmp_item_string *l_cmp= (cmp_item_string *) ci; + return sortcmp(value_res, l_cmp->value_res, cmp_charset); } cmp_item *make_same() { @@ -1364,7 +1364,7 @@ public: Item_cond_and() :Item_cond() {} Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {} Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {} - Item_cond_and(List &list): Item_cond(list) {} + Item_cond_and(List &list_arg): Item_cond(list_arg) {} enum Functype functype() const { return COND_AND_FUNC; } longlong val_int(); const char *func_name() const { return "and"; } @@ -1386,7 +1386,7 @@ public: Item_cond_or() :Item_cond() {} Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {} Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {} - Item_cond_or(List &list): Item_cond(list) {} + Item_cond_or(List &list_arg): Item_cond(list_arg) {} enum Functype functype() const { return COND_OR_FUNC; } longlong val_int(); const char *func_name() const { return "or"; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 601d777d457..a70c221bfe6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2348,7 +2348,7 @@ longlong Item_func_locate::val_int() b->ptr(), b->length(), &match, 1)) return 0; - return (longlong) match.mblen + start0 + 1; + return (longlong) match.mb_len + start0 + 1; } @@ -3138,9 +3138,9 @@ longlong Item_master_pos_wait::val_int() null_value = 1; return 0; } +#ifdef HAVE_REPLICATION longlong pos = (ulong)args[1]->val_int(); longlong timeout = (arg_count==3) ? args[2]->val_int() : 0 ; -#ifdef HAVE_REPLICATION if ((event_count = active_mi->rli.wait_for_pos(thd, log_name, pos, timeout)) == -2) { null_value = 1; @@ -3687,7 +3687,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, bool -Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type, +Item_func_set_user_var::update_hash(void *ptr, uint length, + Item_result res_type, CHARSET_INFO *cs, Derivation dv, bool unsigned_arg) { @@ -3696,9 +3697,9 @@ Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type, result type of the variable */ if ((null_value= args[0]->null_value) && null_item) - type= entry->type; // Don't change type of item + res_type= entry->type; // Don't change type of item if (::update_hash(entry, (null_value= args[0]->null_value), - ptr, length, type, cs, dv, unsigned_arg)) + ptr, length, res_type, cs, dv, unsigned_arg)) { current_thd->fatal_error(); // Probably end of memory null_value= 1; @@ -4851,8 +4852,9 @@ longlong Item_func_row_count::val_int() } -Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name) - :Item_func(), context(context_arg), m_name(name), m_sp(NULL), +Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, + sp_name *name_arg) + :Item_func(), context(context_arg), m_name(name_arg), m_sp(NULL), result_field(NULL) { maybe_null= 1; @@ -4862,8 +4864,8 @@ Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name) Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, - sp_name *name, List &list) - :Item_func(list), context(context_arg), m_name(name), m_sp(NULL), + sp_name *name_arg, List &list) + :Item_func(list), context(context_arg), m_name(name_arg), m_sp(NULL), result_field(NULL) { maybe_null= 1; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index c5200e26cb7..22a4675c116 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -699,8 +699,9 @@ double Item_func_glength::val_real() null_value= (!swkb || !(geom= Geometry::construct(&buffer, - swkb->ptr(), swkb->length())) || - geom->length(&res)); + swkb->ptr(), + swkb->length())) || + geom->geom_length(&res)); return res; } diff --git a/sql/item_row.h b/sql/item_row.h index d6dd4371372..f3133732bb4 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -72,7 +72,7 @@ public: Item *transform(Item_transformer transformer, byte *arg); uint cols() { return arg_count; } - Item* el(uint i) { return items[i]; } + Item* element_index(uint i) { return items[i]; } Item** addr(uint i) { return items + i; } bool check_cols(uint c); bool null_inside() { return with_null; }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b4c4defd655..850cef9d5be 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -38,15 +38,6 @@ C_MODE_END String my_empty_string("",default_charset_info); -static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, - const char *fname) -{ - my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), - c1.collation->name, c1.derivation_name(), - c2.collation->name, c2.derivation_name(), - fname); -} - String *Item_str_func::check_well_formed_result(String *str) { @@ -3211,15 +3202,17 @@ String *Item_func_uuid::val_str(String *str) int i; if (my_gethwaddr(mac)) { + /* purecov: begin inspected */ /* generating random "hardware addr" and because specs explicitly specify that it should NOT correlate with a clock_seq value (initialized random below), we use a separate randominit() here */ - randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)query_id); + randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)global_query_id); for (i=0; i < (int)sizeof(mac); i++) mac[i]=(uchar)(my_rnd(&uuid_rand)*255); + /* purecov: end */ } s=clock_seq_and_node_str+sizeof(clock_seq_and_node_str)-1; for (i=sizeof(mac)-1 ; i>=0 ; i--) @@ -3227,7 +3220,7 @@ String *Item_func_uuid::val_str(String *str) *--s=_dig_vec_lower[mac[i] & 15]; *--s=_dig_vec_lower[mac[i] >> 4]; } - randominit(&uuid_rand, tmp + (ulong)start_time, + randominit(&uuid_rand, tmp + (ulong) server_start_time, tmp + thd->status_var.bytes_sent); set_clock_seq_str(); } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index bffecb3c84c..b048f01de18 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -229,11 +229,11 @@ bool Item_subselect::const_item() const return const_item_cache; } -Item *Item_subselect::get_tmp_table_item(THD *thd) +Item *Item_subselect::get_tmp_table_item(THD *thd_arg) { if (!with_sum_func && !const_item()) return new Item_field(result_field); - return copy_or_same(thd); + return copy_or_same(thd_arg); } void Item_subselect::update_used_tables() @@ -549,13 +549,13 @@ void Item_exists_subselect::print(String *str) } -bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit) +bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit_arg) { - if (unit->fake_select_lex && - unit->fake_select_lex->test_limit()) + if (unit_arg->fake_select_lex && + unit_arg->fake_select_lex->test_limit()) return(1); - SELECT_LEX *sl= unit->first_select(); + SELECT_LEX *sl= unit_arg->first_select(); for (; sl; sl= sl->next_select()) { if (sl->test_limit()) @@ -827,7 +827,6 @@ Item_subselect::trans_res Item_in_subselect::single_value_transformer(JOIN *join, Comp_creator *func) { - Item_subselect::trans_res result= RES_ERROR; SELECT_LEX *select_lex= join->select_lex; DBUG_ENTER("Item_in_subselect::single_value_transformer"); @@ -925,7 +924,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, if (!substitution) { //first call for this unit - SELECT_LEX_UNIT *unit= select_lex->master_unit(); + SELECT_LEX_UNIT *master_unit= select_lex->master_unit(); substitution= optimizer; SELECT_LEX *current= thd->lex->current_select, *up; @@ -948,7 +947,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, (char *)"", (char *)in_left_expr_name); - unit->uncacheable|= UNCACHEABLE_DEPENDENT; + master_unit->uncacheable|= UNCACHEABLE_DEPENDENT; } select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; @@ -1131,7 +1130,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) if (!substitution) { //first call for this unit - SELECT_LEX_UNIT *unit= select_lex->master_unit(); + SELECT_LEX_UNIT *master_unit= select_lex->master_unit(); substitution= optimizer; SELECT_LEX *current= thd->lex->current_select, *up; @@ -1147,7 +1146,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) optimizer->keep_top_level_cache(); thd->lex->current_select= current; - unit->uncacheable|= UNCACHEABLE_DEPENDENT; + master_unit->uncacheable|= UNCACHEABLE_DEPENDENT; } select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; @@ -1170,7 +1169,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) { DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed); if (select_lex->ref_pointer_array[i]-> - check_cols(left_expr->el(i)->cols())) + check_cols(left_expr->element_index(i)->cols())) DBUG_RETURN(RES_ERROR); Item *item_eq= new Item_func_eq(new @@ -1237,7 +1236,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) Item *item, *item_isnull; DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed); if (select_lex->ref_pointer_array[i]-> - check_cols(left_expr->el(i)->cols())) + check_cols(left_expr->element_index(i)->cols())) DBUG_RETURN(RES_ERROR); item= new Item_func_eq(new @@ -1433,14 +1432,14 @@ void Item_in_subselect::print(String *str) } -bool Item_in_subselect::fix_fields(THD *thd, Item **ref) +bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) { bool result = 0; - if(thd->lex->view_prepare_mode && left_expr && !left_expr->fixed) - result = left_expr->fix_fields(thd, &left_expr); + if (thd_arg->lex->view_prepare_mode && left_expr && !left_expr->fixed) + result = left_expr->fix_fields(thd_arg, &left_expr); - return result || Item_subselect::fix_fields(thd, ref); + return result || Item_subselect::fix_fields(thd_arg, ref); } @@ -1479,13 +1478,13 @@ void subselect_engine::set_thd(THD *thd_arg) subselect_single_select_engine:: subselect_single_select_engine(st_select_lex *select, - select_subselect *result, - Item_subselect *item) - :subselect_engine(item, result), + select_subselect *result_arg, + Item_subselect *item_arg) + :subselect_engine(item_arg, result_arg), prepared(0), optimized(0), executed(0), select_lex(select), join(0) { - select_lex->master_unit()->item= item; + select_lex->master_unit()->item= item_arg; } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index f1be99353cc..90c3ddd66e8 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -163,7 +163,7 @@ public: void fix_length_and_dec(); uint cols(); - Item* el(uint i) { return my_reinterpret_cast(Item*)(row[i]); } + Item* element_index(uint i) { return my_reinterpret_cast(Item*)(row[i]); } Item** addr(uint i) { return (Item**)row + i; } bool check_cols(uint c); bool null_inside(); @@ -474,10 +474,10 @@ class subselect_indexsubquery_engine: public subselect_uniquesubquery_engine public: // constructor can assign THD because it will be called after JOIN::prepare - subselect_indexsubquery_engine(THD *thd, st_join_table *tab_arg, + subselect_indexsubquery_engine(THD *thd_arg, st_join_table *tab_arg, Item_subselect *subs, Item *where, bool chk_null) - :subselect_uniquesubquery_engine(thd, tab_arg, subs, where), + :subselect_uniquesubquery_engine(thd_arg, tab_arg, subs, where), check_null(chk_null) {} int exec(bool full_scan); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 9de49df067c..539ed66ed62 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1154,7 +1154,7 @@ double Item_sum_avg::val_real() my_decimal *Item_sum_avg::val_decimal(my_decimal *val) { - my_decimal sum, cnt; + my_decimal sum_buff, cnt; const my_decimal *sum_dec; DBUG_ASSERT(fixed == 1); if (!count) @@ -1162,7 +1162,7 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val) null_value=1; return NULL; } - sum_dec= Item_sum_sum::val_decimal(&sum); + sum_dec= Item_sum_sum::val_decimal(&sum_buff); int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &cnt); my_decimal_div(E_DEC_FATAL_ERROR, val, sum_dec, &cnt, prec_increment); return val; @@ -1672,7 +1672,7 @@ bool Item_sum_min::add() break; case DECIMAL_RESULT: { - my_decimal value, *val= args[0]->val_decimal(&value); + my_decimal value_buff, *val= args[0]->val_decimal(&value_buff); if (!args[0]->null_value && (null_value || (my_decimal_cmp(&sum_dec, val) > 0))) { @@ -1736,7 +1736,7 @@ bool Item_sum_max::add() break; case DECIMAL_RESULT: { - my_decimal value, *val= args[0]->val_decimal(&value); + my_decimal value_buff, *val= args[0]->val_decimal(&value_buff); if (!args[0]->null_value && (null_value || (my_decimal_cmp(val, &sum_dec) > 0))) { @@ -1901,7 +1901,7 @@ void Item_sum_hybrid::reset_field() } case DECIMAL_RESULT: { - my_decimal value, *arg_dec= args[0]->val_decimal(&value); + my_decimal value_buff, *arg_dec= args[0]->val_decimal(&value_buff); if (maybe_null) { @@ -2580,11 +2580,11 @@ bool Item_sum_count_distinct::setup(THD *thd) for (tree_key_length= 0; field < field_end; ++field) { Field *f= *field; - enum enum_field_types type= f->type(); + enum enum_field_types f_type= f->type(); tree_key_length+= f->pack_length(); - if ((type == MYSQL_TYPE_VARCHAR) || - !f->binary() && (type == MYSQL_TYPE_STRING || - type == MYSQL_TYPE_VAR_STRING)) + if ((f_type == MYSQL_TYPE_VARCHAR) || + !f->binary() && (f_type == MYSQL_TYPE_STRING || + f_type == MYSQL_TYPE_VAR_STRING)) { all_binary= FALSE; break; @@ -3167,8 +3167,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, void Item_func_group_concat::cleanup() { - THD *thd= current_thd; - DBUG_ENTER("Item_func_group_concat::cleanup"); Item_sum::cleanup(); @@ -3177,7 +3175,7 @@ void Item_func_group_concat::cleanup() { char warn_buff[MYSQL_ERRMSG_SIZE]; sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values); - warning->set_msg(thd, warn_buff); + warning->set_msg(current_thd, warn_buff); warning= 0; } @@ -3207,8 +3205,7 @@ void Item_func_group_concat::cleanup() warning= 0; } } - DBUG_ASSERT(tree == 0); - DBUG_ASSERT(warning == 0); + DBUG_ASSERT(tree == 0 && warning == 0); } DBUG_VOID_RETURN; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index ca593664299..3726155a478 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1176,14 +1176,14 @@ String* Item_func_dayname::val_str(String* str) { DBUG_ASSERT(fixed == 1); uint weekday=(uint) val_int(); // Always Item_func_daynr() - const char *name; + const char *day_name; THD *thd= current_thd; if (null_value) return (String*) 0; - name= thd->variables.lc_time_names->day_names->type_names[weekday]; - str->set(name, strlen(name), system_charset_info); + day_name= thd->variables.lc_time_names->day_names->type_names[weekday]; + str->set(day_name, strlen(day_name), system_charset_info); return str; } @@ -3308,10 +3308,10 @@ bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date) { DATE_TIME_FORMAT date_time_format; char val_buff[64], format_buff[64]; - String val_str(val_buff, sizeof(val_buff), &my_charset_bin), *val; + String val_string(val_buff, sizeof(val_buff), &my_charset_bin), *val; String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format; - val= args[0]->val_str(&val_str); + val= args[0]->val_str(&val_string); format= args[1]->val_str(&format_str); if (args[0]->null_value || args[1]->null_value) goto null_date; diff --git a/sql/log.cc b/sql/log.cc index 71bdecdc536..d04f0f0f3be 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -118,7 +118,7 @@ static int binlog_prepare(THD *thd, bool all) do nothing. just pretend we can do 2pc, so that MySQL won't switch to 1pc. - real work will be done in MYSQL_LOG::log() + real work will be done in MYSQL_LOG::log_xid() */ return 0; } @@ -132,7 +132,7 @@ static int binlog_commit(THD *thd, bool all) if (my_b_tell(trans_log) == 0) { - // we're here because trans_log was flushed in MYSQL_LOG::log() + // we're here because trans_log was flushed in MYSQL_LOG::log_xid() DBUG_RETURN(0); } if (all) @@ -759,6 +759,8 @@ int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo) 0 ok */ +#ifdef HAVE_REPLICATION + static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset) { int bytes_read; @@ -792,6 +794,7 @@ err: DBUG_RETURN(1); } +#endif /* HAVE_REPLICATION */ /* Find the position in the log-index-file for the given log name @@ -1268,8 +1271,6 @@ err: pthread_mutex_unlock(&LOCK_index); DBUG_RETURN(error); } - - #endif /* HAVE_REPLICATION */ @@ -1629,14 +1630,14 @@ bool MYSQL_LOG::write(Log_event *event_info) */ if (likely(is_open())) { - const char *local_db= event_info->get_db(); IO_CACHE *file= &log_file; #ifdef HAVE_REPLICATION /* - In the future we need to add to the following if tests like - "do the involved tables match (to be implemented) - binlog_[wild_]{do|ignore}_table?" (WL#1049)" + In the future we need to add to the following if tests like + "do the involved tables match (to be implemented) + binlog_[wild_]{do|ignore}_table?" (WL#1049)" */ + const char *local_db= event_info->get_db(); if ((thd && !(thd->options & OPTION_BIN_LOG)) || (!db_ok(local_db, binlog_do_db, binlog_ignore_db))) { @@ -2671,21 +2672,34 @@ int TC_LOG_MMAP::overflow() } /* - all access to active page is serialized but it's not a problem, as - we're assuming that fsync() will be a main bottleneck. - That is, parallelizing writes to log pages we'll decrease number of - threads waiting for a page, but then all these threads will be waiting - for a fsync() anyway + Record that transaction XID is committed on the persistent storage + + NOTES + This function is called in the middle of two-phase commit: + First all resources prepare the transaction, then tc_log->log() is called, + then all resources commit the transaction, then tc_log->unlog() is called. + + All access to active page is serialized but it's not a problem, as + we're assuming that fsync() will be a main bottleneck. + That is, parallelizing writes to log pages we'll decrease number of + threads waiting for a page, but then all these threads will be waiting + for a fsync() anyway + + IMPLEMENTATION + If tc_log == MYSQL_LOG then tc_log writes transaction to binlog and + records XID in a special Xid_log_event. + If tc_log = TC_LOG_MMAP then xid is written in a special memory-mapped + log. RETURN - 0 - error - otherwise - "cookie", a number that will be passed as an argument - to unlog() call. tc_log can define it any way it wants, - and use for whatever purposes. TC_LOG_MMAP sets it - to the position in memory where xid was logged to. + 0 Error + # "cookie", a number that will be passed as an argument + to unlog() call. tc_log can define it any way it wants, + and use for whatever purposes. TC_LOG_MMAP sets it + to the position in memory where xid was logged to. */ -int TC_LOG_MMAP::log(THD *thd, my_xid xid) +int TC_LOG_MMAP::log_xid(THD *thd, my_xid xid) { int err; PAGE *p; @@ -2794,6 +2808,7 @@ int TC_LOG_MMAP::sync() erase xid from the page, update page free space counters/pointers. cookie points directly to the memory where xid was logged */ + void TC_LOG_MMAP::unlog(ulong cookie, my_xid xid) { PAGE *p=pages+(cookie/tc_log_page_size); @@ -3036,7 +3051,7 @@ void TC_LOG_BINLOG::close() 0 - error 1 - success */ -int TC_LOG_BINLOG::log(THD *thd, my_xid xid) +int TC_LOG_BINLOG::log_xid(THD *thd, my_xid xid) { Xid_log_event xle(thd, xid); IO_CACHE *trans_log= (IO_CACHE*)thd->ha_data[binlog_hton.slot]; diff --git a/sql/log_event.cc b/sql/log_event.cc index 0d7ef7e8f2a..416c0a7b3a8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -270,11 +270,14 @@ append_query_string(CHARSET_INFO *csinfo, } #endif + /* Prints a "session_var=value" string. Used by mysqlbinlog to print some SET commands just before it prints a query. */ +#ifdef MYSQL_CLIENT + static void print_set_option(FILE* file, uint32 bits_changed, uint32 option, uint32 flags, const char* name, bool* need_comma) { @@ -286,6 +289,7 @@ static void print_set_option(FILE* file, uint32 bits_changed, uint32 option, *need_comma= 1; } } +#endif /************************************************************************** Log_event methods (= the parent class of all events) @@ -2990,7 +2994,6 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, thd->main_lex.select_lex.context.resolve_in_table_list_only(&tables); set_fields(tables.db, field_list, &thd->main_lex.select_lex.context); thd->variables.pseudo_thread_id= thread_id; - List set_fields; if (net) { // mysql_load will use thd->net to read the file @@ -3001,10 +3004,11 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, thd->net.pkt_nr = net->pkt_nr; } /* - It is safe to use set_fields twice because we are not going to + It is safe to use tmp_list twice because we are not going to update it inside mysql_load(). */ - if (mysql_load(thd, &ex, &tables, field_list, set_fields, set_fields, + List tmp_list; + if (mysql_load(thd, &ex, &tables, field_list, tmp_list, tmp_list, handle_dup, ignore, net != 0)) thd->query_error= 1; if (thd->cuted_fields) diff --git a/sql/log_event.h b/sql/log_event.h index 247e1962776..0f702e08e25 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -841,6 +841,8 @@ public: bool write(IO_CACHE* file) { return(false); }; virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; } +#else + Muted_query_log_event() {} #endif }; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index c5ec6f02cdd..632de67af14 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -58,10 +58,10 @@ typedef ulonglong nested_join_map; /* query_id */ typedef ulonglong query_id_t; -extern query_id_t query_id; +extern query_id_t global_query_id; /* increment query_id and return it. */ -inline query_id_t next_query_id() { return query_id++; } +inline query_id_t next_query_id() { return global_query_id++; } /* useful constants */ extern const key_map key_map_empty; @@ -154,7 +154,7 @@ MY_LOCALE *my_locale_by_name(const char *name); Feel free to raise this by the smallest amount you can to get the "execution_constants" test to pass. */ -#define STACK_MIN_SIZE 10788 // Abort if less stack during eval. +#define STACK_MIN_SIZE 12000 // Abort if less stack during eval. #define STACK_MIN_SIZE_FOR_OPEN 1024*80 #define STACK_BUFF_ALLOC 256 // For stack overrun checks @@ -1186,7 +1186,7 @@ void my_dbopt_free(void); External variables */ -extern time_t start_time; +extern time_t server_start_time; extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH], mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[], def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d8d75a28b75..2db3db08a2c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -322,9 +322,13 @@ static char *my_bind_addr_str; static char *default_collation_name; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; static char mysql_data_home_buff[2]; -static struct passwd *user_info; static I_List thread_cache; +#ifndef EMBEDDED_LIBRARY +static struct passwd *user_info; +static pthread_t select_thread; +#endif + static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; #ifdef HAVE_BERKELEY_DB @@ -398,7 +402,7 @@ ulong slave_net_timeout, slave_trans_retries; ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; ulong query_cache_size=0; ulong refresh_version, flush_version; /* Increments on each reload */ -query_id_t query_id; +query_id_t global_query_id; ulong aborted_threads, aborted_connects; ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size; ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use; @@ -429,7 +433,7 @@ ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; double log_10[32]; /* 10 potences */ -time_t start_time; +time_t server_start_time; char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30]; char *default_tz_name; @@ -544,7 +548,6 @@ static char **defaults_argv; static char *opt_bin_logname; static my_socket unix_sock,ip_sock; -static pthread_t select_thread; struct rand_struct sql_rand; // used by sql_class.cc:THD::THD() /* OS specific variables */ @@ -627,7 +630,6 @@ struct st_VioSSLFd *ssl_acceptor_fd; /* Function declarations */ -static void start_signal_handler(void); pthread_handler_t signal_hand(void *arg); static void mysql_init_variables(void); static void get_options(int argc,char **argv); @@ -638,7 +640,6 @@ static void fix_paths(void); pthread_handler_t handle_connections_sockets(void *arg); pthread_handler_t kill_server_thread(void *arg); static void bootstrap(FILE *file); -static void close_server_sock(); static bool read_init_file(char *file_name); #ifdef __NT__ pthread_handler_t handle_connections_namedpipes(void *arg); @@ -649,10 +650,16 @@ pthread_handler_t handle_connections_shared_memory(void *arg); pthread_handler_t handle_slave(void *arg); static ulong find_bit_type(const char *x, TYPELIB *bit_lib); static void clean_up(bool print_message); +static int test_if_case_insensitive(const char *dir_name); + +#ifndef EMBEDDED_LIBRARY +static void start_signal_handler(void); +static void close_server_sock(); static void clean_up_mutexes(void); static void wait_for_signal_thread_to_end(void); -static int test_if_case_insensitive(const char *dir_name); static void create_pid_file(); +#endif + #ifndef EMBEDDED_LIBRARY /**************************************************************************** @@ -841,7 +848,6 @@ static void close_connections(void) DBUG_PRINT("quit",("close_connections thread")); DBUG_VOID_RETURN; } -#endif /*EMBEDDED_LIBRARY*/ static void close_server_sock() @@ -884,6 +890,8 @@ static void close_server_sock() #endif } +#endif /*EMBEDDED_LIBRARY*/ + void kill_mysql(void) { @@ -969,7 +977,7 @@ static void __cdecl kill_server(int sig_ptr) kill_in_progress=TRUE; abort_loop=1; // This should be set if (sig != 0) // 0 is not a valid signal number - my_sigset(sig,SIG_IGN); + my_sigset(sig, SIG_IGN); /* purify inspected */ if (sig == MYSQL_KILL_SIGNAL || sig == 0) sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname); else @@ -1190,6 +1198,8 @@ void clean_up(bool print_message) } /* clean_up */ +#ifndef EMBEDDED_LIBRARY + /* This is mainly needed when running with purify, but it's still nice to know that all child threads have died when mysqld exits @@ -1258,6 +1268,9 @@ static void clean_up_mutexes() (void) pthread_cond_destroy(&COND_manager); } +#endif /*EMBEDDED_LIBRARY*/ + + /**************************************************************************** ** Init IP and UNIX socket ****************************************************************************/ @@ -1292,7 +1305,7 @@ static void set_ports() static struct passwd *check_user(const char *user) { #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - struct passwd *user_info; + struct passwd *tmp_user_info; uid_t user_id= geteuid(); // Don't bother if we aren't superuser @@ -1300,12 +1313,14 @@ static struct passwd *check_user(const char *user) { if (user) { - // Don't give a warning, if real user is same as given with --user - user_info= getpwnam(user); - if ((!user_info || user_id != user_info->pw_uid) && + /* Don't give a warning, if real user is same as given with --user */ + /* purecov: begin tested */ + tmp_user_info= getpwnam(user); + if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) && global_system_variables.log_warnings) sql_print_warning( "One can only use the --user switch if running as root\n"); + /* purecov: end */ } return NULL; } @@ -1318,23 +1333,25 @@ static struct passwd *check_user(const char *user) } return NULL; } + /* purecov: begin tested */ if (!strcmp(user,"root")) return NULL; // Avoid problem with dynamic libraries - if (!(user_info= getpwnam(user))) + if (!(tmp_user_info= getpwnam(user))) { // Allow a numeric uid to be used const char *pos; for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ; if (*pos) // Not numeric id goto err; - if (!(user_info= getpwuid(atoi(user)))) + if (!(tmp_user_info= getpwuid(atoi(user)))) goto err; else - return user_info; + return tmp_user_info; } else - return user_info; + return tmp_user_info; + /* purecov: end */ err: sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); @@ -1343,10 +1360,11 @@ err: return NULL; } -static void set_user(const char *user, struct passwd *user_info) +static void set_user(const char *user, struct passwd *user_info_arg) { + /* purecov: begin tested */ #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - DBUG_ASSERT(user_info != 0); + DBUG_ASSERT(user_info_arg != 0); #ifdef HAVE_INITGROUPS /* We can get a SIGSEGV when calling initgroups() on some systems when NSS @@ -1355,33 +1373,34 @@ static void set_user(const char *user, struct passwd *user_info) output a specific message to help the user resolve this problem. */ calling_initgroups= TRUE; - initgroups((char*) user, user_info->pw_gid); + initgroups((char*) user, user_info_arg->pw_gid); calling_initgroups= FALSE; #endif - if (setgid(user_info->pw_gid) == -1) + if (setgid(user_info_arg->pw_gid) == -1) { sql_perror("setgid"); unireg_abort(1); } - if (setuid(user_info->pw_uid) == -1) + if (setuid(user_info_arg->pw_uid) == -1) { sql_perror("setuid"); unireg_abort(1); } #endif + /* purecov: end */ } -static void set_effective_user(struct passwd *user_info) +static void set_effective_user(struct passwd *user_info_arg) { #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - DBUG_ASSERT(user_info != 0); - if (setregid((gid_t)-1, user_info->pw_gid) == -1) + DBUG_ASSERT(user_info_arg != 0); + if (setregid((gid_t)-1, user_info_arg->pw_gid) == -1) { sql_perror("setregid"); unireg_abort(1); } - if (setreuid((uid_t)-1, user_info->pw_uid) == -1) + if (setreuid((uid_t)-1, user_info_arg->pw_uid) == -1) { sql_perror("setreuid"); unireg_abort(1); @@ -1728,6 +1747,7 @@ extern "C" sig_handler abort_thread(int sig __attribute__((unused))) the signal thread is ready before continuing ******************************************************************************/ + #if defined(__WIN__) || defined(OS2) static void init_signals(void) { @@ -1968,6 +1988,7 @@ static void init_signals(void) } + static void start_signal_handler(void) { // Save vm id of this process @@ -2019,6 +2040,7 @@ static void init_signals(void) signal_thread = pthread_self(); } + static void start_signal_handler(void) {} @@ -2130,6 +2152,8 @@ mysqld that is not statically linked.\n"); #define SA_NODEFER 0 #endif +#ifndef EMBEDDED_LIBRARY + static void init_signals(void) { sigset_t set; @@ -2202,7 +2226,6 @@ static void init_signals(void) } -#ifndef EMBEDDED_LIBRARY static void start_signal_handler(void) { int error; @@ -2370,11 +2393,11 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) } return(0); /* purecov: deadcode */ } -#endif /*!EMBEDDED_LIBRARY*/ static void check_data_home(const char *path) {} +#endif /*!EMBEDDED_LIBRARY*/ #endif /* __WIN__*/ @@ -2437,6 +2460,7 @@ static int my_message_sql(uint error, const char *str, myf MyFlags) } +#ifndef EMBEDDED_LIBRARY static void *my_str_malloc_mysqld(size_t size) { return my_malloc(size, MYF(MY_FAE)); @@ -2447,6 +2471,7 @@ static void my_str_free_mysqld(void *ptr) { my_free((gptr)ptr, MYF(MY_FAE)); } +#endif /* EMBEDDED_LIBRARY */ #ifdef __WIN__ @@ -2579,7 +2604,7 @@ static int init_common_variables(const char *conf_file_name, int argc, tzset(); // Set tzname max_system_variables.pseudo_thread_id= (ulong)~0; - start_time=time((time_t*) 0); + server_start_time= time((time_t*) 0); if (init_thread_environment()) return 1; mysql_init_variables(); @@ -2595,7 +2620,7 @@ static int init_common_variables(const char *conf_file_name, int argc, #ifdef HAVE_TZNAME { struct tm tm_tmp; - localtime_r(&start_time,&tm_tmp); + localtime_r(&server_start_time,&tm_tmp); strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0], sizeof(system_time_zone)-1); @@ -2949,6 +2974,8 @@ static void openssl_lock(int mode, openssl_lock_t *lock, const char *file, #endif /* HAVE_OPENSSL */ +#ifndef EMBEDDED_LIBRARY + static void init_ssl() { #ifdef HAVE_OPENSSL @@ -2974,6 +3001,7 @@ static void init_ssl() #endif /* HAVE_OPENSSL */ } +#endif /* EMBEDDED_LIBRARY */ static int init_server_components() { @@ -2985,7 +3013,7 @@ static int init_server_components() query_cache_set_min_res_unit(query_cache_min_res_unit); query_cache_init(); query_cache_resize(query_cache_size); - randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); + randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2); reset_floating_point_exceptions(); init_thr_lock(); #ifdef HAVE_REPLICATION @@ -3214,6 +3242,7 @@ server."); } +#ifndef EMBEDDED_LIBRARY static void create_maintenance_thread() { if ( @@ -3231,7 +3260,6 @@ static void create_maintenance_thread() static void create_shutdown_thread() { -#if !defined(EMBEDDED_LIBRARY) #ifdef __WIN__ hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name); pthread_t hThread; @@ -3247,9 +3275,9 @@ static void create_shutdown_thread() if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) sql_print_warning("Can't create thread to handle shutdown requests"); #endif -#endif // EMBEDDED_LIBRARY } +#endif /* EMBEDDED_LIBRARY */ #if defined(__NT__) || defined(HAVE_SMEM) static void handle_connections_methods() @@ -6384,7 +6412,7 @@ static void mysql_init_variables(void) protocol_version= PROTOCOL_VERSION; what_to_log= ~ (1L << (uint) COM_TIME); refresh_version= flush_version= 1L; /* Increments on each reload */ - query_id= thread_id= 1L; + global_query_id= thread_id= 1L; strmov(server_version, MYSQL_SERVER_VERSION); myisam_recover_options_str= sql_mode_str= "OFF"; myisam_stats_method_str= "nulls_unequal"; @@ -7475,6 +7503,8 @@ static int test_if_case_insensitive(const char *dir_name) /* Create file to store pid number */ +#ifndef EMBEDDED_LIBRARY + static void create_pid_file() { File file; @@ -7494,7 +7524,7 @@ static void create_pid_file() sql_perror("Can't start server: can't create PID file"); exit(1); } - +#endif /* EMBEDDED_LIBRARY */ /* Clear most status variables */ void refresh_status(THD *thd) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index e84b2266e82..53f9c8a276d 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -222,6 +222,8 @@ my_bool net_realloc(NET *net, ulong length) -1 Don't know if data is ready or not */ +#if !defined(EMBEDDED_LIBRARY) + static int net_data_is_ready(my_socket sd) { #ifdef HAVE_POLL @@ -256,9 +258,10 @@ static int net_data_is_ready(my_socket sd) return 0; else return test(res ? FD_ISSET(sd, &sfds) : 0); -#endif +#endif /* HAVE_POLL */ } +#endif /* EMBEDDED_LIBRARY */ /* Remove unwanted characters from connection @@ -283,8 +286,11 @@ static int net_data_is_ready(my_socket sd) void net_clear(NET *net) { +#if !defined(EMBEDDED_LIBRARY) int count, ready; +#endif DBUG_ENTER("net_clear"); + #if !defined(EMBEDDED_LIBRARY) while((ready= net_data_is_ready(net->vio->sd)) > 0) { diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 545f01d4755..b3cb140c9a2 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -497,9 +497,6 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, double read_time); static TRP_GROUP_MIN_MAX *get_best_group_min_max(PARAM *param, SEL_TREE *tree); -static int get_index_merge_params(PARAM *param, key_map& needed_reg, - SEL_IMERGE *imerge, double *read_time, - ha_rows* imerge_rows); static double get_index_only_read_time(const PARAM* param, ha_rows records, int keynr); @@ -509,7 +506,6 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map, static void print_ror_scans_arr(TABLE *table, const char *msg, struct st_ror_scan_info **start, struct st_ror_scan_info **end); -static void print_rowid(byte* val, int len); static void print_quick(QUICK_SELECT_I *quick, const key_map *needed_reg); #endif @@ -821,7 +817,7 @@ QUICK_SELECT_I::QUICK_SELECT_I() QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, bool no_alloc, MEM_ROOT *parent_alloc) - :dont_free(0),error(0),free_file(0),in_range(0),cur_range(NULL),range(0) + :dont_free(0),error(0),free_file(0),in_range(0),cur_range(NULL),last_range(0) { sorted= 0; index= key_nr; @@ -1235,13 +1231,12 @@ int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, byte *val1, byte *val2) int QUICK_ROR_UNION_SELECT::reset() { - QUICK_SELECT_I* quick; + QUICK_SELECT_I *quick; int error; DBUG_ENTER("QUICK_ROR_UNION_SELECT::reset"); have_prev_rowid= FALSE; if (!scans_inited) { - QUICK_SELECT_I *quick; List_iterator_fast it(quick_selects); while ((quick= it++)) { @@ -6578,7 +6573,7 @@ int QUICK_RANGE_SELECT::reset() byte *mrange_buff; DBUG_ENTER("QUICK_RANGE_SELECT::reset"); next=0; - range= NULL; + last_range= NULL; in_range= FALSE; cur_range= (QUICK_RANGE**) ranges.buffer; @@ -6696,23 +6691,23 @@ int QUICK_RANGE_SELECT::get_next() { start_key= &mrange_slot->start_key; end_key= &mrange_slot->end_key; - range= *(cur_range++); + last_range= *(cur_range++); - start_key->key= (const byte*) range->min_key; - start_key->length= range->min_length; - start_key->flag= ((range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : - (range->flag & EQ_RANGE) ? + start_key->key= (const byte*) last_range->min_key; + start_key->length= last_range->min_length; + start_key->flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : + (last_range->flag & EQ_RANGE) ? HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT); - end_key->key= (const byte*) range->max_key; - end_key->length= range->max_length; + end_key->key= (const byte*) last_range->max_key; + end_key->length= last_range->max_length; /* We use HA_READ_AFTER_KEY here because if we are reading on a key prefix. We want to find all keys with this prefix. */ - end_key->flag= (range->flag & NEAR_MAX ? HA_READ_BEFORE_KEY : + end_key->flag= (last_range->flag & NEAR_MAX ? HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY); - mrange_slot->range_flag= range->flag; + mrange_slot->range_flag= last_range->flag; } result= file->read_multi_range_first(&mrange, multi_range, count, @@ -6762,7 +6757,7 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, byte *cur_prefix) { int result; key_range start_key, end_key; - if (range) + if (last_range) { /* Read the next record in the same range with prefix after cur_prefix. */ DBUG_ASSERT(cur_prefix != 0); @@ -6776,35 +6771,35 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, byte *cur_prefix) if (count == 0) { /* Ranges have already been used up before. None is left for read. */ - range= 0; + last_range= 0; DBUG_RETURN(HA_ERR_END_OF_FILE); } - range= *(cur_range++); + last_range= *(cur_range++); - start_key.key= (const byte*) range->min_key; - start_key.length= min(range->min_length, prefix_length); - start_key.flag= ((range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : - (range->flag & EQ_RANGE) ? + start_key.key= (const byte*) last_range->min_key; + start_key.length= min(last_range->min_length, prefix_length); + start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : + (last_range->flag & EQ_RANGE) ? HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT); - end_key.key= (const byte*) range->max_key; - end_key.length= min(range->max_length, prefix_length); + end_key.key= (const byte*) last_range->max_key; + end_key.length= min(last_range->max_length, prefix_length); /* We use READ_AFTER_KEY here because if we are reading on a key prefix we want to find all keys with this prefix */ - end_key.flag= (range->flag & NEAR_MAX ? HA_READ_BEFORE_KEY : + end_key.flag= (last_range->flag & NEAR_MAX ? HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY); - result= file->read_range_first(range->min_length ? &start_key : 0, - range->max_length ? &end_key : 0, - test(range->flag & EQ_RANGE), + result= file->read_range_first(last_range->min_length ? &start_key : 0, + last_range->max_length ? &end_key : 0, + test(last_range->flag & EQ_RANGE), sorted); - if (range->flag == (UNIQUE_RANGE | EQ_RANGE)) - range=0; // Stop searching + if (last_range->flag == (UNIQUE_RANGE | EQ_RANGE)) + last_range= 0; // Stop searching if (result != HA_ERR_END_OF_FILE) DBUG_RETURN(result); - range=0; // No matching rows; go to next range + last_range= 0; // No matching rows; go to next range } } @@ -6818,11 +6813,11 @@ int QUICK_RANGE_SELECT_GEOM::get_next() for (;;) { int result; - if (range) + if (last_range) { // Already read through key - result= file->index_next_same(record, (byte*) range->min_key, - range->min_length); + result= file->index_next_same(record, (byte*) last_range->min_key, + last_range->min_length); if (result != HA_ERR_END_OF_FILE) DBUG_RETURN(result); } @@ -6831,18 +6826,18 @@ int QUICK_RANGE_SELECT_GEOM::get_next() if (count == 0) { /* Ranges have already been used up before. None is left for read. */ - range= 0; + last_range= 0; DBUG_RETURN(HA_ERR_END_OF_FILE); } - range= *(cur_range++); + last_range= *(cur_range++); result= file->index_read(record, - (byte*) range->min_key, - range->min_length, - (ha_rkey_function)(range->flag ^ GEOM_FLAG)); + (byte*) last_range->min_key, + last_range->min_length, + (ha_rkey_function)(last_range->flag ^ GEOM_FLAG)); if (result != HA_ERR_KEY_NOT_FOUND) DBUG_RETURN(result); - range=0; // Not found, to next range + last_range= 0; // Not found, to next range } } @@ -6867,7 +6862,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next() bool QUICK_RANGE_SELECT::row_in_ranges() { - QUICK_RANGE *range; + QUICK_RANGE *res; uint min= 0; uint max= ranges.elements - 1; uint mid= (max + min)/2; @@ -6883,8 +6878,8 @@ bool QUICK_RANGE_SELECT::row_in_ranges() max= mid; mid= (min + max) / 2; } - range= *(QUICK_RANGE**)dynamic_array_ptr(&ranges, mid); - return (!cmp_next(range) && !cmp_prev(range)); + res= *(QUICK_RANGE**)dynamic_array_ptr(&ranges, mid); + return (!cmp_next(res) && !cmp_prev(res)); } /* @@ -6898,14 +6893,14 @@ bool QUICK_RANGE_SELECT::row_in_ranges() */ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUICK_RANGE_SELECT *q, - uint used_key_parts) + uint used_key_parts_arg) : QUICK_RANGE_SELECT(*q), rev_it(rev_ranges) { QUICK_RANGE *r; QUICK_RANGE **pr= (QUICK_RANGE**)ranges.buffer; - QUICK_RANGE **last_range= pr + ranges.elements; - for (; pr!=last_range; pr++) + QUICK_RANGE **end_range= pr + ranges.elements; + for (; pr!=end_range; pr++) rev_ranges.push_front(*pr); /* Remove EQ_RANGE flag for keys that are not using the full key */ @@ -6939,11 +6934,11 @@ int QUICK_SELECT_DESC::get_next() for (;;) { int result; - if (range) + if (last_range) { // Already read through key - result = ((range->flag & EQ_RANGE) - ? file->index_next_same(record, (byte*) range->min_key, - range->min_length) : + result = ((last_range->flag & EQ_RANGE) + ? file->index_next_same(record, (byte*) last_range->min_key, + last_range->min_length) : file->index_prev(record)); if (!result) { @@ -6954,47 +6949,49 @@ int QUICK_SELECT_DESC::get_next() DBUG_RETURN(result); } - if (!(range=rev_it++)) + if (!(last_range= rev_it++)) DBUG_RETURN(HA_ERR_END_OF_FILE); // All ranges used - if (range->flag & NO_MAX_RANGE) // Read last record + if (last_range->flag & NO_MAX_RANGE) // Read last record { int local_error; if ((local_error=file->index_last(record))) DBUG_RETURN(local_error); // Empty table - if (cmp_prev(range) == 0) + if (cmp_prev(last_range) == 0) DBUG_RETURN(0); - range=0; // No matching records; go to next range + last_range= 0; // No match; go to next range continue; } - if (range->flag & EQ_RANGE) + if (last_range->flag & EQ_RANGE) { - result = file->index_read(record, (byte*) range->max_key, - range->max_length, HA_READ_KEY_EXACT); + result= file->index_read(record, (byte*) last_range->max_key, + last_range->max_length, HA_READ_KEY_EXACT); } else { - DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range)); - result=file->index_read(record, (byte*) range->max_key, - range->max_length, - ((range->flag & NEAR_MAX) ? - HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV)); + DBUG_ASSERT(last_range->flag & NEAR_MAX || + range_reads_after_key(last_range)); + result=file->index_read(record, (byte*) last_range->max_key, + last_range->max_length, + ((last_range->flag & NEAR_MAX) ? + HA_READ_BEFORE_KEY : + HA_READ_PREFIX_LAST_OR_PREV)); } if (result) { if (result != HA_ERR_KEY_NOT_FOUND) DBUG_RETURN(result); - range=0; // Not found, to next range + last_range= 0; // Not found, to next range continue; } - if (cmp_prev(range) == 0) + if (cmp_prev(last_range) == 0) { - if (range->flag == (UNIQUE_RANGE | EQ_RANGE)) - range = 0; // Stop searching + if (last_range->flag == (UNIQUE_RANGE | EQ_RANGE)) + last_range= 0; // Stop searching DBUG_RETURN(0); // Found key is in range } - range = 0; // To next range + last_range= 0; // To next range } } @@ -9474,23 +9471,9 @@ static void print_quick(QUICK_SELECT_I *quick, const key_map *needed_reg) } -static void print_rowid(byte* val, int len) -{ - byte *pb; - DBUG_LOCK_FILE; - fputc('\"', DBUG_FILE); - for (pb= val; pb!= val + len; ++pb) - fprintf(DBUG_FILE, "%c", *pb); - fprintf(DBUG_FILE, "\", hex: "); - - for (pb= val; pb!= val + len; ++pb) - fprintf(DBUG_FILE, "%x ", *pb); - fputc('\n', DBUG_FILE); - DBUG_UNLOCK_FILE; -} - void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose) { + /* purecov: begin inspected */ fprintf(DBUG_FILE, "%*squick range select, key %s, length: %d\n", indent, "", head->key_info[index].name, max_used_key_length); @@ -9498,8 +9481,8 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose) { QUICK_RANGE *range; QUICK_RANGE **pr= (QUICK_RANGE**)ranges.buffer; - QUICK_RANGE **last_range= pr + ranges.elements; - for (; pr!=last_range; ++pr) + QUICK_RANGE **end_range= pr + ranges.elements; + for (; pr != end_range; ++pr) { fprintf(DBUG_FILE, "%*s", indent + 2, ""); range= *pr; @@ -9524,6 +9507,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose) fputs("\n",DBUG_FILE); } } + /* purecov: end */ } void QUICK_INDEX_MERGE_SELECT::dbug_dump(int indent, bool verbose) diff --git a/sql/opt_range.h b/sql/opt_range.h index f22b157df86..30d708c2991 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -300,7 +300,7 @@ protected: DYNAMIC_ARRAY ranges; /* ordered array of range ptrs */ QUICK_RANGE **cur_range; /* current element in ranges */ - QUICK_RANGE *range; + QUICK_RANGE *last_range; KEY_PART *key_parts; KEY_PART_INFO *key_part_info; int cmp_next(QUICK_RANGE *range); diff --git a/sql/password.c b/sql/password.c index 594096b6ec9..692d512de6f 100644 --- a/sql/password.c +++ b/sql/password.c @@ -473,7 +473,7 @@ scramble(char *to, const char *message, const char *password) */ my_bool -check_scramble(const char *scramble, const char *message, +check_scramble(const char *scramble_arg, const char *message, const uint8 *hash_stage2) { SHA1_CONTEXT sha1_context; @@ -486,7 +486,7 @@ check_scramble(const char *scramble, const char *message, mysql_sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); mysql_sha1_result(&sha1_context, buf); /* encrypt scramble */ - my_crypt((char *) buf, buf, (const uchar *) scramble, SCRAMBLE_LENGTH); + my_crypt((char *) buf, buf, (const uchar *) scramble_arg, SCRAMBLE_LENGTH); /* now buf supposedly contains hash_stage1: so we can get hash_stage2 */ mysql_sha1_reset(&sha1_context); mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE); @@ -496,7 +496,8 @@ check_scramble(const char *scramble, const char *message, /* - Convert scrambled password from asciiz hex string to binary form. + Convert scrambled password from asciiz hex string to binary form. + SYNOPSIS get_salt_from_password() res OUT buf to hold password. Must be at least SHA1_HASH_SIZE diff --git a/sql/protocol.cc b/sql/protocol.cc index e7a8d493341..901183fb178 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -28,8 +28,10 @@ #include static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024; -static void write_eof_packet(THD *thd, NET *net); void net_send_error_packet(THD *thd, uint sql_errno, const char *err); +#ifndef EMBEDDED_LIBRARY +static void write_eof_packet(THD *thd, NET *net); +#endif #ifndef EMBEDDED_LIBRARY bool Protocol::net_store_data(const char *from, uint length) diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 21e46e71825..6774a42fd1a 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -528,11 +528,11 @@ HOSTS"; while ((row= mysql_fetch_row(res))) { - uint32 server_id; + uint32 log_server_id; SLAVE_INFO* si, *old_si; - server_id = atoi(row[0]); + log_server_id = atoi(row[0]); if ((old_si= (SLAVE_INFO*)hash_search(&slave_list, - (byte*)&server_id,4))) + (byte*)&log_server_id,4))) si = old_si; else { @@ -542,7 +542,7 @@ HOSTS"; pthread_mutex_unlock(&LOCK_slave_list); goto err; } - si->server_id = server_id; + si->server_id = log_server_id; my_hash_insert(&slave_list, (byte*)si); } strmake(si->host, row[1], sizeof(si->host)-1); @@ -914,14 +914,14 @@ bool load_master_data(THD* thd) setting active_mi, because init_master_info() sets active_mi with defaults. */ - int error; + int error_2; if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0, (SLAVE_IO | SLAVE_SQL))) my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0)); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); - active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error); + active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error_2); /* at least in recent versions, the condition below should be false */ if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE) active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; diff --git a/sql/set_var.cc b/sql/set_var.cc index ebeffeba9bf..ed3778322b0 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -83,9 +83,6 @@ TYPELIB delay_key_write_typelib= delay_key_write_type_names, NULL }; -static int sys_check_charset(THD *thd, set_var *var); -static bool sys_update_charset(THD *thd, set_var *var); -static void sys_set_default_charset(THD *thd, enum_var_type type); static int sys_check_ftb_syntax(THD *thd, set_var *var); static bool sys_update_ftb_syntax(THD *thd, set_var * var); static void sys_default_ftb_syntax(THD *thd, enum_var_type type); @@ -1420,9 +1417,9 @@ static void fix_server_id(THD *thd, enum_var_type type) sys_var_long_ptr:: -sys_var_long_ptr(const char *name_arg, ulong *value_ptr, +sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg, sys_after_update_func after_update_arg) - :sys_var_long_ptr_global(name_arg, value_ptr, + :sys_var_long_ptr_global(name_arg, value_ptr_arg, &LOCK_global_system_variables, after_update_arg) {} @@ -1772,7 +1769,7 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) /* As there was no local variable, return the global value */ var_type= OPT_GLOBAL; } - switch (type()) { + switch (show_type()) { case SHOW_INT: { uint value; diff --git a/sql/set_var.h b/sql/set_var.h index 11de6ceafe5..9ead0b31f1f 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -56,8 +56,8 @@ public: bool check_enum(THD *thd, set_var *var, TYPELIB *enum_names); bool check_set(THD *thd, set_var *var, TYPELIB *enum_names); virtual bool update(THD *thd, set_var *var)=0; - virtual void set_default(THD *thd, enum_var_type type) {} - virtual SHOW_TYPE type() { return SHOW_UNDEF; } + virtual void set_default(THD *thd_arg, enum_var_type type) {} + virtual SHOW_TYPE show_type() { return SHOW_UNDEF; } virtual byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return 0; } virtual bool check_type(enum_var_type type) @@ -97,14 +97,16 @@ class sys_var_long_ptr_global: public sys_var_global { public: ulong *value; - sys_var_long_ptr_global(const char *name_arg, ulong *value_ptr, + sys_var_long_ptr_global(const char *name_arg, ulong *value_ptr_arg, pthread_mutex_t *guard_arg, sys_after_update_func after_update_arg= NULL) - :sys_var_global(name_arg, after_update_arg, guard_arg), value(value_ptr) {} + :sys_var_global(name_arg, after_update_arg, guard_arg), + value(value_ptr_arg) + {} bool check(THD *thd, set_var *var); bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE show_type() { return SHOW_LONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) value; } }; @@ -126,14 +128,14 @@ class sys_var_ulonglong_ptr :public sys_var { public: ulonglong *value; - sys_var_ulonglong_ptr(const char *name_arg, ulonglong *value_ptr) - :sys_var(name_arg),value(value_ptr) {} - sys_var_ulonglong_ptr(const char *name_arg, ulonglong *value_ptr, + sys_var_ulonglong_ptr(const char *name_arg, ulonglong *value_ptr_arg) + :sys_var(name_arg),value(value_ptr_arg) {} + sys_var_ulonglong_ptr(const char *name_arg, ulonglong *value_ptr_arg, sys_after_update_func func) - :sys_var(name_arg,func), value(value_ptr) {} + :sys_var(name_arg,func), value(value_ptr_arg) {} bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONGLONG; } + SHOW_TYPE show_type() { return SHOW_LONGLONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) value; } }; @@ -152,7 +154,7 @@ public: } bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_MY_BOOL; } + SHOW_TYPE show_type() { return SHOW_MY_BOOL; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) value; } bool check_update_type(Item_result type) { return 0; } @@ -184,7 +186,7 @@ public: { (*set_default_func)(thd, type); } - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) value; } bool check_update_type(Item_result type) @@ -210,7 +212,7 @@ public: { return 1; } - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) value; @@ -239,7 +241,7 @@ public: { return 1; } - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (byte*) *value; @@ -267,7 +269,7 @@ public: return check_enum(thd, var, enum_names); } bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_update_type(Item_result type) { return 0; } }; @@ -302,7 +304,7 @@ public: bool check(THD *thd, set_var *var); bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE show_type() { return SHOW_LONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -320,7 +322,7 @@ public: {} bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_HA_ROWS; } + SHOW_TYPE show_type() { return SHOW_HA_ROWS; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -340,7 +342,7 @@ public: {} bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONGLONG; } + SHOW_TYPE show_type() { return SHOW_LONGLONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_default(enum_var_type type) { @@ -366,7 +368,7 @@ public: {} bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_MY_BOOL; } + SHOW_TYPE show_type() { return SHOW_MY_BOOL; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check(THD *thd, set_var *var) { @@ -397,7 +399,7 @@ public: } bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_update_type(Item_result type) { return 0; } }; @@ -432,7 +434,7 @@ public: :sys_var_thd(name_arg), offset(offset_arg) {} bool check(THD *thd, set_var *var); -SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ @@ -470,7 +472,7 @@ public: bool update(THD *thd, set_var *var); bool check_update_type(Item_result type) { return 0; } bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } - SHOW_TYPE type() { return SHOW_MY_BOOL; } + SHOW_TYPE show_type() { return SHOW_MY_BOOL; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -485,7 +487,7 @@ public: void set_default(THD *thd, enum_var_type type); bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } bool check_default(enum_var_type type) { return 0; } - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE show_type() { return SHOW_LONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -496,7 +498,7 @@ public: sys_var_last_insert_id(const char *name_arg) :sys_var(name_arg) {} bool update(THD *thd, set_var *var); bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } - SHOW_TYPE type() { return SHOW_LONGLONG; } + SHOW_TYPE show_type() { return SHOW_LONGLONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -507,7 +509,7 @@ public: sys_var_insert_id(const char *name_arg) :sys_var(name_arg) {} bool update(THD *thd, set_var *var); bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } - SHOW_TYPE type() { return SHOW_LONGLONG; } + SHOW_TYPE show_type() { return SHOW_LONGLONG; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -529,8 +531,8 @@ public: class sys_var_sync_binlog_period :public sys_var_long_ptr { public: - sys_var_sync_binlog_period(const char *name_arg, ulong *value_ptr) - :sys_var_long_ptr(name_arg,value_ptr) {} + sys_var_sync_binlog_period(const char *name_arg, ulong *value_ptr_arg) + :sys_var_long_ptr(name_arg,value_ptr_arg) {} bool update(THD *thd, set_var *var); }; #endif @@ -560,7 +562,7 @@ public: no_support_one_shot= 0; } bool check(THD *thd, set_var *var); -SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return ((type != STRING_RESULT) && (type != INT_RESULT)); @@ -584,7 +586,7 @@ public: no_support_one_shot= 0; } bool check(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return ((type != STRING_RESULT) && (type != INT_RESULT)); @@ -700,7 +702,7 @@ public: :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; } + SHOW_TYPE show_type() { return SHOW_LONGLONG; } }; @@ -711,7 +713,7 @@ public: :sys_var_key_cache_param(name_arg, offset_arg) {} bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE show_type() { return SHOW_LONG; } }; @@ -726,7 +728,7 @@ public: :sys_var_thd(name_arg), offset(offset_arg), date_time_type(date_time_type_arg) {} - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ @@ -746,13 +748,13 @@ class sys_var_readonly: public sys_var { public: enum_var_type var_type; - SHOW_TYPE show_type; + SHOW_TYPE show_type_value; sys_value_ptr_func value_ptr_func; sys_var_readonly(const char *name_arg, enum_var_type type, SHOW_TYPE show_type_arg, sys_value_ptr_func value_ptr_func_arg) :sys_var(name_arg), var_type(type), - show_type(show_type_arg), value_ptr_func(value_ptr_func_arg) + show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg) {} bool update(THD *thd, set_var *var) { return 1; } bool check_default(enum_var_type type) { return 1; } @@ -762,7 +764,7 @@ public: { return (*value_ptr_func)(thd); } - SHOW_TYPE type() { return show_type; } + SHOW_TYPE show_type() { return show_type_value; } bool is_readonly() const { return 1; } }; @@ -775,7 +777,7 @@ public: no_support_one_shot= 0; } bool check(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ @@ -799,7 +801,7 @@ public: return type != OPT_GLOBAL || !option_limits; } void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_INT; } + SHOW_TYPE show_type() { return SHOW_INT; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -822,7 +824,7 @@ public: sys_var_thd(name_arg) {} bool check(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } + SHOW_TYPE show_type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ @@ -869,8 +871,8 @@ public: } save_result; LEX_STRING base; /* for structs */ - set_var(enum_var_type type_arg, sys_var *var_arg, const LEX_STRING *base_name_arg, - Item *value_arg) + set_var(enum_var_type type_arg, sys_var *var_arg, + const LEX_STRING *base_name_arg, Item *value_arg) :var(var_arg), type(type_arg), base(*base_name_arg) { /* diff --git a/sql/slave.cc b/sql/slave.cc index d0396444ace..e1b1e62bf1c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1696,7 +1696,7 @@ static int init_relay_log_info(RELAY_LOG_INFO* rli, char fname[FN_REFLEN+128]; int info_fd; const char* msg = 0; - int error = 0; + int error; DBUG_ENTER("init_relay_log_info"); if (rli->inited) // Set if this function called @@ -1801,11 +1801,11 @@ file '%s', errno %d)", fname, my_errno); } else // file exists { + error= 0; if (info_fd >= 0) reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0); else { - int error=0; if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) { sql_print_error("\ @@ -2515,12 +2515,12 @@ bool show_master_info(THD* thd, MASTER_INFO* mi) if ((mi->slave_running == MYSQL_SLAVE_RUN_CONNECT) && mi->rli.slave_running) { - long tmp= (long)((time_t)time((time_t*) 0) - - mi->rli.last_master_timestamp) - - mi->clock_diff_with_master; + long time_diff= ((long)((time_t)time((time_t*) 0) + - mi->rli.last_master_timestamp) + - mi->clock_diff_with_master); /* - Apparently on some systems tmp can be <0. Here are possible reasons - related to MySQL: + Apparently on some systems time_diff can be <0. Here are possible + reasons related to MySQL: - the master is itself a slave of another master whose time is ahead. - somebody used an explicit SET TIMESTAMP on the master. Possible reason related to granularity-to-second of time functions @@ -2538,8 +2538,8 @@ bool show_master_info(THD* thd, MASTER_INFO* mi) last_master_timestamp == 0 (an "impossible" timestamp 1970) is a special marker to say "consider we have caught up". */ - protocol->store((longlong)(mi->rli.last_master_timestamp ? max(0, tmp) - : 0)); + protocol->store((longlong)(mi->rli.last_master_timestamp ? + max(0, time_diff) : 0)); } else protocol->store_null(); @@ -3588,15 +3588,17 @@ after reconnect"); while (!io_slave_killed(thd,mi)) { - bool suppress_warnings= 0; + ulong event_len; + + suppress_warnings= 0; /* We say "waiting" because read_event() will wait if there's nothing to read. But if there's something to read, it will not wait. The important thing is to not confuse users by saying "reading" whereas we're in fact receiving nothing. */ - thd->proc_info = "Waiting for master to send event"; - ulong event_len = read_event(mysql, mi, &suppress_warnings); + thd->proc_info= "Waiting for master to send event"; + event_len= read_event(mysql, mi, &suppress_warnings); if (io_slave_killed(thd,mi)) { if (global_system_variables.log_warnings) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 152bc87aead..aec261efff3 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -95,8 +95,6 @@ sp_map_item_type(enum enum_field_types type) static String * sp_get_item_value(Item *item, String *str) { - Item_result result_type= item->result_type(); - switch (item->result_type()) { case REAL_RESULT: case INT_RESULT: @@ -1752,7 +1750,7 @@ sp_head::reset_lex(THD *thd) DBUG_ENTER("sp_head::reset_lex"); LEX *sublex; LEX *oldlex= thd->lex; - my_lex_states state= oldlex->next_state; // Keep original next_state + my_lex_states org_next_state= oldlex->next_state; (void)m_lex.push_front(oldlex); thd->lex= sublex= new st_lex; @@ -1761,10 +1759,10 @@ sp_head::reset_lex(THD *thd) lex_start(thd, oldlex->buf, (ulong) (oldlex->end_of_query - oldlex->ptr)); /* - * next_state is normally the same (0), but it happens that we swap lex in - * "mid-sentence", so we must restore it. + next_state is normally the same (0), but it happens that we swap lex in + "mid-sentence", so we must restore it. */ - sublex->next_state= state; + sublex->next_state= org_next_state; /* We must reset ptr and end_of_query again */ sublex->ptr= oldlex->ptr; sublex->end_of_query= oldlex->end_of_query; diff --git a/sql/sp_head.h b/sql/sp_head.h index 7f2da69aa0c..505a393b4ff 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -618,9 +618,9 @@ class sp_instr_set : public sp_instr public: sp_instr_set(uint ip, sp_pcontext *ctx, - uint offset, Item *val, enum enum_field_types type, + uint offset, Item *val, enum enum_field_types type_arg, LEX *lex, bool lex_resp) - : sp_instr(ip, ctx), m_offset(offset), m_value(val), m_type(type), + : sp_instr(ip, ctx), m_offset(offset), m_value(val), m_type(type_arg), m_lex_keeper(lex, lex_resp) {} @@ -818,8 +818,9 @@ class sp_instr_freturn : public sp_instr public: sp_instr_freturn(uint ip, sp_pcontext *ctx, - Item *val, enum enum_field_types type, LEX *lex) - : sp_instr(ip, ctx), m_value(val), m_type(type), m_lex_keeper(lex, TRUE) + Item *val, enum enum_field_types type_arg, LEX *lex) + : sp_instr(ip, ctx), m_value(val), m_type(type_arg), + m_lex_keeper(lex, TRUE) {} virtual ~sp_instr_freturn() diff --git a/sql/spatial.cc b/sql/spatial.cc index e91653f79d5..3e54d28182c 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -24,13 +24,13 @@ String Geometry::bad_geometry_data("Bad object", &my_charset_bin); -Geometry::Class_info *Geometry::ci_collection[Geometry::wkb_end+1]= +Geometry::Class_info *Geometry::ci_collection[Geometry::wkb_last+1]= { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static Geometry::Class_info **ci_collection_end= - Geometry::ci_collection+Geometry::wkb_end + 1; + Geometry::ci_collection+Geometry::wkb_last + 1; Geometry::Class_info::Class_info(const char *name, int type_id, void(*create_func)(void *)): @@ -550,7 +550,7 @@ bool Gis_line_string::get_mbr(MBR *mbr, const char **end) const } -int Gis_line_string::length(double *len) const +int Gis_line_string::geom_length(double *len) const { uint32 n_points; double prev_x, prev_y; @@ -946,15 +946,14 @@ int Gis_polygon::centroid_xy(double *x, double *y) const while (--n_points) // One point is already read { - double x, y; - get_point(&x, &y, data); + double tmp_x, tmp_y; + get_point(&tmp_x, &tmp_y, data); data+= (SIZEOF_STORED_DOUBLE*2); - /* QQ: Is the following prev_x+x right ? */ - cur_area+= (prev_x + x) * (prev_y - y); - cur_cx+= x; - cur_cy+= y; - prev_x= x; - prev_y= y; + cur_area+= (prev_x + tmp_x) * (prev_y - tmp_y); + cur_cx+= tmp_x; + cur_cy+= tmp_y; + prev_x= tmp_x; + prev_y= tmp_y; } cur_area= fabs(cur_area) / 2; cur_cx= cur_cx / (org_n_points - 1); @@ -1298,7 +1297,7 @@ int Gis_multi_line_string::geometry_n(uint32 num, String *result) const } -int Gis_multi_line_string::length(double *len) const +int Gis_multi_line_string::geom_length(double *len) const { uint32 n_line_strings; const char *data= m_data; @@ -1315,7 +1314,7 @@ int Gis_multi_line_string::length(double *len) const Gis_line_string ls; data+= WKB_HEADER_SIZE; ls.set_data_ptr(data, (uint32) (m_data_end - data)); - if (ls.length(&ls_len)) + if (ls.geom_length(&ls_len)) return 1; *len+= ls_len; /* diff --git a/sql/spatial.h b/sql/spatial.h index a6f74a1ada0..a302657b261 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -189,7 +189,7 @@ public: wkb_multilinestring= 5, wkb_multipolygon= 6, wkb_geometrycollection= 7, - wkb_end=7 + wkb_last=7 }; enum wkbByteOrder { @@ -218,7 +218,7 @@ public: virtual bool dimension(uint32 *dim, const char **end) const=0; virtual int get_x(double *x) const { return -1; } virtual int get_y(double *y) const { return -1; } - virtual int length(double *len) const { return -1; } + virtual int geom_length(double *len) const { return -1; } virtual int area(double *ar, const char **end) const { return -1;} virtual int is_closed(int *closed) const { return -1; } virtual int num_interior_ring(uint32 *n_int_rings) const { return -1; } @@ -274,12 +274,12 @@ public: } bool envelope(String *result) const; - static Class_info *ci_collection[wkb_end+1]; + static Class_info *ci_collection[wkb_last+1]; protected: static Class_info *find_class(int type_id) { - return ((type_id < wkb_point) || (type_id > wkb_end)) ? + return ((type_id < wkb_point) || (type_id > wkb_last)) ? NULL : ci_collection[type_id]; } static Class_info *find_class(const char *name, uint32 len); @@ -360,7 +360,7 @@ public: uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); bool get_data_as_wkt(String *txt, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const; - int length(double *len) const; + int geom_length(double *len) const; int is_closed(int *closed) const; int num_points(uint32 *n_points) const; int start_point(String *point) const; @@ -442,7 +442,7 @@ public: bool get_mbr(MBR *mbr, const char **end) const; int num_geometries(uint32 *num) const; int geometry_n(uint32 num, String *result) const; - int length(double *len) const; + int geom_length(double *len) const; int is_closed(int *closed) const; bool dimension(uint32 *dim, const char **end) const { diff --git a/sql/sql_cache.h b/sql/sql_cache.h index a66067159e2..618dea2c89b 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -128,7 +128,7 @@ struct Query_cache_query inline void tables_type(uint8 type) { tbls_type= type; } inline ulong length() { return len; } inline ulong add(ulong packet_len) { return(len+= packet_len); } - inline void length(ulong length) { len= length; } + inline void length(ulong length_arg) { len= length_arg; } inline gptr query() { return (gptr)(((byte*)this)+ @@ -156,7 +156,7 @@ struct Query_cache_table inline char *db() { return (char *) data(); } inline char *table() { return tbl; } - inline void table(char *table) { tbl= table; } + inline void table(char *table_arg) { tbl= table_arg; } inline uint32 key_length() { return key_len; } inline void key_length(uint32 len) { key_len= len; } inline uint8 type() { return table_type; } @@ -164,7 +164,7 @@ struct Query_cache_table inline qc_engine_callback callback() { return callback_func; } inline void callback(qc_engine_callback fn){ callback_func= fn; } inline ulonglong engine_data() { return engine_data_buff; } - inline void engine_data(ulonglong data) { engine_data_buff= data; } + inline void engine_data(ulonglong data_arg){ engine_data_buff= data_arg; } inline gptr data() { return (gptr)(((byte*)this)+ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d2f1e9ed0d9..998936639cb 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -183,6 +183,8 @@ THD::THD() clear_next_insert_id(0), in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE), spcont(NULL) { + ulong tmp; + stmt_arena= this; thread_stack= 0; db= 0; @@ -269,8 +271,8 @@ THD::THD() protocol_prep.init(this); tablespace_op=FALSE; - ulong tmp=sql_rnd_with_mutex(); - randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::query_id); + tmp= sql_rnd_with_mutex(); + randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::global_query_id); substitute_null_with_insert_id = FALSE; thr_lock_info_init(&lock_info); /* safety: will be reset after start */ thr_lock_owner_init(&main_lock_id, &lock_info); @@ -1432,7 +1434,7 @@ bool select_max_min_finder_subselect::send_data(List &items) bool select_max_min_finder_subselect::cmp_real() { - Item *maxmin= ((Item_singlerow_subselect *)item)->el(0); + Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); double val1= cache->val_real(), val2= maxmin->val_real(); if (fmax) return (cache->null_value && !maxmin->null_value) || @@ -1445,7 +1447,7 @@ bool select_max_min_finder_subselect::cmp_real() bool select_max_min_finder_subselect::cmp_int() { - Item *maxmin= ((Item_singlerow_subselect *)item)->el(0); + Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); longlong val1= cache->val_int(), val2= maxmin->val_int(); if (fmax) return (cache->null_value && !maxmin->null_value) || @@ -1458,7 +1460,7 @@ bool select_max_min_finder_subselect::cmp_int() bool select_max_min_finder_subselect::cmp_decimal() { - Item *maxmin= ((Item_singlerow_subselect *)item)->el(0); + Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); my_decimal cval, *cvalue= cache->val_decimal(&cval); my_decimal mval, *mvalue= maxmin->val_decimal(&mval); if (fmax) @@ -1473,7 +1475,7 @@ bool select_max_min_finder_subselect::cmp_decimal() bool select_max_min_finder_subselect::cmp_str() { String *val1, *val2, buf1, buf2; - Item *maxmin= ((Item_singlerow_subselect *)item)->el(0); + Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); /* as far as both operand is Item_cache buf1 & buf2 will not be used, but added for safety diff --git a/sql/sql_class.h b/sql/sql_class.h index 9ad67524998..8d4cc8e9993 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -64,7 +64,7 @@ class TC_LOG virtual int open(const char *opt_name)=0; virtual void close()=0; - virtual int log(THD *thd, my_xid xid)=0; + virtual int log_xid(THD *thd, my_xid xid)=0; virtual void unlog(ulong cookie, my_xid xid)=0; }; @@ -74,7 +74,7 @@ public: TC_LOG_DUMMY() {} /* Remove gcc warning */ int open(const char *opt_name) { return 0; } void close() { } - int log(THD *thd, my_xid xid) { return 1; } + int log_xid(THD *thd, my_xid xid) { return 1; } void unlog(ulong cookie, my_xid xid) { } }; @@ -119,7 +119,7 @@ class TC_LOG_MMAP: public TC_LOG TC_LOG_MMAP(): inited(0) {} int open(const char *opt_name); void close(); - int log(THD *thd, my_xid xid); + int log_xid(THD *thd, my_xid xid); void unlog(ulong cookie, my_xid xid); int recover(); @@ -253,7 +253,7 @@ public: int open(const char *opt_name); void close(); - int log(THD *thd, my_xid xid); + int log_xid(THD *thd, my_xid xid); void unlog(ulong cookie, my_xid xid); int recover(IO_CACHE *log, Format_description_log_event *fdle); void reset_bytes_written() @@ -1839,13 +1839,14 @@ class select_create: public select_insert { MYSQL_LOCK *lock; Field **field; public: - select_create (TABLE_LIST *table, - HA_CREATE_INFO *create_info_par, - List &fields_par, - List &keys_par, - List &select_fields,enum_duplicates duplic, bool ignore) - :select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore), create_table(table), - extra_fields(&fields_par),keys(&keys_par), create_info(create_info_par), + select_create(TABLE_LIST *table_arg, + HA_CREATE_INFO *create_info_par, + List &fields_par, + List &keys_par, + List &select_fields,enum_duplicates duplic, bool ignore) + :select_insert(NULL, NULL, &select_fields, 0, 0, duplic, ignore), + create_table(table_arg), extra_fields(&fields_par),keys(&keys_par), + create_info(create_info_par), lock(0) {} int prepare(List &list, SELECT_LEX_UNIT *u); @@ -1950,7 +1951,9 @@ public: class select_singlerow_subselect :public select_subselect { public: - select_singlerow_subselect(Item_subselect *item):select_subselect(item){} + select_singlerow_subselect(Item_subselect *item_arg) + :select_subselect(item_arg) + {} bool send_data(List &items); }; @@ -1961,8 +1964,8 @@ class select_max_min_finder_subselect :public select_subselect bool (select_max_min_finder_subselect::*op)(); bool fmax; public: - select_max_min_finder_subselect(Item_subselect *item, bool mx) - :select_subselect(item), cache(0), fmax(mx) + select_max_min_finder_subselect(Item_subselect *item_arg, bool mx) + :select_subselect(item_arg), cache(0), fmax(mx) {} void cleanup(); bool send_data(List &items); @@ -1976,7 +1979,8 @@ public: class select_exists_subselect :public select_subselect { public: - select_exists_subselect(Item_subselect *item):select_subselect(item){} + select_exists_subselect(Item_subselect *item_arg) + :select_subselect(item_arg){} bool send_data(List &items); }; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e1817985cbd..22864e0518e 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -110,8 +110,6 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list) SELECT_LEX *first_select= unit->first_select(); TABLE *table= 0; select_union *derived_result; - bool is_union= first_select->next_select() && - first_select->next_select()->linkage == UNION_TYPE; /* prevent name resolving out of derived table */ for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select()) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 2ce83caa369..2b5d876a6ac 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -60,7 +60,6 @@ #include "sql_trigger.h" #include "sql_select.h" -static int check_null_fields(THD *thd,TABLE *entry); #ifndef EMBEDDED_LIBRARY static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list); static int write_delayed(THD *thd,TABLE *table, enum_duplicates dup, bool ignore, @@ -131,11 +130,11 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, #ifndef NO_EMBEDDED_ACCESS_CHECKS if (grant_option) { - Field_iterator_table fields; - fields.set_table(table); + Field_iterator_table field_it; + field_it.set_table(table); if (check_grant_all_columns(thd, INSERT_ACL, &table->grant, table->s->db, table->s->table_name, - &fields)) + &field_it)) return -1; } #endif @@ -320,8 +319,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, By default, both logs are enabled (this won't cause problems if the server runs without --log-update or --log-bin). */ - bool log_on= (thd->options & OPTION_BIN_LOG) || - (!(thd->security_ctx->master_access & SUPER_ACL)); bool transactional_table, joins_freed= FALSE; bool changed; uint value_count; @@ -335,6 +332,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, Name_resolution_context_state ctx_state; #ifndef EMBEDDED_LIBRARY char *query= thd->query; + bool log_on= (thd->options & OPTION_BIN_LOG) || + (!(thd->security_ctx->master_access & SUPER_ACL)); #endif thr_lock_type lock_type = table_list->lock_type; Item *unused_conds= 0; @@ -758,7 +757,6 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view) Field_translator *trans_start= view->field_translation, *trans_end= trans_start + num; Field_translator *trans; - Field **field_ptr= table->field; uint used_fields_buff_size= (table->s->fields + 7) / 8; uchar *used_fields_buff= (uchar*)thd->alloc(used_fields_buff_size); MY_BITMAP used_fields; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3de842c8551..9894deb5841 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -287,13 +287,15 @@ static char *get_text(LEX *lex) { c = yyGet(); #ifdef USE_MB - int l; - if (use_mb(cs) && - (l = my_ismbchar(cs, - (const char *)lex->ptr-1, - (const char *)lex->end_of_query))) { + { + int l; + if (use_mb(cs) && + (l = my_ismbchar(cs, + (const char *)lex->ptr-1, + (const char *)lex->end_of_query))) { lex->ptr += l-1; continue; + } } #endif if (c == '\\' && @@ -760,8 +762,8 @@ int MYSQLlex(void *arg, void *yythd) lex->tok_start=lex->ptr; // Skip first ` while ((c=yyGet())) { - int length; - if ((length= my_mbcharlen(cs, c)) == 1) + int var_length; + if ((var_length= my_mbcharlen(cs, c)) == 1) { if (c == (uchar) NAMES_SEP_CHAR) break; /* Old .frm format can't handle this char */ @@ -775,9 +777,9 @@ int MYSQLlex(void *arg, void *yythd) } } #ifdef USE_MB - else if (length < 1) + else if (var_length < 1) break; // Error - lex->ptr+= length-1; + lex->ptr+= var_length-1; #endif } if (double_quotes) @@ -1717,13 +1719,14 @@ bool st_lex::can_be_merged() bool selects_allow_merge= select_lex.next_select() == 0; if (selects_allow_merge) { - for (SELECT_LEX_UNIT *unit= select_lex.first_inner_unit(); - unit; - unit= unit->next_unit()) + for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit(); + tmp_unit; + tmp_unit= tmp_unit->next_unit()) { - if (unit->first_select()->parent_lex == this && - (unit->item == 0 || - (unit->item->place() != IN_WHERE && unit->item->place() != IN_ON))) + if (tmp_unit->first_select()->parent_lex == this && + (tmp_unit->item == 0 || + (tmp_unit->item->place() != IN_WHERE && + tmp_unit->item->place() != IN_ON))) { selects_allow_merge= 0; break; @@ -2021,12 +2024,12 @@ void st_lex::first_lists_tables_same() FALSE - success */ -bool st_lex::add_time_zone_tables_to_query_tables(THD *thd) +bool st_lex::add_time_zone_tables_to_query_tables(THD *thd_arg) { /* We should not add these tables twice */ if (!time_zone_tables_used) { - time_zone_tables_used= my_tz_get_table_list(thd, &query_tables_last); + time_zone_tables_used= my_tz_get_table_list(thd_arg, &query_tables_last); if (time_zone_tables_used == &fake_time_zone_tables_list) return TRUE; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index be12467d097..30f445495b8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -398,7 +398,8 @@ protected: select_result *result; ulonglong found_rows_for_union; - bool res; + bool saved_error; + public: bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index bdc08b7bd2d..defb8f7493c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -83,10 +83,11 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, List &set_values, READ_INFO &read_info, String &enclosed, ulong skip_lines, bool ignore_check_option_errors); +#ifndef EMBEDDED_LIBRARY static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, bool transactional_table); - +#endif /* EMBEDDED_LIBRARY */ /* Execute LOAD DATA query @@ -487,6 +488,8 @@ err: } +#ifndef EMBEDDED_LIBRARY + /* Not a very useful function; just to avoid duplication of code */ static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, @@ -502,6 +505,7 @@ static bool write_execute_load_query_log_event(THD *thd, return mysql_bin_log.write(&e); } +#endif /**************************************************************************** ** Read of rows of fixed size + optional garage + optonal newline diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fec7e5ab20d..cb09935268d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -66,13 +66,12 @@ extern "C" int gethostname(char *name, int namelen); #endif -static void time_out_user_resource_limits(THD *thd, USER_CONN *uc); #ifndef NO_EMBEDDED_ACCESS_CHECKS +static void time_out_user_resource_limits(THD *thd, USER_CONN *uc); static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ static bool check_db_used(THD *thd,TABLE_LIST *tables); -static bool check_multi_update_lock(THD *thd); static void remove_escape(char *name); static bool append_file_to_dir(THD *thd, const char **filename_ptr, const char *table_name); @@ -672,6 +671,8 @@ bool is_update_query(enum enum_sql_command command) safe to test and modify members of the USER_CONN structure. */ +#ifndef NO_EMBEDDED_ACCESS_CHECKS + static void time_out_user_resource_limits(THD *thd, USER_CONN *uc) { time_t check_time = thd->start_time ? thd->start_time : time(NULL); @@ -689,7 +690,6 @@ static void time_out_user_resource_limits(THD *thd, USER_CONN *uc) DBUG_VOID_RETURN; } - /* Check if maximum queries per hour limit has been reached returns 0 if OK. @@ -697,7 +697,6 @@ static void time_out_user_resource_limits(THD *thd, USER_CONN *uc) static bool check_mqh(THD *thd, uint check_command) { -#ifndef NO_EMBEDDED_ACCESS_CHECKS bool error= 0; USER_CONN *uc=thd->user_connect; DBUG_ENTER("check_mqh"); @@ -731,11 +730,10 @@ static bool check_mqh(THD *thd, uint check_command) end: (void) pthread_mutex_unlock(&LOCK_user_conn); DBUG_RETURN(error); -#else - return (0); -#endif /* NO_EMBEDDED_ACCESS_CHECKS */ } +#endif /* NO_EMBEDDED_ACCESS_CHECKS */ + static void reset_mqh(LEX_USER *lu, bool get_them= 0) { @@ -1595,7 +1593,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ thd->set_time(); VOID(pthread_mutex_lock(&LOCK_thread_count)); - thd->query_id=query_id; + thd->query_id= global_query_id; if (command != COM_STATISTICS && command != COM_PING) next_query_id(); thread_running++; @@ -1776,7 +1774,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, while (!thd->killed && thd->lex->found_semicolon && !thd->net.report_error) { - char *packet= thd->lex->found_semicolon; + char *next_packet= thd->lex->found_semicolon; net->no_send_error= 0; /* Multiple queries exits, execute them individually @@ -1784,24 +1782,24 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (thd->lock || thd->open_tables || thd->derived_tables || thd->prelocked_mode) close_thread_tables(thd); - ulong length= (ulong)(packet_end-packet); + ulong length= (ulong)(packet_end - next_packet); log_slow_statement(thd); /* Remove garbage at start of query */ - while (my_isspace(thd->charset(), *packet) && length > 0) + while (my_isspace(thd->charset(), *next_packet) && length > 0) { - packet++; + next_packet++; length--; } VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_length= length; - thd->query= packet; + thd->query= next_packet; thd->query_id= next_query_id(); thd->set_time(); /* Reset the query start time. */ /* TODO: set thd->lex->sql_command to SQLCOM_END here */ VOID(pthread_mutex_unlock(&LOCK_thread_count)); - mysql_parse(thd, packet, length); + mysql_parse(thd, next_packet, length); } if (!(specialflag & SPECIAL_NO_PRIOR)) @@ -1818,16 +1816,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { char *fields, *pend; /* Locked closure of all tables */ - TABLE_LIST *locked_tables= NULL; TABLE_LIST table_list; LEX_STRING conv_name; - /* Saved variable value */ - my_bool old_innodb_table_locks= - IF_INNOBASE_DB(thd->variables.innodb_table_locks, FALSE); + /* used as fields initializator */ lex_start(thd, 0, 0); - statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS], &LOCK_status); bzero((char*) &table_list,sizeof(table_list)); @@ -2023,7 +2017,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, STATUS_VAR current_global_status_var; calc_sum_of_all_status(¤t_global_status_var); - ulong uptime = (ulong) (thd->start_time - start_time); + ulong uptime = (ulong) (thd->start_time - server_start_time); sprintf((char*) buff, "Uptime: %lu Threads: %d Questions: %lu Slow queries: %lu Opens: %lu Flush tables: %lu Open tables: %u Queries per second avg: %.3f", uptime, @@ -2070,13 +2064,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { statistic_increment(thd->status_var.com_stat[SQLCOM_SET_OPTION], &LOCK_status); - enum_mysql_set_option command= (enum_mysql_set_option) uint2korr(packet); - switch (command) { - case MYSQL_OPTION_MULTI_STATEMENTS_ON: + uint opt_command= uint2korr(packet); + + switch (opt_command) { + case (int) MYSQL_OPTION_MULTI_STATEMENTS_ON: thd->client_capabilities|= CLIENT_MULTI_STATEMENTS; send_eof(thd); break; - case MYSQL_OPTION_MULTI_STATEMENTS_OFF: + case (int) MYSQL_OPTION_MULTI_STATEMENTS_OFF: thd->client_capabilities&= ~CLIENT_MULTI_STATEMENTS; send_eof(thd); break; @@ -2418,7 +2413,7 @@ mysql_execute_command(THD *thd) { bool res= FALSE; bool need_start_waiting= FALSE; // have protection against global read lock - int result= 0; + int up_result= 0; LEX *lex= thd->lex; /* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */ SELECT_LEX *select_lex= &lex->select_lex; @@ -2561,7 +2556,7 @@ mysql_execute_command(THD *thd) new Item_int((ulonglong)thd->variables.select_limit); } - select_result *result=lex->result; + select_result *sel_result=lex->result; if (all_tables) { if (lex->orig_sql_command != SQLCOM_SHOW_STATUS_PROC && @@ -2588,11 +2583,11 @@ mysql_execute_command(THD *thd) to prepend EXPLAIN to any query and receive output for it, even if the query itself redirects the output. */ - if (!(result= new select_send())) + if (!(sel_result= new select_send())) goto error; else - thd->send_explain_fields(result); - res= mysql_explain_union(thd, &thd->lex->unit, result); + thd->send_explain_fields(sel_result); + res= mysql_explain_union(thd, &thd->lex->unit, sel_result); if (lex->describe & DESCRIBE_EXTENDED) { char buff[1024]; @@ -2603,17 +2598,17 @@ mysql_execute_command(THD *thd) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_YES, str.ptr()); } - result->send_eof(); - delete result; + sel_result->send_eof(); + delete sel_result; } else { - if (!result && !(result= new select_send())) + if (!sel_result && !(sel_result= new select_send())) goto error; query_cache_store_query(thd, all_tables); - res= handle_select(thd, lex, result, 0); - if (result != lex->result) - delete result; + res= handle_select(thd, lex, sel_result, 0); + if (sel_result != lex->result) + delete sel_result; } } break; @@ -2942,7 +2937,7 @@ mysql_execute_command(THD *thd) } if (select_lex->item_list.elements) // With select { - select_result *result; + select_result *sel_result; select_lex->options|= SELECT_NO_UNLOCK; unit->set_limit(select_lex); @@ -2981,20 +2976,20 @@ mysql_execute_command(THD *thd) } } - if ((result= new select_create(create_table, - &lex->create_info, - lex->create_list, - lex->key_list, - select_lex->item_list, - lex->duplicates, - lex->ignore))) + if ((sel_result= new select_create(create_table, + &lex->create_info, + lex->create_list, + lex->key_list, + select_lex->item_list, + lex->duplicates, + lex->ignore))) { /* CREATE from SELECT give its SELECT_LEX for SELECT, and item_list belong to SELECT */ - res= handle_select(thd, lex, result, 0); - delete result; + res= handle_select(thd, lex, sel_result, 0); + delete sel_result; } /* reset for PS */ lex->create_list.empty(); @@ -3309,22 +3304,23 @@ end_with_restore_list: break; DBUG_ASSERT(select_lex->offset_limit == 0); unit->set_limit(select_lex); - res= (result= mysql_update(thd, all_tables, - select_lex->item_list, - lex->value_list, - select_lex->where, - select_lex->order_list.elements, - (ORDER *) select_lex->order_list.first, - unit->select_limit_cnt, - lex->duplicates, lex->ignore)); + res= (up_result= mysql_update(thd, all_tables, + select_lex->item_list, + lex->value_list, + select_lex->where, + select_lex->order_list.elements, + (ORDER *) select_lex->order_list.first, + unit->select_limit_cnt, + lex->duplicates, lex->ignore)); /* mysql_update return 2 if we need to switch to multi-update */ - if (result != 2) + if (up_result != 2) break; + /* Fall through */ case SQLCOM_UPDATE_MULTI: { DBUG_ASSERT(first_table == all_tables && first_table != 0); /* if we switched from normal update, rights are checked */ - if (result != 2) + if (up_result != 2) { if ((res= multi_update_precheck(thd, all_tables))) break; @@ -3408,7 +3404,7 @@ end_with_restore_list: case SQLCOM_REPLACE_SELECT: case SQLCOM_INSERT_SELECT: { - select_result *result; + select_result *sel_result; DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; @@ -3437,13 +3433,15 @@ end_with_restore_list: select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= mysql_insert_select_prepare(thd); - if (!res && (result= new select_insert(first_table, first_table->table, - &lex->field_list, - &lex->update_list, - &lex->value_list, - lex->duplicates, lex->ignore))) + if (!res && (sel_result= new select_insert(first_table, + first_table->table, + &lex->field_list, + &lex->update_list, + &lex->value_list, + lex->duplicates, + lex->ignore))) { - res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE); + res= handle_select(thd, lex, sel_result, OPTION_SETUP_TABLES_DONE); /* Invalidate the table in the query cache if something changed after unlocking when changes become visible. @@ -3461,7 +3459,7 @@ end_with_restore_list: first_table->next_local= save_table; thd->lock=0; } - delete result; + delete sel_result; } /* revert changes for SP */ select_lex->table_list.first= (byte*) first_table; @@ -3526,7 +3524,7 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); TABLE_LIST *aux_tables= (TABLE_LIST *)thd->lex->auxiliary_table_list.first; - multi_delete *result; + multi_delete *del_result; if (!thd->locked_tables && !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) @@ -3551,8 +3549,8 @@ end_with_restore_list: if ((res= mysql_multi_delete_prepare(thd))) goto error; - if (!thd->is_fatal_error && (result= new multi_delete(aux_tables, - lex->table_count))) + if (!thd->is_fatal_error && + (del_result= new multi_delete(aux_tables, lex->table_count))) { res= mysql_select(thd, &select_lex->ref_pointer_array, select_lex->get_table_list(), @@ -3564,8 +3562,8 @@ end_with_restore_list: select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE, - result, unit, select_lex); - delete result; + del_result, unit, select_lex); + delete del_result; } else res= TRUE; // Error @@ -4243,7 +4241,7 @@ end_with_restore_list: { uint namelen; char *name; - int result; + int sp_result; DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ @@ -4306,17 +4304,17 @@ end_with_restore_list: if (!lex->definer) { - bool res= FALSE; + bool local_res= FALSE; Query_arena original_arena; Query_arena *ps_arena = thd->activate_stmt_arena_if_needed(&original_arena); if (!(lex->definer= create_default_definer(thd))) - res= TRUE; + local_res= TRUE; if (ps_arena) thd->restore_active_arena(ps_arena, &original_arena); - if (res) + if (local_res) { /* Error has been already reported. */ delete lex->sphead; @@ -4363,8 +4361,8 @@ end_with_restore_list: } #endif /* NO_EMBEDDED_ACCESS_CHECKS */ - res= (result= lex->sphead->create(thd)); - if (result == SP_OK) + res= (sp_result= lex->sphead->create(thd)); + if (sp_result == SP_OK) { #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ @@ -4388,7 +4386,7 @@ end_with_restore_list: } else { - switch (result) { + switch (sp_result) { case SP_WRITE_ROW_FAILED: my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); break; @@ -4521,7 +4519,7 @@ end_with_restore_list: case SQLCOM_ALTER_PROCEDURE: case SQLCOM_ALTER_FUNCTION: { - int result; + int sp_result; sp_head *sp; st_sp_chistics chistics; @@ -4536,7 +4534,7 @@ end_with_restore_list: if (! sp) { if (lex->spname->m_db.str) - result= SP_KEY_NOT_FOUND; + sp_result= SP_KEY_NOT_FOUND; else { my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); @@ -4561,7 +4559,7 @@ end_with_restore_list: { my_message(ER_BINLOG_UNSAFE_ROUTINE, ER(ER_BINLOG_UNSAFE_ROUTINE), MYF(0)); - result= SP_INTERNAL_ERROR; + sp_result= SP_INTERNAL_ERROR; } else { @@ -4571,15 +4569,15 @@ end_with_restore_list: follow the restrictions that log-bin-trust-function-creators=0 already puts on CREATE FUNCTION. */ + /* Conditionally writes to binlog */ if (lex->sql_command == SQLCOM_ALTER_PROCEDURE) - /* Conditionally writes to binlog */ - result= sp_update_procedure(thd, lex->spname, &lex->sp_chistics); + sp_result= sp_update_procedure(thd, lex->spname, + &lex->sp_chistics); else - /* Conditionally writes to binlog */ - result= sp_update_function(thd, lex->spname, &lex->sp_chistics); + sp_result= sp_update_function(thd, lex->spname, &lex->sp_chistics); } } - switch (result) + switch (sp_result) { case SP_OK: send_ok(thd); @@ -4598,13 +4596,13 @@ end_with_restore_list: case SQLCOM_DROP_PROCEDURE: case SQLCOM_DROP_FUNCTION: { - int result; + int sp_result; int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); - result= sp_routine_exists_in_table(thd, type, lex->spname); + sp_result= sp_routine_exists_in_table(thd, type, lex->spname); mysql_reset_errors(thd, 0); - if (result == SP_OK) + if (sp_result == SP_OK) { char *db= lex->spname->m_db.str; char *name= lex->spname->m_name.str; @@ -4625,12 +4623,11 @@ end_with_restore_list: ER(ER_PROC_AUTO_REVOKE_FAIL)); } #endif + /* Conditionally writes to binlog */ if (lex->sql_command == SQLCOM_DROP_PROCEDURE) - /* Conditionally writes to binlog */ - result= sp_drop_procedure(thd, lex->spname); /* Conditionally writes to binlog */ + sp_result= sp_drop_procedure(thd, lex->spname); else - /* Conditionally writes to binlog */ - result= sp_drop_function(thd, lex->spname); /* Conditionally writes to binlog */ + sp_result= sp_drop_function(thd, lex->spname); } else { @@ -4654,16 +4651,15 @@ end_with_restore_list: } #endif if (lex->spname->m_db.str) - result= SP_KEY_NOT_FOUND; + sp_result= SP_KEY_NOT_FOUND; else { my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); goto error; } } - res= result; - switch (result) - { + res= sp_result; + switch (sp_result) { case SP_OK: send_ok(thd); break; @@ -5299,7 +5295,9 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables, { uint found=0; ulong found_access=0; +#ifndef EMBEDDED_LIBRARY TABLE_LIST *org_tables= tables; +#endif TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table(); Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx; /* @@ -6504,18 +6502,18 @@ void st_select_lex::set_lock_for_tables(thr_lock_type lock_type) 0 on success */ -bool st_select_lex_unit::add_fake_select_lex(THD *thd) +bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg) { SELECT_LEX *first_sl= first_select(); DBUG_ENTER("add_fake_select_lex"); DBUG_ASSERT(!fake_select_lex); - if (!(fake_select_lex= new (thd->mem_root) SELECT_LEX())) + if (!(fake_select_lex= new (thd_arg->mem_root) SELECT_LEX())) DBUG_RETURN(1); fake_select_lex->include_standalone(this, (SELECT_LEX_NODE**)&fake_select_lex); fake_select_lex->select_number= INT_MAX; - fake_select_lex->parent_lex= thd->lex; /* Used in init_query. */ + fake_select_lex->parent_lex= thd_arg->lex; /* Used in init_query. */ fake_select_lex->make_empty_select(); fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE; fake_select_lex->select_limit= 0; @@ -6535,9 +6533,9 @@ bool st_select_lex_unit::add_fake_select_lex(THD *thd) */ global_parameters= fake_select_lex; fake_select_lex->no_table_names_allowed= 1; - thd->lex->current_select= fake_select_lex; + thd_arg->lex->current_select= fake_select_lex; } - thd->lex->pop_context(); + thd_arg->lex->pop_context(); DBUG_RETURN(0); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 8c0235e9768..51ed20b311a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -976,19 +976,19 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, /* Insert @'escaped-varname' instead of parameter in the query */ if (entry) { - char *begin, *ptr; + char *start, *ptr; buf.length(0); if (buf.reserve(entry->name.length*2+3)) DBUG_RETURN(1); - begin= ptr= buf.c_ptr_quick(); + start= ptr= buf.c_ptr_quick(); *ptr++= '@'; *ptr++= '\''; ptr+= escape_string_for_mysql(&my_charset_utf8_general_ci, ptr, 0, entry->name.str, entry->name.length); *ptr++= '\''; - buf.length(ptr - begin); + buf.length(ptr - start); val= &buf; } else @@ -1026,7 +1026,6 @@ static bool mysql_test_insert(Prepared_statement *stmt, enum_duplicates duplic) { THD *thd= stmt->thd; - LEX *lex= stmt->lex; List_iterator_fast its(values_list); List_item *values; DBUG_ENTER("mysql_test_insert"); @@ -2531,7 +2530,9 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) uint param_number; Prepared_statement *stmt; Item_param *param; +#ifndef EMBEDDED_LIBRARY char *packet_end= packet + packet_length - 1; +#endif DBUG_ENTER("mysql_stmt_get_longdata"); statistic_increment(thd->status_var.com_stmt_send_long_data, &LOCK_status); @@ -2585,8 +2586,8 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) Select_fetch_protocol_prep ****************************************************************************/ -Select_fetch_protocol_prep::Select_fetch_protocol_prep(THD *thd) - :protocol(thd) +Select_fetch_protocol_prep::Select_fetch_protocol_prep(THD *thd_arg) + :protocol(thd_arg) {} bool Select_fetch_protocol_prep::send_fields(List &list, uint flags) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3d2f46a9982..c91eb71ec1a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -110,7 +110,6 @@ static uint build_bitmap_for_nested_joins(List *join_list, static COND *optimize_cond(JOIN *join, COND *conds, List *join_list, Item::cond_result *cond_value); -static bool resolve_nested_join (TABLE_LIST *table); static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); static bool open_tmp_table(TABLE *table); static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, @@ -2420,14 +2419,14 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, for( ; sargables->field ; sargables++) { Field *field= sargables->field; - JOIN_TAB *stat= field->table->reginfo.join_tab; + JOIN_TAB *join_tab= field->table->reginfo.join_tab; key_map possible_keys= field->key_start; possible_keys.intersect(field->table->keys_in_use_for_query); bool is_const= 1; - for (uint i=0; i< sargables->num_values; i++) - is_const&= sargables->arg_value[i]->const_item(); + for (uint j=0; j < sargables->num_values; j++) + is_const&= sargables->arg_value[j]->const_item(); if (is_const) - stat[0].const_keys.merge(possible_keys); + join_tab[0].const_keys.merge(possible_keys); } } @@ -3421,16 +3420,16 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, */ if (keyuse->elements) { - KEYUSE end,*prev,*save_pos,*use; + KEYUSE key_end,*prev,*save_pos,*use; qsort(keyuse->buffer,keyuse->elements,sizeof(KEYUSE), (qsort_cmp) sort_keyuse); - bzero((char*) &end,sizeof(end)); /* Add for easy testing */ - VOID(insert_dynamic(keyuse,(gptr) &end)); + bzero((char*) &key_end,sizeof(key_end)); /* Add for easy testing */ + VOID(insert_dynamic(keyuse,(gptr) &key_end)); use=save_pos=dynamic_element(keyuse,0,KEYUSE*); - prev=&end; + prev= &key_end; found_eq_constant=0; for (i=0 ; i < keyuse->elements-1 ; i++,use++) { @@ -3458,7 +3457,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, save_pos++; } i=(uint) (save_pos-(KEYUSE*) keyuse->buffer); - VOID(set_dynamic(keyuse,(gptr) &end,i)); + VOID(set_dynamic(keyuse,(gptr) &key_end,i)); keyuse->elements=i; } return FALSE; @@ -3640,7 +3639,6 @@ best_access_path(JOIN *join, double records= DBL_MAX; double tmp; ha_rows rec; - DBUG_ENTER("best_access_path"); if (s->keyuse) @@ -3680,12 +3678,12 @@ best_access_path(JOIN *join, found_part|= keyuse->keypart_map; if (!(keyuse->used_tables & ~join->const_table_map)) const_part|= keyuse->keypart_map; - double tmp= prev_record_reads(join, (found_ref | + double tmp2= prev_record_reads(join, (found_ref | keyuse->used_tables)); - if (tmp < best_prev_record_reads) + if (tmp2 < best_prev_record_reads) { best_part_found_ref= keyuse->used_tables & ~join->const_table_map; - best_prev_record_reads= tmp; + best_prev_record_reads= tmp2; } if (rec > keyuse->ref_table_rows) rec= keyuse->ref_table_rows; @@ -5732,37 +5730,42 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) */ COND *on_expr= *first_inner_tab->on_expr_ref; - table_map used_tables= join->const_table_map | - OUTER_REF_TABLE_BIT | RAND_TABLE_BIT; + table_map used_tables2= (join->const_table_map | + OUTER_REF_TABLE_BIT | RAND_TABLE_BIT); for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) { current_map= tab->table->map; - used_tables|= current_map; - COND *tmp= make_cond_for_table(on_expr, used_tables, current_map); - if (tmp) + used_tables2|= current_map; + COND *tmp_cond= make_cond_for_table(on_expr, used_tables2, + current_map); + if (tmp_cond) { JOIN_TAB *cond_tab= tab < first_inner_tab ? first_inner_tab : tab; /* First add the guards for match variables of all embedding outer join operations. */ - if (!(tmp= add_found_match_trig_cond(cond_tab->first_inner, - tmp, first_inner_tab))) + if (!(tmp_cond= add_found_match_trig_cond(cond_tab->first_inner, + tmp_cond, + first_inner_tab))) DBUG_RETURN(1); /* Now add the guard turning the predicate off for the null complemented row. */ DBUG_PRINT("info", ("Item_func_trig_cond")); - tmp= new Item_func_trig_cond(tmp, - &first_inner_tab->not_null_compl); - DBUG_PRINT("info", ("Item_func_trig_cond 0x%lx", (ulong) tmp)); - if (tmp) - tmp->quick_fix_field(); + tmp_cond= new Item_func_trig_cond(tmp_cond, + &first_inner_tab-> + not_null_compl); + DBUG_PRINT("info", ("Item_func_trig_cond 0x%lx", + (ulong) tmp_cond)); + if (tmp_cond) + tmp_cond->quick_fix_field(); /* Add the predicate to other pushed down predicates */ DBUG_PRINT("info", ("Item_cond_and")); - cond_tab->select_cond= !cond_tab->select_cond ? tmp : - new Item_cond_and(cond_tab->select_cond,tmp); + cond_tab->select_cond= !cond_tab->select_cond ? tmp_cond : + new Item_cond_and(cond_tab->select_cond, + tmp_cond); DBUG_PRINT("info", ("Item_cond_and 0x%lx", (ulong)cond_tab->select_cond)); if (!cond_tab->select_cond) @@ -6079,7 +6082,7 @@ void JOIN_TAB::cleanup() void JOIN::join_free() { - SELECT_LEX_UNIT *unit; + SELECT_LEX_UNIT *tmp_unit; SELECT_LEX *sl; /* Optimization: if not EXPLAIN and we are done with the JOIN, @@ -6091,8 +6094,10 @@ void JOIN::join_free() cleanup(full); - for (unit= select_lex->first_inner_unit(); unit; unit= unit->next_unit()) - for (sl= unit->first_select(); sl; sl= sl->next_select()) + for (tmp_unit= select_lex->first_inner_unit(); + tmp_unit; + tmp_unit= tmp_unit->next_unit()) + for (sl= tmp_unit->first_select(); sl; sl= sl->next_select()) { Item_subselect *subselect= sl->master_unit()->item; bool full_local= full && (!subselect || subselect->is_evaluated()); @@ -6728,9 +6733,9 @@ static bool check_simple_equality(Item *left_item, Item *right_item, else { /* None of the fields was found in multiple equalities */ - Item_equal *item= new Item_equal((Item_field *) left_item, - (Item_field *) right_item); - cond_equal->current_level.push_back(item); + Item_equal *item_equal= new Item_equal((Item_field *) left_item, + (Item_field *) right_item); + cond_equal->current_level.push_back(item_equal); } } return TRUE; @@ -6837,8 +6842,8 @@ static bool check_row_equality(Item *left_row, Item_row *right_row, for (uint i= 0 ; i < n; i++) { bool is_converted; - Item *left_item= left_row->el(i); - Item *right_item= right_row->el(i); + Item *left_item= left_row->element_index(i); + Item *right_item= right_row->element_index(i); if (left_item->type() == Item::ROW_ITEM && right_item->type() == Item::ROW_ITEM) is_converted= check_row_equality((Item_row *) left_item, @@ -7228,14 +7233,15 @@ static COND *build_equal_items(THD *thd, COND *cond, { if (table->on_expr) { - List *join_list= table->nested_join ? - &table->nested_join->join_list : NULL; + List *nested_join_list= table->nested_join ? + &table->nested_join->join_list : NULL; /* We can modify table->on_expr because its old value will be restored before re-execution of PS/SP. */ table->on_expr= build_equal_items(thd, table->on_expr, inherited, - join_list, &table->cond_equal); + nested_join_list, + &table->cond_equal); } } } @@ -7592,7 +7598,7 @@ change_cond_ref_to_const(THD *thd, I_List *save_list, value->result_type() != STRING_RESULT || left_item->collation.collation == value->collation.collation)) { - Item *tmp=value->new_item(); + Item *tmp=value->clone_item(); tmp->collation.set(right_item->collation); if (tmp) @@ -7616,7 +7622,7 @@ change_cond_ref_to_const(THD *thd, I_List *save_list, value->result_type() != STRING_RESULT || right_item->collation.collation == value->collation.collation)) { - Item *tmp=value->new_item(); + Item *tmp= value->clone_item(); tmp->collation.set(left_item->collation); if (tmp) @@ -8237,7 +8243,6 @@ optimize_cond(JOIN *join, COND *conds, List *join_list, Item::cond_result *cond_value) { THD *thd= join->thd; - SELECT_LEX *select= thd->lex->current_select; DBUG_ENTER("optimize_cond"); if (!conds) @@ -14474,7 +14479,7 @@ int JOIN::rollup_send_data(uint idx) 1 if write_data_failed() */ -int JOIN::rollup_write_data(uint idx, TABLE *table) +int JOIN::rollup_write_data(uint idx, TABLE *table_arg) { uint i; for (i= send_group_parts ; i-- > idx ; ) @@ -14485,7 +14490,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table) ref_pointer_array_size); if ((!having || having->val_int())) { - int error; + int write_error; Item *item; List_iterator_fast it(rollup.fields[i]); while ((item= it++)) @@ -14494,10 +14499,10 @@ int JOIN::rollup_write_data(uint idx, TABLE *table) item->save_in_result_field(1); } copy_sum_funcs(sum_funcs_end[i+1], sum_funcs_end[i]); - if ((error= table->file->write_row(table->record[0]))) + if ((write_error= table_arg->file->write_row(table_arg->record[0]))) { - if (create_myisam_from_heap(thd, table, &tmp_table_param, - error, 0)) + if (create_myisam_from_heap(thd, table_arg, &tmp_table_param, + write_error, 0)) return 1; } } @@ -14678,9 +14683,9 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, } else { - TABLE_LIST *tab=table->pos_in_table_list; - item_list.push_back(new Item_string(tab->alias, - strlen(tab->alias), + TABLE_LIST *real_table= table->pos_in_table_list; + item_list.push_back(new Item_string(real_table->alias, + strlen(real_table->alias), cs)); } /* type */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ee310ea6fe4..2a0a2f07af4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -29,11 +29,11 @@ #include "ha_berkeley.h" // For berkeley_show_logs #endif +#ifndef NO_EMBEDDED_ACCESS_CHECKS static const char *grant_names[]={ "select","insert","update","delete","create","drop","reload","shutdown", "process","file","grant","references","index","alter"}; -#ifndef NO_EMBEDDED_ACCESS_CHECKS static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **), "grant_types", grant_names, NULL}; @@ -463,10 +463,10 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create_info) { - Security_context *sctx= thd->security_ctx; char buff[2048]; String buffer(buff, sizeof(buff), system_charset_info); #ifndef NO_EMBEDDED_ACCESS_CHECKS + Security_context *sctx= thd->security_ctx; uint db_access; #endif HA_CREATE_INFO create; @@ -795,7 +795,7 @@ static int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) { List field_list; - char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end; + char tmp[MAX_FIELD_WIDTH], *for_str, buff[128]; const char *alias; String type(tmp, sizeof(tmp), system_charset_info); Field **ptr,*field; @@ -1037,8 +1037,9 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) but may extrapolate its existence from that of an AUTO_INCREMENT column. */ - if(create_info.auto_increment_value > 1) + if (create_info.auto_increment_value > 1) { + char *end; packet->append(" AUTO_INCREMENT=", 16); end= longlong10_to_str(create_info.auto_increment_value, buff,10); packet->append(buff, (uint) (end - buff)); @@ -1060,6 +1061,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) if (share->min_rows) { + char *end; packet->append(STRING_WITH_LEN(" MIN_ROWS=")); end= longlong10_to_str(share->min_rows, buff, 10); packet->append(buff, (uint) (end- buff)); @@ -1067,6 +1069,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) if (share->max_rows && !table_list->schema_table) { + char *end; packet->append(STRING_WITH_LEN(" MAX_ROWS=")); end= longlong10_to_str(share->max_rows, buff, 10); packet->append(buff, (uint) (end - buff)); @@ -1074,6 +1077,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) if (share->avg_row_length) { + char *end; packet->append(STRING_WITH_LEN(" AVG_ROW_LENGTH=")); end= longlong10_to_str(share->avg_row_length, buff,10); packet->append(buff, (uint) (end - buff)); @@ -1444,7 +1448,7 @@ static bool show_status_array(THD *thd, const char *wild, long nr; if (show_type == SHOW_SYS) { - show_type= ((sys_var*) value)->type(); + show_type= ((sys_var*) value)->show_type(); value= (char*) ((sys_var*) value)->value_ptr(thd, value_type, &null_lex_str); } @@ -1490,7 +1494,7 @@ static bool show_status_array(THD *thd, const char *wild, break; } case SHOW_STARTTIME: - nr= (long) (thd->query_start() - start_time); + nr= (long) (thd->query_start() - server_start_time); end= int10_to_str(nr, buff, 10); break; case SHOW_QUESTION: @@ -2119,19 +2123,21 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) List bases; List_iterator_fast it(bases); COND *partial_cond; - Security_context *sctx= thd->security_ctx; uint derived_tables= lex->derived_tables; int error= 1; db_type not_used; Open_tables_state open_tables_state_backup; bool save_view_prepare_mode= lex->view_prepare_mode; Query_tables_list query_tables_list_backup; - lex->view_prepare_mode= TRUE; +#ifndef NO_EMBEDDED_ACCESS_CHECKS + Security_context *sctx= thd->security_ctx; +#endif DBUG_ENTER("get_all_tables"); LINT_INIT(end); LINT_INIT(len); + lex->view_prepare_mode= TRUE; lex->reset_n_backup_query_tables_list(&query_tables_list_backup); /* @@ -2369,7 +2375,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) bool with_i_schema; HA_CREATE_INFO create; TABLE *table= tables->table; +#ifndef NO_EMBEDDED_ACCESS_CHECKS Security_context *sctx= thd->security_ctx; +#endif DBUG_ENTER("fill_schema_shemata"); if (make_db_list(thd, &files, &idx_field_vals, @@ -2721,7 +2729,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, field->real_type() == MYSQL_TYPE_VARCHAR || // For varbinary type field->real_type() == MYSQL_TYPE_STRING) // For binary type { - uint32 octet_max_length= field->max_length(); + uint32 octet_max_length= field->max_display_length(); if (is_blob && octet_max_length != (uint32) 4294967295U) octet_max_length /= field->charset()->mbmaxlen; longlong char_max_len= is_blob ? @@ -2751,10 +2759,10 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, case FIELD_TYPE_LONG: case FIELD_TYPE_LONGLONG: case FIELD_TYPE_INT24: - field_length= field->max_length() - 1; + field_length= field->max_display_length() - 1; break; case FIELD_TYPE_BIT: - field_length= field->max_length(); + field_length= field->max_display_length(); decimals= -1; // return NULL break; case FIELD_TYPE_FLOAT: @@ -3421,8 +3429,8 @@ static int get_schema_key_column_usage_record(THD *thd, show_table->file->get_foreign_key_list(thd, &f_key_list); FOREIGN_KEY_INFO *f_key_info; - List_iterator_fast it(f_key_list); - while ((f_key_info= it++)) + List_iterator_fast fkey_it(f_key_list); + while ((f_key_info= fkey_it++)) { LEX_STRING *f_info; LEX_STRING *r_info; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 85ff1fddc45..ca90e7b1976 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -618,27 +618,26 @@ skip: } /* -** replace substring with string -** If wrong parameter or not enough memory, do nothing + Replace substring with string + If wrong parameter or not enough memory, do nothing */ - bool String::replace(uint32 offset,uint32 arg_length,const String &to) { return replace(offset,arg_length,to.ptr(),to.length()); } bool String::replace(uint32 offset,uint32 arg_length, - const char *to,uint32 length) + const char *to, uint32 to_length) { - long diff = (long) length-(long) arg_length; + long diff = (long) to_length-(long) arg_length; if (offset+arg_length <= str_length) { if (diff < 0) { - if (length) - memcpy(Ptr+offset,to,length); - bmove(Ptr+offset+length,Ptr+offset+arg_length, + if (to_length) + memcpy(Ptr+offset,to,to_length); + bmove(Ptr+offset+to_length,Ptr+offset+arg_length, str_length-offset-arg_length); } else @@ -650,8 +649,8 @@ bool String::replace(uint32 offset,uint32 arg_length, bmove_upp(Ptr+str_length+diff,Ptr+str_length, str_length-offset-arg_length); } - if (length) - memcpy(Ptr+offset,to,length); + if (to_length) + memcpy(Ptr+offset,to,to_length); } str_length+=(uint32) diff; } diff --git a/sql/sql_string.h b/sql/sql_string.h index 09b8478adf8..d7e9bff82e3 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -87,7 +87,8 @@ public: { /* never called */ } ~String() { free(); } - inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; } + inline void set_charset(CHARSET_INFO *charset_arg) + { str_charset= charset_arg; } inline CHARSET_INFO *charset() const { return str_charset; } inline uint32 length() const { return str_length;} inline uint32 alloced_length() const { return Alloced_length;} diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c14529f6eb1..1eb75215928 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -772,14 +772,14 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, interval= sql_field->interval= typelib(stmt_root, sql_field->interval_list); - List_iterator it(sql_field->interval_list); + List_iterator int_it(sql_field->interval_list); String conv, *tmp; char comma_buf[2]; int comma_length= cs->cset->wc_mb(cs, ',', (uchar*) comma_buf, (uchar*) comma_buf + sizeof(comma_buf)); DBUG_ASSERT(comma_length > 0); - for (uint i= 0; (tmp= it++); i++) + for (uint i= 0; (tmp= int_it++); i++) { uint lengthsp; if (String::needs_conversion(tmp->length(), tmp->charset(), @@ -2154,7 +2154,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *), int (view_operator_func)(THD *, TABLE_LIST*)) { - TABLE_LIST *table, *save_next_global, *save_next_local; + TABLE_LIST *table; SELECT_LEX *select= &thd->lex->select_lex; List field_list; Item *item; @@ -2185,30 +2185,33 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, strxmov(table_name, db, ".", table->table_name, NullS); thd->open_options|= extra_open_options; table->lock_type= lock_type; - /* open only one table from local list of command */ - save_next_global= table->next_global; - table->next_global= 0; - save_next_local= table->next_local; - table->next_local= 0; - select->table_list.first= (byte*)table; - /* - Time zone tables and SP tables can be add to lex->query_tables list, - so it have to be prepared. - TODO: Investigate if we can put extra tables into argument instead of - using lex->query_tables - */ - lex->query_tables= table; - lex->query_tables_last= &table->next_global; - lex->query_tables_own_last= 0; - thd->no_warnings_for_error= no_warnings_for_error; - if (view_operator_func == NULL) - table->required_type=FRMTYPE_TABLE; - open_and_lock_tables(thd, table); - thd->no_warnings_for_error= 0; - table->next_global= save_next_global; - table->next_local= save_next_local; - thd->open_options&= ~extra_open_options; + /* open only one table from local list of command */ + { + TABLE_LIST *save_next_global, *save_next_local; + save_next_global= table->next_global; + table->next_global= 0; + save_next_local= table->next_local; + table->next_local= 0; + select->table_list.first= (byte*)table; + /* + Time zone tables and SP tables can be add to lex->query_tables list, + so it have to be prepared. + TODO: Investigate if we can put extra tables into argument instead of + using lex->query_tables + */ + lex->query_tables= table; + lex->query_tables_last= &table->next_global; + lex->query_tables_own_last= 0; + thd->no_warnings_for_error= no_warnings_for_error; + if (view_operator_func == NULL) + table->required_type=FRMTYPE_TABLE; + open_and_lock_tables(thd, table); + thd->no_warnings_for_error= 0; + table->next_global= save_next_global; + table->next_local= save_next_local; + thd->open_options&= ~extra_open_options; + } if (prepare_func) { switch ((*prepare_func)(thd, table, check_opt)) { diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 817db2d8a79..617cce05525 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -771,8 +771,8 @@ bool Table_triggers_list::prepare_record1_accessors(TABLE *table) void Table_triggers_list::set_table(TABLE *new_table) { - table= new_table; - for (Field **field= table->triggers->record1_field ; *field ; field++) + trigger_table= new_table; + for (Field **field= new_table->triggers->record1_field ; *field ; field++) { (*field)->table= (*field)->orig_table= new_table; (*field)->table_name= &new_table->alias; @@ -1316,7 +1316,8 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, It is OK to allocate some memory on table's MEM_ROOT since this table instance will be thrown out at the end of rename anyway. */ - new_def.str= memdup_root(&table->mem_root, buff.ptr(), buff.length()); + new_def.str= memdup_root(&trigger_table->mem_root, buff.ptr(), + buff.length()); new_def.length= buff.length(); on_table_name->str= new_def.str + before_on_len; on_table_name->length= on_q_table_name_len; @@ -1496,17 +1497,17 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event, if (old_row_is_record1) { old_field= record1_field; - new_field= table->field; + new_field= trigger_table->field; } else { new_field= record1_field; - old_field= table->field; + old_field= trigger_table->field; } thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER); err_status= sp_trigger->execute_trigger - (thd, table->s->db, table->s->table_name, + (thd, trigger_table->s->db, trigger_table->s->table_name, &subject_table_grants[event][time_type]); thd->restore_sub_statement_state(&statement_state); } @@ -1542,7 +1543,7 @@ void Table_triggers_list::mark_fields_used(THD *thd, trg_event_type event) { /* We cannot mark fields which does not present in table. */ if (trg_field->field_idx != (uint)-1) - table->field[trg_field->field_idx]->query_id = thd->query_id; + trigger_table->field[trg_field->field_idx]->query_id = thd->query_id; } } } @@ -1573,7 +1574,7 @@ bool Table_triggers_list::is_updated_in_before_update_triggers(Field *fld) { if (trg_fld->get_settable_routine_parameter() && trg_fld->field_idx != (uint)-1 && - table->field[trg_fld->field_idx]->eq(fld)) + trigger_table->field[trg_fld->field_idx]->eq(fld)) return TRUE; } return FALSE; diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 7e0fadfa677..a708b1454f7 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -43,8 +43,9 @@ class Table_triggers_list: public Sql_alloc */ Field **new_field; Field **old_field; + /* TABLE instance for which this triggers list object was created */ - TABLE *table; + TABLE *trigger_table; /* Names of triggers. Should correspond to order of triggers on definitions_list, @@ -84,7 +85,7 @@ public: List definers_list; Table_triggers_list(TABLE *table_arg): - record1_field(0), table(table_arg) + record1_field(0), trigger_table(table_arg) { bzero((char *)bodies, sizeof(bodies)); bzero((char *)trigger_fields, sizeof(trigger_fields)); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 478b2dce370..c9637aef4ac 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -112,7 +112,7 @@ bool select_union::flush() */ bool -select_union::create_result_table(THD *thd, List *column_types, +select_union::create_result_table(THD *thd_arg, List *column_types, bool is_union_distinct, ulonglong options, const char *alias) { @@ -120,7 +120,7 @@ select_union::create_result_table(THD *thd, List *column_types, tmp_table_param.init(); tmp_table_param.field_count= column_types->elements; - if (! (table= create_tmp_table(thd, &tmp_table_param, *column_types, + if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types, (ORDER*) 0, is_union_distinct, 1, options, HA_POS_ERROR, (char*) alias))) return TRUE; @@ -142,9 +142,9 @@ select_union::create_result_table(THD *thd, List *column_types, */ void -st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) +st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) { - thd->lex->current_select= fake_select_lex; + thd_arg->lex->current_select= fake_select_lex; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next_local); @@ -198,7 +198,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, DBUG_RETURN(FALSE); } prepared= 1; - res= FALSE; + saved_error= FALSE; thd_arg->lex->current_select= sl= first_sl; found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS; @@ -239,23 +239,25 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, can_skip_order_by= is_union && !(sl->braces && sl->explicit_limit); - res= join->prepare(&sl->ref_pointer_array, - (TABLE_LIST*) sl->table_list.first, sl->with_wild, - sl->where, - (can_skip_order_by ? 0 : sl->order_list.elements) + - sl->group_list.elements, - can_skip_order_by ? - (ORDER*) 0 : (ORDER *)sl->order_list.first, - (ORDER*) sl->group_list.first, - sl->having, - (is_union ? (ORDER*) 0 : - (ORDER*) thd_arg->lex->proc_list.first), - sl, this); + saved_error= join->prepare(&sl->ref_pointer_array, + (TABLE_LIST*) sl->table_list.first, + sl->with_wild, + sl->where, + (can_skip_order_by ? 0 : + sl->order_list.elements) + + sl->group_list.elements, + can_skip_order_by ? + (ORDER*) 0 : (ORDER *)sl->order_list.first, + (ORDER*) sl->group_list.first, + sl->having, + (is_union ? (ORDER*) 0 : + (ORDER*) thd_arg->lex->proc_list.first), + sl, this); /* There are no * in the statement anymore (for PS) */ sl->with_wild= 0; last_procedure= join->procedure; - if ((res= (res || thd_arg->is_fatal_error))) + if (saved_error || (saved_error= thd_arg->is_fatal_error)) goto err; /* Use items list of underlaid select for derived tables to preserve @@ -350,12 +352,12 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, arena= thd->activate_stmt_arena_if_needed(&backup_arena); - res= table->fill_item_list(&item_list); + saved_error= table->fill_item_list(&item_list); if (arena) thd->restore_active_arena(arena, &backup_arena); - if (res) + if (saved_error) goto err; if (thd->stmt_arena->is_stmt_prepare()) @@ -374,7 +376,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, fake_select_lex->item_list= item_list; thd_arg->lex->current_select= fake_select_lex; - res= fake_select_lex->join-> + saved_error= fake_select_lex->join-> prepare(&fake_select_lex->ref_pointer_array, (TABLE_LIST*) fake_select_lex->table_list.first, 0, 0, @@ -399,7 +401,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, thd_arg->lex->current_select= lex_select_save; - DBUG_RETURN(res || thd_arg->is_fatal_error); + DBUG_RETURN(saved_error || thd_arg->is_fatal_error); err: thd_arg->lex->current_select= lex_select_save; @@ -441,7 +443,7 @@ bool st_select_lex_unit::exec() thd->lex->current_select= sl; if (optimized) - res= sl->join->reinit(); + saved_error= sl->join->reinit(); else { set_limit(sl); @@ -464,9 +466,9 @@ bool st_select_lex_unit::exec() sl->join->select_options= (select_limit_cnt == HA_POS_ERROR || sl->braces) ? sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union; - res= sl->join->optimize(); + saved_error= sl->join->optimize(); } - if (!res) + if (!saved_error) { records_at_start= table->file->records; sl->join->exec(); @@ -476,11 +478,11 @@ bool st_select_lex_unit::exec() DBUG_RETURN(TRUE); table->no_keyread=1; } - res= sl->join->error; + saved_error= sl->join->error; offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() : 0); - if (!res) + if (!saved_error) { examined_rows+= thd->examined_row_count; if (union_result->flush()) @@ -490,10 +492,10 @@ bool st_select_lex_unit::exec() } } } - if (res) + if (saved_error) { thd->lex->current_select= lex_select_save; - DBUG_RETURN(res); + DBUG_RETURN(saved_error); } /* Needed for the following test and for records_at_start in next loop */ int error= table->file->info(HA_STATUS_VARIABLE); @@ -519,7 +521,7 @@ bool st_select_lex_unit::exec() optimized= 1; /* Send result to 'result' */ - res= TRUE; + saved_error= TRUE; { List empty_list; empty_list.empty(); @@ -560,17 +562,17 @@ bool st_select_lex_unit::exec() } join->init(thd, item_list, fake_select_lex->options, result); } - res= mysql_select(thd, &fake_select_lex->ref_pointer_array, - &result_table_list, - 0, item_list, NULL, - global_parameters->order_list.elements, - (ORDER*)global_parameters->order_list.first, - (ORDER*) NULL, NULL, (ORDER*) NULL, - fake_select_lex->options | SELECT_NO_UNLOCK, - result, this, fake_select_lex); + saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array, + &result_table_list, + 0, item_list, NULL, + global_parameters->order_list.elements, + (ORDER*)global_parameters->order_list.first, + (ORDER*) NULL, NULL, (ORDER*) NULL, + fake_select_lex->options | SELECT_NO_UNLOCK, + result, this, fake_select_lex); fake_select_lex->table_list.empty(); - if (!res) + if (!saved_error) { thd->limit_found_rows = (ulonglong)table->file->records + add_rows; thd->examined_row_count+= examined_rows; @@ -582,7 +584,7 @@ bool st_select_lex_unit::exec() } } thd->lex->current_select= lex_select_save; - DBUG_RETURN(res); + DBUG_RETURN(saved_error); } @@ -659,18 +661,18 @@ void st_select_lex_unit::reinit_exec_mechanism() TRUE - error */ -bool st_select_lex_unit::change_result(select_subselect *result, +bool st_select_lex_unit::change_result(select_subselect *new_result, select_subselect *old_result) { bool res= FALSE; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { if (sl->join && sl->join->result == old_result) - if (sl->join->change_result(result)) + if (sl->join->change_result(new_result)) return TRUE; } if (fake_select_lex && fake_select_lex->join) - res= fake_select_lex->join->change_result(result); + res= fake_select_lex->join->change_result(new_result); return (res); } @@ -749,4 +751,3 @@ void st_select_lex::cleanup_all_joins(bool full) for (sl= unit->first_select(); sl; sl= sl->next_select()) sl->cleanup_all_joins(full); } - diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3b6aa5f1aa2..701a5ab3627 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -67,7 +67,6 @@ static bool check_fields(THD *thd, List &items) List_iterator it(items); Item *item; Item_field *field; - Name_resolution_context *context= &thd->lex->select_lex.context; while ((item= it++)) { diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 53844eb0fd2..3ee85fe05af 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1136,7 +1136,6 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, /* Prepare a security context to check underlying objects of the view */ - Security_context *save_security_ctx= thd->security_ctx; if (!(table->view_sctx= (Security_context *) thd->stmt_arena->alloc(sizeof(Security_context)))) goto err; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6cbc01bdd46..1f63bb43fc1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4733,9 +4733,9 @@ simple_expr: } udf_expr_list ')' { + LEX *lex= Lex; #ifdef HAVE_DLOPEN udf_func *udf; - LEX *lex= Lex; if (NULL != (udf= lex->current_select->udf_list.pop())) { @@ -4814,7 +4814,6 @@ simple_expr: else #endif /* HAVE_DLOPEN */ { - LEX *lex= Lex; THD *thd= lex->thd; LEX_STRING db; if (thd->copy_db_to(&db.str, &db.length)) @@ -5277,7 +5276,6 @@ join_table: | table_ref normal_join table_ref USING { - SELECT_LEX *sel= Select; YYERROR_UNLESS($1 && $3); } '(' using_list ')' @@ -5308,7 +5306,6 @@ join_table: } | table_ref LEFT opt_outer JOIN_SYM table_factor { - SELECT_LEX *sel= Select; YYERROR_UNLESS($1 && $5); } USING '(' using_list ')' @@ -5342,7 +5339,6 @@ join_table: } | table_ref RIGHT opt_outer JOIN_SYM table_factor { - SELECT_LEX *sel= Select; YYERROR_UNLESS($1 && $5); } USING '(' using_list ')' @@ -9002,7 +8998,6 @@ subselect: } | '(' subselect_start subselect ')' { - LEX *lex= Lex; THD *thd= YYTHD; /* note that a local variable can't be used for diff --git a/sql/table.cc b/sql/table.cc index 4c1705b6b7a..bcd9bb71962 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -902,17 +902,17 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, if (share->blob_fields) { Field **ptr; - uint i, *save; + uint k, *save; /* Store offsets to blob fields to find them fast */ if (!(share->blob_field= save= (uint*) alloc_root(&outparam->mem_root, (uint) (share->blob_fields* sizeof(uint))))) goto err; - for (i=0, ptr= outparam->field ; *ptr ; ptr++, i++) + for (k=0, ptr= outparam->field ; *ptr ; ptr++, k++) { if ((*ptr)->flags & BLOB_FLAG) - (*save++)= i; + (*save++)= k; } } @@ -2171,19 +2171,17 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure) { if (check_option && check_option->val_int() == 0) { - TABLE_LIST *view= top_table(); + TABLE_LIST *main_view= top_table(); if (ignore_failure) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED), - view->view_db.str, view->view_name.str); + main_view->view_db.str, main_view->view_name.str); return(VIEW_CHECK_SKIP); } - else - { - my_error(ER_VIEW_CHECK_FAILED, MYF(0), view->view_db.str, view->view_name.str); - return(VIEW_CHECK_ERROR); - } + my_error(ER_VIEW_CHECK_FAILED, MYF(0), main_view->view_db.str, + main_view->view_name.str); + return(VIEW_CHECK_ERROR); } return(VIEW_CHECK_OK); } @@ -2195,19 +2193,20 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure) SYNOPSIS st_table_list::check_single_table() - table reference on variable where to store found table + table_arg reference on variable where to store found table (should be 0 on call, to find table, or point to table for unique test) map bit mask of tables - view view for which we are looking table + view_arg view for which we are looking table RETURN FALSE table not found or found only one TRUE found several tables */ -bool st_table_list::check_single_table(st_table_list **table, table_map map, - st_table_list *view) +bool st_table_list::check_single_table(st_table_list **table_arg, + table_map map, + st_table_list *view_arg) { for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local) { @@ -2215,13 +2214,13 @@ bool st_table_list::check_single_table(st_table_list **table, table_map map, { if (tbl->table->map & map) { - if (*table) + if (*table_arg) return TRUE; - *table= tbl; - tbl->check_option= view->check_option; + *table_arg= tbl; + tbl->check_option= view_arg->check_option; } } - else if (tbl->check_single_table(table, map, view)) + else if (tbl->check_single_table(table_arg, map, view_arg)) return TRUE; } return FALSE; @@ -2535,18 +2534,19 @@ bool st_table_list::prepare_security(THD *thd) while ((tbl= tb++)) { DBUG_ASSERT(tbl->referencing_view); - char *db, *table_name; + char *local_db, *local_table_name; if (tbl->view) { - db= tbl->view_db.str; - table_name= tbl->view_name.str; + local_db= tbl->view_db.str; + local_table_name= tbl->view_name.str; } else { - db= tbl->db; - table_name= tbl->table_name; + local_db= tbl->db; + local_table_name= tbl->table_name; } - fill_effective_table_privileges(thd, &tbl->grant, db, table_name); + fill_effective_table_privileges(thd, &tbl->grant, local_db, + local_table_name); if (tbl->table) tbl->table->grant= grant; } @@ -2909,8 +2909,8 @@ Field_iterator_table_ref::get_or_create_column_ref(TABLE_LIST *parent_table_ref) if (field_it == &table_field_it) { /* The field belongs to a stored table. */ - Field *field= table_field_it.field(); - nj_col= new Natural_join_column(field, table_ref); + Field *tmp_field= table_field_it.field(); + nj_col= new Natural_join_column(tmp_field, table_ref); field_count= table_ref->table->s->fields; } else if (field_it == &view_field_it) @@ -3021,16 +3021,16 @@ void st_table_list::reinit_before_use(THD *thd) is_schema_table_processed= FALSE; TABLE_LIST *embedded; /* The table at the current level of nesting. */ - TABLE_LIST *embedding= this; /* The parent nested table reference. */ + TABLE_LIST *parent_embedding= this; /* The parent nested table reference. */ do { - embedded= embedding; + embedded= parent_embedding; if (embedded->prep_on_expr) embedded->on_expr= embedded->prep_on_expr->copy_andor_structure(thd); - embedding= embedded->embedding; + parent_embedding= embedded->embedding; } - while (embedding && - embedding->nested_join->join_list.head() == embedded); + while (parent_embedding && + parent_embedding->nested_join->join_list.head() == embedded); } /* diff --git a/sql/tztime.cc b/sql/tztime.cc index 4becf4a9fcc..27946d8c306 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1756,8 +1756,8 @@ end_with_setting_default_tz: /* If we have default time zone try to load it */ if (default_tzname) { - String tmp_tzname(default_tzname, &my_charset_latin1); - if (!(global_system_variables.time_zone= my_tz_find(&tmp_tzname, tables))) + String tmp_tzname2(default_tzname, &my_charset_latin1); + if (!(global_system_variables.time_zone= my_tz_find(&tmp_tzname2, tables))) { sql_print_error("Fatal error: Illegal or unknown default time zone '%s'", default_tzname); diff --git a/sql/unireg.cc b/sql/unireg.cc index 8568b09e498..be18acf7d3f 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -83,7 +83,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, uchar fileinfo[64],forminfo[288],*keybuff; TYPELIB formnames; uchar *screen_buff; - char buff[2]; + char buff[128]; DBUG_ENTER("mysql_create_frm"); formnames.type_names=0; @@ -150,7 +150,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, create_info->comment.length, 60); if (tmp_len < create_info->comment.length) { - char buff[128]; (void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'", table); if ((thd->variables.sql_mode & @@ -179,13 +178,13 @@ bool mysql_create_frm(THD *thd, my_string file_name, goto err; int2store(buff, create_info->connect_string.length); - if (my_write(file, (const byte*)buff, sizeof(buff), MYF(MY_NABP)) || + if (my_write(file, (const byte*)buff, 2, MYF(MY_NABP)) || my_write(file, (const byte*)create_info->connect_string.str, create_info->connect_string.length, MYF(MY_NABP))) goto err; int2store(buff, str_db_type.length); - if (my_write(file, (const byte*)buff, sizeof(buff), MYF(MY_NABP)) || + if (my_write(file, (const byte*)buff, 2, MYF(MY_NABP)) || my_write(file, (const byte*)str_db_type.str, str_db_type.length, MYF(MY_NABP))) goto err; @@ -475,11 +474,11 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, create_field *field; while ((field=it++)) { - uint tmp_len= system_charset_info->cset->charpos(system_charset_info, field->comment.str, field->comment.str + - field->comment.length, 255); + field->comment.length, + 255); if (tmp_len < field->comment.length) { char buff[128]; @@ -548,8 +547,9 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, for (uint pos= 0; pos < field->interval->count; pos++) { char *dst; - uint length= field->save_interval->type_lengths[pos], hex_length; const char *src= field->save_interval->type_names[pos]; + uint hex_length; + length= field->save_interval->type_lengths[pos]; hex_length= length * 2; field->interval->type_lengths[pos]= hex_length; field->interval->type_names[pos]= dst= sql_alloc(hex_length + 1); diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 3e8b05580f6..83e71ea47a7 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -415,7 +415,7 @@ uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), { match->beg= 0; match->end= 0; - match->mblen= 0; + match->mb_len= 0; } return 1; /* Empty string is always found */ } @@ -443,13 +443,13 @@ skip: { match[0].beg= 0; match[0].end= (uint) (str- (const uchar*)b-1); - match[0].mblen= match[0].end; + match[0].mb_len= match[0].end; if (nmatch > 1) { match[1].beg= match[0].end; match[1].end= match[0].end+s_length; - match[1].mblen= match[1].end-match[1].beg; + match[1].mb_len= match[1].end-match[1].beg; } } return 2; diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index b4e9ba16d92..25025ceaa26 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5380,11 +5380,11 @@ my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)), static uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *strend) + const char *str, const char *str_end) { uint clen= 0; const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) strend; + const unsigned char *e= (const unsigned char *) str_end; for (clen= 0; b < e; ) { diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 65fef2dfc4c..06b0bdc70eb 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8435,11 +8435,11 @@ uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), static uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *strend) + const char *str, const char *str_end) { uint clen= 0; const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) strend; + const unsigned char *e= (const unsigned char *) str_end; for (clen= 0; b < e; ) { diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 3ef245015d7..01defaed0c7 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -186,7 +186,7 @@ int my_wildcmp_mb(CHARSET_INFO *cs, { /* Found w_many */ uchar cmp; const char* mb = wildstr; - int mblen=0; + int mb_len=0; wildstr++; /* Remove any '%' and '_' from the wild search string */ @@ -212,7 +212,7 @@ int my_wildcmp_mb(CHARSET_INFO *cs, cmp= *++wildstr; mb=wildstr; - mblen= my_ismbchar(cs, wildstr, wildend); + mb_len= my_ismbchar(cs, wildstr, wildend); INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ cmp=likeconv(cs,cmp); do @@ -221,11 +221,11 @@ int my_wildcmp_mb(CHARSET_INFO *cs, { if (str >= str_end) return -1; - if (mblen) + if (mb_len) { - if (str+mblen <= str_end && memcmp(str, mb, mblen) == 0) + if (str+mb_len <= str_end && memcmp(str, mb, mb_len) == 0) { - str += mblen; + str += mb_len; break; } } @@ -257,8 +257,8 @@ uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), register uint32 count=0; while (pos < end) { - uint mblen; - pos+= (mblen= my_ismbchar(cs,pos,end)) ? mblen : 1; + uint mb_len; + pos+= (mb_len= my_ismbchar(cs,pos,end)) ? mb_len : 1; count++; } return count; @@ -272,8 +272,8 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), while (length && pos < end) { - uint mblen; - pos+= (mblen= my_ismbchar(cs, pos, end)) ? mblen : 1; + uint mb_len; + pos+= (mb_len= my_ismbchar(cs, pos, end)) ? mb_len : 1; length--; } return (uint) (length ? end+2-start : pos-start); @@ -288,14 +288,14 @@ uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, while (pos) { my_wc_t wc; - int mblen; + int mb_len; - if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) + if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) { *error= b < e ? 1 : 0; break; } - b+= mblen; + b+= mb_len; pos--; } return (uint) (b - b_start); @@ -319,7 +319,7 @@ uint my_instr_mb(CHARSET_INFO *cs, { match->beg= 0; match->end= 0; - match->mblen= 0; + match->mb_len= 0; } return 1; /* Empty string is always found */ } @@ -329,7 +329,7 @@ uint my_instr_mb(CHARSET_INFO *cs, while (b < end) { - int mblen; + int mb_len; if (!cs->coll->strnncoll(cs, (unsigned char*) b, s_length, (unsigned char*) s, s_length, 0)) @@ -338,19 +338,19 @@ uint my_instr_mb(CHARSET_INFO *cs, { match[0].beg= 0; match[0].end= (uint) (b-b0); - match[0].mblen= res; + match[0].mb_len= res; if (nmatch > 1) { match[1].beg= match[0].end; match[1].end= match[0].end+s_length; - match[1].mblen= 0; /* Not computed */ + match[1].mb_len= 0; /* Not computed */ } } return 2; } - mblen= (mblen= my_ismbchar(cs, b, end)) ? mblen : 1; - b+= mblen; - b_length-= mblen; + mb_len= (mb_len= my_ismbchar(cs, b, end)) ? mb_len : 1; + b+= mb_len; + b_length-= mb_len; res++; } } @@ -551,7 +551,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, char *min_str,char *max_str, uint *min_length,uint *max_length) { - uint mblen; + uint mb_len; const char *end= ptr + ptr_length; char *min_org= min_str; char *min_end= min_str + res_length; @@ -588,11 +588,11 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, pad_max_char(cs, max_str, max_end); return 0; } - if ((mblen= my_ismbchar(cs, ptr, end)) > 1) + if ((mb_len= my_ismbchar(cs, ptr, end)) > 1) { - if (ptr+mblen > end || min_str+mblen > min_end) + if (ptr+mb_len > end || min_str+mb_len > min_end) break; - while (mblen--) + while (mb_len--) *min_str++= *max_str++= *ptr++; } else @@ -650,7 +650,7 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, { /* Found w_many */ uchar cmp; const char* mb = wildstr; - int mblen=0; + int mb_len=0; wildstr++; /* Remove any '%' and '_' from the wild search string */ @@ -676,7 +676,7 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, cmp= *++wildstr; mb=wildstr; - mblen= my_ismbchar(cs, wildstr, wildend); + mb_len= my_ismbchar(cs, wildstr, wildend); INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ do { @@ -684,11 +684,11 @@ static int my_wildcmp_mb_bin(CHARSET_INFO *cs, { if (str >= str_end) return -1; - if (mblen) + if (mb_len) { - if (str+mblen <= str_end && memcmp(str, mb, mblen) == 0) + if (str+mb_len <= str_end && memcmp(str, mb, mb_len) == 0) { - str += mblen; + str += mb_len; break; } } @@ -927,15 +927,15 @@ uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) while (b < e) { - int mblen; + int mb_len; uint pg; - if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) + if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) { - mblen= 1; /* Let's think a wrong sequence takes 1 dysplay cell */ + mb_len= 1; /* Let's think a wrong sequence takes 1 dysplay cell */ b++; continue; } - b+= mblen; + b+= mb_len; pg= (wc >> 8) & 0xFF; clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page; clen++; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index fc9cbfc9d21..eb8f2b41be4 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1174,7 +1174,7 @@ uint my_instr_simple(CHARSET_INFO *cs, { match->beg= 0; match->end= 0; - match->mblen= 0; + match->mb_len= 0; } return 1; /* Empty string is always found */ } @@ -1202,13 +1202,13 @@ skip: { match[0].beg= 0; match[0].end= (uint) (str- (const uchar*)b-1); - match[0].mblen= match[0].end; + match[0].mb_len= match[0].end; if (nmatch > 1) { match[1].beg= match[0].end; match[1].end= match[0].end+s_length; - match[1].mblen= match[1].end-match[1].beg; + match[1].mb_len= match[1].end-match[1].beg; } } return 2; @@ -1586,19 +1586,19 @@ exp: /* [ E [ ] ] */ str++; if (str < end) { - int negative_exp, exp; + int negative_exp, exponent; if ((negative_exp= (*str == '-')) || *str=='+') { if (++str == end) goto ret_sign; } - for (exp= 0 ; + for (exponent= 0 ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) { - exp= exp * 10 + ch; + exponent= exponent * 10 + ch; } - shift+= negative_exp ? -exp : exp; + shift+= negative_exp ? -exponent : exponent; } } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 3854837e09a..e27201eccbf 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4555,11 +4555,11 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), static uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *strend) + const char *str, const char *str_end) { uint clen= 0; const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) strend; + const unsigned char *e= (const unsigned char *) str_end; for (clen= 0; b < e; ) { diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index b18e5ee59d2..a51f358965a 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6929,23 +6929,23 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) uint16 **ucaw= scanner->uca_weight; uchar *ucal= scanner->uca_length; my_wc_t wc; - int mblen; + int mb_len; - if (((mblen= scanner->cs->cset->mb_wc(scanner->cs, &wc, + if (((mb_len= scanner->cs->cset->mb_wc(scanner->cs, &wc, scanner->sbeg, scanner->send)) <= 0)) return -1; scanner->page= wc >> 8; scanner->code= wc & 0xFF; - scanner->sbeg+= mblen; + scanner->sbeg+= mb_len; if (scanner->contractions && !scanner->page && (scanner->code > 0x40) && (scanner->code < 0x80)) { uint page1, code1, cweight; - if (((mblen= scanner->cs->cset->mb_wc(scanner->cs, &wc, + if (((mb_len= scanner->cs->cset->mb_wc(scanner->cs, &wc, scanner->sbeg, scanner->send)) >=0) && (!(page1= (wc >> 8))) && @@ -6955,7 +6955,7 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) { scanner->implicit[0]= 0; scanner->wbeg= scanner->implicit; - scanner->sbeg+= mblen; + scanner->sbeg+= mb_len; return cweight; } } @@ -7314,8 +7314,8 @@ int my_wildcmp_uca(CHARSET_INFO *cs, int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan; - int (*mb_wc)(struct charset_info_st *cs, my_wc_t *wc, - const unsigned char *s,const unsigned char *e); + int (*mb_wc)(struct charset_info_st *, my_wc_t *, + const unsigned char *, const unsigned char *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) @@ -7508,7 +7508,7 @@ typedef struct my_coll_lexem_st my_coll_lexem_init lexem Lex analizer to init str Const string to parse - strend End of the string + str_end End of the string USAGE RETURN VALUES @@ -7516,11 +7516,11 @@ typedef struct my_coll_lexem_st */ static void my_coll_lexem_init(MY_COLL_LEXEM *lexem, - const char *str, const char *strend) + const char *str, const char *str_end) { lexem->beg= str; lexem->prev= str; - lexem->end= strend; + lexem->end= str_end; lexem->diff= 0; lexem->code= 0; } @@ -7677,7 +7677,7 @@ typedef struct my_coll_rule_item_st my_coll_rule_parse rule Collation rule list to load to. str A string containin collation language expression. - strend End of the string. + str_end End of the string. USAGE RETURN VALUES @@ -7686,7 +7686,7 @@ typedef struct my_coll_rule_item_st */ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, - const char *str, const char *strend, + const char *str, const char *str_end, char *errstr, size_t errsize) { MY_COLL_LEXEM lexem; @@ -7699,7 +7699,7 @@ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, /* Init all variables */ errstr[0]= '\0'; bzero(&item, sizeof(item)); - my_coll_lexem_init(&lexem, str, strend); + my_coll_lexem_init(&lexem, str, str_end); while ((lexnum= my_coll_lexem_next(&lexem))) { diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 675ac918e2c..06a9358da35 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8303,11 +8303,11 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), static uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *strend) + const char *str, const char *str_end) { uint clen= 0; const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) strend; + const unsigned char *e= (const unsigned char *) str_end; for (clen= 0; b < e; ) { diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index a21fe4961ec..7fa2eb2d960 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1719,8 +1719,8 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan, plane; - int (*mb_wc)(struct charset_info_st *cs, my_wc_t *wc, - const unsigned char *s,const unsigned char *e); + int (*mb_wc)(struct charset_info_st *, my_wc_t *, + const unsigned char *, const unsigned char *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) diff --git a/strings/decimal.c b/strings/decimal.c index 6b7a2266194..2c0efc8ec92 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -371,16 +371,16 @@ int decimal2string(decimal_t *from, char *to, int *to_len, } else if (unlikely(len > --*to_len)) /* reserve one byte for \0 */ { - int i=len-*to_len; - error= (frac && i <= frac + 1) ? E_DEC_TRUNCATED : E_DEC_OVERFLOW; - if (frac && i >= frac + 1) i--; - if (i > frac) + int j= len-*to_len; + error= (frac && j <= frac + 1) ? E_DEC_TRUNCATED : E_DEC_OVERFLOW; + if (frac && j >= frac + 1) j--; + if (j > frac) { - intg-= i-frac; + intg-= j-frac; frac= 0; } else - frac-=i; + frac-=j; len= from->sign + intg_len + test(frac) + frac_len; } *to_len=len; @@ -900,7 +900,8 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed) if (endp+1 < end_of_string && (*endp == 'e' || *endp == 'E')) { int str_error; - longlong exp= my_strtoll10(endp+1, (char**) &end_of_string, &str_error); + longlong exponent= my_strtoll10(endp+1, (char**) &end_of_string, + &str_error); if (end_of_string != endp +1) /* If at least one digit */ { @@ -910,18 +911,18 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed) error= E_DEC_BAD_NUM; goto fatal_error; } - if (exp > INT_MAX/2 || (str_error == 0 && exp < 0)) + if (exponent > INT_MAX/2 || (str_error == 0 && exponent < 0)) { error= E_DEC_OVERFLOW; goto fatal_error; } - if (exp < INT_MIN/2 && error != E_DEC_OVERFLOW) + if (exponent < INT_MIN/2 && error != E_DEC_OVERFLOW) { error= E_DEC_TRUNCATED; goto fatal_error; } if (error != E_DEC_OVERFLOW) - error= decimal_shift(to, (int) exp); + error= decimal_shift(to, (int) exponent); } } return error; @@ -2063,7 +2064,7 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2, { int frac1=ROUND_UP(from1->frac)*DIG_PER_DEC1, prec1=from1->intg+frac1, frac2=ROUND_UP(from2->frac)*DIG_PER_DEC1, prec2=from2->intg+frac2, - error, i, intg0, frac0, len1, len2, dintg, div=(!mod); + error, i, intg0, frac0, len1, len2, dintg, div_mod=(!mod); dec1 *buf0, *buf1=from1->buf, *buf2=from2->buf, *tmp1, *start2, *stop2, *stop1, *stop0, norm2, carry, *start1, dcarry; dec2 norm_factor, x, guess, y; @@ -2146,7 +2147,7 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2, } buf0=to->buf; stop0=buf0+intg0+frac0; - if (likely(div)) + if (likely(div_mod)) while (dintg++ < 0) *buf0++=0; @@ -2237,7 +2238,7 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2, } } } - if (likely(div)) + if (likely(div_mod)) *buf0=(dec1)guess; dcarry= *start1; start1++; diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index e4302f50c58..2635a0461b0 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -22,6 +22,13 @@ /* Limited snprintf() implementations + SYNOPSIS + my_vsnprintf() + to Store result here + n Store up to n-1 characters, followed by an end 0 + fmt printf format + ap Arguments + IMPLEMENTION: Supports following formats: %#[l]d diff --git a/strings/strtod.c b/strings/strtod.c index ddb570718a0..f651959d4ee 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -58,7 +58,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) { double result= 0.0; uint negative= 0, ndigits, dec_digits= 0, neg_exp= 0; - int exp= 0, digits_after_dec_point= 0, tmp_exp; + int exponent= 0, digits_after_dec_point= 0, tmp_exp; const char *old_str, *end= *end_ptr, *start_of_number; char next_char; my_bool overflow=0; @@ -131,24 +131,25 @@ double my_strtod(const char *str, char **end_ptr, int *error) if ((next_char == 'e' || next_char == 'E') && dec_digits + ndigits != 0 && str < end-1) { - const char *old_str= str++; + const char *old_str2= str++; if ((neg_exp= (*str == '-')) || *str == '+') str++; if (str == end || !my_isdigit(&my_charset_latin1, *str)) - str= old_str; + str= old_str2; else { do { - if (exp < 9999) /* prot. against exp overfl. */ - exp= exp*10 + (*str - '0'); + if (exponent < 9999) /* prot. against exp overfl. */ + exponent= exponent*10 + (*str - '0'); str++; } while (str < end && my_isdigit(&my_charset_latin1, *str)); } } - tmp_exp= neg_exp ? exp + digits_after_dec_point : exp - digits_after_dec_point; + tmp_exp= (neg_exp ? exponent + digits_after_dec_point : + exponent - digits_after_dec_point); if (tmp_exp) { int order; @@ -158,7 +159,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) where f is the resulting floating point number and 1 <= C < 10. Here we compute the modulus */ - order= exp + (neg_exp ? -1 : 1) * (ndigits - 1); + order= exponent + (neg_exp ? -1 : 1) * (ndigits - 1); if (order < 0) order= -order; if (order >= MAX_DBL_EXP && result) @@ -184,18 +185,18 @@ double my_strtod(const char *str, char **end_ptr, int *error) } } - exp= tmp_exp; - if (exp < 0) + exponent= tmp_exp; + if (exponent < 0) { - exp= -exp; + exponent= -exponent; neg_exp= 1; /* neg_exp was 0 before */ } - while (exp >= 100) + while (exponent >= 100) { result= neg_exp ? result/1.0e100 : result*1.0e100; - exp-= 100; + exponent-= 100; } - scaler= scaler10[exp/10]*scaler1[exp%10]; + scaler= scaler10[exponent/10]*scaler1[exponent%10]; if (neg_exp) result/= scaler; else diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index aa993230a7f..a233ee81b31 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -254,9 +254,9 @@ static my_bool check_have_innodb(MYSQL *conn) */ MYSQL_STMT *STDCALL -mysql_simple_prepare(MYSQL *mysql, const char *query) +mysql_simple_prepare(MYSQL *mysql_arg, const char *query) { - MYSQL_STMT *stmt= mysql_stmt_init(mysql); + MYSQL_STMT *stmt= mysql_stmt_init(mysql_arg); if (stmt && mysql_stmt_prepare(stmt, query, strlen(query))) { mysql_stmt_close(stmt); @@ -524,12 +524,12 @@ int my_process_result_set(MYSQL_RES *result) } -int my_process_result(MYSQL *mysql) +int my_process_result(MYSQL *mysql_arg) { MYSQL_RES *result; int row_count; - if (!(result= mysql_store_result(mysql))) + if (!(result= mysql_store_result(mysql_arg))) return 0; row_count= my_process_result_set(result); @@ -1567,7 +1567,7 @@ static void test_prepare() ulong length[7], len; my_bool is_null[7]; char llbuf[22]; - MYSQL_BIND bind[7]; + MYSQL_BIND my_bind[7]; char query[MAX_TEST_QUERY_LENGTH]; myheader("test_prepare"); @@ -1591,39 +1591,39 @@ static void test_prepare() verify_param_count(stmt, 7); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* tinyint */ - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&tiny_data; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&tiny_data; /* string */ - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)str_data; - bind[1].buffer_length= 1000; /* Max string length */ + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)str_data; + my_bind[1].buffer_length= 1000; /* Max string length */ /* integer */ - bind[2].buffer_type= MYSQL_TYPE_LONG; - bind[2].buffer= (void *)&int_data; + my_bind[2].buffer_type= MYSQL_TYPE_LONG; + my_bind[2].buffer= (void *)&int_data; /* short */ - bind[3].buffer_type= MYSQL_TYPE_SHORT; - bind[3].buffer= (void *)&small_data; + my_bind[3].buffer_type= MYSQL_TYPE_SHORT; + my_bind[3].buffer= (void *)&small_data; /* bigint */ - bind[4].buffer_type= MYSQL_TYPE_LONGLONG; - bind[4].buffer= (void *)&big_data; + my_bind[4].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[4].buffer= (void *)&big_data; /* float */ - bind[5].buffer_type= MYSQL_TYPE_FLOAT; - bind[5].buffer= (void *)&real_data; + my_bind[5].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[5].buffer= (void *)&real_data; /* double */ - bind[6].buffer_type= MYSQL_TYPE_DOUBLE; - bind[6].buffer= (void *)&double_data; + my_bind[6].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[6].buffer= (void *)&double_data; - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].length= &length[i]; - bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; + my_bind[i].is_null= &is_null[i]; is_null[i]= 0; } - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); int_data= 320; @@ -1658,7 +1658,7 @@ static void test_prepare() stmt= mysql_simple_prepare(mysql, "SELECT * FROM my_prepare"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); /* get the result */ @@ -1740,7 +1740,7 @@ static void test_double_compare() char real_data[10], tiny_data; double double_data; MYSQL_RES *result; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; ulong length[3]; char query[MAX_TEST_QUERY_LENGTH]; @@ -1768,27 +1768,27 @@ static void test_double_compare() verify_param_count(stmt, 3); /* Always bzero bind array because there can be internal members */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* tinyint */ - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&tiny_data; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&tiny_data; /* string->float */ - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)&real_data; - bind[1].buffer_length= sizeof(real_data); - bind[1].length= &length[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)&real_data; + my_bind[1].buffer_length= sizeof(real_data); + my_bind[1].length= &length[1]; length[1]= 10; /* double */ - bind[2].buffer_type= MYSQL_TYPE_DOUBLE; - bind[2].buffer= (void *)&double_data; + my_bind[2].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[2].buffer= (void *)&double_data; tiny_data= 1; strmov(real_data, "10.2"); double_data= 34.5; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -1823,7 +1823,7 @@ static void test_null() MYSQL_STMT *stmt; int rc; uint nData; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; my_bool is_null[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -1847,14 +1847,14 @@ static void test_null() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].is_null= &is_null[0]; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].is_null= &is_null[0]; is_null[0]= 1; - bind[1]= bind[0]; + my_bind[1]= my_bind[0]; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); /* now, execute the prepared statement to insert 10 records.. */ @@ -1865,11 +1865,11 @@ static void test_null() } /* Re-bind with MYSQL_TYPE_NULL */ - bind[0].buffer_type= MYSQL_TYPE_NULL; + my_bind[0].buffer_type= MYSQL_TYPE_NULL; is_null[0]= 0; /* reset */ - bind[1]= bind[0]; + my_bind[1]= my_bind[0]; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); for (nData= 0; nData<10; nData++) @@ -1889,12 +1889,12 @@ static void test_null() DIE_UNLESS((int) nData == rc); /* Fetch results */ - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&nData; /* this buffer won't be altered */ - bind[0].length= 0; - bind[1]= bind[0]; - bind[0].is_null= &is_null[0]; - bind[1].is_null= &is_null[1]; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&nData; /* this buffer won't be altered */ + my_bind[0].length= 0; + my_bind[1]= my_bind[0]; + my_bind[0].is_null= &is_null[0]; + my_bind[1].is_null= &is_null[1]; stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_null"); check_stmt(stmt); @@ -1902,7 +1902,7 @@ static void test_null() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= 0; @@ -2001,7 +2001,7 @@ static void test_fetch_null() MYSQL_STMT *stmt; int rc; int i, nData; - MYSQL_BIND bind[11]; + MYSQL_BIND my_bind[11]; ulong length[11]; my_bool is_null[11]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2029,14 +2029,14 @@ static void test_fetch_null() myquery(rc); /* fetch */ - bzero((char*) bind, sizeof(bind)); - for (i= 0; i < (int) array_elements(bind); i++) + bzero((char*) my_bind, sizeof(my_bind)); + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].buffer_type= MYSQL_TYPE_LONG; - bind[i].is_null= &is_null[i]; - bind[i].length= &length[i]; + my_bind[i].buffer_type= MYSQL_TYPE_LONG; + my_bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; } - bind[i-1].buffer= (void *)&nData; /* Last column is not null */ + my_bind[i-1].buffer= (void *)&nData; /* Last column is not null */ strmov((char *)query , "SELECT * FROM test_fetch_null"); @@ -2046,7 +2046,7 @@ static void test_fetch_null() stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2231,7 +2231,7 @@ static void test_select() int rc; char szData[25]; int nData= 1; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2265,21 +2265,21 @@ static void test_select() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* string data */ nData= 10; strmov(szData, (char *)"venu"); - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)szData; - bind[1].buffer_length= 4; - bind[1].length= &length[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)szData; + my_bind[1].buffer_length= 4; + my_bind[1].length= &length[1]; length[1]= 4; - bind[0].buffer= (void *)&nData; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&nData; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2301,7 +2301,7 @@ static void test_ps_conj_select() { MYSQL_STMT *stmt; int rc; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; int32 int_data; char str_data[32]; unsigned long str_length; @@ -2327,17 +2327,17 @@ static void test_ps_conj_select() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&int_data; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&int_data; - bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[1].buffer= (void *)str_data; - bind[1].buffer_length= array_elements(str_data); - bind[1].length= &str_length; + my_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[1].buffer= (void *)str_data; + my_bind[1].buffer_length= array_elements(str_data); + my_bind[1].length= &str_length; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); int_data= 1; @@ -2360,7 +2360,7 @@ static void test_bug1115() { MYSQL_STMT *stmt; int rc; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; ulong length[1]; char szData[11]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2410,16 +2410,16 @@ session_id char(9) NOT NULL, \ verify_param_count(stmt, 1); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); strmov(szData, (char *)"abc"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 3; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2429,14 +2429,14 @@ session_id char(9) NOT NULL, \ DIE_UNLESS(rc == 1); strmov(szData, (char *)"venu"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 4; - bind[0].is_null= 0; + my_bind[0].is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2446,14 +2446,14 @@ session_id char(9) NOT NULL, \ DIE_UNLESS(rc == 0); strmov(szData, (char *)"abc"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null= 0; + my_bind[0].is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2472,7 +2472,7 @@ static void test_bug1180() { MYSQL_STMT *stmt; int rc; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; ulong length[1]; char szData[11]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2495,17 +2495,17 @@ static void test_bug1180() verify_param_count(stmt, 1); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); strmov(szData, (char *)"abc"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null= 0; + my_bind[0].is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2515,14 +2515,14 @@ static void test_bug1180() DIE_UNLESS(rc == 0); strmov(szData, (char *)"1111"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 4; - bind[0].is_null= 0; + my_bind[0].is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2532,14 +2532,14 @@ static void test_bug1180() DIE_UNLESS(rc == 1); strmov(szData, (char *)"abc"); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)szData; - bind[0].buffer_length= 10; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)szData; + my_bind[0].buffer_length= 10; + my_bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null= 0; + my_bind[0].is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2562,7 +2562,7 @@ static void test_bug1644() MYSQL_STMT *stmt; MYSQL_RES *result; MYSQL_ROW row; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; int num; my_bool isnull; int rc, i; @@ -2584,18 +2584,18 @@ static void test_bug1644() verify_param_count(stmt, 4); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); num= 22; isnull= 0; for (i= 0 ; i < 4 ; i++) { - bind[i].buffer_type= MYSQL_TYPE_LONG; - bind[i].buffer= (void *)# - bind[i].is_null= &isnull; + my_bind[i].buffer_type= MYSQL_TYPE_LONG; + my_bind[i].buffer= (void *)# + my_bind[i].is_null= &isnull; } - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2603,9 +2603,9 @@ static void test_bug1644() isnull= 1; for (i= 0 ; i < 4 ; i++) - bind[i].is_null= &isnull; + my_bind[i].is_null= &isnull; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2614,9 +2614,9 @@ static void test_bug1644() isnull= 0; num= 88; for (i= 0 ; i < 4 ; i++) - bind[i].is_null= &isnull; + my_bind[i].is_null= &isnull; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2733,7 +2733,7 @@ static void test_simple_update() char szData[25]; int nData= 1; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2765,19 +2765,19 @@ static void test_simple_update() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); nData= 1; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= szData; /* string data */ - bind[0].buffer_length= sizeof(szData); - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= szData; /* string data */ + my_bind[0].buffer_length= sizeof(szData); + my_bind[0].length= &length[0]; length[0]= my_sprintf(szData, (szData, "updated-data")); - bind[1].buffer= (void *) &nData; - bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *) &nData; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -2812,7 +2812,7 @@ static void test_long_data() int rc, int_data; char *data= NullS; MYSQL_RES *result; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; char query[MAX_TEST_QUERY_LENGTH]; myheader("test_long_data"); @@ -2838,15 +2838,15 @@ static void test_long_data() verify_param_count(stmt, 3); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)&int_data; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&int_data; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[2]= bind[1]; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[2]= my_bind[1]; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); int_data= 999; @@ -2898,7 +2898,7 @@ static void test_long_data_str() long length; ulong length1; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; my_bool is_null[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -2920,20 +2920,20 @@ static void test_long_data_str() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)&length; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].is_null= &is_null[0]; + my_bind[0].buffer= (void *)&length; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].is_null= &is_null[0]; is_null[0]= 0; length= 0; - bind[1].buffer= data; /* string data */ - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].length= &length1; - bind[1].is_null= &is_null[1]; + my_bind[1].buffer= data; /* string data */ + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].length= &length1; + my_bind[1].is_null= &is_null[1]; is_null[1]= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); length= 40; @@ -2991,7 +2991,7 @@ static void test_long_data_str1() ulong max_blob_length, blob_length, length1; my_bool true_value; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; MYSQL_FIELD *field; char query[MAX_TEST_QUERY_LENGTH]; @@ -3013,18 +3013,18 @@ static void test_long_data_str1() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= data; /* string data */ - bind[0].buffer_length= sizeof(data); - bind[0].length= &length1; - bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= data; /* string data */ + my_bind[0].buffer_length= sizeof(data); + my_bind[0].length= &length1; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; length1= 0; - bind[1]= bind[0]; - bind[1].buffer_type= MYSQL_TYPE_BLOB; + my_bind[1]= my_bind[0]; + my_bind[1].buffer_type= MYSQL_TYPE_BLOB; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); length= my_sprintf(data, (data, "MySQL AB")); @@ -3105,29 +3105,29 @@ static void test_long_data_str1() DIE_UNLESS(field->max_length == max_blob_length); /* Fetch results into a data buffer that is smaller than data */ - bzero((char*) bind, sizeof(*bind)); - bind[0].buffer_type= MYSQL_TYPE_BLOB; - bind[0].buffer= (void *) &data; /* this buffer won't be altered */ - bind[0].buffer_length= 16; - bind[0].length= &blob_length; - bind[0].error= &bind[0].error_value; - rc= mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(*my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_BLOB; + my_bind[0].buffer= (void *) &data; /* this buffer won't be altered */ + my_bind[0].buffer_length= 16; + my_bind[0].length= &blob_length; + my_bind[0].error= &my_bind[0].error_value; + rc= mysql_stmt_bind_result(stmt, my_bind); data[16]= 0; rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); - DIE_UNLESS(bind[0].error_value); + DIE_UNLESS(my_bind[0].error_value); DIE_UNLESS(strlen(data) == 16); DIE_UNLESS(blob_length == max_blob_length); /* Fetch all data */ - bzero((char*) (bind+1), sizeof(*bind)); - bind[1].buffer_type= MYSQL_TYPE_BLOB; - bind[1].buffer= (void *) &data; /* this buffer won't be altered */ - bind[1].buffer_length= sizeof(data); - bind[1].length= &blob_length; + bzero((char*) (my_bind+1), sizeof(*my_bind)); + my_bind[1].buffer_type= MYSQL_TYPE_BLOB; + my_bind[1].buffer= (void *) &data; /* this buffer won't be altered */ + my_bind[1].buffer_length= sizeof(data); + my_bind[1].length= &blob_length; bzero(data, sizeof(data)); - mysql_stmt_fetch_column(stmt, bind+1, 0, 0); + mysql_stmt_fetch_column(stmt, my_bind+1, 0, 0); DIE_UNLESS(strlen(data) == max_blob_length); mysql_free_result(result); @@ -3148,7 +3148,7 @@ static void test_long_data_bin() char data[255]; long length; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -3170,15 +3170,15 @@ static void test_long_data_bin() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)&length; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&length; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; length= 0; - bind[1].buffer= data; /* string data */ - bind[1].buffer_type= MYSQL_TYPE_LONG_BLOB; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[1].buffer= data; /* string data */ + my_bind[1].buffer_type= MYSQL_TYPE_LONG_BLOB; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); length= 10; @@ -3227,7 +3227,7 @@ static void test_simple_delete() char szData[30]= {0}; int nData= 1; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -3260,20 +3260,20 @@ static void test_simple_delete() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); nData= 1; strmov(szData, "MySQL"); - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= szData; /* string data */ - bind[1].buffer_length= sizeof(szData); - bind[1].length= &length[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= szData; /* string data */ + my_bind[1].buffer_length= sizeof(szData); + my_bind[1].length= &length[1]; length[1]= 5; - bind[0].buffer= (void *)&nData; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&nData; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3310,7 +3310,7 @@ static void test_update() char szData[25]; int nData= 1; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length[2]; char query[MAX_TEST_QUERY_LENGTH]; @@ -3334,19 +3334,19 @@ static void test_update() verify_param_count(stmt, 2); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* string data */ - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= szData; - bind[0].buffer_length= sizeof(szData); - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= szData; + my_bind[0].buffer_length= sizeof(szData); + my_bind[0].length= &length[0]; length[0]= my_sprintf(szData, (szData, "inserted-data")); - bind[1].buffer= (void *)&nData; - bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&nData; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); nData= 100; @@ -3364,18 +3364,18 @@ static void test_update() nData= 100; /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= szData; - bind[0].buffer_length= sizeof(szData); - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= szData; + my_bind[0].buffer_length= sizeof(szData); + my_bind[0].length= &length[0]; length[0]= my_sprintf(szData, (szData, "updated-data")); - bind[1].buffer= (void *)&nData; - bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&nData; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3459,7 +3459,7 @@ static void test_bind_result() int nData; ulong length1; char szData[100]; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; my_bool is_null[2]; myheader("test_bind_result"); @@ -3484,21 +3484,21 @@ static void test_bind_result() /* fetch */ - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *) &nData; /* integer data */ - bind[0].is_null= &is_null[0]; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *) &nData; /* integer data */ + my_bind[0].is_null= &is_null[0]; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= szData; /* string data */ - bind[1].buffer_length= sizeof(szData); - bind[1].length= &length1; - bind[1].is_null= &is_null[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= szData; /* string data */ + my_bind[1].buffer_length= sizeof(szData); + my_bind[1].length= &length1; + my_bind[1].is_null= &is_null[1]; stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3552,7 +3552,7 @@ static void test_bind_result_ext() double d_data; char szData[20], bData[20]; ulong szLength, bLength; - MYSQL_BIND bind[8]; + MYSQL_BIND my_bind[8]; ulong length[8]; my_bool is_null[8]; char llbuf[22]; @@ -3577,45 +3577,45 @@ static void test_bind_result_ext() rc= mysql_commit(mysql); myquery(rc); - bzero((char*) bind, sizeof(bind)); - for (i= 0; i < (int) array_elements(bind); i++) + bzero((char*) my_bind, sizeof(my_bind)); + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].length= &length[i]; - bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; + my_bind[i].is_null= &is_null[i]; } - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&t_data; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&t_data; - bind[1].buffer_type= MYSQL_TYPE_SHORT; - bind[2].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer_type= MYSQL_TYPE_SHORT; + my_bind[2].buffer_type= MYSQL_TYPE_LONG; - bind[3].buffer_type= MYSQL_TYPE_LONGLONG; - bind[1].buffer= (void *)&s_data; + my_bind[3].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[1].buffer= (void *)&s_data; - bind[2].buffer= (void *)&i_data; - bind[3].buffer= (void *)&b_data; + my_bind[2].buffer= (void *)&i_data; + my_bind[3].buffer= (void *)&b_data; - bind[4].buffer_type= MYSQL_TYPE_FLOAT; - bind[4].buffer= (void *)&f_data; + my_bind[4].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[4].buffer= (void *)&f_data; - bind[5].buffer_type= MYSQL_TYPE_DOUBLE; - bind[5].buffer= (void *)&d_data; + my_bind[5].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[5].buffer= (void *)&d_data; - bind[6].buffer_type= MYSQL_TYPE_STRING; - bind[6].buffer= (void *)szData; - bind[6].buffer_length= sizeof(szData); - bind[6].length= &szLength; + my_bind[6].buffer_type= MYSQL_TYPE_STRING; + my_bind[6].buffer= (void *)szData; + my_bind[6].buffer_length= sizeof(szData); + my_bind[6].length= &szLength; - bind[7].buffer_type= MYSQL_TYPE_TINY_BLOB; - bind[7].buffer= (void *)&bData; - bind[7].length= &bLength; - bind[7].buffer_length= sizeof(bData); + my_bind[7].buffer_type= MYSQL_TYPE_TINY_BLOB; + my_bind[7].buffer= (void *)&bData; + my_bind[7].length= &bLength; + my_bind[7].buffer_length= sizeof(bData); stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3673,7 +3673,7 @@ static void test_bind_result_ext1() long bData; char d_data[20]; double szData; - MYSQL_BIND bind[8]; + MYSQL_BIND my_bind[8]; ulong length[8]; my_bool is_null[8]; myheader("test_bind_result_ext1"); @@ -3696,57 +3696,57 @@ static void test_bind_result_ext1() rc= mysql_commit(mysql); myquery(rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *) t_data; - bind[0].buffer_length= sizeof(t_data); - bind[0].error= &bind[0].error_value; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *) t_data; + my_bind[0].buffer_length= sizeof(t_data); + my_bind[0].error= &my_bind[0].error_value; - bind[1].buffer_type= MYSQL_TYPE_FLOAT; - bind[1].buffer= (void *)&s_data; - bind[1].buffer_length= 0; - bind[1].error= &bind[1].error_value; + my_bind[1].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[1].buffer= (void *)&s_data; + my_bind[1].buffer_length= 0; + my_bind[1].error= &my_bind[1].error_value; - bind[2].buffer_type= MYSQL_TYPE_SHORT; - bind[2].buffer= (void *)&i_data; - bind[2].buffer_length= 0; - bind[2].error= &bind[2].error_value; + my_bind[2].buffer_type= MYSQL_TYPE_SHORT; + my_bind[2].buffer= (void *)&i_data; + my_bind[2].buffer_length= 0; + my_bind[2].error= &my_bind[2].error_value; - bind[3].buffer_type= MYSQL_TYPE_TINY; - bind[3].buffer= (void *)&b_data; - bind[3].buffer_length= 0; - bind[3].error= &bind[3].error_value; + my_bind[3].buffer_type= MYSQL_TYPE_TINY; + my_bind[3].buffer= (void *)&b_data; + my_bind[3].buffer_length= 0; + my_bind[3].error= &my_bind[3].error_value; - bind[4].buffer_type= MYSQL_TYPE_LONG; - bind[4].buffer= (void *)&f_data; - bind[4].buffer_length= 0; - bind[4].error= &bind[4].error_value; + my_bind[4].buffer_type= MYSQL_TYPE_LONG; + my_bind[4].buffer= (void *)&f_data; + my_bind[4].buffer_length= 0; + my_bind[4].error= &my_bind[4].error_value; - bind[5].buffer_type= MYSQL_TYPE_STRING; - bind[5].buffer= (void *)d_data; - bind[5].buffer_length= sizeof(d_data); - bind[5].error= &bind[5].error_value; + my_bind[5].buffer_type= MYSQL_TYPE_STRING; + my_bind[5].buffer= (void *)d_data; + my_bind[5].buffer_length= sizeof(d_data); + my_bind[5].error= &my_bind[5].error_value; - bind[6].buffer_type= MYSQL_TYPE_LONG; - bind[6].buffer= (void *)&bData; - bind[6].buffer_length= 0; - bind[6].error= &bind[6].error_value; + my_bind[6].buffer_type= MYSQL_TYPE_LONG; + my_bind[6].buffer= (void *)&bData; + my_bind[6].buffer_length= 0; + my_bind[6].error= &my_bind[6].error_value; - bind[7].buffer_type= MYSQL_TYPE_DOUBLE; - bind[7].buffer= (void *)&szData; - bind[7].buffer_length= 0; - bind[7].error= &bind[7].error_value; + my_bind[7].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[7].buffer= (void *)&szData; + my_bind[7].buffer_length= 0; + my_bind[7].error= &my_bind[7].error_value; - for (i= 0; i < array_elements(bind); i++) + for (i= 0; i < array_elements(my_bind); i++) { - bind[i].is_null= &is_null[i]; - bind[i].length= &length[i]; + my_bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; } stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3807,7 +3807,7 @@ static void bind_fetch(int row_count) double d_data; char s_data[10]; ulong length[10]; - MYSQL_BIND bind[7]; + MYSQL_BIND my_bind[7]; my_bool is_null[7]; stmt= mysql_simple_prepare(mysql, "INSERT INTO test_bind_fetch VALUES " @@ -3817,20 +3817,20 @@ static void bind_fetch(int row_count) verify_param_count(stmt, 7); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].buffer_type= MYSQL_TYPE_LONG; - bind[i].buffer= (void *) &data[i]; + my_bind[i].buffer_type= MYSQL_TYPE_LONG; + my_bind[i].buffer= (void *) &data[i]; } - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); while (count--) { rc= 10+count; - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { data[i]= rc+i; rc+= 12; @@ -3850,36 +3850,36 @@ static void bind_fetch(int row_count) stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch"); check_stmt(stmt); - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].buffer= (void *) &data[i]; - bind[i].length= &length[i]; - bind[i].is_null= &is_null[i]; + my_bind[i].buffer= (void *) &data[i]; + my_bind[i].length= &length[i]; + my_bind[i].is_null= &is_null[i]; } - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&i8_data; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&i8_data; - bind[1].buffer_type= MYSQL_TYPE_SHORT; - bind[1].buffer= (void *)&i16_data; + my_bind[1].buffer_type= MYSQL_TYPE_SHORT; + my_bind[1].buffer= (void *)&i16_data; - bind[2].buffer_type= MYSQL_TYPE_LONG; - bind[2].buffer= (void *)&i32_data; + my_bind[2].buffer_type= MYSQL_TYPE_LONG; + my_bind[2].buffer= (void *)&i32_data; - bind[3].buffer_type= MYSQL_TYPE_LONGLONG; - bind[3].buffer= (void *)&i64_data; + my_bind[3].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[3].buffer= (void *)&i64_data; - bind[4].buffer_type= MYSQL_TYPE_FLOAT; - bind[4].buffer= (void *)&f_data; + my_bind[4].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[4].buffer= (void *)&f_data; - bind[5].buffer_type= MYSQL_TYPE_DOUBLE; - bind[5].buffer= (void *)&d_data; + my_bind[5].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[5].buffer= (void *)&d_data; - bind[6].buffer_type= MYSQL_TYPE_STRING; - bind[6].buffer= (void *)&s_data; - bind[6].buffer_length= sizeof(s_data); + my_bind[6].buffer_type= MYSQL_TYPE_STRING; + my_bind[6].buffer= (void *)&s_data; + my_bind[6].buffer_length= sizeof(s_data); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -3958,10 +3958,10 @@ static void test_fetch_date() MYSQL_STMT *stmt; uint i; int rc, year; - char date[25], time[25], ts[25], ts_4[25], ts_6[20], dt[20]; + char date[25], my_time[25], ts[25], ts_4[25], ts_6[20], dt[20]; ulong d_length, t_length, ts_length, ts4_length, ts6_length, dt_length, y_length; - MYSQL_BIND bind[8]; + MYSQL_BIND my_bind[8]; my_bool is_null[8]; ulong length[8]; @@ -3990,46 +3990,46 @@ static void test_fetch_date() rc= mysql_commit(mysql); myquery(rc); - bzero((char*) bind, sizeof(bind)); - for (i= 0; i < array_elements(bind); i++) + bzero((char*) my_bind, sizeof(my_bind)); + for (i= 0; i < array_elements(my_bind); i++) { - bind[i].is_null= &is_null[i]; - bind[i].length= &length[i]; + my_bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; } - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[1]= bind[2]= bind[0]; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[1]= my_bind[2]= my_bind[0]; - bind[0].buffer= (void *)&date; - bind[0].buffer_length= sizeof(date); - bind[0].length= &d_length; + my_bind[0].buffer= (void *)&date; + my_bind[0].buffer_length= sizeof(date); + my_bind[0].length= &d_length; - bind[1].buffer= (void *)&time; - bind[1].buffer_length= sizeof(time); - bind[1].length= &t_length; + my_bind[1].buffer= (void *)&my_time; + my_bind[1].buffer_length= sizeof(my_time); + my_bind[1].length= &t_length; - bind[2].buffer= (void *)&ts; - bind[2].buffer_length= sizeof(ts); - bind[2].length= &ts_length; + my_bind[2].buffer= (void *)&ts; + my_bind[2].buffer_length= sizeof(ts); + my_bind[2].length= &ts_length; - bind[3].buffer_type= MYSQL_TYPE_LONG; - bind[3].buffer= (void *)&year; - bind[3].length= &y_length; + my_bind[3].buffer_type= MYSQL_TYPE_LONG; + my_bind[3].buffer= (void *)&year; + my_bind[3].length= &y_length; - bind[4].buffer_type= MYSQL_TYPE_STRING; - bind[4].buffer= (void *)&dt; - bind[4].buffer_length= sizeof(dt); - bind[4].length= &dt_length; + my_bind[4].buffer_type= MYSQL_TYPE_STRING; + my_bind[4].buffer= (void *)&dt; + my_bind[4].buffer_length= sizeof(dt); + my_bind[4].length= &dt_length; - bind[5].buffer_type= MYSQL_TYPE_STRING; - bind[5].buffer= (void *)&ts_4; - bind[5].buffer_length= sizeof(ts_4); - bind[5].length= &ts4_length; + my_bind[5].buffer_type= MYSQL_TYPE_STRING; + my_bind[5].buffer= (void *)&ts_4; + my_bind[5].buffer_length= sizeof(ts_4); + my_bind[5].length= &ts4_length; - bind[6].buffer_type= MYSQL_TYPE_STRING; - bind[6].buffer= (void *)&ts_6; - bind[6].buffer_length= sizeof(ts_6); - bind[6].length= &ts6_length; + my_bind[6].buffer_type= MYSQL_TYPE_STRING; + my_bind[6].buffer= (void *)&ts_6; + my_bind[6].buffer_length= sizeof(ts_6); + my_bind[6].length= &ts6_length; rc= my_stmt_result("SELECT * FROM test_bind_result"); DIE_UNLESS(rc == 1); @@ -4037,7 +4037,7 @@ static void test_fetch_date() stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -4050,7 +4050,7 @@ static void test_fetch_date() if (!opt_silent) { fprintf(stdout, "\n date : %s(%lu)", date, d_length); - fprintf(stdout, "\n time : %s(%lu)", time, t_length); + fprintf(stdout, "\n time : %s(%lu)", my_time, t_length); fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length); fprintf(stdout, "\n year : %d(%lu)", year, y_length); fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length); @@ -4061,7 +4061,7 @@ static void test_fetch_date() DIE_UNLESS(strcmp(date, "2002-01-02") == 0); DIE_UNLESS(d_length == 10); - DIE_UNLESS(strcmp(time, "12:49:00") == 0); + DIE_UNLESS(strcmp(my_time, "12:49:00") == 0); DIE_UNLESS(t_length == 8); DIE_UNLESS(strcmp(ts, "2002-01-02 17:46:59") == 0); @@ -4266,7 +4266,7 @@ static void test_prepare_ext() char tData= 1; short sData= 10; longlong bData= 20; - MYSQL_BIND bind[6]; + MYSQL_BIND my_bind[6]; char query[MAX_TEST_QUERY_LENGTH]; myheader("test_prepare_ext"); @@ -4319,33 +4319,33 @@ static void test_prepare_ext() verify_param_count(stmt, 6); /* Always bzero all members of bind parameter */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /*tinyint*/ - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&tData; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&tData; /*smallint*/ - bind[1].buffer_type= MYSQL_TYPE_SHORT; - bind[1].buffer= (void *)&sData; + my_bind[1].buffer_type= MYSQL_TYPE_SHORT; + my_bind[1].buffer= (void *)&sData; /*mediumint*/ - bind[2].buffer_type= MYSQL_TYPE_LONG; - bind[2].buffer= (void *)&nData; + my_bind[2].buffer_type= MYSQL_TYPE_LONG; + my_bind[2].buffer= (void *)&nData; /*int*/ - bind[3].buffer_type= MYSQL_TYPE_LONG; - bind[3].buffer= (void *)&nData; + my_bind[3].buffer_type= MYSQL_TYPE_LONG; + my_bind[3].buffer= (void *)&nData; /*integer*/ - bind[4].buffer_type= MYSQL_TYPE_LONG; - bind[4].buffer= (void *)&nData; + my_bind[4].buffer_type= MYSQL_TYPE_LONG; + my_bind[4].buffer= (void *)&nData; /*bigint*/ - bind[5].buffer_type= MYSQL_TYPE_LONGLONG; - bind[5].buffer= (void *)&bData; + my_bind[5].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[5].buffer= (void *)&bData; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); /* @@ -4484,7 +4484,7 @@ static void test_insert() char str_data[50]; char tiny_data; MYSQL_RES *result; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length; myheader("test_insert"); @@ -4510,19 +4510,19 @@ static void test_insert() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* tinyint */ - bind[0].buffer_type= MYSQL_TYPE_TINY; - bind[0].buffer= (void *)&tiny_data; + my_bind[0].buffer_type= MYSQL_TYPE_TINY; + my_bind[0].buffer= (void *)&tiny_data; /* string */ - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= str_data; - bind[1].buffer_length= sizeof(str_data);; - bind[1].length= &length; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= str_data; + my_bind[1].buffer_length= sizeof(str_data);; + my_bind[1].length= &length; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); /* now, execute the prepared statement to insert 10 records.. */ @@ -4651,7 +4651,7 @@ static void test_stmt_close() { MYSQL *lmysql; MYSQL_STMT *stmt1, *stmt2, *stmt3, *stmt_x; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; MYSQL_RES *result; unsigned int count; int rc; @@ -4732,13 +4732,13 @@ static void test_stmt_close() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)&count; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&count; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; count= 100; - rc= mysql_stmt_bind_param(stmt_x, bind); + rc= mysql_stmt_bind_param(stmt_x, my_bind); check_execute(stmt_x, rc); rc= mysql_stmt_execute(stmt_x); @@ -5166,7 +5166,7 @@ static void test_multi_stmt() int rc; uint32 id; char name[50]; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length[2]; my_bool is_null[2]; myheader("test_multi_stmt"); @@ -5194,25 +5194,25 @@ static void test_multi_stmt() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&id; - bind[0].is_null= &is_null[0]; - bind[0].length= &length[0]; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&id; + my_bind[0].is_null= &is_null[0]; + my_bind[0].length= &length[0]; is_null[0]= 0; length[0]= 0; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)name; - bind[1].buffer_length= sizeof(name); - bind[1].length= &length[1]; - bind[1].is_null= &is_null[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)name; + my_bind[1].buffer_length= sizeof(name); + my_bind[1].length= &length[1]; + my_bind[1].is_null= &is_null[1]; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); id= 10; @@ -5242,7 +5242,7 @@ static void test_multi_stmt() verify_param_count(stmt1, 2); - rc= mysql_stmt_bind_param(stmt1, bind); + rc= mysql_stmt_bind_param(stmt1, my_bind); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt2); @@ -5300,7 +5300,7 @@ static void test_manual_sample() int rc; char str_data[50]; ulonglong affected_rows; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; my_bool is_null; char query[MAX_TEST_QUERY_LENGTH]; @@ -5355,25 +5355,25 @@ static void test_manual_sample() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* INTEGER PART */ - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&int_data; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&int_data; /* STRING PART */ - bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[1].buffer= (void *)str_data; - bind[1].buffer_length= sizeof(str_data); + my_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[1].buffer= (void *)str_data; + my_bind[1].buffer_length= sizeof(str_data); /* SMALLINT PART */ - bind[2].buffer_type= MYSQL_TYPE_SHORT; - bind[2].buffer= (void *)&small_data; - bind[2].is_null= &is_null; + my_bind[2].buffer_type= MYSQL_TYPE_SHORT; + my_bind[2].buffer= (void *)&small_data; + my_bind[2].is_null= &is_null; is_null= 0; /* Bind the buffers */ - if (mysql_stmt_bind_param(stmt, bind)) + if (mysql_stmt_bind_param(stmt, my_bind)) { fprintf(stderr, "\n param bind failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); @@ -5459,7 +5459,7 @@ static void test_prepare_alter() { MYSQL_STMT *stmt; int rc, id; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; my_bool is_null; myheader("test_prepare_alter"); @@ -5482,14 +5482,14 @@ static void test_prepare_alter() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); is_null= 0; - bind[0].buffer_type= MYSQL_TYPE_SHORT; - bind[0].buffer= (void *)&id; - bind[0].is_null= &is_null; + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; + my_bind[0].buffer= (void *)&id; + my_bind[0].is_null= &is_null; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); id= 30; @@ -5689,7 +5689,7 @@ static void test_store_result() int rc; int32 nData; char szData[100]; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; ulong length, length1; my_bool is_null[2]; @@ -5711,24 +5711,24 @@ static void test_store_result() myquery(rc); /* fetch */ - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *) &nData; /* integer data */ - bind[0].length= &length; - bind[0].is_null= &is_null[0]; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *) &nData; /* integer data */ + my_bind[0].length= &length; + my_bind[0].is_null= &is_null[0]; length= 0; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= szData; /* string data */ - bind[1].buffer_length= sizeof(szData); - bind[1].length= &length1; - bind[1].is_null= &is_null[1]; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= szData; /* string data */ + my_bind[1].buffer_length= sizeof(szData); + my_bind[1].length= &length1; + my_bind[1].is_null= &is_null[1]; length1= 0; stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_store_result"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -5874,7 +5874,7 @@ static void test_store_result2() int rc; int nData; ulong length; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char query[MAX_TEST_QUERY_LENGTH]; myheader("test_store_result2"); @@ -5898,21 +5898,21 @@ static void test_store_result2() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *) &nData; /* integer data */ - bind[0].length= &length; - bind[0].is_null= 0; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *) &nData; /* integer data */ + my_bind[0].length= &length; + my_bind[0].is_null= 0; strmov((char *)query , "SELECT col1 FROM test_store_result where col1= ?"); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); nData= 10; length= 0; @@ -5961,7 +5961,7 @@ static void test_subselect() MYSQL_STMT *stmt; int rc, id; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; DBUG_ENTER("test_subselect"); myheader("test_subselect"); @@ -5992,17 +5992,17 @@ static void test_subselect() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *) &id; - bind[0].length= 0; - bind[0].is_null= 0; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *) &id; + my_bind[0].length= 0; + my_bind[0].is_null= 0; stmt= mysql_simple_prepare(mysql, "INSERT INTO test_sub2(id) SELECT * FROM test_sub1 WHERE id= ?"); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); id= 2; @@ -6033,10 +6033,10 @@ static void test_subselect() "from test_sub2 WHERE id1= ?)")); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); id= 7; @@ -6082,7 +6082,7 @@ static void test_bind_date_conv(uint row_count) MYSQL_STMT *stmt= 0; uint rc, i, count= row_count; ulong length[4]; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; my_bool is_null[4]= {0}; MYSQL_TIME tm[4]; ulong second_part; @@ -6097,19 +6097,19 @@ static void test_bind_date_conv(uint row_count) We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; - bind[1].buffer_type= MYSQL_TYPE_TIME; - bind[2].buffer_type= MYSQL_TYPE_DATETIME; - bind[3].buffer_type= MYSQL_TYPE_DATE; + my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; + my_bind[1].buffer_type= MYSQL_TYPE_TIME; + my_bind[2].buffer_type= MYSQL_TYPE_DATETIME; + my_bind[3].buffer_type= MYSQL_TYPE_DATE; - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { - bind[i].buffer= (void *) &tm[i]; - bind[i].is_null= &is_null[i]; - bind[i].length= &length[i]; - bind[i].buffer_length= 30; + my_bind[i].buffer= (void *) &tm[i]; + my_bind[i].is_null= &is_null[i]; + my_bind[i].length= &length[i]; + my_bind[i].buffer_length= 30; length[i]= 20; } @@ -6123,16 +6123,16 @@ static void test_bind_date_conv(uint row_count) minute= 16; sec= 20; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); for (count= 0; count < row_count; count++) { - for (i= 0; i < (int) array_elements(bind); i++) + for (i= 0; i < (int) array_elements(my_bind); i++) { tm[i].neg= 0; tm[i].second_part= second_part+count; - if (bind[i].buffer_type != MYSQL_TYPE_TIME) + if (my_bind[i].buffer_type != MYSQL_TYPE_TIME) { tm[i].year= year+count; tm[i].month= month+count; @@ -6140,7 +6140,7 @@ static void test_bind_date_conv(uint row_count) } else tm[i].year= tm[i].month= tm[i].day= 0; - if (bind[i].buffer_type != MYSQL_TYPE_DATE) + if (my_bind[i].buffer_type != MYSQL_TYPE_DATE) { tm[i].hour= hour+count; tm[i].minute= minute+count; @@ -6164,7 +6164,7 @@ static void test_bind_date_conv(uint row_count) stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_date"); check_stmt(stmt); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -6180,7 +6180,7 @@ static void test_bind_date_conv(uint row_count) if (!opt_silent) fprintf(stdout, "\n"); - for (i= 0; i < array_elements(bind); i++) + for (i= 0; i < array_elements(my_bind); i++) { if (!opt_silent) fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", @@ -6317,7 +6317,7 @@ static void test_date_dt() static void test_pure_coverage() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int rc; ulong length; @@ -6354,18 +6354,18 @@ static void test_pure_coverage() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].length= &length; - bind[0].is_null= 0; - bind[0].buffer_length= 0; + my_bind[0].length= &length; + my_bind[0].is_null= 0; + my_bind[0].buffer_length= 0; - bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute_r(stmt, rc); /* unsupported buffer type */ - bind[0].buffer_type= MYSQL_TYPE_STRING; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); @@ -6379,8 +6379,8 @@ static void test_pure_coverage() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; - rc= mysql_stmt_bind_result(stmt, bind); + my_bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute_r(stmt, rc); /* unsupported buffer type */ rc= mysql_stmt_store_result(stmt); @@ -6400,7 +6400,7 @@ static void test_pure_coverage() static void test_buffers() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int rc; ulong length; my_bool is_null; @@ -6426,15 +6426,15 @@ static void test_buffers() bzero(buffer, sizeof(buffer)); /* Avoid overruns in printf() */ - bzero((char*) bind, sizeof(bind)); - bind[0].length= &length; - bind[0].is_null= &is_null; - bind[0].buffer_length= 1; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)buffer; - bind[0].error= &bind[0].error_value; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].length= &length; + my_bind[0].is_null= &is_null; + my_bind[0].buffer_length= 1; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)buffer; + my_bind[0].error= &my_bind[0].error_value; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); @@ -6443,15 +6443,15 @@ static void test_buffers() buffer[1]= 'X'; rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); - DIE_UNLESS(bind[0].error_value); + DIE_UNLESS(my_bind[0].error_value); if (!opt_silent) fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(buffer[0] == 'M'); DIE_UNLESS(buffer[1] == 'X'); DIE_UNLESS(length == 5); - bind[0].buffer_length= 8; - rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ + my_bind[0].buffer_length= 8; + rc= mysql_stmt_bind_result(stmt, my_bind);/* re-bind */ check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -6461,8 +6461,8 @@ static void test_buffers() DIE_UNLESS(strncmp(buffer, "Database", 8) == 0); DIE_UNLESS(length == 8); - bind[0].buffer_length= 12; - rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ + my_bind[0].buffer_length= 12; + rc= mysql_stmt_bind_result(stmt, my_bind);/* re-bind */ check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -6472,13 +6472,13 @@ static void test_buffers() DIE_UNLESS(strcmp(buffer, "Open-Source") == 0); DIE_UNLESS(length == 11); - bind[0].buffer_length= 6; - rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ + my_bind[0].buffer_length= 6; + rc= mysql_stmt_bind_result(stmt, my_bind);/* re-bind */ check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); - DIE_UNLESS(bind[0].error_value); + DIE_UNLESS(my_bind[0].error_value); if (!opt_silent) fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0); @@ -6594,7 +6594,7 @@ static void test_open_direct() static void test_fetch_nobuffs() { MYSQL_STMT *stmt; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; char str[4][50]; int rc; @@ -6615,16 +6615,16 @@ static void test_fetch_nobuffs() fprintf(stdout, "\n total rows : %d", rc); DIE_UNLESS(rc == 1); - bzero((char*) bind, sizeof(MYSQL_BIND)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)str[0]; - bind[0].buffer_length= sizeof(str[0]); - bind[1]= bind[2]= bind[3]= bind[0]; - bind[1].buffer= (void *)str[1]; - bind[2].buffer= (void *)str[2]; - bind[3].buffer= (void *)str[3]; + bzero((char*) my_bind, sizeof(MYSQL_BIND)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)str[0]; + my_bind[0].buffer_length= sizeof(str[0]); + my_bind[1]= my_bind[2]= my_bind[3]= my_bind[0]; + my_bind[1].buffer= (void *)str[1]; + my_bind[2].buffer= (void *)str[2]; + my_bind[3].buffer= (void *)str[3]; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -6655,7 +6655,7 @@ static void test_fetch_nobuffs() static void test_ushort_bug() { MYSQL_STMT *stmt; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; ushort short_value; uint32 long_value; ulong s_length, l_length, ll_length, t_length; @@ -6685,26 +6685,26 @@ static void test_ushort_bug() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_SHORT; - bind[0].buffer= (void *)&short_value; - bind[0].is_unsigned= TRUE; - bind[0].length= &s_length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; + my_bind[0].buffer= (void *)&short_value; + my_bind[0].is_unsigned= TRUE; + my_bind[0].length= &s_length; - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= (void *)&long_value; - bind[1].length= &l_length; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&long_value; + my_bind[1].length= &l_length; - bind[2].buffer_type= MYSQL_TYPE_LONGLONG; - bind[2].buffer= (void *)&longlong_value; - bind[2].length= &ll_length; + my_bind[2].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[2].buffer= (void *)&longlong_value; + my_bind[2].length= &ll_length; - bind[3].buffer_type= MYSQL_TYPE_TINY; - bind[3].buffer= (void *)&tiny_value; - bind[3].is_unsigned= TRUE; - bind[3].length= &t_length; + my_bind[3].buffer_type= MYSQL_TYPE_TINY; + my_bind[3].buffer= (void *)&tiny_value; + my_bind[3].is_unsigned= TRUE; + my_bind[3].length= &t_length; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -6743,7 +6743,7 @@ static void test_ushort_bug() static void test_sshort_bug() { MYSQL_STMT *stmt; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; short short_value; int32 long_value; ulong s_length, l_length, ll_length, t_length; @@ -6773,25 +6773,25 @@ static void test_sshort_bug() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_SHORT; - bind[0].buffer= (void *)&short_value; - bind[0].length= &s_length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; + my_bind[0].buffer= (void *)&short_value; + my_bind[0].length= &s_length; - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= (void *)&long_value; - bind[1].length= &l_length; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&long_value; + my_bind[1].length= &l_length; - bind[2].buffer_type= MYSQL_TYPE_LONGLONG; - bind[2].buffer= (void *)&longlong_value; - bind[2].length= &ll_length; + my_bind[2].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[2].buffer= (void *)&longlong_value; + my_bind[2].length= &ll_length; - bind[3].buffer_type= MYSQL_TYPE_TINY; - bind[3].buffer= (void *)&tiny_value; - bind[3].is_unsigned= TRUE; - bind[3].length= &t_length; + my_bind[3].buffer_type= MYSQL_TYPE_TINY; + my_bind[3].buffer= (void *)&tiny_value; + my_bind[3].is_unsigned= TRUE; + my_bind[3].length= &t_length; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -6830,7 +6830,7 @@ static void test_sshort_bug() static void test_stiny_bug() { MYSQL_STMT *stmt; - MYSQL_BIND bind[4]; + MYSQL_BIND my_bind[4]; short short_value; int32 long_value; ulong s_length, l_length, ll_length, t_length; @@ -6860,24 +6860,24 @@ static void test_stiny_bug() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_SHORT; - bind[0].buffer= (void *)&short_value; - bind[0].length= &s_length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; + my_bind[0].buffer= (void *)&short_value; + my_bind[0].length= &s_length; - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= (void *)&long_value; - bind[1].length= &l_length; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&long_value; + my_bind[1].length= &l_length; - bind[2].buffer_type= MYSQL_TYPE_LONGLONG; - bind[2].buffer= (void *)&longlong_value; - bind[2].length= &ll_length; + my_bind[2].buffer_type= MYSQL_TYPE_LONGLONG; + my_bind[2].buffer= (void *)&longlong_value; + my_bind[2].length= &ll_length; - bind[3].buffer_type= MYSQL_TYPE_TINY; - bind[3].buffer= (void *)&tiny_value; - bind[3].length= &t_length; + my_bind[3].buffer_type= MYSQL_TYPE_TINY; + my_bind[3].buffer= (void *)&tiny_value; + my_bind[3].length= &t_length; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -6917,7 +6917,7 @@ static void test_field_misc() { MYSQL_STMT *stmt; MYSQL_RES *result; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char table_type[NAME_LEN]; ulong type_length; int rc; @@ -6968,13 +6968,13 @@ static void test_field_misc() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= table_type; - bind[0].length= &type_length; - bind[0].buffer_length= NAME_LEN; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= table_type; + my_bind[0].length= &type_length; + my_bind[0].buffer_length= NAME_LEN; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7256,7 +7256,7 @@ static void test_prepare_grant() static void test_frm_bug() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; MYSQL_RES *result; MYSQL_ROW row; FILE *test_file; @@ -7280,13 +7280,13 @@ static void test_frm_bug() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= data_dir; - bind[0].buffer_length= FN_REFLEN; - bind[1]= bind[0]; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= data_dir; + my_bind[0].buffer_length= FN_REFLEN; + my_bind[1]= my_bind[0]; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7343,7 +7343,7 @@ static void test_frm_bug() static void test_decimal_bug() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char data[30]; int rc; my_bool is_null; @@ -7368,15 +7368,15 @@ static void test_decimal_bug() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL; - bind[0].buffer= (void *)data; - bind[0].buffer_length= 25; - bind[0].is_null= &is_null; + my_bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL; + my_bind[0].buffer= (void *)data; + my_bind[0].buffer_length= 25; + my_bind[0].is_null= &is_null; is_null= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); strmov(data, "8.0"); @@ -7384,7 +7384,7 @@ static void test_decimal_bug() check_execute(stmt, rc); data[0]= 0; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7402,7 +7402,7 @@ static void test_decimal_bug() check_execute(stmt, rc); data[0]= 0; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7427,7 +7427,7 @@ static void test_decimal_bug() check_execute(stmt, rc); data[0]= 0; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7783,7 +7783,7 @@ static void test_cuted_rows() static void test_logs() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char data[255]; ulong length; int rc; @@ -7806,20 +7806,20 @@ static void test_logs() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_SHORT; - bind[0].buffer= (void *)&id; + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; + my_bind[0].buffer= (void *)&id; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)&data; - bind[1].buffer_length= 255; - bind[1].length= &length; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)&data; + my_bind[1].buffer_length= 255; + my_bind[1].length= &length; id= 9876; length= (ulong)(strmov((char *)data, "MySQL - Open Source Database")- data); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -7863,14 +7863,14 @@ static void test_logs() stmt= mysql_simple_prepare(mysql, data); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bind[1].buffer_length= 255; - rc= mysql_stmt_bind_result(stmt, bind); + my_bind[1].buffer_length= 255; + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -7940,7 +7940,7 @@ static void test_nstmts() char query[255]; int rc; static uint i, total_stmts= 2000; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; myheader("test_nstmts"); @@ -7956,10 +7956,10 @@ static void test_nstmts() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)&i; - bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&i; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; for (i= 0; i < total_stmts; i++) { @@ -7970,7 +7970,7 @@ static void test_nstmts() stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -7986,7 +7986,7 @@ static void test_nstmts() check_execute(stmt, rc); i= 0; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -8010,7 +8010,7 @@ static void test_nstmts() static void test_fetch_seek() { MYSQL_STMT *stmt; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; MYSQL_ROW_OFFSET row; int rc; int32 c1; @@ -8030,22 +8030,22 @@ static void test_fetch_seek() stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&c1; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&c1; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)c2; - bind[1].buffer_length= sizeof(c2); + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)c2; + my_bind[1].buffer_length= sizeof(c2); - bind[2]= bind[1]; - bind[2].buffer= (void *)c3; - bind[2].buffer_length= sizeof(c3); + my_bind[2]= my_bind[1]; + my_bind[2].buffer= (void *)c3; + my_bind[2].buffer_length= sizeof(c3); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); @@ -8105,7 +8105,7 @@ static void test_fetch_seek() static void test_fetch_offset() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char data[11]; ulong length; int rc; @@ -8126,20 +8126,20 @@ static void test_fetch_offset() stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)data; - bind[0].buffer_length= 11; - bind[0].is_null= &is_null; - bind[0].length= &length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)data; + my_bind[0].buffer_length= 11; + my_bind[0].is_null= &is_null; + my_bind[0].length= &length; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute_r(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); @@ -8149,19 +8149,19 @@ static void test_fetch_offset() check_execute(stmt, rc); data[0]= '\0'; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "abcd", 4) == 0 && length == 10); - rc= mysql_stmt_fetch_column(stmt, bind, 0, 5); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 5); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "fg", 2) == 0 && length == 10); - rc= mysql_stmt_fetch_column(stmt, bind, 0, 9); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 9); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %s (%ld)", data, length); @@ -8172,7 +8172,7 @@ static void test_fetch_offset() is_null= 0; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); DIE_UNLESS(is_null == 1); @@ -8180,7 +8180,7 @@ static void test_fetch_offset() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute_r(stmt, rc); mysql_stmt_close(stmt); @@ -8194,7 +8194,7 @@ static void test_fetch_offset() static void test_fetch_column() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char c2[20], bc2[20]; ulong l1, l2, bl1, bl2; int rc, c1, bc1; @@ -8213,28 +8213,28 @@ static void test_fetch_column() stmt= mysql_simple_prepare(mysql, "select * from t1 order by c2 desc"); check_stmt(stmt); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&bc1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &bl1; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)bc2; - bind[1].buffer_length= 7; - bind[1].is_null= 0; - bind[1].length= &bl2; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&bc1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &bl1; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)bc2; + my_bind[1].buffer_length= 7; + my_bind[1].is_null= 0; + my_bind[1].length= &bl2; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); /* No-op at this point */ + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); /* No-op at this point */ check_execute_r(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -8244,33 +8244,33 @@ static void test_fetch_column() fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)c2; - bind[0].buffer_length= 7; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)c2; + my_bind[0].buffer_length= 7; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "venu", 4) == 0 && l2 == 4); c2[0]= '\0'; l2= 0; - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "venu") == 0 && l2 == 4); c1= 0; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&c1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &l1; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&c1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &l1; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); @@ -8283,33 +8283,33 @@ static void test_fetch_column() fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)c2; - bind[0].buffer_length= 7; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)c2; + my_bind[0].buffer_length= 7; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "mysq", 4) == 0 && l2 == 5); c2[0]= '\0'; l2= 0; - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "mysql") == 0 && l2 == 5); c1= 0; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&c1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &l1; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&c1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &l1; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); @@ -8318,7 +8318,7 @@ static void test_fetch_column() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); check_execute_r(stmt, rc); mysql_stmt_close(stmt); @@ -8475,7 +8475,7 @@ static void test_mem_overun() static void test_free_result() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char c2[5]; ulong bl1, l2; int rc, c1, bc1; @@ -8495,28 +8495,28 @@ static void test_free_result() stmt= mysql_simple_prepare(mysql, "select * from test_free_result"); check_stmt(stmt); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&bc1; - bind[0].length= &bl1; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&bc1; + my_bind[0].length= &bl1; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); c2[0]= '\0'; l2= 0; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)c2; - bind[0].buffer_length= 7; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)c2; + my_bind[0].buffer_length= 7; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); @@ -8526,13 +8526,13 @@ static void test_free_result() check_execute(stmt, rc); c1= 0, l2= 0; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&c1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&c1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); @@ -8556,7 +8556,7 @@ static void test_free_result() static void test_free_store_result() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char c2[5]; ulong bl1, l2; int rc, c1, bc1; @@ -8575,17 +8575,17 @@ static void test_free_store_result() stmt= mysql_simple_prepare(mysql, "select * from test_free_result"); check_stmt(stmt); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&bc1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &bl1; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&bc1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &bl1; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); @@ -8595,13 +8595,13 @@ static void test_free_store_result() check_execute(stmt, rc); c2[0]= '\0'; l2= 0; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)c2; - bind[0].buffer_length= 7; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)c2; + my_bind[0].buffer_length= 7; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); @@ -8611,13 +8611,13 @@ static void test_free_store_result() check_execute(stmt, rc); c1= 0, l2= 0; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&c1; - bind[0].buffer_length= 0; - bind[0].is_null= 0; - bind[0].length= &l2; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&c1; + my_bind[0].buffer_length= 0; + my_bind[0].is_null= 0; + my_bind[0].length= &l2; - rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0); check_execute(stmt, rc); if (!opt_silent) fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); @@ -8638,7 +8638,7 @@ static void test_free_store_result() static void test_sqlmode() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char c1[5], c2[5]; int rc; char query[MAX_TEST_QUERY_LENGTH]; @@ -8671,17 +8671,17 @@ static void test_sqlmode() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)c1; - bind[0].buffer_length= 2; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)c1; + my_bind[0].buffer_length= 2; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void *)c2; - bind[1].buffer_length= 3; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void *)c2; + my_bind[1].buffer_length= 3; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); strmov(c1, "My"); strmov(c2, "SQL"); @@ -8715,7 +8715,7 @@ static void test_sqlmode() if (!opt_silent) fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); strmov(c1, "My"); strmov(c2, "SQL"); @@ -8778,7 +8778,7 @@ static void test_sqlmode() static void test_ts() { MYSQL_STMT *stmt; - MYSQL_BIND bind[6]; + MYSQL_BIND my_bind[6]; MYSQL_TIME ts; MYSQL_RES *prep_res; char strts[30]; @@ -8811,22 +8811,22 @@ static void test_ts() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; - bind[0].buffer= (void *)&ts; - bind[0].buffer_length= sizeof(ts); + my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; + my_bind[0].buffer= (void *)&ts; + my_bind[0].buffer_length= sizeof(ts); - bind[2]= bind[1]= bind[0]; + my_bind[2]= my_bind[1]= my_bind[0]; - bind[3].buffer_type= MYSQL_TYPE_STRING; - bind[3].buffer= (void *)strts; - bind[3].buffer_length= sizeof(strts); - bind[3].length= &length; + my_bind[3].buffer_type= MYSQL_TYPE_STRING; + my_bind[3].buffer= (void *)strts; + my_bind[3].buffer_length= sizeof(strts); + my_bind[3].length= &length; - bind[5]= bind[4]= bind[3]; + my_bind[5]= my_bind[4]= my_bind[3]; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -8865,7 +8865,7 @@ static void test_ts() stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -8887,7 +8887,7 @@ static void test_ts() static void test_bug1500() { MYSQL_STMT *stmt; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; int rc; int32 int_data[3]= {2, 3, 4}; const char *data; @@ -8914,15 +8914,15 @@ static void test_bug1500() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer= (void *)int_data; - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[2]= bind[1]= bind[0]; - bind[1].buffer= (void *)(int_data + 1); - bind[2].buffer= (void *)(int_data + 2); + my_bind[0].buffer= (void *)int_data; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[2]= my_bind[1]= my_bind[0]; + my_bind[1].buffer= (void *)(int_data + 1); + my_bind[2].buffer= (void *)(int_data + 2); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -8953,13 +8953,13 @@ static void test_bug1500() verify_param_count(stmt, 1); data= "Dogs"; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *) data; - bind[0].buffer_length= strlen(data); - bind[0].is_null= 0; - bind[0].length= 0; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *) data; + my_bind[0].buffer_length= strlen(data); + my_bind[0].is_null= 0; + my_bind[0].length= 0; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -8978,11 +8978,11 @@ static void test_bug1500() verify_param_count(stmt, 1); data= "Grave"; - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *) data; - bind[0].buffer_length= strlen(data); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *) data; + my_bind[0].buffer_length= strlen(data); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -9061,7 +9061,7 @@ static void test_bug2247() int i; const char *create= "CREATE TABLE bug2247(id INT UNIQUE AUTO_INCREMENT)"; const char *insert= "INSERT INTO bug2247 VALUES (NULL)"; - const char *select= "SELECT id FROM bug2247"; + const char *SELECT= "SELECT id FROM bug2247"; const char *update= "UPDATE bug2247 SET id=id+10"; const char *drop= "DROP TABLE IF EXISTS bug2247"; ulonglong exp_count; @@ -9089,7 +9089,7 @@ static void test_bug2247() exp_count= mysql_stmt_affected_rows(stmt); DIE_UNLESS(exp_count == 1); - rc= mysql_query(mysql, select); + rc= mysql_query(mysql, SELECT); myquery(rc); /* mysql_store_result overwrites mysql->affected_rows. Check that @@ -9111,7 +9111,7 @@ static void test_bug2247() mysql_stmt_close(stmt); /* check that mysql_stmt_store_result modifies mysql_stmt_affected_rows */ - stmt= mysql_simple_prepare(mysql, select); + stmt= mysql_simple_prepare(mysql, SELECT); check_stmt(stmt); rc= mysql_stmt_execute(stmt); @@ -9700,7 +9700,7 @@ static void test_multi() { MYSQL_STMT *stmt_delete, *stmt_update, *stmt_select1, *stmt_select2; char *query; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int rc, i; int32 param= 1; ulong length= 1; @@ -9710,11 +9710,11 @@ static void test_multi() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)¶m; - bind[0].length= &length; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)¶m; + my_bind[0].length= &length; rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); @@ -9749,7 +9749,7 @@ static void test_multi() for(i= 0; i < 3; i++) { - rc= mysql_stmt_bind_param(stmt_update, bind); + rc= mysql_stmt_bind_param(stmt_update, my_bind); check_execute(stmt_update, rc); rc= mysql_stmt_execute(stmt_update); @@ -9837,7 +9837,7 @@ static void test_bind_nagative() MYSQL_STMT *stmt_insert; char *query; int rc; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int32 my_val= 0; ulong my_length= 0L; my_bool my_null= FALSE; @@ -9857,14 +9857,14 @@ static void test_bind_nagative() check_stmt(stmt_insert); /* bind parameters */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&my_val; - bind[0].length= &my_length; - bind[0].is_null= (char*)&my_null; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&my_val; + my_bind[0].length= &my_length; + my_bind[0].is_null= (char*)&my_null; - rc= mysql_stmt_bind_param(stmt_insert, bind); + rc= mysql_stmt_bind_param(stmt_insert, my_bind); check_execute(stmt_insert, rc); my_val= -1; @@ -9881,7 +9881,7 @@ static void test_derived() { MYSQL_STMT *stmt; int rc, i; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int32 my_val= 0; ulong my_length= 0L; my_bool my_null= FALSE; @@ -9906,14 +9906,14 @@ TYPE=InnoDB DEFAULT CHARSET=utf8"); We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *)&my_val; - bind[0].length= &my_length; - bind[0].is_null= (char*)&my_null; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *)&my_val; + my_bind[0].length= &my_length; + my_bind[0].is_null= (char*)&my_null; my_val= 1; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); for (i= 0; i < 3; i++) @@ -9987,7 +9987,7 @@ static void test_bug3035() { MYSQL_STMT *stmt; int rc; - MYSQL_BIND bind_array[12], *bind= bind_array, *bind_end= bind + 12; + MYSQL_BIND bind_array[12], *my_bind= bind_array, *bind_end= my_bind + 12; int8 int8_val; uint8 uint8_val; int16 int16_val; @@ -10040,8 +10040,8 @@ static void test_bug3035() bzero((char*) bind_array, sizeof(bind_array)); - for (bind= bind_array; bind < bind_end; bind++) - bind->error= &bind->error_value; + for (my_bind= bind_array; my_bind < bind_end; my_bind++) + my_bind->error= &my_bind->error_value; bind_array[0].buffer_type= MYSQL_TYPE_TINY; bind_array[0].buffer= (void *) &int8_val; @@ -10153,8 +10153,8 @@ static void test_bug3035() if (!opt_silent) { printf("Truncation mask: "); - for (bind= bind_array; bind < bind_end; bind++) - printf("%d", (int) bind->error_value); + for (my_bind= bind_array; my_bind < bind_end; my_bind++) + printf("%d", (int) my_bind->error_value); printf("\n"); } DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED || rc == 0); @@ -10229,7 +10229,7 @@ static void test_bug1664() int rc, int_data; const char *data; const char *str_data= "Simple string"; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; const char *query= "INSERT INTO test_long_data(col2, col1) VALUES(?, ?)"; myheader("test_bug1664"); @@ -10247,16 +10247,16 @@ static void test_bug1664() verify_param_count(stmt, 2); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *)str_data; - bind[0].buffer_length= strlen(str_data); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *)str_data; + my_bind[0].buffer_length= strlen(str_data); - bind[1].buffer= (void *)&int_data; - bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= (void *)&int_data; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); int_data= 1; @@ -10337,7 +10337,7 @@ static void test_bug1664() check_stmt(stmt); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); data= (char *)"SomeData"; @@ -10405,7 +10405,7 @@ static void test_union_param() MYSQL_STMT *stmt; char *query; int rc, i; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char my_val[4]; ulong my_length= 3L; my_bool my_null= FALSE; @@ -10421,21 +10421,21 @@ static void test_union_param() We need to bzero bind structure because mysql_stmt_bind_param checks all its members. */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); /* bind parameters */ - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (char*) &my_val; - bind[0].buffer_length= 4; - bind[0].length= &my_length; - bind[0].is_null= (char*)&my_null; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (char*) &my_val; - bind[1].buffer_length= 4; - bind[1].length= &my_length; - bind[1].is_null= (char*)&my_null; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (char*) &my_val; + my_bind[0].buffer_length= 4; + my_bind[0].length= &my_length; + my_bind[0].is_null= (char*)&my_null; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (char*) &my_val; + my_bind[1].buffer_length= 4; + my_bind[1].length= &my_length; + my_bind[1].is_null= (char*)&my_null; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); for (i= 0; i < 3; i++) @@ -10640,7 +10640,7 @@ static void test_ps_i18n() static void test_bug3796() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; const char *concat_arg0= "concat_with_"; enum { OUT_BUFF_SIZE= 30 }; char out_buff[OUT_BUFF_SIZE]; @@ -10672,23 +10672,23 @@ static void test_bug3796() check_execute(stmt, rc); /* Bind input buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void *) concat_arg0; - bind[0].buffer_length= strlen(concat_arg0); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void *) concat_arg0; + my_bind[0].buffer_length= strlen(concat_arg0); - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); /* Execute the select statement */ rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bind[0].buffer= (void *) out_buff; - bind[0].buffer_length= OUT_BUFF_SIZE; - bind[0].length= &out_length; + my_bind[0].buffer= (void *) out_buff; + my_bind[0].buffer_length= OUT_BUFF_SIZE; + my_bind[0].length= &out_length; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); if (!opt_silent) @@ -10721,7 +10721,7 @@ static void test_bug3796() static void test_bug4026() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; MYSQL_TIME time_in, time_out; MYSQL_TIME datetime_in, datetime_out; const char *stmt_text; @@ -10739,16 +10739,16 @@ static void test_bug4026() check_execute(stmt, rc); /* Bind input buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); bzero((char*) &time_in, sizeof(time_in)); bzero((char*) &time_out, sizeof(time_out)); bzero((char*) &datetime_in, sizeof(datetime_in)); bzero((char*) &datetime_out, sizeof(datetime_out)); - bind[0].buffer_type= MYSQL_TYPE_TIME; - bind[0].buffer= (void *) &time_in; - bind[1].buffer_type= MYSQL_TYPE_DATETIME; - bind[1].buffer= (void *) &datetime_in; + my_bind[0].buffer_type= MYSQL_TYPE_TIME; + my_bind[0].buffer= (void *) &time_in; + my_bind[1].buffer_type= MYSQL_TYPE_DATETIME; + my_bind[1].buffer= (void *) &datetime_in; time_in.hour= 23; time_in.minute= 59; @@ -10766,16 +10766,16 @@ static void test_bug4026() datetime_in.day= 31; datetime_in.time_type= MYSQL_TIMESTAMP_DATETIME; - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); /* Execute the select statement */ rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bind[0].buffer= (void *) &time_out; - bind[1].buffer= (void *) &datetime_out; + my_bind[0].buffer= (void *) &time_out; + my_bind[1].buffer= (void *) &datetime_out; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -10797,7 +10797,7 @@ static void test_bug4026() static void test_bug4079() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; const char *stmt_text; uint32 res; int rc; @@ -10821,12 +10821,12 @@ static void test_bug4079() check_execute(stmt, rc); /* Bind input buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void *) &res; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void *) &res; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc != 0 && rc != MYSQL_NO_DATA); @@ -10869,7 +10869,7 @@ static void test_bug4236() static void test_bug4030() { MYSQL_STMT *stmt; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; MYSQL_TIME time_canonical, time_out; MYSQL_TIME date_canonical, date_out; MYSQL_TIME datetime_canonical, datetime_out; @@ -10890,7 +10890,7 @@ static void test_bug4030() check_execute(stmt, rc); /* Bind output buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); bzero((char*) &time_canonical, sizeof(time_canonical)); bzero((char*) &time_out, sizeof(time_out)); bzero((char*) &date_canonical, sizeof(date_canonical)); @@ -10898,12 +10898,12 @@ static void test_bug4030() bzero((char*) &datetime_canonical, sizeof(datetime_canonical)); bzero((char*) &datetime_out, sizeof(datetime_out)); - bind[0].buffer_type= MYSQL_TYPE_TIME; - bind[0].buffer= (void *) &time_out; - bind[1].buffer_type= MYSQL_TYPE_DATE; - bind[1].buffer= (void *) &date_out; - bind[2].buffer_type= MYSQL_TYPE_DATETIME; - bind[2].buffer= (void *) &datetime_out; + my_bind[0].buffer_type= MYSQL_TYPE_TIME; + my_bind[0].buffer= (void *) &time_out; + my_bind[1].buffer_type= MYSQL_TYPE_DATE; + my_bind[1].buffer= (void *) &date_out; + my_bind[2].buffer_type= MYSQL_TYPE_DATETIME; + my_bind[2].buffer= (void *) &datetime_out; time_canonical.hour= 23; time_canonical.minute= 59; @@ -10922,7 +10922,7 @@ static void test_bug4030() datetime_canonical.day= 31; datetime_canonical.time_type= MYSQL_TIMESTAMP_DATETIME; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -10946,7 +10946,7 @@ static void test_view() { MYSQL_STMT *stmt; int rc, i; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char str_data[50]; ulong length = 0L; long is_null = 0L; @@ -10999,14 +10999,14 @@ static void test_view() check_execute(stmt, rc); strmov(str_data, "TEST"); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= FIELD_TYPE_STRING; - bind[0].buffer= (char *)&str_data; - bind[0].buffer_length= 50; - bind[0].length= &length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= FIELD_TYPE_STRING; + my_bind[0].buffer= (char *)&str_data; + my_bind[0].buffer_length= 50; + my_bind[0].length= &length; length= 4; - bind[0].is_null= (char*)&is_null; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[0].is_null= (char*)&is_null; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt,rc); for (i= 0; i < 3; i++) @@ -11072,7 +11072,7 @@ static void test_view_2where() { MYSQL_STMT *stmt; int rc, i; - MYSQL_BIND bind[8]; + MYSQL_BIND my_bind[8]; char parms[8][100]; ulong length[8]; const char *query= @@ -11120,21 +11120,21 @@ static void test_view_2where() " AENAME,T0001.DEPENDVARS AS DEPENDVARS,T0001.INACTIVE AS " " INACTIVE from LTDX T0001 where (T0001.SRTF2 = 0)"); myquery(rc); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i=0; i < 8; i++) { strmov(parms[i], "1"); - bind[i].buffer_type = MYSQL_TYPE_VAR_STRING; - bind[i].buffer = (char *)&parms[i]; - bind[i].buffer_length = 100; - bind[i].is_null = 0; - bind[i].length = &length[i]; + my_bind[i].buffer_type = MYSQL_TYPE_VAR_STRING; + my_bind[i].buffer = (char *)&parms[i]; + my_bind[i].buffer_length = 100; + my_bind[i].is_null = 0; + my_bind[i].length = &length[i]; length[i] = 1; } stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt,rc); rc= mysql_stmt_execute(stmt); @@ -11155,7 +11155,7 @@ static void test_view_star() { MYSQL_STMT *stmt; int rc, i; - MYSQL_BIND bind[8]; + MYSQL_BIND my_bind[8]; char parms[8][100]; ulong length[8]; const char *query= "SELECT * FROM vt1 WHERE a IN (?,?)"; @@ -11170,14 +11170,14 @@ static void test_view_star() myquery(rc); rc= mysql_query(mysql, "CREATE VIEW vt1 AS SELECT a FROM t1"); myquery(rc); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i= 0; i < 2; i++) { sprintf((char *)&parms[i], "%d", i); - bind[i].buffer_type = MYSQL_TYPE_VAR_STRING; - bind[i].buffer = (char *)&parms[i]; - bind[i].buffer_length = 100; - bind[i].is_null = 0; - bind[i].length = &length[i]; + my_bind[i].buffer_type = MYSQL_TYPE_VAR_STRING; + my_bind[i].buffer = (char *)&parms[i]; + my_bind[i].buffer_length = 100; + my_bind[i].is_null = 0; + my_bind[i].length = &length[i]; length[i] = 1; } @@ -11185,7 +11185,7 @@ static void test_view_star() rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt,rc); for (i= 0; i < 3; i++) @@ -11209,7 +11209,7 @@ static void test_view_insert() { MYSQL_STMT *insert_stmt, *select_stmt; int rc, i; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int my_val = 0; ulong my_length = 0L; long my_null = 0L; @@ -11237,12 +11237,12 @@ static void test_view_insert() rc= mysql_stmt_prepare(select_stmt, query, strlen(query)); check_execute(select_stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type = FIELD_TYPE_LONG; - bind[0].buffer = (char *)&my_val; - bind[0].length = &my_length; - bind[0].is_null = (char*)&my_null; - rc= mysql_stmt_bind_param(insert_stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type = FIELD_TYPE_LONG; + my_bind[0].buffer = (char *)&my_val; + my_bind[0].length = &my_length; + my_bind[0].is_null = (char*)&my_null; + rc= mysql_stmt_bind_param(insert_stmt, my_bind); check_execute(insert_stmt, rc); for (i= 0; i < 3; i++) @@ -11314,7 +11314,7 @@ static void test_view_insert_fields() char parm[11][1000]; ulong l[11]; int rc, i; - MYSQL_BIND bind[11]; + MYSQL_BIND my_bind[11]; const char *query= "INSERT INTO `v1` ( `K1C4` ,`K2C4` ,`K3C4` ,`K4N4` ,`F1C4` ,`F2I4` ,`F3N5` ,`F7F8` ,`F6N4` ,`F5C8` ,`F9D8` ) VALUES( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )"; myheader("test_view_insert_fields"); @@ -11344,22 +11344,22 @@ static void test_view_insert_fields() " F7F8 AS F7F8, F6N4 AS F6N4, F5C8 AS F5C8, F9D8 AS F9D8" " from t1 T0001"); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i= 0; i < 11; i++) { l[i]= 20; - bind[i].buffer_type= MYSQL_TYPE_STRING; - bind[i].is_null= 0; - bind[i].buffer= (char *)&parm[i]; + my_bind[i].buffer_type= MYSQL_TYPE_STRING; + my_bind[i].is_null= 0; + my_bind[i].buffer= (char *)&parm[i]; strmov(parm[i], "1"); - bind[i].buffer_length= 2; - bind[i].length= &l[i]; + my_bind[i].buffer_length= 2; + my_bind[i].length= &l[i]; } stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -11386,7 +11386,7 @@ static void test_view_insert_fields() static void test_bug5126() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; int32 c1, c2; const char *stmt_text; int rc; @@ -11413,14 +11413,14 @@ static void test_bug5126() check_execute(stmt, rc); /* Bind output buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= &c1; - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= &c2; + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= &c1; + my_bind[1].buffer_type= MYSQL_TYPE_LONG; + my_bind[1].buffer= &c2; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -11434,7 +11434,7 @@ static void test_bug5126() static void test_bug4231() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; MYSQL_TIME tm[2]; const char *stmt_text; int rc; @@ -11459,15 +11459,15 @@ static void test_bug4231() check_execute(stmt, rc); /* Bind input buffers */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); bzero((char*) tm, sizeof(tm)); - bind[0].buffer_type= MYSQL_TYPE_DATE; - bind[0].buffer= &tm[0]; - bind[1].buffer_type= MYSQL_TYPE_DATE; - bind[1].buffer= &tm[1]; + my_bind[0].buffer_type= MYSQL_TYPE_DATE; + my_bind[0].buffer= &tm[0]; + my_bind[1].buffer_type= MYSQL_TYPE_DATE; + my_bind[1].buffer= &tm[1]; - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); /* @@ -11513,16 +11513,16 @@ static void test_bug5399() #define NUM_OF_USED_STMT 97 MYSQL_STMT *stmt_list[NUM_OF_USED_STMT]; MYSQL_STMT **stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char buff[600]; int rc; int32 no; myheader("test_bug5399"); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= &no; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= &no; for (stmt= stmt_list; stmt != stmt_list + NUM_OF_USED_STMT; ++stmt) { @@ -11530,7 +11530,7 @@ static void test_bug5399() *stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(*stmt, buff, strlen(buff)); check_execute(*stmt, rc); - mysql_stmt_bind_result(*stmt, bind); + mysql_stmt_bind_result(*stmt, my_bind); } if (!opt_silent) printf("%d statements prepared.\n", NUM_OF_USED_STMT); @@ -11555,7 +11555,7 @@ static void test_bug5399() static void test_bug5194() { MYSQL_STMT *stmt; - MYSQL_BIND *bind; + MYSQL_BIND *my_bind; char *query; char *param_str; int param_str_length; @@ -11653,7 +11653,7 @@ static void test_bug5194() rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - bind= (MYSQL_BIND*) malloc(MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); + my_bind= (MYSQL_BIND*) malloc(MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); query= (char*) malloc(strlen(query_template) + MAX_PARAM_COUNT * CHARS_PER_PARAM + 1); param_str= (char*) malloc(COLUMN_COUNT * CHARS_PER_PARAM); @@ -11661,8 +11661,8 @@ static void test_bug5194() if (bind == 0 || query == 0 || param_str == 0) { fprintf(stderr, "Can't allocate enough memory for query structs\n"); - if (bind) - free(bind); + if (my_bind) + free(my_bind); if (query) free(query); if (param_str) @@ -11680,11 +11680,11 @@ static void test_bug5194() param_str_length= strlen(param_str); /* setup bind array */ - bzero((char*) bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); + bzero((char*) my_bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); for (i= 0; i < MAX_PARAM_COUNT; ++i) { - bind[i].buffer_type= MYSQL_TYPE_FLOAT; - bind[i].buffer= fa_ptr; + my_bind[i].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[i].buffer= fa_ptr; if (++fa_ptr == float_array + COLUMN_COUNT) fa_ptr= float_array; } @@ -11724,7 +11724,7 @@ static void test_bug5194() (int) strlen(query), nrows, mysql_stmt_param_count(stmt)); /* bind the parameter array and execute the query */ - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -11732,7 +11732,7 @@ static void test_bug5194() } mysql_stmt_close(stmt); - free(bind); + free(my_bind); free(query); free(param_str); stmt_text= "drop table t1"; @@ -11775,7 +11775,7 @@ static void test_bug5315() static void test_bug6049() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; MYSQL_RES *res; MYSQL_ROW row; const char *stmt_text; @@ -11798,13 +11798,13 @@ static void test_bug6049() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type = MYSQL_TYPE_STRING; - bind[0].buffer = &buffer; - bind[0].buffer_length = sizeof(buffer); - bind[0].length = &length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type = MYSQL_TYPE_STRING; + my_bind[0].buffer = &buffer; + my_bind[0].buffer_length = sizeof(buffer); + my_bind[0].length = &length; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -11824,7 +11824,7 @@ static void test_bug6049() static void test_bug6058() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; MYSQL_RES *res; MYSQL_ROW row; const char *stmt_text; @@ -11847,13 +11847,13 @@ static void test_bug6058() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type = MYSQL_TYPE_STRING; - bind[0].buffer = &buffer; - bind[0].buffer_length = sizeof(buffer); - bind[0].length = &length; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type = MYSQL_TYPE_STRING; + my_bind[0].buffer = &buffer; + my_bind[0].buffer_length = sizeof(buffer); + my_bind[0].length = &length; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -11892,7 +11892,7 @@ static void test_bug6046() const char *stmt_text; int rc; short b= 1; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; myheader("test_bug6046"); @@ -11915,11 +11915,11 @@ static void test_bug6046() check_execute(stmt, rc); b= 1; - bzero((char*) bind, sizeof(bind)); - bind[0].buffer= &b; - bind[0].buffer_type= MYSQL_TYPE_SHORT; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer= &b; + my_bind[0].buffer_type= MYSQL_TYPE_SHORT; - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12037,7 +12037,7 @@ static void test_bug6096() MYSQL_STMT *stmt; MYSQL_RES *query_result, *stmt_metadata; const char *stmt_text; - MYSQL_BIND bind[12]; + MYSQL_BIND my_bind[12]; MYSQL_FIELD *query_field_list, *stmt_field_list; ulong query_field_count, stmt_field_count; int rc; @@ -12110,14 +12110,14 @@ static void test_bug6096() /* Bind and fetch the data */ - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i= 0; i < stmt_field_count; ++i) { - bind[i].buffer_type= MYSQL_TYPE_STRING; - bind[i].buffer_length= stmt_field_list[i].max_length + 1; - bind[i].buffer= malloc(bind[i].buffer_length); + my_bind[i].buffer_type= MYSQL_TYPE_STRING; + my_bind[i].buffer_length= stmt_field_list[i].max_length + 1; + my_bind[i].buffer= malloc(my_bind[i].buffer_length); } - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -12126,7 +12126,7 @@ static void test_bug6096() /* Clean up */ for (i= 0; i < stmt_field_count; ++i) - free(bind[i].buffer); + free(my_bind[i].buffer); mysql_stmt_close(stmt); mysql_free_result(query_result); mysql_free_result(stmt_metadata); @@ -12146,7 +12146,7 @@ static void test_datetime_ranges() const char *stmt_text; int rc, i; MYSQL_STMT *stmt; - MYSQL_BIND bind[6]; + MYSQL_BIND my_bind[6]; MYSQL_TIME tm[6]; myheader("test_datetime_ranges"); @@ -12165,13 +12165,13 @@ static void test_datetime_ranges() check_stmt(stmt); verify_param_count(stmt, 6); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i= 0; i < 6; i++) { - bind[i].buffer_type= MYSQL_TYPE_DATETIME; - bind[i].buffer= &tm[i]; + my_bind[i].buffer_type= MYSQL_TYPE_DATETIME; + my_bind[i].buffer= &tm[i]; } - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); tm[0].year= 2004; tm[0].month= 11; tm[0].day= 10; @@ -12208,9 +12208,9 @@ static void test_datetime_ranges() We reuse contents of bind and tm arrays left from previous part of test. */ for (i= 0; i < 3; i++) - bind[i].buffer_type= MYSQL_TYPE_DATE; + my_bind[i].buffer_type= MYSQL_TYPE_DATE; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -12240,9 +12240,9 @@ static void test_datetime_ranges() Again we reuse what we can from previous part of test. */ for (i= 0; i < 5; i++) - bind[i].buffer_type= MYSQL_TYPE_TIME; + my_bind[i].buffer_type= MYSQL_TYPE_TIME; - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); tm[0].year= 0; tm[0].month= 0; tm[0].day= 10; @@ -12273,7 +12273,7 @@ static void test_datetime_ranges() static void test_bug4172() { MYSQL_STMT *stmt; - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; const char *stmt_text; MYSQL_RES *res; MYSQL_ROW row; @@ -12296,21 +12296,21 @@ static void test_bug4172() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= f; - bind[0].buffer_length= sizeof(f); - bind[0].length= &f_len; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= d; - bind[1].buffer_length= sizeof(d); - bind[1].length= &d_len; - bind[2].buffer_type= MYSQL_TYPE_STRING; - bind[2].buffer= e; - bind[2].buffer_length= sizeof(e); - bind[2].length= &e_len; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= f; + my_bind[0].buffer_length= sizeof(f); + my_bind[0].length= &f_len; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= d; + my_bind[1].buffer_length= sizeof(d); + my_bind[1].length= &d_len; + my_bind[2].buffer_type= MYSQL_TYPE_STRING; + my_bind[2].buffer= e; + my_bind[2].buffer_length= sizeof(e); + my_bind[2].length= &e_len; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); mysql_stmt_store_result(stmt); rc= mysql_stmt_fetch(stmt); @@ -12340,7 +12340,7 @@ static void test_conversion() MYSQL_STMT *stmt; const char *stmt_text; int rc; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char buff[4]; ulong length; @@ -12363,12 +12363,12 @@ static void test_conversion() rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer= buff; - bind[0].length= &length; - bind[0].buffer_type= MYSQL_TYPE_STRING; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer= buff; + my_bind[0].length= &length; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); buff[0]= (uchar) 0xC3; buff[1]= (uchar) 0xA0; @@ -12383,8 +12383,8 @@ static void test_conversion() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bind[0].buffer_length= sizeof(buff); - mysql_stmt_bind_result(stmt, bind); + my_bind[0].buffer_length= sizeof(buff); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); @@ -12405,7 +12405,7 @@ static void test_conversion() static void test_rewind(void) { MYSQL_STMT *stmt; - MYSQL_BIND bind; + MYSQL_BIND my_bind; int rc = 0; const char *stmt_text; long unsigned int length=4, Data=0; @@ -12426,11 +12426,11 @@ static void test_rewind(void) rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) &bind, sizeof(MYSQL_BIND)); - bind.buffer_type= MYSQL_TYPE_LONG; - bind.buffer= (void *)&Data; /* this buffer won't be altered */ - bind.length= &length; - bind.is_null= &isnull; + bzero((char*) &my_bind, sizeof(MYSQL_BIND)); + my_bind.buffer_type= MYSQL_TYPE_LONG; + my_bind.buffer= (void *)&Data; /* this buffer won't be altered */ + my_bind.length= &length; + my_bind.is_null= &isnull; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12438,7 +12438,7 @@ static void test_rewind(void) rc= mysql_stmt_store_result(stmt); DIE_UNLESS(rc == 0); - rc= mysql_stmt_bind_result(stmt, &bind); + rc= mysql_stmt_bind_result(stmt, &my_bind); DIE_UNLESS(rc == 0); /* retreive all result sets till we are at the end */ @@ -12471,7 +12471,7 @@ static void test_truncation() const char *stmt_text; int rc; uint bind_count; - MYSQL_BIND *bind_array, *bind; + MYSQL_BIND *bind_array, *my_bind; myheader("test_truncation"); @@ -12523,86 +12523,86 @@ static void test_truncation() /*************** Fill in the bind structure and bind it **************/ bind_array= malloc(sizeof(MYSQL_BIND) * bind_count); bzero((char*) bind_array, sizeof(MYSQL_BIND) * bind_count); - for (bind= bind_array; bind < bind_array + bind_count; bind++) - bind->error= &bind->error_value; - bind= bind_array; + for (my_bind= bind_array; my_bind < bind_array + bind_count; my_bind++) + my_bind->error= &my_bind->error_value; + my_bind= bind_array; - bind->buffer= malloc(sizeof(uint8)); - bind->buffer_type= MYSQL_TYPE_TINY; - bind->is_unsigned= TRUE; + my_bind->buffer= malloc(sizeof(uint8)); + my_bind->buffer_type= MYSQL_TYPE_TINY; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(uint32)); - bind->buffer_type= MYSQL_TYPE_LONG; - bind->is_unsigned= TRUE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(uint32)); + my_bind->buffer_type= MYSQL_TYPE_LONG; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(int8)); - bind->buffer_type= MYSQL_TYPE_TINY; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(int8)); + my_bind->buffer_type= MYSQL_TYPE_TINY; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(uint16)); - bind->buffer_type= MYSQL_TYPE_SHORT; - bind->is_unsigned= TRUE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(uint16)); + my_bind->buffer_type= MYSQL_TYPE_SHORT; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(int16)); - bind->buffer_type= MYSQL_TYPE_SHORT; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(int16)); + my_bind->buffer_type= MYSQL_TYPE_SHORT; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(uint16)); - bind->buffer_type= MYSQL_TYPE_SHORT; - bind->is_unsigned= TRUE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(uint16)); + my_bind->buffer_type= MYSQL_TYPE_SHORT; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(int8)); - bind->buffer_type= MYSQL_TYPE_TINY; - bind->is_unsigned= TRUE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(int8)); + my_bind->buffer_type= MYSQL_TYPE_TINY; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(float)); - bind->buffer_type= MYSQL_TYPE_FLOAT; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(float)); + my_bind->buffer_type= MYSQL_TYPE_FLOAT; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(float)); - bind->buffer_type= MYSQL_TYPE_FLOAT; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(float)); + my_bind->buffer_type= MYSQL_TYPE_FLOAT; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(double)); - bind->buffer_type= MYSQL_TYPE_DOUBLE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(double)); + my_bind->buffer_type= MYSQL_TYPE_DOUBLE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(longlong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(longlong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(ulonglong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; - bind->is_unsigned= TRUE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(ulonglong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; + my_bind->is_unsigned= TRUE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(longlong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(longlong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(longlong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(longlong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(longlong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(longlong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(longlong)); - bind->buffer_type= MYSQL_TYPE_LONGLONG; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(longlong)); + my_bind->buffer_type= MYSQL_TYPE_LONGLONG; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(double)); - bind->buffer_type= MYSQL_TYPE_DOUBLE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(double)); + my_bind->buffer_type= MYSQL_TYPE_DOUBLE; - DIE_UNLESS(++bind < bind_array + bind_count); - bind->buffer= malloc(sizeof(double)); - bind->buffer_type= MYSQL_TYPE_DOUBLE; + DIE_UNLESS(my_bind++ < bind_array + bind_count); + my_bind->buffer= malloc(sizeof(double)); + my_bind->buffer_type= MYSQL_TYPE_DOUBLE; rc= mysql_stmt_bind_result(stmt, bind_array); check_execute(stmt, rc); @@ -12610,82 +12610,82 @@ static void test_truncation() DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); /*************** Verify truncation results ***************************/ - bind= bind_array; + my_bind= bind_array; /* signed tiny -> tiny */ - DIE_UNLESS(*bind->error && * (int8*) bind->buffer == -10); + DIE_UNLESS(*my_bind->error && * (int8*) my_bind->buffer == -10); /* signed tiny -> uint32 */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (int32*) bind->buffer == -10); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && * (int32*) my_bind->buffer == -10); /* unsigned tiny -> tiny */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (uint8*) bind->buffer == 200); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && * (uint8*) my_bind->buffer == 200); /* short -> ushort */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (int16*) bind->buffer == -32767); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && * (int16*) my_bind->buffer == -32767); /* ushort -> short */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (uint16*) bind->buffer == 64000); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && * (uint16*) my_bind->buffer == 64000); /* short -> ushort (no truncation, data is in the range of target type) */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && * (uint16*) bind->buffer == 32000); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && * (uint16*) my_bind->buffer == 32000); /* ushort -> utiny */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (int8*) bind->buffer == 0); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && * (int8*) my_bind->buffer == 0); /* int -> float: no truncation, the number is a power of two */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && * (float*) bind->buffer == 1073741824); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && * (float*) my_bind->buffer == 1073741824); /* int -> float: truncation, not enough bits in float */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error); /* int -> double: no truncation */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && * (double*) bind->buffer == 1073741825); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && * (double*) my_bind->buffer == 1073741825); /* double -> longlong: fractional part is lost */ - DIE_UNLESS(++bind < bind_array + bind_count); + DIE_UNLESS(my_bind++ < bind_array + bind_count); /* double -> ulonglong, negative fp number to unsigned integer */ - DIE_UNLESS(++bind < bind_array + bind_count); + DIE_UNLESS(my_bind++ < bind_array + bind_count); /* Value in the buffer is not defined: don't test it */ - DIE_UNLESS(*bind->error); + DIE_UNLESS(*my_bind->error); /* double -> longlong, negative fp number to signed integer: no loss */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && * (longlong*) bind->buffer == LL(-12345678910)); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && * (longlong*) my_bind->buffer == LL(-12345678910)); /* big numeric string -> number */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error); /* junk string -> number */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && *(longlong*) bind->buffer == 0); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(*my_bind->error && *(longlong*) my_bind->buffer == 0); /* string with trailing spaces -> number */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && *(longlong*) bind->buffer == 12345); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && *(longlong*) my_bind->buffer == 12345); /* string with trailing spaces -> double */ - DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(! *bind->error && *(double*) bind->buffer == 12345.67); + DIE_UNLESS(my_bind++ < bind_array + bind_count); + DIE_UNLESS(! *my_bind->error && *(double*) my_bind->buffer == 12345.67); /* string with trailing junk -> double */ - DIE_UNLESS(++bind < bind_array + bind_count); + DIE_UNLESS(my_bind++ < bind_array + bind_count); /* XXX: There must be a truncation error: but it's not the way the server behaves, so let's leave it for now. */ - DIE_UNLESS(*(double*) bind->buffer == 12345.67); + DIE_UNLESS(*(double*) my_bind->buffer == 12345.67); /* TODO: string -> double, double -> time, double -> string (truncation errors are not supported here yet) @@ -12698,8 +12698,8 @@ static void test_truncation() mysql_stmt_close(stmt); - for (bind= bind_array; bind < bind_array + bind_count; bind++) - free(bind->buffer); + for (my_bind= bind_array; my_bind < bind_array + bind_count; my_bind++) + free(my_bind->buffer); free(bind_array); rc= mysql_query(mysql, "drop table t1"); @@ -12714,7 +12714,7 @@ static void test_truncation_option() uint8 buf; my_bool option= 0; my_bool error; - MYSQL_BIND bind; + MYSQL_BIND my_bind; myheader("test_truncation_option"); @@ -12727,14 +12727,14 @@ static void test_truncation_option() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) &bind, sizeof(MYSQL_BIND)); + bzero((char*) &my_bind, sizeof(my_bind)); - bind.buffer= (void*) &buf; - bind.buffer_type= MYSQL_TYPE_TINY; - bind.is_unsigned= TRUE; - bind.error= &error; + my_bind.buffer= (void*) &buf; + my_bind.buffer_type= MYSQL_TYPE_TINY; + my_bind.is_unsigned= TRUE; + my_bind.error= &error; - rc= mysql_stmt_bind_result(stmt, &bind); + rc= mysql_stmt_bind_result(stmt, &my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); @@ -12742,7 +12742,7 @@ static void test_truncation_option() rc= mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, (char*) &option); myquery(rc); /* need to rebind for the new setting to take effect */ - rc= mysql_stmt_bind_result(stmt, &bind); + rc= mysql_stmt_bind_result(stmt, &my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12789,7 +12789,7 @@ static void test_bug8330() MYSQL_STMT *stmt[2]; int i, rc; const char *query= "select a,b from t1 where a=?"; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; long lval[2]; myheader("test_bug8330"); @@ -12802,17 +12802,17 @@ static void test_bug8330() rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i=0; i < 2; i++) { stmt[i]= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt[i], query, strlen(query)); check_execute(stmt[i], rc); - bind[i].buffer_type= MYSQL_TYPE_LONG; - bind[i].buffer= (void*) &lval[i]; - bind[i].is_null= 0; - mysql_stmt_bind_param(stmt[i], &bind[i]); + my_bind[i].buffer_type= MYSQL_TYPE_LONG; + my_bind[i].buffer= (void*) &lval[i]; + my_bind[i].is_null= 0; + mysql_stmt_bind_param(stmt[i], &my_bind[i]); } rc= mysql_stmt_execute(stmt[0]); @@ -13060,7 +13060,7 @@ static void test_bug9159() static void test_bug9520() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char a[6]; ulong a_len; int rc, row_count= 0; @@ -13084,13 +13084,13 @@ static void test_bug9520() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (char*) a; - bind[0].buffer_length= sizeof(a); - bind[0].length= &a_len; + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (char*) a; + my_bind[0].buffer_length= sizeof(a); + my_bind[0].length= &a_len; - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); while (!(rc= mysql_stmt_fetch(stmt))) row_count++; @@ -13116,7 +13116,7 @@ static void test_bug9520() static void test_bug9478() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char a[6]; ulong a_len; int rc, i; @@ -13133,12 +13133,12 @@ static void test_bug9478() stmt= open_cursor("select name from t1 where id=2"); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (char*) a; - bind[0].buffer_length= sizeof(a); - bind[0].length= &a_len; - mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (char*) a; + my_bind[0].buffer_length= sizeof(a); + my_bind[0].length= &a_len; + mysql_stmt_bind_result(stmt, my_bind); for (i= 0; i < 5; i++) { @@ -13202,7 +13202,7 @@ static void test_bug9478() /* Test the case with a server side cursor */ stmt= open_cursor("select name from t1"); - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); for (i= 0; i < 5; i++) { @@ -13256,7 +13256,7 @@ static void test_bug9478() static void test_bug9643() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int32 a; int rc; const char *stmt_text; @@ -13290,11 +13290,11 @@ static void test_bug9643() rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void*) &a; - bind[0].buffer_length= sizeof(a); - mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void*) &a; + my_bind[0].buffer_length= sizeof(a); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -13317,7 +13317,7 @@ static void test_bug9643() static void test_bug11111() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char buf[2][20]; ulong len[2]; int i; @@ -13346,16 +13346,16 @@ static void test_bug11111() mysql_stmt_prepare(stmt, query, strlen(query)); mysql_stmt_execute(stmt); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); for (i=0; i < 2; i++) { - bind[i].buffer_type= MYSQL_TYPE_STRING; - bind[i].buffer= (gptr *)&buf[i]; - bind[i].buffer_length= 20; - bind[i].length= &len[i]; + my_bind[i].buffer_type= MYSQL_TYPE_STRING; + my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer_length= 20; + my_bind[i].length= &len[i]; } - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); @@ -13378,7 +13378,7 @@ static void test_bug11111() static void test_bug10729() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char a[21]; int rc; const char *stmt_text; @@ -13404,11 +13404,11 @@ static void test_bug10729() rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void*) a; - bind[0].buffer_length= sizeof(a); - mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void*) a; + my_bind[0].buffer_length= sizeof(a); + mysql_stmt_bind_result(stmt, my_bind); for (i= 0; i < 3; i++) { @@ -13489,7 +13489,7 @@ static void test_bug9992() static void test_bug10736() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; char a[21]; int rc; const char *stmt_text; @@ -13514,11 +13514,11 @@ static void test_bug10736() rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void*) a; - bind[0].buffer_length= sizeof(a); - mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void*) a; + my_bind[0].buffer_length= sizeof(a); + mysql_stmt_bind_result(stmt, my_bind); for (i= 0; i < 3; i++) { @@ -13545,7 +13545,7 @@ static void test_bug10736() static void test_bug10794() { MYSQL_STMT *stmt, *stmt1; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; char a[21]; int id_val; ulong a_len; @@ -13563,13 +13563,13 @@ static void test_bug10794() stmt_text= "insert into t1 (id, name) values (?, ?)"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void*) &id_val; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer= (void*) a; - bind[1].length= &a_len; - rc= mysql_stmt_bind_param(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void*) &id_val; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer= (void*) a; + my_bind[1].length= &a_len; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); for (i= 0; i < 42; i++) { @@ -13585,12 +13585,12 @@ static void test_bug10794() mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); stmt1= mysql_stmt_init(mysql); mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type); - bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void*) a; - bind[0].buffer_length= sizeof(a); - bind[0].length= &a_len; - rc= mysql_stmt_bind_result(stmt, bind); + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void*) a; + my_bind[0].buffer_length= sizeof(a); + my_bind[0].length= &a_len; + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -13604,7 +13604,7 @@ static void test_bug10794() stmt_text= "select name from t1 where id=10"; rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); check_execute(stmt1, rc); - rc= mysql_stmt_bind_result(stmt1, bind); + rc= mysql_stmt_bind_result(stmt1, my_bind); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt1); while (1) @@ -13703,7 +13703,7 @@ static void test_bug11172() static void test_bug11656() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; int rc; const char *stmt_text; char buf[2][20]; @@ -13729,16 +13729,16 @@ static void test_bug11656() type= (ulong) CURSOR_TYPE_READ_ONLY; mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); - bzero((char*) bind, sizeof(bind)); + bzero((char*) my_bind, sizeof(my_bind)); strmov(buf[0], "pcint502_MY2"); strmov(buf[1], "*"); for (i=0; i < 2; i++) { - bind[i].buffer_type= MYSQL_TYPE_STRING; - bind[i].buffer= (gptr *)&buf[i]; - bind[i].buffer_length= strlen(buf[i]); + my_bind[i].buffer_type= MYSQL_TYPE_STRING; + my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer_length= strlen(buf[i]); } - mysql_stmt_bind_param(stmt, bind); + mysql_stmt_bind_param(stmt, my_bind); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -13918,7 +13918,7 @@ static void test_bug11037() static void test_bug10760() { MYSQL_STMT *stmt; - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; int rc; const char *stmt_text; char id_buf[20]; @@ -13994,13 +13994,13 @@ static void test_bug10760() rc= mysql_query(mysql, "alter table t1 engine=InnoDB"); myquery(rc); - bzero(bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= (void*) id_buf; - bind[0].buffer_length= sizeof(id_buf); - bind[0].length= &id_len; + bzero(my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_STRING; + my_bind[0].buffer= (void*) id_buf; + my_bind[0].buffer_length= sizeof(id_buf); + my_bind[0].length= &id_len; check_execute(stmt, rc); - mysql_stmt_bind_result(stmt, bind); + mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_execute(stmt); rc= mysql_stmt_fetch(stmt); @@ -14079,7 +14079,7 @@ static void test_bug12001() static void test_bug11909() { MYSQL_STMT *stmt1, *stmt2; - MYSQL_BIND bind[7]; + MYSQL_BIND my_bind[7]; int rc; char firstname[20], midinit[20], lastname[20], workdept[20]; ulong firstname_len, midinit_len, lastname_len, workdept_len; @@ -14117,36 +14117,36 @@ static void test_bug11909() stmt1= open_cursor("SELECT empno, firstname, midinit, lastname," "workdept, salary, bonus FROM t1"); - bzero(bind, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= (void*) &empno; + bzero(my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= (void*) &empno; - bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[1].buffer= (void*) firstname; - bind[1].buffer_length= sizeof(firstname); - bind[1].length= &firstname_len; + my_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[1].buffer= (void*) firstname; + my_bind[1].buffer_length= sizeof(firstname); + my_bind[1].length= &firstname_len; - bind[2].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[2].buffer= (void*) midinit; - bind[2].buffer_length= sizeof(midinit); - bind[2].length= &midinit_len; + my_bind[2].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[2].buffer= (void*) midinit; + my_bind[2].buffer_length= sizeof(midinit); + my_bind[2].length= &midinit_len; - bind[3].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[3].buffer= (void*) lastname; - bind[3].buffer_length= sizeof(lastname); - bind[3].length= &lastname_len; + my_bind[3].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[3].buffer= (void*) lastname; + my_bind[3].buffer_length= sizeof(lastname); + my_bind[3].length= &lastname_len; - bind[4].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[4].buffer= (void*) workdept; - bind[4].buffer_length= sizeof(workdept); - bind[4].length= &workdept_len; + my_bind[4].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[4].buffer= (void*) workdept; + my_bind[4].buffer_length= sizeof(workdept); + my_bind[4].length= &workdept_len; - bind[5].buffer_type= MYSQL_TYPE_DOUBLE; - bind[5].buffer= (void*) &salary; + my_bind[5].buffer_type= MYSQL_TYPE_DOUBLE; + my_bind[5].buffer= (void*) &salary; - bind[6].buffer_type= MYSQL_TYPE_FLOAT; - bind[6].buffer= (void*) &bonus; - rc= mysql_stmt_bind_result(stmt1, bind); + my_bind[6].buffer_type= MYSQL_TYPE_FLOAT; + my_bind[6].buffer= (void*) &bonus; + rc= mysql_stmt_bind_result(stmt1, my_bind); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt1); @@ -14163,7 +14163,7 @@ static void test_bug11909() DIE_UNLESS(bonus == (float) 1000.0); stmt2= open_cursor("SELECT empno, firstname FROM t1"); - rc= mysql_stmt_bind_result(stmt2, bind); + rc= mysql_stmt_bind_result(stmt2, my_bind); check_execute(stmt2, rc); rc= mysql_stmt_execute(stmt2); @@ -14197,7 +14197,7 @@ static void test_bug11909() static void test_bug11901() { MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; int rc; char workdept[20]; ulong workdept_len; @@ -14288,19 +14288,19 @@ static void test_bug11901() " from (t1 left join t2 on t2.deptno = t1.workdept) " " where t1.empno = ?) " "order by 1"); - bzero(bind, sizeof(bind)); + bzero(my_bind, sizeof(my_bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer= &empno; - rc= mysql_stmt_bind_param(stmt, bind); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer= &empno; + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; - bind[1].buffer= (void*) workdept; - bind[1].buffer_length= sizeof(workdept); - bind[1].length= &workdept_len; + my_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + my_bind[1].buffer= (void*) workdept; + my_bind[1].buffer_length= sizeof(workdept); + my_bind[1].length= &workdept_len; - rc= mysql_stmt_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, my_bind); check_execute(stmt, rc); empno= 10; @@ -14322,7 +14322,7 @@ static void test_bug11904() int rc; const char *stmt_text; const ulong type= (ulong)CURSOR_TYPE_READ_ONLY; - MYSQL_BIND bind[2]; + MYSQL_BIND my_bind[2]; int country_id=0; char row_data[11]= {0}; @@ -14349,18 +14349,18 @@ static void test_bug11904() rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); check_execute(stmt1, rc); - memset(bind, 0, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].buffer=& country_id; - bind[0].buffer_length= 0; - bind[0].length= 0; + memset(my_bind, 0, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_LONG; + my_bind[0].buffer=& country_id; + my_bind[0].buffer_length= 0; + my_bind[0].length= 0; - bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[1].buffer=& row_data; - bind[1].buffer_length= sizeof(row_data) - 1; - bind[1].length= 0; + my_bind[1].buffer_type= MYSQL_TYPE_STRING; + my_bind[1].buffer=& row_data; + my_bind[1].buffer_length= sizeof(row_data) - 1; + my_bind[1].length= 0; - rc= mysql_stmt_bind_result(stmt1, bind); + rc= mysql_stmt_bind_result(stmt1, my_bind); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt1); @@ -14554,7 +14554,7 @@ static void test_bug14210() static void test_bug13488() { - MYSQL_BIND bind[3]; + MYSQL_BIND my_bind[3]; MYSQL_STMT *stmt1; int rc, f1, f2, f3, i; const ulong type= CURSOR_TYPE_READ_ONLY; @@ -14574,16 +14574,16 @@ static void test_bug13488() rc= mysql_query(mysql, "insert into t2 values (1,2), (2,4)"); myquery(rc); - memset(bind, 0, sizeof(bind)); + memset(my_bind, 0, sizeof(my_bind)); for (i= 0; i < 3; i++) { - bind[i].buffer_type= MYSQL_TYPE_LONG; - bind[i].buffer_length= 4; - bind[i].length= 0; + my_bind[i].buffer_type= MYSQL_TYPE_LONG; + my_bind[i].buffer_length= 4; + my_bind[i].length= 0; } - bind[0].buffer=&f1; - bind[1].buffer=&f2; - bind[2].buffer=&f3; + my_bind[0].buffer=&f1; + my_bind[1].buffer=&f2; + my_bind[2].buffer=&f3; stmt1= mysql_stmt_init(mysql); rc= mysql_stmt_attr_set(stmt1,STMT_ATTR_CURSOR_TYPE, (const void *)&type); @@ -14595,7 +14595,7 @@ static void test_bug13488() rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); - rc= mysql_stmt_bind_result(stmt1, bind); + rc= mysql_stmt_bind_result(stmt1, my_bind); check_execute(stmt1, rc); rc= mysql_stmt_fetch(stmt1); @@ -15127,7 +15127,7 @@ static void test_bug14169() static void test_bug20152() { - MYSQL_BIND bind[1]; + MYSQL_BIND my_bind[1]; MYSQL_STMT *stmt; MYSQL_TIME tm; int rc; @@ -15135,9 +15135,9 @@ static void test_bug20152() myheader("test_bug20152"); - memset(bind, 0, sizeof(bind)); - bind[0].buffer_type= MYSQL_TYPE_DATE; - bind[0].buffer= (void*)&tm; + memset(my_bind, 0, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_DATE; + my_bind[0].buffer= (void*)&tm; tm.year = 2006; tm.month = 6; @@ -15154,7 +15154,7 @@ static void test_bug20152() stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_stmt_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); From af583b828303e5ad7a285b54d60fb1b3669ee2a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 06:21:15 +0200 Subject: [PATCH 02/78] After merge fixes: - Remove compiler warnings - Fix merge errors - Indentation fixes sql/ha_ndbcluster.cc: After merge fixes sql/slave.cc: After merge fixes sql/sp.cc: After merge fixes sql/sql_table.cc: After merge fixes sql/sql_view.cc: After merge fixes --- sql/ha_ndbcluster.cc | 18 +++++++++--------- sql/slave.cc | 4 +++- sql/sp.cc | 5 ----- sql/sql_table.cc | 14 ++++++++------ sql/sql_view.cc | 10 ++++++---- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index eb60f8effd5..6152ac78a87 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6219,20 +6219,19 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, bool sorted, HANDLER_BUFFER *buffer) { - DBUG_ENTER("ha_ndbcluster::read_multi_range_first"); - int res; KEY* key_info= table->key_info + active_index; NDB_INDEX_TYPE cur_index_type= get_index_type(active_index); ulong reclength= table->s->reclength; NdbOperation* op; Thd_ndb *thd_ndb= get_thd_ndb(current_thd); + DBUG_ENTER("ha_ndbcluster::read_multi_range_first"); /** * blobs and unique hash index with NULL can't be batched currently */ if (uses_blob_value(m_retrieve_all_fields) || - (index_type == UNIQUE_INDEX && + (cur_index_type == UNIQUE_INDEX && has_null_in_unique_index(active_index) && null_value_index_search(ranges, ranges+range_count, buffer))) { @@ -7953,6 +7952,7 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond * &cond, DBUG_RETURN(1); } + int ha_ndbcluster::build_scan_filter_group(Ndb_cond* &cond, NdbScanFilter *filter) { @@ -8026,6 +8026,7 @@ ha_ndbcluster::build_scan_filter_group(Ndb_cond* &cond, NdbScanFilter *filter) DBUG_RETURN(0); } + int ha_ndbcluster::build_scan_filter(Ndb_cond * &cond, NdbScanFilter *filter) { @@ -8076,14 +8077,14 @@ ha_ndbcluster::generate_scan_filter(Ndb_cond_stack *ndb_cond_stack, DBUG_RETURN(0); } + int ha_ndbcluster::generate_scan_filter_from_cond(Ndb_cond_stack *ndb_cond_stack, NdbScanFilter& filter) { - DBUG_ENTER("generate_scan_filter_from_cond"); bool multiple_cond= FALSE; - - DBUG_PRINT("info", ("Generating scan filter")); + DBUG_ENTER("generate_scan_filter_from_cond"); + // Wrap an AND group around multiple conditions if (ndb_cond_stack->next) { @@ -8109,6 +8110,7 @@ ha_ndbcluster::generate_scan_filter_from_cond(Ndb_cond_stack *ndb_cond_stack, DBUG_RETURN(0); } + int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op, const KEY* key_info, const byte *key, @@ -8119,15 +8121,14 @@ int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op, KEY_PART_INFO* end= key_part+key_info->key_parts; NdbScanFilter filter(op); int res; - DBUG_ENTER("generate_scan_filter_from_key"); + filter.begin(NdbScanFilter::AND); for (; key_part != end; key_part++) { Field* field= key_part->field; uint32 pack_len= field->pack_length(); const byte* ptr= key; - char buf[256]; DBUG_PRINT("info", ("Filtering value for %s", field->field_name)); DBUG_DUMP("key", (char*)ptr, pack_len); if (key_part->null_bit) @@ -8162,7 +8163,6 @@ int ndbcluster_show_status(THD* thd) { Protocol *protocol= thd->protocol; - DBUG_ENTER("ndbcluster_show_status"); if (have_ndbcluster != SHOW_OPTION_YES) diff --git a/sql/slave.cc b/sql/slave.cc index e1b1e62bf1c..100e5795da8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4393,6 +4393,8 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) pthread_mutex_t *log_lock= rli->relay_log.get_log_lock(); DBUG_ENTER("queue_event"); + LINT_INIT(inc_pos); + if (mi->rli.relay_log.description_event_for_queue->binlog_version<4 && buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */) DBUG_RETURN(queue_old_event(mi,buf,event_len)); @@ -4533,7 +4535,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) err: pthread_mutex_unlock(&mi->data_lock); - DBUG_PRINT("info", ("error=%d", error)); + DBUG_PRINT("info", ("error: %d", error)); DBUG_RETURN(error); } diff --git a/sql/sp.cc b/sql/sp.cc index 188db4546c9..48c80ed4368 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -492,8 +492,6 @@ db_create_routine(THD *thd, int type, sp_head *sp) int ret; TABLE *table; char definer[USER_HOST_BUFF_SIZE]; - char old_db_buf[NAME_LEN+1]; - LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, sp->m_name.str)); @@ -1843,9 +1841,7 @@ create_string(THD *thd, String *buf, SYNOPSIS sp_use_new_db() thd thread handle - new_db new database name (a string and its length) - old_db [IN] str points to a buffer where to store the old database, length contains the size of the buffer [OUT] if old db was not NULL, its name is copied @@ -1853,7 +1849,6 @@ create_string(THD *thd, String *buf, accordingly. Otherwise str[0] is set to '\0' and length is set to 0. The out parameter should be used only if the database name has been changed (see dbchangedp). - dbchangedp [OUT] is set to TRUE if the current database is changed, FALSE otherwise. A database is not changed if the old name is the same as the new one, both names are empty, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index bcca3906266..0af7ea7e40a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -223,9 +223,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, String wrong_tables; int error; bool some_tables_deleted=0, tmp_table_deleted=0, foreign_key_error=0; - DBUG_ENTER("mysql_rm_table_part2"); + LINT_INIT(alias); + if (!drop_temporary && lock_table_names(thd, tables)) DBUG_RETURN(1); @@ -2998,7 +2999,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ALTER_INFO *alter_info, bool do_send_ok) { TABLE *table,*new_table=0; - int error; + int error= 0; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; @@ -3051,9 +3052,11 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_RETURN(1); VOID(pthread_mutex_lock(&LOCK_open)); if (lock_table_names(thd, table_list)) + { + error= 1; goto view_err; + } - error=0; if (!do_rename(thd, table_list, new_db, new_name, new_name, 1)) { if (mysql_bin_log.is_open()) @@ -3154,7 +3157,6 @@ view_err: switch (alter_info->keys_onoff) { case LEAVE_AS_IS: - error= 0; break; case ENABLE: wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); @@ -3169,10 +3171,10 @@ view_err: } if (error == HA_ERR_WRONG_COMMAND) { + error= 0; push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->alias); - error= 0; } if (!error && (new_name != table_name || new_db != db)) @@ -3202,10 +3204,10 @@ view_err: if (error == HA_ERR_WRONG_COMMAND) { + error= 0; push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->alias); - error= 0; } if (!error) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 3ee85fe05af..d5f7f4cee9e 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -862,7 +862,8 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, Query_arena *arena, backup; TABLE_LIST *top_view= table->top_table(); int res; - bool result; + bool result, view_is_mergeable; + TABLE_LIST *view_main_select_tables; DBUG_ENTER("mysql_make_view"); DBUG_PRINT("info", ("table: 0x%lx (%s)", (ulong) table, table->table_name)); @@ -1089,9 +1090,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, table->next_global= view_tables; } - bool view_is_mergeable= (table->algorithm != VIEW_ALGORITHM_TMPTABLE && - lex->can_be_merged()); - TABLE_LIST *view_main_select_tables; + view_is_mergeable= (table->algorithm != VIEW_ALGORITHM_TMPTABLE && + lex->can_be_merged()); + LINT_INIT(view_main_select_tables); + if (view_is_mergeable) { /* From 982e455909c5e19e712f08b0baad89efc88f5f89 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Jan 2007 16:55:53 +0200 Subject: [PATCH 03/78] Added two possible error cases for a test. mysql-test/r/wait_timeout.result: Added two possible error cases for a test. Depending on a platform, either errno can occur and is correct. Possible errors are CR_SERVER_GONE_ERROR and CR_SERVER_LOST mysql-test/t/wait_timeout.test: Added two possible error cases for a test. Depending on a platform, either errno can occur and is correct. Possible errors are CR_SERVER_GONE_ERROR and CR_SERVER_LOST --- mysql-test/r/wait_timeout.result | 4 ++-- mysql-test/t/wait_timeout.test | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/wait_timeout.result b/mysql-test/r/wait_timeout.result index b865a17454d..6fbff82f908 100644 --- a/mysql-test/r/wait_timeout.result +++ b/mysql-test/r/wait_timeout.result @@ -6,7 +6,7 @@ select 1; 1 1 select 2; -ERROR HY000: MySQL server has gone away +Got one of the listed errors select 3; 3 3 @@ -14,7 +14,7 @@ select 1; 1 1 select 2; -ERROR HY000: MySQL server has gone away +Got one of the listed errors select 3; 3 3 diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 67ed8fedfeb..9b9813f9655 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -46,7 +46,8 @@ while (!`select @aborted_clients`) connection default; # When the connection is closed in this way, the error code should # be consistent see bug#2845 for an explanation ---error 2006 +# depending on platform/client, either errno 2006 or 2013 can occur below +--error 2006,2013 select 2; --enable_reconnect select 3; @@ -90,7 +91,8 @@ while (!`select @aborted_clients`) connection con1; # When the connection is closed in this way, the error code should # be consistent see bug#2845 for an explanation ---error 2006 +# depending on platform/client, either errno 2006 or 2013 can occur below +--error 2006,2013 select 2; --enable_reconnect select 3; From f6a95153667dab02d11e9d71a2bf6c389ae1571b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Jan 2007 19:05:13 +0200 Subject: [PATCH 04/78] New file for autopush. To disable (known) compiler warnings. support-files/disabled_compiler_warnings.txt: BitKeeper file /home/my/bk/mysql-5.0/support-files/disabled_compiler_warnings.txt --- support-files/disabled_compiler_warnings.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 support-files/disabled_compiler_warnings.txt diff --git a/support-files/disabled_compiler_warnings.txt b/support-files/disabled_compiler_warnings.txt new file mode 100644 index 00000000000..f8651e1d27d --- /dev/null +++ b/support-files/disabled_compiler_warnings.txt @@ -0,0 +1,12 @@ +DictTabInfo.cpp : .*invalid access to non-static.* +DictTabInfo.cpp : .*macro was used incorrectly.* +EventLogger.cpp : .*defined but not used.* : 916 +NdbSqlUtil.cpp : .*unused variable.* : 684 - 685 +DbdihMain.cpp : .*unused variable.* : 6666 +DbtcMain.cpp : .*unused variable.* : 6947 +DbtcMain.cpp : .*unused variable.* : 11870 +DbtupExecQuery.cpp : .*unused variable.* : 1449 +DbtupSystemRestart.cpp : .*unused variable.* : 95 - 96 +DbtupIndex.cpp : .*unused variable.* : 188 - 242 +ndbd_malloc.cpp : .*defined but not used.* : 25 +main.cpp : .*unused variable.* : 131 - 132 From cf0b194d6cbaa4a064a0fc0fcef1c74d921e1e33 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jan 2007 13:35:49 -0500 Subject: [PATCH 05/78] BUG#21490 - No warning issued for deprecated replication parameters This patch deprecates the replication startup options in the configuration file and on the command line. The options deprecated include: MASTER_HOST, MASTER_USER, MASTER_PASSWORD, MASTER_PORT, MASTER_CONNECT_RETRY, MASTER_SSL, MASTER_SSL_CA, MASTER_SSL_CAPATH, MASTER_SSL_CERT, MASTER_SSL_KEY, and MASTER_SSL_CIPHER The code is designed to print the warning message once. sql/mysql_priv.h: BUG#21490 - No warning issued for deprecated replication parameters This patch modifies the WARN_DEPRECATED macro to permit displaying a deprecated warning to the user at startup when the replication startup options are detected. It displays the same messae as the original version of the macro but allows the macro to be called before a thread is created and the ER() macro is defined. --- sql/mysql_priv.h | 12 ++++++++++++ sql/mysqld.cc | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index cad42320db4..06a02978994 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -91,6 +91,18 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1)) #define all_bits_set(A,B) ((A) & (B) != (B)) +#define WARN_DEPRECATED(Thd,Ver,Old,New) \ + do { \ + DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \ + if (Thd != NULL) \ + push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ + ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \ + (Old), (Ver), (New)); \ + else \ + sql_print_warning("The syntax %s is deprecated and will be removed " \ + "in MySQL %s. Please use %s instead.", (Old), (Ver), (New)); \ + } while(0) + extern CHARSET_INFO *system_charset_info, *files_charset_info ; extern CHARSET_INFO *national_charset_info, *table_alias_charset; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 488751eb015..a7dc8bede84 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -356,6 +356,8 @@ my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_log_slave_updates= 0; my_bool opt_innodb; +bool slave_warning_issued = false; + #ifdef HAVE_NDBCLUSTER_DB const char *opt_ndbcluster_connectstring= 0; const char *opt_ndb_connectstring= 0; @@ -6888,6 +6890,29 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case (int) OPT_STANDALONE: /* Dummy option for NT */ break; #endif + /* + The following change issues a deprecation warning if the slave + configuration is specified either in the my.cnf file or on + the command-line. See BUG#21490. + */ + case OPT_MASTER_HOST: + case OPT_MASTER_USER: + case OPT_MASTER_PASSWORD: + case OPT_MASTER_PORT: + case OPT_MASTER_CONNECT_RETRY: + case OPT_MASTER_SSL: + case OPT_MASTER_SSL_KEY: + case OPT_MASTER_SSL_CERT: + case OPT_MASTER_SSL_CAPATH: + case OPT_MASTER_SSL_CIPHER: + case OPT_MASTER_SSL_CA: + if (!slave_warning_issued) //only show the warning once + { + slave_warning_issued = true; + WARN_DEPRECATED(0, "5.2", "for replication startup options", + "'CHANGE MASTER'"); + } + break; case OPT_CONSOLE: if (opt_console) opt_error_log= 0; // Force logs to stdout From ea65c36c19225f91a686c4cc33b1fe1527f1e785 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Jan 2007 15:52:15 +0200 Subject: [PATCH 06/78] Fixed compiler warnings Fixed wrong merge that disabled 'make test' Renamed all suppress files to end in '.supp' Don't give "skipped %d bytes from file" warnings in 5.0 mysql-test/purify.supp: Rename: mysql-test/suppress.purify -> mysql-test/purify.supp support-files/compiler_warnings.supp: Rename: support-files/disabled_compiler_warnings.txt -> support-files/compiler_warnings.supp Makefile.am: Added back missing cd from wrong merge heap/hp_write.c: Fixed compiler warning mysql-test/r/mysqlbinlog.result: Fixed test case to drop all used tables at start and used tables after each test group mysql-test/t/mysqlbinlog.test: Fixed test case to drop all used tables at start and used tables after each test group sql/net_serv.cc: Don't give "skipped %d bytes from file" warnings in 5.0 (The proper fix for this is in 5.1) sql/table.cc: Fixed compiler warning --- Makefile.am | 1 + heap/hp_write.c | 2 +- mysql-test/{suppress.purify => purify.supp} | 0 mysql-test/r/mysqlbinlog.result | 12 +++++++----- mysql-test/t/mysqlbinlog.test | 15 ++++++++++----- sql/net_serv.cc | 2 +- sql/table.cc | 3 ++- ...mpiler_warnings.txt => compiler_warnings.supp} | 0 8 files changed, 22 insertions(+), 13 deletions(-) rename mysql-test/{suppress.purify => purify.supp} (100%) rename support-files/{disabled_compiler_warnings.txt => compiler_warnings.supp} (100%) diff --git a/Makefile.am b/Makefile.am index 798d1944fd0..04d50ccfbaf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -123,6 +123,7 @@ tags: # making sure each user use different ports. test-ps: + cd mysql-test ; \ @PERL@ ./mysql-test-run.pl $(force) --ps-protocol test-ns: diff --git a/heap/hp_write.c b/heap/hp_write.c index 8a392d54c51..86e79c9d7ec 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -68,7 +68,7 @@ int heap_write(HP_INFO *info, const byte *record) err: if (my_errno == HA_ERR_FOUND_DUPP_KEY) - DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef)); + DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef))); info->errkey= keydef - share->keydef; /* We don't need to delete non-inserted key from rb-tree. Also, if diff --git a/mysql-test/suppress.purify b/mysql-test/purify.supp similarity index 100% rename from mysql-test/suppress.purify rename to mysql-test/purify.supp diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index b2571ec5d12..18d49dca813 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -1,5 +1,5 @@ set timestamp=1000000000; -drop table if exists t1,t2; +drop table if exists t1,t2,t3,t4,t5,t03,t04; create table t1 (word varchar(20)); create table t2 (id int auto_increment not null primary key); insert into t1 values ("abirvalg"); @@ -23,7 +23,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0/*!*/; /*!\C latin1 *//*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -drop table if exists t1,t2/*!*/; +drop table if exists t1,t2,t3,t4,t5,t03,t04/*!*/; SET TIMESTAMP=1000000000/*!*/; create table t1 (word varchar(20))/*!*/; SET TIMESTAMP=1000000000/*!*/; @@ -100,7 +100,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0/*!*/; /*!\C latin1 *//*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -drop table if exists t1,t2/*!*/; +drop table if exists t1,t2,t3,t4,t5,t03,t04/*!*/; SET TIMESTAMP=1000000000/*!*/; create table t1 (word varchar(20))/*!*/; SET TIMESTAMP=1000000000/*!*/; @@ -192,6 +192,7 @@ DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +drop table t1,t2; flush logs; create table t3 (f text character set utf8); create table t4 (f text character set cp932); @@ -209,13 +210,14 @@ HEX(f) select HEX(f) from t4; HEX(f) 835C +drop table t3,t4,t03,t04; flush logs; select * from t5 /* must be (1),(1) */; a 1 1 +drop table t5; flush logs; -drop table if exists t5; create table t5 (c1 int, c2 varchar(128) character set latin1 not null); insert into t5 values (1, date_format('2001-01-01','%W')); set lc_time_names=de_DE; @@ -234,6 +236,7 @@ c1 c2 1 Monday 2 Montag 3 Monday +drop table t5; drop procedure if exists p1; flush logs; create procedure p1() @@ -269,4 +272,3 @@ call p1(); 1 1 drop procedure p1; -drop table t1, t2, t03, t04, t3, t4, t5; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index f03ccffb7af..6c54e734006 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -7,7 +7,7 @@ set timestamp=1000000000; --disable_warnings -drop table if exists t1,t2; +drop table if exists t1,t2,t3,t4,t5,t03,t04; --enable_warnings create table t1 (word varchar(20)); @@ -106,8 +106,11 @@ select "--- reading stdin --" as ""; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 +drop table t1,t2; +# # Bug#16217 (mysql client did not know how not switch its internal charset) +# flush logs; create table t3 (f text character set utf8); create table t4 (f text character set cp932); @@ -121,6 +124,7 @@ select HEX(f) from t03; select HEX(f) from t3; select HEX(f) from t04; select HEX(f) from t4; +drop table t3,t4,t03,t04; # #BUG#14157: utf8 encoding in binlog without set character_set_client @@ -133,6 +137,7 @@ flush logs; # should use default-character-set same as the server. --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL select * from t5 /* must be (1),(1) */; +drop table t5; # # Bug#22645 LC_TIME_NAMES: Statement not replicated @@ -140,7 +145,6 @@ select * from t5 /* must be (1),(1) */; # lc_time_names dependent values correctly # flush logs; -drop table if exists t5; create table t5 (c1 int, c2 varchar(128) character set latin1 not null); insert into t5 values (1, date_format('2001-01-01','%W')); set lc_time_names=de_DE; @@ -152,6 +156,8 @@ flush logs; drop table t5; --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007 | $MYSQL select * from t5 order by c1; +drop table t5; + # # Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails # @@ -175,6 +181,8 @@ call p1(); --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000009 | $MYSQL call p1(); drop procedure p1; + +# # Some coverage of not normally used parts # --disable_query_log @@ -182,7 +190,4 @@ drop procedure p1; --exec $MYSQL_BINLOG --help 2>&1 > /dev/null --enable_query_log -# clean up -drop table t1, t2, t03, t04, t3, t4, t5; - # End of 5.0 tests diff --git a/sql/net_serv.cc b/sql/net_serv.cc index e4d45ca1882..e08270c94f4 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -299,7 +299,7 @@ void net_clear(NET *net) { DBUG_PRINT("info",("skipped %d bytes from file: %s", count, vio_description(net->vio))); -#ifdef EXTRA_DEBUG +#if defined(EXTRA_DEBUG) && (MYSQL_VERSION_ID < 51000) fprintf(stderr,"skipped %d bytes from file: %s\n", count, vio_description(net->vio)); #endif diff --git a/sql/table.cc b/sql/table.cc index 4f1b8e6c833..f220c6e4cb5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2915,7 +2915,8 @@ Field_iterator_table_ref::get_or_create_column_ref(TABLE_LIST *parent_table_ref) uint field_count; TABLE_LIST *add_table_ref= parent_table_ref ? parent_table_ref : table_ref; - + LINT_INIT(field_count); + if (field_it == &table_field_it) { /* The field belongs to a stored table. */ diff --git a/support-files/disabled_compiler_warnings.txt b/support-files/compiler_warnings.supp similarity index 100% rename from support-files/disabled_compiler_warnings.txt rename to support-files/compiler_warnings.supp From 1b72f3618b901f017fc4f5db5dbaad72ca79243a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Jan 2007 16:42:03 +0200 Subject: [PATCH 07/78] Avoid compiler warnings on powermacg5 Fixed compilation error when trying to compile libmysqld on powermac configure.in: Added flag if __cxa_pure_virtual() should be defined. Without this flag, we get a warning from my_global.h for every compiled file on powermacg5 extra/yassl/taocrypt/include/type_traits.hpp: Avoid compiler warning include/my_global.h: Avoid compiler warning on powermacg5 sql/mysqld.cc: Fix compiler error when compiling embedded on powermac --- configure.in | 2 +- extra/yassl/taocrypt/include/type_traits.hpp | 6 +++++- include/my_global.h | 2 +- sql/mysqld.cc | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 94bc85557df..9b2bc65cf3c 100644 --- a/configure.in +++ b/configure.in @@ -1082,7 +1082,7 @@ case $SYSTEM_TYPE in *darwin6*) if test "$ac_cv_prog_gcc" = "yes" then - FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH" + FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH -DDONT_DECLARE_CXA_PURE_VIRTUAL " CFLAGS="$CFLAGS $FLAGS" CXXFLAGS="$CXXFLAGS $FLAGS" MAX_C_OPTIMIZE="-O" diff --git a/extra/yassl/taocrypt/include/type_traits.hpp b/extra/yassl/taocrypt/include/type_traits.hpp index b985358e1c1..3a50f9ba8f3 100644 --- a/extra/yassl/taocrypt/include/type_traits.hpp +++ b/extra/yassl/taocrypt/include/type_traits.hpp @@ -69,7 +69,11 @@ MK_FUNDAMENTAL_TYPE(unsigned long) MK_FUNDAMENTAL_TYPE(float) MK_FUNDAMENTAL_TYPE( double) -MK_FUNDAMENTAL_TYPE(long double) + +#ifdef LONG_DOUBLE_IS_DISTINCT_TYPE +// Don't define by default as this gives warnings on power mac + MK_FUNDAMENTAL_TYPE(long double) +#endif #if defined(WORD64_AVAILABLE) && defined(WORD64_IS_DISTINCT_TYPE) MK_FUNDAMENTAL_TYPE(word64) diff --git a/include/my_global.h b/include/my_global.h index b91ff8a9e5b..d53dee23e17 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -540,7 +540,7 @@ typedef unsigned short ushort; duplicate declaration of __cxa_pure_virtual, solved by declaring it a weak symbol. */ -#ifdef USE_MYSYS_NEW +#if defined(USE_MYSYS_NEW) && ! defined(DONT_DECLARE_CXA_PURE_VIRTUAL) C_MODE_START int __cxa_pure_virtual () __attribute__ ((weak)); C_MODE_END diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 15580f944a4..7a19e26a8b7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -900,7 +900,7 @@ void kill_mysql(void) { DBUG_ENTER("kill_mysql"); -#ifdef SIGNALS_DONT_BREAK_READ +#if defined(SIGNALS_DONT_BREAK_READ) && !defined(EMBEDDED_LIBRARY) abort_loop=1; // Break connection loops close_server_sock(); // Force accept to wake up #endif From fb33da5f569bd3fac9d658ba5eaaeeab285c7085 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 24 Jan 2007 16:37:38 +0400 Subject: [PATCH 08/78] Bug#25815 Data truncated for column TEXT Problem: "Data truncated" warning was incorrectly generated when storing a Japanese character encoded in utf8 into a cp932 column. Reason: Incorrect wrong warning condition compared the original length of the character in bytes (which is 3 in utf8) to the converted length of the character in bytes (which is 2 in cp932). Fix: use "how many bytes were scanned from input" instead of "how many bytes were put to the column" in the condition. mysql-test/r/ctype_cp932.result: Adding test case mysql-test/t/ctype_cp932.test: Adding test case sql/field.cc: Change warning condition from: "if number of bytes written to destination is less than full source length" to "if number of bytes read from source is less than full source length" --- mysql-test/r/ctype_cp932.result | 12 ++++++++++++ mysql-test/t/ctype_cp932.test | 11 +++++++++++ sql/field.cc | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index ed57b87c1ba..10451686e2c 100755 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -11353,3 +11353,15 @@ a a a drop table t1; +set names utf8; +create table t1 (a text) default character set cp932; +insert into t1 values (_utf8 0xE38182); +show warnings; +Level Code Message +select * from t1; +a +ã‚ +select hex(a) from t1; +hex(a) +82A0 +drop table t1; diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 688d06c4dde..c6196b928b0 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -413,3 +413,14 @@ select * from t1; insert into t1 values ('abc'); select * from t1; drop table t1; + +# +# Bug#25815 Data truncated for column TEXT +# +set names utf8; +create table t1 (a text) default character set cp932; +insert into t1 values (_utf8 0xE38182); +show warnings; +select * from t1; +select hex(a) from t1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 257c7846468..61a687567fc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7024,7 +7024,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) cannot_convert_error_pos, from + length)) return 2; - if (copy_length < length) + if (from_end_pos < from + length) { report_data_too_long(this); return 2; From 428cdb5124dae5923fe58da866dde2ce9575f1d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Jan 2007 22:40:30 +0100 Subject: [PATCH 09/78] mysql.spec.sh: Added man page mysql_install_db.1 support-files/mysql.spec.sh: Added man page mysql_install_db.1 --- support-files/mysql.spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 02176ea0b41..a9f8d574de9 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -559,6 +559,7 @@ fi %doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1* +%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1 %doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1* From d51d6adca7947c3fde0263b9f8da78788dc5b3f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 3 Feb 2007 20:14:16 +0100 Subject: [PATCH 10/78] BUG#25306 (Race conditions during replication slave shutdown (valgrind stacks)): The possibility of the race is removed by changing sequence of calls pthread_mutex_unlock(&mi->run_lock); pthread_cond_broadcast(&mi->stop_cond); into pthread_cond_broadcast(&mi->stop_cond); pthread_mutex_unlock(&mi->run_lock); at the end of I/O thread (similar change at the end of SQL thread). This ensures that no thread waiting on the condition executes between the broadcast and the unlock and thus can't delete the mi structure which caused the bug. sql/slave.cc: Change order of condition broadcast and mutex unlock at the end of slave's I/O thread and SQL thread. sql/sql_repl.cc: Add DBUG_ENTER() call --- sql/slave.cc | 19 ++++++++++++++----- sql/sql_repl.cc | 8 +++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 8805f950d50..13793705b9a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3758,8 +3758,13 @@ err: mi->abort_slave= 0; mi->slave_running= 0; mi->io_thd= 0; - pthread_mutex_unlock(&mi->run_lock); + /* + Note: the order of the two following calls (first broadcast, then unlock) + is important. Otherwise a killer_thread can execute between the calls and + delete the mi structure leading to a crash! (see BUG#25306 for details) + */ pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done + pthread_mutex_unlock(&mi->run_lock); #ifndef DBUG_OFF if (abort_slave_event_count && !events_till_abort) goto slave_begin; @@ -3977,8 +3982,13 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ THD_CHECK_SENTRY(thd); delete thd; pthread_mutex_unlock(&LOCK_thread_count); - pthread_cond_broadcast(&rli->stop_cond); + /* + Note: the order of the broadcast and unlock calls below (first broadcast, then unlock) + is important. Otherwise a killer_thread can execute between the calls and + delete the mi structure leading to a crash! (see BUG#25306 for details) + */ + pthread_cond_broadcast(&rli->stop_cond); #ifndef DBUG_OFF /* Bug #19938 Valgrind error (race) in handle_slave_sql() @@ -3986,9 +3996,8 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ */ const int eta= rli->events_till_abort; #endif - - // tell the world we are done - pthread_mutex_unlock(&rli->run_lock); + pthread_mutex_unlock(&rli->run_lock); // tell the world we are done + #ifndef DBUG_OFF // TODO: reconsider the code below if (abort_slave_event_count && !eta) goto slave_begin; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 88a752f7acb..004abc775bf 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -882,12 +882,14 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report ) { + DBUG_ENTER("stop_slave"); + int slave_errno; if (!thd) thd = current_thd; if (check_access(thd, SUPER_ACL, any_db,0,0,0,0)) - return 1; + DBUG_RETURN(1); thd->proc_info = "Killing slave"; int thread_mask; lock_slave_threads(mi); @@ -921,12 +923,12 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report ) { if (net_report) my_message(slave_errno, ER(slave_errno), MYF(0)); - return 1; + DBUG_RETURN(1); } else if (net_report) send_ok(thd); - return 0; + DBUG_RETURN(0); } From 12ddb5f7c27dee26ff06931f4062263ef0e02503 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Feb 2007 15:19:01 -0800 Subject: [PATCH 11/78] thd_lib_detected moved so that it is correctly declared as a data section symbol and not a common symbol on gcc 4.0.1 on darwin 8.8.0 PowerPC MacOS X 10.4.8 mysys/my_pthread.c: thd_lib_detected moved to my_thr_init.c mysys/my_thr_init.c: thd_lib_detected moved here so that it is correctly declared as a data section symbol and not a common symbol on gcc 4.0.1 on darwin 8.8.0 PowerPC MacOS X 10.4.8 --- mysys/my_pthread.c | 1 - mysys/my_thr_init.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index b9da9d4817a..49aab9230e8 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -29,7 +29,6 @@ #define SCHED_POLICY SCHED_OTHER #endif -uint thd_lib_detected; #ifndef my_pthread_setprio void my_pthread_setprio(pthread_t thread_id,int prior) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 67ab1e4a38a..abacc7bc004 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -47,6 +47,8 @@ pthread_mutexattr_t my_fast_mutexattr; pthread_mutexattr_t my_errorcheck_mutexattr; #endif +uint thd_lib_detected; + #ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */ /* From 6a46b6d6e6a69c152efd10867f101995322d1c8f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Feb 2007 14:22:19 -0800 Subject: [PATCH 12/78] Bug#12204 "CONNECTION is a reserved keyword" Allow connection to be used as an ordinary identifier Tests included. mysql-test/r/keywords.result: test that CONNECTION may be used as ordinary identifier test that CONNECTION may be used in stored procedure. mysql-test/t/keywords.test: test that CONNECTION may be used as ordinary identifier test that CONNECTION may be used in stored procedure. sql/sql_yacc.yy: Set CONNECTION as an unreserved keyword --- mysql-test/r/keywords.result | 13 +++++++++++++ mysql-test/t/keywords.test | 22 ++++++++++++++++++++++ sql/sql_yacc.yy | 1 + 3 files changed, 36 insertions(+) diff --git a/mysql-test/r/keywords.result b/mysql-test/r/keywords.result index 88a0ab8abd5..c14ae584c86 100644 --- a/mysql-test/r/keywords.result +++ b/mysql-test/r/keywords.result @@ -16,3 +16,16 @@ select events.binlog from events; binlog 1 drop table events; +create table t1 (connection int, b int); +create procedure p1() +begin +declare connection int; +select max(t1.connection) into connection from t1; +select concat("max=",connection) 'p1'; +end| +insert into t1 (connection) values (1); +call p1(); +p1 +max=1 +drop procedure p1; +drop table t1; diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index de0159a950e..46933a230ee 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -19,3 +19,25 @@ select events.binlog from events; drop table events; # End of 4.1 tests + + +# +# Bug#12204 - CONNECTION should not be a reserved word +# + +create table t1 (connection int, b int); +delimiter |; +create procedure p1() +begin + declare connection int; + select max(t1.connection) into connection from t1; + select concat("max=",connection) 'p1'; +end| +delimiter ;| +insert into t1 (connection) values (1); +call p1(); +drop procedure p1; +drop table t1; + + +# End of 5.0 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b4147d2905c..37c591b4f4a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7926,6 +7926,7 @@ keyword_sp: | COMPACT_SYM {} | COMPRESSED_SYM {} | CONCURRENT {} + | CONNECTION_SYM {} | CONSISTENT_SYM {} | CUBE_SYM {} | DATA_SYM {} From 914ae41f3310d6fe8994a86b38930c1c3375dc0e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Feb 2007 15:53:14 +0100 Subject: [PATCH 13/78] Fix for BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values". When in an INSERT ON DUPLICATE KEY UPDATE, using an autoincrement column, we inserted some autogenerated values and also updated some rows, some autogenerated values were not used (for example, even if 10 was the largest autoinc value in the table at the start of the statement, 12 could be the first autogenerated value inserted by the statement, instead of 11). One autogenerated value was lost per updated row. Led to exhausting the range of the autoincrement column faster. Bug introduced by fix of BUG#20188; present since 5.0.24 and 5.1.12. This bug breaks replication from a pre-5.0.24 master. But the present bugfix, as it makes INSERT ON DUP KEY UPDATE behave like pre-5.0.24, breaks replication from a [5.0.24,5.0.34] master to a fixed (5.0.36) slave! To warn users against this when they upgrade their slave, as agreed with the support team, we add code for a fixed slave to detect that it is connected to a buggy master in a situation (INSERT ON DUP KEY UPDATE into autoinc column) likely to break replication, in which case it cannot replicate so stops and prints a message to the slave's error log and to SHOW SLAVE STATUS. For 5.0.36->[5.0.24,5.0.34] replication we cannot warn as master does not know the slave's version (but we always recommended to users to have slave at least as new as master). As agreed with support, I'll also ask for an alert to be put into the MySQL Network Monitoring and Advisory Service. mysql-test/r/rpl_insert_id.result: results to check the bugfix; without the bugfix, you would see, in master and slave: "3,2" instead of "2,2" for the INSERT VALUES testcase, "11,6,..." instead of "6,6,..." for the INSERT SELECT testcase. mysql-test/t/rpl_insert_id.test: testing that BUG#24432 is fixed sql/log_event.cc: A trick to force the master to pretend it is old and features BUG#24432. To do fast lookups in the list of known bugs by version, we compute the 3 X.Y.Z numbers from the master's version string and cache that into a new member Format_description_log_event::server_version_split. We do this computation in the event's two constructors. A simple prevention against buffer overrun when reading the master's version from a binlog event (assume the event is corrupted on disk, and so the version string on disk is longer than ST_SERVER_VER_LEN (50), then we would not get a closing 0 at the end of the class member. sql/log_event.h: new member to hold the "split server version" (3 numbers X.Y.Z), and a method to compute this from the version string. sql/slave.cc: a function which tells, based on master's version (as found in the Format_description event in the relay log being executed), if master can have a certain bug. This function uses a list of bug_id / first_version_with_bug / first_version_with_fix. If the test is positive, a short error message is put into SHOW SLAVE STATUS, and a verbose message is put into the slave's error log. The caller is expected to stop the slave in this case. sql/slave.h: new function to test if the replication master has a bug sql/sql_insert.cc: Fix for BUG#24432:t he reason was a misplaced restore_auto_increment() (misplaced when fixing BUG#20188). Indeed, when updating the row, it is clear that the autogenerated auto_increment value will not be used for this row (and if by "chance" the autoinc value present in the updated row is >= to the not used autogenerated value, adjust_next_insert_id_after_explicit_value() will fix next_insert_id). We also add code for a fixed slave to detect that it is connected to a buggy master (in which case it cannot replicate so stops). mysql-test/r/rpl_known_bugs_detection.result: see that SHOW SLAVE STATUS prints information that slave found a bug in master, and does not execute the dangerous event (table stays empty). mysql-test/t/rpl_known_bugs_detection-master.opt: pass debug symbol to make the master pretend it has BUG#24432 mysql-test/t/rpl_known_bugs_detection.test: new test to see if bug detection by slave works --- mysql-test/r/rpl_insert_id.result | 58 ++++++++ mysql-test/r/rpl_known_bugs_detection.result | 133 ++++++++++++++++++ mysql-test/t/rpl_insert_id.test | 53 +++++++ .../t/rpl_known_bugs_detection-master.opt | 1 + mysql-test/t/rpl_known_bugs_detection.test | 90 ++++++++++++ sql/log_event.cc | 37 +++++ sql/log_event.h | 2 + sql/slave.cc | 64 +++++++++ sql/slave.h | 1 + sql/sql_insert.cc | 20 ++- 10 files changed, 458 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/rpl_known_bugs_detection.result create mode 100644 mysql-test/t/rpl_known_bugs_detection-master.opt create mode 100644 mysql-test/t/rpl_known_bugs_detection.test diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result index d133a2ae8ed..a5c8e17f67e 100644 --- a/mysql-test/r/rpl_insert_id.result +++ b/mysql-test/r/rpl_insert_id.result @@ -234,6 +234,64 @@ n b 2 100 3 350 drop table t1; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, +UNIQUE(b)); +INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; +SELECT * FROM t1; +a b +1 10 +2 2 +SELECT * FROM t1; +a b +1 10 +2 2 +drop table t1; +CREATE TABLE t1 ( +id bigint(20) unsigned NOT NULL auto_increment, +field_1 int(10) unsigned NOT NULL, +field_2 varchar(255) NOT NULL, +field_3 varchar(255) NOT NULL, +PRIMARY KEY (id), +UNIQUE KEY field_1 (field_1, field_2) +); +CREATE TABLE t2 ( +field_a int(10) unsigned NOT NULL, +field_b varchar(255) NOT NULL, +field_c varchar(255) NOT NULL +); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +SELECT * FROM t1; +id field_1 field_2 field_3 +1 1 a 1a +2 2 b 2b +3 3 c 3c +4 4 d 4d +5 5 e 5e +6 6 f 6f +SELECT * FROM t1; +id field_1 field_2 field_3 +1 1 a 1a +2 2 b 2b +3 3 c 3c +4 4 d 4d +5 5 e 5e +6 6 f 6f +drop table t1, t2; DROP PROCEDURE IF EXISTS p1; DROP TABLE IF EXISTS t1, t2; SELECT LAST_INSERT_ID(0); diff --git a/mysql-test/r/rpl_known_bugs_detection.result b/mysql-test/r/rpl_known_bugs_detection.result new file mode 100644 index 00000000000..c23586c6f61 --- /dev/null +++ b/mysql-test/r/rpl_known_bugs_detection.result @@ -0,0 +1,133 @@ +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; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, +UNIQUE(b)); +INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; +SELECT * FROM t1; +a b +1 10 +2 2 +show slave status;; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port # +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos # +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 1105 +Last_Error Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10' +Skip_Counter 0 +Exec_Master_Log_Pos 238 +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # +SELECT * FROM t1; +a b +stop slave; +reset slave; +reset master; +drop table t1; +start slave; +CREATE TABLE t1 ( +id bigint(20) unsigned NOT NULL auto_increment, +field_1 int(10) unsigned NOT NULL, +field_2 varchar(255) NOT NULL, +field_3 varchar(255) NOT NULL, +PRIMARY KEY (id), +UNIQUE KEY field_1 (field_1, field_2) +); +CREATE TABLE t2 ( +field_a int(10) unsigned NOT NULL, +field_b varchar(255) NOT NULL, +field_c varchar(255) NOT NULL +); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +SELECT * FROM t1; +id field_1 field_2 field_3 +1 1 a 1a +2 2 b 2b +3 3 c 3c +4 4 d 4d +5 5 e 5e +6 6 f 6f +show slave status;; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port # +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos # +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 1105 +Last_Error Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c' +Skip_Counter 0 +Exec_Master_Log_Pos 1270 +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # +SELECT * FROM t1; +id field_1 field_2 field_3 +drop table t1, t2; +drop table t1, t2; diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test index 331a913256c..be2948e9678 100644 --- a/mysql-test/t/rpl_insert_id.test +++ b/mysql-test/t/rpl_insert_id.test @@ -245,6 +245,59 @@ select * from t1 order by n; connection master; drop table t1; +# +# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" +# + +# testcase with INSERT VALUES +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, +UNIQUE(b)); +INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; +SELECT * FROM t1; +sync_slave_with_master; +SELECT * FROM t1; +connection master; +drop table t1; + +# tescase with INSERT SELECT +CREATE TABLE t1 ( + id bigint(20) unsigned NOT NULL auto_increment, + field_1 int(10) unsigned NOT NULL, + field_2 varchar(255) NOT NULL, + field_3 varchar(255) NOT NULL, + PRIMARY KEY (id), + UNIQUE KEY field_1 (field_1, field_2) +); +CREATE TABLE t2 ( + field_a int(10) unsigned NOT NULL, + field_b varchar(255) NOT NULL, + field_c varchar(255) NOT NULL +); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); +# Updating table t1 based on values from table t2 +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +# Inserting new record into t2 +INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); +# Updating t1 again +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +SELECT * FROM t1; +sync_slave_with_master; +SELECT * FROM t1; +connection master; +drop table t1, t2; + # # BUG#20339: stored procedure using LAST_INSERT_ID() does not # replicate statement-based diff --git a/mysql-test/t/rpl_known_bugs_detection-master.opt b/mysql-test/t/rpl_known_bugs_detection-master.opt new file mode 100644 index 00000000000..d4ba386a1a0 --- /dev/null +++ b/mysql-test/t/rpl_known_bugs_detection-master.opt @@ -0,0 +1 @@ +--loose-debug=d,pretend_version_50034_in_binlog diff --git a/mysql-test/t/rpl_known_bugs_detection.test b/mysql-test/t/rpl_known_bugs_detection.test new file mode 100644 index 00000000000..4719716d4a1 --- /dev/null +++ b/mysql-test/t/rpl_known_bugs_detection.test @@ -0,0 +1,90 @@ +# Test to see if slave can detect certain known bugs present +# on the master, and appropriately decides to stop +# (assuming the bug is fixed in the slave, slave cannot of course +# imitate the bug, so it has to stop). + +source include/have_debug.inc; +source include/master-slave.inc; + +# +# This is to test that slave properly detects if +# master may suffer from: +# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" +# (i.e. on master, INSERT ON DUPLICATE KEY UPDATE is used and manipulates +# an auto_increment column, and is binlogged statement-based). +# + +# testcase with INSERT VALUES +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, +UNIQUE(b)); +sync_slave_with_master; +connection master; +INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; +SELECT * FROM t1; +connection slave; +wait_for_slave_to_stop; +# show the error message +--replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 # +--query_vertical show slave status; +# show that it was not replicated +SELECT * FROM t1; + +# restart replication for the next testcase +stop slave; +reset slave; +connection master; +reset master; +drop table t1; +connection slave; +start slave; + +# testcase with INSERT SELECT +connection master; +CREATE TABLE t1 ( + id bigint(20) unsigned NOT NULL auto_increment, + field_1 int(10) unsigned NOT NULL, + field_2 varchar(255) NOT NULL, + field_3 varchar(255) NOT NULL, + PRIMARY KEY (id), + UNIQUE KEY field_1 (field_1, field_2) +); +CREATE TABLE t2 ( + field_a int(10) unsigned NOT NULL, + field_b varchar(255) NOT NULL, + field_c varchar(255) NOT NULL +); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); +INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); +sync_slave_with_master; +connection master; +# Updating table t1 based on values from table t2 +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +# Inserting new record into t2 +INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); +# Updating t1 again +INSERT INTO t1 (field_1, field_2, field_3) +SELECT t2.field_a, t2.field_b, t2.field_c +FROM t2 +ON DUPLICATE KEY UPDATE +t1.field_3 = t2.field_c; +SELECT * FROM t1; +connection slave; +wait_for_slave_to_stop; +# show the error message +--replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 # +--query_vertical show slave status; +# show that it was not replicated +SELECT * FROM t1; +connection master; +drop table t1, t2; +connection slave; +drop table t1, t2; + +# End of 5.0 tests diff --git a/sql/log_event.cc b/sql/log_event.cc index 657fd510e78..a14cd79461d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2047,6 +2047,8 @@ Start_log_event_v3::Start_log_event_v3(const char* buf, binlog_version= uint2korr(buf+ST_BINLOG_VER_OFFSET); memcpy(server_version, buf+ST_SERVER_VER_OFFSET, ST_SERVER_VER_LEN); + // prevent overrun if log is corrupted on disk + server_version[ST_SERVER_VER_LEN-1]= 0; created= uint4korr(buf+ST_CREATED_OFFSET); /* We use log_pos to mark if this was an artificial event or not */ artificial_event= (log_pos == 0); @@ -2170,6 +2172,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) switch (binlog_ver) { case 4: /* MySQL 5.0 */ memcpy(server_version, ::server_version, ST_SERVER_VER_LEN); + DBUG_EXECUTE_IF("pretend_version_50034_in_binlog", + strmov(server_version, "5.0.34");); common_header_len= LOG_EVENT_HEADER_LEN; number_of_event_types= LOG_EVENT_TYPES; /* we'll catch my_malloc() error in is_valid() */ @@ -2241,6 +2245,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) post_header_len= 0; /* will make is_valid() fail */ break; } + calc_server_version_split(); } @@ -2280,6 +2285,7 @@ Format_description_log_event(const char* buf, post_header_len= (uint8*) my_memdup((byte*)buf+ST_COMMON_HEADER_LEN_OFFSET+1, number_of_event_types* sizeof(*post_header_len), MYF(0)); + calc_server_version_split(); DBUG_VOID_RETURN; } @@ -2380,6 +2386,37 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli) } #endif + +/** + Splits the event's 'server_version' string into three numeric pieces stored + into 'server_version_split': + X.Y.Zabc (X,Y,Z numbers, a not a digit) -> {X,Y,Z} + X.Yabc -> {X,Y,0} + Xabc -> {X,0,0} + 'server_version_split' is then used for lookups to find if the server which + created this event has some known bug. +*/ +void Format_description_log_event::calc_server_version_split() +{ + char *p= server_version, *r; + ulong number; + for (uint i= 0; i<=2; i++) + { + number= strtoul(p, &r, 10); + server_version_split[i]= (uchar)number; + DBUG_ASSERT(number < 256); // fit in uchar + p= r; + DBUG_ASSERT(!((i == 0) && (*r != '.'))); // should be true in practice + if (*r == '.') + p++; // skip the dot + } + DBUG_PRINT("info",("Format_description_log_event::server_version_split:" + " '%s' %d %d %d", server_version, + server_version_split[0], + server_version_split[1], server_version_split[2])); +} + + /************************************************************************** Load_log_event methods General note about Load_log_event: the binlogging of LOAD DATA INFILE is diff --git a/sql/log_event.h b/sql/log_event.h index fd2a5e5fb63..d3ebe6860f5 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1102,6 +1102,7 @@ public: uint8 number_of_event_types; /* The list of post-headers' lengthes */ uint8 *post_header_len; + uchar server_version_split[3]; Format_description_log_event(uint8 binlog_ver, const char* server_ver=0); @@ -1133,6 +1134,7 @@ public: */ return FORMAT_DESCRIPTION_HEADER_LEN; } + void calc_server_version_split(); }; diff --git a/sql/slave.cc b/sql/slave.cc index 8805f950d50..37c782a42c3 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5165,6 +5165,70 @@ end: } +/** + Detects, based on master's version (as found in the relay log), if master + has a certain bug. + @param rli RELAY_LOG_INFO which tells the master's version + @param bug_id Number of the bug as found in bugs.mysql.com + @return TRUE if master has the bug, FALSE if it does not. +*/ +bool rpl_master_has_bug(RELAY_LOG_INFO *rli, uint bug_id) +{ + struct st_version_range_for_one_bug { + uint bug_id; + const uchar introduced_in[3]; // first version with bug + const uchar fixed_in[3]; // first version with fix + }; + static struct st_version_range_for_one_bug versions_for_all_bugs[]= + { + {24432, { 5, 0, 24 }, { 5, 0, 36 } }, + {24432, { 5, 1, 12 }, { 5, 1, 16 } } + }; + const uchar *master_ver= + rli->relay_log.description_event_for_exec->server_version_split; + + DBUG_ASSERT(sizeof(rli->relay_log.description_event_for_exec->server_version_split) == 3); + + for (uint i= 0; + i < sizeof(versions_for_all_bugs)/sizeof(*versions_for_all_bugs);i++) + { + const uchar *introduced_in= versions_for_all_bugs[i].introduced_in, + *fixed_in= versions_for_all_bugs[i].fixed_in; + if ((versions_for_all_bugs[i].bug_id == bug_id) && + (memcmp(introduced_in, master_ver, 3) <= 0) && + (memcmp(fixed_in, master_ver, 3) > 0)) + { + // a verbose message for the error log + slave_print_error(rli, ER_UNKNOWN_ERROR, + "According to the master's version ('%s')," + " it is probable that master suffers from this bug:" + " http://bugs.mysql.com/bug.php?id=%u" + " and thus replicating the current binary log event" + " may make the slave's data become different from the" + " master's data." + " To take no risk, slave refuses to replicate" + " this event and stops." + " We recommend that all updates be stopped on the" + " master and slave, that the data of both be" + " manually synchronized," + " that master's binary logs be deleted," + " that master be upgraded to a version at least" + " equal to '%d.%d.%d'. Then replication can be" + " restarted.", + rli->relay_log.description_event_for_exec->server_version, + bug_id, + fixed_in[0], fixed_in[1], fixed_in[2]); + // a short message for SHOW SLAVE STATUS (message length constraints) + my_printf_error(ER_UNKNOWN_ERROR, "master may suffer from" + " http://bugs.mysql.com/bug.php?id=%u" + " so slave stops; check error log on slave" + " for more info", MYF(0), bug_id); + return TRUE; + } + } + return FALSE; +} + #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION template class I_List_iterator; template class I_List_iterator; diff --git a/sql/slave.h b/sql/slave.h index bbf450bab75..e7d4456ccd9 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -533,6 +533,7 @@ void table_rule_ent_hash_to_str(String* s, HASH* h); void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a); bool show_master_info(THD* thd, MASTER_INFO* mi); bool show_binlog_info(THD* thd); +bool rpl_master_has_bug(RELAY_LOG_INFO *rli, uint bug_id); /* See if the query uses any tables that should not be replicated */ bool tables_ok(THD* thd, TABLE_LIST* tables); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c60d3c307d0..c5f1524c556 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -58,6 +58,7 @@ #include "sp_head.h" #include "sql_trigger.h" #include "sql_select.h" +#include "slave.h" static int check_null_fields(THD *thd,TABLE *entry); #ifndef EMBEDDED_LIBRARY @@ -468,6 +469,14 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, thd->cuted_fields = 0L; table->next_number_field=table->found_next_number_field; +#ifdef HAVE_REPLICATION + if (thd->slave_thread && + (info.handle_duplicates == DUP_UPDATE) && + (table->next_number_field != NULL) && + rpl_master_has_bug(&active_mi->rli, 24432)) + goto abort; +#endif + error=0; id=0; thd->proc_info="update"; @@ -1133,11 +1142,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (res == VIEW_CHECK_ERROR) goto before_trg_err; + table->file->restore_auto_increment(); if ((error=table->file->update_row(table->record[1],table->record[0]))) { if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) { - table->file->restore_auto_increment(); goto ok_or_after_trg_err; } goto err; @@ -2369,6 +2378,15 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) } restore_record(table,s->default_values); // Get empty record table->next_number_field=table->found_next_number_field; + +#ifdef HAVE_REPLICATION + if (thd->slave_thread && + (info.handle_duplicates == DUP_UPDATE) && + (table->next_number_field != NULL) && + rpl_master_has_bug(&active_mi->rli, 24432)) + DBUG_RETURN(1); +#endif + thd->cuted_fields=0; if (info.ignore || info.handle_duplicates != DUP_ERROR) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); From 33f24f2c58b97397c872616b1d5bf692dffa86fd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Feb 2007 15:57:28 +0100 Subject: [PATCH 14/78] BUG#25463 (Memory allocation problems in replication slave thread): The problem is (most probably) caused by whole server shutting down before a slave thread terminates correctly. Fixing this requires fixing server shutdown code which has been done in 5.1 tree. Thus we ignore the issue in 5.0 assuming that it is fixed in 5.1. mysql-test/valgrind.supp: Added a suppresion rule. --- mysql-test/valgrind.supp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index f7eb9baa4c7..e71f4541cfd 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -346,3 +346,20 @@ fun:_ZN19TransporterRegistry11performSendEv fun:_ZN19TransporterRegistry14forceSendCheckEi } + +# +# BUG#25463: Probable cause - slave thread doesn't have time to terminate properly +# because rest of the server shuts down before that. The server shutdown code has +# been fixed in 5.1 and there this leak should not happen. Suppression has been +# approved by Monty. +# +# Important: do not propagate this rule to 5.1 tree! +# + +{ + Slave thread shutdown (BUG#25463) + Memcheck:Leak + fun:calloc + fun:my_thread_init + fun:handle_slave_io +} From 5c1f67d31223ca769345eee7209796c552caae27 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Feb 2007 13:03:37 +0200 Subject: [PATCH 15/78] Fixes a compilation problem on Windows. Backport of the same fix from 4.0. --- sql/mysqld.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 43d76f28007..59ea766b5c8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2251,7 +2251,11 @@ int main(int argc, char **argv) #endif /* Set signal used to kill MySQL */ +#if defined(SIGUSR2) thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2; +#else + thr_kill_signal= SIGINT; +#endif /* Init mutexes for the global MYSQL_LOG objects. From a3dc06a87413689c5e5f1a623f30317341a41e6e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Feb 2007 13:31:51 +0000 Subject: [PATCH 16/78] BUG#22025 Return correct error message when transporter error occur. ndb/src/common/debugger/EventLogger.cpp: Add correct error string when transporter error occur. --- ndb/src/common/debugger/EventLogger.cpp | 99 ++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 3efd52808e2..39daa3effe8 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -16,6 +16,7 @@ #include #include "EventLogger.hpp" +#include #include #include @@ -528,10 +529,100 @@ void getTextUndoLogBlocked(QQQQ) { theData[2]); } void getTextTransporterError(QQQQ) { - BaseString::snprintf(m_text, m_text_len, - "Transporter to node %d reported error 0x%x", - theData[1], - theData[2]); + struct myTransporterError{ + int errorNum; + char errorString[256]; + }; + int i = 0; + int lenth = 0; + static const struct myTransporterError TransporterErrorString[]= + { + //TE_NO_ERROR = 0 + {TE_NO_ERROR,"No error"}, + //TE_ERROR_CLOSING_SOCKET = 0x1 + {TE_ERROR_CLOSING_SOCKET,"Error found during closing of socket"}, + //TE_ERROR_IN_SELECT_BEFORE_ACCEPT = 0x2 + {TE_ERROR_IN_SELECT_BEFORE_ACCEPT,"Error found before accept. The transporter will retry"}, + //TE_INVALID_MESSAGE_LENGTH = 0x3 | TE_DO_DISCONNECT + {TE_INVALID_MESSAGE_LENGTH,"Error found in message (invalid message length)"}, + //TE_INVALID_CHECKSUM = 0x4 | TE_DO_DISCONNECT + {TE_INVALID_CHECKSUM,"Error found in message (checksum)"}, + //TE_COULD_NOT_CREATE_SOCKET = 0x5 + {TE_COULD_NOT_CREATE_SOCKET,"Error found while creating socket(can't create socket)"}, + //TE_COULD_NOT_BIND_SOCKET = 0x6 + {TE_COULD_NOT_BIND_SOCKET,"Error found while binding server socket"}, + //TE_LISTEN_FAILED = 0x7 + {TE_LISTEN_FAILED,"Error found while listening to server socket"}, + //TE_ACCEPT_RETURN_ERROR = 0x8 + {TE_ACCEPT_RETURN_ERROR,"Error found during accept(accept return error)"}, + //TE_SHM_DISCONNECT = 0xb | TE_DO_DISCONNECT + {TE_SHM_DISCONNECT,"The remote node has disconnected"}, + //TE_SHM_IPC_STAT = 0xc | TE_DO_DISCONNECT + {TE_SHM_IPC_STAT,"Unable to check shm segment"}, + //TE_SHM_UNABLE_TO_CREATE_SEGMENT = 0xd + {TE_SHM_UNABLE_TO_CREATE_SEGMENT,"Unable to create shm segment"}, + //TE_SHM_UNABLE_TO_ATTACH_SEGMENT = 0xe + {TE_SHM_UNABLE_TO_ATTACH_SEGMENT,"Unable to attach shm segment"}, + //TE_SHM_UNABLE_TO_REMOVE_SEGMENT = 0xf + {TE_SHM_UNABLE_TO_REMOVE_SEGMENT,"Unable to remove shm segment"}, + //TE_TOO_SMALL_SIGID = 0x10 + {TE_TOO_SMALL_SIGID,"Sig ID too small"}, + //TE_TOO_LARGE_SIGID = 0x11 + {TE_TOO_LARGE_SIGID,"Sig ID too large"}, + //TE_WAIT_STACK_FULL = 0x12 | TE_DO_DISCONNECT + {TE_WAIT_STACK_FULL,"Wait stack was full"}, + //TE_RECEIVE_BUFFER_FULL = 0x13 | TE_DO_DISCONNECT + {TE_RECEIVE_BUFFER_FULL,"Receive buffer was full"}, + //TE_SIGNAL_LOST_SEND_BUFFER_FULL = 0x14 | TE_DO_DISCONNECT + {TE_SIGNAL_LOST_SEND_BUFFER_FULL,"Send buffer was full,and trying to force send fails"}, + //TE_SIGNAL_LOST = 0x15 + {TE_SIGNAL_LOST,"Send failed for unknown reason(signal lost)"}, + //TE_SEND_BUFFER_FULL = 0x16 + {TE_SEND_BUFFER_FULL,"The send buffer was full, but sleeping for a while solved"}, + //TE_SCI_LINK_ERROR = 0x0017 + {TE_SCI_LINK_ERROR,"There is no link from this node to the switch"}, + //TE_SCI_UNABLE_TO_START_SEQUENCE = 0x18 | TE_DO_DISCONNECT + {TE_SCI_UNABLE_TO_START_SEQUENCE,"Could not start a sequence, because system resources are exumed or no sequence has been created"}, + //TE_SCI_UNABLE_TO_REMOVE_SEQUENCE = 0x19 | TE_DO_DISCONNECT + {TE_SCI_UNABLE_TO_REMOVE_SEQUENCE,"Could not remove a sequence"}, + //TE_SCI_UNABLE_TO_CREATE_SEQUENCE = 0x1a | TE_DO_DISCONNECT + {TE_SCI_UNABLE_TO_CREATE_SEQUENCE,"Could not create a sequence, because system resources are exempted. Must reboot"}, + //TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR = 0x1b | TE_DO_DISCONNECT + {TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR,"Tried to send data on redundant link but failed"}, + //TE_SCI_CANNOT_INIT_LOCALSEGMENT = 0x1c | TE_DO_DISCONNECT + {TE_SCI_CANNOT_INIT_LOCALSEGMENT,"Cannot initialize local segment"}, + //TE_SCI_CANNOT_MAP_REMOTESEGMENT = 0x1d | TE_DO_DISCONNEC + {TE_SCI_CANNOT_MAP_REMOTESEGMENT,"Cannot map remote segment"}, + //TE_SCI_UNABLE_TO_UNMAP_SEGMENT = 0x1e | TE_DO_DISCONNECT + {TE_SCI_UNABLE_TO_UNMAP_SEGMENT,"Cannot free the resources used by this segment (step 1)"}, + //TE_SCI_UNABLE_TO_REMOVE_SEGMENT = 0x1f | TE_DO_DISCONNEC + {TE_SCI_UNABLE_TO_REMOVE_SEGMENT,"Cannot free the resources used by this segment (step 2)"}, + //TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT = 0x20 | TE_DO_DISCONNECT + {TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT,"Cannot disconnect from a remote segment"}, + //TE_SHM_IPC_PERMANENT = 0x21 + {TE_SHM_IPC_PERMANENT,"Shm ipc Permanent error"}, + //TE_SCI_UNABLE_TO_CLOSE_CHANNEL = 0x22 + {TE_SCI_UNABLE_TO_CLOSE_CHANNEL,"Unable to close the sci channel and the resources allocated"} + }; + + lenth = sizeof(TransporterErrorString)/sizeof(struct myTransporterError); + for(i=0; i Date: Mon, 12 Feb 2007 15:03:11 +0100 Subject: [PATCH 17/78] Compile error on Windows: Signal names are undefined. Fix by hiding the whole section. mysys/my_thr_init.c: Compile error on Windows: Both "SIGALRM" and "SIGUSR1" are undefined. Fix by hiding the whole section, according to Jani it is not needed on Windows. --- mysys/my_thr_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 5729f27b7a7..f4fd96b769d 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -60,11 +60,14 @@ static uint get_thread_lib(void); my_bool my_thread_global_init(void) { +#if defined(SIGALRM) || defined(SIGUSR1) + /* On Windows, these signals are not defined, but this whole part is not needed. */ thd_lib_detected= get_thread_lib(); if (thd_lib_detected == THD_LIB_LT) thr_client_alarm= SIGALRM; else thr_client_alarm= SIGUSR1; +#endif if (pthread_key_create(&THR_KEY_mysys,0)) { From 2d2957c041708548a422d4e64bf2d3cc10051cf8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Feb 2007 19:55:33 +0100 Subject: [PATCH 18/78] Break a double declare of "uint thr_client_alarm" between "mysys/thr_alarm.c" and "mysys/my_pthread.c". mysys/my_pthread.c: Break a double declare: "uint thr_client_alarm" is also declared in "mysys/thr_alarm.c", take it from there. --- mysys/my_pthread.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index fd716448e43..19766a2d195 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -32,7 +32,6 @@ #endif uint thd_lib_detected; -uint thr_client_alarm; #ifndef my_pthread_setprio void my_pthread_setprio(pthread_t thread_id,int prior) From 715281a94bf2e215f85e3074ffe2131dba311f88 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Feb 2007 20:13:34 +0100 Subject: [PATCH 19/78] Fix a linkage problem with the previous patch for "thr_client_alarm". mysys/my_pthread.c: Linkage problem with previous patch: "thr_client_alarm" must be declared in here. mysys/thr_alarm.c: Linkage problem: Declare "thr_client_alarm" over in "mysys/my_pthread.c". --- mysys/my_pthread.c | 1 + mysys/thr_alarm.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 19766a2d195..fd716448e43 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -32,6 +32,7 @@ #endif uint thd_lib_detected; +uint thr_client_alarm; #ifndef my_pthread_setprio void my_pthread_setprio(pthread_t thread_id,int prior) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 8f342e269de..c8e1e55aac2 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -37,7 +37,6 @@ #define ETIME ETIMEDOUT #endif -uint thr_client_alarm; static int alarm_aborted=1; /* No alarm thread */ my_bool thr_alarm_inited= 0; volatile my_bool alarm_thread_running= 0; From 9ed1b8434603d69eb0646013f721a402a624833c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 11:05:38 +0700 Subject: [PATCH 20/78] Bug#26293 cluster mgmt node sometimes doesn't receive events from all nodes on restart - signals where sometimes sent too early when setting up subscriptions ndb/include/kernel/signaldata/DumpStateOrd.hpp: added dump for active subscriptions in cmvmi ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: added dump for active subscriptions in cmvmi ndb/src/mgmsrv/MgmtSrvr.cpp: bug in that signals where sent prior to api reg conf arrived, causing thrown away signals and subsequent hangs in mgmtserver also add retry if node connected but not yet received api reg conf ndb/src/ndbapi/ClusterMgr.cpp: added status variable m_api_reg_conf in cluster manager to correctly be able to determine if a node is sendable ndb/src/ndbapi/ClusterMgr.hpp: added status variable m_api_reg_conf in cluster manager to correctly be able to determine if a node is sendable ndb/src/ndbapi/SignalSender.cpp: assert to see that node is sendable when signal is sent ndb/src/ndbapi/SignalSender.hpp: manke metchd const --- .../kernel/signaldata/DumpStateOrd.hpp | 4 + ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 20 +++- ndb/src/mgmsrv/MgmtSrvr.cpp | 94 +++++++++++++++---- ndb/src/ndbapi/ClusterMgr.cpp | 5 +- ndb/src/ndbapi/ClusterMgr.hpp | 1 + ndb/src/ndbapi/SignalSender.cpp | 2 + ndb/src/ndbapi/SignalSender.hpp | 2 +- 7 files changed, 105 insertions(+), 23 deletions(-) diff --git a/ndb/include/kernel/signaldata/DumpStateOrd.hpp b/ndb/include/kernel/signaldata/DumpStateOrd.hpp index 8d0961d1c27..5a1d9ece9cf 100644 --- a/ndb/include/kernel/signaldata/DumpStateOrd.hpp +++ b/ndb/include/kernel/signaldata/DumpStateOrd.hpp @@ -107,6 +107,10 @@ public: CmvmiDumpLongSignalMemory = 2601, CmvmiSetRestartOnErrorInsert = 2602, CmvmiTestLongSigWithDelay = 2603, + CmvmiDumpSubscriptions = 2604, /* note: done to respective outfile + to be able to debug if events + for some reason does not end up + in clusterlog */ // 7000 DIH // 7001 DIH // 7002 DIH diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 5dd1e527dd2..a9d9c991ca3 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -897,7 +897,7 @@ void Cmvmi::execSET_VAR_REQ(Signal* signal) case TimeToWaitAlive: // QMGR - case HeartbeatIntervalDbDb: // TODO ev till Ndbcnt också + case HeartbeatIntervalDbDb: // TODO possibly Ndbcnt too case HeartbeatIntervalDbApi: case ArbitTimeout: sendSignal(QMGR_REF, GSN_SET_VAR_REQ, signal, 3, JBB); @@ -1105,6 +1105,24 @@ Cmvmi::execDUMP_STATE_ORD(Signal* signal) } } + if (arg == DumpStateOrd::CmvmiDumpSubscriptions) + { + SubscriberPtr ptr; + subscribers.first(ptr); + g_eventLogger.info("List subscriptions:"); + while(ptr.i != RNIL) + { + g_eventLogger.info("Subscription: %u, nodeId: %u, ref: 0x%x", + ptr.i, refToNode(ptr.p->blockRef), ptr.p->blockRef); + for(Uint32 i = 0; i < LogLevel::LOGLEVEL_CATEGORIES; i++) + { + Uint32 level = ptr.p->logLevel.getLogLevel((LogLevel::EventCategory)i); + g_eventLogger.info("Category %u Level %u", i, level); + } + subscribers.next(ptr); + } + } + if (arg == DumpStateOrd::CmvmiDumpLongSignalMemory){ infoEvent("Cmvmi: g_sectionSegmentPool size: %d free: %d", g_sectionSegmentPool.getSize(), diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 0ee59f70885..5818e7fe3ae 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -704,7 +704,7 @@ int MgmtSrvr::okToSendTo(NodeId nodeId, bool unCond) return WRONG_PROCESS_TYPE; // Check if we have contact with it if(unCond){ - if(theFacade->theClusterMgr->getNodeInfo(nodeId).connected) + if(theFacade->theClusterMgr->getNodeInfo(nodeId).m_api_reg_conf) return 0; } else if (theFacade->get_node_alive(nodeId) == true) @@ -1562,32 +1562,85 @@ MgmtSrvr::status(int nodeId, } int -MgmtSrvr::setEventReportingLevelImpl(int nodeId, +MgmtSrvr::setEventReportingLevelImpl(int nodeId_arg, const EventSubscribeReq& ll) { SignalSender ss(theFacade); - ss.lock(); - - SimpleSignal ssig; - EventSubscribeReq * dst = - CAST_PTR(EventSubscribeReq, ssig.getDataPtrSend()); - ssig.set(ss,TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ, - EventSubscribeReq::SignalLength); - *dst = ll; - - NodeBitmask nodes; + NdbNodeBitmask nodes; + int retries = 30; nodes.clear(); - Uint32 max = (nodeId == 0) ? (nodeId = 1, MAX_NDB_NODES) : nodeId; - for(; (Uint32) nodeId <= max; nodeId++) + while (1) { - if (nodeTypes[nodeId] != NODE_TYPE_DB) - continue; - if (okToSendTo(nodeId, true)) - continue; - if (ss.sendSignal(nodeId, &ssig) == SEND_OK) + Uint32 nodeId, max; + ss.lock(); + SimpleSignal ssig; + EventSubscribeReq * dst = + CAST_PTR(EventSubscribeReq, ssig.getDataPtrSend()); + ssig.set(ss,TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ, + EventSubscribeReq::SignalLength); + *dst = ll; + + if (nodeId_arg == 0) { - nodes.set(nodeId); + // all nodes + nodeId = 1; + max = MAX_NDB_NODES; } + else + { + // only one node + max = nodeId = nodeId_arg; + } + // first make sure nodes are sendable + for(; nodeId <= max; nodeId++) + { + if (nodeTypes[nodeId] != NODE_TYPE_DB) + continue; + if (okToSendTo(nodeId, true)) + { + if (theFacade->theClusterMgr->getNodeInfo(nodeId).connected == false) + { + // node not connected we can safely skip this one + continue; + } + // api_reg_conf not recevied yet, need to retry + break; + } + } + if (nodeId <= max) + { + if (--retries) + { + ss.unlock(); + NdbSleep_MilliSleep(100); + continue; + } + return SEND_OR_RECEIVE_FAILED; + } + + if (nodeId_arg == 0) + { + // all nodes + nodeId = 1; + max = MAX_NDB_NODES; + } + else + { + // only one node + max = nodeId = nodeId_arg; + } + // now send to all sendable nodes nodes + // note, lock is held, so states have not changed + for(; (Uint32) nodeId <= max; nodeId++) + { + if (nodeTypes[nodeId] != NODE_TYPE_DB) + continue; + if (theFacade->theClusterMgr->getNodeInfo(nodeId).connected == false) + continue; // node is not connected, skip + if (ss.sendSignal(nodeId, &ssig) == SEND_OK) + nodes.set(nodeId); + } + break; } if (nodes.isclear()) @@ -1598,6 +1651,7 @@ MgmtSrvr::setEventReportingLevelImpl(int nodeId, int error = 0; while (!nodes.isclear()) { + Uint32 nodeId; SimpleSignal *signal = ss.waitFor(); int gsn = signal->readSignalNumber(); nodeId = refToNode(signal->header.theSendersBlockRef); diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp index 2ff27ca893e..060e5f71b6c 100644 --- a/ndb/src/ndbapi/ClusterMgr.cpp +++ b/ndb/src/ndbapi/ClusterMgr.cpp @@ -327,7 +327,7 @@ ClusterMgr::showState(NodeId nodeId){ ClusterMgr::Node::Node() : m_state(NodeState::SL_NOTHING) { compatible = nfCompleteRep = true; - connected = defined = m_alive = false; + connected = defined = m_alive = m_api_reg_conf = false; m_state.m_connected_nodes.clear(); } @@ -401,6 +401,8 @@ ClusterMgr::execAPI_REGCONF(const Uint32 * theData){ node.m_info.m_version); } + node.m_api_reg_conf = true; + node.m_state = apiRegConf->nodeState; if (node.compatible && (node.m_state.startLevel == NodeState::SL_STARTED || node.m_state.startLevel == NodeState::SL_SINGLEUSER)){ @@ -519,6 +521,7 @@ ClusterMgr::reportDisconnected(NodeId nodeId){ noOfConnectedNodes--; theNodes[nodeId].connected = false; + theNodes[nodeId].m_api_reg_conf = false; theNodes[nodeId].m_state.m_connected_nodes.clear(); reportNodeFailed(nodeId, true); diff --git a/ndb/src/ndbapi/ClusterMgr.hpp b/ndb/src/ndbapi/ClusterMgr.hpp index 32234a0b2f4..b05b73c8324 100644 --- a/ndb/src/ndbapi/ClusterMgr.hpp +++ b/ndb/src/ndbapi/ClusterMgr.hpp @@ -65,6 +65,7 @@ public: bool compatible; // Version is compatible bool nfCompleteRep; // NF Complete Rep has arrived bool m_alive; // Node is alive + bool m_api_reg_conf;// API_REGCONF has arrived NodeInfo m_info; NodeState m_state; diff --git a/ndb/src/ndbapi/SignalSender.cpp b/ndb/src/ndbapi/SignalSender.cpp index 804ea92877d..199c6d6e804 100644 --- a/ndb/src/ndbapi/SignalSender.cpp +++ b/ndb/src/ndbapi/SignalSender.cpp @@ -140,6 +140,8 @@ SignalSender::getNoOfConnectedNodes() const { SendStatus SignalSender::sendSignal(Uint16 nodeId, const SimpleSignal * s){ + assert(getNodeInfo(nodeId).m_api_reg_conf == true || + s->readSignalNumber() == GSN_API_REGREQ); return theFacade->theTransporterRegistry->prepareSend(&s->header, 1, // JBB &s->theData[0], diff --git a/ndb/src/ndbapi/SignalSender.hpp b/ndb/src/ndbapi/SignalSender.hpp index ec874e63c52..4cad759a334 100644 --- a/ndb/src/ndbapi/SignalSender.hpp +++ b/ndb/src/ndbapi/SignalSender.hpp @@ -32,7 +32,7 @@ public: Uint32 theData[25]; LinearSectionPtr ptr[3]; - int readSignalNumber() {return header.theVerId_signalNumber; } + int readSignalNumber() const {return header.theVerId_signalNumber; } Uint32 *getDataPtrSend() { return theData; } const Uint32 *getDataPtr() const { return theData; } From 00b143b439a9ae00ba6653c399f4a6da718626d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 11:16:10 +0700 Subject: [PATCH 21/78] make sure some printouts in ndbd out file is done with g_eventLogger --- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 130 +++++++++++----------- ndb/src/kernel/vm/WatchDog.cpp | 7 +- 2 files changed, 71 insertions(+), 66 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 5ee3ac8d67d..7810aa45d00 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -1786,8 +1786,8 @@ void Dbdih::execSTART_PERMREQ(Signal* signal) return; }//if if (getNodeStatus(nodeId) != NodeRecord::DEAD){ - ndbout << "nodeStatus in START_PERMREQ = " - << (Uint32) getNodeStatus(nodeId) << endl; + g_eventLogger.error("nodeStatus in START_PERMREQ = %u", + (Uint32) getNodeStatus(nodeId)); ndbrequire(false); }//if @@ -4029,9 +4029,9 @@ void Dbdih::checkCopyTab(NodeRecordPtr failedNodePtr) jam(); break; default: - ndbout_c("outstanding gsn: %s(%d)", - getSignalName(c_nodeStartMaster.m_outstandingGsn), - c_nodeStartMaster.m_outstandingGsn); + g_eventLogger.error("outstanding gsn: %s(%d)", + getSignalName(c_nodeStartMaster.m_outstandingGsn), + c_nodeStartMaster.m_outstandingGsn); ndbrequire(false); } @@ -4472,9 +4472,10 @@ void Dbdih::failedNodeLcpHandling(Signal* signal, NodeRecordPtr failedNodePtr) failedNodePtr.p->activeStatus = Sysfile::NS_NotActive_NotTakenOver; break; default: - ndbout << "activeStatus = " << (Uint32) failedNodePtr.p->activeStatus; - ndbout << " at failure after NODE_FAILREP of node = "; - ndbout << failedNodePtr.i << endl; + g_eventLogger.error("activeStatus = %u " + "at failure after NODE_FAILREP of node = %u", + (Uint32) failedNodePtr.p->activeStatus, + failedNodePtr.i); ndbrequire(false); break; }//switch @@ -4629,7 +4630,7 @@ Dbdih::startLcpMasterTakeOver(Signal* signal, Uint32 nodeId){ /** * Node failure during master take over... */ - ndbout_c("Nodefail during master take over"); + g_eventLogger.info("Nodefail during master take over"); } setLocalNodefailHandling(signal, nodeId, NF_LCP_TAKE_OVER); @@ -4869,7 +4870,8 @@ void Dbdih::execMASTER_GCPCONF(Signal* signal) if (latestLcpId > SYSFILE->latestLCP_ID) { jam(); #if 0 - ndbout_c("Dbdih: Setting SYSFILE->latestLCP_ID to %d", latestLcpId); + g_eventLogger.info("Dbdih: Setting SYSFILE->latestLCP_ID to %d", + latestLcpId); SYSFILE->latestLCP_ID = latestLcpId; #endif SYSFILE->keepGCI = oldestKeepGci; @@ -5528,7 +5530,7 @@ Dbdih::checkLocalNodefailComplete(Signal* signal, Uint32 failedNodeId, if (ERROR_INSERTED(7030)) { - ndbout_c("Reenable GCP_PREPARE"); + g_eventLogger.info("Reenable GCP_PREPARE"); CLEAR_ERROR_INSERT_VALUE; } @@ -5701,7 +5703,7 @@ Dbdih::sendMASTER_LCPCONF(Signal * signal){ c_lcpState.setLcpStatus(LCP_STATUS_IDLE, __LINE__); #if 0 if(c_copyGCISlave.m_copyReason == CopyGCIReq::LOCAL_CHECKPOINT){ - ndbout_c("Dbdih: Also resetting c_copyGCISlave"); + g_eventLogger.info("Dbdih: Also resetting c_copyGCISlave"); c_copyGCISlave.m_copyReason = CopyGCIReq::IDLE; c_copyGCISlave.m_expectedNextWord = 0; } @@ -5790,7 +5792,7 @@ Dbdih::sendMASTER_LCPCONF(Signal * signal){ if(c_lcpState.lcpStatus == LCP_TAB_SAVED){ #ifdef VM_TRACE - ndbout_c("Sending extra GSN_LCP_COMPLETE_REP to new master"); + g_eventLogger.info("Sending extra GSN_LCP_COMPLETE_REP to new master"); #endif sendLCP_COMPLETE_REP(signal); } @@ -5946,7 +5948,7 @@ void Dbdih::execMASTER_LCPCONF(Signal* signal) nodePtr.p->lcpStateAtTakeOver = lcpState; #ifdef VM_TRACE - ndbout_c("MASTER_LCPCONF"); + g_eventLogger.info("MASTER_LCPCONF"); printMASTER_LCP_CONF(stdout, &signal->theData[0], 0, 0); #endif @@ -6023,7 +6025,7 @@ void Dbdih::MASTER_LCPhandling(Signal* signal, Uint32 failedNodeId) // protocol. /* --------------------------------------------------------------------- */ #ifdef VM_TRACE - ndbout_c("MASTER_LCPhandling:: LMTOS_ALL_IDLE -> checkLcpStart"); + g_eventLogger.info("MASTER_LCPhandling:: LMTOS_ALL_IDLE -> checkLcpStart"); #endif checkLcpStart(signal, __LINE__); break; @@ -6034,7 +6036,7 @@ void Dbdih::MASTER_LCPhandling(Signal* signal, Uint32 failedNodeId) // protocol by calculating the keep gci and storing the new lcp id. /* --------------------------------------------------------------------- */ #ifdef VM_TRACE - ndbout_c("MASTER_LCPhandling:: LMTOS_COPY_ONGOING -> storeNewLcpId"); + g_eventLogger.info("MASTER_LCPhandling:: LMTOS_COPY_ONGOING -> storeNewLcpId"); #endif if (c_lcpState.lcpStatus == LCP_STATUS_ACTIVE) { jam(); @@ -6045,7 +6047,7 @@ void Dbdih::MASTER_LCPhandling(Signal* signal, Uint32 failedNodeId) /*---------------------------------------------------------------------*/ Uint32 lcpId = SYSFILE->latestLCP_ID; #ifdef VM_TRACE - ndbout_c("Decreasing latestLCP_ID from %d to %d", lcpId, lcpId - 1); + g_eventLogger.info("Decreasing latestLCP_ID from %d to %d", lcpId, lcpId - 1); #endif SYSFILE->latestLCP_ID--; }//if @@ -6062,10 +6064,10 @@ void Dbdih::MASTER_LCPhandling(Signal* signal, Uint32 failedNodeId) * complete before finalising the LCP process. * ------------------------------------------------------------------ */ #ifdef VM_TRACE - ndbout_c("MASTER_LCPhandling:: LMTOS_ALL_ACTIVE -> " - "startLcpRoundLoopLab(table=%u, fragment=%u)", - c_lcpMasterTakeOverState.minTableId, - c_lcpMasterTakeOverState.minFragId); + g_eventLogger.info("MASTER_LCPhandling:: LMTOS_ALL_ACTIVE -> " + "startLcpRoundLoopLab(table=%u, fragment=%u)", + c_lcpMasterTakeOverState.minTableId, + c_lcpMasterTakeOverState.minFragId); #endif c_lcpState.keepGci = SYSFILE->keepGCI; @@ -7376,8 +7378,8 @@ void Dbdih::checkGcpStopLab(Signal* signal) if (cgcpSameCounter == 1200) { jam(); #ifdef VM_TRACE - ndbout << "System crash due to GCP Stop in state = "; - ndbout << (Uint32) cgcpStatus << endl; + g_eventLogger.error("System crash due to GCP Stop in state = %u", + (Uint32) cgcpStatus); #endif crashSystemAtGcpStop(signal); return; @@ -7390,8 +7392,8 @@ void Dbdih::checkGcpStopLab(Signal* signal) if (cgcpSameCounter == 1200) { jam(); #ifdef VM_TRACE - ndbout << "System crash due to GCP Stop in state = "; - ndbout << (Uint32) cgcpStatus << endl; + g_eventLogger.error("System crash due to GCP Stop in state = %u", + (Uint32) cgcpStatus); #endif crashSystemAtGcpStop(signal); return; @@ -7582,7 +7584,7 @@ void Dbdih::GCP_SAVEhandling(Signal* signal, Uint32 nodeId) getNodeState().startLevel == NodeState::SL_STARTED){ jam(); #if 0 - ndbout_c("Dbdih: Clearing initial start ongoing"); + g_eventLogger.info("Dbdih: Clearing initial start ongoing"); #endif Sysfile::clearInitialStartOngoing(SYSFILE->systemRestartBits); } @@ -7601,7 +7603,7 @@ void Dbdih::execGCP_PREPARE(Signal* signal) if (ERROR_INSERTED(7030)) { cgckptflag = true; - ndbout_c("Delayed GCP_PREPARE 5s"); + g_eventLogger.info("Delayed GCP_PREPARE 5s"); sendSignalWithDelay(reference(), GSN_GCP_PREPARE, signal, 5000, signal->getLength()); return; @@ -7621,7 +7623,7 @@ void Dbdih::execGCP_PREPARE(Signal* signal) if (ERROR_INSERTED(7031)) { - ndbout_c("Crashing delayed in GCP_PREPARE 3s"); + g_eventLogger.info("Crashing delayed in GCP_PREPARE 3s"); signal->theData[0] = 9999; sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 3000, 1); return; @@ -8136,7 +8138,7 @@ void Dbdih::initLcpLab(Signal* signal, Uint32 senderRef, Uint32 tableId) * This is LCP master takeover */ #ifdef VM_TRACE - ndbout_c("initLcpLab aborted due to LCP master takeover - 1"); + g_eventLogger.info("initLcpLab aborted due to LCP master takeover - 1"); #endif c_lcpState.setLcpStatus(LCP_STATUS_IDLE, __LINE__); sendMASTER_LCPCONF(signal); @@ -8149,7 +8151,7 @@ void Dbdih::initLcpLab(Signal* signal, Uint32 senderRef, Uint32 tableId) * Master take over but has not yet received MASTER_LCPREQ */ #ifdef VM_TRACE - ndbout_c("initLcpLab aborted due to LCP master takeover - 2"); + g_eventLogger.info("initLcpLab aborted due to LCP master takeover - 2"); #endif return; } @@ -9380,9 +9382,10 @@ void Dbdih::checkTcCounterLab(Signal* signal) { CRASH_INSERTION(7009); if (c_lcpState.lcpStatus != LCP_STATUS_IDLE) { - ndbout << "lcpStatus = " << (Uint32) c_lcpState.lcpStatus; - ndbout << "lcpStatusUpdatedPlace = " << - c_lcpState.lcpStatusUpdatedPlace << endl; + g_eventLogger.error("lcpStatus = %u" + "lcpStatusUpdatedPlace = %d", + (Uint32) c_lcpState.lcpStatus, + c_lcpState.lcpStatusUpdatedPlace); ndbrequire(false); return; }//if @@ -9935,9 +9938,8 @@ void Dbdih::execLCP_FRAG_REP(Signal* signal) if(tabPtr.p->tabStatus == TabRecord::TS_DROPPING){ jam(); - ndbout_c("TS_DROPPING - Neglecting to save Table: %d Frag: %d - ", - tableId, - fragId); + g_eventLogger.info("TS_DROPPING - Neglecting to save Table: %d Frag: %d - ", + tableId, fragId); } else { jam(); /** @@ -10065,7 +10067,7 @@ void Dbdih::findReplica(ReplicaRecordPtr& replicaPtr, }; #ifdef VM_TRACE - ndbout_c("Fragment Replica(node=%d) not found", nodeId); + g_eventLogger.info("Fragment Replica(node=%d) not found", nodeId); replicaPtr.i = fragPtrP->oldStoredReplicas; while(replicaPtr.i != RNIL){ ptrCheckGuard(replicaPtr, creplicaFileSize, replicaRecord); @@ -10078,9 +10080,9 @@ void Dbdih::findReplica(ReplicaRecordPtr& replicaPtr, }//if }; if(replicaPtr.i != RNIL){ - ndbout_c("...But was found in oldStoredReplicas"); + g_eventLogger.info("...But was found in oldStoredReplicas"); } else { - ndbout_c("...And wasn't found in oldStoredReplicas"); + g_eventLogger.info("...And wasn't found in oldStoredReplicas"); } #endif ndbrequire(false); @@ -10114,8 +10116,8 @@ Dbdih::reportLcpCompletion(const LcpFragRep* lcpReport) ndbrequire(replicaPtr.p->lcpOngoingFlag == true); if(lcpNo != replicaPtr.p->nextLcp){ - ndbout_c("lcpNo = %d replicaPtr.p->nextLcp = %d", - lcpNo, replicaPtr.p->nextLcp); + g_eventLogger.error("lcpNo = %d replicaPtr.p->nextLcp = %d", + lcpNo, replicaPtr.p->nextLcp); ndbrequire(false); } ndbrequire(lcpNo == replicaPtr.p->nextLcp); @@ -10150,7 +10152,7 @@ Dbdih::reportLcpCompletion(const LcpFragRep* lcpReport) // Not all fragments in table have been checkpointed. /* ----------------------------------------------------------------- */ if(0) - ndbout_c("reportLcpCompletion: fragment %d not ready", fid); + g_eventLogger.info("reportLcpCompletion: fragment %d not ready", fid); return false; }//if }//for @@ -10267,7 +10269,7 @@ void Dbdih::execLCP_COMPLETE_REP(Signal* signal) jamEntry(); #if 0 - ndbout_c("LCP_COMPLETE_REP"); + g_eventLogger.info("LCP_COMPLETE_REP"); printLCP_COMPLETE_REP(stdout, signal->getDataPtr(), signal->length(), number()); @@ -10353,7 +10355,7 @@ void Dbdih::allNodesLcpCompletedLab(Signal* signal) if(c_lcpMasterTakeOverState.state != LMTOS_IDLE){ jam(); #ifdef VM_TRACE - ndbout_c("Exiting from allNodesLcpCompletedLab"); + g_eventLogger.info("Exiting from allNodesLcpCompletedLab"); #endif return; } @@ -10582,14 +10584,14 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal) infoEvent("Detected GCP stop...sending kill to %s", c_GCP_SAVEREQ_Counter.getText()); - ndbout_c("Detected GCP stop...sending kill to %s", - c_GCP_SAVEREQ_Counter.getText()); + g_eventLogger.error("Detected GCP stop...sending kill to %s", + c_GCP_SAVEREQ_Counter.getText()); return; } case GCP_SAVE_LQH_FINISHED: - ndbout_c("m_copyReason: %d m_waiting: %d", - c_copyGCIMaster.m_copyReason, - c_copyGCIMaster.m_waiting); + g_eventLogger.error("m_copyReason: %d m_waiting: %d", + c_copyGCIMaster.m_copyReason, + c_copyGCIMaster.m_waiting); break; case GCP_READY: // shut up lint case GCP_PREPARE_SENT: @@ -10597,11 +10599,11 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal) break; } - ndbout_c("c_copyGCISlave: sender{Data, Ref} %d %x reason: %d nextWord: %d", - c_copyGCISlave.m_senderData, - c_copyGCISlave.m_senderRef, - c_copyGCISlave.m_copyReason, - c_copyGCISlave.m_expectedNextWord); + g_eventLogger.error("c_copyGCISlave: sender{Data, Ref} %d %x reason: %d nextWord: %d", + c_copyGCISlave.m_senderData, + c_copyGCISlave.m_senderRef, + c_copyGCISlave.m_copyReason, + c_copyGCISlave.m_expectedNextWord); FileRecordPtr file0Ptr; file0Ptr.i = crestartInfoFile[0]; @@ -12804,9 +12806,9 @@ void Dbdih::setLcpActiveStatusEnd() nodePtr.i = getOwnNodeId(); ptrAss(nodePtr, nodeRecord); ndbrequire(nodePtr.p->activeStatus == Sysfile::NS_Active); - ndbout_c("NR: setLcpActiveStatusEnd - m_participatingLQH"); + g_eventLogger.info("NR: setLcpActiveStatusEnd - m_participatingLQH"); } else { - ndbout_c("NR: setLcpActiveStatusEnd - !m_participatingLQH"); + g_eventLogger.info("NR: setLcpActiveStatusEnd - !m_participatingLQH"); } } @@ -13637,8 +13639,8 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) } if(arg == DumpStateOrd::EnableUndoDelayDataWrite){ - ndbout << "Dbdih:: delay write of datapages for table = " - << dumpState->args[1]<< endl; + g_eventLogger.info("Dbdih:: delay write of datapages for table = %s", + dumpState->args[1]); // Send this dump to ACC and TUP EXECUTE_DIRECT(DBACC, GSN_DUMP_STATE_ORD, signal, 2); EXECUTE_DIRECT(DBTUP, GSN_DUMP_STATE_ORD, signal, 2); @@ -13655,13 +13657,13 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) }//if if (signal->theData[0] == DumpStateOrd::DihMinTimeBetweenLCP) { // Set time between LCP to min value - ndbout << "Set time between LCP to min value" << endl; + g_eventLogger.info("Set time between LCP to min value"); c_lcpState.clcpDelay = 0; // TimeBetweenLocalCheckpoints.min return; } if (signal->theData[0] == DumpStateOrd::DihMaxTimeBetweenLCP) { // Set time between LCP to max value - ndbout << "Set time between LCP to max value" << endl; + g_eventLogger.info("Set time between LCP to max value"); c_lcpState.clcpDelay = 31; // TimeBetweenLocalCheckpoints.max return; } @@ -13697,7 +13699,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) { cgcpDelay = signal->theData[1]; } - ndbout_c("Setting time between gcp : %d", cgcpDelay); + g_eventLogger.info("Setting time between gcp : %d", cgcpDelay); } if (arg == 7021 && signal->getLength() == 2) @@ -13820,7 +13822,7 @@ Dbdih::execPREP_DROP_TAB_REQ(Signal* signal){ while(index < count){ if(nodePtr.p->queuedChkpt[index].tableId == tabPtr.i){ jam(); - // ndbout_c("Unqueuing %d", index); + // g_eventLogger.info("Unqueuing %d", index); count--; for(Uint32 i = index; i #include #include - +#include + +extern EventLogger g_eventLogger; + extern "C" void* runWatchDog(void* w){ @@ -125,7 +128,7 @@ WatchDog::run(){ last_stuck_action = "Unknown place"; break; }//switch - ndbout << "Ndb kernel is stuck in: " << last_stuck_action << endl; + g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action); if(alerts == 3){ shutdownSystem(last_stuck_action); } From 7fd6bbce2538f30fa2a2a76da44117e28e5c7a57 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:22:03 +1100 Subject: [PATCH 22/78] WL#3704 mgmapi timeouts (and cleanups) indicate units in SocketOutputStream timeout rename timeout in SocketOutputStream to reflect units (ms) In 5.0 as well as is safe cleanup patch that will help with merging. ndb/include/util/OutputStream.hpp: rename timeout in SocketOutputStream to reflect units (ms) ndb/src/common/util/OutputStream.cpp: rename timeout in SocketOutputStream to reflect units (ms) --- ndb/include/util/OutputStream.hpp | 6 +++--- ndb/src/common/util/OutputStream.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ndb/include/util/OutputStream.hpp b/ndb/include/util/OutputStream.hpp index 460915e12e7..35ef3c5fed4 100644 --- a/ndb/include/util/OutputStream.hpp +++ b/ndb/include/util/OutputStream.hpp @@ -42,10 +42,10 @@ public: class SocketOutputStream : public OutputStream { NDB_SOCKET_TYPE m_socket; - unsigned m_timeout; + unsigned m_timeout_ms; public: - SocketOutputStream(NDB_SOCKET_TYPE socket, unsigned writeTimeout = 1000); - + SocketOutputStream(NDB_SOCKET_TYPE socket, unsigned write_timeout_ms = 1000); + int print(const char * fmt, ...); int println(const char * fmt, ...); }; diff --git a/ndb/src/common/util/OutputStream.cpp b/ndb/src/common/util/OutputStream.cpp index cccd76eac2c..eada1452f02 100644 --- a/ndb/src/common/util/OutputStream.cpp +++ b/ndb/src/common/util/OutputStream.cpp @@ -42,16 +42,16 @@ FileOutputStream::println(const char * fmt, ...){ } SocketOutputStream::SocketOutputStream(NDB_SOCKET_TYPE socket, - unsigned timeout){ + unsigned write_timeout_ms){ m_socket = socket; - m_timeout = timeout; + m_timeout_ms = write_timeout_ms; } int SocketOutputStream::print(const char * fmt, ...){ va_list ap; va_start(ap, fmt); - const int ret = vprint_socket(m_socket, m_timeout, fmt, ap); + const int ret = vprint_socket(m_socket, m_timeout_ms, fmt, ap); va_end(ap); return ret; } @@ -59,7 +59,7 @@ int SocketOutputStream::println(const char * fmt, ...){ va_list ap; va_start(ap, fmt); - const int ret = vprintln_socket(m_socket, m_timeout, fmt, ap); + const int ret = vprintln_socket(m_socket, m_timeout_ms, fmt, ap); va_end(ap); return ret; } From 22d157e494bc271b001b304509ac67d13eec10af Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:28:04 +1100 Subject: [PATCH 23/78] BUG#26352 unused ndb_mgm_rep_command in mgmapi.cpp ndb/src/mgmapi/mgmapi.cpp: remove ndb_mgm_rep_command function --- ndb/src/mgmapi/mgmapi.cpp | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index fa7aed8b182..cacb55fe8fc 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -2187,43 +2187,6 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype, return nodeid; } -/***************************************************************************** - * Global Replication - ******************************************************************************/ -extern "C" -int -ndb_mgm_rep_command(NdbMgmHandle handle, unsigned int request, - unsigned int* replication_id, - struct ndb_mgm_reply* /*reply*/) -{ - SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_rep_command"); - const ParserRow replication_reply[] = { - MGM_CMD("global replication reply", NULL, ""), - MGM_ARG("result", String, Mandatory, "Error message"), - MGM_ARG("id", Int, Optional, "Id of global replication"), - MGM_END() - }; - CHECK_HANDLE(handle, -1); - CHECK_CONNECTED(handle, -1); - - Properties args; - args.put("request", request); - const Properties *reply; - reply = ndb_mgm_call(handle, replication_reply, "rep", &args); - CHECK_REPLY(reply, -1); - - const char * result; - reply->get("result", &result); - reply->get("id", replication_id); - if(strcmp(result,"Ok")!=0) { - delete reply; - return -1; - } - - delete reply; - return 0; -} - extern "C" int ndb_mgm_set_int_parameter(NdbMgmHandle handle, From a031b4307cfc78262bc512be27dcc7f2c9a5267f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:35:29 +1100 Subject: [PATCH 24/78] BUG#26353 remove GET_CONFIG_BACKWARDS_COMPAT from ndb_mgmd there is backwards compatibility for GET CONFIG style configuration requests in ndb_mgmd. None of the ndbd versions that use this couldn't possibly connect to a 5.0 or 5.1 cluster. remove the backwards compat remove it ndb/src/mgmsrv/Services.cpp: remove MGM_GET_CONFIG_BACKWARDS_COMPAT code. any client using GET CONFIG will just not work with modern NDB. ndb/src/mgmsrv/Services.hpp: remove GET CONFIG support --- ndb/src/mgmsrv/Services.cpp | 86 ++----------------------------------- ndb/src/mgmsrv/Services.hpp | 9 ---- 2 files changed, 3 insertions(+), 92 deletions(-) diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index a2dec949f67..aa35c826535 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -332,19 +332,6 @@ MgmApiSession::runSession() switch(ctx.m_status) { case Parser_t::UnknownCommand: -#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT - /* Backwards compatibility for old NDBs that still use - * the old "GET CONFIG" command. - */ - size_t i; - for(i=0; iprintln("Expected 2 arguments for GET CONFIG"); - return; - } - - /* Put arguments in properties object so we can call the real function */ - args.put("version", version); - args.put("node", node); - getConfig_common(ctx, args, true); -} -#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */ - -void -MgmApiSession::getConfig(Parser_t::Context &ctx, - const class Properties &args) { - getConfig_common(ctx, args); -} - static Properties * backward(const char * base, const Properties* reply){ Properties * ret = new Properties(); @@ -560,9 +521,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &, } void -MgmApiSession::getConfig_common(Parser_t::Context &, - const class Properties &args, - bool compat) { +MgmApiSession::getConfig(Parser_t::Context &, + const class Properties &args) +{ Uint32 version, node = 0; args.get("version", &version); @@ -576,47 +537,6 @@ MgmApiSession::getConfig_common(Parser_t::Context &, return; } - if(version > 0 && version < makeVersion(3, 5, 0) && compat){ - Properties *reply = backward("", conf->m_oldConfig); - reply->put("Version", version); - reply->put("LocalNodeId", node); - - backward("", reply); - //reply->print(); - - const Uint32 size = reply->getPackedSize(); - Uint32 *buffer = new Uint32[size/4+1]; - - reply->pack(buffer); - delete reply; - - const int uurows = (size + 44)/45; - char * uubuf = new char[uurows * 62+5]; - - const int uusz = uuencode_mem(uubuf, (char *)buffer, size); - delete[] buffer; - - m_output->println("GET CONFIG %d %d %d %d %d", - 0, version, node, size, uusz); - - m_output->println("begin 664 Ndb_cfg.bin"); - - /* XXX Need to write directly to the socket, because the uubuf is not - * NUL-terminated. This could/should probably be done in a nicer way. - */ - write_socket(m_socket, MAX_WRITE_TIMEOUT, uubuf, uusz); - delete[] uubuf; - - m_output->println("end"); - m_output->println(""); - return; - } - - if(compat){ - m_output->println("GET CONFIG %d %d %d %d %d",1, version, 0, 0, 0); - return; - } - if(node != 0){ bool compatible; switch (m_mgmsrv.getNodeType(node)) { diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp index 4d904e8369e..48ba55a8b12 100644 --- a/ndb/src/mgmsrv/Services.hpp +++ b/ndb/src/mgmsrv/Services.hpp @@ -24,9 +24,6 @@ #include "MgmtSrvr.hpp" -/** Undefine this to remove backwards compatibility for "GET CONFIG". */ -#define MGM_GET_CONFIG_BACKWARDS_COMPAT - class MgmApiSession : public SocketServer::Session { static void stop_session_if_timed_out(SocketServer::Session *_s, void *data); @@ -42,9 +39,6 @@ private: char m_err_str[1024]; int m_stopSelf; // -1 is restart, 0 do nothing, 1 stop - void getConfig_common(Parser_t::Context &ctx, - const class Properties &args, - bool compat = false); const char *get_error_text(int err_no) { return m_mgmsrv.getErrorText(err_no, m_err_str, sizeof(m_err_str)); } @@ -55,9 +49,6 @@ public: void getStatPort(Parser_t::Context &ctx, const class Properties &args); void getConfig(Parser_t::Context &ctx, const class Properties &args); -#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT - void getConfig_old(Parser_t::Context &ctx); -#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */ void get_nodeid(Parser_t::Context &ctx, const class Properties &args); void getVersion(Parser_t::Context &ctx, const class Properties &args); From e953dd8a35631fc3051d1b0f57fc3867b17bc851 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:47:34 +1100 Subject: [PATCH 25/78] BUG#26355 FIXME: use constant for max loglevel in ndb_mgmd ndb/include/mgmapi/mgmapi.h: use constant for max log level in ndb_mgmd. (more useful in 5.1 due to other defines and refinements of mgmapi) ndb/src/mgmsrv/Services.cpp: fix the XXX fixme of constant for max log level --- ndb/include/mgmapi/mgmapi.h | 2 ++ ndb/src/mgmsrv/Services.cpp | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index 2423048f98f..e5889a1ee6d 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -16,6 +16,8 @@ #ifndef MGMAPI_H #define MGMAPI_H +#define NDB_MGM_MAX_LOGLEVEL 15 + /** * @mainpage MySQL Cluster Management API * diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index aa35c826535..01f71aa24f5 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -764,8 +764,7 @@ MgmApiSession::setClusterLogLevel(Parser::Context &, DBUG_PRINT("enter",("node=%d, category=%d, level=%d", node, cat, level)); - /* XXX should use constants for this value */ - if(level > 15) { + if(level > NDB_MGM_MAX_LOGLEVEL) { m_output->println(reply); m_output->println("result: Invalid loglevel %d", level); m_output->println(""); @@ -809,8 +808,7 @@ MgmApiSession::setLogLevel(Parser::Context &, args.get("category", &cat); args.get("level", &level); - /* XXX should use constants for this value */ - if(level > 15) { + if(level > NDB_MGM_MAX_LOGLEVEL) { m_output->println("set loglevel reply"); m_output->println("result: Invalid loglevel", errorString.c_str()); m_output->println(""); @@ -1510,7 +1508,7 @@ MgmApiSession::listen_event(Parser::Context & ctx, } int level = atoi(spec[1].c_str()); - if(level < 0 || level > 15){ + if(level < 0 || level > NDB_MGM_MAX_LOGLEVEL){ msg.appfmt("Invalid level: >%s<", spec[1].c_str()); result = -1; goto done; From cea0d57d7039cae92756c5b2305de1f0ee38f24d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:51:16 +1100 Subject: [PATCH 26/78] BUG#26356 uninitialised data sent from TAMPER_ORD to DIHNDBTAMPER Don't send uninit data in TAMPER_ORD to DIHNDBTAMPER Even though this data is unused from the CMVMI (mgmd) signal, we shouldn't be doing stuff with uninited data. ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: init the 3rd word of DIHNDBTAMPER before sending to DIH. --- ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 5dd1e527dd2..00343172cb0 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -839,7 +839,7 @@ void Cmvmi::execTAMPER_ORD(Signal* signal) // to be able to indicate if we really introduced an error. #ifdef ERROR_INSERT TamperOrd* const tamperOrd = (TamperOrd*)&signal->theData[0]; - + signal->theData[2] = 0; signal->theData[1] = tamperOrd->errorNo; signal->theData[0] = 5; sendSignal(DBDIH_REF, GSN_DIHNDBTAMPER, signal, 3,JBB); From f8a679e9a674204e19458a3f468eb6c8f3f8b0f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:55:08 +1100 Subject: [PATCH 27/78] BUG#26357 remove unused GSN_STATISTICS_REQ and CONF remove GSN_STATISTICS_REQ and CONF These are unused and have been since BK import. not needed. ndb/include/kernel/GlobalSignalNumbers.h: remove STATISTICS_REQ and CONF ndb/src/common/debugger/signaldata/SignalNames.cpp: remove signal names for STATISTICS_REQ and CONF (unused) ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: remove unused STATISTICS signals ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp: remove unused STATISTICS signals --- ndb/include/kernel/GlobalSignalNumbers.h | 4 ++-- .../debugger/signaldata/SignalNames.cpp | 4 +--- ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 19 ------------------- ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp | 1 - 4 files changed, 3 insertions(+), 25 deletions(-) diff --git a/ndb/include/kernel/GlobalSignalNumbers.h b/ndb/include/kernel/GlobalSignalNumbers.h index 08d35a0b0cb..78be268cbc7 100644 --- a/ndb/include/kernel/GlobalSignalNumbers.h +++ b/ndb/include/kernel/GlobalSignalNumbers.h @@ -540,13 +540,13 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES; #define GSN_ABORT_ALL_REF 446 #define GSN_ABORT_ALL_CONF 447 -#define GSN_STATISTICS_REQ 448 +/* 448 unused - formerly GSN_STATISTICS_REQ */ #define GSN_STOP_ORD 449 #define GSN_TAMPER_ORD 450 #define GSN_SET_VAR_REQ 451 #define GSN_SET_VAR_CONF 452 #define GSN_SET_VAR_REF 453 -#define GSN_STATISTICS_CONF 454 +/* 454 unused - formerly GSN_STATISTICS_CONF */ #define GSN_START_ORD 455 /* 457 unused */ diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 9839fd32cf2..36185638b57 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -380,15 +380,13 @@ const GsnName SignalNames [] = { ,{ GSN_TUP_WRITELOG_REQ, "TUP_WRITELOG_REQ" } ,{ GSN_LQH_WRITELOG_REQ, "LQH_WRITELOG_REQ" } - ,{ GSN_STATISTICS_REQ, "STATISTICS_REQ" } ,{ GSN_START_ORD, "START_ORD" } ,{ GSN_STOP_ORD, "STOP_ORD" } ,{ GSN_TAMPER_ORD, "TAMPER_ORD" } ,{ GSN_SET_VAR_REQ, "SET_VAR_REQ" } ,{ GSN_SET_VAR_CONF, "SET_VAR_CONF" } ,{ GSN_SET_VAR_REF, "SET_VAR_REF" } - ,{ GSN_STATISTICS_CONF, "STATISTICS_CONF" } - + ,{ GSN_EVENT_SUBSCRIBE_REQ, "EVENT_SUBSCRIBE_REQ" } ,{ GSN_EVENT_SUBSCRIBE_CONF, "EVENT_SUBSCRIBE_CONF" } ,{ GSN_EVENT_SUBSCRIBE_REF, "EVENT_SUBSCRIBE_REF" } diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 00343172cb0..9e8a1df0138 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -77,7 +77,6 @@ Cmvmi::Cmvmi(const Configuration & conf) : addRecSignal(GSN_OPEN_COMREQ, &Cmvmi::execOPEN_COMREQ); addRecSignal(GSN_TEST_ORD, &Cmvmi::execTEST_ORD); - addRecSignal(GSN_STATISTICS_REQ, &Cmvmi::execSTATISTICS_REQ); addRecSignal(GSN_TAMPER_ORD, &Cmvmi::execTAMPER_ORD); addRecSignal(GSN_SET_VAR_REQ, &Cmvmi::execSET_VAR_REQ); addRecSignal(GSN_SET_VAR_CONF, &Cmvmi::execSET_VAR_CONF); @@ -703,24 +702,6 @@ Cmvmi::execTEST_ORD(Signal * signal){ #endif } -void Cmvmi::execSTATISTICS_REQ(Signal* signal) -{ - // TODO Note ! This is only a test implementation... - - static int stat1 = 0; - jamEntry(); - - //ndbout << "data 1: " << signal->theData[1]; - - int x = signal->theData[0]; - stat1++; - signal->theData[0] = stat1; - sendSignal(x, GSN_STATISTICS_CONF, signal, 7, JBB); - -}//execSTATISTICS_REQ() - - - void Cmvmi::execSTOP_ORD(Signal* signal) { jamEntry(); diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp index e3a20795701..b4ed5e45490 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp @@ -55,7 +55,6 @@ private: void execSIZEALT_ACK(Signal* signal); void execTEST_ORD(Signal* signal); - void execSTATISTICS_REQ(Signal* signal); void execSTOP_ORD(Signal* signal); void execSTART_ORD(Signal* signal); void execTAMPER_ORD(Signal* signal); From 6f334b5558f48ed0b3fa4b9881d79a182f55348b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 16:03:25 +1100 Subject: [PATCH 28/78] BUG#26358 remove unused and non-working SET_VAR_REQ/CONF signals remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/include/kernel/GlobalSignalNumbers.h: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/common/debugger/signaldata/SignalNames.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbacc/Dbacc.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbacc/DbaccInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbacc/DbaccMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbdih/Dbdih.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbdih/DbdihInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dblqh/Dblqh.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbtc/Dbtc.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbtc/DbtcInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbtup/Dbtup.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/dbtup/DbtupGen.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/qmgr/Qmgr.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/qmgr/QmgrInit.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) ndb/src/mgmsrv/MgmtSrvr.hpp: remove SET_VAR_REQ,REF,CONF - unused, #if 0 and confusing Remove the dead SET_VAR_REQ,REF,CONF signals. They: a) don't currently work b) will cause confusion with future mgmd updates for signal interface to configuration things (e.g. port numbers) --- ndb/include/kernel/GlobalSignalNumbers.h | 6 +- .../debugger/signaldata/SignalNames.cpp | 3 - ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 157 ------------------ ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp | 5 - ndb/src/kernel/blocks/dbacc/Dbacc.hpp | 1 - ndb/src/kernel/blocks/dbacc/DbaccInit.cpp | 1 - ndb/src/kernel/blocks/dbacc/DbaccMain.cpp | 27 --- ndb/src/kernel/blocks/dbdih/Dbdih.hpp | 1 - ndb/src/kernel/blocks/dbdih/DbdihInit.cpp | 1 - ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 24 --- ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 1 - ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 1 - ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 24 --- ndb/src/kernel/blocks/dbtc/Dbtc.hpp | 1 - ndb/src/kernel/blocks/dbtc/DbtcInit.cpp | 1 - ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 30 ---- ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 1 - ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 28 ---- ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp | 1 - ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp | 1 - ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 17 -- ndb/src/kernel/blocks/qmgr/Qmgr.hpp | 1 - ndb/src/kernel/blocks/qmgr/QmgrInit.cpp | 1 - ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 28 ---- ndb/src/mgmsrv/MgmtSrvr.hpp | 1 - 25 files changed, 3 insertions(+), 360 deletions(-) diff --git a/ndb/include/kernel/GlobalSignalNumbers.h b/ndb/include/kernel/GlobalSignalNumbers.h index 78be268cbc7..1ffc198de41 100644 --- a/ndb/include/kernel/GlobalSignalNumbers.h +++ b/ndb/include/kernel/GlobalSignalNumbers.h @@ -543,9 +543,9 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES; /* 448 unused - formerly GSN_STATISTICS_REQ */ #define GSN_STOP_ORD 449 #define GSN_TAMPER_ORD 450 -#define GSN_SET_VAR_REQ 451 -#define GSN_SET_VAR_CONF 452 -#define GSN_SET_VAR_REF 453 +/* 451 unused - formerly GSN_SET_VAR_REQ */ +/* 452 unused - formerly GSN_SET_VAR_CONF */ +/* 453 unused - formerly GSN_SET_VAR_REF */ /* 454 unused - formerly GSN_STATISTICS_CONF */ #define GSN_START_ORD 455 diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 36185638b57..66e7a10cdb7 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -383,9 +383,6 @@ const GsnName SignalNames [] = { ,{ GSN_START_ORD, "START_ORD" } ,{ GSN_STOP_ORD, "STOP_ORD" } ,{ GSN_TAMPER_ORD, "TAMPER_ORD" } - ,{ GSN_SET_VAR_REQ, "SET_VAR_REQ" } - ,{ GSN_SET_VAR_CONF, "SET_VAR_CONF" } - ,{ GSN_SET_VAR_REF, "SET_VAR_REF" } ,{ GSN_EVENT_SUBSCRIBE_REQ, "EVENT_SUBSCRIBE_REQ" } ,{ GSN_EVENT_SUBSCRIBE_CONF, "EVENT_SUBSCRIBE_CONF" } diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 9e8a1df0138..b8b539e22c9 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -78,9 +78,6 @@ Cmvmi::Cmvmi(const Configuration & conf) : addRecSignal(GSN_TEST_ORD, &Cmvmi::execTEST_ORD); addRecSignal(GSN_TAMPER_ORD, &Cmvmi::execTAMPER_ORD); - addRecSignal(GSN_SET_VAR_REQ, &Cmvmi::execSET_VAR_REQ); - addRecSignal(GSN_SET_VAR_CONF, &Cmvmi::execSET_VAR_CONF); - addRecSignal(GSN_SET_VAR_REF, &Cmvmi::execSET_VAR_REF); addRecSignal(GSN_STOP_ORD, &Cmvmi::execSTOP_ORD); addRecSignal(GSN_START_ORD, &Cmvmi::execSTART_ORD); addRecSignal(GSN_EVENT_SUBSCRIBE_REQ, @@ -828,160 +825,6 @@ void Cmvmi::execTAMPER_ORD(Signal* signal) }//execTAMPER_ORD() - - -void Cmvmi::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - jamEntry(); - switch (var) { - - // NDBCNTR_REF - - // DBTC - case TransactionDeadlockDetectionTimeout: - case TransactionInactiveTime: - case NoOfConcurrentProcessesHandleTakeover: - sendSignal(DBTC_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // DBDIH - case TimeBetweenLocalCheckpoints: - case TimeBetweenGlobalCheckpoints: - sendSignal(DBDIH_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // DBLQH - case NoOfConcurrentCheckpointsDuringRestart: - case NoOfConcurrentCheckpointsAfterRestart: - sendSignal(DBLQH_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // DBACC - case NoOfDiskPagesToDiskDuringRestartACC: - case NoOfDiskPagesToDiskAfterRestartACC: - sendSignal(DBACC_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // DBTUP - case NoOfDiskPagesToDiskDuringRestartTUP: - case NoOfDiskPagesToDiskAfterRestartTUP: - sendSignal(DBTUP_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // DBDICT - - // NDBCNTR - case TimeToWaitAlive: - - // QMGR - case HeartbeatIntervalDbDb: // TODO ev till Ndbcnt också - case HeartbeatIntervalDbApi: - case ArbitTimeout: - sendSignal(QMGR_REF, GSN_SET_VAR_REQ, signal, 3, JBB); - break; - - // NDBFS - - // CMVMI - case MaxNoOfSavedMessages: - case LockPagesInMainMemory: - case TimeBetweenWatchDogCheck: - case StopOnError: - handleSET_VAR_REQ(signal); - break; - - - // Not possible to update (this could of course be handled by each block - // instead but I havn't investigated where they belong) - case Id: - case ExecuteOnComputer: - case ShmKey: - case MaxNoOfConcurrentOperations: - case MaxNoOfConcurrentTransactions: - case MemorySpaceIndexes: - case MemorySpaceTuples: - case MemoryDiskPages: - case NoOfFreeDiskClusters: - case NoOfDiskClusters: - case NoOfFragmentLogFiles: - case NoOfDiskClustersPerDiskFile: - case NoOfDiskFiles: - case MaxNoOfSavedEvents: - default: - - int mgmtSrvr = setVarReq->mgmtSrvrBlockRef(); - sendSignal(mgmtSrvr, GSN_SET_VAR_REF, signal, 0, JBB); - } // switch - -#endif -}//execSET_VAR_REQ() - - -void Cmvmi::execSET_VAR_CONF(Signal* signal) -{ - int mgmtSrvr = signal->theData[0]; - sendSignal(mgmtSrvr, GSN_SET_VAR_CONF, signal, 0, JBB); - -}//execSET_VAR_CONF() - - -void Cmvmi::execSET_VAR_REF(Signal* signal) -{ - int mgmtSrvr = signal->theData[0]; - sendSignal(mgmtSrvr, GSN_SET_VAR_REF, signal, 0, JBB); - -}//execSET_VAR_REF() - - -void Cmvmi::handleSET_VAR_REQ(Signal* signal) { -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - int val = setVarReq->value(); - - switch (var) { - case MaxNoOfSavedMessages: - theConfig.maxNoOfErrorLogs(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case LockPagesInMainMemory: - int result; - if (val == 0) { - result = NdbMem_MemUnlockAll(); - } - else { - result = NdbMem_MemLockAll(); - } - if (result == 0) { - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - } - else { - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } - break; - - case TimeBetweenWatchDogCheck: - theConfig.timeBetweenWatchDogCheck(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case StopOnError: - theConfig.stopOnError(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - return; - } // switch -#endif -} - #ifdef VM_TRACE class RefSignalTest { public: diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp index b4ed5e45490..712e70039c9 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.hpp @@ -58,16 +58,11 @@ private: void execSTOP_ORD(Signal* signal); void execSTART_ORD(Signal* signal); void execTAMPER_ORD(Signal* signal); - void execSET_VAR_REQ(Signal* signal); - void execSET_VAR_CONF(Signal* signal); - void execSET_VAR_REF(Signal* signal); void execDUMP_STATE_ORD(Signal* signal); void execEVENT_SUBSCRIBE_REQ(Signal *); void cancelSubscription(NodeId nodeId); - - void handleSET_VAR_REQ(Signal* signal); void execTESTSIG(Signal* signal); void execNODE_START_REP(Signal* signal); diff --git a/ndb/src/kernel/blocks/dbacc/Dbacc.hpp b/ndb/src/kernel/blocks/dbacc/Dbacc.hpp index 43810a08ac7..02a7e69b684 100644 --- a/ndb/src/kernel/blocks/dbacc/Dbacc.hpp +++ b/ndb/src/kernel/blocks/dbacc/Dbacc.hpp @@ -911,7 +911,6 @@ private: void execDROP_TAB_REQ(Signal* signal); void execFSREMOVECONF(Signal* signal); void execREAD_CONFIG_REQ(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execDUMP_STATE_ORD(Signal* signal); // Statement blocks diff --git a/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp b/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp index 024a32ca95c..80664e8911a 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp @@ -178,7 +178,6 @@ Dbacc::Dbacc(const class Configuration & conf): addRecSignal(GSN_DROP_TAB_REQ, &Dbacc::execDROP_TAB_REQ); addRecSignal(GSN_FSREMOVECONF, &Dbacc::execFSREMOVECONF); addRecSignal(GSN_READ_CONFIG_REQ, &Dbacc::execREAD_CONFIG_REQ, true); - addRecSignal(GSN_SET_VAR_REQ, &Dbacc::execSET_VAR_REQ); initData(); diff --git a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 40af5a52c03..37f75d82710 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -11648,33 +11648,6 @@ Dbacc::execDUMP_STATE_ORD(Signal* signal) #endif }//Dbacc::execDUMP_STATE_ORD() -void Dbacc::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - int val = setVarReq->value(); - - - switch (var) { - - case NoOfDiskPagesToDiskAfterRestartACC: - clblPagesPerTick = val; - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case NoOfDiskPagesToDiskDuringRestartACC: - // Valid only during start so value not set. - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } // switch -#endif - -}//execSET_VAR_REQ() - void Dbacc::execREAD_PSUEDO_REQ(Signal* signal){ jamEntry(); diff --git a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index e8f24876979..ba2d8a6522a 100644 --- a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -693,7 +693,6 @@ private: void execFSREADREF(Signal *); void execFSWRITECONF(Signal *); void execFSWRITEREF(Signal *); - void execSET_VAR_REQ(Signal *); void execCHECKNODEGROUPSREQ(Signal *); void execSTART_INFOREQ(Signal*); void execSTART_INFOREF(Signal*); diff --git a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp index 360f320cb74..6e456c9c841 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp @@ -216,7 +216,6 @@ Dbdih::Dbdih(const class Configuration & config): addRecSignal(GSN_FSREADREF, &Dbdih::execFSREADREF, true); addRecSignal(GSN_FSWRITECONF, &Dbdih::execFSWRITECONF); addRecSignal(GSN_FSWRITEREF, &Dbdih::execFSWRITEREF, true); - addRecSignal(GSN_SET_VAR_REQ, &Dbdih::execSET_VAR_REQ); addRecSignal(GSN_START_INFOREQ, &Dbdih::execSTART_INFOREQ); diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 5ee3ac8d67d..6839dca892f 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -14026,30 +14026,6 @@ Dbdih::execNDB_TAMPER(Signal* signal) return; }//Dbdih::execNDB_TAMPER() -void Dbdih::execSET_VAR_REQ(Signal* signal) { -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - int val = setVarReq->value(); - - - switch (var) { - case TimeBetweenLocalCheckpoints: - c_lcpState.clcpDelay = val; - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case TimeBetweenGlobalCheckpoints: - cgcpDelay = val; - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } // switch -#endif -} - void Dbdih::execBLOCK_COMMIT_ORD(Signal* signal){ BlockCommitOrd* const block = (BlockCommitOrd *)&signal->theData[0]; diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 817832bdfcb..40eb6a9c668 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -2201,7 +2201,6 @@ private: void execFSREADCONF(Signal* signal); void execFSREADREF(Signal* signal); void execSCAN_HBREP(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execTIME_SIGNAL(Signal* signal); void execFSSYNCCONF(Signal* signal); diff --git a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 0b395e250c1..3452269be51 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -314,7 +314,6 @@ Dblqh::Dblqh(const class Configuration & conf): addRecSignal(GSN_FSREADCONF, &Dblqh::execFSREADCONF); addRecSignal(GSN_FSREADREF, &Dblqh::execFSREADREF, true); addRecSignal(GSN_ACC_ABORTCONF, &Dblqh::execACC_ABORTCONF); - addRecSignal(GSN_SET_VAR_REQ, &Dblqh::execSET_VAR_REQ); addRecSignal(GSN_TIME_SIGNAL, &Dblqh::execTIME_SIGNAL); addRecSignal(GSN_FSSYNCCONF, &Dblqh::execFSSYNCCONF); addRecSignal(GSN_REMOVE_MARKER_ORD, &Dblqh::execREMOVE_MARKER_ORD); diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 6a439b24c03..7e920b2e7e4 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -18902,30 +18902,6 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal) }//Dblqh::execDUMP_STATE_ORD() -void Dblqh::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - - switch (var) { - - case NoOfConcurrentCheckpointsAfterRestart: - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case NoOfConcurrentCheckpointsDuringRestart: - // Valid only during start so value not set. - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } // switch -#endif -}//execSET_VAR_REQ() - - /* **************************************************************** */ /* ---------------------------------------------------------------- */ /* ---------------------- TRIGGER HANDLING ------------------------ */ diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index d6c4529bb72..514cc2183aa 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -1323,7 +1323,6 @@ private: void execTIME_SIGNAL(Signal* signal); void execAPI_FAILREQ(Signal* signal); void execSCAN_HBREP(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execABORT_ALL_REQ(Signal* signal); diff --git a/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp b/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp index 0b46f598a89..73149f0b6fd 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp @@ -256,7 +256,6 @@ Dbtc::Dbtc(const class Configuration & conf): addRecSignal(GSN_INCL_NODEREQ, &Dbtc::execINCL_NODEREQ); addRecSignal(GSN_TIME_SIGNAL, &Dbtc::execTIME_SIGNAL); addRecSignal(GSN_API_FAILREQ, &Dbtc::execAPI_FAILREQ); - addRecSignal(GSN_SET_VAR_REQ, &Dbtc::execSET_VAR_REQ); addRecSignal(GSN_TC_COMMIT_ACK, &Dbtc::execTC_COMMIT_ACK); addRecSignal(GSN_ABORT_ALL_REQ, &Dbtc::execABORT_ALL_REQ); diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 2b2e0e649a4..2afa077b672 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -10999,36 +10999,6 @@ Dbtc::execDUMP_STATE_ORD(Signal* signal) } }//Dbtc::execDUMP_STATE_ORD() -void Dbtc::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - int val = setVarReq->value(); - - - switch (var) { - - case TransactionInactiveTime: - jam(); - set_appl_timeout_value(val); - break; - case TransactionDeadlockDetectionTimeout: - set_timeout_value(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case NoOfConcurrentProcessesHandleTakeover: - set_no_parallel_takeover(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } // switch -#endif -} - void Dbtc::execABORT_ALL_REQ(Signal* signal) { jamEntry(); diff --git a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 3079a530807..c78e7d9bced 100644 --- a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -1116,7 +1116,6 @@ private: void execFSREADCONF(Signal* signal); void execNDB_STTOR(Signal* signal); void execREAD_CONFIG_REQ(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execDROP_TAB_REQ(Signal* signal); void execALTER_TAB_REQ(Signal* signal); void execFSREMOVECONF(Signal* signal); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index f21f2eba9fc..0f83c45077b 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -103,7 +103,6 @@ Dbtup::Dbtup(const class Configuration & conf) addRecSignal(GSN_FSREADCONF, &Dbtup::execFSREADCONF); addRecSignal(GSN_NDB_STTOR, &Dbtup::execNDB_STTOR); addRecSignal(GSN_READ_CONFIG_REQ, &Dbtup::execREAD_CONFIG_REQ, true); - addRecSignal(GSN_SET_VAR_REQ, &Dbtup::execSET_VAR_REQ); // Trigger Signals addRecSignal(GSN_CREATE_TRIG_REQ, &Dbtup::execCREATE_TRIG_REQ); @@ -1315,32 +1314,5 @@ void Dbtup::seizePendingFileOpenInfoRecord(PendingFileOpenInfoPtr& pfoiPtr) pfoiPtr.p->pfoNextRec = RNIL; }//Dbtup::seizePendingFileOpenInfoRecord() -void Dbtup::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)signal->getDataPtrSend(); - ConfigParamId var = setVarReq->variable(); - int val = setVarReq->value(); - - switch (var) { - - case NoOfDiskPagesToDiskAfterRestartTUP: - clblPagesPerTick = val; - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case NoOfDiskPagesToDiskDuringRestartTUP: - // Valid only during start so value not set. - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - } // switch -#endif - -}//execSET_VAR_REQ() - - diff --git a/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp b/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp index ec9d4a0dc60..80b0b29ea69 100644 --- a/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp +++ b/ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp @@ -190,7 +190,6 @@ private: void execNDB_STARTCONF(Signal* signal); void execREAD_NODESREQ(Signal* signal); void execNDB_STARTREF(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execSTOP_PERM_REF(Signal* signal); void execSTOP_PERM_CONF(Signal* signal); diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp index 6df52b6fbe7..fdd6e7677d3 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp @@ -80,7 +80,6 @@ Ndbcntr::Ndbcntr(const class Configuration & conf): addRecSignal(GSN_NDB_STARTCONF, &Ndbcntr::execNDB_STARTCONF); addRecSignal(GSN_READ_NODESREQ, &Ndbcntr::execREAD_NODESREQ); addRecSignal(GSN_NDB_STARTREF, &Ndbcntr::execNDB_STARTREF); - addRecSignal(GSN_SET_VAR_REQ, &Ndbcntr::execSET_VAR_REQ); addRecSignal(GSN_STOP_PERM_REF, &Ndbcntr::execSTOP_PERM_REF); addRecSignal(GSN_STOP_PERM_CONF, &Ndbcntr::execSTOP_PERM_CONF); diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 26e8f246293..87b71ba1c5f 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -2026,23 +2026,6 @@ Ndbcntr::execDUMP_STATE_ORD(Signal* signal) }//Ndbcntr::execDUMP_STATE_ORD() -void Ndbcntr::execSET_VAR_REQ(Signal* signal) { -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - - switch (var) { - case TimeToWaitAlive: - // Valid only during start so value not set. - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - }// switch -#endif -}//Ndbcntr::execSET_VAR_REQ() - void Ndbcntr::updateNodeState(Signal* signal, const NodeState& newState) const{ NodeStateRep * const stateRep = (NodeStateRep *)&signal->theData[0]; diff --git a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp index dcca240eeb6..9d2ac80d905 100644 --- a/ndb/src/kernel/blocks/qmgr/Qmgr.hpp +++ b/ndb/src/kernel/blocks/qmgr/Qmgr.hpp @@ -242,7 +242,6 @@ private: void execAPI_REGREQ(Signal* signal); void execAPI_FAILCONF(Signal* signal); void execREAD_NODESREQ(Signal* signal); - void execSET_VAR_REQ(Signal* signal); void execREAD_NODESREF(Signal* signal); void execREAD_NODESCONF(Signal* signal); diff --git a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp index b8885569f0e..a087fe38c1c 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp @@ -82,7 +82,6 @@ Qmgr::Qmgr(const class Configuration & conf) addRecSignal(GSN_DISCONNECT_REP, &Qmgr::execDISCONNECT_REP); addRecSignal(GSN_API_FAILCONF, &Qmgr::execAPI_FAILCONF); addRecSignal(GSN_READ_NODESREQ, &Qmgr::execREAD_NODESREQ); - addRecSignal(GSN_SET_VAR_REQ, &Qmgr::execSET_VAR_REQ); addRecSignal(GSN_API_BROADCAST_REP, &Qmgr::execAPI_BROADCAST_REP); // Arbitration signals diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 0156f334051..c992ebe6cb9 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -4774,34 +4774,6 @@ Qmgr::execDUMP_STATE_ORD(Signal* signal) #endif }//Qmgr::execDUMP_STATE_ORD() -void Qmgr::execSET_VAR_REQ(Signal* signal) -{ -#if 0 - SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0]; - ConfigParamId var = setVarReq->variable(); - UintR val = setVarReq->value(); - - switch (var) { - case HeartbeatIntervalDbDb: - setHbDelay(val/10); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case HeartbeatIntervalDbApi: - setHbApiDelay(val/10); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - case ArbitTimeout: - setArbitTimeout(val); - sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB); - break; - - default: - sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB); - }// switch -#endif -}//execSET_VAR_REQ() void Qmgr::execAPI_BROADCAST_REP(Signal* signal) diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 59f1487f7dc..62d2efd5b16 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -597,7 +597,6 @@ private: */ enum WaitSignalType { NO_WAIT, // We don't expect to receive any signal - WAIT_SET_VAR, // Accept SET_VAR_CONF and SET_VAR_REF WAIT_SUBSCRIBE_CONF // Accept event subscription confirmation }; From 5a25c67a59b1e80fba4a0487508c899e6ae88d8f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:16:26 +0700 Subject: [PATCH 29/78] Bug #21033 Error 0 in readAutoIncrementValue() - do not call function if table has no autoincrement --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 30be53f1ddb..3d0d8a3f079 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3245,7 +3245,7 @@ int ha_ndbcluster::info(uint flag) if (flag & HA_STATUS_AUTO) { DBUG_PRINT("info", ("HA_STATUS_AUTO")); - if (m_table) + if (m_table && table->found_next_number_field) { Ndb *ndb= get_ndb(); From ddc31bc9db705328ccad16d14cf4a90fc54fc098 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:26:06 +0700 Subject: [PATCH 30/78] backport some mysql-test ndbcluster things from 5.1 remove compiler warning EventLogger.cpp Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11 - partial fix - object map to handle failed realloc mysql-test/ndb/ndb_config_2_node.ini: backport some mysql-test ndbcluster things from 5.1 mysql-test/ndb/ndbcluster.sh: backport some mysql-test ndbcluster things from 5.1 ndb/src/common/debugger/EventLogger.cpp: remove compiler warning ndb/src/ndbapi/ObjectMap.hpp: Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11 - partial fix - object map to handle failed realloc --- mysql-test/ndb/ndb_config_2_node.ini | 10 +++ mysql-test/ndb/ndbcluster.sh | 97 +++++++++++++++++-------- ndb/src/common/debugger/EventLogger.cpp | 4 +- ndb/src/ndbapi/ObjectMap.hpp | 13 ++-- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/mysql-test/ndb/ndb_config_2_node.ini b/mysql-test/ndb/ndb_config_2_node.ini index a6a56376f33..aafed28dbc6 100644 --- a/mysql-test/ndb/ndb_config_2_node.ini +++ b/mysql-test/ndb/ndb_config_2_node.ini @@ -1,5 +1,6 @@ [ndbd default] NoOfReplicas= 2 +MaxNoOfConcurrentTransactions= 64 MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations DataMemory= CHOOSE_DataMemory IndexMemory= CHOOSE_IndexMemory @@ -7,6 +8,15 @@ Diskless= CHOOSE_Diskless TimeBetweenWatchDogCheck= 30000 DataDir= CHOOSE_FILESYSTEM MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes +MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes +TimeBetweenGlobalCheckpoints= 500 +NoOfFragmentLogFiles= 3 + +# +# Increase deadlock-timeout to cater for slow test-machines +# (possibly running several tests in parallell) +# +#TransactionDeadlockDetectionTimeout= 7500 [ndbd] HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index c53bf1306e6..be08781361e 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -63,12 +63,17 @@ stop_ndb= initial_ndb= status_ndb= ndb_diskless=0 +ndbd_nodes=2 +relative_config_data_dir= +opt_core= ndb_no_ord=512 +ndb_no_attr=2048 ndb_con_op=105000 ndb_dmem=80M ndb_imem=24M +VERBOSE=100 NDB_MGM_EXTRA_OPTS= NDB_MGMD_EXTRA_OPTS= NDBD_EXTRA_OPTS= @@ -89,6 +94,9 @@ while test $# -gt 0; do --debug*) flags_ndb="$flags_ndb $1" ;; + --ndbd-nodes=*) + ndbd_nodes=`echo "$1" | sed -e "s;--ndbd-nodes=;;"` + ;; --status) status_ndb=1 ;; @@ -104,6 +112,9 @@ while test $# -gt 0; do --data-dir=*) fsdir=`echo "$1" | sed -e "s;--data-dir=;;"` ;; + --relative-config-data-dir) + relative_config_data_dir=1 + ;; --port=*) port=`echo "$1" | sed -e "s;--port=;;"` ;; @@ -122,6 +133,12 @@ while test $# -gt 0; do --character-sets-dir=*) CHARSETSDIR=`echo "$1" | sed -e "s;--character-sets-dir=;;"` ;; + --core) + opt_core="--core" + ;; + --verbose=*) + VERBOSE=`echo "$1" | sed -e "s;--verbose=;;"` + ;; -- ) shift; break ;; --* ) $ECHO "Unrecognized option: $1"; exit 1 ;; * ) break ;; @@ -130,9 +147,10 @@ while test $# -gt 0; do done fs_ndb="$fsdir/ndbcluster-$port" +config_ini=ndb/ndb_config_${ndbd_nodes}_node.ini NDB_HOME= -if [ ! -x "$fsdir" ]; then +if [ ! -d "$fsdir" ]; then echo "$fsdir missing" exit 1 fi @@ -148,11 +166,15 @@ if [ ! -x "$exec_waiter" ]; then echo "$exec_waiter missing" exit 1 fi +if [ ! -f "$config_ini" ]; then + echo "$config_ini missing, unsupported number of nodes" + exit 1 +fi -exec_mgmtclient="$exec_mgmtclient --no-defaults $NDB_MGM_EXTRA_OPTS" -exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $NDB_MGMD_EXTRA_OPTS" -exec_ndb="$exec_ndb --no-defaults $NDBD_EXTRA_OPTS --character-sets-dir=$CHARSETSDIR" -exec_waiter="$exec_waiter --no-defaults" +exec_mgmtclient="$exec_mgmtclient --no-defaults $opt_core $NDB_MGM_EXTRA_OPTS" +exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $opt_core $NDB_MGMD_EXTRA_OPTS" +exec_ndb="$exec_ndb --no-defaults $opt_core $NDBD_EXTRA_OPTS --character-sets-dir=$CHARSETSDIR" +exec_waiter="$exec_waiter --no-defaults $opt_core" ndb_host="localhost" ndb_mgmd_port=$port @@ -196,18 +218,24 @@ fi # Start management server as deamon # Edit file system path and ports in config file +if [ $relative_config_data_dir ] ; then + config_fs_ndb="." +else + config_fs_ndb=$fs_ndb +fi if [ $initial_ndb ] ; then - rm -f $fs_ndb/ndb_* 2>&1 | cat > /dev/null + rm -rf $fs_ndb/ndb_* 2>&1 | cat > /dev/null sed \ + -e s,"CHOOSE_MaxNoOfAttributes","$ndb_no_attr",g \ -e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \ -e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \ -e s,"CHOOSE_DataMemory","$ndb_dmem",g \ -e s,"CHOOSE_IndexMemory","$ndb_imem",g \ -e s,"CHOOSE_Diskless","$ndb_diskless",g \ -e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \ - -e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \ + -e s,"CHOOSE_FILESYSTEM","$config_fs_ndb",g \ -e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \ - < ndb/ndb_config_2_node.ini \ + < "$config_ini" \ > "$fs_ndb/config.ini" fi @@ -218,7 +246,7 @@ if ( cd "$fs_ndb" ; $exec_mgmtsrvr -f config.ini ) ; then :; else echo "Unable to start $exec_mgmtsrvr from `pwd`" exit 1 fi -if sleep_until_file_created $fs_ndb/ndb_3.pid 120 +if sleep_until_file_created $fs_ndb/ndb_`expr $ndbd_nodes + 1`.pid 120 then :; else exit 1 fi @@ -226,38 +254,43 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" # Start database node -echo "Starting ndbd" -( cd "$fs_ndb" ; $exec_ndb $flags_ndb & ) -if sleep_until_file_created $fs_ndb/ndb_1.pid 120 -then :; else - stop_default_ndbcluster - exit 1 -fi -cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" - -# Start database node - -echo "Starting ndbd" -( cd "$fs_ndb" ; $exec_ndb $flags_ndb & ) -if sleep_until_file_created $fs_ndb/ndb_2.pid 120 -then :; else - stop_default_ndbcluster - exit 1 -fi -cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" +id=1 +while [ $id -le $ndbd_nodes ] +do + if [ `expr $VERBOSE \> 1` = 1 ] ; then + echo "Starting ndbd $id($ndbd_nodes)" + fi + ( cd "$fs_ndb" ; $exec_ndb $flags_ndb & ) + if sleep_until_file_created $fs_ndb/ndb_${id}.pid 120 + then :; else + stop_default_ndbcluster + exit 1 + fi + cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" + id=`expr $id + 1` +done # test if Ndb Cluster starts properly -echo "Waiting for NDB data nodes to start..." -if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK" > /dev/null 2>&1; then :; else - echo "Ndbcluster startup failed" +if [ `expr $VERBOSE \> 1` = 1 ] ; then + echo "Waiting for NDB data nodes to start..." +fi +if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK" > /dev/null 2>&1 ; then :; else + if [ `expr $VERBOSE \> 0` = 1 ] ; then + echo "Ndbcluster startup failed" + fi stop_default_ndbcluster exit 1 fi +if [ `expr $VERBOSE \> 1` = 1 ] ; then + echo "Ok" +fi cat `find "$fs_ndb" -name 'ndb_*.pid'` > $fs_ndb/$pidfile -status_ndbcluster +if [ `expr $VERBOSE \> 2` = 1 ] ; then + status_ndbcluster +fi } status_ndbcluster() { diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 39daa3effe8..535158fb7d1 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -530,8 +530,8 @@ void getTextUndoLogBlocked(QQQQ) { } void getTextTransporterError(QQQQ) { struct myTransporterError{ - int errorNum; - char errorString[256]; + Uint32 errorNum; + char errorString[256]; }; int i = 0; int lenth = 0; diff --git a/ndb/src/ndbapi/ObjectMap.hpp b/ndb/src/ndbapi/ObjectMap.hpp index 486ef08abb8..0e0c9668164 100644 --- a/ndb/src/ndbapi/ObjectMap.hpp +++ b/ndb/src/ndbapi/ObjectMap.hpp @@ -46,7 +46,7 @@ private: } * m_map; NdbMutex * m_mutex; - void expand(Uint32 newSize); + int expand(Uint32 newSize); }; inline @@ -73,9 +73,8 @@ NdbObjectIdMap::map(void * object){ // lock(); - if(m_firstFree == InvalidId){ - expand(m_expandSize); - } + if(m_firstFree == InvalidId && expand(m_expandSize)) + return InvalidId; Uint32 ff = m_firstFree; m_firstFree = m_map[ff].m_next; @@ -130,7 +129,7 @@ NdbObjectIdMap::getObject(Uint32 id){ return 0; } -inline void +inline int NdbObjectIdMap::expand(Uint32 incSize){ NdbMutex_Lock(m_mutex); Uint32 newSize = m_size + incSize; @@ -149,9 +148,11 @@ NdbObjectIdMap::expand(Uint32 incSize){ } else { - ndbout_c("NdbObjectIdMap::expand unable to expand!!"); + NdbMutex_Unlock(m_mutex); + return -1; } NdbMutex_Unlock(m_mutex); + return 0; } #endif From 69377dd20797fee8b2e4f5c5769d5e09319bd9c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 15:33:48 +0700 Subject: [PATCH 31/78] ndb_config_4_node.ini, ndb_config_1_node.ini: new file --- mysql-test/ndb/ndb_config_1_node.ini | 43 +++++++++++++++++++++++ mysql-test/ndb/ndb_config_4_node.ini | 52 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 mysql-test/ndb/ndb_config_1_node.ini create mode 100644 mysql-test/ndb/ndb_config_4_node.ini diff --git a/mysql-test/ndb/ndb_config_1_node.ini b/mysql-test/ndb/ndb_config_1_node.ini new file mode 100644 index 00000000000..7b0d2829530 --- /dev/null +++ b/mysql-test/ndb/ndb_config_1_node.ini @@ -0,0 +1,43 @@ +[ndbd default] +NoOfReplicas= 1 +MaxNoOfConcurrentTransactions= 64 +MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations +DataMemory= CHOOSE_DataMemory +IndexMemory= CHOOSE_IndexMemory +Diskless= CHOOSE_Diskless +TimeBetweenWatchDogCheck= 30000 +DataDir= CHOOSE_FILESYSTEM +MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes +MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes +TimeBetweenGlobalCheckpoints= 500 +NoOfFragmentLogFiles= 3 + +# +# Increase deadlock-timeout to cater for slow test-machines +# (possibly running several tests in parallell) +# +#TransactionDeadlockDetectionTimeout= 7500 + +[ndbd] +HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress + +[ndb_mgmd] +HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress +DataDir= CHOOSE_FILESYSTEM # +PortNumber= CHOOSE_PORT_MGM + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] diff --git a/mysql-test/ndb/ndb_config_4_node.ini b/mysql-test/ndb/ndb_config_4_node.ini new file mode 100644 index 00000000000..2154475aa37 --- /dev/null +++ b/mysql-test/ndb/ndb_config_4_node.ini @@ -0,0 +1,52 @@ +[ndbd default] +NoOfReplicas= 2 +MaxNoOfConcurrentTransactions= 64 +MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations +DataMemory= CHOOSE_DataMemory +IndexMemory= CHOOSE_IndexMemory +Diskless= CHOOSE_Diskless +TimeBetweenWatchDogCheck= 30000 +DataDir= CHOOSE_FILESYSTEM +MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes +MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes +TimeBetweenGlobalCheckpoints= 500 +NoOfFragmentLogFiles= 3 + +# +# Increase deadlock-timeout to cater for slow test-machines +# (possibly running several tests in parallell) +# +#TransactionDeadlockDetectionTimeout= 7500 + +[ndbd] +HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress + +[ndbd] +HostName= CHOOSE_HOSTNAME_2 # hostname is a valid network adress + +[ndbd] +HostName= CHOOSE_HOSTNAME_3 # hostname is a valid network adress + +[ndbd] +HostName= CHOOSE_HOSTNAME_4 # hostname is a valid network adress + +[ndb_mgmd] +HostName= CHOOSE_HOSTNAME_1 # hostname is a valid network adress +DataDir= CHOOSE_FILESYSTEM # +PortNumber= CHOOSE_PORT_MGM + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] + +[mysqld] From 6c8b5256c61653d315de5d7f91f2bfd1f2503c54 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 18:35:59 +0200 Subject: [PATCH 32/78] Bug#19717: The blackhole engine is returning an OK flag in index_read(), whereas it must return HA_ERR_END_OF_FILE instead (as there are by definition no rows in a table of that engine. mysql-test/r/blackhole.result: Bug#19717: test case mysql-test/t/blackhole.test: Bug#19717: test case sql/ha_blackhole.cc: Bug#19717: return no rows instead of success. --- mysql-test/r/blackhole.result | 11 +++++++++++ mysql-test/t/blackhole.test | 15 +++++++++++++++ sql/ha_blackhole.cc | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/blackhole.result b/mysql-test/r/blackhole.result index 140d7e73d48..0ee5f326e0f 100644 --- a/mysql-test/r/blackhole.result +++ b/mysql-test/r/blackhole.result @@ -123,3 +123,14 @@ master-bin.000001 # Query 1 # use `test`; create table t3 like t1 master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t3 master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3 drop table t1,t2,t3; +CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 ADD INDEX(a); +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD UNIQUE INDEX(a); +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD PRIMARY KEY(a); +DELETE FROM t1 WHERE a=10; +DROP TABLE t1; diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index e40b84eb5cd..4bafad2d777 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -127,4 +127,19 @@ show binlog events; drop table t1,t2,t3; +# +#Bug#19717: DELETE Query Error on BLACKHOLE when using WHERE on column with UNIQUE INDEX +# +CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 ADD INDEX(a); +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD UNIQUE INDEX(a); +DELETE FROM t1 WHERE a=10; +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD PRIMARY KEY(a); +DELETE FROM t1 WHERE a=10; +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 61a8658be53..3f4285ec595 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -180,7 +180,7 @@ int ha_blackhole::index_read(byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag) { DBUG_ENTER("ha_blackhole::index_read"); - DBUG_RETURN(0); + DBUG_RETURN(HA_ERR_END_OF_FILE); } From 6ae94723ca07c0938d25105d6180c96bc6abeaae Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 22:06:41 -0800 Subject: [PATCH 33/78] Fixed bug #25971: indexes on text columns were ignored when ref accesses were evaluated. According to the new rules for string comparison partial indexes on text columns can be used in the same cases when partial indexes on varchar columns can be used. mysql-test/r/endspace.result: Adjusted results after the fix for bug #25971. mysql-test/r/innodb.result: Adjusted results after the fix for bug #25971. mysql-test/r/myisam.result: Adjusted results after the fix for bug #25971. mysql-test/r/select.result: Added a test case for bug #25971. mysql-test/r/type_blob.result: Adjusted results after the fix for bug #25971. mysql-test/t/select.test: Added a test case for bug #25971. --- mysql-test/r/endspace.result | 2 +- mysql-test/r/innodb.result | 2 +- mysql-test/r/myisam.result | 2 +- mysql-test/r/select.result | 148 ++++++++++++++++++++++++++++++++++ mysql-test/r/type_blob.result | 4 +- mysql-test/t/select.test | 46 +++++++++++ sql/sql_select.cc | 8 +- 7 files changed, 200 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/endspace.result b/mysql-test/r/endspace.result index 0e68418a80f..003ee7ffd5e 100644 --- a/mysql-test/r/endspace.result +++ b/mysql-test/r/endspace.result @@ -98,7 +98,7 @@ concat('|', text1, '|') |teststring | explain select concat('|', text1, '|') from t1 where text1='teststring '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range key1 key1 22 NULL 2 Using where +1 SIMPLE t1 ref key1 key1 22 const 2 Using where select concat('|', text1, '|') from t1 where text1 like 'teststring_%'; concat('|', text1, '|') |teststring | diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 38d71ac7a42..496c8aa90d2 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1991,7 +1991,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c c 11 const # Using where; Using index explain select count(*) from t1 where t='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t t 13 NULL # Using where +1 SIMPLE t1 ref t t 13 const # Using where explain select count(*) from t1 where v like 'a%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range v v 13 NULL # Using where; Using index diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 0f6e0ad537a..83359048a8c 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1071,7 +1071,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c c 11 const # Using where; Using index explain select count(*) from t1 where t='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t t 13 NULL # Using where +1 SIMPLE t1 ref t t 13 const # Using where explain select count(*) from t1 where v like 'a%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range v v 13 NULL # Using where; Using index diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index f50f4859d48..c3132a1b5f6 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3785,4 +3785,152 @@ case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co; i c co 1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)); +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref name name 6 const 3 Using where +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref name name 6 test.t1.name 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +ccc NULL NULL +bb bb 1 +bb bb 6 +cc cc 3 +cc cc 5 +cc cc 7 +aa aa 2 +aa aa 2 +DROP TABLE t1,t2; +CREATE TABLE t1 (name text); +CREATE TABLE t2 (name text, n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref name name 6 const 3 Using where +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref name name 6 test.t1.name 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +ccc NULL NULL +bb bb 1 +bb bb 6 +cc cc 3 +cc cc 5 +cc cc 7 +aa aa 2 +aa aa 2 +DROP TABLE t1,t2; End of 5.0 tests diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 73b67a2241e..b28f404c641 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -610,12 +610,12 @@ create table t1 (id integer primary key auto_increment, txt text, index txt_inde insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL); select * from t1 where txt='Chevy' or txt is NULL; id txt -3 NULL 1 Chevy 2 Chevy +3 NULL explain select * from t1 where txt='Chevy' or txt is NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range txt_index txt_index 23 NULL 2 Using where +1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where select * from t1 where txt='Chevy '; id txt 1 Chevy diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index c4737814137..ea5fadb2e1b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3253,4 +3253,50 @@ select case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co; +# +# Bug #22971: indexes on text columns are ignored for ref accesses +# + +CREATE TABLE t1 (name varchar(255)); +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +SELECT * FROM t2 ORDER BY name; +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; + +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; + +DROP TABLE t1,t2; + +CREATE TABLE t1 (name text); +CREATE TABLE t2 (name text, n int, KEY (name(3))); +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +SELECT * FROM t2; +SELECT * FROM t2 ORDER BY name; +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; + +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; + +DROP TABLE t1,t2; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ed108828909..93f5092fd60 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2854,15 +2854,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond, /* We can't use indexes if the effective collation of the operation differ from the field collation. - - We also cannot use index on a text column, as the column may - contain 'x' 'x\t' 'x ' and 'read_next_same' will stop after - 'x' when searching for WHERE col='x ' */ if (field->cmp_type() == STRING_RESULT && - (((Field_str*)field)->charset() != cond->compare_collation() || - ((*value)->type() != Item::NULL_ITEM && - (field->flags & BLOB_FLAG) && !field->binary()))) + ((Field_str*)field)->charset() != cond->compare_collation()) return; } } From f6834c02ca00ba2e07bebb61efa4eec4afad67ca Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Feb 2007 15:39:03 +0100 Subject: [PATCH 34/78] Fix for BUG#25507 "multi-row insert delayed + auto increment causes duplicate key entries on slave" (two concurrrent connections doing multi-row INSERT DELAYED to insert into an auto_increment column, caused replication slave to stop with "duplicate key error" (and binlog was wrong)), and BUG#26116 "If multi-row INSERT DELAYED has errors, statement-based binlogging breaks" (the binlog was not accounting for all rows inserted, or slave could stop). The fix is that: if (statement-based) binlogging is on, a multi-row INSERT DELAYED is silently converted to a non-delayed INSERT. Note: it is not possible to test BUG#25507 in 5.0 (requires mysqlslap), so it is tested only in the changeset for 5.1. However, BUG#26116 is tested here, and the fix for BUG#25507 is the same code change. mysql-test/r/innodb-replace.result: result update mysql-test/t/innodb-replace.test: now that multi-row delayed inserts are converted to normal inserts if the statement-based binlog is enabled, no error is issued even if this engine does not support INSERT DELAYED, as the insert does not go through the INSERT DELAYED code. To preserve the goal of this test, we change the statements to single- row inserts. sql/sql_insert.cc: A multi-row INSERT DELAYED cannot be recorded to a statement-based binlog in a way that describes the insertions actually done; in that case we fallback to a non-delayed INSERT. mysql-test/r/rpl_insert_delayed.result: result. Master and slave match. mysql-test/t/rpl_insert_delayed.test: Test for BUG#26116 (see if one error at first row on master makes the slave's data incorrect, see if one error at second row on master makes slave stop). --- mysql-test/r/innodb-replace.result | 4 +- mysql-test/r/rpl_insert_delayed.result | 31 ++++++++++++ mysql-test/t/innodb-replace.test | 4 +- mysql-test/t/rpl_insert_delayed.test | 67 ++++++++++++++++++++++++++ sql/sql_insert.cc | 21 ++++++++ 5 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/rpl_insert_delayed.result create mode 100644 mysql-test/t/rpl_insert_delayed.test diff --git a/mysql-test/r/innodb-replace.result b/mysql-test/r/innodb-replace.result index b7edcc49e56..77e0aeb38fd 100644 --- a/mysql-test/r/innodb-replace.result +++ b/mysql-test/r/innodb-replace.result @@ -2,11 +2,11 @@ drop table if exists t1; create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; select * from t1; c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +replace delayed into t1 (c1, c2) values ( "text1","11"); ERROR HY000: Table storage engine for 't1' doesn't have this option select * from t1; c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +replace delayed into t1 (c1, c2) values ( "text1","12"); ERROR HY000: Table storage engine for 't1' doesn't have this option select * from t1; c1 c2 stamp diff --git a/mysql-test/r/rpl_insert_delayed.result b/mysql-test/r/rpl_insert_delayed.result new file mode 100644 index 00000000000..38e2cddd650 --- /dev/null +++ b/mysql-test/r/rpl_insert_delayed.result @@ -0,0 +1,31 @@ +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; +CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); +truncate table t1; +insert delayed into t1 values(10, "my name"); +insert delayed into t1 values(10, "is Bond"), (20, "James Bond"); +ERROR 23000: Duplicate entry '10' for key 1 +flush table t1; +select * from t1; +id name +10 my name +select * from t1; +id name +10 my name +delete from t1 where id!=10; +insert delayed into t1 values(20, "is Bond"), (10, "James Bond"); +ERROR 23000: Duplicate entry '10' for key 1 +flush table t1; +select * from t1; +id name +10 my name +20 is Bond +select * from t1; +id name +10 my name +20 is Bond +drop table t1; diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test index 51b70f34b65..d44ede65ce8 100644 --- a/mysql-test/t/innodb-replace.test +++ b/mysql-test/t/innodb-replace.test @@ -12,10 +12,10 @@ drop table if exists t1; create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; select * from t1; --error 1031 -replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +replace delayed into t1 (c1, c2) values ( "text1","11"); select * from t1; --error 1031 -replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +replace delayed into t1 (c1, c2) values ( "text1","12"); select * from t1; drop table t1; diff --git a/mysql-test/t/rpl_insert_delayed.test b/mysql-test/t/rpl_insert_delayed.test new file mode 100644 index 00000000000..3f72f3a3625 --- /dev/null +++ b/mysql-test/t/rpl_insert_delayed.test @@ -0,0 +1,67 @@ +--source include/master-slave.inc +--source include/not_embedded.inc +--source include/not_windows.inc + +connection master; + +let $binlog_format_statement=1; + +CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); + +sync_slave_with_master; + +# +# BUG#26116 "If multi-row INSERT DELAYED has errors, +# statement-based binlogging breaks"; +# happened only in statement-based binlogging. +# + +connection master; +truncate table t1; +# first scenario: duplicate on first row +insert delayed into t1 values(10, "my name"); +if ($binlog_format_statement) +{ + # statement below will be converted to non-delayed INSERT and so + # will stop at first error, guaranteeing replication. + --error ER_DUP_ENTRY + insert delayed into t1 values(10, "is Bond"), (20, "James Bond"); +} +if (!$binlog_format_statement) +{ + insert delayed into t1 values(10, "is Bond"), (20, "James Bond"); +} +flush table t1; # to wait for INSERT DELAYED to be done +select * from t1; +sync_slave_with_master; +# when bug existed in statement-based binlogging, t1 on slave had +# different content from on master +select * from t1; + +# second scenario: duplicate on second row +connection master; +delete from t1 where id!=10; +if ($binlog_format_statement) +{ + # statement below will be converted to non-delayed INSERT and so + # will be binlogged with its ER_DUP_ENTRY error code, guaranteeing + # replication (slave will hit the same error code and so be fine). + --error ER_DUP_ENTRY + insert delayed into t1 values(20, "is Bond"), (10, "James Bond"); +} +if (!$binlog_format_statement) +{ + insert delayed into t1 values(20, "is Bond"), (10, "James Bond"); +} +flush table t1; # to wait for INSERT DELAYED to be done +select * from t1; +sync_slave_with_master; +# when bug existed in statement-based binlogging, query was binlogged +# with error_code=0 so slave stopped +select * from t1; + +# clean up +connection master; +drop table t1; +sync_slave_with_master; +connection master; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c5f1524c556..f0708ee548a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -356,6 +356,27 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, (duplic == DUP_UPDATE)) lock_type=TL_WRITE; #endif + if ((lock_type == TL_WRITE_DELAYED) && + log_on && mysql_bin_log.is_open() && + (values_list.elements > 1)) + { + /* + Statement-based binary logging does not work in this case, because: + a) two concurrent statements may have their rows intermixed in the + queue, leading to autoincrement replication problems on slave (because + the values generated used for one statement don't depend only on the + value generated for the first row of this statement, so are not + replicable) + b) if first row of the statement has an error the full statement is + not binlogged, while next rows of the statement may be inserted. + c) if first row succeeds, statement is binlogged immediately with a + zero error code (i.e. "no error"), if then second row fails, query + will fail on slave too and slave will stop (wrongly believing that the + master got no error). + So we fallback to non-delayed INSERT. + */ + lock_type= TL_WRITE; + } table_list->lock_type= lock_type; #ifndef EMBEDDED_LIBRARY From 9dfb1d9011cf5b31d139d3904a0bf3afae91ad24 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Feb 2007 15:50:56 +0100 Subject: [PATCH 35/78] Backport from the Falcon tree. When opening/creating the transaction coordinator's log, if binlog is used, the tc log is the binlog so we use the binlog's name; otherwise we use the mmap-based log, named after the mandatory argument of the --log-tc option (meant for that). sql/log.cc: fixing wrong order of arguments to my_create() (3rd param is the desired modes of the file; "0" lead to no rights for anybody on the file). sql/mysqld.cc: When opening/creating the transaction coordinator's log, if binlog is used, the tc log is the binlog so we use the binlog's name; otherwise we use the mmap-based log, named after the mandatory argument of the --log-tc option (meant for that). --- sql/log.cc | 2 +- sql/mysqld.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 1961a5b6f88..aef8e2eff2c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2523,7 +2523,7 @@ int TC_LOG_MMAP::open(const char *opt_name) goto err; if (using_heuristic_recover()) return 1; - if ((fd= my_create(logname, O_RDWR, 0, MYF(MY_WME))) < 0) + if ((fd= my_create(logname, CREATE_MODE, O_RDWR, MYF(MY_WME))) < 0) goto err; inited=1; file_length= opt_tc_log_size; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d4f9791dade..672f585e721 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3171,7 +3171,7 @@ server."); (TC_LOG *) &tc_log_mmap) : (TC_LOG *) &tc_log_dummy); - if (tc_log->open(opt_bin_logname)) + if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file)) { sql_print_error("Can't init tc log"); unireg_abort(1); From 6f21a5af6bec093063e803aaf4f1cd8ca1fa618c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 16:31:31 +0100 Subject: [PATCH 36/78] include/config-win.h : Companion change to this one ChangeSet@1.2206, 2007-01-22 02:32:07+02:00, jani@a88-113-38-195.elisa-laajakaista.fi +8 -0 include/my_pthread.h@1.67, 2007-01-22 02:32:06+02:00, jani@a88-113-38-195.elisa-laajakaista.fi +31 -10 which renamed "sigset()" -> "my_sigset()" but forgot to do it for Windows ... include/config-win.h: Companion change to this one ChangeSet@1.2206, 2007-01-22 02:32:07+02:00, jani@a88-113-38-195.elisa-laajakaista.fi +8 -0 include/my_pthread.h@1.67, 2007-01-22 02:32:06+02:00, jani@a88-113-38-195.elisa-laajakaista.fi +31 -10 which renamed "sigset()" -> "my_sigset()" but forgot to do it for Windows ... --- include/config-win.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config-win.h b/include/config-win.h index 42aa23c3afe..3adb940aa4f 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -167,7 +167,7 @@ typedef uint rf_SetTimer; /* Convert some simple functions to Posix */ -#define sigset(A,B) signal((A),(B)) +#define my_sigset(A,B) signal((A),(B)) #define finite(A) _finite(A) #define sleep(A) Sleep((A)*1000) From d5813a06f67d6478fed95aa9d10c44e1c1eb1076 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 19:39:28 +0300 Subject: [PATCH 37/78] Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. If the UPDATE values of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE statement contains fields from the SELECT part and the select employs a temporary table then those fields will contain wrong values because they aren't corrected to get data from the temporary table. The solution is to add these fields to the selects all_fields list, to store pointers to those fields in the selects ref_pointer_array and to access them via Item_ref objects. The substitution for Item_ref objects is done in the new function called Item_field::update_value_transformer(). It is called through the item->transform() mechanism at the end of the select_insert::prepare() function. sql/item.cc: Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. The new method Item_field::update_value_transformer() is added. It substitutes fields in the update values list for references (Item_ref objects) to them. sql/item.h: Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. The update_value_transformer() method is added to the Item and to the Item_field classes. sql/sql_insert.cc: Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. Traverse update values and substitute fields from the select for references (Item_ref objects) to them. sql/sql_select.cc: Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. Traverse update values and substitute fields from the select for references (Item_ref objects) to them. mysql-test/r/insert_select.result: Added a test case for bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. mysql-test/t/insert_select.test: Added a test case for bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. --- mysql-test/r/insert_select.result | 13 +++++++++ mysql-test/t/insert_select.test | 15 +++++++++++ sql/item.cc | 45 +++++++++++++++++++++++++++++++ sql/item.h | 2 ++ sql/sql_insert.cc | 16 +++++++++++ sql/sql_select.cc | 6 ++--- 6 files changed, 94 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 2e0acf303c2..92b3ea0e42b 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -731,3 +731,16 @@ select @@identity; @@identity 0 drop table t1; +CREATE TABLE t1 (f1 INT, f2 INT ); +CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); +INSERT INTO t1 VALUES (1,1),(2,2),(10,10); +INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1; +INSERT INTO t2 (f1, f2) +SELECT f1, f1 FROM t2 src WHERE f1 < 2 +ON DUPLICATE KEY UPDATE f1 = 100 + src.f1; +SELECT * FROM t2; +f1 f2 +101 1 +2 2 +10 10 +DROP TABLE t1, t2; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 5c60fc8e1f0..31508b3d6c4 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -292,3 +292,18 @@ select @@identity; insert ignore t1(f2) select 1; select @@identity; drop table t1; + +# +# Bug#16630: wrong result, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE +# +CREATE TABLE t1 (f1 INT, f2 INT ); +CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); +INSERT INTO t1 VALUES (1,1),(2,2),(10,10); +INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1; +INSERT INTO t2 (f1, f2) + SELECT f1, f1 FROM t2 src WHERE f1 < 2 + ON DUPLICATE KEY UPDATE f1 = 100 + src.f1; +SELECT * FROM t2; +DROP TABLE t1, t2; + + diff --git a/sql/item.cc b/sql/item.cc index 95001809e9a..23193e0990c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4809,6 +4809,51 @@ void Item_field::update_null_value() } +/* + Add the field to the select list and substitute it for the reference to + the field. + + SYNOPSIS + Item_field::update_value_transformer() + select_arg current select + + DESCRIPTION + If the field doesn't belong to the table being inserted into then it is + added to the select list, pointer to it is stored in the ref_pointer_array + of the select and the field itself is substituted for the Item_ref object. + This is done in order to get correct values from update fields that + belongs to the SELECT part in the INSERT .. SELECT .. ON DUPLICATE KEY + UPDATE statement. + + RETURN + 0 if error occured + ref if all conditions are met + this field otherwise +*/ + +Item *Item_field::update_value_transformer(byte *select_arg) +{ + SELECT_LEX *select= (SELECT_LEX*)select_arg; + DBUG_ASSERT(fixed); + + if (field->table != select->context.table_list->table && + type() != Item::TRIGGER_FIELD_ITEM) + { + List *all_fields= &select->join->all_fields; + Item **ref_pointer_array= select->ref_pointer_array; + int el= all_fields->elements; + Item_ref *ref; + + ref_pointer_array[el]= (Item*)this; + all_fields->push_front((Item*)this); + ref= new Item_ref(&select->context, ref_pointer_array + el, + table_name, field_name); + return ref; + } + return this; +} + + Item_ref::Item_ref(Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg) diff --git a/sql/item.h b/sql/item.h index 6c41aa09f80..c254578f780 100644 --- a/sql/item.h +++ b/sql/item.h @@ -817,6 +817,7 @@ public: virtual Item_field *filed_for_view_update() { return 0; } virtual Item *neg_transformer(THD *thd) { return NULL; } + virtual Item *update_value_transformer(byte *select_arg) { return this; } virtual Item *safe_charset_converter(CHARSET_INFO *tocs); void delete_self() { @@ -1295,6 +1296,7 @@ public: Item_field *filed_for_view_update() { return this; } Item *safe_charset_converter(CHARSET_INFO *tocs); int fix_outer_field(THD *thd, Field **field, Item **reference); + virtual Item *update_value_transformer(byte *select_arg); friend class Item_default_value; friend class Item_insert_value; friend class st_select_lex_unit; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 39d7f8e9b58..542f47294e5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2388,7 +2388,23 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) next_name_resolution_table= ctx_state.save_next_local; } res= res || setup_fields(thd, 0, *info.update_values, 1, 0, 0); + if (!res) + { + /* + Traverse the update values list and substitute fields from the + select for references (Item_ref objects) to them. This is done in + order to get correct values from those fields when the select + employs a temporary table. + */ + List_iterator li(*info.update_values); + Item *item; + while ((item= li++)) + { + item->transform(&Item::update_value_transformer, + (byte*)lex->current_select); + } + } /* Restore the current context. */ ctx_state.restore_state(context, table_list); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 05ee0d77c1f..f4fec36aa53 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -482,6 +482,9 @@ JOIN::prepare(Item ***rref_pointer_array, } } + if (!procedure && result && result->prepare(fields_list, unit_arg)) + goto err; /* purecov: inspected */ + /* Init join struct */ count_field_types(&tmp_table_param, all_fields, 0); ref_pointer_array_size= all_fields.elements*sizeof(Item*); @@ -495,9 +498,6 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; } #endif - if (!procedure && result && result->prepare(fields_list, unit_arg)) - goto err; /* purecov: inspected */ - if (select_lex->olap == ROLLUP_TYPE && rollup_init()) goto err; if (alloc_func_list()) From 2cd7831fb5d630da7451ba61f76b10c6a60c1500 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 18:10:27 +0100 Subject: [PATCH 38/78] ndb - bug#26454 make lockpages=1 run a bit earlier in startup ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: change order --- ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index fe6caf04d8c..a9039385805 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -76,8 +76,8 @@ static BlockInfo ALL_BLOCKS[] = { { DBDICT_REF, 1 , 6000, 6003 }, { NDBFS_REF, 0 , 2000, 2999 }, { NDBCNTR_REF, 0 , 1000, 1999 }, + { CMVMI_REF, 1 , 9000, 9999 }, // before QMGR { QMGR_REF, 1 , 1, 999 }, - { CMVMI_REF, 1 , 9000, 9999 }, { TRIX_REF, 1 , 0, 0 }, { BACKUP_REF, 1 , 10000, 10999 }, { DBUTIL_REF, 1 , 11000, 11999 }, From 0e39133ad73e7ec7e821591d912509054174d697 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 18:20:24 +0100 Subject: [PATCH 39/78] ndb - bug in my.cnf handling on resize of vector backport fix from 5.1 ndb/src/mgmsrv/InitConfigFileParser.cpp: backport fix from 5.1 --- ndb/src/mgmsrv/InitConfigFileParser.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ndb/src/mgmsrv/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp index f937daf8620..264a998a67b 100644 --- a/ndb/src/mgmsrv/InitConfigFileParser.cpp +++ b/ndb/src/mgmsrv/InitConfigFileParser.cpp @@ -800,6 +800,7 @@ InitConfigFileParser::parse_mycnf() /** * Add ndbd, ndb_mgmd, api/mysqld */ + Uint32 idx = options.size(); { struct my_option opt; bzero(&opt, sizeof(opt)); @@ -809,7 +810,6 @@ InitConfigFileParser::parse_mycnf() opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); - ndbd = &options.back(); opt.name = "ndb_mgmd"; opt.id = 256; @@ -817,7 +817,6 @@ InitConfigFileParser::parse_mycnf() opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); - ndb_mgmd = &options.back(); opt.name = "mysqld"; opt.id = 256; @@ -825,20 +824,22 @@ InitConfigFileParser::parse_mycnf() opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); - mysqld = &options.back(); - opt.name = "api"; + opt.name = "ndbapi"; opt.id = 256; opt.value = (gptr*)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); - api = &options.back(); bzero(&opt, sizeof(opt)); options.push_back(opt); - } + ndbd = &options[idx]; + ndb_mgmd = &options[idx+1]; + mysqld = &options[idx+2]; + api = &options[idx+3]; + } Context ctx(m_info, m_errstream); const char *groups[]= { "cluster_config", 0 }; From 4d7334c821bb3ff8b89c4715c5008e831512006d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 14:30:25 -0800 Subject: [PATCH 40/78] Adjusted results after fix for bug 25971. --- mysql-test/r/bdb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 33398d1ddd7..382fbf750c4 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1442,7 +1442,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c c 11 const # Using where explain select count(*) from t1 where t='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t t 13 NULL # Using where +1 SIMPLE t1 ref t t 13 NULL # Using where explain select count(*) from t1 where v like 'a%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range v v 13 NULL # Using where From d7992c88c6e60c92e6736cd5c95790923f79a59d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 15:43:50 -0800 Subject: [PATCH 41/78] Adjusted results after fix for bug 25971. --- mysql-test/r/bdb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 382fbf750c4..91c385112b4 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1442,7 +1442,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c c 11 const # Using where explain select count(*) from t1 where t='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref t t 13 NULL # Using where +1 SIMPLE t1 ref t t 13 const # Using where explain select count(*) from t1 where v like 'a%'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range v v 13 NULL # Using where From 778b4aad59994e166f91c50b47d686a53a5e8b80 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Feb 2007 23:52:17 +0100 Subject: [PATCH 42/78] ndb - bug#26457 master failure during master take over ndb/src/kernel/blocks/ERROR_codes.txt: new error code ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Make sure to clear NF_XX_LCP if master fails during master take-over ndb/test/include/NdbRestarter.hpp: Add support for querying next master and node group (for multi node failure testing) ndb/test/ndbapi/testNodeRestart.cpp: testcase ndb/test/run-test/daily-basic-tests.txt: testcase ndb/test/src/NdbRestarter.cpp: Add support for querying next master and node group (for multi node failure testing) --- ndb/src/kernel/blocks/ERROR_codes.txt | 4 +- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 27 +++++++++- ndb/test/include/NdbRestarter.hpp | 2 + ndb/test/ndbapi/testNodeRestart.cpp | 42 +++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++ ndb/test/src/NdbRestarter.cpp | 62 +++++++++++++++++++++++ 6 files changed, 139 insertions(+), 2 deletions(-) diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index 0bcc99a6334..f7cb49014cb 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -5,7 +5,7 @@ Next DBACC 3002 Next DBTUP 4014 Next DBLQH 5043 Next DBDICT 6007 -Next DBDIH 7178 +Next DBDIH 7181 Next DBTC 8039 Next CMVMI 9000 Next BACKUP 10022 @@ -71,6 +71,8 @@ Delay GCP_SAVEREQ by 10 secs 7177: Delay copying of sysfileData in execCOPY_GCIREQ +7180: Crash master during master-take-over in execMASTER_LCPCONF + ERROR CODES FOR TESTING NODE FAILURE, LOCAL CHECKPOINT HANDLING: ----------------------------------------------------------------- diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 5f573d40dfe..0e6fe4714b6 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -4612,6 +4612,8 @@ void Dbdih::startLcpMasterTakeOver(Signal* signal, Uint32 nodeId){ jam(); + Uint32 oldNode = c_lcpMasterTakeOverState.failedNodeId; + c_lcpMasterTakeOverState.minTableId = ~0; c_lcpMasterTakeOverState.minFragId = ~0; c_lcpMasterTakeOverState.failedNodeId = nodeId; @@ -4630,7 +4632,20 @@ Dbdih::startLcpMasterTakeOver(Signal* signal, Uint32 nodeId){ /** * Node failure during master take over... */ - ndbout_c("Nodefail during master take over"); + ndbout_c("Nodefail during master take over (old: %d)", oldNode); + } + + NodeRecordPtr nodePtr; + nodePtr.i = oldNode; + if (oldNode > 0 && oldNode < MAX_NDB_NODES) + { + jam(); + ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord); + if (nodePtr.p->m_nodefailSteps.get(NF_LCP_TAKE_OVER)) + { + jam(); + checkLocalNodefailComplete(signal, oldNode, NF_LCP_TAKE_OVER); + } } setLocalNodefailHandling(signal, nodeId, NF_LCP_TAKE_OVER); @@ -5646,6 +5661,14 @@ void Dbdih::execMASTER_LCPREQ(Signal* signal) jamEntry(); const BlockReference newMasterBlockref = req->masterRef; + if (newMasterBlockref != cmasterdihref) + { + jam(); + ndbout_c("resending GSN_MASTER_LCPREQ"); + sendSignalWithDelay(reference(), GSN_MASTER_LCPREQ, signal, + signal->getLength(), 50); + return; + } Uint32 failedNodeId = req->failedNodeId; /** @@ -5946,6 +5969,8 @@ void Dbdih::execMASTER_LCPCONF(Signal* signal) ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord); nodePtr.p->lcpStateAtTakeOver = lcpState; + CRASH_INSERTION(7180); + #ifdef VM_TRACE ndbout_c("MASTER_LCPCONF"); printMASTER_LCP_CONF(stdout, &signal->theData[0], 0, 0); diff --git a/ndb/test/include/NdbRestarter.hpp b/ndb/test/include/NdbRestarter.hpp index 3ec92ae786e..a2e6a4b3248 100644 --- a/ndb/test/include/NdbRestarter.hpp +++ b/ndb/test/include/NdbRestarter.hpp @@ -62,6 +62,8 @@ public: int dumpStateAllNodes(int * _args, int _num_args); int getMasterNodeId(); + int getNextMasterNodeId(int nodeId); + int getNodeGroup(int nodeId); int getRandomNodeSameNodeGroup(int nodeId, int randomNumber); int getRandomNodeOtherNodeGroup(int nodeId, int randomNumber); int getRandomNotMasterNodeId(int randomNumber); diff --git a/ndb/test/ndbapi/testNodeRestart.cpp b/ndb/test/ndbapi/testNodeRestart.cpp index 43fb77342b5..e729e8179b5 100644 --- a/ndb/test/ndbapi/testNodeRestart.cpp +++ b/ndb/test/ndbapi/testNodeRestart.cpp @@ -1045,6 +1045,45 @@ int runBug25554(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int +runBug26457(NDBT_Context* ctx, NDBT_Step* step) +{ + NdbRestarter res; + if (res.getNumDbNodes() < 4) + return NDBT_OK; + + int loops = ctx->getNumLoops(); + while (loops --) + { +retry: + int master = res.getMasterNodeId(); + int next = res.getNextMasterNodeId(master); + + ndbout_c("master: %d next: %d", master, next); + + if (res.getNodeGroup(master) == res.getNodeGroup(next)) + { + res.restartOneDbNode(next, false, false, true); + if (res.waitClusterStarted()) + return NDBT_FAILED; + goto retry; + } + + int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 2 }; + + if (res.dumpStateOneNode(next, val2, 2)) + return NDBT_FAILED; + + if (res.insertErrorInNode(next, 7180)) + return NDBT_FAILED; + + res.restartOneDbNode(master, false, false, true); + if (res.waitClusterStarted()) + return NDBT_FAILED; + } + + return NDBT_OK; +} NDBT_TESTSUITE(testNodeRestart); TESTCASE("NoLoad", @@ -1367,6 +1406,9 @@ TESTCASE("Bug25364", ""){ TESTCASE("Bug25554", ""){ INITIALIZER(runBug25554); } +TESTCASE("Bug26457", ""){ + INITIALIZER(runBug26457); +} NDBT_TESTSUITE_END(testNodeRestart); int main(int argc, const char** argv){ diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 00fa14eea2c..9074ff145d8 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -477,6 +477,10 @@ max-time: 1000 cmd: testNodeRestart args: -n Bug25554 T1 +max-time: 1000 +cmd: testNodeRestart +args: -n Bug26457 T1 + # OLD FLEX max-time: 500 cmd: flexBench diff --git a/ndb/test/src/NdbRestarter.cpp b/ndb/test/src/NdbRestarter.cpp index 2c16a05240d..4c7f52a8622 100644 --- a/ndb/test/src/NdbRestarter.cpp +++ b/ndb/test/src/NdbRestarter.cpp @@ -128,6 +128,68 @@ NdbRestarter::getMasterNodeId(){ return node; } +int +NdbRestarter::getNodeGroup(int nodeId){ + if (!isConnected()) + return -1; + + if (getStatus() != 0) + return -1; + + for(size_t i = 0; i < ndbNodes.size(); i++) + { + if(ndbNodes[i].node_id == nodeId) + { + return ndbNodes[i].node_group; + } + } + + return -1; +} + +int +NdbRestarter::getNextMasterNodeId(int nodeId){ + if (!isConnected()) + return -1; + + if (getStatus() != 0) + return -1; + + size_t i; + for(i = 0; i < ndbNodes.size(); i++) + { + if(ndbNodes[i].node_id == nodeId) + { + break; + } + } + assert(i < ndbNodes.size()); + if (i == ndbNodes.size()) + return -1; + + int dynid = ndbNodes[i].dynamic_id; + int minid = dynid; + for (i = 0; i minid) + minid = ndbNodes[i].dynamic_id; + + for (i = 0; i dynid && + ndbNodes[i].dynamic_id < minid) + { + minid = ndbNodes[i].dynamic_id; + } + + if (minid != ~0) + { + for (i = 0; i Date: Mon, 19 Feb 2007 14:39:37 +0200 Subject: [PATCH 43/78] Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. Several problems fixed: 1. There was a "catch-all" context initialization in setup_tables() that was causing the table that we insert into to be visible in the SELECT part of an INSERT .. SELECT .. statement with no tables in its FROM clause. This was making sure all the under-initialized contexts in various parts of the code are not left uninitialized. Fixed by removing the "catch-all" statement and initializing the context in the parser. 2. Incomplete name resolution context when resolving the right-hand values in the ON DUPLICATE KEY UPDATE ... part of an INSERT ... SELECT ... caused columns from NATURAL JOIN/JOIN USING table references in the FROM clause of the select to be unavailable. Fixed by establishing a proper name resolution context. 3. When setting up the special name resolution context for problem 2 there was no check for cases where an aggregate function without a GROUP BY effectively takes the column from the SELECT part of an INSERT ... SELECT unavailable for ON DUPLICATE KEY UPDATE. Fixed by checking for that condition when setting up the name resolution context. mysql-test/r/insert_update.result: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - test case mysql-test/t/insert_update.test: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - test case sql/item.h: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - save_next_local is not referenced any more outside class methods sql/sql_base.cc: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - removed a "catch-all" code to cater for correct context initialization sql/sql_help.cc: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - fixed the name resolution context initialization sql/sql_insert.cc: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - Fixed the context of resolving the values in INSERT SELECT ON UPDATE sql/sql_prepare.cc: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - Correct context for name resolution of prepared INSERT .. SELECT sql/sql_union.cc: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - fixed the name resolution context initialization sql/sql_yacc.yy: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. - Set the context here instead of setup_tables() --- mysql-test/r/insert_update.result | 17 +++++++ mysql-test/t/insert_update.test | 23 +++++++++ sql/item.h | 7 ++- sql/sql_base.cc | 17 +------ sql/sql_help.cc | 2 + sql/sql_insert.cc | 77 ++++++++++++++++--------------- sql/sql_prepare.cc | 21 ++++----- sql/sql_union.cc | 2 + sql/sql_yacc.yy | 7 ++- 9 files changed, 105 insertions(+), 68 deletions(-) diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index 6be37450835..f658ff06624 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -219,3 +219,20 @@ SELECT * FROM t1; a b 45 2 DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +INSERT INTO t1 SELECT 1, j; +ERROR 42S22: Unknown column 'j' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, c INT); +INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3 +ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; +ERROR 42S22: Unknown column 'a' in 'field list' +DROP TABLE t1,t2; diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index b3813864464..4581cc7a875 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -139,3 +139,26 @@ INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = SELECT * FROM t1; DROP TABLE t1; + +# +# Bug#25831: Deficiencies in INSERT ... SELECT ... field name resolving. +# +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +--error ER_BAD_FIELD_ERROR +INSERT INTO t1 SELECT 1, j; +DROP TABLE t1; + +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, c INT); +INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3 + ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2,t3; + +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (3); +--error ER_BAD_FIELD_ERROR +INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2; diff --git a/sql/item.h b/sql/item.h index 62d6127f10b..e6be2f223da 100644 --- a/sql/item.h +++ b/sql/item.h @@ -325,10 +325,10 @@ private: TABLE_LIST *save_first_name_resolution_table; TABLE_LIST *save_next_name_resolution_table; bool save_resolve_in_select_list; + TABLE_LIST *save_next_local; public: Name_resolution_context_state() {} /* Remove gcc warning */ - TABLE_LIST *save_next_local; public: /* Save the state of a name resolution context. */ @@ -355,6 +355,11 @@ public: next_name_resolution_table= save_next_name_resolution_table; context->resolve_in_select_list= save_resolve_in_select_list; } + + TABLE_LIST *get_first_name_resolution_table() + { + return save_first_name_resolution_table; + } }; /*************************************************************************/ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0949d4aa331..304a16dc62e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4498,21 +4498,8 @@ bool setup_tables(THD *thd, Name_resolution_context *context, uint tablenr= 0; DBUG_ENTER("setup_tables"); - /* - Due to the various call paths that lead to setup_tables() it may happen - that context->table_list and context->first_name_resolution_table can be - NULL (this is typically done when creating TABLE_LISTs internally). - TODO: - Investigate all cases when this my happen, initialize the name resolution - context correctly in all those places, and remove the context reset below. - */ - if (!context->table_list || !context->first_name_resolution_table) - { - /* Test whether the context is in a consistent state. */ - DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list); - context->table_list= context->first_name_resolution_table= tables; - } - + DBUG_ASSERT ((select_insert && !tables->next_name_resolution_table) || !tables || + (context->table_list && context->first_name_resolution_table)); /* this is used for INSERT ... SELECT. For select we setup tables except first (and its underlying tables) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 78349a6ef0d..ba7f1a534ea 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -656,6 +656,8 @@ bool mysqld_help(THD *thd, const char *mask) Init tables and fields to be usable from items tables do not contain VIEWs => we can pass 0 as conds */ + thd->lex->select_lex.context.table_list= + thd->lex->select_lex.context.first_name_resolution_table= &tables[0]; setup_tables(thd, &thd->lex->select_lex.context, &thd->lex->select_lex.top_join_list, tables, 0, &leaves, FALSE); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fb59aeea8e7..75caba84716 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -966,6 +966,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d", (ulong)table_list, (ulong)table, (int)insert_into_view)); + /* INSERT should have a SELECT or VALUES clause */ + DBUG_ASSERT (!select_insert || !values); /* For subqueries in VALUES() we should not see the table in which we are @@ -998,44 +1000,40 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, select_insert)) DBUG_RETURN(TRUE); - /* Save the state of the current name resolution context. */ - ctx_state.save_state(context, table_list); - - /* - Perform name resolution only in the first table - 'table_list', - which is the table that is inserted into. - */ - table_list->next_local= 0; - context->resolve_in_table_list_only(table_list); /* Prepare the fields in the statement. */ - if (values && - !(res= check_insert_fields(thd, context->table_list, fields, *values, - !insert_into_view, &map) || - setup_fields(thd, 0, *values, 0, 0, 0)) && - duplic == DUP_UPDATE) + if (values) { - select_lex->no_wrap_view_item= TRUE; - res= check_update_fields(thd, context->table_list, update_fields, &map); - select_lex->no_wrap_view_item= FALSE; + /* if we have INSERT ... VALUES () we cannot have a GROUP BY clause */ + DBUG_ASSERT (!select_lex->group_list.elements); + + /* Save the state of the current name resolution context. */ + ctx_state.save_state(context, table_list); + /* - When we are not using GROUP BY we can refer to other tables in the - ON DUPLICATE KEY part. - */ - if (select_lex->group_list.elements == 0) + Perform name resolution only in the first table - 'table_list', + which is the table that is inserted into. + */ + table_list->next_local= 0; + context->resolve_in_table_list_only(table_list); + + if (!(res= check_insert_fields(thd, context->table_list, fields, *values, + !insert_into_view, &map) || + setup_fields(thd, 0, *values, 0, 0, 0)) + && duplic == DUP_UPDATE) { - context->table_list->next_local= ctx_state.save_next_local; - /* first_name_resolution_table was set by resolve_in_table_list_only() */ - context->first_name_resolution_table-> - next_name_resolution_table= ctx_state.save_next_local; + select_lex->no_wrap_view_item= TRUE; + res= check_update_fields(thd, context->table_list, update_fields, &map); + select_lex->no_wrap_view_item= FALSE; } + + /* Restore the current context. */ + ctx_state.restore_state(context, table_list); + if (!res) res= setup_fields(thd, 0, update_values, 1, 0, 0); } - /* Restore the current context. */ - ctx_state.restore_state(context, table_list); - if (res) DBUG_RETURN(res); @@ -2355,7 +2353,6 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) if (info.handle_duplicates == DUP_UPDATE) { - /* Save the state of the current name resolution context. */ Name_resolution_context *context= &lex->select_lex.context; Name_resolution_context_state ctx_state; @@ -2371,16 +2368,20 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) *info.update_fields, &map); lex->select_lex.no_wrap_view_item= FALSE; /* - When we are not using GROUP BY we can refer to other tables in the - ON DUPLICATE KEY part + When we are not using GROUP BY and there are no ungrouped aggregate functions + we can refer to other tables in the ON DUPLICATE KEY part. + We use next_name_resolution_table descructively, so check it first (views?) */ - if (lex->select_lex.group_list.elements == 0) - { - context->table_list->next_local= ctx_state.save_next_local; - /* first_name_resolution_table was set by resolve_in_table_list_only() */ - context->first_name_resolution_table-> - next_name_resolution_table= ctx_state.save_next_local; - } + DBUG_ASSERT (!table_list->next_name_resolution_table); + if (lex->select_lex.group_list.elements == 0 && + !lex->select_lex.with_sum_func) + /* + We must make a single context out of the two separate name resolution contexts : + the INSERT table and the tables in the SELECT part of INSERT ... SELECT. + To do that we must concatenate the two lists + */ + table_list->next_name_resolution_table= ctx_state.get_first_name_resolution_table(); + res= res || setup_fields(thd, 0, *info.update_values, 1, 0, 0); /* Restore the current context. */ diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 002b1d52331..3b46d613c93 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1571,21 +1571,16 @@ error: static bool mysql_insert_select_prepare_tester(THD *thd) { - TABLE_LIST *first; - bool res; SELECT_LEX *first_select= &thd->lex->select_lex; + TABLE_LIST *second_table= ((TABLE_LIST*)first_select->table_list.first)-> + next_local; + /* Skip first table, which is the table we are inserting in */ - first_select->table_list.first= (byte*)(first= - ((TABLE_LIST*)first_select-> - table_list.first)->next_local); - res= mysql_insert_select_prepare(thd); - /* - insert/replace from SELECT give its SELECT_LEX for SELECT, - and item_list belong to SELECT - */ - thd->lex->select_lex.context.resolve_in_select_list= TRUE; - thd->lex->select_lex.context.table_list= first; - return res; + first_select->table_list.first= (byte *) second_table; + thd->lex->select_lex.context.table_list= + thd->lex->select_lex.context.first_name_resolution_table= second_table; + + return mysql_insert_select_prepare(thd); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 8b7dde2f818..0632d88875e 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -147,6 +147,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next_local); + fake_select_lex->context.table_list= fake_select_lex->context.first_name_resolution_table= + fake_select_lex->get_table_list(); for (ORDER *order= (ORDER *)global_parameters->order_list.first; order; order=order->next) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 92640ea58d6..15682385cfe 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4188,8 +4188,13 @@ select_into: | select_from into; select_from: - FROM join_table_list where_clause group_clause having_clause + FROM join_table_list where_clause group_clause having_clause opt_order_clause opt_limit_clause procedure_clause + { + Select->context.table_list= + Select->context.first_name_resolution_table= + (TABLE_LIST *) Select->table_list.first; + } | FROM DUAL_SYM where_clause opt_limit_clause /* oracle compatibility: oracle always requires FROM clause, and DUAL is system table without fields. From 85fdd106bd4cd9a8e9d9410ceadfad6644d2120d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 20:13:08 +0100 Subject: [PATCH 44/78] ndb - bug#26481 fix for killed node during initial node restart ndb/src/kernel/blocks/dbdih/Dbdih.hpp: add flag for initial node restart, to keep track on when to concider it to be "done" ndb/src/kernel/blocks/dbdih/DbdihInit.cpp: add flag for initial node restart, to keep track on when to concider it to be "done" ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: add flag for initial node restart, to keep track on when to concider it to be "done" ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Check cstartRecReq also when refusing GCP_SAVEREQ ndb/test/ndbapi/testNodeRestart.cpp: add testcase --- ndb/src/kernel/blocks/dbdih/Dbdih.hpp | 1 + ndb/src/kernel/blocks/dbdih/DbdihInit.cpp | 1 + ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 22 ++++++++++++ ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 3 +- ndb/test/ndbapi/testNodeRestart.cpp | 43 +++++++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index f1b3897c76f..41240a2d620 100644 --- a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -1368,6 +1368,7 @@ private: Uint32 csystemnodes; Uint32 currentgcp; Uint32 c_newest_restorable_gci; + Uint32 c_set_initial_start_flag; enum GcpMasterTakeOverState { GMTOS_IDLE = 0, diff --git a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp index bb96c4b8831..4e71ecd5fe2 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp @@ -75,6 +75,7 @@ void Dbdih::initData() c_blockCommit = false; c_blockCommitNo = 1; cntrlblockref = RNIL; + c_set_initial_start_flag = FALSE; }//Dbdih::initData() void Dbdih::initRecords() diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 0e6fe4714b6..bf71bc56723 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -667,6 +667,12 @@ done: { jam(); memcpy(sysfileData, cdata, sizeof(sysfileData)); + + if (c_set_initial_start_flag) + { + jam(); + Sysfile::setInitialStartOngoing(SYSFILE->systemRestartBits); + } } c_copyGCISlave.m_copyReason = reason; @@ -1260,6 +1266,11 @@ void Dbdih::execNDB_STTOR(Signal* signal) // The permission is given by the master node in the alive set. /*-----------------------------------------------------------------------*/ createMutexes(signal, 0); + if (cstarttype == NodeState::ST_INITIAL_NODE_RESTART) + { + jam(); + c_set_initial_start_flag = TRUE; // In sysfile... + } break; case ZNDB_SPH3: @@ -10277,6 +10288,17 @@ Dbdih::sendLCP_COMPLETE_REP(Signal* signal){ sendSignal(c_lcpState.m_masterLcpDihRef, GSN_LCP_COMPLETE_REP, signal, LcpCompleteRep::SignalLength, JBB); + + /** + * Say that an initial node restart does not need to be redone + * once node has been part of first LCP + */ + if (c_set_initial_start_flag && + c_lcpState.m_participatingLQH.get(getOwnNodeId())) + { + jam(); + c_set_initial_start_flag = FALSE; + } } /*-------------------------------------------------------------------------- */ diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 3d93ce3fc31..ab5deca27b5 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -11673,7 +11673,8 @@ void Dblqh::execGCP_SAVEREQ(Signal* signal) return; } - if(getNodeState().getNodeRestartInProgress()){ + if(getNodeState().getNodeRestartInProgress() && cstartRecReq == ZFALSE) + { GCPSaveRef * const saveRef = (GCPSaveRef*)&signal->theData[0]; saveRef->dihPtr = dihPtr; saveRef->nodeId = getOwnNodeId(); diff --git a/ndb/test/ndbapi/testNodeRestart.cpp b/ndb/test/ndbapi/testNodeRestart.cpp index e729e8179b5..c8c8ddd88d6 100644 --- a/ndb/test/ndbapi/testNodeRestart.cpp +++ b/ndb/test/ndbapi/testNodeRestart.cpp @@ -1085,6 +1085,46 @@ retry: return NDBT_OK; } +int +runBug26481(NDBT_Context* ctx, NDBT_Step* step) +{ + + int result = NDBT_OK; + int loops = ctx->getNumLoops(); + int records = ctx->getNumRecords(); + NdbRestarter res; + + int node = res.getRandomNotMasterNodeId(rand()); + ndbout_c("node: %d", node); + if (res.restartOneDbNode(node, true, true, true)) + return NDBT_FAILED; + + if (res.waitNodesNoStart(&node, 1)) + return NDBT_FAILED; + + int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 }; + if (res.dumpStateOneNode(node, val2, 2)) + return NDBT_FAILED; + + if (res.insertErrorInNode(node, 7018)) + return NDBT_FAILED; + + if (res.startNodes(&node, 1)) + return NDBT_FAILED; + + res.waitNodesStartPhase(&node, 1, 3); + + if (res.waitNodesNoStart(&node, 1)) + return NDBT_FAILED; + + res.startNodes(&node, 1); + + if (res.waitClusterStarted()) + return NDBT_FAILED; + + return NDBT_OK; +} + NDBT_TESTSUITE(testNodeRestart); TESTCASE("NoLoad", "Test that one node at a time can be stopped and then restarted "\ @@ -1409,6 +1449,9 @@ TESTCASE("Bug25554", ""){ TESTCASE("Bug26457", ""){ INITIALIZER(runBug26457); } +TESTCASE("Bug26481", ""){ + INITIALIZER(runBug26481); +} NDBT_TESTSUITE_END(testNodeRestart); int main(int argc, const char** argv){ From 2f58470f5d364643fb56abb7effacef8e32b3156 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 22:30:54 +0100 Subject: [PATCH 45/78] ndb - forgott to add testcase for bug#26481 ndb/test/run-test/daily-basic-tests.txt: forgott to add testcase for bug#26481 --- ndb/test/run-test/daily-basic-tests.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 9074ff145d8..baad45013dd 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -481,6 +481,10 @@ max-time: 1000 cmd: testNodeRestart args: -n Bug26457 T1 +max-time: 1000 +cmd: testNodeRestart +args: -n Bug26481 T1 + # OLD FLEX max-time: 500 cmd: flexBench From 2afacafb78861a6ba523a3d896d457e9c85aa93a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 22:51:04 +0100 Subject: [PATCH 46/78] ndb - fix correct argv/argc handling in testBitfield ndb/test/ndbapi/testBitfield.cpp: fix correct argv/argc handling in testBitfield --- ndb/test/ndbapi/testBitfield.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ndb/test/ndbapi/testBitfield.cpp b/ndb/test/ndbapi/testBitfield.cpp index e26f495f5a4..1d1e203d185 100644 --- a/ndb/test/ndbapi/testBitfield.cpp +++ b/ndb/test/ndbapi/testBitfield.cpp @@ -36,9 +36,10 @@ main(int argc, char** argv){ load_defaults("my",load_default_groups,&argc,&argv); int ho_error; - argc--; - argv++; - + if ((ho_error=handle_options(&argc, &argv, my_long_options, + ndb_std_get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + Ndb_cluster_connection con(opt_connect_str); if(con.connect(12, 5, 1)) { From 65e7108f695e58dc9316aaa5cbf2f14cfa0f31ba Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 00:55:33 +0100 Subject: [PATCH 47/78] fix compile error in testBitfield --- ndb/test/ndbapi/testBitfield.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ndb/test/ndbapi/testBitfield.cpp b/ndb/test/ndbapi/testBitfield.cpp index 1d1e203d185..8ba8f3d92ef 100644 --- a/ndb/test/ndbapi/testBitfield.cpp +++ b/ndb/test/ndbapi/testBitfield.cpp @@ -8,6 +8,15 @@ static const char* _dbname = "TEST_DB"; static int g_loops = 7; + +NDB_STD_OPTS_VARS; + +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; + static void usage() { ndb_std_print_version(); From 446672d42f17b90428086e8053995c7fc5f8a24f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 10:01:54 +0100 Subject: [PATCH 48/78] Fixed a bad merge. Got a duplicate symbol on OSX. --- mysys/my_thr_init.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index abacc7bc004..67ab1e4a38a 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -47,8 +47,6 @@ pthread_mutexattr_t my_fast_mutexattr; pthread_mutexattr_t my_errorcheck_mutexattr; #endif -uint thd_lib_detected; - #ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */ /* From cf933534eac84b998de0853ff809f828405b7e00 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 13:10:27 +0100 Subject: [PATCH 49/78] After-merge fix: The declaration of "thr_client_alarm" had got lost, keep it in "mysys/thr_alarm.c". mysys/thr_alarm.c: After-merge fix: In 4.1, the variable "thr_client_alarm" is declared in this module. --- mysys/thr_alarm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 7ccc1dc5d2f..759544af17b 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -36,6 +36,7 @@ #define ETIME ETIMEDOUT #endif +uint thr_client_alarm; static int alarm_aborted=1; /* No alarm thread */ my_bool thr_alarm_inited= 0; volatile my_bool alarm_thread_running= 0; From da39e1d848cd5851accc9a0b348d482c574c380b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 16:50:54 +0100 Subject: [PATCH 50/78] Raise version number after cloning 5.0.36 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index a447732a06a..d48c3403954 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.36) +AM_INIT_AUTOMAKE(mysql, 5.0.38) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=36 +NDB_VERSION_BUILD=38 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 2f3a17b63e4e207ae8796d953ba611a593e3ee2c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Feb 2007 13:02:57 +0200 Subject: [PATCH 51/78] Fixed unsafe define of uint4korr() Fixed that --extern works with mysql-test-run.pl Small trivial cleanups include/my_global.h: Fixed unsafe define of uint4korr() mysql-test/lib/mtr_report.pl: Removed wrong messages when using --extern mysql-test/mysql-test-run.pl: Fixed that --extern works Print help on stdout instead of stderr (make it easier to pipe it to less) mysql-test/t/ndb_lock.test: Added other possible error code sql/sql_prepare.cc: Removed not needed casts --- include/my_global.h | 2 +- mysql-test/lib/mtr_report.pl | 6 +- mysql-test/mysql-test-run.pl | 187 +++++++++++++++++++---------------- mysql-test/t/ndb_lock.test | 2 +- sql/sql_prepare.cc | 4 +- 5 files changed, 111 insertions(+), 90 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index d53dee23e17..23fe71caa8d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1078,7 +1078,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */ */ #define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) #endif -#define uint4korr(A) (*((unsigned long *) (A))) +#define uint4korr(A) (*((uint32 *) (A))) #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16) +\ diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index e3eebc25091..2a90344c110 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -236,8 +236,10 @@ sub mtr_report_stats ($) { "the documentation at\n", "http://www.mysql.com/doc/en/MySQL_test_suite.html\n"; } - print - "The servers were restarted $tot_restarts times\n"; + if (!$::opt_extern) + { + print "The servers where restarted $tot_restarts times\n"; + } if ( $::opt_timer ) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 83a440f5ec4..d6e74976fb6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -696,7 +696,9 @@ sub command_line_setup () { "$glob_basedir/client", "$glob_basedir/bin"); - $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), + if (!$opt_extern) + { + $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), "$glob_basedir/sql/mysqld", "$path_client_bindir/mysqld-max-nt", "$path_client_bindir/mysqld-max", @@ -708,8 +710,16 @@ sub command_line_setup () { "$glob_basedir/bin/mysqld", "$glob_basedir/sbin/mysqld"); - # Use the mysqld found above to find out what features are available - collect_mysqld_features(); + # Use the mysqld found above to find out what features are available + collect_mysqld_features(); + } + else + { + $mysqld_variables{'port'}= 3306; + $mysqld_variables{'master-port'}= 3306; + $opt_skip_ndbcluster= 1; + $opt_skip_im= 1; + } if ( $opt_comment ) { @@ -746,7 +756,7 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # NOTE if the default binlog format is changed, this has to be changed $used_binlog_format= "stmt"; - if ( $mysql_version_id >= 50100 ) + if (!$opt_extern && $mysql_version_id >= 50100 ) { $used_binlog_format= "mixed"; # Default value for binlog format @@ -832,19 +842,20 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # Check im suport # -------------------------------------------------------------------------- - if ( $mysql_version_id < 50000 ) + if (!$opt_extern) { - # Instance manager is not supported until 5.0 - $opt_skip_im= 1; + if ( $mysql_version_id < 50000 ) { + # Instance manager is not supported until 5.0 + $opt_skip_im= 1; + + } + + if ( $glob_win32 ) { + mtr_report("Disable Instance manager - not supported on Windows"); + $opt_skip_im= 1; + } } - - if ( $glob_win32 ) - { - mtr_report("Disable Instance manager - not supported on Windows"); - $opt_skip_im= 1; - } - # -------------------------------------------------------------------------- # Record flag # -------------------------------------------------------------------------- @@ -1208,7 +1219,7 @@ sub command_line_setup () { $opt_skip_rpl= 1; # Setup master->[0] with the settings for the extern server - $master->[0]->{'path_sock'}= $opt_socket if $opt_socket; + $master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock"; mtr_report("Using extern server at '$master->[0]->{path_sock}'"); } else @@ -1474,57 +1485,53 @@ sub executable_setup () { $exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog"); $exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin"); $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); - if ( $mysql_version_id >= 50100 ) - { - $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap"); - } - if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server ) - { - $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade") - } - else - { - $exe_mysql_upgrade= ""; - } - if ( ! $glob_win32 ) + if (!$opt_extern) { - # Look for mysql_fix_system_table script - $exe_mysql_fix_system_tables= - mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables", - "$path_client_bindir/mysql_fix_privilege_tables"); - } - - # Look for mysql_fix_privilege_tables.sql script - $file_mysql_fix_privilege_tables= - mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", - "$glob_basedir/share/mysql_fix_privilege_tables.sql"); - - if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) - { - mtr_warning("Could not find all required ndb binaries, " . - "all ndb tests will fail, use --skip-ndbcluster to " . - "skip testing it."); - - foreach my $cluster (@{$clusters}) - { - $cluster->{"executable_setup_failed"}= 1; + if ( $mysql_version_id >= 50100 ) { + $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap"); } + if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server ) { + $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade") + } else { + $exe_mysql_upgrade= ""; + } + + if ( ! $glob_win32 ) { + # Look for mysql_fix_system_table script + $exe_mysql_fix_system_tables= + mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables", + "$path_client_bindir/mysql_fix_privilege_tables"); + } + + # Look for mysql_fix_privilege_tables.sql script + $file_mysql_fix_privilege_tables= + mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", + "$glob_basedir/share/mysql_fix_privilege_tables.sql"); + + if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { + mtr_warning("Could not find all required ndb binaries, " . + "all ndb tests will fail, use --skip-ndbcluster to " . + "skip testing it."); + + foreach my $cluster (@{$clusters}) { + $cluster->{"executable_setup_failed"}= 1; + } + } + + if ( ! $opt_skip_im and executable_setup_im()) { + mtr_warning("Could not find all required instance manager binaries, " . + "all im tests will fail, use --skip-im to " . + "continue without instance manager"); + $instance_manager->{"executable_setup_failed"}= 1; + } + + # Look for the udf_example library + $lib_udf_example= + mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), + "$glob_basedir/sql/.libs/udf_example.so",); + } - - if ( ! $opt_skip_im and executable_setup_im()) - { - mtr_warning("Could not find all required instance manager binaries, " . - "all im tests will fail, use --skip-im to " . - "continue without instance manager"); - $instance_manager->{"executable_setup_failed"}= 1; - } - - # Look for the udf_example library - $lib_udf_example= - mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), - "$glob_basedir/sql/.libs/udf_example.so",); - # Look for mysqltest executable if ( $glob_use_embedded_server ) { @@ -1590,7 +1597,7 @@ sub mysql_client_test_arguments() mtr_add_arg($args, "--port=$master->[0]->{'port'}"); mtr_add_arg($args, "--socket=$master->[0]->{'path_sock'}"); - if ( $mysql_version_id >= 50000 ) + if ( $opt_extern || $mysql_version_id >= 50000 ) { mtr_add_arg($args, "--vardir=$opt_vardir") } @@ -1701,7 +1708,7 @@ sub environment_setup () { } $ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths, - $ENV{'LD_LIBRARY_PATHS'} ? + $ENV{'LD_LIBRARY_PATH'} ? split(':', $ENV{'LD_LIBRARY_PATH'}) : ()); mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}"); @@ -1882,7 +1889,7 @@ sub environment_setup () { my $cmdline_mysqlbinlog= "$exe_mysqlbinlog" . " --no-defaults --local-load=$opt_tmpdir"; - if ( $mysql_version_id >= 50000 ) + if (!$opt_extern && $mysql_version_id >= 50000 ) { $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir"; } @@ -1913,7 +1920,7 @@ sub environment_setup () { # ---------------------------------------------------- # Setup env so childs can execute mysql_upgrade # ---------------------------------------------------- - if ( $mysql_version_id >= 50000 ) + if ( !$opt_extern && $mysql_version_id >= 50000 ) { $ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments(); } @@ -1921,7 +1928,7 @@ sub environment_setup () { # ---------------------------------------------------- # Setup env so childs can execute mysql_fix_system_tables # ---------------------------------------------------- - if ( ! $glob_win32 ) + if ( !$opt_extern && ! $glob_win32 ) { my $cmdline_mysql_fix_system_tables= "$exe_mysql_fix_system_tables --no-defaults --host=localhost " . @@ -1931,7 +1938,10 @@ sub environment_setup () { "--socket=$master->[0]->{'path_sock'}"; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; } - $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; + if (!$opt_extern) + { + $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; + } # ---------------------------------------------------- # Setup env so childs can execute my_print_defaults @@ -2235,7 +2245,10 @@ sub check_ssl_support ($) { if ($opt_skip_ssl || $opt_extern) { - mtr_report("Skipping SSL"); + if (!$opt_extern) + { + mtr_report("Skipping SSL"); + } $opt_ssl_supported= 0; $opt_ssl= 0; return; @@ -2310,9 +2323,12 @@ sub vs_config_dirs ($$) { sub check_ndbcluster_support ($) { my $mysqld_variables= shift; - if ($opt_skip_ndbcluster) + if ($opt_skip_ndbcluster || $opt_extern) { - mtr_report("Skipping ndbcluster"); + if (!$opt_extern) + { + mtr_report("Skipping ndbcluster"); + } $opt_skip_ndbcluster_slave= 1; return; } @@ -2728,7 +2744,10 @@ sub initialize_servers () { } else { - mtr_report("No need to create '$opt_vardir' it already exists"); + if ($opt_verbose) + { + mtr_report("No need to create '$opt_vardir' it already exists"); + } } } else @@ -3125,17 +3144,17 @@ sub do_before_run_mysqltest($) unlink("$result_dir/$tname.log"); unlink("$result_dir/$tname.warnings"); - if ( $mysql_version_id < 50000 ) + if (!$opt_extern) { - # Set environment variable NDB_STATUS_OK to 1 - # if script decided to run mysqltest cluster _is_ installed ok - $ENV{'NDB_STATUS_OK'} = "1"; - } - elsif ( $mysql_version_id < 50100 ) - { - # Set environment variable NDB_STATUS_OK to YES - # if script decided to run mysqltest cluster _is_ installed ok - $ENV{'NDB_STATUS_OK'} = "YES"; + if ( $mysql_version_id < 50000 ) { + # Set environment variable NDB_STATUS_OK to 1 + # if script decided to run mysqltest cluster _is_ installed ok + $ENV{'NDB_STATUS_OK'} = "1"; + } elsif ( $mysql_version_id < 50100 ) { + # Set environment variable NDB_STATUS_OK to YES + # if script decided to run mysqltest cluster _is_ installed ok + $ENV{'NDB_STATUS_OK'} = "YES"; + } } } @@ -4903,10 +4922,10 @@ sub usage ($) { if ( $message ) { - print STDERR "$message \n"; + print STDERR "$message\n"; } - print STDERR < Date: Wed, 21 Feb 2007 19:38:40 +0200 Subject: [PATCH 52/78] After merge fixes This also fixes a bug in counting number of rows that are updated when we have many simultanous queries extra/yassl/src/ssl.cpp: Removed compiler warning extra/yassl/taocrypt/src/asn.cpp: After merge fixes extra/yassl/testsuite/testsuite.cpp: Removed compiler warning mysql-test/r/ndb_lock.result: After merge fixes ndb/src/common/debugger/EventLogger.cpp: Removed compiler warning ndb/src/common/util/ConfigValues.cpp: Removed compiler warning ndb/src/common/util/NdbSqlUtil.cpp: Removed compiler warning ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Removed compiler warning ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp: Removed compiler warning ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp: Removed compiler warning ndb/src/kernel/vm/ndbd_malloc.cpp: Removed compiler warning ndb/src/mgmclient/main.cpp: Removed compiler warning ndb/src/ndbapi/SignalSender.cpp: Removed compiler warning sql/ha_ndbcluster.cc: Some extra safety sql/item_cmpfunc.cc: After merge fixes sql/item_subselect.cc: After merge fixes sql/sql_insert.cc: After merge fixes (This actually fixes a bug in old code when many connections are in use) support-files/compiler_warnings.supp: Removed some suppressed warnings --- extra/yassl/src/ssl.cpp | 2 +- extra/yassl/taocrypt/src/asn.cpp | 2 -- extra/yassl/testsuite/testsuite.cpp | 4 ++-- mysql-test/r/ndb_lock.result | 2 +- ndb/src/common/debugger/EventLogger.cpp | 3 +++ ndb/src/common/util/ConfigValues.cpp | 2 -- ndb/src/common/util/NdbSqlUtil.cpp | 2 -- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 3 --- ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp | 2 -- ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp | 2 -- ndb/src/kernel/vm/ndbd_malloc.cpp | 2 ++ ndb/src/mgmclient/main.cpp | 2 -- ndb/src/ndbapi/SignalSender.cpp | 8 -------- sql/ha_ndbcluster.cc | 3 +++ sql/item_cmpfunc.cc | 2 +- sql/item_subselect.cc | 9 ++++----- sql/sql_insert.cc | 2 +- support-files/compiler_warnings.supp | 12 ++---------- 18 files changed, 20 insertions(+), 44 deletions(-) diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 70198af79b4..837121c249d 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -950,7 +950,7 @@ void ERR_print_errors_fp(FILE* /*fp*/) char* ERR_error_string(unsigned long errNumber, char* buffer) { - static char* msg = "Please supply a buffer for error string"; + static char* msg = (char*) "Please supply a buffer for error string"; if (buffer) { SetErrorString(YasslError(errNumber), buffer); diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index ef7a330b76d..5bc865a4ba7 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -747,8 +747,6 @@ void CertDecoder::GetName(NameType nt) idx += length2; } - source_.advance(oidSz + 1); - word32 length2 = GetLength(source_); source_.advance(length2); } } diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp index 93b9b3d7026..06e75153341 100644 --- a/extra/yassl/testsuite/testsuite.cpp +++ b/extra/yassl/testsuite/testsuite.cpp @@ -86,8 +86,8 @@ int main(int argc, char** argv) // input output compare byte input[TaoCrypt::MD5::DIGEST_SIZE]; byte output[TaoCrypt::MD5::DIGEST_SIZE]; - file_test("input", input); - file_test("output", output); + file_test((char*) "input", input); + file_test((char*) "output", output); assert(memcmp(input, output, sizeof(input)) == 0); printf("\nAll tests passed!\n"); diff --git a/mysql-test/r/ndb_lock.result b/mysql-test/r/ndb_lock.result index d5875cb4d47..9a2cea0f512 100644 --- a/mysql-test/r/ndb_lock.result +++ b/mysql-test/r/ndb_lock.result @@ -121,7 +121,7 @@ select * from t1 where x = 1 for update; x y z 1 one 1 select * from t1 where x = 2 for update; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction +Got one of the listed errors rollback; commit; begin; diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 3efd52808e2..58849b7d8db 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -913,6 +913,8 @@ EventLogger::close() removeAllHandlers(); } +#ifdef NOT_USED + static NdbOut& operator<<(NdbOut& out, const LogLevel & ll) { @@ -922,6 +924,7 @@ operator<<(NdbOut& out, const LogLevel & ll) out << "]"; return out; } +#endif int EventLoggerBase::event_lookup(int eventType, diff --git a/ndb/src/common/util/ConfigValues.cpp b/ndb/src/common/util/ConfigValues.cpp index cc1ce0d1519..9309fe3fbd6 100644 --- a/ndb/src/common/util/ConfigValues.cpp +++ b/ndb/src/common/util/ConfigValues.cpp @@ -18,8 +18,6 @@ #include #include -static Uint32 hash(Uint32 key, Uint32 size); -static Uint32 nextHash(Uint32 key, Uint32 size, Uint32 pos, Uint32 count); static bool findKey(const Uint32 * vals, Uint32 sz, Uint32 key, Uint32 * pos); /** diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 1234e4ece6b..0f62d66c149 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -681,8 +681,6 @@ int NdbSqlUtil::cmpBit(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) { Uint32 n = (n1 < n2) ? n1 : n2; - char* c1 = (char*)p1; - char* c2 = (char*)p2; int ret = memcmp(p1, p2, n); return ret; } diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 2b2e0e649a4..af994a2b3cb 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -6944,7 +6944,6 @@ void Dbtc::execGCP_NOMORETRANS(Signal* signal) /*****************************************************************************/ void Dbtc::execNODE_FAILREP(Signal* signal) { - HostRecordPtr tmpHostptr; jamEntry(); NodeFailRep * const nodeFail = (NodeFailRep *)&signal->theData[0]; @@ -11866,8 +11865,6 @@ void Dbtc::execTCKEYREF(Signal* signal) } const UintR TconnectIndex = indexOp->connectionIndex; ApiConnectRecord * const regApiPtr = &apiConnectRecord[TconnectIndex]; - Uint32 tcKeyRequestInfo = indexOp->tcIndxReq.requestInfo; - Uint32 commitFlg = TcKeyReq::getCommitFlag(tcKeyRequestInfo); switch(indexOp->indexOpState) { case(IOS_NOOP): { diff --git a/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp b/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp index b0f71223c9d..964d8578217 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp @@ -185,7 +185,6 @@ Dbtup::tuxReadPk(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* data PagePtr pagePtr; pagePtr.i = pageId; ptrCheckGuard(pagePtr, cnoOfPage, page); - const Uint32 tabDescriptor = tablePtr.p->tabDescriptor; const Uint32* attrIds = &tableDescriptor[tablePtr.p->readKeyArray].tabDescr; const Uint32 numAttrs = tablePtr.p->noOfKeyAttr; // read pk attributes from original tuple @@ -239,7 +238,6 @@ Dbtup::accReadPk(Uint32 tableId, Uint32 fragId, Uint32 fragPageId, Uint32 pageIn FragrecordPtr fragPtr; getFragmentrec(fragPtr, fragId, tablePtr.p); // get real page id and tuple offset - PagePtr pagePtr; Uint32 pageId = getRealpid(fragPtr.p, fragPageId); ndbrequire((pageIndex & 0x1) == 0); Uint32 pageOffset = ZPAGE_HEADER_SIZE + (pageIndex >> 1) * tablePtr.p->tupheadsize; diff --git a/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp b/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp index f9898519bde..364a8a0bba5 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp @@ -92,8 +92,6 @@ void Dbtup::rfrReadRestartInfoLab(Signal* signal, RestartInfoRecordPtr riPtr) seizeDiskBufferSegmentRecord(dbsiPtr); riPtr.p->sriDataBufferSegmentP = dbsiPtr.i; Uint32 retPageRef = RNIL; - Uint32 noAllocPages = 1; - Uint32 noOfPagesAllocated; { /** * Use low pages for 0-pages during SR diff --git a/ndb/src/kernel/vm/ndbd_malloc.cpp b/ndb/src/kernel/vm/ndbd_malloc.cpp index 9386e3c7cd3..21a26ff11d8 100644 --- a/ndb/src/kernel/vm/ndbd_malloc.cpp +++ b/ndb/src/kernel/vm/ndbd_malloc.cpp @@ -22,12 +22,14 @@ #include #endif +#ifdef TRACE_MALLOC static void xxx(size_t size, size_t *s_m, size_t *s_k, size_t *s_b) { *s_m = size/1024/1024; *s_k = (size - *s_m*1024*1024)/1024; *s_b = size - *s_m*1024*1024-*s_k*1024; } +#endif static Uint64 g_allocated_memory; void *ndbd_malloc(size_t size) diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 2d0103632b9..55617c74e3f 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -128,8 +128,6 @@ read_and_execute(int _try_reconnect) int main(int argc, char** argv){ NDB_INIT(argv[0]); - const char *_host = 0; - int _port = 0; load_defaults("my",load_default_groups,&argc,&argv); int ho_error; diff --git a/ndb/src/ndbapi/SignalSender.cpp b/ndb/src/ndbapi/SignalSender.cpp index 548a3e1d111..b8e71f310f7 100644 --- a/ndb/src/ndbapi/SignalSender.cpp +++ b/ndb/src/ndbapi/SignalSender.cpp @@ -19,14 +19,6 @@ #include #include -static -void -require(bool x) -{ - if (!x) - abort(); -} - SimpleSignal::SimpleSignal(bool dealloc){ memset(this, 0, sizeof(* this)); deallocSections = dealloc; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 3443fd58aa8..555910ca3df 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6660,6 +6660,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) for (;;) { + if (abort_loop) + break; /* Shutting down server */ + pthread_mutex_lock(&LOCK_ndb_util_thread); pthread_cond_timedwait(&COND_ndb_util_thread, &LOCK_ndb_util_thread, diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 10877fa4434..e0d74cc7547 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -904,7 +904,7 @@ longlong Item_in_optimizer::val_int() */ for (i= 0; i < ncols; i++) { - if (cache->el(i)->null_value) + if (cache->element_index(i)->null_value) item_subs->set_cond_guard_var(i, FALSE); } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index cb6e8146adc..20d9ed8affa 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1164,7 +1164,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) optimizer->keep_top_level_cache(); thd->lex->current_select= current; - unit->uncacheable|= UNCACHEABLE_DEPENDENT; + master_unit->uncacheable|= UNCACHEABLE_DEPENDENT; if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards) { @@ -1220,7 +1220,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) (char *)"") ); Item *col_item= new Item_cond_or(item_eq, item_isnull); - if (!abort_on_null && left_expr->el(i)->maybe_null) + if (!abort_on_null && left_expr->element_index(i)->maybe_null) { if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i)))) DBUG_RETURN(RES_ERROR); @@ -1234,7 +1234,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) ref_pointer_array + i, (char *)"", (char *)"")); - if (!abort_on_null && left_expr->el(i)->maybe_null) + if (!abort_on_null && left_expr->element_index(i)->maybe_null) { if (!(item_nnull_test= new Item_func_trig_cond(item_nnull_test, get_cond_guard(i)))) @@ -1311,7 +1311,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) TODO: why we create the above for cases where the right part cant be NULL? */ - if (left_expr->el(i)->maybe_null) + if (left_expr->element_index(i)->maybe_null) { if (!(item= new Item_func_trig_cond(item, get_cond_guard(i)))) DBUG_RETURN(RES_ERROR); @@ -1762,7 +1762,6 @@ int subselect_single_select_engine::exec() if (!executed) { item->reset_value_registration(); - bool have_changed_access= FALSE; JOIN_TAB *changed_tabs[MAX_TABLES]; JOIN_TAB **last_changed_tab= changed_tabs; if (item->have_guarded_conds()) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 3b479841c1d..aa429f9250e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1193,7 +1193,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto err; } if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || - compare_record(table, query_id)) + compare_record(table, thd->query_id)) { info->updated++; diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index f8651e1d27d..d97ffbfafe2 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -1,12 +1,4 @@ DictTabInfo.cpp : .*invalid access to non-static.* DictTabInfo.cpp : .*macro was used incorrectly.* -EventLogger.cpp : .*defined but not used.* : 916 -NdbSqlUtil.cpp : .*unused variable.* : 684 - 685 -DbdihMain.cpp : .*unused variable.* : 6666 -DbtcMain.cpp : .*unused variable.* : 6947 -DbtcMain.cpp : .*unused variable.* : 11870 -DbtupExecQuery.cpp : .*unused variable.* : 1449 -DbtupSystemRestart.cpp : .*unused variable.* : 95 - 96 -DbtupIndex.cpp : .*unused variable.* : 188 - 242 -ndbd_malloc.cpp : .*defined but not used.* : 25 -main.cpp : .*unused variable.* : 131 - 132 +DbdihMain.cpp : .*unused variable.* : 6666-6705 +DbtupExecQuery.cpp : .*unused variable.* : 1448-1449 From f8855142d7a498c540f8f92ab1095a1038aeb079 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Feb 2007 23:00:32 +0300 Subject: [PATCH 53/78] Bug#23800: Outer fields in correlated subqueries is used in a temporary table created for sorting. Any outer reference in a subquery was represented by an Item_field object. If the outer select employs a temporary table all such fields should be replaced with fields from that temporary table in order to point to the actual data. This replacement wasn't done and that resulted in a wrong subquery evaluation and a wrong result of the whole query. Now any outer field is represented by two objects - Item_field placed in the outer select and Item_outer_ref in the subquery. Item_field object is processed as a normal field and the reference to it is saved in the ref_pointer_array. Thus the Item_outer_ref is always references the correct field. The original field is substituted for a reference in the Item_field::fix_outer_field() function. New function called fix_inner_refs() is added to fix fields referenced from inner selects and to fix references (Item_ref objects) to these fields. The new Item_outer_ref class is a descendant of the Item_direct_ref class. It additionally stores a reference to the original field and designed to behave more like a field. sql/item.cc: Bug#23800: Correlated sub query returning incorrect results when operated upon. Now all outer fields are substituted with references to them (Item_outer_ref objects) in the Item_field::fix_outer_field() function. The original field is saved in the Item_outer_ref object. sql/item.h: Bug#23800: Correlated sub query returning incorrect results when operated upon. Added the Item_outer_ref class. sql/mysql_priv.h: Bug#23800: Correlated sub query returning incorrect results when operated upon. Added the fix_inner_refs() function prototype. sql/sql_delete.cc: Bug#23800: Correlated sub query returning incorrect results when operated upon. Added call to the fix_inner_refs() function. sql/sql_select.cc: Bug#23800: Correlated sub query returning incorrect results when operated upon. The new function called fix_inner_refs() is added. mysql-test/r/subselect.result: Added a test case for bug#23800: Correlated sub query returning incorrect results when operated upon. sql/sql_update.cc: Bug#23800: Correlated sub query returning incorrect results when operated upon. Added call to the fix_inner_refs() function. mysql-test/r/subselect3.result: Corrected test cases result after fix for bug#23800: Correlated sub query returning incorrect results when operated upon. mysql-test/t/subselect.test: Added a test case for bug#23800: Correlated sub query returning incorrect results when operated upon. sql/sql_lex.cc: Bug#23800: Correlated sub query returning incorrect results when operated upon. Added cleanup of the inner_refs_list. sql/sql_lex.h: Bug#23800: Correlated sub query returning incorrect results when operated upon. The inner_refs_list is added to the SELECT_LEX class. --- mysql-test/r/subselect.result | 60 ++++++++++++++++++++---- mysql-test/r/subselect3.result | 22 ++++----- mysql-test/t/subselect.test | 29 +++++++++++- sql/item.cc | 80 ++++++++++++++++++++++++++++---- sql/item.h | 40 ++++++++++++++-- sql/mysql_priv.h | 2 + sql/sql_delete.cc | 6 +++ sql/sql_lex.cc | 1 + sql/sql_lex.h | 3 +- sql/sql_select.cc | 83 +++++++++++++++++++++++++++++++--- sql/sql_update.cc | 5 ++ 11 files changed, 290 insertions(+), 41 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 06f8c019265..7177b4e4432 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -224,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where Warnings: -Note 1276 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) AS `min(t3.a)` from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a @@ -313,8 +313,8 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL Warnings: -Note 1276 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 -Note 1276 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select (select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row @@ -330,9 +330,9 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Using index +2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 Using where; Using index Warnings: -Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous @@ -868,7 +868,7 @@ explain extended select (select a+1) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Warnings: -Note 1276 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select (`test`.`t1`.`a` + 1) AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; @@ -1741,9 +1741,9 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 Using where -2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 Using where; Using index +2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 Using where; Using index Warnings: -Note 1276 Field or reference 'tt.id' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); @@ -2279,7 +2279,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY up ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where Warnings: -Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) drop table t1; CREATE TABLE t1 (t1_a int); @@ -3712,3 +3712,45 @@ bb 2 cc 3 dd 1 DROP TABLE t1,t2,t3; +CREATE TABLE t1(f1 int); +CREATE TABLE t2(f2 int, f21 int, f3 timestamp); +INSERT INTO t1 VALUES (1),(1),(2),(2); +INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11"), (2,2,"2004-02-29 11:11:11"); +SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1; +sq +2 +4 +SELECT (SELECT SUM(1) FROM t2 ttt GROUP BY t2.f3 LIMIT 1) AS tt FROM t2; +tt +2 +2 +PREPARE stmt1 FROM 'SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1'; +EXECUTE stmt1; +sq +2 +4 +EXECUTE stmt1; +sq +2 +4 +DEALLOCATE PREPARE stmt1; +SELECT f2, AVG(f21), +(SELECT t.f3 FROM t2 AS t WHERE t2.f2=t.f2 AND t.f3=MAX(t2.f3)) AS test +FROM t2 GROUP BY f2; +f2 AVG(f21) test +1 1.0000 2004-02-29 11:11:11 +2 2.0000 2004-02-29 11:11:11 +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL); +INSERT INTO t1 VALUES +(1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), +(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'), +(3,2,'k'), (3,1,'l'), (1,9,'m'); +SELECT a, MAX(b), +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test +FROM t1 GROUP BY a; +a MAX(b) test +1 9 m +2 3 h +3 4 i +DROP TABLE t1; diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index 29143b9e504..b975ea8cbdc 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -29,7 +29,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,(`test`.`t2`.`a`,(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond(((`test`.`t2`.`a`) = (max(`test`.`t1`.`ie`)))))) AS `Z` from `test`.`t2` explain extended select a, oref from t2 @@ -38,7 +38,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where (`test`.`t2`.`a`,(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having ((`test`.`t2`.`a`) = (max(`test`.`t1`.`ie`))))) select a, oref, a in ( select max(ie) from t1 where oref=t2.oref group by grp union @@ -91,7 +91,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using where; Full scan on NULL key Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond((`test`.`t1`.`a`))))) AS `Z` from `test`.`t2` flush status; select oref, a from t2 where a in (select a from t1 where oref=t2.oref); @@ -156,7 +156,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 4 Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 Using where Warnings: -Note 1276 Field or reference 't3.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,(`test`.`t3`.`a`,(select 1 AS `Not_used` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((((`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond((`test`.`t1`.`a`)))) AS `Z` from `test`.`t3` drop table t1, t2, t3; create table t1 (a int NOT NULL, b int NOT NULL, key(a)); @@ -184,7 +184,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t1 ref a a 4 func 2 Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 Using where Warnings: -Note 1276 Field or reference 't3.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,(`test`.`t3`.`a`,(select 1 AS `Not_used` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((`test`.`t3`.`a`) = `test`.`t1`.`a`))))) AS `Z` from `test`.`t3` drop table t1,t2,t3; create table t1 (oref int, grp int); @@ -240,7 +240,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using where; Full scan on NULL key Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,((`test`.`t2`.`a`,`test`.`t2`.`b`),(((`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond((((`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond((((`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond((`test`.`t1`.`a`)) and trigcond((`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; a b oref Z @@ -257,7 +257,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 2 Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 100 Using where Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,((`test`.`t2`.`a`,`test`.`t2`.`b`),(select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond((((`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond((((`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond((`test`.`t1`.`a`)) and trigcond((`test`.`t1`.`b`))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1,t4 where c=t2.oref) Z @@ -302,7 +302,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 8 Using where 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 Using where; Full scan on NULL key Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,((`test`.`t2`.`a`,`test`.`t2`.`b`),(((`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond((((`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond((((`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond((`test`.`t1`.`ie1`)) and trigcond((`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10)) drop table t1, t2; create table t1 (oref char(4), grp int, ie int); @@ -432,7 +432,7 @@ alter table t1 add index idx(oref,ie); explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 -2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 test.t2.oref,func 4 Using where; Using index; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 t2.oref,func 4 Using where; Using index; Full scan on NULL key select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; oref a Z ee NULL NULL @@ -457,7 +457,7 @@ group by grp having min(ie) > 1) Z from t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 -2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort +2 DEPENDENT SUBQUERY t1 ref idx idx 5 t2.oref 2 Using where; Using temporary; Using filesort select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1) Z @@ -572,7 +572,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 Using where; Full scan on NULL key Warnings: -Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,((`test`.`t2`.`a`,`test`.`t2`.`b`),(((`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond((((`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond((((`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond((`test`.`t1`.`ie1`)) and trigcond((`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` drop table t1,t2; create table t1 (oref char(4), grp int, ie int primary key); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index d8478bae258..11cec291d8c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2600,4 +2600,31 @@ SELECT * FROM t1 UNION SELECT c from t2 WHERE c=t1.c); -DROP TABLE t1,t2,t3; +DROP TABLE t1,t2,t3; +# +# Bug#23800: Outer fields in correlated subqueries is used in a temporary +# table created for sorting. +# +CREATE TABLE t1(f1 int); +CREATE TABLE t2(f2 int, f21 int, f3 timestamp); +INSERT INTO t1 VALUES (1),(1),(2),(2); +INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11"), (2,2,"2004-02-29 11:11:11"); +SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1; +SELECT (SELECT SUM(1) FROM t2 ttt GROUP BY t2.f3 LIMIT 1) AS tt FROM t2; +PREPARE stmt1 FROM 'SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)) AS sq FROM t1 GROUP BY f1'; +EXECUTE stmt1; +EXECUTE stmt1; +DEALLOCATE PREPARE stmt1; +SELECT f2, AVG(f21), + (SELECT t.f3 FROM t2 AS t WHERE t2.f2=t.f2 AND t.f3=MAX(t2.f3)) AS test + FROM t2 GROUP BY f2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL); +INSERT INTO t1 VALUES + (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), + (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'), + (3,2,'k'), (3,1,'l'), (1,9,'m'); +SELECT a, MAX(b), + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test + FROM t1 GROUP BY a; +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index 95001809e9a..54aaf573525 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1609,7 +1609,7 @@ void Item_ident_for_show::make_field(Send_field *tmp_field) Item_field::Item_field(Field *f) :Item_ident(0, NullS, *f->table_name, f->field_name), item_equal(0), no_const_subst(0), - have_privileges(0), any_privileges(0) + have_privileges(0), any_privileges(0), fixed_as_field(0) { set_field(f); /* @@ -1623,7 +1623,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, Field *f) :Item_ident(context_arg, f->table->s->db, *f->table_name, f->field_name), item_equal(0), no_const_subst(0), - have_privileges(0), any_privileges(0) + have_privileges(0), any_privileges(0), fixed_as_field(0) { /* We always need to provide Item_field with a fully qualified field @@ -1662,7 +1662,7 @@ Item_field::Item_field(Name_resolution_context *context_arg, const char *field_name_arg) :Item_ident(context_arg, db_arg,table_name_arg,field_name_arg), field(0), result_field(0), item_equal(0), no_const_subst(0), - have_privileges(0), any_privileges(0) + have_privileges(0), any_privileges(0), fixed_as_field(0) { collation.set(DERIVATION_IMPLICIT); } @@ -1675,7 +1675,8 @@ Item_field::Item_field(THD *thd, Item_field *item) item_equal(item->item_equal), no_const_subst(item->no_const_subst), have_privileges(item->have_privileges), - any_privileges(item->any_privileges) + any_privileges(item->any_privileges), + fixed_as_field(item->fixed_as_field) { collation.set(DERIVATION_IMPLICIT); } @@ -3484,8 +3485,46 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) } if (*from_field != view_ref_found) { + prev_subselect_item->used_tables_cache|= (*from_field)->table->map; prev_subselect_item->const_item_cache= 0; + if (!last_checked_context->select_lex->having_fix_field && + !fixed_as_field) + { + Item_outer_ref *rf; + Query_arena *arena= 0, backup; + /* + Each outer field is replaced for an Item_outer_ref object. + This is done in order to get correct results when the outer + select employs a temporary table. + The original fields are saved in the inner_fields_list of the + outer select. This list is created by the following reasons: + 1. We can't add field items to the outer select list directly + because the outer select hasn't been fully fixed yet. + 2. We need a location to refer to in the Item_ref object + so the inner_fields_list is used as such temporary + reference storage. + The new Item_outer_ref object replaces the original field and is + also saved in the inner_refs_list of the outer select. Here + it is only created. It can be fixed only after the original + field has been fixed and this is done in the fix_inner_refs() + function. + */ + set_field(*from_field); + arena= thd->activate_stmt_arena_if_needed(&backup); + rf= new Item_outer_ref(context, this); + if (!rf) + { + if (arena) + thd->restore_active_arena(arena, &backup); + return -1; + } + *reference= rf; + select->inner_refs_list.push_back(rf); + if (arena) + thd->restore_active_arena(arena, &backup); + fixed_as_field= 1; + } if (thd->lex->in_sum_func && thd->lex->in_sum_func->nest_level == thd->lex->current_select->nest_level) @@ -3612,7 +3651,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) { mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, - this, this); + this, (Item_ident*)*reference); if (last_checked_context->select_lex->having_fix_field) { Item_ref *rf; @@ -4818,8 +4857,7 @@ Item_ref::Item_ref(Name_resolution_context *context_arg, /* This constructor used to create some internals references over fixed items */ - DBUG_ASSERT(ref != 0); - if (*ref && (*ref)->fixed) + if (ref && *ref && (*ref)->fixed) set_properties(); } @@ -5119,7 +5157,7 @@ void Item_ref::print(String *str) if (ref) { if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF && - name && alias_name_used) + ref_type() != OUTER_REF && name && alias_name_used) { THD *thd= current_thd; append_identifier(thd, str, name, (uint) strlen(name)); @@ -5367,7 +5405,7 @@ bool Item_direct_ref::get_date(TIME *ltime,uint fuzzydate) /* - Prepare referenced view viewld then call usual Item_direct_ref::fix_fields + Prepare referenced field then call usual Item_direct_ref::fix_fields SYNOPSIS Item_direct_view_ref::fix_fields() @@ -5390,6 +5428,30 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference) return Item_direct_ref::fix_fields(thd, reference); } +/* + Prepare referenced outer field then call usual Item_direct_ref::fix_fields + + SYNOPSIS + Item_outer_ref::fix_fields() + thd thread handler + reference reference on reference where this item stored + + RETURN + FALSE OK + TRUE Error +*/ + +bool Item_outer_ref::fix_fields(THD *thd, Item **reference) +{ + DBUG_ASSERT(*ref); + /* outer_field->check_cols() will be made in Item_direct_ref::fix_fields */ + outer_field->fixed_as_field= 1; + if (!outer_field->fixed && + (outer_field->fix_fields(thd, reference))) + return TRUE; + return Item_direct_ref::fix_fields(thd, reference); +} + /* Compare two view column references for equality. diff --git a/sql/item.h b/sql/item.h index 6c41aa09f80..c2bc483e87b 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1214,7 +1214,7 @@ public: uint have_privileges; /* field need any privileges (for VIEW creation) */ bool any_privileges; - + bool fixed_as_field; Item_field(Name_resolution_context *context_arg, const char *db_arg,const char *table_name_arg, const char *field_name_arg); @@ -1817,7 +1817,7 @@ class Item_ref :public Item_ident protected: void set_properties(); public: - enum Ref_Type { REF, DIRECT_REF, VIEW_REF }; + enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF }; Field *result_field; /* Save result here */ Item **ref; Item_ref(Name_resolution_context *context_arg, @@ -1878,7 +1878,7 @@ public: (*ref)->get_tmp_table_item(thd)); } table_map used_tables() const - { + { return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); } table_map not_null_tables() const { return (*ref)->not_null_tables(); } @@ -1951,6 +1951,40 @@ public: }; +class Item_outer_ref :public Item_direct_ref +{ +public: + Item_field *outer_field; + Item_outer_ref(Name_resolution_context *context_arg, + Item_field *outer_field_arg) + :Item_direct_ref(context_arg, 0, outer_field_arg->table_name, + outer_field_arg->field_name), + outer_field(outer_field_arg) + { + ref= (Item**)&outer_field; + set_properties(); + fixed= 0; + } + void cleanup() + { + ref= (Item**)&outer_field; + fixed= 0; + Item_direct_ref::cleanup(); + outer_field->cleanup(); + } + void save_in_result_field(bool no_conversions) + { + outer_field->save_org_in_field(result_field); + } + bool fix_fields(THD *, Item **); + table_map used_tables() const + { + return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT; + } + virtual Ref_Type ref_type() { return OUTER_REF; } +}; + + class Item_in_subselect; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1dd3c9dceca..792afeca59e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -747,6 +747,8 @@ int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List &fields, List &all_fields, ORDER *order, bool *hidden_group_fields); +bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, + Item **ref_pointer_array); bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 94d753eb703..749ee04493b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -353,6 +353,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) Item *fake_conds= 0; SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_delete"); + List all_fields; thd->lex->allow_sum_func= 0; if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context, @@ -376,6 +377,11 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) DBUG_RETURN(TRUE); } } + + if (select_lex->inner_refs_list.elements && + fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array)) + DBUG_RETURN(-1); + select_lex->fix_prepare_information(thd, conds, &fake_conds); DBUG_RETURN(FALSE); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ce76c35b33c..c3e18394c41 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1192,6 +1192,7 @@ void st_select_lex::init_select() is_correlated= 0; cur_pos_in_select_list= UNDEF_POS; non_agg_fields.empty(); + inner_refs_list.empty(); } /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index ae2b0d30a9c..f8d8e6efcb2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -547,7 +547,8 @@ public: bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */ /* TRUE when having fix field called in processing of this SELECT */ bool having_fix_field; - + /* List of references to fields referenced from inner selects */ + List inner_refs_list; /* Number of Item_sum-derived objects in this SELECT */ uint n_sum_items; /* Number of Item_sum-derived objects in children and descendant SELECTs */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 63f2604a934..2f2eb0ecca1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -268,6 +268,70 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, } +/* + Fix fields referenced from inner selects. + + SYNOPSIS + fix_inner_refs() + thd Thread handle + all_fields List of all fields used in select + select Current select + ref_pointer_array Array of references to Items used in current select + + DESCRIPTION + The function fixes fields referenced from inner selects and + also fixes references (Item_ref objects) to these fields. Each field + is fixed as a usual hidden field of the current select - it is added + to the all_fields list and the pointer to it is saved in the + ref_pointer_array if latter is provided. + After the field has been fixed we proceed with fixing references + (Item_ref objects) to this field from inner subqueries. If the + ref_pointer_array is provided then Item_ref objects is set to + reference element in that array with the pointer to the field. + + RETURN + TRUE an error occured + FALSE ok +*/ + +bool +fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, + Item **ref_pointer_array) +{ + Item_outer_ref *ref; + bool res= FALSE; + List_iterator ref_it(select->inner_refs_list); + while ((ref= ref_it++)) + { + Item_field *item= ref->outer_field; + /* + TODO: this field item already might be present in the select list. + In this case instead of adding new field item we could use an + existing one. The change will lead to less operations for copying fields, + smaller temporary tables and less data passed through filesort. + */ + if (ref_pointer_array) + { + int el= all_fields.elements; + ref_pointer_array[el]= (Item*)item; + /* Add the field item to the select list of the current select. */ + all_fields.push_front((Item*)item); + /* + If it's needed reset each Item_ref item that refers this field with + a new reference taken from ref_pointer_array. + */ + ref->ref= ref_pointer_array + el; + } + if (!ref->fixed && ref->fix_fields(thd, 0)) + { + res= TRUE; + break; + } + thd->used_tables|= item->used_tables(); + } + return res; +} + /* Function to setup clauses without sum functions */ @@ -395,6 +459,10 @@ JOIN::prepare(Item ***rref_pointer_array, if (having && having->with_sum_func) having->split_sum_func2(thd, ref_pointer_array, all_fields, &having, TRUE); + if (select_lex->inner_refs_list.elements && + fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array)) + DBUG_RETURN(-1); + if (select_lex->inner_sum_func_list) { Item_sum *end=select_lex->inner_sum_func_list; @@ -5133,13 +5201,15 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, key_part->length, keyuse->val); } - else if (keyuse->val->type() == Item::FIELD_ITEM) + else if (keyuse->val->type() == Item::FIELD_ITEM || + (keyuse->val->type() == Item::REF_ITEM && + ((Item_ref*)keyuse->val)->ref_type() == Item_ref::OUTER_REF) ) return new store_key_field(thd, key_part->field, key_buff + maybe_null, maybe_null ? key_buff : 0, key_part->length, - ((Item_field*) keyuse->val)->field, + ((Item_field*) keyuse->val->real_item())->field, keyuse->val->full_name()); return new store_key_item(thd, key_part->field, @@ -8697,7 +8767,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, type they needed to be handled separately. */ if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || - type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE) + type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE || + type == MYSQL_TYPE_TIMESTAMP) new_field= item->tmp_table_field_from_field_type(table); /* Make sure that the blob fits into a Field_varstring which has @@ -8804,8 +8875,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item *orig_item= 0; if (type != Item::FIELD_ITEM && - item->real_item()->type() == Item::FIELD_ITEM && - !((Item_ref *) item)->depended_from) + item->real_item()->type() == Item::FIELD_ITEM) { orig_item= item; item= item->real_item(); @@ -13465,8 +13535,7 @@ count_field_types(TMP_TABLE_PARAM *param, List &fields, { Item::Type type=field->type(); Item::Type real_type= field->real_item()->type(); - if (type == Item::FIELD_ITEM || (real_type == Item::FIELD_ITEM && - !((Item_ref *) field)->depended_from)) + if (real_type == Item::FIELD_ITEM) param->field_count++; else if (real_type == Item::SUM_FUNC_ITEM) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 1db77f8704c..60b7ac1df1c 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -134,6 +134,7 @@ int mysql_update(THD *thd, READ_RECORD info; SELECT_LEX *select_lex= &thd->lex->select_lex; bool need_reopen; + List all_fields; DBUG_ENTER("mysql_update"); LINT_INIT(timestamp_query_id); @@ -226,6 +227,10 @@ int mysql_update(THD *thd, DBUG_RETURN(1); /* purecov: inspected */ } + if (select_lex->inner_refs_list.elements && + fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array)) + DBUG_RETURN(-1); + if (conds) { Item::cond_result cond_value; From ddb5a5636cfac14560d4a15c608b0c6f0e3477cd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Feb 2007 14:11:01 +0100 Subject: [PATCH 54/78] Bug #24010: INSERT INTO ... SELECT fails on unique constraint with data it doesn't select. This bug was fixed along with bug #16861: User defined variable can have a wrong value if a tmp table was used. There the fix consisted of Item_func_set_user_var overloading the method Item::save_in_field. Consider the query from the test case: INSERT INTO foo( bar, baz ) SELECT bar, @newBaz := 1 + baz FROM foo WHERE quux <= 0.1; Here the assignment expression '@newBaz := 1 + baz' is represented by an Item_func_set_user_var. Its member method save_in_field, which writes the value of this assignment into the result field, writes the val_xxx() value, which is not updated at this point. In the fix introduced by the patch, the save_in_field method reads the actual variable value instead. See also comment for ChangeSet@1.2368.1.3, 2007-01-09 23:24:56+03:00, evgen@moonbone.local +4 -0 and comment for Item_func_set_user_var::save_in_field (item_func.cc) mysql-test/r/update.result: BUG#24010 The correct, and expected, result mysql-test/t/update.test: BUG#24010 The test case for this bug. When the bug is active, the INSERT ... SELECT statement will try to insert the values <1, 2> which gives an error --- mysql-test/r/update.result | 19 +++++++++++++++++++ mysql-test/t/update.test | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 9e2bc52657a..b3c5760e2c9 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -434,3 +434,22 @@ Handler_read_prev 0 Handler_read_rnd 0 Handler_read_rnd_next 21 DROP TABLE t1; +CREATE TABLE t1 ( +a INT(11), +quux decimal( 31, 30 ), +UNIQUE KEY bar (a), +KEY quux (quux) +); +INSERT INTO +t1 ( a, quux ) +VALUES +( 1, 1 ), +( 2, 0.1 ); +INSERT INTO t1( a ) +SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1; +SELECT * FROM t1; +a quux +1 1.000000000000000000000000000000 +2 0.100000000000000000000000000000 +3 NULL +DROP TABLE t1; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 3ce7ef72670..23ee75d61ea 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -342,3 +342,29 @@ UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999; show status like '%Handler_read%'; DROP TABLE t1; + +# +# Bug #24010: INSERT INTO ... SELECT fails on unique constraint with data it +# doesn't select +# +CREATE TABLE t1 ( + + a INT(11), + quux decimal( 31, 30 ), + + UNIQUE KEY bar (a), + KEY quux (quux) +); + +INSERT INTO + t1 ( a, quux ) +VALUES + ( 1, 1 ), + ( 2, 0.1 ); + +INSERT INTO t1( a ) + SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1; + +SELECT * FROM t1; + +DROP TABLE t1; From 50bd97a9436afe01606ad0cef323e7bda4d77e9b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Feb 2007 16:59:57 +0200 Subject: [PATCH 55/78] Fixed compiler warnings (for linux and win32 and win64) Fixed a couple of usage of not initialized warnings (unlikely cases) client/mysqldump.c: Fixed compiler warnings from 'max' build client/mysqltest.c: Removed compiler warnings cmd-line-utils/readline/xmalloc.c: Fixed compiler warnings from 'max' build extra/comp_err.c: Fixed compiler warnings from 'max' build extra/yassl/include/openssl/ssl.h: Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit extra/yassl/include/socket_wrapper.hpp: Moved socket_t to ssl.h, to be able to removed compiler warnings on windows 64 bit extra/yassl/src/ssl.cpp: Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit extra/yassl/taocrypt/src/integer.cpp: Fixed compiler warnings include/my_global.h: Added my_offsetof() macro from 5.1 to get rid of compiler warnings innobase/include/ut0byte.ic: Fixed compiler warnings on win64 innobase/include/ut0ut.ic: Fixed compiler warnings on win64 libmysql/libmysql.def: Fixed compiler warnings on win64 myisam/mi_packrec.c: Fixed compiler warnings on win64 myisam/myisamchk.c: Fixed compiler warnings from 'max' build mysys/base64.c: Fixed compiler warnings on win64 mysys/mf_keycache.c: Fixed compiler warnings from 'max' build mysys/my_getopt.c: Fixed compiler warnings from 'max' build mysys/my_init.c: Fixed compiler warnings from 'max' build mysys/my_thr_init.c: Fixed compiler warnings mysys/ptr_cmp.c: Fixed compiler warnings from 'max' build ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/mysqlmanager.cc: Fixed compiler warnings sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/ha_berkeley.cc: Moved get_auto_primary_key() here as int5store() gives (wrong) compiler warnings in win64 sql/ha_berkeley.h: Moved get_auto_primary_key() to ha_berkeley.cc sql/ha_innodb.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings from 'max' build sql/item_timefunc.cc: Fixed compiler warnings sql/mysqld.cc: Fixed compiler warnings sql/sql_acl.cc: Fixed compiler warnings from 'max' build sql/sql_base.cc: Fixed compiler warnings from 'max' build sql/sql_insert.cc: Initialize variable that may be used unitialized on error conditions (not fatal) sql/sql_prepare.cc: Fixed compiler warnings from 'max' build sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/udf_example.def: Fixed compiler warnings on win64 sql/unireg.cc: Initialize variable that may be used unitialized on error conditions strings/ctype-ucs2.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings support-files/compiler_warnings.supp: Ignore warnings from sql_yacc.cc that are hard to remove Ignore some not important warnings from windows 64 bit build tools/mysqlmanager.c: Fixed compiler warnings --- client/mysqldump.c | 4 ++-- client/mysqltest.c | 17 +++++++++-------- cmd-line-utils/readline/xmalloc.c | 4 ++-- extra/comp_err.c | 4 ++++ extra/yassl/include/openssl/ssl.h | 8 ++++++-- extra/yassl/include/socket_wrapper.hpp | 6 ++---- extra/yassl/src/ssl.cpp | 2 +- extra/yassl/taocrypt/src/integer.cpp | 2 +- include/my_global.h | 15 +++++++++++++++ innobase/include/ut0byte.ic | 4 ++-- innobase/include/ut0ut.ic | 2 +- libmysql/libmysql.def | 1 - myisam/mi_packrec.c | 2 +- myisam/myisamchk.c | 1 + mysys/base64.c | 4 ++-- mysys/mf_keycache.c | 5 ++++- mysys/my_getopt.c | 1 + mysys/my_init.c | 2 ++ mysys/my_thr_init.c | 6 +++--- mysys/ptr_cmp.c | 2 +- ndb/include/kernel/signaldata/DictTabInfo.hpp | 10 +++++----- .../instance-manager/mysql_connection.cc | 2 +- server-tools/instance-manager/mysqlmanager.cc | 2 +- sql/filesort.cc | 2 +- sql/ha_berkeley.cc | 10 ++++++++++ sql/ha_berkeley.h | 8 +------- sql/ha_innodb.cc | 9 ++++++--- sql/item.cc | 2 ++ sql/item_timefunc.cc | 2 +- sql/mysqld.cc | 4 ++-- sql/sql_acl.cc | 2 ++ sql/sql_base.cc | 1 + sql/sql_insert.cc | 1 + sql/sql_prepare.cc | 1 + sql/sql_select.cc | 4 ++-- sql/sql_show.cc | 7 ++++--- sql/udf_example.def | 1 - sql/unireg.cc | 3 +++ strings/ctype-ucs2.c | 5 ++++- strings/ctype-utf8.c | 2 ++ strings/decimal.c | 3 +++ support-files/compiler_warnings.supp | 8 ++++++++ tools/mysqlmanager.c | 2 +- 43 files changed, 122 insertions(+), 61 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 6863de93224..94ab9dac5ac 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2016,7 +2016,8 @@ continue_xml: */ -static void dump_triggers_for_table(char *table, char *db) +static void dump_triggers_for_table(char *table, + char *db __attribute__((unused))) { char *result_table; char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3]; @@ -2025,7 +2026,6 @@ static void dump_triggers_for_table(char *table, char *db) FILE *sql_file= md_result_file; MYSQL_RES *result; MYSQL_ROW row; - DBUG_ENTER("dump_triggers_for_table"); DBUG_PRINT("enter", ("db: %s, table: %s", db, table)); diff --git a/client/mysqltest.c b/client/mysqltest.c index 15f2e161ba8..616077fea9b 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1844,7 +1844,7 @@ void do_copy_file(struct st_command *command) void do_chmod_file(struct st_command *command) { - ulong mode= 0; + long mode= 0; static DYNAMIC_STRING ds_mode; static DYNAMIC_STRING ds_file; const struct command_arg chmod_file_args[] = { @@ -1864,7 +1864,7 @@ void do_chmod_file(struct st_command *command) die("You must write a 4 digit octal number for mode"); DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str)); - handle_command_error(command, chmod(ds_file.str, mode)); + handle_command_error(command, chmod(ds_file.str, (mode_t) mode)); dynstr_free(&ds_mode); dynstr_free(&ds_file); DBUG_VOID_RETURN; @@ -6275,7 +6275,8 @@ typedef struct st_replace_found { void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds, - const char *str, int len) + const char *str, + int len __attribute__((unused))) { reg1 REPLACE *rep_pos; reg2 REPLACE_STRING *rep_str; @@ -6666,7 +6667,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, we need at least what we have so far in the buffer + the part before this match */ - need_buf_len= (res_p - buf) + subs[0].rm_so; + need_buf_len= (res_p - buf) + (int) subs[0].rm_so; /* on this pass, calculate the memory for the result buffer */ while (expr_p < replace_end) @@ -6676,17 +6677,17 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, if (c == '\\' && expr_p + 1 < replace_end) { - back_ref_num= expr_p[1] - '0'; + back_ref_num= (int) (expr_p[1] - '0'); } /* found a valid back_ref (eg. \1)*/ if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub) { - int start_off,end_off; + regoff_t start_off, end_off; if ((start_off=subs[back_ref_num].rm_so) > -1 && (end_off=subs[back_ref_num].rm_eo) > -1) { - need_buf_len += (end_off - start_off); + need_buf_len += (int) (end_off - start_off); } expr_p += 2; } @@ -6706,7 +6707,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, /* copy the pre-match part */ if (subs[0].rm_so) { - memcpy(res_p, str_p, subs[0].rm_so); + memcpy(res_p, str_p, (size_t) subs[0].rm_so); res_p+= subs[0].rm_so; } diff --git a/cmd-line-utils/readline/xmalloc.c b/cmd-line-utils/readline/xmalloc.c index 698807addf9..848a3563fa9 100644 --- a/cmd-line-utils/readline/xmalloc.c +++ b/cmd-line-utils/readline/xmalloc.c @@ -57,7 +57,7 @@ xmalloc (bytes) temp = malloc (bytes); if (temp == 0) - memory_error_and_abort ("xmalloc"); + memory_error_and_abort ((char*) "xmalloc"); return (temp); } @@ -71,7 +71,7 @@ xrealloc (pointer, bytes) temp = pointer ? realloc (pointer, bytes) : malloc (bytes); if (temp == 0) - memory_error_and_abort ("xrealloc"); + memory_error_and_abort ((char*) "xrealloc"); return (temp); } diff --git a/extra/comp_err.c b/extra/comp_err.c index df6df1678a6..a9bda6e3124 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -41,7 +41,9 @@ static char *NAMEFILE= (char*) "mysqld_ername.h"; static char *STATEFILE= (char*) "sql_state.h"; static char *TXTFILE= (char*) "../sql/share/errmsg.txt"; static char *DATADIRECTORY= (char*) "../sql/share/"; +#ifndef DBUG_OFF static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace"; +#endif /* Header for errmsg.sys files */ uchar file_head[]= { 254, 254, 2, 1 }; @@ -402,6 +404,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error, int rcount= 0; DBUG_ENTER("parse_input_file"); + *top_error= 0; + *top_lang= 0; if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME)))) DBUG_RETURN(0); diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 16110c52f43..d0c49d6816c 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -33,7 +33,6 @@ #include "opensslv.h" /* for version number */ #include "rsa.h" - #define YASSL_VERSION "1.5.8" @@ -190,11 +189,16 @@ enum { /* ERR Constants */ EVP_R_BAD_DECRYPT = 2 }; +#ifdef WIN + typedef SOCKET socket_t; +#else + typedef int socket_t; +#endif SSL_CTX* SSL_CTX_new(SSL_METHOD*); SSL* SSL_new(SSL_CTX*); -int SSL_set_fd (SSL*, int); +int SSL_set_fd (SSL*, socket_t); int SSL_connect(SSL*); int SSL_write(SSL*, const void*, int); int SSL_read(SSL*, void*, int); diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 308704c2af0..de28778ead9 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -38,16 +38,14 @@ #include #include #endif +#include "openssl/ssl.h" /* for socket_t */ namespace yaSSL { typedef unsigned int uint; -#ifdef _WIN32 - typedef SOCKET socket_t; -#else - typedef int socket_t; +#ifndef _WIN32 const socket_t INVALID_SOCKET = -1; const int SD_RECEIVE = 0; const int SD_SEND = 1; diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 837121c249d..1f9d0dd4020 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -229,7 +229,7 @@ void SSL_free(SSL* ssl) } -int SSL_set_fd(SSL* ssl, int fd) +int SSL_set_fd(SSL* ssl, socket_t fd) { ssl->useSocket().set_fd(fd); return SSL_SUCCESS; diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 419783403ea..84255aa8544 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -3390,7 +3390,7 @@ void Integer::DivideByPowerOf2(Integer &r, Integer &q, const Integer &a, CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount); SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount); if (n % WORD_BITS != 0) - r.reg_[wordCount-1] %= (1 << (n % WORD_BITS)); + r.reg_[wordCount-1] %= ((word) 1 << (n % WORD_BITS)); } else { diff --git a/include/my_global.h b/include/my_global.h index 23fe71caa8d..21fe1ebc3cb 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -846,6 +846,21 @@ typedef long long my_ptrdiff_t; #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) +/* + Custom version of standard offsetof() macro which can be used to get + offsets of members in class for non-POD types (according to the current + version of C++ standard offsetof() macro can't be used in such cases and + attempt to do so causes warnings to be emitted, OTOH in many cases it is + still OK to assume that all instances of the class has the same offsets + for the same members). + + This is temporary solution which should be removed once File_parser class + and related routines are refactored. +*/ + +#define my_offsetof(TYPE, MEMBER) \ + ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10)) + #define NullS (char *) 0 /* Nowdays we do not support MessyDos */ #ifndef NEAR diff --git a/innobase/include/ut0byte.ic b/innobase/include/ut0byte.ic index e141de3aa3f..3d268325674 100644 --- a/innobase/include/ut0byte.ic +++ b/innobase/include/ut0byte.ic @@ -388,8 +388,8 @@ ut_bit_set_nth( ut_ad(TRUE == 1); if (val) { - return((1 << n) | a); + return(((ulint) 1 << n) | a); } else { - return(~(1 << n) & a); + return(~((ulint) 1 << n) & a); } } diff --git a/innobase/include/ut0ut.ic b/innobase/include/ut0ut.ic index 9a0ef1c0d5b..4bbb4eac3c3 100644 --- a/innobase/include/ut0ut.ic +++ b/innobase/include/ut0ut.ic @@ -170,5 +170,5 @@ ut_2_exp( /* out: 2 to power n */ ulint n) /* in: number */ { - return(1 << n); + return((ulint) 1 << n); } diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index cf45e20a697..8c6b71d9553 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -1,5 +1,4 @@ LIBRARY LIBMYSQL -DESCRIPTION 'MySQL 5.0 Client Library' VERSION 6.0 EXPORTS _dig_vec_lower diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 6df64ae2cd4..0bd13d228d1 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -564,7 +564,7 @@ static void fill_quick_table(uint16 *table, uint bits, uint max_bits, */ value|= (max_bits - bits) << 8 | IS_CHAR; - for (end= table + (1 << bits); table < end; table++) + for (end= table + ((uint) 1 << bits); table < end; table++) { *table= (uint16) value; } diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index eab06525cd4..0332644c5a6 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -720,6 +720,7 @@ get_one_option(int optid, case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; break; + default: assert(0); /* Impossible */ } check_param.stats_method= method_conv; break; diff --git a/mysys/base64.c b/mysys/base64.c index 6a6b7eae359..47b93942784 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -98,10 +98,10 @@ base64_encode(const void *src, size_t src_len, char *dst) } -static inline unsigned +static inline uint pos(unsigned char c) { - return strchr(base64_table, c) - base64_table; + return (uint) (strchr(base64_table, c) - base64_table); } diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 0762d10ab08..87f136dbf81 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -167,8 +167,10 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, struct st_my_thread_var *thread); #endif static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block); +#ifndef DBUG_OFF static void test_key_cache(KEY_CACHE *keycache, const char *where, my_bool lock); +#endif #define KEYCACHE_HASH(f, pos) \ (((ulong) ((pos) >> keycache->key_cache_shift)+ \ @@ -2605,7 +2607,8 @@ static int flush_all_key_blocks(KEY_CACHE *keycache) 0 on success (always because it can't fail) */ -int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache) +int reset_key_cache_counters(const char *name __attribute__((unused)), + KEY_CACHE *key_cache) { DBUG_ENTER("reset_key_cache_counters"); if (!key_cache->key_cache_inited) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 250c10e8479..623c48b2e55 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -194,6 +194,7 @@ int handle_options(int *argc, char ***argv, Find first the right option. Return error in case of an ambiguous, or unknown option */ + LINT_INIT(prev_found); optp= longopts; if (!(opt_found= findopt(opt_str, length, &optp, &prev_found))) { diff --git a/mysys/my_init.c b/mysys/my_init.c index cc4bef10e8d..2bcf5f44c4d 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -197,7 +197,9 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", } if (!(infoflag & MY_DONT_FREE_DBUG)) + { DBUG_END(); /* Must be done before my_thread_end */ + } #ifdef THREAD my_thread_end(); my_thread_global_end(); diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 67ab1e4a38a..7a5fdbf8ad6 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -54,8 +54,8 @@ pthread_mutexattr_t my_errorcheck_mutexattr; race conditions in NPTL pthread_exit code. */ -static -pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) +static pthread_handler_t +nptl_pthread_exit_hack_handler(void *arg __attribute__((unused))) { /* Do nothing! */ pthread_exit(0); @@ -400,9 +400,9 @@ const char *my_thread_name(void) static uint get_thread_lib(void) { +#ifdef _CS_GNU_LIBPTHREAD_VERSION char buff[64]; -#ifdef _CS_GNU_LIBPTHREAD_VERSION confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff)); if (!strncasecmp(buff, "NPTL", 4)) diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index a3bc3702c34..33c28160a4c 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -185,7 +185,7 @@ my_off_t my_get_ptr(byte *ptr, uint pack_length) case 3: pos= (my_off_t) mi_uint3korr(ptr); break; case 2: pos= (my_off_t) mi_uint2korr(ptr); break; case 1: pos= (my_off_t) mi_uint2korr(ptr); break; - default: DBUG_ASSERT(0); + default: DBUG_ASSERT(0); return 0; } return pos; } diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 57111a8aea1..9f4898174fe 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -46,17 +46,17 @@ inline int my_decimal_get_binary_size(uint precision, uint scale) #endif #define DTIMAP(x, y, z) \ - { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 } + { DictTabInfo::y, my_offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 } #define DTIMAP2(x, y, z, u, v) \ - { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, u, v, 0 } + { DictTabInfo::y, my_offsetof(x, z), SimpleProperties::Uint32Value, u, v, 0 } #define DTIMAPS(x, y, z, u, v) \ - { DictTabInfo::y, offsetof(x, z), SimpleProperties::StringValue, u, v, 0 } + { DictTabInfo::y, my_offsetof(x, z), SimpleProperties::StringValue, u, v, 0 } #define DTIMAPB(x, y, z, u, v, l) \ - { DictTabInfo::y, offsetof(x, z), SimpleProperties::BinaryValue, u, v, \ - offsetof(x, l) } + { DictTabInfo::y, my_offsetof(x, z), SimpleProperties::BinaryValue, u, v, \ + my_offsetof(x, l) } #define DTIBREAK(x) \ { DictTabInfo::x, 0, SimpleProperties::InvalidValue, 0, 0, 0 } diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc index 32618a6cdd6..3e1694e24ee 100644 --- a/server-tools/instance-manager/mysql_connection.cc +++ b/server-tools/instance-manager/mysql_connection.cc @@ -135,7 +135,7 @@ int Mysql_connection_thread::init() /* Initialize random number generator */ { ulong seed1= (ulong) &rand_st + rand(); - ulong seed2= rand() + time(0); + ulong seed2= rand() + (ulong) time(0); randominit(&rand_st, seed1, seed2); } /* Fill scramble - server's random message used for handshake */ diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index 2b6921d59aa..66fc0b68ac4 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -199,7 +199,7 @@ static void init_environment(char *progname) MY_INIT(progname); log_init(); umask(0117); - srand(time(0)); + srand((uint) time(0)); } diff --git a/sql/filesort.cc b/sql/filesort.cc index 93fa566349c..e40c492fe8e 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -98,7 +98,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, uint maxbuffer; BUFFPEK *buffpek; ha_rows records= HA_POS_ERROR; - uchar **sort_keys; + uchar **sort_keys= 0; IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile; SORTPARAM param; bool multi_byte_charset; diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index d63935f1a9c..e78808e3308 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -233,6 +233,7 @@ static int berkeley_close_connection(THD *thd) return 0; } + bool berkeley_flush_logs() { int error; @@ -439,6 +440,15 @@ ulong ha_berkeley::index_flags(uint idx, uint part, bool all_parts) const } +void ha_berkeley::get_auto_primary_key(byte *to) +{ + pthread_mutex_lock(&share->mutex); + share->auto_ident++; + int5store(to,share->auto_ident); + pthread_mutex_unlock(&share->mutex); +} + + static int berkeley_cmp_hidden_key(DB* file, const DBT *new_key, const DBT *saved_key) { diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 051990b0ee5..336c90f009a 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -141,13 +141,7 @@ class ha_berkeley: public handler enum thr_lock_type lock_type); void get_status(); - inline void get_auto_primary_key(byte *to) - { - pthread_mutex_lock(&share->mutex); - share->auto_ident++; - int5store(to,share->auto_ident); - pthread_mutex_unlock(&share->mutex); - } + void get_auto_primary_key(byte *to); ulonglong get_auto_increment(); void print_error(int error, myf errflag); uint8 table_cache_type() { return HA_CACHE_TBL_TRANSACT; } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index d854c362df8..8a35ff000a8 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2711,7 +2711,8 @@ ha_innobase::store_key_val_for_row( true_len = (ulint) cs->cset->well_formed_len(cs, (const char *) data, (const char *) data + len, - key_len / cs->mbmaxlen, + (uint) (key_len / + cs->mbmaxlen), &error); } @@ -2780,7 +2781,8 @@ ha_innobase::store_key_val_for_row( (const char *) blob_data, (const char *) blob_data + blob_len, - key_len / cs->mbmaxlen, + (uint) (key_len / + cs->mbmaxlen), &error); } @@ -2852,7 +2854,8 @@ ha_innobase::store_key_val_for_row( (const char *)src_start, (const char *)src_start + key_len, - key_len / cs->mbmaxlen, + (uint) (key_len / + cs->mbmaxlen), &error); } } diff --git a/sql/item.cc b/sql/item.cc index 205ae49a3cb..4c346070f10 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1521,6 +1521,8 @@ bool agg_item_charsets(DTCollation &coll, const char *fname, doesn't display each argument's characteristics. - if nargs is 1, then this error cannot happen. */ + LINT_INIT(safe_args[0]); + LINT_INIT(safe_args[1]); if (nargs >=2 && nargs <= 3) { safe_args[0]= args[0]; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 8b4e93fa085..683cd8803d6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1608,7 +1608,7 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions) void Item_func_sysdate_local::store_now_in_TIME(TIME *now_time) { THD *thd= current_thd; - thd->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL)); + thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL)); thd->time_zone_used= 1; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fe3ba1c6d5a..74aad27d0fe 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -324,6 +324,7 @@ static I_List thread_cache; #ifndef EMBEDDED_LIBRARY static struct passwd *user_info; static pthread_t select_thread; +static uint thr_kill_signal; #endif static pthread_cond_t COND_thread_cache, COND_flush_thread_cache; @@ -522,7 +523,6 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; pthread_cond_t COND_refresh,COND_thread_count, COND_global_read_lock; pthread_t signal_thread; pthread_attr_t connection_attrib; -static uint thr_kill_signal; File_parser_dummy_hook file_parser_dummy_hook; @@ -3216,7 +3216,7 @@ server."); #ifdef HAVE_REPLICATION if (opt_bin_log && expire_logs_days) { - long purge_time= time(0) - expire_logs_days*24*60*60; + long purge_time= (long) (time(0) - expire_logs_days*24*60*60); if (purge_time >= 0) mysql_bin_log.purge_logs_before_date(purge_time); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 39a38f3c44e..298fb61d5f0 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5021,6 +5021,8 @@ static int handle_grant_struct(uint struct_no, bool drop, user= grant_name->user; host= grant_name->host.hostname; break; + default: + assert(0); } if (! user) user= ""; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ad9cd5985d1..767b955252c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2975,6 +2975,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, if (nj_col->view_field) { Item *item; + LINT_INIT(arena); if (register_tree_change) arena= thd->activate_stmt_arena_if_needed(&backup); /* diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index aa429f9250e..3e7c3d15e78 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -410,6 +410,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, #ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) { + res= 1; if (thd->locked_tables) { DBUG_ASSERT(table_list->db); /* Must be set in the parser */ diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ccf70444385..774b82ce618 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2015,6 +2015,7 @@ void mysql_sql_stmt_prepare(THD *thd) uint query_len; DBUG_ENTER("mysql_sql_stmt_prepare"); DBUG_ASSERT(thd->protocol == &thd->protocol_simple); + LINT_INIT(query_len); if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bbb76616733..63c8ddad3ae 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8081,7 +8081,7 @@ static uint build_bitmap_for_nested_joins(List *join_list, */ if (nested_join->join_list.elements != 1) { - nested_join->nj_map= 1 << first_unused++; + nested_join->nj_map= (nested_join_map) 1 << first_unused++; first_unused= build_bitmap_for_nested_joins(&nested_join->join_list, first_unused); } @@ -10056,6 +10056,7 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) enum_nested_loop_state error= NESTED_LOOP_OK; JOIN_TAB *join_tab; DBUG_ENTER("do_select"); + LINT_INIT(join_tab); join->procedure=procedure; join->tmp_table= table; /* Save for easy recursion */ @@ -10100,7 +10101,6 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) else { DBUG_ASSERT(join->tables); - DBUG_ASSERT(join_tab); error= sub_select(join,join_tab,0); if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS) error= sub_select(join,join_tab,1); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c2b2c77fbda..c4b06934fc3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2515,20 +2515,21 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, if (file->create_time) { thd->variables.time_zone->gmt_sec_to_TIME(&time, - file->create_time); + (my_time_t) file->create_time); table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); table->field[14]->set_notnull(); } if (file->update_time) { thd->variables.time_zone->gmt_sec_to_TIME(&time, - file->update_time); + (my_time_t) file->update_time); table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); table->field[15]->set_notnull(); } if (file->check_time) { - thd->variables.time_zone->gmt_sec_to_TIME(&time, file->check_time); + thd->variables.time_zone->gmt_sec_to_TIME(&time, + (my_time_t) file->check_time); table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); table->field[16]->set_notnull(); } diff --git a/sql/udf_example.def b/sql/udf_example.def index ee107d58e51..7a87147d7b6 100644 --- a/sql/udf_example.def +++ b/sql/udf_example.def @@ -1,5 +1,4 @@ LIBRARY udf_example -DESCRIPTION 'MySQL Sample for UDF' VERSION 1.0 EXPORTS lookup diff --git a/sql/unireg.cc b/sql/unireg.cc index 033daa20524..06b2e0c10a2 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -839,7 +839,10 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, field->field_name, &table); if (!regfield) + { + error= 1; goto err; // End of memory + } if (!(field->flags & NOT_NULL_FLAG)) { diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index baee37c103b..6b1ba3c1ef6 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -206,6 +206,7 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); while ( s < se && t < te ) { @@ -320,7 +321,8 @@ static int my_strncasecmp_ucs2(CHARSET_INFO *cs, const char *se=s+len; const char *te=t+len; MY_UNICASE_INFO **uni_plane= cs->caseinfo; - + LINT_INIT(s_wc); + while ( s < se && t < te ) { int plane; @@ -1382,6 +1384,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, my_wc_t s_wc,t_wc; const uchar *se=s+slen; const uchar *te=t+tlen; + LINT_INIT(s_wc); while ( s < se && t < te ) { diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index a3403579181..0e28ff7e342 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2310,6 +2310,7 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); while ( s < se && t < te ) { @@ -2379,6 +2380,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, my_wc_t s_wc,t_wc; const uchar *se= s+slen, *te= t+tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE diff_if_only_endspace_difference= 0; diff --git a/strings/decimal.c b/strings/decimal.c index bfbf6187064..ea92174bfc8 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1356,6 +1356,7 @@ int bin2decimal(char *from, decimal_t *to, int precision, int scale) { int i=dig2bytes[intg0x]; dec1 x; + LINT_INIT(x); switch (i) { case 1: x=mi_sint1korr(from); break; @@ -1397,6 +1398,7 @@ int bin2decimal(char *from, decimal_t *to, int precision, int scale) { int i=dig2bytes[frac0x]; dec1 x; + LINT_INIT(x); switch (i) { case 1: x=mi_sint1korr(from); break; @@ -1483,6 +1485,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, sanity(to); + LINT_INIT(round_digit); switch (mode) { case HALF_UP: case HALF_EVEN: round_digit=5; break; diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index d97ffbfafe2..9e18bee0f9e 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -2,3 +2,11 @@ DictTabInfo.cpp : .*invalid access to non-static.* DictTabInfo.cpp : .*macro was used incorrectly.* DbdihMain.cpp : .*unused variable.* : 6666-6705 DbtupExecQuery.cpp : .*unused variable.* : 1448-1449 +sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.* + +# +# Ignore all conversion warnings on windows 64 +# (Is safe as we are not yet supporting strings >= 2G) +# +.* : conversion from 'size_t' to .*int'.* +.* : conversion from '__int64' to .*int'.* diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 6a8621fac42..f952a5806b4 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -1312,7 +1312,7 @@ static void usage() static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument) + char *argument __attribute__((unused))) { switch (optid) { case '#': From 77db97540964830edd35906aa8447d4beb776ad8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Feb 2007 20:20:49 +0200 Subject: [PATCH 56/78] Portability fix Suppress compiler warnings from bdb and (for the moment) warnings from ndb client/mysqltest.c: Portability fix for windows (windows doesn't have mode_t) support-files/compiler_warnings.supp: Suppress warnings from bdb and (for the moment) warnings from ndb --- client/mysqltest.c | 2 +- support-files/compiler_warnings.supp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 616077fea9b..28de470769e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1864,7 +1864,7 @@ void do_chmod_file(struct st_command *command) die("You must write a 4 digit octal number for mode"); DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str)); - handle_command_error(command, chmod(ds_file.str, (mode_t) mode)); + handle_command_error(command, chmod(ds_file.str, mode)); dynstr_free(&ds_mode); dynstr_free(&ds_file); DBUG_VOID_RETURN; diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 9e18bee0f9e..8f5f3408b44 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -4,9 +4,23 @@ DbdihMain.cpp : .*unused variable.* : 6666-6705 DbtupExecQuery.cpp : .*unused variable.* : 1448-1449 sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.* +# +# bdb is not critical to keep up to date +# +.*/bdb/.* : .*discards qualifiers from pointer target type.* +.*/bdb/.* : .*unused parameter.* +.*/bdb/.* : .*may be used uninitialized.* +.*/bdb/.* : .*empty body in an if-statement.* +db_vrfy.c : .*comparison is always false due to limited range of data type.* + # # Ignore all conversion warnings on windows 64 # (Is safe as we are not yet supporting strings >= 2G) # .* : conversion from 'size_t' to .*int'.* .* : conversion from '__int64' to .*int'.* + +# +# The following should be fixed by the ndb team +# +.*/ndb/.* : .*used uninitialized in this function.* From 8c07265ce1444b0c6cf0d6938ef934ae7c9f8587 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Feb 2007 15:32:51 +0100 Subject: [PATCH 57/78] the fix for BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" didn't make it into 5.0.36 and 5.1.16, so we need to adjust the bug-detection-based-on-version-number code. Because the rpl tree has a too old version, rpl_insert_id cannot pass, so I disable it (like is already the case in 5.1-rpl for the same reason), and the repl team will re-enable it when they merge 5.0 and 5.1 into their trees (thus getting the right version number). mysql-test/t/disabled.def: rpl_insert_id tests statement-based replication of INSERT ON DUPLICATE KEY UPDATE. This type of INSERT had BUG#24432, which is fixed in 5.0.38; we made the slave detect if it is connected to a <5.0.38 master and if so refuse to replicate. The problem is that this 5.0-rpl tree, even though it will produce the 5.0.38 release, still has a 5.0.36 version in configure.in. Thus rpl_insert_id fails. So I disable it. As soon as the 5.0-rpl tree gets the changesets from the main 5.0, its version will change to 5.0.38 and so the repl team will re-enable the test. sql/slave.cc: the fix for BUG#24432 didn't make it into 5.0.36 and 5.1.16, so we need to adjust the bug-detection-based-on-version-number code. --- mysql-test/t/disabled.def | 1 + sql/slave.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 3213bd4eb5b..1464ddaa6b0 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -14,4 +14,5 @@ im_daemon_life_cycle : Bug#24415 see note: [19 Dec 23:17] Trudy Pelzer ndb_load : Bug#17233 user_limits : Bug#23921 random failure of user_limits.test flush2 : Bug#24805 Pushbuild can't handle test with --disable-log-bin +rpl_insert_id : replication team will enable as soon as they merge their tree with main tree and so got version number 5.0.38 diff --git a/sql/slave.cc b/sql/slave.cc index 37c782a42c3..f61d1e2ed69 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5181,8 +5181,8 @@ bool rpl_master_has_bug(RELAY_LOG_INFO *rli, uint bug_id) }; static struct st_version_range_for_one_bug versions_for_all_bugs[]= { - {24432, { 5, 0, 24 }, { 5, 0, 36 } }, - {24432, { 5, 1, 12 }, { 5, 1, 16 } } + {24432, { 5, 0, 24 }, { 5, 0, 38 } }, + {24432, { 5, 1, 12 }, { 5, 1, 17 } } }; const uchar *master_ver= rli->relay_log.description_event_for_exec->server_version_split; From e52ec3e6d5adae554bc343d56a04bf6ea55d170e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Feb 2007 12:58:56 -0500 Subject: [PATCH 58/78] BUG#20141 "User-defined variables are not replicated properly for SF/ Triggers in SBR mode." BUG#14914 "SP: Uses of session variables in routines are not always replicated" BUG#25167 "Dupl. usage of user-variables in trigger/function is not replicated correctly" User-defined variables used inside of stored functions/triggers in statements which did not update tables directly were not replicated. We also had problems with replication of user-defined variables which were used in triggers (or stored functions called from table-updating statements) more than once. This patch addresses the first issue by enabling logging of all references to user-defined variables in triggers/stored functions and not only references from table-updating statements. The second issue stemmed from the fact that for user-defined variables used from triggers or stored functions called from table-updating statements we were writing binlog events for each reference instead of only one event for the first reference. This problem is already solved for stored functions called from non-updating statements with help of "event unioning" mechanism. So the patch simply extends this mechanism to the case affected. It also fixes small problem in this mechanism which caused wrong logging of references to user-variables in cases when non-updating statement called several stored functions which used the same variable and some of these function calls were omitted from binlog as they were not updating any tables. mysql-test/r/rpl_user_variables.result: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch adds the correct results for execution of the added test procedures to the rpl_user_variables test. mysql-test/t/rpl_user_variables.test: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch adds additional tests to the rpl_user_variables test that test many of the different ways user-defined variables can be required to be replicated. sql/item_func.cc: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. To properly log accesses to user-defined variables from stored functions/triggers, the get_var_with_binlog() method needs to log references to such variables even from non-table-updating statements within them. sql/log.cc: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch modifies the start_union_events method to accept the query id from a parameter. This allows callers to set the query_id to the id of the sub statement such as a trigger or stored function. Which permits the code to identify when a user defined variable has been used by the statement and this already present in THD::user_var_event. Note: The changes to sql_class.cc, sp_head.cc, and log.cc are designed to allow the proper replication of access to user-defined variables under a special test case (the last case shown in rpl_user_variables.test). sql/sp_head.cc: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch modifies the code to allow for cases where events for function calls have a separate union for each event and thus cannot use the query_id of the caller as the start of the union. Thus, we use an artifically created query_id to set the start of the events. Note: The changes to sql_class.cc, sp_head.cc, and log.cc are designed to allow the proper replication of access to user-defined variables under a special test case (the last case shown in rpl_user_variables.test). sql/sql_class.cc: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch adds the query_id parameter to the calls to mysql_bin_log.start_union_events(). Note: The changes to sql_class.cc, sp_head.cc, and log.cc are designed to allow the proper replication of access to user-defined variables under a special test case (the last case shown in rpl_user_variables.test). sql/sql_class.h: BUG#20141 - User-defined variables are not replicated properly for SF/Triggers in SBR mode. This patch adds the query_id parameter to the calls to mysql_bin_log.start_union_events(). --- mysql-test/r/rpl_user_variables.result | 176 ++++++++++++++ mysql-test/t/rpl_user_variables.test | 303 ++++++++++++++++++++++++- sql/item_func.cc | 9 +- sql/log.cc | 4 +- sql/sp_head.cc | 18 +- sql/sql_class.cc | 7 + sql/sql_class.h | 2 +- 7 files changed, 511 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result index 45618688a33..05f2b68042e 100644 --- a/mysql-test/r/rpl_user_variables.result +++ b/mysql-test/r/rpl_user_variables.result @@ -108,4 +108,180 @@ slave-bin.000001 # User var 2 # @`a`=NULL slave-bin.000001 # Query 1 # use `test`; insert into t1 values (@a),(@a),(@a*5) insert into t1 select * FROM (select @var1 union select @var2) AS t2; drop table t1; +End of 4.1 tests. +DROP TABLE IF EXISTS t20; +DROP TABLE IF EXISTS t21; +DROP PROCEDURE IF EXISTS test.insert; +CREATE TABLE t20 (a VARCHAR(20)); +CREATE TABLE t21 (a VARCHAR(20)); +CREATE PROCEDURE test.insert() +BEGIN +IF (@VAR) +THEN +INSERT INTO test.t20 VALUES ('SP_TRUE'); +ELSE +INSERT INTO test.t20 VALUES ('SP_FALSE'); +END IF; +END| +CREATE TRIGGER test.insert_bi BEFORE INSERT +ON test.t20 FOR EACH ROW +BEGIN +IF (@VAR) +THEN +INSERT INTO test.t21 VALUES ('TRIG_TRUE'); +ELSE +INSERT INTO test.t21 VALUES ('TRIG_FALSE'); +END IF; +END| +SET @VAR=0; +CALL test.insert(); +SET @VAR=1; +CALL test.insert(); +On master: Check the tables for correct data +SELECT * FROM t20; +a +SP_FALSE +SP_TRUE +SELECT * FROM t21; +a +TRIG_FALSE +TRIG_TRUE +On slave: Check the tables for correct data and it matches master +SELECT * FROM t20; +a +SP_FALSE +SP_TRUE +SELECT * FROM t21; +a +TRIG_FALSE +TRIG_TRUE +DROP TABLE t20; +DROP TABLE t21; +DROP PROCEDURE test.insert; +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS test.square; +CREATE TABLE t1 (i INT); +CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN (@var * @var); +SET @var = 1; +INSERT INTO t1 VALUES (square()); +SET @var = 2; +INSERT INTO t1 VALUES (square()); +SET @var = 3; +INSERT INTO t1 VALUES (square()); +SET @var = 4; +INSERT INTO t1 VALUES (square()); +SET @var = 5; +INSERT INTO t1 VALUES (square()); +On master: Retrieve the values from the table +SELECT * FROM t1; +i +1 +4 +9 +16 +25 +On slave: Retrieve the values from the table and verify they are the same as on master +SELECT * FROM t1; +i +1 +4 +9 +16 +25 +DROP TABLE t1; +DROP FUNCTION test.square; +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +CREATE TABLE t1(a int); +CREATE FUNCTION f1() returns int deterministic +BEGIN +return @a; +END | +CREATE FUNCTION f2() returns int deterministic +BEGIN +IF (@b > 0) then +SET @c = (@a + @b); +else +SET @c = (@a - 1); +END if; +return @c; +END | +SET @a=500; +INSERT INTO t1 values(f1()); +SET @b = 125; +SET @c = 1; +INSERT INTO t1 values(f2()); +On master: Retrieve the values from the table +SELECT * from t1; +a +500 +625 +On slave: Check the tables for correct data and it matches master +SELECT * from t1; +a +500 +625 +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 (i int); +CREATE TABLE t2 (k int); +CREATE trigger t1_bi before INSERT on t1 for each row +BEGIN +INSERT INTO t2 values (@a); +SET @a:=42; +INSERT INTO t2 values (@a); +END | +SET @a:=100; +INSERT INTO t1 values (5); +On master: Check to see that data was inserted correctly in both tables +SELECT * from t1; +i +5 +SELECT * from t2; +k +100 +42 +On slave: Check the tables for correct data and it matches master +SELECT * from t1; +i +5 +SELECT * from t2; +k +100 +42 +End of 5.0 tests. +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +CREATE TABLE t1 (i INT); +CREATE FUNCTION f1() RETURNS INT RETURN @a; +CREATE FUNCTION f2() RETURNS INT +BEGIN +INSERT INTO t1 VALUES (10 + @a); +RETURN 0; +END| +SET @a:=123; +SELECT f1(), f2(); +f1() f2() +123 0 +On master: Check to see that data was inserted correctly +INSERT INTO t1 VALUES(f1()); +SELECT * FROM t1; +i +133 +123 +On slave: Check the table for correct data and it matches master +SELECT * FROM t1; +i +133 +123 +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP TABLE t1; stop slave; diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test index dbe75a15038..b2f4bfbb29d 100644 --- a/mysql-test/t/rpl_user_variables.test +++ b/mysql-test/t/rpl_user_variables.test @@ -57,8 +57,305 @@ insert into t1 select * FROM (select @var1 union select @var2) AS t2; drop table t1; save_master_pos; -connection slave; -sync_with_master; +--echo End of 4.1 tests. + +# BUG#20141 +# The following tests ensure that if user-defined variables are used in SF/Triggers +# that they are replicated correctly. These tests should be run in both SBR and RBR +# modes. + +# This test uses a procedure that inserts data values based on the value of a +# user-defined variable. It also has a trigger that inserts data based on the +# same variable. Successful test runs show that the @var is replicated +# properly and that the procedure and trigger insert the correct data on the +# slave. +# +# The test of stored procedure was included for completeness. Replication of stored +# procedures was not directly affected by BUG#20141. +# +# This test was constructed for BUG#20141 + +--disable_warnings +DROP TABLE IF EXISTS t20; +DROP TABLE IF EXISTS t21; +DROP PROCEDURE IF EXISTS test.insert; +--enable_warnings + +CREATE TABLE t20 (a VARCHAR(20)); +CREATE TABLE t21 (a VARCHAR(20)); +DELIMITER |; + +# Create a procedure that uses the @var for flow control + +CREATE PROCEDURE test.insert() +BEGIN + IF (@VAR) + THEN + INSERT INTO test.t20 VALUES ('SP_TRUE'); + ELSE + INSERT INTO test.t20 VALUES ('SP_FALSE'); + END IF; +END| + +# Create a trigger that uses the @var for flow control + +CREATE TRIGGER test.insert_bi BEFORE INSERT + ON test.t20 FOR EACH ROW + BEGIN + IF (@VAR) + THEN + INSERT INTO test.t21 VALUES ('TRIG_TRUE'); + ELSE + INSERT INTO test.t21 VALUES ('TRIG_FALSE'); + END IF; + END| +DELIMITER ;| + +sync_slave_with_master; +connection master; + +# Set @var and call the procedure, repeat with different values + +SET @VAR=0; +CALL test.insert(); +SET @VAR=1; +CALL test.insert(); + +--echo On master: Check the tables for correct data + +SELECT * FROM t20; +SELECT * FROM t21; + +sync_slave_with_master; + +--echo On slave: Check the tables for correct data and it matches master + +SELECT * FROM t20; +SELECT * FROM t21; +connection master; + +# Cleanup + +DROP TABLE t20; +DROP TABLE t21; +DROP PROCEDURE test.insert; + +# This test uses a stored function that uses user-defined variables to return data +# This test was constructed for BUG#20141 + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS test.square; +--enable_warnings + +CREATE TABLE t1 (i INT); + +# Create function that returns a value from @var. In this case, the square function + +CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN (@var * @var); + +sync_slave_with_master; +connection master; + +# Set the @var to different values and insert them into a table + +SET @var = 1; +INSERT INTO t1 VALUES (square()); +SET @var = 2; +INSERT INTO t1 VALUES (square()); +SET @var = 3; +INSERT INTO t1 VALUES (square()); +SET @var = 4; +INSERT INTO t1 VALUES (square()); +SET @var = 5; +INSERT INTO t1 VALUES (square()); + +--echo On master: Retrieve the values from the table + +SELECT * FROM t1; + +sync_slave_with_master; + +--echo On slave: Retrieve the values from the table and verify they are the same as on master + +SELECT * FROM t1; + +connection master; + +# Cleanup + +DROP TABLE t1; +DROP FUNCTION test.square; + +# This test uses stored functions that uses user-defined variables to return data +# based on the use of @vars inside a function body. +# This test was constructed for BUG#14914 + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +--enable_warnings + +CREATE TABLE t1(a int); +DELIMITER |; + +# Create a function that simply returns the value of an @var. +# Create a function that uses an @var for flow control, creates and uses another +# @var and sets its value to a value based on another @var. + +CREATE FUNCTION f1() returns int deterministic +BEGIN + return @a; +END | + +CREATE FUNCTION f2() returns int deterministic +BEGIN + IF (@b > 0) then + SET @c = (@a + @b); + else + SET @c = (@a - 1); + END if; + return @c; +END | +DELIMITER ;| + +sync_slave_with_master; +connection master; + +# Set an @var to a value and insert data into a table using the first function. +# Set two more @vars to some values and insert data into a table using the second function. + +SET @a=500; +INSERT INTO t1 values(f1()); +SET @b = 125; +SET @c = 1; +INSERT INTO t1 values(f2()); + +sync_slave_with_master; + +--echo On master: Retrieve the values from the table + +SELECT * from t1; + +--echo On slave: Check the tables for correct data and it matches master + +SELECT * from t1; + +connection master; + +# Cleanup + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; + +# This test uses a function that changes a user-defined variable in its body. This test +# will ensure the @vars are replicated when needed and not interrupt the normal execution +# of the function on the slave. This also applies to triggers. +# +# This test was constructed for BUG#25167 + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +CREATE TABLE t1 (i int); +CREATE TABLE t2 (k int); +DELIMITER |; + +# Create a trigger that inserts data into another table, changes the @var then inserts +# another row with the modified value. + +CREATE trigger t1_bi before INSERT on t1 for each row +BEGIN + INSERT INTO t2 values (@a); + SET @a:=42; + INSERT INTO t2 values (@a); +END | +DELIMITER ;| + +sync_slave_with_master; +connection master; + +# Set the @var to a value then insert data into first table. + +SET @a:=100; +INSERT INTO t1 values (5); + +--echo On master: Check to see that data was inserted correctly in both tables + +SELECT * from t1; +SELECT * from t2; + +sync_slave_with_master; + +--echo On slave: Check the tables for correct data and it matches master + +SELECT * from t1; +SELECT * from t2; + +connection master; + +--echo End of 5.0 tests. + +# Cleanup + +DROP TABLE t1; +DROP TABLE t2; + +# This test uses a stored function that uses user-defined variables to return data +# The test ensures the value of the user-defined variable is replicated correctly +# and in the correct order of assignment. +# This test was constructed for BUG#20141 + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +--enable_warnings + +CREATE TABLE t1 (i INT); + +# Create two functions. One simply returns the user-defined variable. The other +# returns a value based on the user-defined variable. + +CREATE FUNCTION f1() RETURNS INT RETURN @a; +DELIMITER |; +CREATE FUNCTION f2() RETURNS INT +BEGIN + INSERT INTO t1 VALUES (10 + @a); + RETURN 0; +END| +DELIMITER ;| + +sync_slave_with_master; +connection master; + +# Set the variable and execute the functions. + +SET @a:=123; +SELECT f1(), f2(); + +--echo On master: Check to see that data was inserted correctly + +INSERT INTO t1 VALUES(f1()); +SELECT * FROM t1; + +sync_slave_with_master; + +--echo On slave: Check the table for correct data and it matches master + +SELECT * FROM t1; + +connection master; + +# Cleanup + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP TABLE t1; + +sync_slave_with_master; stop slave; -# End of 4.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 1ef77208469..99640e9185c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4223,7 +4223,14 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command, user_var_entry *var_entry; var_entry= get_variable(&thd->user_vars, name, 0); - if (!(opt_bin_log && is_update_query(sql_command))) + /* + Any reference to user-defined variable which is done from stored + function or trigger affects their execution and the execution of the + calling statement. We must log all such variables even if they are + not involved in table-updating statements. + */ + if (!(opt_bin_log && + (is_update_query(sql_command) || thd->in_sub_stmt))) { *out_entry= var_entry; return 0; diff --git a/sql/log.cc b/sql/log.cc index 1961a5b6f88..ba46490b100 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1577,13 +1577,13 @@ bool MYSQL_LOG::flush_and_sync() return err; } -void MYSQL_LOG::start_union_events(THD *thd) +void MYSQL_LOG::start_union_events(THD *thd, query_id_t query_id_param) { DBUG_ASSERT(!thd->binlog_evt_union.do_union); thd->binlog_evt_union.do_union= TRUE; thd->binlog_evt_union.unioned_events= FALSE; thd->binlog_evt_union.unioned_events_trans= FALSE; - thd->binlog_evt_union.first_query_id= thd->query_id; + thd->binlog_evt_union.first_query_id= query_id_param; } void MYSQL_LOG::stop_union_events(THD *thd) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index de0edabda3e..d1a39422c7f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1464,8 +1464,24 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, binlog_save_options= thd->options; if (need_binlog_call) { + query_id_t q; reset_dynamic(&thd->user_var_events); - mysql_bin_log.start_union_events(thd); + /* + In case of artificially constructed events for function calls + we have separate union for each such event and hence can't use + query_id of real calling statement as the start of all these + unions (this will break logic of replication of user-defined + variables). So we use artifical value which is guaranteed to + be greater than all query_id's of all statements belonging + to previous events/unions. + Possible alternative to this is logging of all function invocations + as one select and not resetting THD::user_var_events before + each invocation. + */ + VOID(pthread_mutex_lock(&LOCK_thread_count)); + q= ::query_id; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); + mysql_bin_log.start_union_events(thd, q + 1); } /* diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0794d4c797a..8e1a0c5f1e3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2051,6 +2051,10 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, if (!lex->requires_prelocking() || is_update_query(lex->sql_command)) options&= ~OPTION_BIN_LOG; + + if ((backup->options & OPTION_BIN_LOG) && is_update_query(lex->sql_command)) + mysql_bin_log.start_union_events(this, this->query_id); + /* Disable result sets */ client_capabilities &= ~CLIENT_MULTI_RESULTS; in_sub_stmt|= new_state; @@ -2097,6 +2101,9 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) sent_row_count= backup->sent_row_count; client_capabilities= backup->client_capabilities; + if ((options & OPTION_BIN_LOG) && is_update_query(lex->sql_command)) + mysql_bin_log.stop_union_events(this); + /* The following is added to the old values as we are interested in the total complexity of the query diff --git a/sql/sql_class.h b/sql/sql_class.h index 05034ebd573..05ea9ac215e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -311,7 +311,7 @@ public: bool write(Log_event* event_info); // binary log write bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event); - void start_union_events(THD *thd); + void start_union_events(THD *thd, query_id_t query_id_param); void stop_union_events(THD *thd); bool is_query_in_union(THD *thd, query_id_t query_id_param); From b1e1f77f1ffcbd1f3f9d07d8da598061ea2cb75c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Feb 2007 23:04:15 +0300 Subject: [PATCH 59/78] item.cc: Post fix for bug#23800. The Item_field constructor now increases the select_n_where_fields counter. sql_yacc.yy: Post fix for bug#23800. Take into account fields that might be added by subselects. sql_lex.h: Post fix for bug#23800. Added the select_n_where_fields variable to the st_select_lex class. sql_lex.cc: Post fix for bug#23800. Initialization of the select_n_where_fields variable. sql/sql_lex.cc: Post fix for bug#23800. Initialization of the select_n_where_fields variable. sql/sql_lex.h: Post fix for bug#23800. Added the select_n_where_fields variable to the st_select_lex class. sql/item.cc: Post fix for bug#23800. The Item_field constructor now increases the select_n_where_fields counter. sql/sql_yacc.yy: Post fix for bug#23800. Take into account fields that might be added by subselects. --- sql/item.cc | 3 +++ sql/sql_lex.cc | 2 ++ sql/sql_lex.h | 5 +++++ sql/sql_yacc.yy | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/sql/item.cc b/sql/item.cc index a57f3c0fa96..9149a1240ea 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1664,7 +1664,10 @@ Item_field::Item_field(Name_resolution_context *context_arg, field(0), result_field(0), item_equal(0), no_const_subst(0), have_privileges(0), any_privileges(0), fixed_as_field(0) { + SELECT_LEX *select= current_thd->lex->current_select; collation.set(DERIVATION_IMPLICIT); + if (select && select->parsing_place != IN_HAVING) + select->select_n_where_fields++; } // Constructor need to process subselect with temporary tables (see Item) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c3e18394c41..cd26bfbc6f8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1151,6 +1151,7 @@ void st_select_lex::init_query() cond_count= between_count= with_wild= 0; conds_processed_with_permanent_arena= 0; ref_pointer_array= 0; + select_n_where_fields= 0; select_n_having_items= 0; subquery_in_having= explicit_limit= 0; is_item_list_lookup= 0; @@ -1550,6 +1551,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) (Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items + item_list.elements + select_n_having_items + + select_n_where_fields + order_group_num)*5)) == 0; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f8d8e6efcb2..d2171f745c1 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -530,6 +530,11 @@ public: uint select_n_having_items; uint cond_count; /* number of arguments of and/or/xor in where/having/on */ uint between_count; /* number of between predicates in where/having/on */ + /* + Number of fields used in select list or where clause of current select + and all inner subselects. + */ + uint select_n_where_fields; enum_parsing_place parsing_place; /* where we are parsing expression */ bool with_sum_func; /* sum function indicator */ /* diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d5b3aadbf39..2e9cc662ba8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9275,6 +9275,12 @@ subselect_end: lex->current_select = lex->current_select->return_after_parsing(); lex->nest_level--; lex->current_select->n_child_sum_items += child->n_sum_items; + /* + A subselect can add fields to an outer select. Reserve space for + them. + */ + lex->current_select->select_n_where_fields+= + child->select_n_where_fields; }; /************************************************************************** From dc8b4bacc5bb76540cb33cfdcaecf916b716fa89 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Feb 2007 00:31:26 +0100 Subject: [PATCH 60/78] log_on needed also in embedded server --- sql/sql_insert.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cd5f424fc14..613b28faf63 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -381,11 +381,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, List_item *values; Name_resolution_context *context; Name_resolution_context_state ctx_state; -#ifndef EMBEDDED_LIBRARY char *query= thd->query; bool log_on= (thd->options & OPTION_BIN_LOG) || (!(thd->security_ctx->master_access & SUPER_ACL)); -#endif thr_lock_type lock_type = table_list->lock_type; Item *unused_conds= 0; DBUG_ENTER("mysql_insert"); From 84e68927195baf4a0f1704745be73f00db1086b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Feb 2007 23:02:11 +0300 Subject: [PATCH 61/78] item.h: Post fix for bug#23800. Copy the table name of an Item_outer_ref to the conventional memory. sql/item.h: Post fix for bug#23800. Copy the table name of an Item_outer_ref to the conventional memory. --- sql/item.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/item.h b/sql/item.h index ec6d4fabae5..93b43c8b61a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1968,6 +1968,7 @@ public: outer_field_arg->field_name), outer_field(outer_field_arg) { + table_name= my_strdup(outer_field_arg->table_name, MYF(MY_WME)); ref= (Item**)&outer_field; set_properties(); fixed= 0; From 90d4f80922c7f8873ed8c415303f8d7276f5e32d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 09:01:43 +0300 Subject: [PATCH 62/78] item.cc, item.h: Post fix for bug#23800. sql/item.h: Post fix for bug#23800. sql/item.cc: Post fix for bug#23800. --- sql/item.cc | 1 + sql/item.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 9149a1240ea..cc41b83f8d9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5497,6 +5497,7 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference) if (!outer_field->fixed && (outer_field->fix_fields(thd, reference))) return TRUE; + table_name= outer_field->table_name; return Item_direct_ref::fix_fields(thd, reference); } diff --git a/sql/item.h b/sql/item.h index 93b43c8b61a..ec6d4fabae5 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1968,7 +1968,6 @@ public: outer_field_arg->field_name), outer_field(outer_field_arg) { - table_name= my_strdup(outer_field_arg->table_name, MYF(MY_WME)); ref= (Item**)&outer_field; set_properties(); fixed= 0; From 8c336fbc46fd3e8d1a7cc073883270c5a2ac3cc8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 08:11:10 +0100 Subject: [PATCH 63/78] Compiler warning suppression fix: Add missing file to 'make dist'. support-files/Makefile.am: Add missing file to 'make dist'. --- support-files/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support-files/Makefile.am b/support-files/Makefile.am index f2533100117..af835bf350e 100644 --- a/support-files/Makefile.am +++ b/support-files/Makefile.am @@ -28,7 +28,8 @@ EXTRA_DIST = mysql.spec.sh \ binary-configure.sh \ magic \ MySQL-shared-compat.spec.sh \ - ndb-config-2-node.ini.sh + ndb-config-2-node.ini.sh \ + compiler_warnings.supp SUBDIRS = MacOSX RHEL4-SElinux From 7d883c0defe80a210a4b3cb2a9d1b2195497f5b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 15:25:43 +0400 Subject: [PATCH 64/78] Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters Problem: DROP TRIGGER was not properly handled in combination with slave filters, which made replication stop Fix: loading table name before checking slave filters when dropping a trigger. mysql-test/r/rpl_replicate_do.result: Adding test case mysql-test/t/rpl_replicate_do.test: Adding test case sql/sql_parse.cc: Loading table name when dropping a trigger before checking slave filtering rules. sql/sql_trigger.cc: Making add_table_for_trigger() public sql/sql_trigger.h: Making add_table_for_trigger() public --- mysql-test/r/rpl_replicate_do.result | 34 ++++++++++++++++++++++++++++ mysql-test/t/rpl_replicate_do.test | 32 ++++++++++++++++++++++++++ sql/sql_parse.cc | 25 ++++++++++++++++++++ sql/sql_trigger.cc | 6 +---- sql/sql_trigger.h | 4 ++++ 5 files changed, 96 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index f79f6305342..9bacffb0609 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -41,3 +41,37 @@ select * from t1; ts 2005-08-12 00:00:00 drop table t1; +*** master *** +create table t1 (a int, b int); +create trigger trg1 before insert on t1 for each row set new.b=2; +create table t2 (a int, b int); +create trigger trg2 before insert on t2 for each row set new.b=2; +show tables; +Tables_in_test +t1 +t2 +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer +trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost +trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost +*** slave *** +show tables; +Tables_in_test +t1 +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer +trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost +*** master *** +drop trigger trg1; +drop trigger trg2; +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer +*** slave *** +show tables; +Tables_in_test +t1 +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer +*** master *** +drop table t1; +drop table t2; diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test index 9dec8c06c79..0e95d71514b 100644 --- a/mysql-test/t/rpl_replicate_do.test +++ b/mysql-test/t/rpl_replicate_do.test @@ -59,3 +59,35 @@ drop table t1; sync_slave_with_master; # End of 4.1 tests + +# +# Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters +# +--echo *** master *** +connection master; +create table t1 (a int, b int); +create trigger trg1 before insert on t1 for each row set new.b=2; +create table t2 (a int, b int); +create trigger trg2 before insert on t2 for each row set new.b=2; +show tables; +show triggers; +sync_slave_with_master; +--echo *** slave *** +connection slave; +show tables; +show triggers; +--echo *** master *** +connection master; +drop trigger trg1; +drop trigger trg2; +show triggers; +sync_slave_with_master; +--echo *** slave *** +connection slave; +show tables; +show triggers; +--echo *** master *** +connection master; +drop table t1; +drop table t2; +sync_slave_with_master; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b0b7afc6528..7226a8e3c86 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -33,6 +33,7 @@ #include "sp_head.h" #include "sp.h" #include "sp_cache.h" +#include "sql_trigger.h" #ifdef HAVE_OPENSSL /* @@ -2485,6 +2486,30 @@ mysql_execute_command(THD *thd) #ifdef HAVE_REPLICATION if (unlikely(thd->slave_thread)) { + if (lex->sql_command == SQLCOM_DROP_TRIGGER) + { + /* + When dropping a trigger, we need to load its table name + before checking slave filter rules. + */ + add_table_for_trigger(thd, thd->lex->spname, 1, &all_tables); + + if (!all_tables) + { + /* + If table name cannot be loaded, + it means the trigger does not exists possibly because + CREATE TRIGGER was previously skipped for this trigger + according to slave filtering rules. + Returning success without producing any errors in this case. + */ + DBUG_RETURN(0); + } + + // force searching in slave.cc:tables_ok() + all_tables->updating= 1; + } + /* Check if statment should be skipped because of slave filtering rules diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 3569733d064..0b648570b86 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -107,10 +107,6 @@ const LEX_STRING trg_event_type_names[]= }; -static int -add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, - TABLE_LIST ** table); - class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook { private: @@ -1183,7 +1179,7 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event, 1 Error */ -static int +int add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, TABLE_LIST **table) { diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 7e0fadfa677..8970986b931 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -139,3 +139,7 @@ private: extern const LEX_STRING trg_action_time_type_names[]; extern const LEX_STRING trg_event_type_names[]; + +int +add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, + TABLE_LIST **table); From 2e669d8e7b5944ad4a785ccd11424e060c5ce9bc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 20:35:28 +0100 Subject: [PATCH 65/78] Fix for BUG#26050 "LOAD DATA INFILE breaks ACID"; the ok must be sent to the client only after the binlog write and engine commit. No testcase for this bug, as to reproduce it, we need to "kill -9" mysqld, which we cannot do in the testsuite. But, I tested by hand. sql/sql_load.cc: D in ACID means that once the client got the ok from the server, the data is durable on disk. Implies that the ok must be sent after the binlog write and after the engine commit, not before. --- sql/sql_load.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 5710f9c4c97..10124e5f5ff 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -353,7 +353,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } sprintf(name, ER(ER_LOAD_INFO), (ulong) info.records, (ulong) info.deleted, (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - send_ok(thd,info.copied+info.deleted,0L,name); // on the slave thd->query is never initialized if (!thd->slave_thread) mysql_update_log.write(thd,thd->query,thd->query_length); @@ -378,6 +377,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, #endif /*!EMBEDDED_LIBRARY*/ if (transactional_table) error=ha_autocommit_or_rollback(thd,error); + + /* ok to client sent only after binlog write and engine commit */ + send_ok(thd, info.copied + info.deleted, 0L, name); err: if (thd->lock) { From 3a520a785eeee973e79d1f6e482e270e24a20c56 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Feb 2007 12:37:17 +0400 Subject: [PATCH 66/78] removed unused variable --- sql/sql_select.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a20e1f06147..5202f35f4de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13534,7 +13534,6 @@ count_field_types(TMP_TABLE_PARAM *param, List &fields, param->quick_group=1; while ((field=li++)) { - Item::Type type=field->type(); Item::Type real_type= field->real_item()->type(); if (real_type == Item::FIELD_ITEM) param->field_count++; From 4be9d3cc0aeef55f0eeeb66add04ba48fc93ad58 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Feb 2007 10:32:45 -0500 Subject: [PATCH 67/78] BUG#20141 "User-defined variables are not replicated properly for SF/Triggers in SBR mode." BUG#14914 "SP: Uses of session variables in routines are not always replicated" BUG#25167 "Dupl. usage of user-variables in trigger/function is not replicated correctly" This patch corrects a minor error in the previous patch for BUG#20141. This patch corrects an errant code change to sp_head.cc. The comments for the first patch follow: User-defined variables used inside of stored functions/triggers in statements which did not update tables directly were not replicated. We also had problems with replication of user-defined variables which were used in triggers (or stored functions called from table-updating statements) more than once. This patch addresses the first issue by enabling logging of all references to user-defined variables in triggers/stored functions and not only references from table-updating statements. The second issue stemmed from the fact that for user-defined variables used from triggers or stored functions called from table-updating statements we were writing binlog events for each reference instead of only one event for the first reference. This problem is already solved for stored functions called from non-updating statements with help of "event unioning" mechanism. So the patch simply extends this mechanism to the case affected. It also fixes small problem in this mechanism which caused wrong logging of references to user-variables in cases when non-updating statement called several stored functions which used the same variable and some of these function calls were omitted from binlog as they were not updating any tables. sql/sp_head.cc: BUG#20141 "User-defined variables are not replicated properly for SF/Triggers in SBR mode." This patch corrects a minor error in the previous patch for BUG#20141. The code: q= ::query_id; was an errant line of code that was not intended to be in the patch. Instead, the correct line of code is: q= global_query_id; --- sql/sp_head.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index cabdd07b711..24bdd2db5b6 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1477,7 +1477,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, each invocation. */ VOID(pthread_mutex_lock(&LOCK_thread_count)); - q= ::query_id; + q= global_query_id; VOID(pthread_mutex_unlock(&LOCK_thread_count)); mysql_bin_log.start_union_events(thd, q + 1); } From c3a3aff54feeb194e0217249305f74f18021099a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 17:06:57 +0400 Subject: [PATCH 68/78] Bug#15126 character_set_database is not replicated (LOAD DATA INFILE need it) This patch fixes problem that LOAD DATA could use different character sets when loading files on master and on slave sides: - Adding replication of thd->variables.collation_database - Adding optional character set clause into LOAD DATA Note, the second way, with explicit CHARACTER SET clause should be the recommended way to load data using an alternative character set. The old way, using "SET @@character_set_database=xxx" should be gradually depricated. mysql-test/r/mysqlbinlog.result: Adding test case mysql-test/t/mysqlbinlog.test: Adding test case sql/log_event.cc: Adding logging of thd->variables.collation_database sql/log_event.h: Adding declarations sql/sql_class.cc: Exchange character set is null by default sql/sql_class.h: Adding character set into sql_exchange sql/sql_load.cc: - Using exchange character set (if it was specified in LOAD DATA syntax) - Using thd->variables.collation_database by default sql/sql_yacc.yy: Adding optional character set clause into LOAD DATA syntax mysql-test/r/rpl_loaddata2.result: New BitKeeper file ``mysql-test/r/rpl_loaddata2.result'' mysql-test/std_data/loaddata6.dat: New BitKeeper file ``mysql-test/std_data/loaddata6.dat'' mysql-test/t/rpl_loaddata2.test: New BitKeeper file ``mysql-test/t/rpl_loaddata2.test'' --- mysql-test/r/mysqlbinlog.result | 58 +++++++++++++++++++++++++++++++ mysql-test/r/rpl_loaddata2.result | 37 ++++++++++++++++++++ mysql-test/std_data/loaddata6.dat | 1 + mysql-test/t/mysqlbinlog.test | 24 +++++++++++++ mysql-test/t/rpl_loaddata2.test | 33 ++++++++++++++++++ sql/log_event.cc | 48 ++++++++++++++++++++++--- sql/log_event.h | 5 ++- sql/sql_class.cc | 1 + sql/sql_class.h | 1 + sql/sql_load.cc | 3 +- sql/sql_yacc.yy | 7 ++++ 11 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 mysql-test/r/rpl_loaddata2.result create mode 100644 mysql-test/std_data/loaddata6.dat create mode 100644 mysql-test/t/rpl_loaddata2.test diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index b2571ec5d12..0f34259d11d 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -270,3 +270,61 @@ call p1(); 1 drop procedure p1; drop table t1, t2, t03, t04, t3, t4, t5; +flush logs; +create table t1 (a varchar(64) character set utf8); +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=latin1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=latin1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; +select hex(a) from t1; +hex(a) +C3BF +D0AA +C3BF +C3BF +D0AA +C3BF +D0AA +drop table t1; +flush logs; +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +use test/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/; +SET @@session.sql_mode=0/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +create table t1 (a varchar(64) character set utf8)/*!*/; +SET TIMESTAMP=1000000000/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.collation_database=7/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.collation_database=7/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; +SET TIMESTAMP=1000000000/*!*/; +load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; +SET TIMESTAMP=1000000000/*!*/; +drop table t1/*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; diff --git a/mysql-test/r/rpl_loaddata2.result b/mysql-test/r/rpl_loaddata2.result new file mode 100644 index 00000000000..929d06e74cf --- /dev/null +++ b/mysql-test/r/rpl_loaddata2.result @@ -0,0 +1,37 @@ +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; +create table t1 (a varchar(10) character set utf8); +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=DEFAULT; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=DEFAULT; +load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; +select hex(a) from t1; +hex(a) +C3BF +D0AA +C3BF +C3BF +C3BF +D0AA +D0AA +select hex(a) from t1; +hex(a) +C3BF +D0AA +C3BF +C3BF +C3BF +D0AA +D0AA +drop table t1; diff --git a/mysql-test/std_data/loaddata6.dat b/mysql-test/std_data/loaddata6.dat new file mode 100644 index 00000000000..29e181ebb88 --- /dev/null +++ b/mysql-test/std_data/loaddata6.dat @@ -0,0 +1 @@ +ÿ diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index b2bda247cd7..11ddc0d5a01 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -179,4 +179,28 @@ drop procedure p1; # clean up drop table t1, t2, t03, t04, t3, t4, t5; +# +# Bug#15126 character_set_database is not replicated +# (LOAD DATA INFILE need it) +# + +flush logs; +create table t1 (a varchar(64) character set utf8); +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=latin1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set character_set_database=latin1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; +select hex(a) from t1; +drop table t1; +flush logs; +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000011 + # End of 5.0 tests + diff --git a/mysql-test/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata2.test new file mode 100644 index 00000000000..7f2389cb9f6 --- /dev/null +++ b/mysql-test/t/rpl_loaddata2.test @@ -0,0 +1,33 @@ +# +# Check LOAD DATA + character sets + replication +# +source include/master-slave.inc; + +# +# Bug#15126 character_set_database is not replicated +# (LOAD DATA INFILE need it) +# +connection master; +create table t1 (a varchar(10) character set utf8); +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=DEFAULT; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=koi8r; +load data infile '../std_data_ln/loaddata6.dat' into table t1; +set @@character_set_database=DEFAULT; +load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; + +select hex(a) from t1; + +save_master_pos; +connection slave; +sync_with_master; + +select hex(a) from t1; +connection master; +drop table t1; +sync_slave_with_master; diff --git a/sql/log_event.cc b/sql/log_event.cc index a14cd79461d..daf7fdeab2c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1088,7 +1088,8 @@ bool Query_log_event::write(IO_CACHE* file) 1+4+ // code of autoinc and the 2 autoinc variables 1+6+ // code of charset and charset 1+1+MAX_TIME_ZONE_NAME_LENGTH+ // code of tz and tz length and tz name - 1+2 // code of lc_time_names and lc_time_names_number + 1+2+ // code of lc_time_names and lc_time_names_number + 1+2 // code of charset_database and charset_database_number ], *start, *start_of_status; ulong event_length; @@ -1207,6 +1208,13 @@ bool Query_log_event::write(IO_CACHE* file) int2store(start, lc_time_names_number); start+= 2; } + if (charset_database_number) + { + DBUG_ASSERT(charset_database_number <= 0xFFFF); + *start++= Q_CHARSET_DATABASE_CODE; + int2store(start, charset_database_number); + start+= 2; + } /* Here there could be code like if (command-line-option-which-says-"log_this_variable" && inited) @@ -1272,7 +1280,8 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, sql_mode(thd_arg->variables.sql_mode), auto_increment_increment(thd_arg->variables.auto_increment_increment), auto_increment_offset(thd_arg->variables.auto_increment_offset), - lc_time_names_number(thd_arg->variables.lc_time_names->number) + lc_time_names_number(thd_arg->variables.lc_time_names->number), + charset_database_number(0) { time_t end_time; time(&end_time); @@ -1280,6 +1289,9 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, catalog_len = (catalog) ? (uint32) strlen(catalog) : 0; /* status_vars_len is set just before writing the event */ db_len = (db) ? (uint32) strlen(db) : 0; + if (thd_arg->variables.collation_database != thd_arg->db_charset) + charset_database_number= thd_arg->variables.collation_database->number; + /* If we don't use flags2 for anything else than options contained in thd->options, it would be more efficient to flags2=thd_arg->options @@ -1350,7 +1362,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, db(NullS), catalog_len(0), status_vars_len(0), flags2_inited(0), sql_mode_inited(0), charset_inited(0), auto_increment_increment(1), auto_increment_offset(1), - time_zone_len(0), lc_time_names_number(0) + time_zone_len(0), lc_time_names_number(0), charset_database_number(0) { ulong data_len; uint32 tmp; @@ -1455,6 +1467,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, lc_time_names_number= uint2korr(pos); pos+= 2; break; + case Q_CHARSET_DATABASE_CODE: + charset_database_number= uint2korr(pos); + pos+= 2; + break; default: /* That's why you must write status vars in growing order of code */ DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\ @@ -1652,6 +1668,16 @@ void Query_log_event::print_query_header(FILE* file, lc_time_names_number, print_event_info->delimiter); print_event_info->lc_time_names_number= lc_time_names_number; } + if (charset_database_number != print_event_info->charset_database_number) + { + if (charset_database_number) + fprintf(file, "SET @@session.collation_database=%d%s\n", + charset_database_number, print_event_info->delimiter); + else + fprintf(file, "SET @@session.collation_database=DEFAULT%s\n", + print_event_info->delimiter); + print_event_info->charset_database_number= charset_database_number; + } } @@ -1817,7 +1843,21 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, } else thd->variables.lc_time_names= &my_locale_en_US; - + if (charset_database_number) + { + CHARSET_INFO *cs; + if (!(cs= get_charset(charset_database_number, MYF(0)))) + { + char buf[20]; + int10_to_str((int) charset_database_number, buf, -10); + my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); + goto compare_errors; + } + thd->variables.collation_database= cs; + } + else + thd->variables.collation_database= thd->db_charset; + /* Execute the query (note that we bypass dispatch_command()) */ mysql_parse(thd, thd->query, thd->query_length); diff --git a/sql/log_event.h b/sql/log_event.h index d3ebe6860f5..c08306e30d2 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -272,6 +272,7 @@ struct sql_ex_info #define Q_LC_TIME_NAMES_CODE 7 +#define Q_CHARSET_DATABASE_CODE 8 /* Intvar event post-header */ #define I_TYPE_OFFSET 0 @@ -509,10 +510,11 @@ typedef struct st_print_event_info char charset[6]; // 3 variables, each of them storable in 2 bytes char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH]; uint lc_time_names_number; + uint charset_database_number; st_print_event_info() :flags2_inited(0), sql_mode_inited(0), auto_increment_increment(1),auto_increment_offset(1), charset_inited(0), - lc_time_names_number(0) + lc_time_names_number(0), charset_database_number(0) { /* Currently we only use static PRINT_EVENT_INFO objects, so zeroed at @@ -797,6 +799,7 @@ public: uint time_zone_len; /* 0 means uninited */ const char *time_zone_str; uint lc_time_names_number; /* 0 means en_US */ + uint charset_database_number; #ifndef MYSQL_CLIENT diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0794d4c797a..a020c570cb6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -902,6 +902,7 @@ sql_exchange::sql_exchange(char *name,bool flag) enclosed= line_start= &my_empty_string; line_term= &default_line_term; escaped= &default_escaped; + cs= NULL; } bool select_send::send_fields(List &list, uint flags) diff --git a/sql/sql_class.h b/sql/sql_class.h index 05034ebd573..817a033a526 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1687,6 +1687,7 @@ public: bool opt_enclosed; bool dumpfile; ulong skip_lines; + CHARSET_INFO *cs; sql_exchange(char *name,bool dumpfile_flag); }; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0e4057d9ae4..d971eae56c0 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -313,7 +313,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, info.handle_duplicates=handle_duplicates; info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX; - READ_INFO read_info(file,tot_length,thd->variables.collation_database, + READ_INFO read_info(file,tot_length, + ex->cs ? ex->cs : thd->variables.collation_database, *field_term,*ex->line_start, *ex->line_term, *enclosed, info.escape_char, read_file_from_client, is_fifo); if (read_info.error) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 92640ea58d6..8843423c352 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -992,6 +992,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); old_or_new_charset_name_or_default collation_name collation_name_or_default + opt_load_data_charset %type internal_variable_name @@ -3262,6 +3263,10 @@ charset_name_or_default: charset_name { $$=$1; } | DEFAULT { $$=NULL; } ; +opt_load_data_charset: + /* Empty */ { $$= NULL; } + | charset charset_name_or_default { $$= $2; } + ; old_or_new_charset_name: ident_or_text @@ -7214,6 +7219,8 @@ load_data: lex->update_list.empty(); lex->value_list.empty(); } + opt_load_data_charset + { Lex->exchange->cs= $12; } opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec opt_load_data_set_spec {} From 18f1d1a2005156724eb0e633b629ec3df5f5266b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 17:32:18 +0400 Subject: [PATCH 69/78] After merge fix --- mysql-test/r/mysqlbinlog.result | 1 - mysql-test/t/mysqlbinlog.test | 2 -- 2 files changed, 3 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 412b4ad3b85..8ca2422443d 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -272,7 +272,6 @@ call p1(); 1 1 drop procedure p1; -drop table t1, t2, t03, t04, t3, t4, t5; flush logs; create table t1 (a varchar(64) character set utf8); load data infile '../std_data_ln/loaddata6.dat' into table t1; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 1545e7f1d99..fe86d850267 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -189,8 +189,6 @@ drop procedure p1; --exec $MYSQL_BINLOG --version 2>&1 > /dev/null --exec $MYSQL_BINLOG --help 2>&1 > /dev/null --enable_query_log -# clean up -drop table t1, t2, t03, t04, t3, t4, t5; # # Bug#15126 character_set_database is not replicated From 4a83cd38eae270a20bbd257cbd3b986dbc6aab31 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 18:13:23 +0400 Subject: [PATCH 70/78] Additional test changes for Bug N 15126 character_set_database is not replicated (LOAD DATA INFILE need it) Positions of some binlog events were changed because of additional logging of @@collation_database. --- mysql-test/r/ctype_cp932_binlog.result | 18 +++++++++--------- mysql-test/r/ctype_cp932_notembedded.result | 6 +++--- mysql-test/t/ctype_cp932_binlog.test | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/ctype_cp932_binlog.result b/mysql-test/r/ctype_cp932_binlog.result index d3d800b7bf0..ff295961008 100644 --- a/mysql-test/r/ctype_cp932_binlog.result +++ b/mysql-test/r/ctype_cp932_binlog.result @@ -8,9 +8,9 @@ SET @var1= x'8300'; EXECUTE stmt1 USING @var1; SHOW BINLOG EVENTS FROM 98; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 98 Query 1 185 use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 185 User var 1 224 @`var1`=_binary 0x8300 COLLATE binary -master-bin.000001 224 Query 1 317 use `test`; INSERT INTO t1 VALUES(@'var1') +master-bin.000001 98 Query 1 188 use `test`; CREATE TABLE t1(f1 blob) +master-bin.000001 188 User var 1 227 @`var1`=_binary 0x8300 COLLATE binary +master-bin.000001 227 Query 1 323 use `test`; INSERT INTO t1 VALUES(@'var1') SELECT HEX(f1) FROM t1; HEX(f1) 8300 @@ -30,17 +30,17 @@ HEX(s1) HEX(s2) d 466F6F2773206120426172 ED40ED41ED42 47.93 DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 393| +SHOW BINLOG EVENTS FROM 402| Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 393 Query 1 556 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, +master-bin.000001 402 Query 1 568 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) -master-bin.000001 556 Query 1 801 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), +master-bin.000001 568 Query 1 816 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END -master-bin.000001 801 Query 1 1017 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) -master-bin.000001 1017 Query 1 1103 use `test`; DROP PROCEDURE bug18293 -master-bin.000001 1103 Query 1 1179 use `test`; DROP TABLE t4 +master-bin.000001 816 Query 1 1035 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) +master-bin.000001 1035 Query 1 1124 use `test`; DROP PROCEDURE bug18293 +master-bin.000001 1124 Query 1 1203 use `test`; DROP TABLE t4 diff --git a/mysql-test/r/ctype_cp932_notembedded.result b/mysql-test/r/ctype_cp932_notembedded.result index d04fce7738c..c58bfc65454 100644 --- a/mysql-test/r/ctype_cp932_notembedded.result +++ b/mysql-test/r/ctype_cp932_notembedded.result @@ -8,9 +8,9 @@ SET @var1= x'8300'; EXECUTE stmt1 USING @var1; SHOW BINLOG EVENTS FROM 98; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 98 Query 1 185 use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 185 User var 1 224 @`var1`=_binary 0x8300 COLLATE binary -master-bin.000001 224 Query 1 317 use `test`; INSERT INTO t1 VALUES(@'var1') +master-bin.000001 98 Query 1 188 use `test`; CREATE TABLE t1(f1 blob) +master-bin.000001 188 User var 1 227 @`var1`=_binary 0x8300 COLLATE binary +master-bin.000001 227 Query 1 323 use `test`; INSERT INTO t1 VALUES(@'var1') SELECT HEX(f1) FROM t1; HEX(f1) 8300 diff --git a/mysql-test/t/ctype_cp932_binlog.test b/mysql-test/t/ctype_cp932_binlog.test index 3bbbe94f0e3..ee0e588fdae 100644 --- a/mysql-test/t/ctype_cp932_binlog.test +++ b/mysql-test/t/ctype_cp932_binlog.test @@ -51,7 +51,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 393| +SHOW BINLOG EVENTS FROM 402| delimiter ;| # End of 5.0 tests From def9c0b2367808d6e8f6b9ffe2f82f6465d9642b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 22:23:35 +0200 Subject: [PATCH 71/78] Fixed compiler warnings. client/mysql_upgrade.c: Fixed problem with mysql_upgrade being dependent on local my.cnf files and problem with memory not being freed. client/mysqltest.c: Changed type to avoid warning. cmd-line-utils/readline/xmalloc.c: Fix to avoid warning. include/my_dbug.h: To disable parts from code in non-debug more. sql/field.cc: Fixed warning. sql/ha_archive.cc: Fixed warning. sql/ha_berkeley.cc: Added casts to avoid warnings. sql/ha_ndbcluster.cc: Fixed warnings. sql/log.cc: Added casts to avoid warnings. sql/slave.cc: Avoid warning. sql/sql_repl.cc: Avoid warning. support-files/compiler_warnings.supp: Added disabled warnings to compiler_warnings.supp file. These are backported mainly from 5.1 suppress file, but there are some additional new ones. --- client/mysql_upgrade.c | 29 +++++++++----- client/mysqltest.c | 2 +- cmd-line-utils/readline/xmalloc.c | 7 ++-- include/my_dbug.h | 2 + sql/field.cc | 6 +-- sql/ha_archive.cc | 2 +- sql/ha_berkeley.cc | 6 +-- sql/ha_ndbcluster.cc | 29 ++++++++++---- sql/log.cc | 4 +- sql/slave.cc | 2 + sql/sql_repl.cc | 2 + support-files/compiler_warnings.supp | 56 ++++++++++++++++++++++++++-- 12 files changed, 114 insertions(+), 33 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 21242818b21..afd9e057c8d 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -171,7 +171,7 @@ void set_extra_default(int id, const struct my_option *opt) } d= (extra_default_t *)my_malloc(sizeof(extra_default_t), - MYF(MY_FAE|MY_ZEROFILL)); + MYF(MY_FAE | MY_ZEROFILL)); d->id= id; d->name= opt->name; d->n_len= strlen(opt->name); @@ -345,15 +345,17 @@ static int create_defaults_file(const char *path, const char *forced_path) } dynstr_set(&buf, NULL); } - if (dynstr_append_mem(&buf, "\n", 1) - || dynstr_append_mem(&buf, d->name, d->n_len) - || (d->v_len && (dynstr_append_mem(&buf, "=", 1) - || dynstr_append_mem(&buf, d->value, d->v_len)))) + if (dynstr_append_mem(&buf, "\n", 1) || + dynstr_append_mem(&buf, d->name, d->n_len) || + (d->v_len && (dynstr_append_mem(&buf, "=", 1) || + dynstr_append_mem(&buf, d->value, d->v_len)))) { ret= 1; goto error; } my_delete((gptr)d, MYF(0)); + my_free((gptr) d, MYF(0)); + list_pop(extra_defaults); /* pop off the head */ } if (my_write(defaults_file, buf.str, buf.length, MYF(MY_FNABP | MY_WME))) @@ -451,10 +453,10 @@ int main(int argc, char **argv) char *forced_extra_defaults; char *local_defaults_group_suffix; const char *script_line; - char *upgrade_defaults_path; + char *upgrade_defaults_path= NULL; char *defaults_to_use= NULL; int upgrade_defaults_created= 0; - + int no_defaults; char path[FN_REFLEN]; DYNAMIC_STRING cmdline; @@ -464,6 +466,10 @@ int main(int argc, char **argv) #endif /* Check if we are forced to use specific defaults */ + no_defaults= 0; + if (argc >= 2 && !strcmp(argv[1],"--no-defaults")) + no_defaults= 1; + get_defaults_options(argc, argv, &forced_defaults_file, &forced_extra_defaults, &local_defaults_group_suffix); @@ -578,7 +584,9 @@ int main(int argc, char **argv) if (defaults_to_use) { dynstr_append(&cmdline, " "); - dynstr_append_os_quoted(&cmdline, "--defaults-extra-file=", + dynstr_append_os_quoted(&cmdline, + (no_defaults ? "--defaults-file=" : + "--defaults-extra-file="), defaults_to_use, NullS); } @@ -652,7 +660,9 @@ fix_priv_tables: if (defaults_to_use) { dynstr_append(&cmdline, " "); - dynstr_append_os_quoted(&cmdline, "--defaults-extra-file=", + dynstr_append_os_quoted(&cmdline, + (no_defaults ? "--defaults-file=" : + "--defaults-extra-file="), defaults_to_use, NullS); } dynstr_append(&cmdline, " "); @@ -684,6 +694,7 @@ error: if (upgrade_defaults_created) my_delete(upgrade_defaults_path, MYF(0)); + my_free(upgrade_defaults_path, MYF(MY_ALLOW_ZERO_PTR)); my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return ret; } diff --git a/client/mysqltest.c b/client/mysqltest.c index 28de470769e..074eeb0fac4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -6726,7 +6726,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub) { - int start_off,end_off; + regoff_t start_off, end_off; if ((start_off=subs[back_ref_num].rm_so) > -1 && (end_off=subs[back_ref_num].rm_eo) > -1) { diff --git a/cmd-line-utils/readline/xmalloc.c b/cmd-line-utils/readline/xmalloc.c index 848a3563fa9..497936d3b43 100644 --- a/cmd-line-utils/readline/xmalloc.c +++ b/cmd-line-utils/readline/xmalloc.c @@ -39,8 +39,7 @@ /* **************************************************************** */ static void -memory_error_and_abort (fname) - char *fname; +memory_error_and_abort(const char *fname) { fprintf (stderr, "%s: out of virtual memory\n", fname); exit (2); @@ -57,7 +56,7 @@ xmalloc (bytes) temp = malloc (bytes); if (temp == 0) - memory_error_and_abort ((char*) "xmalloc"); + memory_error_and_abort("xmalloc"); return (temp); } @@ -71,7 +70,7 @@ xrealloc (pointer, bytes) temp = pointer ? realloc (pointer, bytes) : malloc (bytes); if (temp == 0) - memory_error_and_abort ((char*) "xrealloc"); + memory_error_and_abort("xrealloc"); return (temp); } diff --git a/include/my_dbug.h b/include/my_dbug.h index a3591f0151a..31fd507ec73 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -74,6 +74,7 @@ extern void _db_unlock_file(void); #define DBUG_ASSERT(A) assert(A) #define DBUG_EXECUTE_IF(keyword,a1) \ {if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}} +#define IF_DBUG(A) A #else /* No debugger */ #define DBUG_ENTER(a1) @@ -98,6 +99,7 @@ extern void _db_unlock_file(void); #define DBUG_OUTPUT(A) #define DBUG_ASSERT(A) {} #define DBUG_LEAVE +#define IF_DBUG(A) #endif #ifdef __cplusplus } diff --git a/sql/field.cc b/sql/field.cc index 981a877783f..fa838332926 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6144,9 +6144,9 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) void Field_string::sort_string(char *to,uint length) { - uint tmp=my_strnxfrm(field_charset, - (unsigned char *) to, length, - (unsigned char *) ptr, field_length); + IF_DBUG(uint tmp=) my_strnxfrm(field_charset, + (unsigned char *) to, length, + (unsigned char *) ptr, field_length); DBUG_ASSERT(tmp == length); } diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 96b6861007e..730d8b46945 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -750,7 +750,7 @@ int ha_archive::write_row(byte *buf) if ((*field)->real_type() == MYSQL_TYPE_VARCHAR) { uint actual_length= (*field)->data_length((char*) buf + (*field)->offset()); - uint offset= (*field)->offset() + actual_length + + IF_DBUG(uint offset=) (*field)->offset() + actual_length + (actual_length > 255 ? 2 : 1); DBUG_PRINT("archive",("Offset is %d -> %d\n", actual_length, offset)); /* diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index e78808e3308..2a5fe775ca6 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -807,7 +807,7 @@ int ha_berkeley::pack_row(DBT *row, const byte *record, bool new_row) ptr+=BDB_HIDDEN_PRIMARY_KEY_LENGTH; } row->data=rec_buff; - row->size= (size_t) (ptr - rec_buff); + row->size= (u_int32_t) (ptr - rec_buff); return 0; } @@ -902,7 +902,7 @@ DBT *ha_berkeley::create_key(DBT *key, uint keynr, char *buff, key_part->length); key_length-=key_part->length; } - key->size= (buff - (char*) key->data); + key->size= (u_int32_t) (buff - (char*) key->data); DBUG_DUMP("key",(char*) key->data, key->size); DBUG_RETURN(key); } @@ -946,7 +946,7 @@ DBT *ha_berkeley::pack_key(DBT *key, uint keynr, char *buff, key_ptr+=key_part->store_length; key_length-=key_part->store_length; } - key->size= (buff - (char*) key->data); + key->size= (u_int32_t) (buff - (char*) key->data); DBUG_DUMP("key",(char*) key->data, key->size); DBUG_RETURN(key); } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 46d3870e544..7a9c7d0d021 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2331,10 +2331,12 @@ int ha_ndbcluster::write_row(byte *record) { Ndb *ndb= get_ndb(); Uint64 next_val= (Uint64) table->next_number_field->val_int() + 1; +#ifndef DBUG_OFF char buff[22]; DBUG_PRINT("info", ("Trying to set next auto increment value to %s", llstr(next_val, buff))); +#endif if (ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, TRUE) == -1) ERR_RETURN(ndb->getNdbError()); @@ -3490,7 +3492,7 @@ int ha_ndbcluster::end_bulk_insert() } else { - int res= trans->restart(); + IF_DBUG(int res=) trans->restart(); DBUG_ASSERT(res == 0); } } @@ -4257,7 +4259,9 @@ static int create_ndb_column(NDBCOL &col, // Set autoincrement if (field->flags & AUTO_INCREMENT_FLAG) { +#ifndef DBUG_OFF char buff[22]; +#endif col.setAutoIncrement(TRUE); ulonglong value= info->auto_increment_value ? info->auto_increment_value : (ulonglong) 1; @@ -5680,7 +5684,9 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname, if (share->commit_count != 0) { *commit_count= share->commit_count; +#ifndef DBUG_OFF char buff[22]; +#endif DBUG_PRINT("info", ("Getting commit_count: %s from share", llstr(share->commit_count, buff))); pthread_mutex_unlock(&share->mutex); @@ -5706,7 +5712,9 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname, pthread_mutex_lock(&share->mutex); if (share->commit_count_lock == lock) { +#ifndef DBUG_OFF char buff[22]; +#endif DBUG_PRINT("info", ("Setting commit_count to %s", llstr(stat.commit_count, buff))); share->commit_count= stat.commit_count; @@ -5762,7 +5770,9 @@ ndbcluster_cache_retrieval_allowed(THD *thd, bool is_autocommit= !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)); char *dbname= full_name; char *tabname= dbname+strlen(dbname)+1; +#ifndef DBUG_OFF char buff[22], buff2[22]; +#endif DBUG_ENTER("ndbcluster_cache_retrieval_allowed"); DBUG_PRINT("enter", ("dbname: %s, tabname: %s, is_autocommit: %d", dbname, tabname, is_autocommit)); @@ -5829,7 +5839,9 @@ ha_ndbcluster::register_query_cache_table(THD *thd, ulonglong *engine_data) { Uint64 commit_count; +#ifndef DBUG_OFF char buff[22]; +#endif bool is_autocommit= !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)); DBUG_ENTER("ha_ndbcluster::register_query_cache_table"); DBUG_PRINT("enter",("dbname: %s, tabname: %s, is_autocommit: %d", @@ -6036,7 +6048,9 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, int retries= 10; int reterr= 0; int retry_sleep= 30 * 1000; /* 30 milliseconds */ +#ifndef DBUG_OFF char buff[22], buff2[22], buff3[22], buff4[22]; +#endif DBUG_ENTER("ndb_get_table_statistics"); DBUG_PRINT("enter", ("table: %s", table)); @@ -6725,7 +6739,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) if (ndb_get_table_statistics(NULL, false, ndb, tabname, &stat) == 0) { +#ifndef DBUG_OFF char buff[22], buff2[22]; +#endif DBUG_PRINT("ndb_util_thread", ("Table: %s commit_count: %s rows: %s", share->table_name, @@ -7565,8 +7581,8 @@ void ndb_serialize_cond(const Item *item, void *arg) DBUG_PRINT("info", ("INT_ITEM")); if (context->expecting(Item::INT_ITEM)) { - Item_int *int_item= (Item_int *) item; - DBUG_PRINT("info", ("value %ld", (long) int_item->value)); + DBUG_PRINT("info", ("value %ld", + (long) ((Item_int*) item)->value)); NDB_ITEM_QUALIFICATION q; q.value_type= Item::INT_ITEM; curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item); @@ -7592,8 +7608,7 @@ void ndb_serialize_cond(const Item *item, void *arg) DBUG_PRINT("info", ("REAL_ITEM")); if (context->expecting(Item::REAL_ITEM)) { - Item_float *float_item= (Item_float *) item; - DBUG_PRINT("info", ("value %f", float_item->value)); + DBUG_PRINT("info", ("value %f", ((Item_float *) item)->value)); NDB_ITEM_QUALIFICATION q; q.value_type= Item::REAL_ITEM; curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item); @@ -7640,8 +7655,8 @@ void ndb_serialize_cond(const Item *item, void *arg) DBUG_PRINT("info", ("DECIMAL_ITEM")); if (context->expecting(Item::DECIMAL_ITEM)) { - Item_decimal *decimal_item= (Item_decimal *) item; - DBUG_PRINT("info", ("value %f", decimal_item->val_real())); + DBUG_PRINT("info", ("value %f", + ((Item_decimal*) item)->val_real())); NDB_ITEM_QUALIFICATION q; q.value_type= Item::DECIMAL_ITEM; curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item); diff --git a/sql/log.cc b/sql/log.cc index 05c6a548e28..a6c02d10732 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -304,7 +304,7 @@ void setup_windows_event_source() /* Register EventMessageFile */ dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, - (PBYTE) szPath, strlen(szPath)+1); + (PBYTE) szPath, (DWORD) (strlen(szPath) + 1)); /* Register supported event types */ dwTypes= (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | @@ -1784,7 +1784,7 @@ void MYSQL_LOG::rotate_and_purge(uint flags) #ifdef HAVE_REPLICATION if (expire_logs_days) { - long purge_time= time(0) - expire_logs_days*24*60*60; + long purge_time= (long) (time(0) - expire_logs_days*24*60*60); if (purge_time >= 0) purge_logs_before_date(purge_time); } diff --git a/sql/slave.cc b/sql/slave.cc index 19494f44d85..7018a9310e9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -52,7 +52,9 @@ ulonglong relay_log_space_limit = 0; int disconnect_slave_event_count = 0, abort_slave_event_count = 0; int events_till_abort = -1; +#ifndef DBUG_OFF static int events_till_disconnect = -1; +#endif typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 01b1149a2b3..1e32bd16d34 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -22,7 +22,9 @@ int max_binlog_dump_events = 0; // unlimited my_bool opt_sporadic_binlog_dump_fail = 0; +#ifndef DBUG_OFF static int binlog_dump_count = 0; +#endif /* fake_rotate_event() builds a fake (=which does not exist physically in any diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 8f5f3408b44..2cf43f230c3 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -1,9 +1,26 @@ +integer.cpp: .*control reaches end of non-void function.*: 1288-1427 DictTabInfo.cpp : .*invalid access to non-static.* DictTabInfo.cpp : .*macro was used incorrectly.* -DbdihMain.cpp : .*unused variable.* : 6666-6705 -DbtupExecQuery.cpp : .*unused variable.* : 1448-1449 +DbdihMain.cpp : .*unused variable.* : 6666-7013 +DbtupExecQuery.cpp : .*unused variable.* : 1448-1449 +kernel_types.h : .*only defines private constructors and has no friends.* : 51 +Dbtup.hpp: .*only defines private constructors and has no friends.* +diskpage.hpp: .*only defines private constructors and has no friends.* +tuppage.hpp: .*only defines private constructors and has no friends.* +NdbScanOperation.cpp: .*unused variable '__align'.* : 1190-1200 +sql_yacc.cc : .*label 'yyerrlab1' defined but not used.* +kernel_types.h : .*'struct Local_key' only defines private constructors and has no friends.* +lgman.hpp : .*'struct Lgman::Buffer_idx' only defines private constructors and has no friends.* +SchemaFile.hpp : .*'struct SchemaFile::TableEntry' only defines private constructors and has no friends.* sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.* +# +# Things that can be ignored in InnoDB +# +pars0grm.tab.c: .*'yyerrorlab' : unreferenced label.* +_flex_tmp.c: .*not enough actual parameters for macro 'yywrap'.* +pars0lex.l: .*conversion from 'ulint' to 'int', possible loss of data.* + # # bdb is not critical to keep up to date # @@ -11,16 +28,49 @@ sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.* .*/bdb/.* : .*unused parameter.* .*/bdb/.* : .*may be used uninitialized.* .*/bdb/.* : .*empty body in an if-statement.* +.*/bdb/.* : .*conversion from 'u?lint' to 'int', possible loss of data.* db_vrfy.c : .*comparison is always false due to limited range of data type.* # # Ignore all conversion warnings on windows 64 # (Is safe as we are not yet supporting strings >= 2G) # -.* : conversion from 'size_t' to .*int'.* .* : conversion from '__int64' to .*int'.* +.* : conversion from '__int64' to 'uint8'.* +.* : conversion from '__int64' to 'uint32'.* +.* : conversion from '__int64' to 'u.*long'.* +.* : conversion from '__int64' to 'long'.* +.* : conversion from '__int64' to 'off_t'.* +.* : conversion from '.*size_t' to .*int'.* +.* : conversion from '.*size_t' to 'TaoCrypt::word32'.* +.* : conversion from '.*size_t' to 'u.*long'.* +.* : conversion from '.*size_t' to 'uint32'.* +.* : conversion from '.*size_t' to 'off_t'.* +.* : conversion from '.*size_t' to 'size_s'.* +ha_berkeley.cc : .*conversion from 'ulonglong' to 'char'.* # # The following should be fixed by the ndb team # .*/ndb/.* : .*used uninitialized in this function.* +.*/ndb/.* : .*unused variable.* +.*/ndb/.* : .*defined but not used.* + +# +# Unexplanable (?) stuff +# +listener.cc : .*conversion from 'SOCKET' to 'int'.* +net_serv.cc : .*conversion from 'SOCKET' to 'int'.* +mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 567 + +# +# Wrong compiler warnings +# +.* : .*no matching operator delete found; memory will not be freed if initialization throws an exception.* + +# +# Viossl warnings - fixed in 5.1, disabled in 5.0. Too large to be changed +# in 5.0. Please do not merge upwards. +# +socket_wrapper.cpp : .*truncation of constant value.* +viossl.c : .*conversion from 'SOCKET' to 'socket_t'.* From d93c7f39f8ff8db3a6106a474a3791d7b1b9e9c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 11:23:12 +0400 Subject: [PATCH 72/78] Additional fix for bug N 15126 Replacing local directory. mysql-test/r/mysqlbinlog.result: Additional fix for bug N 15126 mysql-test/t/mysqlbinlog.test: Additional fix for bug N 15126 --- mysql-test/r/mysqlbinlog.result | 14 +++++++------- mysql-test/t/mysqlbinlog.test | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 8ca2422443d..0664cc73608 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -307,23 +307,23 @@ SET @@session.sql_mode=0/*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; create table t1 (a varchar(64) character set utf8)/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE '/home/bar/mysql-5.0.b15126/mysql-test/var/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; SET TIMESTAMP=1000000000/*!*/; drop table t1/*!*/; DELIMITER ; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index fe86d850267..f992729d2be 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -211,6 +211,7 @@ load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8 select hex(a) from t1; drop table t1; flush logs; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000011 # End of 5.0 tests From b3fafa40fc839141ba525466e0c98d3db01631f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 08:41:13 +0100 Subject: [PATCH 73/78] Fixes of compilation warnings and errors. sql/mysql_priv.h: Removing compiler warning "NULL used in arithmetic" sql/mysqld.cc: First argument to WARN_DEPRECATED is supposed to be a pointer (to THD structure) sql/sql_insert.cc: Removing compiler warning "unused variable". Apparently query is not used when compiling libmysqld. sql/sql_yacc.yy: Removing compiler error "Macro already defined" --- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 2 +- sql/sql_insert.cc | 2 ++ sql/sql_yacc.yy | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 97f56c83b4f..7ca0d567253 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -100,7 +100,7 @@ void net_set_read_timeout(NET *net, uint timeout); #define WARN_DEPRECATED(Thd,Ver,Old,New) \ do { \ DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \ - if (Thd != NULL) \ + if (((gptr)Thd) != NULL) \ push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \ (Old), (Ver), (New)); \ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5709a12c03d..f8fbbee5644 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6957,7 +6957,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), if (!slave_warning_issued) //only show the warning once { slave_warning_issued = true; - WARN_DEPRECATED(0, "5.2", "for replication startup options", + WARN_DEPRECATED(NULL, "5.2", "for replication startup options", "'CHANGE MASTER'"); } break; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 613b28faf63..b44cbf46a31 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -381,7 +381,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, List_item *values; Name_resolution_context *context; Name_resolution_context_state ctx_state; +#ifndef EMBEDDED_LIBRARY char *query= thd->query; +#endif bool log_on= (thd->options & OPTION_BIN_LOG) || (!(thd->security_ctx->master_access & SUPER_ACL)); thr_lock_type lock_type = table_list->lock_type; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index efe8d85d8f5..933fa839e71 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -46,6 +46,7 @@ const LEX_STRING null_lex_str={0,0}; #define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if (my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }} +#undef WARN_DEPRECATED /* this macro is also defined in mysql_priv.h */ #define WARN_DEPRECATED(A,B) \ push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN, \ ER_WARN_DEPRECATED_SYNTAX, \ From ef02cb6305cab784573a8a607889bf3420c946b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 11:52:25 +0400 Subject: [PATCH 74/78] Renaming recenly added test case, because of name conflict when merging into 5.1. mysql-test/t/rpl_loaddata_charset.test: Rename: mysql-test/t/rpl_loaddata2.test -> mysql-test/t/rpl_loaddata_charset.test mysql-test/r/rpl_loaddata_charset.result: Rename: mysql-test/r/rpl_loaddata2.result -> mysql-test/r/rpl_loaddata_charset.result --- .../r/{rpl_loaddata2.result => rpl_loaddata_charset.result} | 0 mysql-test/t/{rpl_loaddata2.test => rpl_loaddata_charset.test} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename mysql-test/r/{rpl_loaddata2.result => rpl_loaddata_charset.result} (100%) rename mysql-test/t/{rpl_loaddata2.test => rpl_loaddata_charset.test} (100%) diff --git a/mysql-test/r/rpl_loaddata2.result b/mysql-test/r/rpl_loaddata_charset.result similarity index 100% rename from mysql-test/r/rpl_loaddata2.result rename to mysql-test/r/rpl_loaddata_charset.result diff --git a/mysql-test/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata_charset.test similarity index 100% rename from mysql-test/t/rpl_loaddata2.test rename to mysql-test/t/rpl_loaddata_charset.test From 30ece9b060bc141becd5ead9f67058ecfda21bec Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 12:26:07 +0400 Subject: [PATCH 75/78] Fix for wrong replace command. --- mysql-test/r/mysqlbinlog.result | 14 +++++++------- mysql-test/t/mysqlbinlog.test | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 0664cc73608..9ee2a1e769a 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -307,23 +307,23 @@ SET @@session.sql_mode=0/*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; create table t1 (a varchar(64) character set utf8)/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; +load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; SET TIMESTAMP=1000000000/*!*/; drop table t1/*!*/; DELIMITER ; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index f992729d2be..d35bd16c1f9 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -211,7 +211,7 @@ load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8 select hex(a) from t1; drop table t1; flush logs; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR --exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000011 # End of 5.0 tests From c04d5985c1cee79921de5a8ca4b684e82d2c5695 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 10:52:25 +0200 Subject: [PATCH 76/78] Disabled compiler warnings. sql/ha_archive.cc: Fixed a warning from unused computed value. This block is only used in debug mode and changes nothing. support-files/compiler_warnings.supp: Disabled a warning from BDB. --- sql/ha_archive.cc | 4 +++- support-files/compiler_warnings.supp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 730d8b46945..2ee514f29c9 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -749,10 +749,12 @@ int ha_archive::write_row(byte *buf) DBUG_PRINT("archive",("MyPack is %d\n", (*field)->data_length((char*) buf + (*field)->offset()))); if ((*field)->real_type() == MYSQL_TYPE_VARCHAR) { +#ifndef DBUG_OFF uint actual_length= (*field)->data_length((char*) buf + (*field)->offset()); - IF_DBUG(uint offset=) (*field)->offset() + actual_length + + uint offset= (*field)->offset() + actual_length + (actual_length > 255 ? 2 : 1); DBUG_PRINT("archive",("Offset is %d -> %d\n", actual_length, offset)); +#endif /* if ((*field)->pack_length() + (*field)->offset() != offset) bzero(buf + offset, (size_t)((*field)->pack_length() + (actual_length > 255 ? 2 : 1) - (*field)->data_length)); diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 2cf43f230c3..46f706198c0 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -30,6 +30,7 @@ pars0lex.l: .*conversion from 'ulint' to 'int', possible loss of data.* .*/bdb/.* : .*empty body in an if-statement.* .*/bdb/.* : .*conversion from 'u?lint' to 'int', possible loss of data.* db_vrfy.c : .*comparison is always false due to limited range of data type.* +dbm.c : .*'item.dsize' is used uninitialized in this function.* # # Ignore all conversion warnings on windows 64 From 33ccc75633e06ff5d8948713262b22c2c177371b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 11:28:33 +0200 Subject: [PATCH 77/78] Fixed compiler warnings. client/mysqltest.c: Fixed a compiler warning. support-files/compiler_warnings.supp: Suppressed compiler warnings on Win 64. --- client/mysqltest.c | 2 +- support-files/compiler_warnings.supp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 074eeb0fac4..f6dea1d6b3e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -6730,7 +6730,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, if ((start_off=subs[back_ref_num].rm_so) > -1 && (end_off=subs[back_ref_num].rm_eo) > -1) { - int block_len= end_off - start_off; + int block_len= (int) (end_off - start_off); memcpy(res_p,str_p + start_off, block_len); res_p += block_len; } diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 46f706198c0..a147255f9a4 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -48,6 +48,7 @@ dbm.c : .*'item.dsize' is used uninitialized in this function.* .* : conversion from '.*size_t' to 'uint32'.* .* : conversion from '.*size_t' to 'off_t'.* .* : conversion from '.*size_t' to 'size_s'.* +.* : conversion from 'u?lint' to 'int'.* ha_berkeley.cc : .*conversion from 'ulonglong' to 'char'.* # @@ -74,4 +75,5 @@ mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 567 # in 5.0. Please do not merge upwards. # socket_wrapper.cpp : .*truncation of constant value.* +socket_wrapper.hpp : .*truncation of constant value.* viossl.c : .*conversion from 'SOCKET' to 'socket_t'.* From 8fa0d1b98e701f3643093696ffe6e6ea02481a82 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 10:40:48 +0100 Subject: [PATCH 78/78] Removing two more compilation warnings. sql/slave.cc: Guard declaration of variable to avoid "unused variable" warning. sql/sql_repl.cc: Guard declaration of variable to avoid "unused variable" warning. --- sql/slave.cc | 2 ++ sql/sql_repl.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sql/slave.cc b/sql/slave.cc index 572fafd58b5..9d466ce5dad 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -52,7 +52,9 @@ ulonglong relay_log_space_limit = 0; int disconnect_slave_event_count = 0, abort_slave_event_count = 0; int events_till_abort = -1; +#ifndef DBUG_OFF static int events_till_disconnect = -1; +#endif typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 1702783b5b7..b451c612398 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -22,7 +22,9 @@ int max_binlog_dump_events = 0; // unlimited my_bool opt_sporadic_binlog_dump_fail = 0; +#ifndef DBUG_OFF static int binlog_dump_count = 0; +#endif /* fake_rotate_event() builds a fake (=which does not exist physically in any