From 679b293a47a430bf8b4aad9273f144196d4c144e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 10 Jan 2006 11:35:21 +0100 Subject: [PATCH 1/6] Bug #13228 open table cache not flushed when table schema changed - Close open unused handlers when a schema error occurs. --- mysql-test/r/ndb_alter_table2.result | 42 ++++++++++++++ mysql-test/t/ndb_alter_table2.test | 83 ++++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 7 +++ 3 files changed, 132 insertions(+) create mode 100644 mysql-test/r/ndb_alter_table2.result create mode 100644 mysql-test/t/ndb_alter_table2.test diff --git a/mysql-test/r/ndb_alter_table2.result b/mysql-test/r/ndb_alter_table2.result new file mode 100644 index 00000000000..399578dc97b --- /dev/null +++ b/mysql-test/r/ndb_alter_table2.result @@ -0,0 +1,42 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL +) ENGINE=ndbcluster; +BEGIN; +INSERT INTO t1 VALUES (9410,9412); +BEGIN; +INSERT INTO t1 VALUES (9411,9412); +BEGIN; +INSERT INTO t1 VALUES (9412,9412); +BEGIN; +INSERT INTO t1 VALUES (9413,9412); +BEGIN; +INSERT INTO t1 VALUES (9414,9412); +BEGIN; +INSERT INTO t1 VALUES (9415,9412); +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +drop table t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +c INT NOT NULL +) ENGINE=ndbcluster; +select * from t1; +ERROR HY000: Got error 241 'Invalid schema object version' from ndbcluster +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +drop table t1; diff --git a/mysql-test/t/ndb_alter_table2.test b/mysql-test/t/ndb_alter_table2.test new file mode 100644 index 00000000000..3861fcc6c9d --- /dev/null +++ b/mysql-test/t/ndb_alter_table2.test @@ -0,0 +1,83 @@ +-- source include/have_ndb.inc +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); +connect (con3,localhost,root,,test); +connect (con4,localhost,root,,test); +connect (con5,localhost,root,,test); +connect (con6,localhost,root,,test); + +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL +) ENGINE=ndbcluster; + +connection con1; +BEGIN; +INSERT INTO t1 VALUES (9410,9412); +connection con2; +BEGIN; +--send +INSERT INTO t1 VALUES (9411,9412); +connection con3; +BEGIN; +--send +INSERT INTO t1 VALUES (9412,9412); +connection con4; +BEGIN; +--send +INSERT INTO t1 VALUES (9413,9412); +connection con5; +BEGIN; +--send +INSERT INTO t1 VALUES (9414,9412); +connection con6; +BEGIN; +--send +INSERT INTO t1 VALUES (9415,9412); +connection con1; +sleep 1; + +ROLLBACK; +connection con2; +reap; +ROLLBACK; +connection con3; +reap; +ROLLBACK; +connection con4; +reap; +ROLLBACK; +connection con5; +reap; +ROLLBACK; +connection con6; +reap; +ROLLBACK; + +connection server2; + +drop table t1; +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL, + c INT NOT NULL +) ENGINE=ndbcluster; + +connection server1; + +--error 1296 +select * from t1; +select * from t1; +select * from t1; +select * from t1; +select * from t1; +select * from t1; + +drop table t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0552eded9b6..f357a1e814d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -510,6 +510,13 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) case NdbError::SchemaError: invalidate_dictionary_cache(TRUE); + /* Close other open handlers not used by any thread */ + TABLE_LIST table_list; + bzero((char*) &table_list,sizeof(table_list)); + table_list.db= m_dbname; + table_list.alias= table_list.table_name= m_tabname; + close_cached_tables(current_thd, 0, &table_list); + if (err.code==284) { /* From bf5f4a3c053c57d7b8a2f7b266527a02db5cd53b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 7 Apr 2006 11:18:45 +0200 Subject: [PATCH 2/6] Bug#13228 open table cache not flushed when table schema changed - Error 1296 is no longer returned on first select after DROP/CREATE. --- mysql-test/r/ndb_alter_table2.result | 2 +- mysql-test/t/ndb_alter_table2.test | 1 - sql/ha_ndbcluster.cc | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_alter_table2.result b/mysql-test/r/ndb_alter_table2.result index 399578dc97b..0d2e2289f91 100644 --- a/mysql-test/r/ndb_alter_table2.result +++ b/mysql-test/r/ndb_alter_table2.result @@ -28,7 +28,7 @@ b INT NOT NULL, c INT NOT NULL ) ENGINE=ndbcluster; select * from t1; -ERROR HY000: Got error 241 'Invalid schema object version' from ndbcluster +a b c select * from t1; a b c select * from t1; diff --git a/mysql-test/t/ndb_alter_table2.test b/mysql-test/t/ndb_alter_table2.test index 3861fcc6c9d..4464f37a030 100644 --- a/mysql-test/t/ndb_alter_table2.test +++ b/mysql-test/t/ndb_alter_table2.test @@ -72,7 +72,6 @@ CREATE TABLE t1 ( connection server1; ---error 1296 select * from t1; select * from t1; select * from t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c88aaeb7298..caab541652a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -556,6 +556,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) ERR_PRINT(err); switch (err.classification) { case NdbError::SchemaError: + { invalidate_dictionary_cache(TRUE); /* Close other open handlers not used by any thread */ @@ -583,6 +584,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) DBUG_PRINT("info", ("Table exists but must have changed")); } break; + } default: break; } From 98904a8caa8a1e0683c8608fb3fb22589c12529f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 7 Apr 2006 11:26:21 +0200 Subject: [PATCH 3/6] Add new function mysql_get_ssl_cipher to libmysl and use it from client to avoid dependency on SSL libs from mysql client. --- client/mysql.cc | 5 ++--- include/mysql.h | 1 + sql-common/client.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2001056dea1..a0bc6f52f29 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3212,10 +3212,9 @@ com_status(String *buffer __attribute__((unused)), mysql_free_result(result); } #ifdef HAVE_OPENSSL - if (mysql.net.vio && mysql.net.vio->ssl_arg && - SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg)) + if (mysql_get_ssl_cipher(&mysql)) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg)); + mysql_get_ssl_cipher(&mysql)); else #endif /* HAVE_OPENSSL */ tee_puts("SSL:\t\t\tNot in use", stdout); diff --git a/include/mysql.h b/include/mysql.h index 925a4525378..6217ce631b5 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -409,6 +409,7 @@ MYSQL * STDCALL mysql_init(MYSQL *mysql); my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); +const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql); my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db); MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, diff --git a/sql-common/client.c b/sql-common/client.c index cd50960164b..a923e22a74a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1535,6 +1535,27 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) mysql->connector_fd = 0; DBUG_VOID_RETURN; } + + +/* + Return the SSL cipher (if any) used for current + connection to the server. + + SYNOPSYS + mysql_get_ssl_cipher() + mysql pointer to the mysql connection + +*/ + +const char * STDCALL +mysql_get_ssl_cipher(MYSQL *mysql) +{ + DBUG_ENTER("mysql_get_ssl_cipher"); + if (mysql->net.vio && mysql->net.vio->ssl_arg) + SSL_get_cipher_name((SSL*)mysql->net.vio->ssl_arg); + DBUG_RETURN(NULL); +} + #endif /* HAVE_OPENSSL */ From 24a6dd64b557b39116a24f870bb5bffd2c287020 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 10 Apr 2006 12:23:20 +0200 Subject: [PATCH 4/6] Update implementation of new function 'mysql_get_ssl_cipher' after review --- client/mysql.cc | 4 ++-- libmysql/libmysql.def | 1 + sql-common/client.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index a0bc6f52f29..077ea69c3ca 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3212,9 +3212,9 @@ com_status(String *buffer __attribute__((unused)), mysql_free_result(result); } #ifdef HAVE_OPENSSL - if (mysql_get_ssl_cipher(&mysql)) + if ((status= mysql_get_ssl_cipher(&mysql))) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - mysql_get_ssl_cipher(&mysql)); + status); else #endif /* HAVE_OPENSSL */ tee_puts("SSL:\t\t\tNot in use", stdout); diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index a469c67c466..cf45e20a697 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -65,6 +65,7 @@ EXPORTS mysql_get_proto_info mysql_get_server_info mysql_get_client_version + mysql_get_ssl_cipher mysql_info mysql_init mysql_insert_id diff --git a/sql-common/client.c b/sql-common/client.c index 1303b26c325..72745d72b12 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1552,7 +1552,7 @@ mysql_get_ssl_cipher(MYSQL *mysql) { DBUG_ENTER("mysql_get_ssl_cipher"); if (mysql->net.vio && mysql->net.vio->ssl_arg) - SSL_get_cipher_name((SSL*)mysql->net.vio->ssl_arg); + DBUG_RETURN(SSL_get_cipher_name((SSL*)mysql->net.vio->ssl_arg)); DBUG_RETURN(NULL); } From 475e1f6a53ca97faf880f6ac861fc390b144ace0 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 10 Apr 2006 15:11:37 +0200 Subject: [PATCH 5/6] Bug#15069 [patch] my_print_defaults does'nt care --sysconfdir - Grab the path from "configure --sysconfdir=" and set it as the first place to look for my.cnf files Do this both in Makefiles for libmysql and mysys - Patch provided by Francesco Riosa. Thank you! --- libmysql/Makefile.shared | 1 + mysys/Makefile.am | 1 + mysys/default.c | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index c4c9c0036e2..fd0a4eb051d 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -85,6 +85,7 @@ DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ -DDEFAULT_HOME_ENV=MYSQL_HOME \ -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \ + -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs) # The automatic dependencies miss this diff --git a/mysys/Makefile.am b/mysys/Makefile.am index ee0dcb544b6..2de8d7820f5 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -70,6 +70,7 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ -DDEFAULT_HOME_ENV=MYSQL_HOME \ -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \ + -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \ @DEFS@ libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@ diff --git a/mysys/default.c b/mysys/default.c index edd02402a2a..90f8dc5f689 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -48,7 +48,7 @@ char *defaults_extra_file=0; /* Which directories are searched for options (and in which order) */ -#define MAX_DEFAULT_DIRS 6 +#define MAX_DEFAULT_DIRS 7 const char *default_directories[MAX_DEFAULT_DIRS + 1]; #ifdef __WIN__ @@ -959,11 +959,13 @@ static uint my_get_system_windows_directory(char *buffer, uint size) 4. getenv(DEFAULT_HOME_ENV) 5. Directory above where the executable is located 6. "" + 7. --sysconfdir= On Novell NetWare, this is: 1. sys:/etc/ 2. getenv(DEFAULT_HOME_ENV) 3. "" + 4. --sysconfdir= On OS/2, this is: 1. getenv(ETC) @@ -971,12 +973,14 @@ static uint my_get_system_windows_directory(char *buffer, uint size) 3. getenv(DEFAULT_HOME_ENV) 4. "" 5. "~/" + 6. --sysconfdir= Everywhere else, this is: 1. /etc/ 2. getenv(DEFAULT_HOME_ENV) 3. "" 4. "~/" + 5. --sysconfdir= */ @@ -1040,6 +1044,10 @@ static void init_default_directories() } *ptr++= (char *)&config_dir; } +#endif +#ifdef DEFAULT_SYSCONFDIR + if (DEFAULT_SYSCONFDIR != "") + *ptr++= DEFAULT_SYSCONFDIR; #endif *ptr= 0; /* end marker */ } From e805afde11a18c55f9a86ad1e07f80d33f26a29e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 10 Apr 2006 18:08:54 +0200 Subject: [PATCH 6/6] Step 1 in removing mysql-test-run.sh from 5.1 and up --- Makefile.am | 39 ++++++++++-------------------------- mysql-test/mysql-test-run.sh | 12 +++++++++++ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3f17cbe797d..eb81344acb6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -119,54 +119,37 @@ tags: # making sure each user use different ports. test: - cd mysql-test ; \ - ./mysql-test-run --mysqld=--binlog-format=statement && \ - ./mysql-test-run --ps-protocol --mysqld=--binlog-format=row - -test-full: - cd mysql-test ; \ - ./mysql-test-run --mysqld=--binlog-format=statement && \ - ./mysql-test-run --ps-protocol --mysqld=--binlog-format=statement && \ - ./mysql-test-run --mysqld=--binlog-format=row && \ - ./mysql-test-run --ps-protocol --mysqld=--binlog-format=row - -test-force: - cd mysql-test ; \ - ./mysql-test-run --force --mysqld=--binlog-format=statement && \ - ./mysql-test-run --ps-protocol --force --mysqld=--binlog-format=row - -test-force-full: - cd mysql-test ; \ - ./mysql-test-run --force --mysqld=--binlog-format=statement && \ - ./mysql-test-run --force --ps-protocol --mysqld=--binlog-format=statement && \ - ./mysql-test-run --force --mysqld=--binlog-format=row && \ - ./mysql-test-run --force --ps-protocol --mysqld=--binlog-format=row - -# We are testing a new Perl version of the test script -test-pl: cd mysql-test ; \ ./mysql-test-run.pl --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --ps-protocol --mysqld=--binlog-format=row -test-full-pl: +test-full: cd mysql-test ; \ ./mysql-test-run.pl --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --ps-protocol --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --mysqld=--binlog-format=row && \ ./mysql-test-run.pl --ps-protocol --mysqld=--binlog-format=row -test-force-pl: +test-force: cd mysql-test ; \ ./mysql-test-run.pl --force --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --ps-protocol --force --mysqld=--binlog-format=row -test-force-full-pl: +test-force-full: cd mysql-test ; \ ./mysql-test-run.pl --force --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --force --ps-protocol --mysqld=--binlog-format=statement && \ ./mysql-test-run.pl --force --mysqld=--binlog-format=row && \ ./mysql-test-run.pl --force --ps-protocol --mysqld=--binlog-format=row +# Keep these for a while +test-pl: test +test-full-pl: test-full +test-force-pl: test-force +test-force-full-pl: test-force-full + + + # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 4485d8ca073..7bc56e24f4b 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -7,6 +7,18 @@ # List of failed cases (--force) backported from 4.1 by Joerg # :-) + +echo "##################################################"; +echo "This script is deprecated and will soon be removed"; +echo "Use mysql-test-run.pl instead"; +echo "Now sleeping 20 seconds..."; +echo "##################################################"; +sleep 20; +echo "continuing"; +echo; + + + #++ # Access Definitions #--