From 10e329ffd489d5cac4678b5beb08cbc61bc074a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 May 2007 14:14:27 +0200 Subject: [PATCH 001/156] Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment_increment for Ndb --- mysql-test/r/ndb_insert.result | 169 +++++++++++++++++++++++++++++++++ mysql-test/t/ndb_insert.test | 137 ++++++++++++++++++++++++++ ndb/include/ndbapi/Ndb.hpp | 9 +- ndb/src/ndbapi/Ndb.cpp | 95 +++++++++++++----- sql/ha_ndbcluster.cc | 18 ++-- sql/handler.cc | 6 +- sql/handler.h | 3 +- 7 files changed, 401 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index e7275bde2b8..b5349ecb59c 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -657,3 +657,172 @@ a b 2 NULL 3 NULL drop table t1; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +1 1 0 +11 2 1 +21 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_offset=5; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +27 4 3 +35 5 4 +99 6 5 +105 7 6 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +7 +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_increment=2; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +1 1 0 +3 2 1 +5 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; +SET @@session.auto_increment_offset=1; +SET @@session.auto_increment_increment=1; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +7 1 0 +8 2 1 +9 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 3; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +15 1 0 +25 2 1 +35 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 5; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 100; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +105 1 0 +115 2 1 +125 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index f346b7dc4ab..b8f00d6f6aa 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -639,4 +639,141 @@ insert ignore into t1 values (1,0), (2,0), (2,null), (3,null); select * from t1 order by a; drop table t1; +# Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM; + +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_offset=5; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_increment=2; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; + +SET @@session.auto_increment_offset=1; +SET @@session.auto_increment_increment=1; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 3; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 5; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 100; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + # End of 4.1 tests diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp index b3c9acd4e20..f83db77739e 100644 --- a/ndb/include/ndbapi/Ndb.hpp +++ b/ndb/include/ndbapi/Ndb.hpp @@ -1388,9 +1388,11 @@ public: * @return 0 or -1 on error, and tupleId in out parameter */ int getAutoIncrementValue(const char* aTableName, - Uint64 & tupleId, Uint32 cacheSize); + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1); int getAutoIncrementValue(const NdbDictionary::Table * aTable, - Uint64 & tupleId, Uint32 cacheSize); + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1); int readAutoIncrementValue(const char* aTableName, Uint64 & tupleId); int readAutoIncrementValue(const NdbDictionary::Table * aTable, @@ -1401,7 +1403,8 @@ public: Uint64 tupleId, bool increase); private: int getTupleIdFromNdb(Ndb_local_table_info* info, - Uint64 & tupleId, Uint32 cacheSize); + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1 ); int readTupleIdFromNdb(Ndb_local_table_info* info, Uint64 & tupleId); int setTupleIdInNdb(Ndb_local_table_info* info, diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 449f287dc1d..941bfc88b24 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -767,17 +767,27 @@ Ndb::getNodeId() } /**************************************************************************** -Uint64 getTupleIdFromNdb( Uint32 aTableId, Uint32 cacheSize ); +Uint64 getAutoIncrementValue( const char* aTableName, + Uint64 & tupleId, + Uint32 cacheSize, + Uint64 step, + Uint64 start); -Parameters: aTableId : The TableId. - cacheSize: Prefetch this many values -Remark: Returns a new TupleId to the application. - The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId. - It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp. +Parameters: aTableName (IN) : The table name. + autoValue (OUT) : Returns new autoincrement value + cacheSize (IN) : Prefetch this many values + step (IN) : Specifies the step between the + autoincrement values. + start (IN) : Start value for first value +Remark: Returns a new autoincrement value to the application. + The autoincrement values can be increased by steps + (default 1) and a number of values can be prefetched + by specifying cacheSize (default 10). ****************************************************************************/ int Ndb::getAutoIncrementValue(const char* aTableName, - Uint64 & tupleId, Uint32 cacheSize) + Uint64 & autoValue, Uint32 cacheSize, + Uint64 step, Uint64 start) { DBUG_ENTER("Ndb::getAutoIncrementValue"); BaseString internal_tabname(internalize_table_name(aTableName)); @@ -788,15 +798,17 @@ Ndb::getAutoIncrementValue(const char* aTableName, theError.code = theDictionary->getNdbError().code; DBUG_RETURN(-1); } - if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) + DBUG_PRINT("info", ("step %lu", (ulong) step)); + if (getTupleIdFromNdb(info, autoValue, cacheSize, step, start) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %lu", (ulong) tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong) autoValue)); DBUG_RETURN(0); } int Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, - Uint64 & tupleId, Uint32 cacheSize) + Uint64 & autoValue, Uint32 cacheSize, + Uint64 step, Uint64 start) { DBUG_ENTER("Ndb::getAutoIncrementValue"); assert(aTable != 0); @@ -809,36 +821,73 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, theError.code = theDictionary->getNdbError().code; DBUG_RETURN(-1); } - if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) + DBUG_PRINT("info", ("step %lu", (ulong) step)); + if (getTupleIdFromNdb(info, autoValue, cacheSize, step, start) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong) autoValue)); DBUG_RETURN(0); } int Ndb::getTupleIdFromNdb(Ndb_local_table_info* info, - Uint64 & tupleId, Uint32 cacheSize) + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step, Uint64 start) { +/* + Returns a new TupleId to the application. + The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId. + It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp. + In most cases step= start= 1, in which case we get: + 1,2,3,4,5,... + If step=10 and start=5 and first number is 1, we get: + 5,15,25,35,... +*/ DBUG_ENTER("Ndb::getTupleIdFromNdb"); - if (info->m_first_tuple_id != info->m_last_tuple_id) + DBUG_PRINT("info", ("Step %lu (%lu,%lu)", (ulong) step, (ulong) info->m_first_tuple_id, (ulong) info->m_last_tuple_id)); + /* + Check if the next value can be taken from the pre-fetched + sequence. + */ + if (info->m_first_tuple_id != info->m_last_tuple_id && + info->m_first_tuple_id + step <= info->m_last_tuple_id) { assert(info->m_first_tuple_id < info->m_last_tuple_id); - tupleId = ++info->m_first_tuple_id; - DBUG_PRINT("info", ("next cached value %lu", (ulong)tupleId)); + info->m_first_tuple_id += step; + tupleId = info->m_first_tuple_id; + DBUG_PRINT("info", ("Next cached value %lu", (ulong) tupleId)); } else { + /* + If start value is greater than step it is ignored + */ + Uint64 offset = (start > step) ? 1 : start; + + /* + Pre-fetch a number of values depending on cacheSize + */ if (cacheSize == 0) cacheSize = 1; - DBUG_PRINT("info", ("reading %u values from database", (uint)cacheSize)); + + DBUG_PRINT("info", ("Reading %u values from database", (uint)cacheSize)); /* * reserve next cacheSize entries in db. adds cacheSize to NEXTID - * and returns first tupleId in the new range. + * and returns first tupleId in the new range. If tupleId's are + * incremented in steps then multiply the cacheSize with step size. */ - Uint64 opValue = cacheSize; + Uint64 opValue = cacheSize * step; + if (opTupleIdOnNdb(info, opValue, 0) == -1) DBUG_RETURN(-1); - tupleId = opValue; + DBUG_PRINT("info", ("Next value fetched from database %lu", (ulong) opValue)); + DBUG_PRINT("info", ("Increasing %lu by offset %lu, increment is %lu", (ulong) (ulong) opValue, (ulong) offset, (ulong) step)); + Uint64 current, next; + next = ((Uint64) (opValue + step - offset)) / step; + next = next * step + offset; + current = (next < step) ? next : next - step; + tupleId = (opValue <= current) ? current : next; + DBUG_PRINT("info", ("Returning %lu", (ulong) tupleId)); + info->m_first_tuple_id = tupleId; } DBUG_RETURN(0); } @@ -1065,9 +1114,9 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op) } else { - DBUG_PRINT("info", - ("Setting next auto increment value (db) to %lu", - (ulong)opValue)); + DBUG_PRINT("info", + ("Setting next auto increment value (db) to %lu", + (ulong)opValue)); info->m_first_tuple_id = info->m_last_tuple_id = opValue - 1; } break; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9b48e0d4f38..175a81e226c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2264,12 +2264,10 @@ int ha_ndbcluster::write_row(byte *record) if (has_auto_increment) { int error; - + m_skip_auto_increment= FALSE; if ((error= update_auto_increment())) DBUG_RETURN(error); - /* Ensure that handler is always called for auto_increment values */ - thd->next_insert_id= 0; m_skip_auto_increment= !auto_increment_column_changed; } } @@ -2312,8 +2310,10 @@ int ha_ndbcluster::write_row(byte *record) int ret; Uint64 auto_value; uint retries= NDB_AUTO_INCREMENT_RETRIES; + do { - ret= ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, 1); + ret= ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, 1); } while (ret == -1 && --retries && ndb->getNdbError().status == NdbError::TemporaryError); @@ -2322,7 +2322,7 @@ int ha_ndbcluster::write_row(byte *record) if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } - else + else { if ((res= set_primary_key_from_record(op, record))) return res; @@ -4841,6 +4841,8 @@ ulonglong ha_ndbcluster::get_auto_increment() { int cache_size; Uint64 auto_value; + Uint64 step= current_thd->variables.auto_increment_increment; + Uint64 start= current_thd->variables.auto_increment_offset; DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); Ndb *ndb= get_ndb(); @@ -4861,7 +4863,8 @@ ulonglong ha_ndbcluster::get_auto_increment() ret= m_skip_auto_increment ? ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) : - ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, cache_size); + ndb->getAutoIncrementValue((const NDBTAB *) m_table, + auto_value, cache_size, step, start); } while (ret == -1 && --retries && ndb->getNdbError().status == NdbError::TemporaryError); @@ -4894,7 +4897,8 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): HA_NEED_READ_RANGE_BUFFER | HA_CAN_GEOMETRY | HA_CAN_BIT_FIELD | - HA_PARTIAL_COLUMN_READ), + HA_PARTIAL_COLUMN_READ | + HA_EXTERNAL_AUTO_INCREMENT), m_share(0), m_use_write(FALSE), m_ignore_dup_key(FALSE), diff --git a/sql/handler.cc b/sql/handler.cc index c6c31593a5f..31c3827dc25 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1598,6 +1598,8 @@ int handler::update_auto_increment() ulonglong nr; THD *thd= table->in_use; struct system_variables *variables= &thd->variables; + bool external_auto_increment= + table->file->table_flags() & HA_EXTERNAL_AUTO_INCREMENT; DBUG_ENTER("handler::update_auto_increment"); /* @@ -1615,12 +1617,12 @@ int handler::update_auto_increment() adjust_next_insert_id_after_explicit_value(nr); DBUG_RETURN(0); } - if (!(nr= thd->next_insert_id)) + if (external_auto_increment || !(nr= thd->next_insert_id)) { if ((nr= get_auto_increment()) == ~(ulonglong) 0) DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED); // Mark failure - if (variables->auto_increment_increment != 1) + if (!external_auto_increment && variables->auto_increment_increment != 1) nr= next_insert_id(nr-1, variables); /* Update next row based on the found value. This way we don't have to diff --git a/sql/handler.h b/sql/handler.h index 9863d541b5f..8847d0306fb 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -93,7 +93,8 @@ #define HA_CAN_BIT_FIELD (1 << 28) /* supports bit fields */ #define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */ #define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30) - +/* The storage engine manages auto_increment itself */ +#define HA_EXTERNAL_AUTO_INCREMENT (1 << 31) /* bits in index_flags(index_number) for what you can do with index */ #define HA_READ_NEXT 1 /* TODO really use this flag */ From b1f3d4feaa2b94ff0e720ba2d46b2e2401dcd0fa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 May 2007 17:09:06 +0200 Subject: [PATCH 002/156] Ndb.hpp, Ndb.cpp, ha_ndbcluster.cc: Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment sql/ha_ndbcluster.cc: Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment storage/ndb/include/ndbapi/Ndb.hpp: Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment storage/ndb/src/ndbapi/Ndb.cpp: Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment --- sql/ha_ndbcluster.cc | 5 +- storage/ndb/include/ndbapi/Ndb.hpp | 11 ++-- storage/ndb/src/ndbapi/Ndb.cpp | 92 ++++++++++++++++++++++-------- 3 files changed, 79 insertions(+), 29 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index be0571de02a..da63ca8361f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6056,7 +6056,7 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values) -{ +{ int cache_size; Uint64 auto_value; DBUG_ENTER("get_auto_increment"); @@ -6080,7 +6080,8 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment, ret= m_skip_auto_increment ? ndb->readAutoIncrementValue(m_table, g.range, auto_value) : - ndb->getAutoIncrementValue(m_table, g.range, auto_value, cache_size); + ndb->getAutoIncrementValue(m_table, g.range, + auto_value, cache_size, increment, offset); } while (ret == -1 && --retries && ndb->getNdbError().status == NdbError::TemporaryError); diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp index 5f96408ea30..ae2eefff1b2 100644 --- a/storage/ndb/include/ndbapi/Ndb.hpp +++ b/storage/ndb/include/ndbapi/Ndb.hpp @@ -1488,12 +1488,15 @@ public: int initAutoIncrement(); int getAutoIncrementValue(const char* aTableName, - Uint64 & tupleId, Uint32 cacheSize); + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1); int getAutoIncrementValue(const NdbDictionary::Table * aTable, - Uint64 & tupleId, Uint32 cacheSize); + Uint64 & tupleId, Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1); int getAutoIncrementValue(const NdbDictionary::Table * aTable, TupleIdRange & range, Uint64 & tupleId, - Uint32 cacheSize); + Uint32 cacheSize, + Uint64 step = 1, Uint64 start = 1); int readAutoIncrementValue(const char* aTableName, Uint64 & tupleId); int readAutoIncrementValue(const NdbDictionary::Table * aTable, @@ -1510,7 +1513,7 @@ public: private: int getTupleIdFromNdb(const NdbTableImpl* table, TupleIdRange & range, Uint64 & tupleId, - Uint32 cacheSize); + Uint32 cacheSize, Uint64 step = 1, Uint64 start = 1); int readTupleIdFromNdb(const NdbTableImpl* table, TupleIdRange & range, Uint64 & tupleId); int setTupleIdInNdb(const NdbTableImpl* table, diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp index 78b7af5522b..84ff477b59b 100644 --- a/storage/ndb/src/ndbapi/Ndb.cpp +++ b/storage/ndb/src/ndbapi/Ndb.cpp @@ -754,17 +754,27 @@ Ndb::getNodeId() } /**************************************************************************** -Uint64 getTupleIdFromNdb( Uint32 aTableId, Uint32 cacheSize ); +Uint64 getAutoIncrementValue( const char* aTableName, + Uint64 & autoValue, + Uint32 cacheSize, + Uint64 step, + Uint64 start); -Parameters: aTableId : The TableId. - cacheSize: Prefetch this many values -Remark: Returns a new TupleId to the application. - The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId. - It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp. +Parameters: aTableName (IN) : The table name. + autoValue (OUT) : Returns new autoincrement value + cacheSize (IN) : Prefetch this many values + step (IN) : Specifies the step between the + autoincrement values. + start (IN) : Start value for first value +Remark: Returns a new autoincrement value to the application. + The autoincrement values can be increased by steps + (default 1) and a number of values can be prefetched + by specifying cacheSize (default 10). ****************************************************************************/ int Ndb::getAutoIncrementValue(const char* aTableName, - Uint64 & tupleId, Uint32 cacheSize) + Uint64 & autoValue, Uint32 cacheSize, + Uint64 step, Uint64 start) { DBUG_ENTER("Ndb::getAutoIncrementValue"); ASSERT_NOT_MYSQLD; @@ -778,15 +788,16 @@ Ndb::getAutoIncrementValue(const char* aTableName, } const NdbTableImpl* table = info->m_table_impl; TupleIdRange & range = info->m_tuple_id_range; - if (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1) + if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %lu", (ulong) tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong) autoValue)); DBUG_RETURN(0); } int Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, - Uint64 & tupleId, Uint32 cacheSize) + Uint64 & autoValue, Uint32 cacheSize, + Uint64 step, Uint64 start) { DBUG_ENTER("Ndb::getAutoIncrementValue"); ASSERT_NOT_MYSQLD; @@ -801,51 +812,86 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, DBUG_RETURN(-1); } TupleIdRange & range = info->m_tuple_id_range; - if (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1) + if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong)autoValue)); DBUG_RETURN(0); } int Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, - TupleIdRange & range, Uint64 & tupleId, - Uint32 cacheSize) + TupleIdRange & range, Uint64 & autoValue, + Uint32 cacheSize, Uint64 step, Uint64 start) { DBUG_ENTER("Ndb::getAutoIncrementValue"); assert(aTable != 0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); - if (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1) + if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong)autoValue)); DBUG_RETURN(0); } int Ndb::getTupleIdFromNdb(const NdbTableImpl* table, - TupleIdRange & range, Uint64 & tupleId, Uint32 cacheSize) + TupleIdRange & range, Uint64 & tupleId, + Uint32 cacheSize, Uint64 step, Uint64 start) { +/* + Returns a new TupleId to the application. + The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId. + It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp. + In most cases step= start= 1, in which case we get: + 1,2,3,4,5,... + If step=10 and start=5 and first number is 1, we get: + 5,15,25,35,... +*/ DBUG_ENTER("Ndb::getTupleIdFromNdb"); - if (range.m_first_tuple_id != range.m_last_tuple_id) + /* + Check if the next value can be taken from the pre-fetched + sequence. + */ + if (range.m_first_tuple_id != range.m_last_tuple_id && + range.m_first_tuple_id + step <= range.m_last_tuple_id) { assert(range.m_first_tuple_id < range.m_last_tuple_id); - tupleId = ++range.m_first_tuple_id; - DBUG_PRINT("info", ("next cached value %lu", (ulong)tupleId)); + range.m_first_tuple_id += step; + tupleId = range.m_first_tuple_id; + DBUG_PRINT("info", ("Next cached value %lu", (ulong) tupleId)); } else { + /* + If start value is greater than step it is ignored + */ + Uint64 offset = (start > step) ? 1 : start; + + /* + Pre-fetch a number of values depending on cacheSize + */ if (cacheSize == 0) cacheSize = 1; + DBUG_PRINT("info", ("reading %u values from database", (uint)cacheSize)); /* * reserve next cacheSize entries in db. adds cacheSize to NEXTID - * and returns first tupleId in the new range. + * and returns first tupleId in the new range. If tupleId's are + * incremented in steps then multiply the cacheSize with step size. */ - Uint64 opValue = cacheSize; + Uint64 opValue = cacheSize * step; + if (opTupleIdOnNdb(table, range, opValue, 0) == -1) DBUG_RETURN(-1); - tupleId = opValue; + DBUG_PRINT("info", ("Next value fetched from database %lu", (ulong) opValue)); + DBUG_PRINT("info", ("Increasing %lu by offset %lu, increment is %lu", (ulong) (ulong) opValue, (ulong) offset, (ulong) step)); + Uint64 current, next; + next = ((Uint64) (opValue + step - offset)) / step; + next = next * step + offset; + current = (next < step) ? next : next - step; + tupleId = (opValue <= current) ? current : next; + DBUG_PRINT("info", ("Returning %lu", (ulong) tupleId)); + range.m_first_tuple_id = tupleId; } DBUG_RETURN(0); } From e296f3a453ff1caf3883f0671f54b812f156a86f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 10:56:39 +0200 Subject: [PATCH 003/156] BUG#28439 date_formats test case fails with binlog disabled mysql-test/r/date_formats.result: BUG#28439 remove binlog_format from SHOW VARIABLES statements mysql-test/t/date_formats.test: BUG#28439 don't select binlog_format in SHOW VARIABLES --- mysql-test/r/date_formats.result | 9 +++------ mysql-test/t/date_formats.test | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 7375260d863..62eeb4b2fbf 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -1,14 +1,12 @@ drop table if exists t1; -SHOW GLOBAL VARIABLES LIKE "%_format%"; +SHOW GLOBAL VARIABLES WHERE Variable_name LIKE "%_format%" AND Variable_name != "binlog_format"; Variable_name Value -binlog_format date_format %d.%m.%Y datetime_format %Y-%m-%d %H:%i:%s default_week_format 0 time_format %H.%i.%s -SHOW SESSION VARIABLES LIKE "%_format%"; +SHOW SESSION VARIABLES WHERE Variable_name LIKE "%_format%" AND Variable_name != "binlog_format"; Variable_name Value -binlog_format date_format %d.%m.%Y datetime_format %Y-%m-%d %H:%i:%s default_week_format 0 @@ -30,9 +28,8 @@ set datetime_format= '%H:%i:%s %Y-%m-%d'; set datetime_format= '%H:%i:%s.%f %m-%d-%Y'; set datetime_format= '%h:%i:%s %p %Y-%m-%d'; set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d'; -SHOW SESSION VARIABLES LIKE "%format"; +SHOW SESSION VARIABLES WHERE Variable_name LIKE "%format" AND Variable_name != "binlog_format"; Variable_name Value -binlog_format date_format %m-%d-%Y datetime_format %h:%i:%s.%f %p %Y-%m-%d default_week_format 0 diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index fe39cd95753..a121439c12e 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -6,10 +6,8 @@ drop table if exists t1; --enable_warnings ---replace_result ROW STATEMENT MIXED -SHOW GLOBAL VARIABLES LIKE "%_format%"; ---replace_result ROW STATEMENT MIXED -SHOW SESSION VARIABLES LIKE "%_format%"; +SHOW GLOBAL VARIABLES WHERE Variable_name LIKE "%_format%" AND Variable_name != "binlog_format"; +SHOW SESSION VARIABLES WHERE Variable_name LIKE "%_format%" AND Variable_name != "binlog_format"; # # Test setting a lot of different formats to see which formats are accepted and @@ -36,8 +34,7 @@ set datetime_format= '%H:%i:%s.%f %m-%d-%Y'; set datetime_format= '%h:%i:%s %p %Y-%m-%d'; set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d'; ---replace_result ROW STATEMENT MIXED -SHOW SESSION VARIABLES LIKE "%format"; +SHOW SESSION VARIABLES WHERE Variable_name LIKE "%format" AND Variable_name != "binlog_format"; --error 1231 SET time_format='%h:%i:%s'; From adeaeb5025f9bb7e462973f0a8c0f1f43af9a3e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 11:32:33 +0200 Subject: [PATCH 004/156] BUG#28370 federated test cases fail with binlog disabled mysql-test/include/federated.inc: BUG#28370 all federated tests require --log-bin for now mysql-test/mysql-test-run.pl: BUG#28370 detect --skip-log-bin option in mtr's --mysqld option mysql-test/r/have_log_bin.require: the variable is really called log_bin --- mysql-test/include/federated.inc | 1 + mysql-test/mysql-test-run.pl | 3 +-- mysql-test/r/have_log_bin.require | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/federated.inc b/mysql-test/include/federated.inc index c8e8ededa11..7bdb2efaa8b 100644 --- a/mysql-test/include/federated.inc +++ b/mysql-test/include/federated.inc @@ -1,3 +1,4 @@ +--source include/have_log_bin.inc --source include/not_embedded.inc --source ./include/have_federated_db.inc diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c494626bbae..6bf35410783 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3740,8 +3740,7 @@ sub mysqld_arguments ($$$$) { "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path); # Check if "extra_opt" contains --skip-log-bin - my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt); - + my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt); if ( $mysqld->{'type'} eq 'master' ) { if (! ($opt_skip_master_binlog || $skip_binlog) ) diff --git a/mysql-test/r/have_log_bin.require b/mysql-test/r/have_log_bin.require index cacdf8df0ce..d4fd77e4f8d 100644 --- a/mysql-test/r/have_log_bin.require +++ b/mysql-test/r/have_log_bin.require @@ -1,2 +1,2 @@ Variable_name Value -have_log_bin ON +log_bin ON From c317bc08cd32e6c910efa9efa7ba948b21eb2ee7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 12:22:53 +0200 Subject: [PATCH 005/156] BUG#28372 mysqldump test case fails with binlog disabled mysql-test/t/mysqldump.test: BUG#28372 don't run this test case if binlog is disabled --- mysql-test/t/mysqldump.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 4c4690520c6..78718a9e6ec 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1,6 +1,9 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc +# Binlog is required +--source include/have_log_bin.inc + --disable_warnings DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa, t3; drop database if exists mysqldump_test_db; From b9ec849bb28a149652602de342300022416eca46 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 20:00:23 +0200 Subject: [PATCH 006/156] Bug#23068 - key_cache_block_size is not set or displayes correctly Command line and configuration file option 'key_cache_block_size' was reduced by MALLOC_OVERHEAD (8 in a production server, 36 in a debug server) from the user supplied value and restricted it to the greatest multiple of 512 less or equal to the reduced value. This patch changes option 'key_cache_block_size' to not deduce MALLOC_OVERHEAD from the input value. However, the restriction to a multiple of 512 is still done. sql/mysqld.cc: Bug#23068 - key_cache_block_size is not set or displayes correctly Changed option 'key_cache_block_size' to not deduce MALLOC_OVERHEAD from the input value. --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5abef25b62..c1c7dad1551 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5806,7 +5806,7 @@ log and this option does nothing anymore.", (gptr*) &dflt_key_cache_var.param_block_size, (gptr*) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, - KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, + KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", (gptr*) &dflt_key_cache_var.param_division_limit, From f0d2042bed670dea6d5d7bbd78a29ce0846081f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2007 07:53:16 +0200 Subject: [PATCH 007/156] remove some not used code --- sql/ha_ndbcluster.cc | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0f3a42bbce7..d7326375afb 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -234,11 +234,6 @@ inline int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans, bool force_release) { -#ifdef NOT_USED - int m_batch_execute= 0; - if (m_batch_execute) - return 0; -#endif h->release_completed_operations(trans, force_release); return trans->execute(NdbTransaction::NoCommit, NdbTransaction::AbortOnError, @@ -248,11 +243,6 @@ int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans, inline int execute_commit(ha_ndbcluster *h, NdbTransaction *trans) { -#ifdef NOT_USED - int m_batch_execute= 0; - if (m_batch_execute) - return 0; -#endif return trans->execute(NdbTransaction::Commit, NdbTransaction::AbortOnError, h->m_force_send); @@ -261,11 +251,6 @@ int execute_commit(ha_ndbcluster *h, NdbTransaction *trans) inline int execute_commit(THD *thd, NdbTransaction *trans) { -#ifdef NOT_USED - int m_batch_execute= 0; - if (m_batch_execute) - return 0; -#endif return trans->execute(NdbTransaction::Commit, NdbTransaction::AbortOnError, thd->variables.ndb_force_send); @@ -275,11 +260,6 @@ inline int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans, bool force_release) { -#ifdef NOT_USED - int m_batch_execute= 0; - if (m_batch_execute) - return 0; -#endif h->release_completed_operations(trans, force_release); return trans->execute(NdbTransaction::NoCommit, NdbTransaction::AO_IgnoreError, From 2756cb6203732ecc423c7c803630a871b93d01a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2007 11:27:59 +0200 Subject: [PATCH 008/156] Fix comments and option description in mysqlslap. --- client/mysqlslap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 0335922881a..692334ec72d 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -35,7 +35,8 @@ Supply your own create and query SQL statements, with 50 clients querying (200 selects for each): - mysqlslap --create="CREATE TABLE A (a int);INSERT INTO A (23)" \ + mysqlslap --delimiter=";" \ + --create="CREATE TABLE A (a int);INSERT INTO A VALUES (23)" \ --query="SELECT * FROM A" --concurrency=50 --iterations=200 Let the program build the query SQL statement with a table of two int @@ -554,7 +555,7 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"iterations", 'i', "Number of times too run the tests.", (gptr*) &iterations, + {"iterations", 'i', "Number of times to run the tests.", (gptr*) &iterations, (gptr*) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, {"number-char-cols", 'x', "Number of VARCHAR columns to create table with if specifying --auto-generate-sql ", From eaa1a23a3ed38f00a362a63fe36fccc726a4b741 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2007 16:40:05 +0200 Subject: [PATCH 009/156] Bug #28653 Fast GCP + high load + high RedoBuffer causes ndbrequire - parameterize on RedoBuffer --- storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 5 +++-- storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 4 ++-- storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 3fc8891c082..0f88933f617 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -2678,7 +2678,8 @@ private: UintR cfirstfreeLogFile; UintR clogFileFileSize; -#define ZLFO_FILE_SIZE 256 /* MAX 256 OUTSTANDING FILE OPERATIONS */ +#define ZLFO_MIN_FILE_SIZE 256 +// RedoBuffer/32K minimum ZLFO_MIN_FILE_SIZE LogFileOperationRecord *logFileOperationRecord; LogFileOperationRecordPtr lfoPtr; UintR cfirstfreeLfo; @@ -2695,7 +2696,7 @@ private: UintR cfirstfreePageRef; UintR cpageRefFileSize; -#define ZSCANREC_FILE_SIZE 100 +// Configurable ArrayPool c_scanRecordPool; ScanRecordPtr scanptr; UintR cscanNoFreeRec; diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 8ddb96f9111..8aaf86de73a 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -30,11 +30,11 @@ void Dblqh::initData() cgcprecFileSize = ZGCPREC_FILE_SIZE; chostFileSize = MAX_NDB_NODES; clcpFileSize = ZNO_CONCURRENT_LCP; - clfoFileSize = ZLFO_FILE_SIZE; + clfoFileSize = 0; clogFileFileSize = 0; clogPartFileSize = ZLOG_PART_FILE_SIZE; cpageRefFileSize = ZPAGE_REF_FILE_SIZE; - cscanrecFileSize = ZSCANREC_FILE_SIZE; + cscanrecFileSize = 0; ctabrecFileSize = 0; ctcConnectrecFileSize = 0; ctcNodeFailrecFileSize = MAX_NDB_NODES; diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 6c99e8d0e13..35a53aae1c0 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -992,6 +992,11 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) ndb_mgm_get_int_parameter(p, CFG_DB_REDO_BUFFER, &log_page_size); + /* maximum number of log file operations */ + clfoFileSize = (log_page_size+32768-1)/32768; + if (clfoFileSize < ZLFO_MIN_FILE_SIZE) + clfoFileSize = ZLFO_MIN_FILE_SIZE; + /** * Always set page size in half MBytes */ From bf699d7187a146e7d2b3d7b87d45dcb2cd654827 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2007 16:50:38 +0200 Subject: [PATCH 010/156] Bug #28653 Fast GCP + high load + high RedoBuffer causes ndbrequire - correction, use recomputed _actual_ redobuffer --- storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 35a53aae1c0..95d71c80e5c 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -992,11 +992,6 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) ndb_mgm_get_int_parameter(p, CFG_DB_REDO_BUFFER, &log_page_size); - /* maximum number of log file operations */ - clfoFileSize = (log_page_size+32768-1)/32768; - if (clfoFileSize < ZLFO_MIN_FILE_SIZE) - clfoFileSize = ZLFO_MIN_FILE_SIZE; - /** * Always set page size in half MBytes */ @@ -1007,6 +1002,11 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) clogPageFileSize+= (16 - mega_byte_part); } + /* maximum number of log file operations */ + clfoFileSize = clogPageFileSize; + if (clfoFileSize < ZLFO_MIN_FILE_SIZE) + clfoFileSize = ZLFO_MIN_FILE_SIZE; + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TABLE, &ctabrecFileSize)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TC_CONNECT, &ctcConnectrecFileSize)); From 15259e7e8aef731caf725ca0fc45223a040e9732 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2007 10:39:24 -0700 Subject: [PATCH 011/156] Bug#27836 "sql_plugin.cc, dynamic_array is not dynamic" When the DYNAMIC_ARRAYs were resized, pointers became invalid. Solved by only storing pointers within the DYNAMIC_ARRAYs. sql/sql_plugin.cc: Bug27836 Store pointers to data structures in dynamic arrays: plugin_dl_array, plugin_array Allocate data structures in plugin_mem_root --- sql/sql_plugin.cc | 56 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 5f8513a4a9e..5008019fb30 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -278,7 +278,7 @@ static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl) DBUG_ENTER("plugin_dl_find"); for (i= 0; i < plugin_dl_array.elements; i++) { - tmp= dynamic_element(&plugin_dl_array, i, struct st_plugin_dl *); + tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **); if (tmp->ref_count && ! my_strnncoll(files_charset_info, (const uchar *)dl->str, dl->length, @@ -296,17 +296,20 @@ static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl) DBUG_ENTER("plugin_dl_insert_or_reuse"); for (i= 0; i < plugin_dl_array.elements; i++) { - tmp= dynamic_element(&plugin_dl_array, i, struct st_plugin_dl *); + tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **); if (! tmp->ref_count) { memcpy(tmp, plugin_dl, sizeof(struct st_plugin_dl)); DBUG_RETURN(tmp); } } - if (insert_dynamic(&plugin_dl_array, (gptr)plugin_dl)) + if (insert_dynamic(&plugin_dl_array, (gptr)&plugin_dl)) DBUG_RETURN(0); - DBUG_RETURN(dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1, - struct st_plugin_dl *)); + tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1, + struct st_plugin_dl **)= + (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (gptr)plugin_dl, + sizeof(struct st_plugin_dl)); + DBUG_RETURN(tmp); } #endif /* HAVE_DLOPEN */ @@ -516,8 +519,8 @@ static void plugin_dl_del(const LEX_STRING *dl) for (i= 0; i < plugin_dl_array.elements; i++) { - struct st_plugin_dl *tmp= dynamic_element(&plugin_dl_array, i, - struct st_plugin_dl *); + struct st_plugin_dl *tmp= *dynamic_element(&plugin_dl_array, i, + struct st_plugin_dl **); if (tmp->ref_count && ! my_strnncoll(files_charset_info, (const uchar *)dl->str, dl->length, @@ -665,21 +668,24 @@ plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) { uint i; + struct st_plugin_int *tmp; DBUG_ENTER("plugin_insert_or_reuse"); for (i= 0; i < plugin_array.elements; i++) { - struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, - struct st_plugin_int *); + tmp= *dynamic_element(&plugin_array, i, struct st_plugin_int **); if (tmp->state == PLUGIN_IS_FREED) { memcpy(tmp, plugin, sizeof(struct st_plugin_int)); DBUG_RETURN(tmp); } } - if (insert_dynamic(&plugin_array, (gptr)plugin)) + if (insert_dynamic(&plugin_array, (gptr)&plugin)) DBUG_RETURN(0); - DBUG_RETURN(dynamic_element(&plugin_array, plugin_array.elements - 1, - struct st_plugin_int *)); + tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1, + struct st_plugin_int **)= + (struct st_plugin_int *) memdup_root(&plugin_mem_root, (gptr)plugin, + sizeof(struct st_plugin_int)); + DBUG_RETURN(tmp); } @@ -874,7 +880,7 @@ static void reap_plugins(void) for (idx= 0; idx < count; idx++) { - plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); + plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **); if (plugin->state == PLUGIN_IS_DELETED && !plugin->ref_count) { /* change the status flag to prevent reaping by another thread */ @@ -1097,9 +1103,9 @@ int plugin_init(int *argc, char **argv, int flags) pthread_mutex_init(&LOCK_plugin, MY_MUTEX_INIT_FAST); if (my_init_dynamic_array(&plugin_dl_array, - sizeof(struct st_plugin_dl),16,16) || + sizeof(struct st_plugin_dl *),16,16) || my_init_dynamic_array(&plugin_array, - sizeof(struct st_plugin_int),16,16)) + sizeof(struct st_plugin_int *),16,16)) goto err; for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) @@ -1185,7 +1191,7 @@ int plugin_init(int *argc, char **argv, int flags) for (i= 0; i < plugin_array.elements; i++) { - plugin_ptr= dynamic_element(&plugin_array, i, struct st_plugin_int *); + plugin_ptr= *dynamic_element(&plugin_array, i, struct st_plugin_int **); if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED) { if (plugin_initialize(plugin_ptr)) @@ -1232,11 +1238,13 @@ static bool register_builtin(struct st_mysql_plugin *plugin, tmp->ref_count= 0; tmp->plugin_dl= 0; - if (insert_dynamic(&plugin_array, (gptr)tmp)) + if (insert_dynamic(&plugin_array, (gptr)&tmp)) DBUG_RETURN(1); - *ptr= dynamic_element(&plugin_array, plugin_array.elements - 1, - struct st_plugin_int *); + *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1, + struct st_plugin_int **)= + (struct st_plugin_int *) memdup_root(&plugin_mem_root, (gptr)tmp, + sizeof(struct st_plugin_int)); if (my_hash_insert(&plugin_hash[plugin->type],(byte*) *ptr)) DBUG_RETURN(1); @@ -1458,7 +1466,7 @@ void plugin_shutdown(void) reap_plugins(); for (i= free_slots= 0; i < count; i++) { - plugin= dynamic_element(&plugin_array, i, struct st_plugin_int *); + plugin= *dynamic_element(&plugin_array, i, struct st_plugin_int **); switch (plugin->state) { case PLUGIN_IS_READY: plugin->state= PLUGIN_IS_DELETED; @@ -1490,7 +1498,7 @@ void plugin_shutdown(void) */ for (i= 0; i < count; i++) { - plugins[i]= dynamic_element(&plugin_array, i, struct st_plugin_int *); + plugins[i]= *dynamic_element(&plugin_array, i, struct st_plugin_int **); /* change the state to ensure no reaping races */ if (plugins[i]->state == PLUGIN_IS_DELETED) plugins[i]->state= PLUGIN_IS_DYING; @@ -1555,7 +1563,7 @@ void plugin_shutdown(void) count= plugin_dl_array.elements; dl= (struct st_plugin_dl **)my_alloca(sizeof(void*) * count); for (i= 0; i < count; i++) - dl[i]= dynamic_element(&plugin_dl_array, i, struct st_plugin_dl *); + dl[i]= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **); for (i= 0; i < plugin_dl_array.elements; i++) free_plugin_mem(dl[i]); my_afree(dl); @@ -1714,7 +1722,7 @@ bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, { for (idx= 0; idx < total; idx++) { - plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); + plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **); plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL; } } @@ -3139,7 +3147,7 @@ void my_print_help_inc_plugins(my_option *main_options, uint size) if (initialized) for (uint idx= 0; idx < plugin_array.elements; idx++) { - p= dynamic_element(&plugin_array, idx, struct st_plugin_int *); + p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **); if (!p->plugin->system_vars || !(opt= construct_help_options(&mem_root, p))) From 9202b48b5e4f37fdfafe69073c2aebc0e3d8f895 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2007 21:02:01 +0200 Subject: [PATCH 012/156] Bug #28653 Fast GCP + high load + high RedoBuffer causes ndbrequire - correction, use recomputed _actual_ redobuffer --- ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 5 +++-- ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 4 ++-- ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 4474d226a27..2ed08db527c 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -2668,7 +2668,8 @@ private: UintR cfirstfreeLogFile; UintR clogFileFileSize; -#define ZLFO_FILE_SIZE 256 /* MAX 256 OUTSTANDING FILE OPERATIONS */ +#define ZLFO_MIN_FILE_SIZE 256 +// RedoBuffer/32K minimum ZLFO_MIN_FILE_SIZE LogFileOperationRecord *logFileOperationRecord; LogFileOperationRecordPtr lfoPtr; UintR cfirstfreeLfo; @@ -2685,7 +2686,7 @@ private: UintR cfirstfreePageRef; UintR cpageRefFileSize; -#define ZSCANREC_FILE_SIZE 100 +// Configurable ArrayPool c_scanRecordPool; ScanRecordPtr scanptr; UintR cscanNoFreeRec; diff --git a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 3452269be51..65f4b0f9b4b 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -32,11 +32,11 @@ void Dblqh::initData() chostFileSize = MAX_NDB_NODES; clcpFileSize = ZNO_CONCURRENT_LCP; clcpLocrecFileSize = ZLCP_LOCREC_FILE_SIZE; - clfoFileSize = ZLFO_FILE_SIZE; + clfoFileSize = 0; clogFileFileSize = 0; clogPartFileSize = ZLOG_PART_FILE_SIZE; cpageRefFileSize = ZPAGE_REF_FILE_SIZE; - cscanrecFileSize = ZSCANREC_FILE_SIZE; + cscanrecFileSize = 0; ctabrecFileSize = 0; ctcConnectrecFileSize = 0; ctcNodeFailrecFileSize = MAX_NDB_NODES; diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 684598364ab..88bc3f372a5 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -7251,6 +7251,11 @@ void Dblqh::continueScanNextReqLab(Signal* signal) return; } + /* maximum number of log file operations */ + clfoFileSize = clogPageFileSize; + if (clfoFileSize < ZLFO_MIN_FILE_SIZE) + clfoFileSize = ZLFO_MIN_FILE_SIZE; + // Update timer on tcConnectRecord tcConnectptr.p->tcTimer = cLqhTimeOutCount; init_acc_ptr_list(scanptr.p); From babe38a4257bf80d30c324da20648ae6a8f0fc7a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 12:25:15 +0200 Subject: [PATCH 013/156] Bug #28525 Node failures in PGMAN at ndbrequire (line 430) storage/ndb/src/kernel/blocks/pgman.cpp: Under heavy insert PGMAN can run out of page entries even when set to 100 times page cache entries. In this use pattern the extra entries remain idle on LIRS stack. Only ONSTACK is set. There is not enough activity to free them the normal way. A study of PGMAN / DBTUP behaviour is needed. This patch adds new sublist SL_IDLE. When page entry pool is empty, an idle entry is released from SL_IDLE front if there is any. Otherwise, we still crash. The factor above is set from 100 to 10 (still high). storage/ndb/src/kernel/blocks/pgman.hpp: Under heavy insert PGMAN can run out of page entries even when set to 100 times page cache entries. In this use pattern the extra entries remain idle on LIRS stack. Only ONSTACK is set. There is not enough activity to free them the normal way. A study of PGMAN / DBTUP behaviour is needed. This patch adds new sublist SL_IDLE. When page entry pool is empty, an idle entry is released from SL_IDLE front if there is any. Otherwise, we still crash. The factor above is set from 100 to 10 (still high). --- storage/ndb/src/kernel/blocks/pgman.cpp | 69 +++++++++++++++++++++++-- storage/ndb/src/kernel/blocks/pgman.hpp | 6 ++- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp index 719b60fa466..09335396a07 100644 --- a/storage/ndb/src/kernel/blocks/pgman.cpp +++ b/storage/ndb/src/kernel/blocks/pgman.cpp @@ -123,8 +123,8 @@ Pgman::execREAD_CONFIG_REQ(Signal* signal) if (page_buffer > 0) { page_buffer /= GLOBAL_PAGE_SIZE; // in pages - m_page_entry_pool.setSize(100*page_buffer); m_param.m_max_pages = page_buffer; + m_page_entry_pool.setSize(m_param.m_lirs_stack_mult * page_buffer); m_param.m_max_hot_pages = (page_buffer * 9) / 10; } @@ -141,6 +141,7 @@ Pgman::execREAD_CONFIG_REQ(Signal* signal) Pgman::Param::Param() : m_max_pages(64), // smallish for testing + m_lirs_stack_mult(10), m_max_hot_pages(56), m_max_loop_count(256), m_max_io_waits(64), @@ -301,6 +302,9 @@ Pgman::get_sublist_no(Page_state state) { return Page_entry::SL_LOCKED; } + if (state == Page_entry::ONSTACK) { + return Page_entry::SL_IDLE; + } return Page_entry::SL_OTHER; } @@ -415,15 +419,55 @@ Pgman::get_page_entry(Ptr& ptr, Uint32 file_no, Uint32 page_no) { if (find_page_entry(ptr, file_no, page_no)) { + jam(); ndbrequire(ptr.p->m_state != 0); m_stats.m_page_hits++; + +#ifdef VM_TRACE + debugOut << "PGMAN: get_page_entry: found" << endl; + debugOut << "PGMAN: " << ptr << endl; +#endif return true; } + if (m_page_entry_pool.getNoOfFree() == 0) + { + jam(); + Page_sublist& pl_idle = *m_page_sublist[Page_entry::SL_IDLE]; + Ptr idle_ptr; + if (pl_idle.first(idle_ptr)) + { + jam(); + +#ifdef VM_TRACE + debugOut << "PGMAN: get_page_entry: re-use idle entry" << endl; + debugOut << "PGMAN: " << idle_ptr << endl; +#endif + + Page_state state = idle_ptr.p->m_state; + ndbrequire(state == Page_entry::ONSTACK); + + Page_stack& pl_stack = m_page_stack; + ndbrequire(pl_stack.hasPrev(idle_ptr)); + pl_stack.remove(idle_ptr); + state &= ~ Page_entry::ONSTACK; + set_page_state(idle_ptr, state); + ndbrequire(idle_ptr.p->m_state == 0); + + release_page_entry(idle_ptr); + } + } + if (seize_page_entry(ptr, file_no, page_no)) { + jam(); ndbrequire(ptr.p->m_state == 0); m_stats.m_page_faults++; + +#ifdef VM_TRACE + debugOut << "PGMAN: get_page_entry: seize" << endl; + debugOut << "PGMAN: " << ptr << endl; +#endif return true; } @@ -1929,6 +1973,8 @@ Pgman::verify_page_entry(Ptr ptr) break; case Page_entry::SL_LOCKED: break; + case Page_entry::SL_IDLE: + break; case Page_entry::SL_OTHER: break; default: @@ -1975,8 +2021,11 @@ Pgman::verify_page_lists() ndbrequire(stack_count == pl_stack.count() || dump_page_lists()); ndbrequire(queue_count == pl_queue.count() || dump_page_lists()); + Uint32 hot_count = 0; Uint32 hot_bound_count = 0; Uint32 cold_bound_count = 0; + Uint32 stack_request_count = 0; + Uint32 queue_request_count = 0; Uint32 i1 = RNIL; for (pl_stack.first(ptr); ptr.i != RNIL; pl_stack.next(ptr)) @@ -1987,9 +2036,13 @@ Pgman::verify_page_lists() ndbrequire(state & Page_entry::ONSTACK || dump_page_lists()); if (! pl_stack.hasPrev(ptr)) ndbrequire(state & Page_entry::HOT || dump_page_lists()); - if (state & Page_entry::HOT && - state & Page_entry::BOUND) - hot_bound_count++; + if (state & Page_entry::HOT) { + hot_count++; + if (state & Page_entry::BOUND) + hot_bound_count++; + } + if (state & Page_entry::REQUEST) + stack_request_count++; } Uint32 i2 = RNIL; @@ -2001,6 +2054,8 @@ Pgman::verify_page_lists() ndbrequire(state & Page_entry::ONQUEUE || dump_page_lists()); ndbrequire(state & Page_entry::BOUND || dump_page_lists()); cold_bound_count++; + if (state & Page_entry::REQUEST) + queue_request_count++; } Uint32 tot_bound_count = @@ -2033,7 +2088,11 @@ Pgman::verify_page_lists() << " cache:" << m_stats.m_num_pages << "(" << locked_bound_count << "L)" << " stack:" << pl_stack.count() + << " hot:" << hot_count + << " hot_bound:" << hot_bound_count + << " stack_request:" << stack_request_count << " queue:" << pl_queue.count() + << " queue_request:" << queue_request_count << " queuewait:" << queuewait_count << endl; debugOut << "PGMAN:"; @@ -2141,6 +2200,8 @@ Pgman::get_sublist_name(Uint32 list_no) return "busy"; case Page_entry::SL_LOCKED: return "locked"; + case Page_entry::SL_IDLE: + return "idle"; case Page_entry::SL_OTHER: return "other"; } diff --git a/storage/ndb/src/kernel/blocks/pgman.hpp b/storage/ndb/src/kernel/blocks/pgman.hpp index 07029d1c3e5..e3bf0fa5780 100644 --- a/storage/ndb/src/kernel/blocks/pgman.hpp +++ b/storage/ndb/src/kernel/blocks/pgman.hpp @@ -325,8 +325,9 @@ private: ,SL_CALLBACK_IO = 4 ,SL_BUSY = 5 ,SL_LOCKED = 6 - ,SL_OTHER = 7 - ,SUBLIST_COUNT = 8 + ,SL_IDLE = 7 + ,SL_OTHER = 8 + ,SUBLIST_COUNT = 9 }; Uint16 m_file_no; // disk page address set at seize @@ -401,6 +402,7 @@ private: struct Param { Param(); Uint32 m_max_pages; // max number of cache pages + Uint32 m_lirs_stack_mult; // in m_max_pages (around 3-10) Uint32 m_max_hot_pages; // max hot cache pages (up to 99%) Uint32 m_max_loop_count; // limit purely local loops Uint32 m_max_io_waits; From 454fca74e4cb51f8f2589341de759431b0c05fa7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 17:21:12 +0500 Subject: [PATCH 014/156] decimal buffer overflow bug fixed mysql-test/r/ps_2myisam.result: test result fixed mysql-test/r/ps_3innodb.result: test result fixed mysql-test/r/ps_4heap.result: test result fixed mysql-test/r/ps_5merge.result: test result fixed mysql-test/r/ps_7ndb.result: test result fixed sql/my_decimal.h: DECIMAL_MAX_STR_LENGTH fixed --- mysql-test/r/ps_2myisam.result | 32 ++++++++--------- mysql-test/r/ps_3innodb.result | 32 ++++++++--------- mysql-test/r/ps_4heap.result | 32 ++++++++--------- mysql-test/r/ps_5merge.result | 64 +++++++++++++++++----------------- mysql-test/r/ps_7ndb.result | 32 ++++++++--------- sql/my_decimal.h | 11 ++++-- 6 files changed, 104 insertions(+), 99 deletions(-) diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 2ce35dae092..544528e3c60 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1927,8 +1927,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1974,8 +1974,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2024,8 +2024,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2064,8 +2064,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2112,8 +2112,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2156,8 +2156,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2202,8 +2202,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2240,8 +2240,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 70181ecccdc..472a0c6000e 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1910,8 +1910,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1957,8 +1957,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2007,8 +2007,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2047,8 +2047,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2095,8 +2095,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2139,8 +2139,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2185,8 +2185,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2223,8 +2223,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 19be5a2707e..e5e64eb8f86 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1911,8 +1911,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1958,8 +1958,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2008,8 +2008,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2048,8 +2048,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2096,8 +2096,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2140,8 +2140,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2186,8 +2186,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2224,8 +2224,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index ebdc5c8c9fd..daf6986552b 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1847,8 +1847,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1894,8 +1894,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1944,8 +1944,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1984,8 +1984,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2032,8 +2032,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2076,8 +2076,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2122,8 +2122,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2160,8 +2160,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -4868,8 +4868,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -4915,8 +4915,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -4965,8 +4965,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -5005,8 +5005,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -5053,8 +5053,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -5097,8 +5097,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -5143,8 +5143,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -5181,8 +5181,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 2cffb698fc0..b39dcf82142 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1910,8 +1910,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -1957,8 +1957,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2007,8 +2007,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2047,8 +2047,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2095,8 +2095,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2139,8 +2139,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2185,8 +2185,8 @@ def @arg07 253 23 1 Y 128 31 63 def @arg08 253 23 1 Y 128 31 63 def @arg09 253 23 1 Y 128 31 63 def @arg10 253 23 1 Y 128 31 63 -def @arg11 253 67 6 Y 128 30 63 -def @arg12 253 67 6 Y 128 30 63 +def @arg11 253 83 6 Y 128 30 63 +def @arg12 253 83 6 Y 128 30 63 def @arg13 253 16777216 10 Y 128 31 63 def @arg14 253 16777216 19 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 @@ -2223,8 +2223,8 @@ def @arg07 253 23 0 Y 128 31 63 def @arg08 253 23 0 Y 128 31 63 def @arg09 253 23 0 Y 128 31 63 def @arg10 253 23 0 Y 128 31 63 -def @arg11 253 67 0 Y 128 30 63 -def @arg12 253 67 0 Y 128 30 63 +def @arg11 253 83 0 Y 128 30 63 +def @arg12 253 83 0 Y 128 30 63 def @arg13 253 16777216 0 Y 128 31 63 def @arg14 253 16777216 0 Y 128 31 63 def @arg15 253 16777216 19 Y 128 31 63 diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 17eb75cfdc5..5632f191b57 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -36,13 +36,18 @@ C_MODE_END /* maximum length of buffer in our big digits (uint32) */ #define DECIMAL_BUFF_LENGTH 9 + +/* the number of digits that my_decimal can possibly contain */ +#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9) + + /* maximum guaranteed precision of number in decimal digits (number of our digits * number of decimal digits in one our big digit - number of decimal - digits in one our big digit decreased on 1 (because we always put decimal + digits in one our big digit decreased by 1 (because we always put decimal point on the border of our big digits)) */ -#define DECIMAL_MAX_PRECISION ((DECIMAL_BUFF_LENGTH * 9) - 8*2) +#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2) #define DECIMAL_MAX_SCALE 30 #define DECIMAL_NOT_SPECIFIED 31 @@ -50,7 +55,7 @@ C_MODE_END maximum length of string representation (number of maximum decimal digits + 1 position for sign + 1 position for decimal point) */ -#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_PRECISION + 2) +#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2) /* maximum size of packet length */ From dc8912df551841b813469abcf8f2a3558ac8be5c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 23:08:31 +0200 Subject: [PATCH 015/156] Makefile.am : Bypass bug#28685 and skip the "rowlock" suite in the release builds. Makefile.am: Bypass bug#28685 and skip the "rowlock" suite in the release builds. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b92ee7ae0bc..14f2886c472 100644 --- a/Makefile.am +++ b/Makefile.am @@ -136,8 +136,10 @@ test-bt: @PERL@ ./mysql-test-run.pl --force --comment=rpl --suite=rpl -cd mysql-test ; MTR_BUILD_THREAD=auto \ @PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=parts - -cd mysql-test ; MTR_BUILD_THREAD=auto \ - @PERL@ ./mysql-test-run.pl --force --comment=rowlock --suite=row_lock + +# Re-enable the "rowlock" suite when bug#28685 is fixed +# -cd mysql-test ; MTR_BUILD_THREAD=auto \ +# @PERL@ ./mysql-test-run.pl --force --comment=rowlock --suite=row_lock # Re-enable the "jp" suite when bug#28563 is fixed # -cd mysql-test ; MTR_BUILD_THREAD=auto \ From a40ec74750f512d4fcd1c38b19cdf76ad208f513 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 16:40:24 -0700 Subject: [PATCH 016/156] Missing functionality in WL#2936: String variables not readable by using @@name. Required for WL1722. sql/set_var.cc: Missing functionality in WL2936: String variables not readable by using @@name. --- sql/set_var.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sql/set_var.cc b/sql/set_var.cc index 3dc8cddcb26..bd9b31468f7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1489,6 +1489,25 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) pthread_mutex_unlock(&LOCK_global_system_variables); return new Item_int(value,1); } + case SHOW_CHAR_PTR: + { + Item *tmp; + pthread_mutex_lock(&LOCK_global_system_variables); + char *str= *(char**) value_ptr(thd, var_type, base); + if (str) + { + uint length= strlen(str); + tmp= new Item_string(thd->strmake(str, length), length, + system_charset_info, DERIVATION_SYSCONST); + } + else + { + tmp= new Item_null(); + tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); + } + pthread_mutex_unlock(&LOCK_global_system_variables); + return tmp; + } case SHOW_CHAR: { Item *tmp; From 0d3df46fe768c39f59a809c32bd5d9814f0a9594 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 May 2007 23:21:03 +0200 Subject: [PATCH 017/156] sql_parse.cc, config-win.h, config-netware.h: Don't try determine stack direction at configure time compiler_flag.m4: Use AC_TRY_COMPILE and AC_TRY_LINK instead of AC_TRY_RUN where possible misc.m4, configure.in: Use fourth argument to AC_TRY_RUN, to be used in cross compilation Don't try determine stack direction at configure time configure.in: Use fourth argument to AC_TRY_RUN, to be used in cross compilation Don't try determine stack direction at configure time config/ac-macros/compiler_flag.m4: Use AC_TRY_COMPILE and AC_TRY_LINK instead of AC_TRY_RUN where possible config/ac-macros/misc.m4: Use fourth argument to AC_TRY_RUN, to be used in cross compilation Don't try determine stack direction at configure time include/config-netware.h: Don't try determine stack direction at configure time include/config-win.h: Don't try determine stack direction at configure time sql/sql_parse.cc: Don't try determine stack direction at configure time --- config/ac-macros/compiler_flag.m4 | 2 +- config/ac-macros/misc.m4 | 27 +++------------------------ configure.in | 7 ++++--- include/config-netware.h | 3 --- include/config-win.h | 2 -- sql/sql_parse.cc | 9 +++------ 6 files changed, 11 insertions(+), 39 deletions(-) diff --git a/config/ac-macros/compiler_flag.m4 b/config/ac-macros/compiler_flag.m4 index 88097c7a62e..ce2ce6cbdfa 100644 --- a/config/ac-macros/compiler_flag.m4 +++ b/config/ac-macros/compiler_flag.m4 @@ -7,7 +7,7 @@ AC_DEFUN([AC_SYS_COMPILER_FLAG], AC_CACHE_VAL(mysql_cv_option_$2, [ CFLAGS="[$]OLD_CFLAGS $1" - AC_TRY_RUN([int main(){exit(0);}],mysql_cv_option_$2=yes,mysql_cv_option_$2=no,mysql_cv_option_$2=no) + AC_TRY_LINK([int main(){exit(0);}],mysql_cv_option_$2=yes,mysql_cv_option_$2=no,mysql_cv_option_$2=no) ]) CFLAGS="[$]OLD_CFLAGS" diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4 index a20db96a950..0619a52fbbf 100644 --- a/config/ac-macros/misc.m4 +++ b/config/ac-macros/misc.m4 @@ -450,29 +450,6 @@ AC_DEFINE([HAVE_BOOL], [1], [bool is not defined by all C++ compilators]) fi ])dnl -AC_DEFUN([MYSQL_STACK_DIRECTION], - [AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, - [AC_TRY_RUN([#include - int find_stack_direction () - { - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; - } - int main () - { - exit (find_stack_direction() < 0); - }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1, - ac_cv_c_stack_direction=0)]) - AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) -])dnl - AC_DEFUN([MYSQL_CHECK_LONGLONG_TO_FLOAT], [ AC_MSG_CHECKING(if conversion of longlong to float works) @@ -488,7 +465,9 @@ int main() fprintf(file,"%g\n",f); fclose(file); return (0); -}], ac_cv_conv_longlong_to_float=`cat conftestval`, ac_cv_conv_longlong_to_float=0, ifelse([$2], , , ac_cv_conv_longlong_to_float=$2))])dnl +}], ac_cv_conv_longlong_to_float=`cat conftestval`, + ac_cv_conv_longlong_to_float=0, + ac_cv_conv_longlong_to_float="yes")])dnl # Cross compiling, assume can convert if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes" then ac_cv_conv_longlong_to_float=yes diff --git a/configure.in b/configure.in index e3c6edb9b0f..7c18aeb4fc6 100644 --- a/configure.in +++ b/configure.in @@ -264,7 +264,10 @@ AC_TRY_RUN([ AC_MSG_RESULT("ptr")], [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf]) AC_MSG_RESULT("garbage")]) - ]) + ], + # Cross compile, assume POSIX + [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) + AC_MSG_RESULT("int (we assume)")]) ;; esac @@ -1784,8 +1787,6 @@ MYSQL_TYPE_ACCEPT #---END: # Figure out what type of struct rlimit to use with setrlimit MYSQL_TYPE_STRUCT_RLIMIT -# Find where the stack goes -MYSQL_STACK_DIRECTION # We want to skip alloca on irix unconditionally. It may work on some version.. MYSQL_FUNC_ALLOCA # Do struct timespec have members tv_sec or ts_sec diff --git a/include/config-netware.h b/include/config-netware.h index f287699249b..f7f494b519c 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -112,9 +112,6 @@ extern "C" { /* signal by closing the sockets */ #define SIGNAL_WITH_VIO_CLOSE 1 -/* On NetWare, stack grows towards lower address*/ -#define STACK_DIRECTION -1 - /* On NetWare, we need to set stack size for threads, otherwise default 16K is used */ #define NW_THD_STACKSIZE 65536 diff --git a/include/config-win.h b/include/config-win.h index 8d6f8885626..d34e3bf791e 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -250,8 +250,6 @@ inline double ulonglong2double(ulonglong value) #endif -#define STACK_DIRECTION -1 - /* Optimized store functions for Intel x86 */ #ifndef _WIN64 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 06419010a24..039bdbbdfdd 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4996,17 +4996,14 @@ bool check_merge_table_access(THD *thd, char *db, Check stack size; Send error if there isn't enough stack to continue ****************************************************************************/ -#if STACK_DIRECTION < 0 -#define used_stack(A,B) (long) (A - B) -#else -#define used_stack(A,B) (long) (B - A) -#endif +#ifndef EMBEDDED_LIBRARY + +#define used_stack(A,B) (long)(A > B ? A - B : B - A) #ifndef DBUG_OFF long max_stack_used; #endif -#ifndef EMBEDDED_LIBRARY /* Note: The 'buf' parameter is necessary, even if it is unused here. - fix_fields functions has a "dummy" buffer large enough for the From 787e0a39479ddd0b43a351e990d8ae23ebfb8307 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 13:27:26 +0500 Subject: [PATCH 018/156] BUG#18839 - return value of parser->parse() is ignored Check value returned by parser->parse(). Better handle situations when it fails. storage/myisam/ft_boolean_search.c: Check value returned by parser->parse(). storage/myisam/ft_nlq_search.c: Check value returned by parser->parse(). --- storage/myisam/ft_boolean_search.c | 51 ++++++++++++++++++------------ storage/myisam/ft_nlq_search.c | 8 +++-- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 68076d7e401..f5866011f04 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -286,8 +286,8 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, } -static void _ftb_parse_query(FTB *ftb, byte *query, uint len, - struct st_mysql_ftparser *parser) +static int _ftb_parse_query(FTB *ftb, byte *query, uint len, + struct st_mysql_ftparser *parser) { MYSQL_FTPARSER_PARAM *param; MY_FTB_PARAM ftb_param; @@ -295,9 +295,9 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len, DBUG_ASSERT(parser); if (ftb->state != UNINITIALIZED) - DBUG_VOID_RETURN; + DBUG_RETURN(0); if (! (param= ftparser_call_initializer(ftb->info, ftb->keynr, 0))) - DBUG_VOID_RETURN; + DBUG_RETURN(1); ftb_param.ftb= ftb; ftb_param.depth= 0; @@ -312,8 +312,7 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len, param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO; - parser->parse(param); - DBUG_VOID_RETURN; + DBUG_RETURN(parser->parse(param)); } @@ -538,9 +537,10 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, ftbe->phrase= NULL; ftbe->document= 0; ftb->root=ftbe; - _ftb_parse_query(ftb, query, query_len, keynr == NO_SUCH_KEY ? - &ft_default_parser : - info->s->keyinfo[keynr].parser); + if (unlikely(_ftb_parse_query(ftb, query, query_len, + keynr == NO_SUCH_KEY ? &ft_default_parser : + info->s->keyinfo[keynr].parser))) + goto err; /* Hack: instead of init_queue, we'll use reinit queue to be able to alloc queue with alloc_root() @@ -621,7 +621,7 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, { param->mysql_add_word(param, word.pos, word.len, 0); if (phrase_param->match) - return 1; + break; } return 0; } @@ -639,6 +639,7 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, RETURN VALUE 1 is returned if phrase found, 0 else. + -1 is returned if error occurs. */ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, @@ -667,12 +668,13 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_WITH_STOPWORDS; - parser->parse(param); + if (unlikely(parser->parse(param))) + return -1; DBUG_RETURN(ftb_param.match ? 1 : 0); } -static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_orig) +static int _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_orig) { FT_SEG_ITERATOR ftsi; FTB_EXPR *ftbe; @@ -704,17 +706,19 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ weight=ftbe->cur_weight*ftbe->weight; if (mode && ftbe->phrase) { - int not_found=1; + int found= 0; memcpy(&ftsi, ftsi_orig, sizeof(ftsi)); - while (_mi_ft_segiterator(&ftsi) && not_found) + while (_mi_ft_segiterator(&ftsi) && !found) { if (!ftsi.pos) continue; - not_found = ! _ftb_check_phrase(ftb, ftsi.pos, ftsi.len, - ftbe, parser); + found= _ftb_check_phrase(ftb, ftsi.pos, ftsi.len, ftbe, parser); + if (unlikely(found < 0)) + return 1; } - if (not_found) break; + if (!found) + break; } /* ftbe->quot */ } else @@ -746,6 +750,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_ weight*= ftbe->weight; } } + return 0; } @@ -778,7 +783,11 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record) { while (curdoc == (ftbw=(FTB_WORD *)queue_top(& ftb->queue))->docid[0]) { - _ftb_climb_the_tree(ftb, ftbw, 0); + if (unlikely(_ftb_climb_the_tree(ftb, ftbw, 0))) + { + my_errno= HA_ERR_OUT_OF_MEM; + goto err; + } /* update queue */ _ft2_search(ftb, ftbw, 0); @@ -854,7 +863,8 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, if (ftbw->docid[1] == ftb->info->lastpos) continue; ftbw->docid[1]= ftb->info->lastpos; - _ftb_climb_the_tree(ftb, ftbw, ftb_param->ftsi); + if (unlikely(_ftb_climb_the_tree(ftb, ftbw, ftb_param->ftsi))) + return 1; } return(0); } @@ -926,7 +936,8 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) continue; param->doc= (byte *)ftsi.pos; param->length= ftsi.len; - parser->parse(param); + if (unlikely(parser->parse(param))) + return 0; } ftbe=ftb->root; if (ftbe->docid[1]==docid && ftbe->cur_weight>0 && diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 5c6f66897ee..2bef5238501 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -257,8 +257,12 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, { info->update|= HA_STATE_AKTIV; ftparser_param->flags= MYSQL_FTFLAGS_NEED_COPY; - _mi_ft_parse(&wtree, info, keynr, record, ftparser_param, - &wtree.mem_root); + if (unlikely(_mi_ft_parse(&wtree, info, keynr, record, ftparser_param, + &wtree.mem_root))) + { + delete_queue(&best); + goto err; + } } } delete_queue(&best); From 07086b2e09b822089745ecbc9703729bf68ce9fc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 12:20:34 +0200 Subject: [PATCH 019/156] Bug #28525 Node failures in PGMAN at ndbrequire (line 430) (part 2) --- storage/ndb/src/kernel/blocks/pgman.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp index 09335396a07..72333856cf1 100644 --- a/storage/ndb/src/kernel/blocks/pgman.cpp +++ b/storage/ndb/src/kernel/blocks/pgman.cpp @@ -948,9 +948,11 @@ Pgman::process_map(Signal* signal) #ifdef VM_TRACE debugOut << "PGMAN: >process_map" << endl; #endif - int max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; - if (max_count > 0) + int max_count = 0; + if (m_param.m_max_io_waits > m_stats.m_current_io_waits) { + max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; max_count = max_count / 2 + 1; + } Page_sublist& pl_map = *m_page_sublist[Page_entry::SL_MAP]; while (! pl_map.isEmpty() && --max_count >= 0) @@ -1102,15 +1104,10 @@ Pgman::process_cleanup(Signal* signal) } int max_loop_count = m_param.m_max_loop_count; - int max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; - - if (max_count > 0) - { + int max_count = 0; + if (m_param.m_max_io_waits > m_stats.m_current_io_waits) { + max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; max_count = max_count / 2 + 1; - /* - * Possibly add code here to avoid writing too rapidly. May be - * unnecessary since only cold pages are cleaned. - */ } Ptr ptr = m_cleanup_ptr; @@ -1212,9 +1209,12 @@ bool Pgman::process_lcp(Signal* signal) { Page_hashlist& pl_hash = m_page_hashlist; - int max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; - if (max_count > 0) + + int max_count = 0; + if (m_param.m_max_io_waits > m_stats.m_current_io_waits) { + max_count = m_param.m_max_io_waits - m_stats.m_current_io_waits; max_count = max_count / 2 + 1; + } #ifdef VM_TRACE debugOut From d41bc07359c68780f467278aec2b3f0abea5020e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 12:56:48 +0200 Subject: [PATCH 020/156] Bug #28653 Fast GCP + high load + high RedoBuffer causes ndbrequire - correction, backport to 5.0 --- ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 5 +++++ ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 65f4b0f9b4b..adeed3e1e8b 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -338,6 +338,11 @@ Dblqh::Dblqh(const class Configuration & conf): initData(); + /* maximum number of log file operations */ + clfoFileSize = clogPageFileSize; + if (clfoFileSize < ZLFO_MIN_FILE_SIZE) + clfoFileSize = ZLFO_MIN_FILE_SIZE; + #ifdef VM_TRACE { void* tmp[] = { diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 88bc3f372a5..684598364ab 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -7251,11 +7251,6 @@ void Dblqh::continueScanNextReqLab(Signal* signal) return; } - /* maximum number of log file operations */ - clfoFileSize = clogPageFileSize; - if (clfoFileSize < ZLFO_MIN_FILE_SIZE) - clfoFileSize = ZLFO_MIN_FILE_SIZE; - // Update timer on tcConnectRecord tcConnectptr.p->tcTimer = cLqhTimeOutCount; init_acc_ptr_list(scanptr.p); From 8e885fe0237a1ee5d72d3d2e21587aedc2e34211 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 13:05:05 +0200 Subject: [PATCH 021/156] Bug #28653 Fast GCP + high load + high RedoBuffer causes ndbrequire - correction, backport to 5.0 --- storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 35849c6186c..e2c4b91d904 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -305,11 +305,6 @@ Dblqh::Dblqh(Block_context& ctx): initData(); - /* maximum number of log file operations */ - clfoFileSize = clogPageFileSize; - if (clfoFileSize < ZLFO_MIN_FILE_SIZE) - clfoFileSize = ZLFO_MIN_FILE_SIZE; - #ifdef VM_TRACE { void* tmp[] = { From b1a5f427bccba48c4d4d0fce24c60f89045a07c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 13:23:11 +0200 Subject: [PATCH 022/156] Bug #28719: multi pk update ignore corrupts data - check multi update as well as update - this bug is not present in 5.0, but execution patch is wrong, so there are probably other bugs mysql-test/r/ndb_basic.result: Bug #28719: multi pk update ignore corrupts data - add test + backport some tests from 5.1 mysql-test/t/ndb_basic.test: Bug #28719: multi pk update ignore corrupts data - add test + backport some tests from 5.1 --- mysql-test/r/ndb_basic.result | 71 +++++++++++++++++++++++++++++++++++ mysql-test/t/ndb_basic.test | 40 ++++++++++++++++++++ sql/ha_ndbcluster.cc | 3 +- 3 files changed, 113 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 75ccc6cd39e..346b1d5741b 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -770,4 +770,75 @@ c abc ab d ab ab e abc abc DROP TABLE t1; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 20 +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +a b +3 30 +drop table t1,t2; +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t1 set a=1, b=100; +ERROR 23000: Duplicate entry '1' for key 1 +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +a b +1 11 +2 20 +3 30 +drop table t1; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +update t1 set a = 1 where a = 3; +ERROR 23000: Duplicate entry '1' for key 1 +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 30 +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +ERROR 23000: Duplicate entry '1' for key 1 +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +drop table t1,t2; End of 5.0 tests diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 70fbfbfe733..80c8942348c 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -740,6 +740,46 @@ INSERT INTO t1 VALUES SELECT * FROM t1 ORDER BY a; DROP TABLE t1; +# delete +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +drop table t1,t2; + +# insert ignore +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +--error ER_DUP_ENTRY +insert into t1 set a=1, b=100; +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +drop table t1; + +# update +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +--error ER_DUP_ENTRY +update t1 set a = 1 where a = 3; +select * from t1 order by a; +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +--error ER_DUP_ENTRY +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +drop table t1,t2; + # End of 5.0 tests --echo End of 5.0 tests diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d7326375afb..47815f0fbf1 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2449,7 +2449,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) * If IGNORE the ignore constraint violations on primary and unique keys, * but check that it is not part of INSERT ... ON DUPLICATE KEY UPDATE */ - if (m_ignore_dup_key && thd->lex->sql_command == SQLCOM_UPDATE) + if (m_ignore_dup_key && (thd->lex->sql_command == SQLCOM_UPDATE || + thd->lex->sql_command == SQLCOM_UPDATE_MULTI)) { int peek_res= peek_indexed_rows(new_data, pk_update); From e231e496027fc5c257a8a99f09d7c1253381c831 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 14:13:42 +0200 Subject: [PATCH 023/156] Bug #28719: multi pk update ignore corrupts data - 5.1 adoption --- mysql-test/t/ndb_basic.test | 46 +++---------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 8496f0e83b5..870c7435d3e 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -767,7 +767,7 @@ drop table t1,t2; # insert ignore create table t1 (a int not null primary key, b int not null) engine=ndb; insert into t1 values (1,10), (2,20), (3,30); ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 set a=1, b=100; insert ignore into t1 set a=1, b=100; select * from t1 order by a; @@ -780,12 +780,12 @@ create table t1 (a int not null primary key, b int not null) engine=ndb; create table t2 (c int not null primary key, d int not null) engine=ndb; insert into t1 values (1,10), (2,10), (3,30), (4, 30); insert into t2 values (1,10), (2,10), (3,30), (4, 30); ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME update t1 set a = 1 where a = 3; select * from t1 order by a; update t1 set b = 1 where a > 1 order by a desc limit 1; select * from t1 order by a; ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; select * from t1 order by a; update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; @@ -832,44 +832,4 @@ create table t2 like t1; rename table t1 to t10, t2 to t20; drop table t10,t20; -# delete -create table t1 (a int not null primary key, b int not null) engine=ndb; -create table t2 (a int not null primary key, b int not null) engine=ndb; -insert into t1 values (1,10), (2,20), (3,30); -insert into t2 values (1,10), (2,20), (3,30); -select * from t1 order by a; -delete from t1 where a > 0 order by a desc limit 1; -select * from t1 order by a; -delete from t1,t2 using t1,t2 where t1.a = t2.a; -select * from t2 order by a; -drop table t1,t2; - -# insert ignore -create table t1 (a int not null primary key, b int not null) engine=ndb; -insert into t1 values (1,10), (2,20), (3,30); ---error ER_DUP_ENTRY_WITH_KEY_NAME -insert into t1 set a=1, b=100; -insert ignore into t1 set a=1, b=100; -select * from t1 order by a; -insert into t1 set a=1, b=1000 on duplicate key update b=b+1; -select * from t1 order by a; -drop table t1; - -# update -create table t1 (a int not null primary key, b int not null) engine=ndb; -create table t2 (c int not null primary key, d int not null) engine=ndb; -insert into t1 values (1,10), (2,10), (3,30), (4, 30); -insert into t2 values (1,10), (2,10), (3,30), (4, 30); ---error ER_DUP_ENTRY_WITH_KEY_NAME -update t1 set a = 1 where a = 3; -select * from t1 order by a; -update t1 set b = 1 where a > 1 order by a desc limit 1; -select * from t1 order by a; ---error ER_DUP_ENTRY_WITH_KEY_NAME -update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; -select * from t1 order by a; -update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; -select * from t1 order by a; -drop table t1,t2; - --echo End of 5.1 tests From 547b51124c580e0d5fbfd519a93e38f2364f729c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 15:59:02 +0200 Subject: [PATCH 024/156] bug#28717, make sure only master updates activeStatus so that othernodes dont get confused after having recevied status from master and then tries to update it self ndb/src/kernel/blocks/ERROR_codes.txt: error 1001, delay node_failrep ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: error 1001, delay node_failrep ndb/test/ndbapi/testNodeRestart.cpp: testcase ndb/test/run-test/daily-basic-tests.txt: testcase --- ndb/src/kernel/blocks/ERROR_codes.txt | 7 +- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 8 +- ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 7 ++ ndb/test/ndbapi/testNodeRestart.cpp | 81 +++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 + 5 files changed, 105 insertions(+), 2 deletions(-) diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index 0bcc99a6334..bf54d583299 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -1,5 +1,5 @@ Next QMGR 1 -Next NDBCNTR 1000 +Next NDBCNTR 1002 Next NDBFS 2000 Next DBACC 3002 Next DBTUP 4014 @@ -487,3 +487,8 @@ Dbdict: 6003 Crash in participant @ CreateTabReq::Prepare 6004 Crash in participant @ CreateTabReq::Commit 6005 Crash in participant @ CreateTabReq::CreateDrop + +Ndbcntr: +-------- + +1001: Delay sending NODE_FAILREP (to own node), until error is cleared diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index f24a8e2c7d5..44e2293f318 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -4448,12 +4448,18 @@ void Dbdih::failedNodeLcpHandling(Signal* signal, NodeRecordPtr failedNodePtr) jam(); const Uint32 nodeId = failedNodePtr.i; - if (c_lcpState.m_participatingLQH.get(failedNodePtr.i)){ + if (isMaster() && c_lcpState.m_participatingLQH.get(failedNodePtr.i)) + { /*----------------------------------------------------*/ /* THE NODE WAS INVOLVED IN A LOCAL CHECKPOINT. WE */ /* MUST UPDATE THE ACTIVE STATUS TO INDICATE THAT */ /* THE NODE HAVE MISSED A LOCAL CHECKPOINT. */ /*----------------------------------------------------*/ + + /** + * Bug#28717, Only master should do this, as this status is copied + * to other nodes + */ switch (failedNodePtr.p->activeStatus) { case Sysfile::NS_Active: jam(); diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 26e8f246293..65d80669316 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -1375,6 +1375,13 @@ void Ndbcntr::execNODE_FAILREP(Signal* signal) { jamEntry(); + if (ERROR_INSERTED(1001)) + { + sendSignalWithDelay(reference(), GSN_NODE_FAILREP, signal, 100, + signal->getLength()); + return; + } + const NodeFailRep * nodeFail = (NodeFailRep *)&signal->theData[0]; NdbNodeBitmask allFailed; allFailed.assign(NdbNodeBitmask::Size, nodeFail->theNodes); diff --git a/ndb/test/ndbapi/testNodeRestart.cpp b/ndb/test/ndbapi/testNodeRestart.cpp index 9adbfbd46a6..e5ced961b6f 100644 --- a/ndb/test/ndbapi/testNodeRestart.cpp +++ b/ndb/test/ndbapi/testNodeRestart.cpp @@ -1045,6 +1045,84 @@ int runBug25554(NDBT_Context* ctx, NDBT_Step* step){ } +int +runBug28717(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + int loops = ctx->getNumLoops(); + int records = ctx->getNumRecords(); + Ndb* pNdb = GETNDB(step); + NdbRestarter res; + + if (res.getNumDbNodes() < 4) + { + return NDBT_OK; + } + + int master = res.getMasterNodeId(); + int node0 = res.getRandomNodeOtherNodeGroup(master, rand()); + int node1 = res.getRandomNodeSameNodeGroup(node0, rand()); + + ndbout_c("master: %d node0: %d node1: %d", master, node0, node1); + + if (res.restartOneDbNode(node0, false, true, true)) + { + return NDBT_FAILED; + } + + { + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 }; + NdbLogEventHandle handle = + ndb_mgm_create_logevent_handle(res.handle, filter); + + + int dump[] = { DumpStateOrd::DihStartLcpImmediately }; + struct ndb_logevent event; + + for (Uint32 i = 0; i<3; i++) + { + res.dumpStateOneNode(master, dump, 1); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointStarted); + while(ndb_logevent_get_next(handle, &event, 0) >= 0 && + event.type != NDB_LE_LocalCheckpointCompleted); + } + } + + if (res.waitNodesNoStart(&node0, 1)) + return NDBT_FAILED; + + int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 }; + + if (res.dumpStateOneNode(node0, val2, 2)) + return NDBT_FAILED; + + if (res.insertErrorInNode(node0, 5010)) + return NDBT_FAILED; + + if (res.insertErrorInNode(node1, 1001)) + return NDBT_FAILED; + + if (res.startNodes(&node0, 1)) + return NDBT_FAILED; + + NdbSleep_SecSleep(3); + + if (res.insertErrorInNode(node1, 0)) + return NDBT_FAILED; + + if (res.waitNodesNoStart(&node0, 1)) + return NDBT_FAILED; + + if (res.startNodes(&node0, 1)) + return NDBT_FAILED; + + 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 "\ @@ -1366,6 +1444,9 @@ TESTCASE("Bug25364", ""){ TESTCASE("Bug25554", ""){ INITIALIZER(runBug25554); } +TESTCASE("Bug28717", ""){ + INITIALIZER(runBug28717); +} 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 d2c91279d18..5a3947ec1e9 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -492,6 +492,10 @@ max-time: 1500 cmd: testDict args: -n CreateAndDrop +max-time: 1000 +cmd: testNodeRestart +args: -n Bug28717 T1 + max-time: 1500 cmd: testDict args: -n CreateAndDropAtRandom -l 200 T1 From f4c75aefb2f064dbca40e83e96f29dcf1fb0b9c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 16:18:04 +0200 Subject: [PATCH 025/156] make memeber public --- ndb/test/include/NdbRestarter.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ndb/test/include/NdbRestarter.hpp b/ndb/test/include/NdbRestarter.hpp index 2f21c41b9c4..63de32ac038 100644 --- a/ndb/test/include/NdbRestarter.hpp +++ b/ndb/test/include/NdbRestarter.hpp @@ -65,6 +65,8 @@ public: int getRandomNodeOtherNodeGroup(int nodeId, int randomNumber); int getRandomNotMasterNodeId(int randomNumber); + NdbMgmHandle handle; + protected: int waitClusterState(ndb_mgm_node_status _status, @@ -87,7 +89,6 @@ protected: bool connected; BaseString addr; - NdbMgmHandle handle; ndb_mgm_configuration * m_config; protected: ndb_mgm_configuration * getConfig(); From 07524c35f8cc6962b8be558cf8bb1731e3cbd349 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 16:31:31 +0200 Subject: [PATCH 026/156] print user and system time at watchdog check --- ndb/src/kernel/vm/WatchDog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ndb/src/kernel/vm/WatchDog.cpp b/ndb/src/kernel/vm/WatchDog.cpp index d1abb709b1e..2e24a5eaa6c 100644 --- a/ndb/src/kernel/vm/WatchDog.cpp +++ b/ndb/src/kernel/vm/WatchDog.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "WatchDog.hpp" #include "GlobalData.hpp" @@ -129,6 +130,13 @@ WatchDog::run(){ break; }//switch g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action); + { + struct tms my_tms; + times(&my_tms); + g_eventLogger.info("User time: %llu System time: %llu", + (Uint64)my_tms.tms_utime, + (Uint64)my_tms.tms_stime); + } if(alerts == 3){ shutdownSystem(last_stuck_action); } From 2fd3e40a91c2786fc8e9b8292ed06949ce8945cf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 22:14:29 +0200 Subject: [PATCH 027/156] configure.in: After merge changes, removed unneeded Netware specific sprintf case configure.in: After merge changes, removed unneeded Netware specific sprintf case --- configure.in | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 7c18aeb4fc6..8f4b847bb25 100644 --- a/configure.in +++ b/configure.in @@ -230,14 +230,8 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL']) AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf) AC_CHECK_PROG(DVIS, tex, manual.dvi) -AC_MSG_CHECKING("return type of sprintf") - #check the return type of sprintf -case $SYSTEM_TYPE in - *netware*) - AC_DEFINE(SPRINTF_RETURNS_INT, [1]) AC_MSG_RESULT("int") - ;; - *) +AC_MSG_CHECKING("return type of sprintf") AC_TRY_RUN([ int main() { @@ -263,13 +257,12 @@ AC_TRY_RUN([ [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf]) AC_MSG_RESULT("ptr")], [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf]) - AC_MSG_RESULT("garbage")]) - ], + AC_MSG_RESULT("garbage")] + )], # Cross compile, assume POSIX [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) - AC_MSG_RESULT("int (we assume)")]) - ;; -esac + AC_MSG_RESULT("int (we assume)")] +) AC_PATH_PROG(uname_prog, uname, no) From 8fb480ef501d7c78100b692a680ae383dcbd94d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 22:18:51 +0200 Subject: [PATCH 028/156] Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory plugin/daemon_example/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory plugin/fulltext/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory unittest/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory unittest/examples/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory unittest/mysys/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory unittest/mytap/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory unittest/mytap/t/Makefile.am: Consistent use of '%::SCCS/s.%' to prevent some 'make' implementations from trying to update files in SCCS directory --- plugin/daemon_example/Makefile.am | 3 +++ plugin/fulltext/Makefile.am | 3 +++ unittest/Makefile.am | 3 +++ unittest/examples/Makefile.am | 2 ++ unittest/mysys/Makefile.am | 2 ++ unittest/mytap/Makefile.am | 3 +++ unittest/mytap/t/Makefile.am | 2 ++ 7 files changed, 18 insertions(+) diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am index 21a86f8973e..92b1ab040fb 100644 --- a/plugin/daemon_example/Makefile.am +++ b/plugin/daemon_example/Makefile.am @@ -36,3 +36,6 @@ noinst_LIBRARIES = @plugin_daemon_example_static_target@ libdaemon_example_a_CXXFLAGS = $(AM_CFLAGS) libdaemon_example_a_CFLAGS = $(AM_CFLAGS) libdaemon_example_a_SOURCES= daemon_example.cc + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/plugin/fulltext/Makefile.am b/plugin/fulltext/Makefile.am index d4ec097efbd..ec033018a00 100644 --- a/plugin/fulltext/Makefile.am +++ b/plugin/fulltext/Makefile.am @@ -22,3 +22,6 @@ pkglib_LTLIBRARIES= mypluglib.la mypluglib_la_SOURCES= plugin_example.c mypluglib_la_LDFLAGS= -module -rpath $(pkglibdir) mypluglib_la_CFLAGS= -DMYSQL_DYNAMIC_PLUGIN + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 6197586b008..65fa615fb98 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -25,3 +25,6 @@ test: test-verbose: HARNESS_VERBOSE=1 perl unit.pl run $(unittests) + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/examples/Makefile.am b/unittest/examples/Makefile.am index f3183225888..94032c00928 100644 --- a/unittest/examples/Makefile.am +++ b/unittest/examples/Makefile.am @@ -22,3 +22,5 @@ LDADD = -lmytap noinst_PROGRAMS = simple-t skip-t todo-t skip_all-t no_plan-t core-t +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am index 54b3d203e10..be91ef31c9d 100644 --- a/unittest/mysys/Makefile.am +++ b/unittest/mysys/Makefile.am @@ -23,3 +23,5 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \ noinst_PROGRAMS = bitmap-t base64-t my_atomic-t +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/mytap/Makefile.am b/unittest/mytap/Makefile.am index 2f77c4e3e0d..c02bcd3b49d 100644 --- a/unittest/mytap/Makefile.am +++ b/unittest/mytap/Makefile.am @@ -21,3 +21,6 @@ noinst_HEADERS = tap.h libmytap_a_SOURCES = tap.c SUBDIRS = . t + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/mytap/t/Makefile.am b/unittest/mytap/t/Makefile.am index 576bbafa299..e89a088bb3a 100644 --- a/unittest/mytap/t/Makefile.am +++ b/unittest/mytap/t/Makefile.am @@ -21,3 +21,5 @@ LDADD = -lmytap noinst_PROGRAMS = basic-t +# Don't update the files from bitkeeper +%::SCCS/s.% From bfc82a63637aea40e1e671bff97a0fb13f9fefe3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 07:16:26 +0200 Subject: [PATCH 029/156] ndb - fix typo --- ndb/test/run-test/daily-basic-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index fffe1ac9046..1ade56f7579 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -608,7 +608,7 @@ args: -n Bug_11133 T1 max-time: 1000 cmd: testNdbApi -args: -n BugBug28443 +args: -n Bug28443 #max-time: 500 #cmd: testInterpreter From ff0479e367d1734ace67f27ea28e0e1778315f33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 11:55:12 +0200 Subject: [PATCH 030/156] Bug #26783 replication status unknown after cluster or mysqld failure --- mysql-test/t/disabled.def | 1 - sql/ha_ndbcluster.cc | 2 -- 2 files changed, 3 deletions(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index e2a0b30c592..e283ca9458f 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -39,5 +39,4 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb #rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly -rpl_ndb_stm_innodb : Bug#26783 ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5ec125718c0..52861e3e627 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4248,8 +4248,6 @@ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd, extern MASTER_INFO *active_mi; static int ndbcluster_update_apply_status(THD *thd, int do_update) { - return 0; - Thd_ndb *thd_ndb= get_thd_ndb(thd); Ndb *ndb= thd_ndb->ndb; NDBDICT *dict= ndb->getDictionary(); From 6c40a4e64276776b0cb2501cd4d5a0d2939f4db5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 12:23:49 +0200 Subject: [PATCH 031/156] BUG#17707 check-cpu script doesn't include Turion BUILD/check-cpu: BUG#17707 add Turion (and Opteron) --- BUILD/check-cpu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 2854ec721c6..7429a955ac0 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -104,6 +104,12 @@ check_cpu () { *Athlon*64*) cpu_arg="athlon64"; ;; + *Turion*) + cpu_arg="athlon64"; + ;; + *Opteron*) + cpu_arg="athlon64"; + ;; *Athlon*) cpu_arg="athlon"; ;; From a14059db518e6519a2bc1579e5b0f7e04a89c7c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 23:39:57 +0200 Subject: [PATCH 032/156] shorten some files for tar to work storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp: Rename: storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp -> storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp: Rename: storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp -> storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp: Rename: storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp -> storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp: Rename: storage/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp -> storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp: Rename: storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp -> storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp --- storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile | 6 +++--- .../mgmapi_logevent/{mgmapi_logevent.cpp => main.cpp} | 0 storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile | 6 +++--- .../mgmapi_logevent2/{mgmapi_logevent2.cpp => main.cpp} | 0 storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile | 6 +++--- .../ndbapi_simple_dual/{ndbapi_simple_dual.cpp => main.cpp} | 0 storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile | 6 +++--- .../{ndbapi_simple_index.cpp => main.cpp} | 0 storage/ndb/src/kernel/blocks/dblqh/Makefile.am | 2 +- .../redoLogReader/{redoLogFileReader.cpp => reader.cpp} | 0 10 files changed, 13 insertions(+), 13 deletions(-) rename storage/ndb/ndbapi-examples/mgmapi_logevent/{mgmapi_logevent.cpp => main.cpp} (100%) rename storage/ndb/ndbapi-examples/mgmapi_logevent2/{mgmapi_logevent2.cpp => main.cpp} (100%) rename storage/ndb/ndbapi-examples/ndbapi_simple_dual/{ndbapi_simple_dual.cpp => main.cpp} (100%) rename storage/ndb/ndbapi-examples/ndbapi_simple_index/{ndbapi_simple_index.cpp => main.cpp} (100%) rename storage/ndb/src/kernel/blocks/dblqh/redoLogReader/{redoLogFileReader.cpp => reader.cpp} (100%) diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile b/storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile index c9b4507c4a7..b67150b71fa 100644 --- a/storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile +++ b/storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile @@ -1,6 +1,6 @@ TARGET = mgmapi_logevent -SRCS = $(TARGET).cpp -OBJS = $(TARGET).o +SRCS = main.cpp +OBJS = main.o CXX = g++ CFLAGS = -c -Wall -fno-rtti -fno-exceptions CXXFLAGS = @@ -17,7 +17,7 @@ SYS_LIB = $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET) -$(TARGET).o: $(SRCS) +$(OBJS): $(SRCS) $(CXX) $(CFLAGS) -I$(TOP_SRCDIR)/include -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/mgmapi -I$(INCLUDE_DIR)/ndbapi $(SRCS) clean: diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp similarity index 100% rename from storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp rename to storage/ndb/ndbapi-examples/mgmapi_logevent/main.cpp diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile index 95b43b11f6b..fd9499c7a68 100644 --- a/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile +++ b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile @@ -1,6 +1,6 @@ TARGET = mgmapi_logevent2 -SRCS = $(TARGET).cpp -OBJS = $(TARGET).o +SRCS = main.cpp +OBJS = main.o CXX = g++ CFLAGS = -c -Wall -fno-rtti -fno-exceptions CXXFLAGS = @@ -17,7 +17,7 @@ SYS_LIB = $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET) -$(TARGET).o: $(SRCS) +$(OBJS): $(SRCS) $(CXX) $(CFLAGS) -I$(TOP_SRCDIR)/include -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/mgmapi -I$(INCLUDE_DIR)/ndbapi $(SRCS) clean: diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp similarity index 100% rename from storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp rename to storage/ndb/ndbapi-examples/mgmapi_logevent2/main.cpp diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile b/storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile index 7f0ca52fcc3..9757df3ceab 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile +++ b/storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile @@ -1,6 +1,6 @@ TARGET = ndbapi_simple_dual -SRCS = $(TARGET).cpp -OBJS = $(TARGET).o +SRCS = main.cpp +OBJS = main.o CXX = g++ CFLAGS = -c -Wall -fno-rtti -fno-exceptions CXXFLAGS = @@ -17,7 +17,7 @@ SYS_LIB = $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET) -$(TARGET).o: $(SRCS) +$(OBJS): $(SRCS) $(CXX) $(CFLAGS) -I$(TOP_SRCDIR)/include -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS) clean: diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp b/storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp similarity index 100% rename from storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp rename to storage/ndb/ndbapi-examples/ndbapi_simple_dual/main.cpp diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile b/storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile index c38975381f5..975563b9508 100644 --- a/storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile +++ b/storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile @@ -1,6 +1,6 @@ TARGET = ndbapi_simple_index -SRCS = $(TARGET).cpp -OBJS = $(TARGET).o +SRCS = main.cpp +OBJS = main.o CXX = g++ CFLAGS = -c -Wall -fno-rtti -fno-exceptions CXXFLAGS = @@ -17,7 +17,7 @@ SYS_LIB = $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET) -$(TARGET).o: $(SRCS) +$(OBJS): $(SRCS) $(CXX) $(CFLAGS) -I$(INCLUDE_DIR)/include -I$(INCLUDE_DIR)/storage/ndb/include -I$(INCLUDE_DIR)/storage/ndb/include/ndbapi $(SRCS) clean: diff --git a/storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp b/storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp similarity index 100% rename from storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp rename to storage/ndb/ndbapi-examples/ndbapi_simple_index/main.cpp diff --git a/storage/ndb/src/kernel/blocks/dblqh/Makefile.am b/storage/ndb/src/kernel/blocks/dblqh/Makefile.am index c7c477a512c..b545096dc83 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dblqh/Makefile.am @@ -16,7 +16,7 @@ EXTRA_PROGRAMS = ndbd_redo_log_reader ndbd_redo_log_reader_SOURCES = redoLogReader/records.cpp \ - redoLogReader/redoLogFileReader.cpp + redoLogReader/reader.cpp include $(top_srcdir)/storage/ndb/config/common.mk.am include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am diff --git a/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp b/storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp similarity index 100% rename from storage/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp rename to storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp From afac7ead7f3bf5e4a3335af0da7b7abb274c7c02 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 09:00:50 +0200 Subject: [PATCH 033/156] Bug #28749 MaxNoOfOpenFiles offset by 1 --- ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 353330929e5..55b0a8c4d39 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -569,7 +569,7 @@ AsyncFile* Ndbfs::createAsyncFile(){ // Check limit of open files - if (theFiles.size()+1 == m_maxFiles) { + if (theFiles.size() == m_maxFiles) { // Print info about all open files for (unsigned i = 0; i < theFiles.size(); i++){ AsyncFile* file = theFiles[i]; From 40462a078f9b640e80d5649f0f682bfcc64c5a08 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 12:29:19 +0200 Subject: [PATCH 034/156] Bug #28770 file already opened error when corrupt schema file - make sure we close the first file, before opening the next --- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index b125f8d988d..699b5cb735b 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -401,6 +401,9 @@ void Dbdict::execFSCLOSECONF(Signal* signal) case FsConnectRecord::OPEN_READ_SCHEMA2: openSchemaFile(signal, 1, fsPtr.i, false, false); break; + case FsConnectRecord::OPEN_READ_TAB_FILE2: + openTableFile(signal, 1, fsPtr.i, c_readTableRecord.tableId, false); + break; default: jamLine((fsPtr.p->fsState & 0xFFF)); ndbrequire(false); @@ -780,8 +783,11 @@ void Dbdict::readTableConf(Signal* signal, void Dbdict::readTableRef(Signal* signal, FsConnectRecordPtr fsPtr) { + /** + * First close corrupt file + */ fsPtr.p->fsState = FsConnectRecord::OPEN_READ_TAB_FILE2; - openTableFile(signal, 1, fsPtr.i, c_readTableRecord.tableId, false); + closeFile(signal, fsPtr.p->filePtr, fsPtr.i); return; }//Dbdict::readTableRef() From 91e5084ef13fa870ec332ce1e74dd92f0228fdee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 17:25:22 +0200 Subject: [PATCH 035/156] Bug #28443 - correction of merge error --- ndb/src/common/transporter/Packer.cpp | 5 +++ .../common/transporter/TCP_Transporter.hpp | 4 ++ .../transporter/TransporterRegistry.cpp | 41 ++++++++++--------- ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 17 ++++++++ ndb/test/ndbapi/testNdbApi.cpp | 34 +++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++ 6 files changed, 86 insertions(+), 19 deletions(-) diff --git a/ndb/src/common/transporter/Packer.cpp b/ndb/src/common/transporter/Packer.cpp index 66c00b0af89..d471167b0e7 100644 --- a/ndb/src/common/transporter/Packer.cpp +++ b/ndb/src/common/transporter/Packer.cpp @@ -20,7 +20,12 @@ #include #include +#ifdef ERROR_INSERT +Uint32 MAX_RECEIVED_SIGNALS = 1024; +#else #define MAX_RECEIVED_SIGNALS 1024 +#endif + Uint32 TransporterRegistry::unpack(Uint32 * readPtr, Uint32 sizeOfData, diff --git a/ndb/src/common/transporter/TCP_Transporter.hpp b/ndb/src/common/transporter/TCP_Transporter.hpp index 8cba7a01532..fdb64939d5a 100644 --- a/ndb/src/common/transporter/TCP_Transporter.hpp +++ b/ndb/src/common/transporter/TCP_Transporter.hpp @@ -101,6 +101,10 @@ private: virtual void updateReceiveDataPtr(Uint32 bytesRead); virtual Uint32 get_free_buffer() const; + + inline bool hasReceiveData () const { + return receiveBuffer.sizeOfData > 0; + } protected: /** * Setup client/server and perform connect/accept diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index bd3136f023c..7a05dcb30c2 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -841,6 +841,7 @@ TransporterRegistry::poll_OSE(Uint32 timeOutMillis) Uint32 TransporterRegistry::poll_TCP(Uint32 timeOutMillis) { + bool hasdata = false; if (false && nTCPTransporters == 0) { tcpReadSelectReply = 0; @@ -885,6 +886,7 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis) // Put the connected transporters in the socket read-set FD_SET(socket, &tcpReadset); } + hasdata |= t->hasReceiveData(); } // The highest socket value plus one @@ -901,7 +903,7 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis) } #endif - return tcpReadSelectReply; + return tcpReadSelectReply || hasdata; } #endif @@ -937,26 +939,27 @@ TransporterRegistry::performReceive() #endif #ifdef NDB_TCP_TRANSPORTER - if(tcpReadSelectReply > 0) + for (int i=0; igetRemoteNodeId(); - const NDB_SOCKET_TYPE socket = t->getSocket(); - if(is_connected(nodeId)){ - if(t->isConnected() && FD_ISSET(socket, &tcpReadset)) + checkJobBuffer(); + TCP_Transporter *t = theTCPTransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + const NDB_SOCKET_TYPE socket = t->getSocket(); + if(is_connected(nodeId)){ + if(t->isConnected()) + { + if (FD_ISSET(socket, &tcpReadset)) { - const int receiveSize = t->doReceive(); - if(receiveSize > 0) - { - Uint32 * ptr; - Uint32 sz = t->getReceiveData(&ptr); - transporter_recv_from(callbackObj, nodeId); - Uint32 szUsed = unpack(ptr, sz, nodeId, ioStates[nodeId]); - t->updateReceiveDataPtr(szUsed); - } + t->doReceive(); + } + + if (t->hasReceiveData()) + { + Uint32 * ptr; + Uint32 sz = t->getReceiveData(&ptr); + transporter_recv_from(callbackObj, nodeId); + Uint32 szUsed = unpack(ptr, sz, nodeId, ioStates[nodeId]); + t->updateReceiveDataPtr(szUsed); } } } diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index a9d9c991ca3..8c3148862d4 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -136,6 +136,7 @@ Cmvmi::~Cmvmi() #ifdef ERROR_INSERT NodeBitmask c_error_9000_nodes_mask; +extern Uint32 MAX_RECEIVED_SIGNALS; #endif void Cmvmi::execNDB_TAMPER(Signal* signal) @@ -165,6 +166,22 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) kill(getpid(), SIGABRT); } #endif + +#ifdef ERROR_INSERT + if (signal->theData[0] == 9003) + { + if (MAX_RECEIVED_SIGNALS < 1024) + { + MAX_RECEIVED_SIGNALS = 1024; + } + else + { + MAX_RECEIVED_SIGNALS = rand() % 128; + } + ndbout_c("MAX_RECEIVED_SIGNALS: %d", MAX_RECEIVED_SIGNALS); + CLEAR_ERROR_INSERT_VALUE; + } +#endif }//execNDB_TAMPER() void Cmvmi::execSET_LOGLEVELORD(Signal* signal) diff --git a/ndb/test/ndbapi/testNdbApi.cpp b/ndb/test/ndbapi/testNdbApi.cpp index aee668039fe..ad16c472229 100644 --- a/ndb/test/ndbapi/testNdbApi.cpp +++ b/ndb/test/ndbapi/testNdbApi.cpp @@ -1306,6 +1306,36 @@ int runTestExecuteAsynch(NDBT_Context* ctx, NDBT_Step* step){ template class Vector; +int +runBug28443(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + int records = ctx->getNumRecords(); + + NdbRestarter restarter; + + restarter.insertErrorInAllNodes(9003); + + for (Uint32 i = 0; igetNumLoops(); i++) + { + HugoTransactions hugoTrans(*ctx->getTab()); + if (hugoTrans.loadTable(GETNDB(step), records, 2048) != 0) + { + result = NDBT_FAILED; + goto done; + } + if (runClearTable(ctx, step) != 0) + { + result = NDBT_FAILED; + goto done; + } + } + +done: + restarter.insertErrorInAllNodes(9003); + + return result; +} NDBT_TESTSUITE(testNdbApi); TESTCASE("MaxNdb", @@ -1392,6 +1422,10 @@ TESTCASE("Scan_4006", INITIALIZER(runScan_4006); FINALIZER(runClearTable); } +TESTCASE("Bug28443", + ""){ + INITIALIZER(runBug28443); +} TESTCASE("ExecuteAsynch", "Check that executeAsync() works (BUG#27495)\n"){ INITIALIZER(runTestExecuteAsynch); diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 5a3947ec1e9..f4a685299d6 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -617,6 +617,10 @@ max-time: 500 cmd: testNdbApi args: -n ExecuteAsynch T1 +max-time: 1000 +cmd: testNdbApi +args: -n BugBug28443 + #max-time: 500 #cmd: testInterpreter #args: T1 From e65fdda8b1a188442cf5547dba18c69a0cecf1b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 22:11:53 +0200 Subject: [PATCH 036/156] Makefile.am, configure.in: Added --with-mysqld-libs configure flag configure.in: Added --with-mysqld-libs configure flag sql/Makefile.am: Added --with-mysqld-libs configure flag --- configure.in | 6 ++++++ sql/Makefile.am | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index b9f84086e28..1b3fb9f867d 100644 --- a/configure.in +++ b/configure.in @@ -1747,6 +1747,12 @@ AC_ARG_WITH(client-ldflags, [CLIENT_EXTRA_LDFLAGS=]) AC_SUBST(CLIENT_EXTRA_LDFLAGS) +AC_ARG_WITH(mysqld-libs, + [ --with-mysqld-libs Extra libraries to link with for mysqld], + [MYSQLD_EXTRA_LIBS=$withval], + [MYSQLD_EXTRA_LIBS=]) +AC_SUBST(MYSQLD_EXTRA_LIBS) + AC_ARG_WITH(lib-ccflags, [ --with-lib-ccflags Extra CC options for libraries], [LIB_EXTRA_CCFLAGS=$withval], diff --git a/sql/Makefile.am b/sql/Makefile.am index cf7bc0a1452..69dbef4364d 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -43,7 +43,8 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \ @bdb_libs@ @innodb_libs@ @pstack_libs@ \ @innodb_system_libs@ \ @ndbcluster_libs@ @ndbcluster_system_libs@ \ - $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@ + $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@ \ + @MYSQLD_EXTRA_LIBS@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_strfunc.h item_timefunc.h item_uniq.h \ item_create.h item_subselect.h item_row.h \ From c063a677ac7207ed1139059330a98cbd3917e7b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 09:34:24 +0200 Subject: [PATCH 037/156] some test cases cannot run with --skip-log-bin mysql-test/r/mix_innodb_myisam_binlog.result: have_log_bin.inc increases transaction count by onw mysql-test/t/binlog.test: test obviously requires binlog mysql-test/t/blackhole.test: test requires binlog for now mysql-test/t/ctype_cp932_binlog.test: test requires binlog mysql-test/t/ctype_cp932_notembedded.test: test requires binlog for now mysql-test/t/ctype_ucs_binlog.test: test requires binlog mysql-test/t/drop_temp_table.test: test requires binlog for now mysql-test/t/flush_block_commit_notembedded.test: test requires binlog for now mysql-test/t/insert_select-binlog.test: test requires binlog mysql-test/t/mix_innodb_myisam_binlog.test: test requires binlog mysql-test/t/mysqlbinlog-cp932.test: test requires binlog mysql-test/t/mysqlbinlog.test: test requires binlog mysql-test/t/mysqlbinlog2.test: test requires binlog mysql-test/t/mysqltest.test: test requires binlog for now mysql-test/t/sp_trans.test: test requires binlog for now mysql-test/t/user_var-binlog.test: test requires binlog for now --- mysql-test/r/mix_innodb_myisam_binlog.result | 30 +++++++++---------- mysql-test/t/binlog.test | 1 + mysql-test/t/blackhole.test | 1 + mysql-test/t/ctype_cp932_binlog.test | 1 + mysql-test/t/ctype_cp932_notembedded.test | 1 + mysql-test/t/ctype_ucs_binlog.test | 1 + mysql-test/t/drop_temp_table.test | 1 + .../t/flush_block_commit_notembedded.test | 2 ++ mysql-test/t/insert_select-binlog.test | 1 + mysql-test/t/mix_innodb_myisam_binlog.test | 2 +- mysql-test/t/mysqlbinlog-cp932.test | 3 +- mysql-test/t/mysqlbinlog.test | 2 ++ mysql-test/t/mysqlbinlog2.test | 2 ++ mysql-test/t/mysqltest.test | 2 ++ mysql-test/t/sp_trans.test | 1 + mysql-test/t/user_var-binlog.test | 1 + 16 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index a8b132ae927..2c0712f80b1 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -11,7 +11,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(1) master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1 -master-bin.000001 347 Xid 1 # COMMIT /* xid=8 */ +master-bin.000001 347 Xid 1 # COMMIT /* xid=9 */ delete from t1; delete from t2; reset master; @@ -47,7 +47,7 @@ master-bin.000001 253 Query 1 # use `test`; savepoint my_savepoint master-bin.000001 338 Query 1 # use `test`; insert into t1 values(4) master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint -master-bin.000001 616 Xid 1 # COMMIT /* xid=25 */ +master-bin.000001 616 Xid 1 # COMMIT /* xid=26 */ delete from t1; delete from t2; reset master; @@ -74,7 +74,7 @@ master-bin.000001 338 Query 1 # use `test`; insert into t1 values(6) master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint master-bin.000001 616 Query 1 # use `test`; insert into t1 values(7) -master-bin.000001 703 Xid 1 # COMMIT /* xid=37 */ +master-bin.000001 703 Xid 1 # COMMIT /* xid=38 */ delete from t1; delete from t2; reset master; @@ -101,7 +101,7 @@ insert into t2 select * from t1; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(9) -master-bin.000001 185 Xid 1 # COMMIT /* xid=60 */ +master-bin.000001 185 Xid 1 # COMMIT /* xid=61 */ master-bin.000001 212 Query 1 # use `test`; insert into t2 select * from t1 delete from t1; delete from t2; @@ -112,18 +112,18 @@ insert into t2 select * from t1; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10) -master-bin.000001 186 Xid 1 # COMMIT /* xid=66 */ +master-bin.000001 186 Xid 1 # COMMIT /* xid=67 */ master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1 insert into t1 values(11); commit; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10) -master-bin.000001 186 Xid 1 # COMMIT /* xid=66 */ +master-bin.000001 186 Xid 1 # COMMIT /* xid=67 */ master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 307 Query 1 # use `test`; BEGIN master-bin.000001 375 Query 1 # use `test`; insert into t1 values(11) -master-bin.000001 463 Xid 1 # COMMIT /* xid=68 */ +master-bin.000001 463 Xid 1 # COMMIT /* xid=69 */ alter table t2 engine=INNODB; delete from t1; delete from t2; @@ -137,7 +137,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(12) master-bin.000001 254 Query 1 # use `test`; insert into t2 select * from t1 -master-bin.000001 348 Xid 1 # COMMIT /* xid=78 */ +master-bin.000001 348 Xid 1 # COMMIT /* xid=79 */ delete from t1; delete from t2; reset master; @@ -161,7 +161,7 @@ show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(14) -master-bin.000001 254 Xid 1 # COMMIT /* xid=94 */ +master-bin.000001 254 Xid 1 # COMMIT /* xid=95 */ delete from t1; delete from t2; reset master; @@ -182,7 +182,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(16) master-bin.000001 254 Query 1 # use `test`; insert into t1 values(18) -master-bin.000001 342 Xid 1 # COMMIT /* xid=105 */ +master-bin.000001 342 Xid 1 # COMMIT /* xid=106 */ delete from t1; delete from t2; alter table t2 type=MyISAM; @@ -234,19 +234,19 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(16) master-bin.000001 254 Query 1 # use `test`; insert into t1 values(18) -master-bin.000001 342 Xid 1 # COMMIT /* xid=105 */ +master-bin.000001 342 Xid 1 # COMMIT /* xid=106 */ master-bin.000001 369 Query 1 # use `test`; delete from t1 -master-bin.000001 446 Xid 1 # COMMIT /* xid=114 */ +master-bin.000001 446 Xid 1 # COMMIT /* xid=115 */ master-bin.000001 473 Query 1 # use `test`; delete from t2 -master-bin.000001 550 Xid 1 # COMMIT /* xid=115 */ +master-bin.000001 550 Xid 1 # COMMIT /* xid=116 */ master-bin.000001 577 Query 1 # use `test`; alter table t2 type=MyISAM master-bin.000001 666 Query 1 # use `test`; insert into t1 values (1) -master-bin.000001 754 Xid 1 # COMMIT /* xid=117 */ +master-bin.000001 754 Xid 1 # COMMIT /* xid=118 */ master-bin.000001 781 Query 1 # use `test`; insert into t2 values (20) master-bin.000001 870 Query 1 # use `test`; drop table t1,t2 master-bin.000001 949 Query 1 # use `test`; create temporary table ti (a int) engine=innodb master-bin.000001 1059 Query 1 # use `test`; insert into ti values(1) -master-bin.000001 1146 Xid 1 # COMMIT /* xid=132 */ +master-bin.000001 1146 Xid 1 # COMMIT /* xid=133 */ master-bin.000001 1173 Query 1 # use `test`; create temporary table t1 (a int) engine=myisam master-bin.000001 1283 Query 1 # use `test`; insert t1 values (1) master-bin.000001 1366 Query 1 # use `test`; create table t0 (n int) diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test index 1063940d378..1b4d43d9727 100644 --- a/mysql-test/t/binlog.test +++ b/mysql-test/t/binlog.test @@ -1,6 +1,7 @@ # # misc binlogging tests that do not require a slave running # +-- source include/have_log_bin.inc -- source include/not_embedded.inc -- source include/have_bdb.inc -- source include/have_innodb.inc diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index 4bafad2d777..af319d37dd0 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -4,6 +4,7 @@ # -- source include/not_embedded.inc -- source include/have_blackhole.inc +-- source include/have_log_bin.inc --disable_warnings drop table if exists t1,t2; diff --git a/mysql-test/t/ctype_cp932_binlog.test b/mysql-test/t/ctype_cp932_binlog.test index ee0e588fdae..1690dd13b5c 100644 --- a/mysql-test/t/ctype_cp932_binlog.test +++ b/mysql-test/t/ctype_cp932_binlog.test @@ -1,5 +1,6 @@ -- source include/not_embedded.inc -- source include/have_cp932.inc +-- source include/have_log_bin.inc --character_set cp932 --disable_warnings diff --git a/mysql-test/t/ctype_cp932_notembedded.test b/mysql-test/t/ctype_cp932_notembedded.test index 52e7acc3f01..7ae6275816e 100644 --- a/mysql-test/t/ctype_cp932_notembedded.test +++ b/mysql-test/t/ctype_cp932_notembedded.test @@ -1,5 +1,6 @@ -- source include/not_embedded.inc -- source include/have_cp932.inc +-- source include/have_log_bin.inc --character_set cp932 --disable_warnings diff --git a/mysql-test/t/ctype_ucs_binlog.test b/mysql-test/t/ctype_ucs_binlog.test index 2467d34386c..92d4458a9c2 100644 --- a/mysql-test/t/ctype_ucs_binlog.test +++ b/mysql-test/t/ctype_ucs_binlog.test @@ -1,5 +1,6 @@ --source include/not_embedded.inc --source include/have_ucs2.inc +--source include/have_log_bin.inc # # Check correct binlogging of UCS2 user variables (BUG#3875) diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test index bc06de4096c..7c83a2919b7 100644 --- a/mysql-test/t/drop_temp_table.test +++ b/mysql-test/t/drop_temp_table.test @@ -1,5 +1,6 @@ # Embedded server doesn't support binlog -- source include/not_embedded.inc +-- source include/have_log_bin.inc --disable_warnings drop database if exists `drop-temp+table-test`; diff --git a/mysql-test/t/flush_block_commit_notembedded.test b/mysql-test/t/flush_block_commit_notembedded.test index 4650a5a15a8..25eb093226e 100644 --- a/mysql-test/t/flush_block_commit_notembedded.test +++ b/mysql-test/t/flush_block_commit_notembedded.test @@ -3,6 +3,8 @@ # We verify that we did not introduce a deadlock. # This is intended to mimick how mysqldump and innobackup work. +-- source include/have_log_bin.inc + # And it requires InnoDB -- source include/not_embedded.inc -- source include/have_innodb.inc diff --git a/mysql-test/t/insert_select-binlog.test b/mysql-test/t/insert_select-binlog.test index d4041f86ab5..4bff09577a7 100644 --- a/mysql-test/t/insert_select-binlog.test +++ b/mysql-test/t/insert_select-binlog.test @@ -1,5 +1,6 @@ # Embedded server doesn't support binlog -- source include/not_embedded.inc +-- source include/have_log_bin.inc # Check if a partly-completed INSERT SELECT in a MyISAM table goes into the # binlog diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 8bced9f069c..bb7a2946592 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -4,7 +4,7 @@ # slave is always with --skip-innodb in the testsuite. I (Guilhem) however # did some tests manually on a slave; tables are replicated fine and # Exec_Master_Log_Pos advances as expected. - +-- source include/have_log_bin.inc # Embedded server doesn't support binlogging -- source include/not_embedded.inc diff --git a/mysql-test/t/mysqlbinlog-cp932.test b/mysql-test/t/mysqlbinlog-cp932.test index 1487606a6c2..1c9f91fd9a8 100644 --- a/mysql-test/t/mysqlbinlog-cp932.test +++ b/mysql-test/t/mysqlbinlog-cp932.test @@ -1,6 +1,7 @@ # disabled in embedded until tools running is fixed with embedded ---source include/not_embedded.inc +-- source include/not_embedded.inc -- source include/have_cp932.inc +-- source include/have_log_bin.inc # Bug#16217 (mysql client did not know how not switch its internal charset) flush logs; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index a7b3f413f23..cb1dad2bc85 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -1,5 +1,7 @@ # We are using .opt file since we need small binlog size +-- source include/have_log_bin.inc + # Embedded server doesn't support binlogging -- source include/not_embedded.inc diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 14b213cd9cc..6f9045b429b 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -1,6 +1,8 @@ # Test for the new options --start-datetime, stop-datetime, # and a few others. +-- source include/have_log_bin.inc + # Embedded server doesn't support binlogging -- source include/not_embedded.inc diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 328206626df..ebbc80890ab 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1,3 +1,5 @@ +-- source include/have_log_bin.inc + # This test should work in embedded server after mysqltest is fixed -- source include/not_embedded.inc diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index d9b34c303ae..dc6adcaf6fd 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -2,6 +2,7 @@ # tests that require InnoDB... # +-- source include/have_log_bin.inc -- source include/have_innodb.inc --disable_warnings diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index 12a5e616fa2..2b7f880d7fa 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -1,5 +1,6 @@ # Embedded server does not support binlogging --source include/not_embedded.inc +--source include/have_log_bin.inc # Check that user variables are binlogged correctly (BUG#3875) create table t1 (a varchar(50)); From 5d566e2d5126ce34c0c0acebe4249c72d7602a83 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 10:07:35 +0200 Subject: [PATCH 038/156] test case ps requires binlog for now mysql-test/t/ps.test: test requires binlog for now --- mysql-test/t/ps.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 1fd1cc4a405..db401de26bb 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1,4 +1,5 @@ -- source include/not_embedded.inc +-- source include/have_log_bin.inc # # SQL Syntax for Prepared Statements test # From 7a6b827cd2e3dae954f473788040fb018d2c1124 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 10:21:19 +0200 Subject: [PATCH 039/156] after-merge fixes: test cases that were moved to extra/binlog_tests do not need to check for binlog being enabled mysql-test/extra/binlog_tests/blackhole.test: after-merge fix, not needed in 5.1 mysql-test/extra/binlog_tests/ctype_cp932_binlog.test: after-merge fix, not needed in 5.1 mysql-test/extra/binlog_tests/ctype_ucs_binlog.test: after-merge fix, not needed in 5.1 mysql-test/extra/binlog_tests/drop_temp_table.test: after-merge fix, not needed in 5.1 mysql-test/extra/binlog_tests/insert_select-binlog.test: after-merge fix, not needed in 5.1 mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: after-merge fix, not needed in 5.1 --- mysql-test/extra/binlog_tests/blackhole.test | 1 - mysql-test/extra/binlog_tests/ctype_cp932_binlog.test | 1 - mysql-test/extra/binlog_tests/ctype_ucs_binlog.test | 1 - mysql-test/extra/binlog_tests/drop_temp_table.test | 1 - mysql-test/extra/binlog_tests/insert_select-binlog.test | 1 - mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test | 2 +- 6 files changed, 1 insertion(+), 6 deletions(-) diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test index fead7d270b0..9f842a9a4eb 100644 --- a/mysql-test/extra/binlog_tests/blackhole.test +++ b/mysql-test/extra/binlog_tests/blackhole.test @@ -4,7 +4,6 @@ # -- source include/not_embedded.inc -- source include/have_blackhole.inc --- source include/have_log_bin.inc --disable_warnings drop table if exists t1,t2; diff --git a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test index 5c172afd122..30585ece71c 100644 --- a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test @@ -1,6 +1,5 @@ -- source include/not_embedded.inc -- source include/have_cp932.inc --- source include/have_log_bin.inc --character_set cp932 --disable_warnings diff --git a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test index fa374502997..e1a9dba7775 100644 --- a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test @@ -1,6 +1,5 @@ --source include/not_embedded.inc --source include/have_ucs2.inc ---source include/have_log_bin.inc # # Check correct binlogging of UCS2 user variables (BUG#3875) diff --git a/mysql-test/extra/binlog_tests/drop_temp_table.test b/mysql-test/extra/binlog_tests/drop_temp_table.test index b674baca38b..87f94eff987 100644 --- a/mysql-test/extra/binlog_tests/drop_temp_table.test +++ b/mysql-test/extra/binlog_tests/drop_temp_table.test @@ -1,6 +1,5 @@ # Embedded server doesn't support binlog -- source include/not_embedded.inc --- source include/have_log_bin.inc --disable_warnings drop database if exists `drop-temp+table-test`; diff --git a/mysql-test/extra/binlog_tests/insert_select-binlog.test b/mysql-test/extra/binlog_tests/insert_select-binlog.test index b7846e3766d..b09eebcb996 100644 --- a/mysql-test/extra/binlog_tests/insert_select-binlog.test +++ b/mysql-test/extra/binlog_tests/insert_select-binlog.test @@ -1,6 +1,5 @@ # Embedded server doesn't support binlog -- source include/not_embedded.inc --- source include/have_log_bin.inc --disable_warnings drop table if exists t1,t2; diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test index fb1b78b43e9..d6ccc403ce9 100644 --- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test @@ -4,7 +4,7 @@ # slave is always with --skip-innodb in the testsuite. I (Guilhem) however # did some tests manually on a slave; tables are replicated fine and # Exec_Master_Log_Pos advances as expected. --- source include/have_log_bin.inc + # Embedded server doesn't support binlogging -- source include/not_embedded.inc From 0c138881c7ba4b8353d02c09e20f0d52521058c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 12:21:55 +0200 Subject: [PATCH 040/156] fix test case broken for ps-protocol by previous push mysql-test/t/mix_innodb_myisam_binlog.test: have_log_bin.inc increases transaction count by one, modify ps-protocol substitutions accordingly --- mysql-test/t/mix_innodb_myisam_binlog.test | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index bb7a2946592..53de4d11b81 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -29,7 +29,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=14" "xid=8" +--replace_result "xid=15" "xid=9" show binlog events from 98; delete from t1; @@ -58,7 +58,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=47" "xid=25" +--replace_result "xid=48" "xid=26" show binlog events from 98; delete from t1; @@ -76,7 +76,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=69" "xid=37" +--replace_result "xid=70" "xid=38" show binlog events from 98; # and when ROLLBACK is not explicit? @@ -109,7 +109,7 @@ insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=117" "xid=60" +--replace_result "xid=118" "xid=61" show binlog events from 98; # Check that when the query updat1ng the MyISAM table is the first in the @@ -122,13 +122,13 @@ insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=131" "xid=66" +--replace_result "xid=132" "xid=67" show binlog events from 98; insert into t1 values(11); commit; --replace_column 5 # ---replace_result "xid=131" "xid=66" "xid=134" "xid=68" +--replace_result "xid=132" "xid=67" "xid=135" "xid=69" show binlog events from 98; @@ -147,7 +147,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=153" "xid=78" +--replace_result "xid=154" "xid=79" show binlog events from 98; delete from t1; @@ -175,7 +175,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=185" "xid=94" +--replace_result "xid=186" "xid=95" show binlog events from 98; delete from t1; @@ -193,7 +193,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=206" "xid=105" +--replace_result "xid=207" "xid=106" show binlog events from 98; # Test for BUG#5714, where a MyISAM update in the transaction used to @@ -254,7 +254,7 @@ disconnect con2; connection con3; select get_lock("lock1",60); --replace_column 5 # ---replace_result "xid=206" "xid=105" "xid=224" "xid=114" "xid=227" "xid=115" "xid=231" "xid=117" "xid=258" "xid=132" +--replace_result "xid=207" "xid=106" "xid=225" "xid=115" "xid=228" "xid=116" "xid=232" "xid=118" "xid=259" "xid=133" show binlog events from 98; do release_lock("lock1"); drop table t0,t2; From 0655cf10241cfa31d90e9f3fda0d3648510646e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 13:53:44 +0200 Subject: [PATCH 041/156] fixed not matching if/endif (cmake) CMakeLists.txt: Fixed not matching if/endif (cmake) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 890ee2676e8..54df0befad9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ IF(EMBED_MANIFESTS) STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS}) IF(NOT tmp_manifest) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") - ENDIF(tmp_manifest) + ENDIF(NOT tmp_manifest) # Set the processor architecture. IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") SET(PROCESSOR_ARCH "X64") From b21a0587bb4873fb25f2cb02b925acba60e44595 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 14:05:07 +0200 Subject: [PATCH 042/156] fix test case mysql-test/r/binlog.result: transaction ids increased by one due to have_log_bin.inc mysql-test/t/binlog.test: transaction ids for ps-protocol increased by one due to have_log_bin.inc --- mysql-test/r/binlog.result | 4 ++-- mysql-test/t/binlog.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result index 25930c31735..4ed6c50c7f6 100644 --- a/mysql-test/r/binlog.result +++ b/mysql-test/r/binlog.result @@ -17,7 +17,7 @@ master-bin.000001 # Query 1 # use `test`; insert t1 values (5) master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert t2 values (5) -master-bin.000001 # Xid 1 # COMMIT /* xid=12 */ +master-bin.000001 # Xid 1 # COMMIT /* xid=13 */ drop table t1,t2; reset master; create table t1 (n int) engine=innodb; @@ -128,7 +128,7 @@ master-bin.000001 # Query 1 # use `test`; insert into t1 values(4 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(3 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(2 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(1 + 4) -master-bin.000001 # Xid 1 # COMMIT /* xid=19 */ +master-bin.000001 # Xid 1 # COMMIT /* xid=20 */ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002' from 98; Log_name Pos Event_type Server_id End_log_pos Info diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test index 1b4d43d9727..3bc6c6953ed 100644 --- a/mysql-test/t/binlog.test +++ b/mysql-test/t/binlog.test @@ -20,7 +20,7 @@ begin; insert t2 values (5); commit; # first COMMIT must be Query_log_event, second - Xid_log_event ---replace_result "xid=21" "xid=12" +--replace_result "xid=22" "xid=13" --replace_column 2 # 5 # show binlog events from 98; drop table t1,t2; @@ -42,7 +42,7 @@ while ($1) --enable_query_log commit; drop table t1; ---replace_result "xid=32" "xid=19" +--replace_result "xid=33" "xid=20" --replace_column 2 # 5 # show binlog events in 'master-bin.000001' from 98; --replace_column 2 # 5 # From 09f500e84d3608aa24f0281bab1b607664bca902 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 14:11:58 +0200 Subject: [PATCH 043/156] Fix CMakeLists.txt. CMakeLists.txt: Fix. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb5e53be20e..8b1268e0699 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,7 @@ IF(EMBED_MANIFESTS) STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS}) IF(NOT tmp_manifest) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") - ENDIF(tmp_manifest) + ENDIF(NOT tmp_manifest) # Set the processor architecture. IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") SET(PROCESSOR_ARCH "X64") From 489a3fe4ee6b8243d026197f8f74a1e3aa30a4d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 20:04:54 +0200 Subject: [PATCH 044/156] Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables Setting a key_cache_block_size which is not a power of 2 could corrupt MyISAM tables. A couple of computations in the key cache code use bit operations which do only work if key_cache_block_size is a power of 2. Replaced bit operations by arithmetic operations to make key cache able to handle block sizes that are not a power of 2. include/keycache.h: Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables Removed element 'key_cache_shift' from KEY_CACHE after the changes in mf_keycache.c made it unused. mysql-test/r/key_cache.result: Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables Added test result mysql-test/t/key_cache.test: Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables Added test mysys/mf_keycache.c: Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables Replaced bit operations by arithmetic operations to make key cache able to handle block sizes that are not a power of 2. --- include/keycache.h | 1 - mysql-test/r/key_cache.result | 27 +++++++++++++++++++++++++++ mysql-test/t/key_cache.test | 27 +++++++++++++++++++++++++++ mysys/mf_keycache.c | 11 +++++------ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/include/keycache.h b/include/keycache.h index dc763b8cc08..54c099fc474 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -46,7 +46,6 @@ typedef struct st_key_cache my_bool key_cache_inited; my_bool resize_in_flush; /* true during flush of resize operation */ my_bool can_be_used; /* usage of cache for read/write is allowed */ - uint key_cache_shift; ulong key_cache_mem_size; /* specified size of the cache memory */ uint key_cache_block_size; /* size of the page buffer of a cache block */ ulong min_warm_blocks; /* min number of warm blocks; */ diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index a1bf3d0e128..1ab58c1ad6c 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -341,3 +341,30 @@ Warning 1438 Cannot drop default keycache select @@global.key_buffer_size; @@global.key_buffer_size 2097152 +SET @bug28478_key_cache_block_size= @@global.key_cache_block_size; +SET GLOBAL key_cache_block_size= 1536; +CREATE TABLE t1 ( +id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, +c1 CHAR(150), +c2 CHAR(150), +c3 CHAR(150), +KEY(c1, c2, c3) +) ENGINE= MyISAM; +INSERT INTO t1 (c1, c2, c3) VALUES +('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f'), +('e', 'f', 'g'), ('f', 'g', 'h'), ('g', 'h', 'i'), ('h', 'i', 'j'), +('i', 'j', 'k'), ('j', 'k', 'l'), ('k', 'l', 'm'), ('l', 'm', 'n'), +('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'), +('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'), +('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z'); +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW VARIABLES LIKE 'key_cache_block_size'; +Variable_name Value +key_cache_block_size 1536 +SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; +DROP TABLE t1; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 3044964ebc3..4c14dc96aaa 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -219,4 +219,31 @@ set global key_cache_block_size= @my_key_cache_block_size; set @@global.key_buffer_size=0; select @@global.key_buffer_size; +# +# Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables +# +SET @bug28478_key_cache_block_size= @@global.key_cache_block_size; +SET GLOBAL key_cache_block_size= 1536; +CREATE TABLE t1 ( + id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + c1 CHAR(150), + c2 CHAR(150), + c3 CHAR(150), + KEY(c1, c2, c3) + ) ENGINE= MyISAM; +INSERT INTO t1 (c1, c2, c3) VALUES + ('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f'), + ('e', 'f', 'g'), ('f', 'g', 'h'), ('g', 'h', 'i'), ('h', 'i', 'j'), + ('i', 'j', 'k'), ('j', 'k', 'l'), ('k', 'l', 'm'), ('l', 'm', 'n'), + ('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'), + ('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'), + ('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z'); +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1; +CHECK TABLE t1; +SHOW VARIABLES LIKE 'key_cache_block_size'; +SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; +DROP TABLE t1; + # End of 4.1 tests diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 87f136dbf81..af910678a1f 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -173,7 +173,7 @@ static void test_key_cache(KEY_CACHE *keycache, #endif #define KEYCACHE_HASH(f, pos) \ -(((ulong) ((pos) >> keycache->key_cache_shift)+ \ +(((ulong) ((pos) / keycache->key_cache_block_size) + \ (ulong) (f)) & (keycache->hash_entries-1)) #define FILE_HASH(f) ((uint) (f) & (CHANGED_BLOCKS_HASH-1)) @@ -329,7 +329,6 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->key_cache_mem_size= use_mem; keycache->key_cache_block_size= key_cache_block_size; - keycache->key_cache_shift= my_bit_log2(key_cache_block_size); DBUG_PRINT("info", ("key_cache_block_size: %u", key_cache_block_size)); @@ -352,7 +351,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + ALIGN_SIZE(sizeof(HASH_LINK*) * keycache->hash_entries))) + - ((ulong) blocks << keycache->key_cache_shift) > use_mem) + ((ulong) blocks * keycache->key_cache_block_size) > use_mem) blocks--; /* Allocate memory for cache page buffers */ if ((keycache->block_mem= @@ -1807,7 +1806,7 @@ byte *key_cache_read(KEY_CACHE *keycache, uint status; int page_st; - offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + offset= (uint) (filepos % keycache->key_cache_block_size); /* Read data in key_cache_block_size increments */ do { @@ -1946,7 +1945,7 @@ int key_cache_insert(KEY_CACHE *keycache, int error; uint offset; - offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + offset= (uint) (filepos % keycache->key_cache_block_size); do { keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -2081,7 +2080,7 @@ int key_cache_write(KEY_CACHE *keycache, int page_st; uint offset; - offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + offset= (uint) (filepos % keycache->key_cache_block_size); do { keycache_pthread_mutex_lock(&keycache->cache_lock); From 92f59fc73d09c7b8d304ab61ab9463c556bdca5f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 May 2007 22:07:44 +0200 Subject: [PATCH 045/156] post-merge fix --- sql/sql_plugin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2c5fb75e575..c0161463550 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -307,7 +307,7 @@ static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl) DBUG_RETURN(0); tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1, struct st_plugin_dl **)= - (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (gptr)plugin_dl, + (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (uchar*)plugin_dl, sizeof(struct st_plugin_dl)); DBUG_RETURN(tmp); } @@ -683,7 +683,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) DBUG_RETURN(0); tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1, struct st_plugin_int **)= - (struct st_plugin_int *) memdup_root(&plugin_mem_root, (gptr)plugin, + (struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)plugin, sizeof(struct st_plugin_int)); DBUG_RETURN(tmp); } @@ -1244,7 +1244,7 @@ static bool register_builtin(struct st_mysql_plugin *plugin, *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1, struct st_plugin_int **)= - (struct st_plugin_int *) memdup_root(&plugin_mem_root, (gptr)tmp, + (struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp, sizeof(struct st_plugin_int)); if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr)) From 93b101243d4c3155dc0f8a15dadcaef20a169345 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 13:50:13 +0500 Subject: [PATCH 046/156] BUG#28574 - repair table causes queries to fail with various corruption errors: 126,134,145 When one thread attempts to lock two (or more) tables and another thread executes statement that aborts these locks (e.g. REPAIR TABLE) we may get a table object with wrong lock type in a table cache. For example if SELECT FROM t1,t2 was aborted, subsequent INSERT INTO t1 may be executed under read lock. As a result we may get various table corruptions and even a server crash. This is fixed by resetting lock type in case lock was aborted by another thread. I failed to create reasonable test case for this bug. sql/lock.cc: If thr_multi_lock was aborted by another thread, it unlocks tables that were locked before one that was aborted. Lock type for tables that were after a table that was aborted preserved. Thus we need to reset lock data in case thr_multi_lock was aborted. --- sql/lock.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sql/lock.cc b/sql/lock.cc index 3b2b2857f65..92c34f84b97 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -155,6 +155,13 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags) if (thr_multi_lock(sql_lock->locks + sql_lock->lock_count, sql_lock->lock_count)) { + /* + reset_lock_data is required here. If thr_multi_lock fails it + resets lock type for tables, which were locked before (and + including) one that caused error. Lock type for other tables + preserved. + */ + reset_lock_data(sql_lock); thd->some_tables_deleted=1; // Try again sql_lock->lock_count=0; // Locks are alread freed } From e42439af33698293a26f18dcf50a275ad19d76c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 19:44:09 +0500 Subject: [PATCH 047/156] Bug #28477 innodb assertion and crash during alter table to add/drop partition. The bug was repeated on MyISAM tables, so isn't InnoDB specific. Reason of the bug is that partition-related members of TABLE_SHARE wasn't properly updated after ALTER command. So if other thread doesn't reread frm file, and just uses cached SHARE, it uses wrong data sql/sql_table.cc: Bug #28477 innodb assertion and crash during alter table to add/drop partition. keep share members updated after table modification sql/table.cc: Bug #28477 innodb assertion and crash during alter table to add/drop partition. share->partition_info_buffer_size initialization added sql/table.h: Bug #28477 innodb assertion and crash during alter table to add/drop partition. partition_info_buffer_size declared in st_table_share to store the size of the memory available for partition_info --- sql/sql_table.cc | 12 +++++++++++- sql/table.cc | 3 ++- sql/table.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9c0552df94e..2a31f0cb2df 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1329,6 +1329,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) if (part_info) { + TABLE_SHARE *share= lpt->table->s; if (!(part_syntax_buf= generate_partition_syntax(part_info, &syntax_len, TRUE, TRUE))) @@ -1336,7 +1337,16 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) DBUG_RETURN(TRUE); } part_info->part_info_string= part_syntax_buf; - part_info->part_info_len= syntax_len; + share->partition_info_len= part_info->part_info_len= syntax_len; + if (share->partition_info_buffer_size < syntax_len + 1) + { + share->partition_info_buffer_size= syntax_len+1; + if (!(share->partition_info= + alloc_root(&share->mem_root, syntax_len+1))) + DBUG_RETURN(TRUE); + + } + memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1); } } #endif diff --git a/sql/table.cc b/sql/table.cc index 8eb01f06302..7b916455ddb 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -720,7 +720,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { uint32 partition_info_len = uint4korr(next_chunk); #ifdef WITH_PARTITION_STORAGE_ENGINE - if ((share->partition_info_len= partition_info_len)) + if ((share->partition_info_buffer_size= + share->partition_info_len= partition_info_len)) { if (!(share->partition_info= memdup_root(&share->mem_root, next_chunk + 4, diff --git a/sql/table.h b/sql/table.h index 99fbf57bb52..6aa9eb8e3c6 100644 --- a/sql/table.h +++ b/sql/table.h @@ -243,6 +243,7 @@ typedef struct st_table_share bool auto_partitioned; const char *partition_info; uint partition_info_len; + uint partition_info_buffer_size; const char *part_state; uint part_state_len; handlerton *default_part_db_type; From 7d5f53e450c616f2654c6eef1d03b7ded4f98da5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 17:43:48 +0200 Subject: [PATCH 048/156] Avoid a compile error which arises from a redefinition of "inline": If it has been defined (by "configure", in "include/my_config.h"), then an "#undef" is needed to avoid a redefinition. This is needed to prevent a compile error of the debug server on AIX. mysys/mf_keycache.c: It may happen, that "include/my_config.h" already contains a #define inline ... as created by "configure" (this happens on AIX). In this case, an "#undef" is needed to avoid a compile error. --- mysys/mf_keycache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 4c98882ac7e..473aabe0c01 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -325,6 +325,9 @@ static int keycache_pthread_cond_signal(pthread_cond_t *cond); #endif /* defined(KEYCACHE_DEBUG) */ #if !defined(DBUG_OFF) +#if defined(inline) +#undef inline +#endif #define inline /* disabled inline for easier debugging */ static int fail_block(BLOCK_LINK *block); static int fail_hlink(HASH_LINK *hlink); From 15bb76f2d85725707f05624a2b818388b4da7cd2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 21:04:26 +0200 Subject: [PATCH 049/156] Exclude the "row_lock" test suite from a source tarball ("make dist") and, as a consequence, from binary packages. This is necessary because of entry 28685 in the bugs DB. --- mysql-test/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 1e9371e5bf2..774008bc106 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -71,7 +71,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(distdir)/std_data/ndb_backup50 $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(distdir)/std_data/ndb_backup51 $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib - -rm -rf `find $(distdir)/suite -type d -name SCCS` + -rm -rf `find $(distdir)/suite -type d -name SCCS` $(distdir)/suite/row_lock install-data-local: $(mkinstalldirs) \ @@ -113,7 +113,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup50 $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51 $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib - for f in `(cd $(srcdir); find suite -type f | grep -v SCCS)`; \ + for f in `(cd $(srcdir); find suite -type f | egrep -v 'SCCS|row_lock')`; \ do \ d=$(DESTDIR)$(testdir)/`dirname $$f`; \ mkdir -p $$d ; \ From 1a166bc4c98282acc24e4cf708511d9f412644ce Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Jun 2007 19:30:37 +0200 Subject: [PATCH 050/156] Bug#20612. storage/ndb/src/kernel/blocks/pgman.cpp: a) in one case pl_queue.remove(ptr) was not followed by state &= ~ Page_entry::ONQUEUE. b) when collecting initial hot entries have to remove from queue if somehow got there. b) is easy to get with large buffer cache (256M). a) or b) is probably cause of bug#20612. --- storage/ndb/src/kernel/blocks/pgman.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp index 72333856cf1..78bc70427a9 100644 --- a/storage/ndb/src/kernel/blocks/pgman.cpp +++ b/storage/ndb/src/kernel/blocks/pgman.cpp @@ -669,6 +669,7 @@ Pgman::lirs_reference(Ptr ptr) jam(); move_cleanup_ptr(ptr); pl_queue.remove(ptr); + state &= ~ Page_entry::ONQUEUE; } if (state & Page_entry::BOUND) { @@ -699,6 +700,12 @@ Pgman::lirs_reference(Ptr ptr) pl_stack.add(ptr); state |= Page_entry::ONSTACK; state |= Page_entry::HOT; + // it could be on queue already + if (state & Page_entry::ONQUEUE) { + jam(); + pl_queue.remove(ptr); + state &= ~Page_entry::ONQUEUE; + } } set_page_state(ptr, state); From c8e0d0dbd54652c8eb3fd652228ee9ef86dc038a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 10:27:10 +0200 Subject: [PATCH 051/156] ndb - make size of redo log files (fragment log files) configurable using new config variable FragmentLogFileSize (4M - 1G) mysql-test/ndb/ndb_config_1_node.ini: change log file size (test) mysql-test/ndb/ndb_config_2_node.ini: change log file size (test) storage/ndb/include/mgmapi/mgmapi_config_parameters.h: add new confif parameter storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp: make logfile size configurable storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: make logfile size configurable storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: make logfile size configurable storage/ndb/src/mgmsrv/ConfigInfo.cpp: add new config variable storage/ndb/src/ndbapi/ndberror.c: update error message --- mysql-test/ndb/ndb_config_1_node.ini | 3 +- mysql-test/ndb/ndb_config_2_node.ini | 3 +- .../include/mgmapi/mgmapi_config_parameters.h | 1 + storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 13 +- .../ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 3 + .../ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 282 +++++++++++------- storage/ndb/src/mgmsrv/ConfigInfo.cpp | 12 + storage/ndb/src/ndbapi/ndberror.c | 2 +- 8 files changed, 195 insertions(+), 124 deletions(-) diff --git a/mysql-test/ndb/ndb_config_1_node.ini b/mysql-test/ndb/ndb_config_1_node.ini index 39e758493c8..24f6c904737 100644 --- a/mysql-test/ndb/ndb_config_1_node.ini +++ b/mysql-test/ndb/ndb_config_1_node.ini @@ -10,7 +10,8 @@ DataDir= CHOOSE_FILESYSTEM MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes TimeBetweenGlobalCheckpoints= 500 -NoOfFragmentLogFiles= 3 +NoOfFragmentLogFiles= 8 +FragmentLogFileSize= 6M DiskPageBufferMemory= CHOOSE_DiskPageBufferMemory # diff --git a/mysql-test/ndb/ndb_config_2_node.ini b/mysql-test/ndb/ndb_config_2_node.ini index 99f31150d8c..302998bc79e 100644 --- a/mysql-test/ndb/ndb_config_2_node.ini +++ b/mysql-test/ndb/ndb_config_2_node.ini @@ -10,7 +10,8 @@ DataDir= CHOOSE_FILESYSTEM MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes TimeBetweenGlobalCheckpoints= 500 -NoOfFragmentLogFiles= 3 +NoOfFragmentLogFiles= 4 +FragmentLogFileSize=12M DiskPageBufferMemory= CHOOSE_DiskPageBufferMemory # the following parametes just function as a small regression # test that the parameter exists diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index 119958d0ce0..ed34a372db6 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -64,6 +64,7 @@ #define CFG_DB_FILESYSTEM_PATH 125 #define CFG_DB_NO_REDOLOG_FILES 126 +#define CFG_DB_REDOLOG_FILE_SIZE 140 #define CFG_DB_LCP_DISC_PAGES_TUP 127 #define CFG_DB_LCP_DISC_PAGES_TUP_SR 128 diff --git a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 0f88933f617..18fc7417623 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -71,7 +71,6 @@ class Dbtup; /* CONSTANTS OF THE LOG PAGES */ /* ------------------------------------------------------------------------- */ #define ZPAGE_HEADER_SIZE 32 -#define ZNO_MBYTES_IN_FILE 16 #define ZPAGE_SIZE 8192 #define ZPAGES_IN_MBYTE 32 #define ZTWOLOG_NO_PAGES_IN_MBYTE 5 @@ -142,7 +141,7 @@ class Dbtup; /* IN THE MBYTE. */ /* ------------------------------------------------------------------------- */ #define ZFD_HEADER_SIZE 3 -#define ZFD_PART_SIZE 48 +#define ZFD_MBYTE_SIZE 3 #define ZLOG_HEAD_SIZE 8 #define ZNEXT_LOG_SIZE 2 #define ZABORT_LOG_SIZE 3 @@ -169,7 +168,6 @@ class Dbtup; #define ZPOS_LOG_TYPE 0 #define ZPOS_NO_FD 1 #define ZPOS_FILE_NO 2 -#define ZMAX_LOG_FILES_IN_PAGE_ZERO 40 /* ------------------------------------------------------------------------- */ /* THE POSITIONS WITHIN A PREPARE LOG RECORD AND A NEW PREPARE */ /* LOG RECORD. */ @@ -1436,17 +1434,17 @@ public: * header of each log file. That information is used during * system restart to find the tail of the log. */ - UintR logLastPrepRef[16]; + UintR *logLastPrepRef; /** * The max global checkpoint completed before the mbyte in the * log file was started. One variable per mbyte. */ - UintR logMaxGciCompleted[16]; + UintR *logMaxGciCompleted; /** * The max global checkpoint started before the mbyte in the log * file was started. One variable per mbyte. */ - UintR logMaxGciStarted[16]; + UintR *logMaxGciStarted; /** * This variable contains the file name as needed by the file * system when opening the file. @@ -2162,6 +2160,7 @@ private: void execSTART_RECREF(Signal* signal); void execGCP_SAVEREQ(Signal* signal); + void execFSOPENREF(Signal* signal); void execFSOPENCONF(Signal* signal); void execFSCLOSECONF(Signal* signal); void execFSWRITECONF(Signal* signal); @@ -2671,6 +2670,8 @@ private: LogPartRecord *logPartRecord; LogPartRecordPtr logPartPtr; UintR clogPartFileSize; + Uint32 clogFileSize; // In MBYTE + Uint32 cmaxLogFilesInPageZero; // // Configurable LogFileRecord *logFileRecord; diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 8aaf86de73a..05ea2047fc0 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -60,6 +60,8 @@ void Dblqh::initData() cLqhTimeOutCheckCount = 0; cbookedAccOps = 0; m_backup_ptr = RNIL; + clogFileSize = 16; + cmaxLogFilesInPageZero = 40; }//Dblqh::initData() void Dblqh::initRecords() @@ -260,6 +262,7 @@ Dblqh::Dblqh(Block_context& ctx): addRecSignal(GSN_START_FRAGREQ, &Dblqh::execSTART_FRAGREQ); addRecSignal(GSN_START_RECREF, &Dblqh::execSTART_RECREF); addRecSignal(GSN_GCP_SAVEREQ, &Dblqh::execGCP_SAVEREQ); + addRecSignal(GSN_FSOPENREF, &Dblqh::execFSOPENREF, true); addRecSignal(GSN_FSOPENCONF, &Dblqh::execFSOPENCONF); addRecSignal(GSN_FSCLOSECONF, &Dblqh::execFSCLOSECONF); addRecSignal(GSN_FSWRITECONF, &Dblqh::execFSWRITECONF); diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 33696ebba27..4a7d38c293c 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -62,6 +62,7 @@ #include #include #include +#include // Use DEBUG to print messages that should be // seen only when we debug the product @@ -1020,9 +1021,37 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_FRAG, &tmp)); c_fragment_pool.setSize(tmp); + if (!ndb_mgm_get_int_parameter(p, CFG_DB_REDOLOG_FILE_SIZE, + &clogFileSize)) + { + // convert to mbyte + clogFileSize = (clogFileSize + 1024*1024 - 1) / (1024 * 1024); + ndbrequire(clogFileSize >= 4 && clogFileSize <= 1024); + } + + cmaxLogFilesInPageZero = (ZPAGE_SIZE - ZPAGE_HEADER_SIZE - 128) / + (ZFD_MBYTE_SIZE * clogFileSize); + + /** + * "Old" cmaxLogFilesInPageZero was 40 + * Each FD need 3 words per mb, require that they can fit into 1 page + * (atleast 1 FD) + * Is also checked in ConfigInfo.cpp (max FragmentLogFileSize = 1Gb) + * 1Gb = 1024Mb => 3(ZFD_MBYTE_SIZE) * 1024 < 8192 (ZPAGE_SIZE) + */ + if (cmaxLogFilesInPageZero > 40) + { + jam(); + cmaxLogFilesInPageZero = 40; + } + else + { + ndbrequire(cmaxLogFilesInPageZero); + } + initRecords(); initialiseRecordsLab(signal, 0, ref, senderData); - + return; }//Dblqh::execSIZEALT_REP() @@ -11750,9 +11779,9 @@ void Dblqh::sendStartLcp(Signal* signal) Uint32 Dblqh::remainingLogSize(const LogFileRecordPtr &sltCurrLogFilePtr, const LogPartRecordPtr &sltLogPartPtr) { - Uint32 hf = sltCurrLogFilePtr.p->fileNo*ZNO_MBYTES_IN_FILE+sltCurrLogFilePtr.p->currentMbyte; - Uint32 tf = sltLogPartPtr.p->logTailFileNo*ZNO_MBYTES_IN_FILE+sltLogPartPtr.p->logTailMbyte; - Uint32 sz = sltLogPartPtr.p->noLogFiles*ZNO_MBYTES_IN_FILE; + Uint32 hf = sltCurrLogFilePtr.p->fileNo*clogFileSize+sltCurrLogFilePtr.p->currentMbyte; + Uint32 tf = sltLogPartPtr.p->logTailFileNo*clogFileSize+sltLogPartPtr.p->logTailMbyte; + Uint32 sz = sltLogPartPtr.p->noLogFiles*clogFileSize; if (tf > hf) hf += sz; return sz-(hf-tf); } @@ -11810,7 +11839,7 @@ void Dblqh::setLogTail(Signal* signal, Uint32 keepGci) /* ------------------------------------------------------------------------- */ SLT_LOOP: for (tsltIndex = tsltStartMbyte; - tsltIndex <= ZNO_MBYTES_IN_FILE - 1; + tsltIndex <= clogFileSize - 1; tsltIndex++) { if (sltLogFilePtr.p->logMaxGciStarted[tsltIndex] >= keepGci) { /* ------------------------------------------------------------------------- */ @@ -11826,7 +11855,7 @@ void Dblqh::setLogTail(Signal* signal, Uint32 keepGci) /* ------------------------------------------------------------------------- */ /*STEPPING BACK INCLUDES ALSO STEPPING BACK TO THE PREVIOUS LOG FILE. */ /* ------------------------------------------------------------------------- */ - tsltMbyte = ZNO_MBYTES_IN_FILE - 1; + tsltMbyte = clogFileSize - 1; sltLogFilePtr.i = sltLogFilePtr.p->prevLogFile; ptrCheckGuard(sltLogFilePtr, clogFileFileSize, logFileRecord); }//if @@ -11864,7 +11893,7 @@ void Dblqh::setLogTail(Signal* signal, Uint32 keepGci) UintR ToldTailFileNo = sltLogPartPtr.p->logTailFileNo; UintR ToldTailMByte = sltLogPartPtr.p->logTailMbyte; - arrGuard(tsltMbyte, 16); + arrGuard(tsltMbyte, clogFileSize); sltLogPartPtr.p->logTailFileNo = sltLogFilePtr.p->logLastPrepRef[tsltMbyte] >> 16; /* ------------------------------------------------------------------------- */ @@ -12364,6 +12393,26 @@ void Dblqh::execFSOPENCONF(Signal* signal) }//switch }//Dblqh::execFSOPENCONF() +void +Dblqh::execFSOPENREF(Signal* signal) +{ + jamEntry(); + FsRef* ref = (FsRef*)signal->getDataPtr(); + Uint32 err = ref->errorCode; + if (err == FsRef::fsErrInvalidFileSize) + { + char buf[256]; + BaseString::snprintf(buf, sizeof(buf), + "Invalid file size for redo logfile, " + " size only changable with --initial"); + progError(__LINE__, + NDBD_EXIT_INVALID_CONFIG, + buf); + return; + } + + SimulatedBlock::execFSOPENREF(signal); +} /* ************>> */ /* FSREADCONF > */ @@ -13009,7 +13058,7 @@ void Dblqh::openFileInitLab(Signal* signal) { logFilePtr.p->logFileStatus = LogFileRecord::OPEN_INIT; seizeLogpage(signal); - writeSinglePage(signal, (ZNO_MBYTES_IN_FILE * ZPAGES_IN_MBYTE) - 1, + writeSinglePage(signal, (clogFileSize * ZPAGES_IN_MBYTE) - 1, ZPAGE_SIZE - 1, __LINE__); lfoPtr.p->lfoState = LogFileOperationRecord::INIT_WRITE_AT_END; return; @@ -13072,7 +13121,7 @@ void Dblqh::writeInitMbyteLab(Signal* signal) { releaseLfo(signal); logFilePtr.p->currentMbyte = logFilePtr.p->currentMbyte + 1; - if (logFilePtr.p->currentMbyte == ZNO_MBYTES_IN_FILE) { + if (logFilePtr.p->currentMbyte == clogFileSize) { jam(); releaseLogpage(signal); logFilePtr.p->logFileStatus = LogFileRecord::CLOSING_INIT; @@ -13192,7 +13241,7 @@ void Dblqh::initLogfile(Signal* signal, Uint32 fileNo) logFilePtr.p->lastPageWritten = 0; logFilePtr.p->logPageZero = RNIL; logFilePtr.p->currentMbyte = 0; - for (tilIndex = 0; tilIndex <= 15; tilIndex++) { + for (tilIndex = 0; tilIndex < clogFileSize; tilIndex++) { logFilePtr.p->logMaxGciCompleted[tilIndex] = (UintR)-1; logFilePtr.p->logMaxGciStarted[tilIndex] = (UintR)-1; logFilePtr.p->logLastPrepRef[tilIndex] = 0; @@ -13243,8 +13292,12 @@ void Dblqh::openFileRw(Signal* signal, LogFileRecordPtr olfLogFilePtr) signal->theData[3] = olfLogFilePtr.p->fileName[1]; signal->theData[4] = olfLogFilePtr.p->fileName[2]; signal->theData[5] = olfLogFilePtr.p->fileName[3]; - signal->theData[6] = ZOPEN_READ_WRITE | FsOpenReq::OM_AUTOSYNC; + signal->theData[6] = ZOPEN_READ_WRITE | FsOpenReq::OM_AUTOSYNC | FsOpenReq::OM_CHECK_SIZE; req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord); + Uint64 sz = clogFileSize; + sz *= 1024; sz *= 1024; + req->file_size_hi = sz >> 32; + req->file_size_lo = sz & 0xFFFFFFFF; sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA); }//Dblqh::openFileRw() @@ -13299,8 +13352,12 @@ void Dblqh::openNextLogfile(Signal* signal) signal->theData[3] = onlLogFilePtr.p->fileName[1]; signal->theData[4] = onlLogFilePtr.p->fileName[2]; signal->theData[5] = onlLogFilePtr.p->fileName[3]; - signal->theData[6] = 2 | FsOpenReq::OM_AUTOSYNC; + signal->theData[6] = 2 | FsOpenReq::OM_AUTOSYNC | FsOpenReq::OM_CHECK_SIZE; req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord); + Uint64 sz = clogFileSize; + sz *= 1024; sz *= 1024; + req->file_size_hi = sz >> 32; + req->file_size_lo = sz & 0xFFFFFFFF; sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA); }//if }//Dblqh::openNextLogfile() @@ -13431,7 +13488,7 @@ void Dblqh::writeFileDescriptor(Signal* signal) /* -------------------------------------------------- */ /* START BY WRITING TO LOG FILE RECORD */ /* -------------------------------------------------- */ - arrGuard(logFilePtr.p->currentMbyte, 16); + arrGuard(logFilePtr.p->currentMbyte, clogFileSize); logFilePtr.p->logMaxGciCompleted[logFilePtr.p->currentMbyte] = logPartPtr.p->logPartNewestCompletedGCI; logFilePtr.p->logMaxGciStarted[logFilePtr.p->currentMbyte] = cnewestGci; @@ -13457,10 +13514,7 @@ void Dblqh::writeFileDescriptor(Signal* signal) /* ------------------------------------------------------------------------- */ void Dblqh::writeFileHeaderOpen(Signal* signal, Uint32 wmoType) { - LogFileRecordPtr wmoLogFilePtr; UintR twmoNoLogDescriptors; - UintR twmoLoop; - UintR twmoIndex; /* -------------------------------------------------- */ /* WRITE HEADER INFORMATION IN THE NEW FILE. */ @@ -13468,52 +13522,44 @@ void Dblqh::writeFileHeaderOpen(Signal* signal, Uint32 wmoType) logPagePtr.p->logPageWord[ZPAGE_HEADER_SIZE + ZPOS_LOG_TYPE] = ZFD_TYPE; logPagePtr.p->logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO] = logFilePtr.p->fileNo; - if (logPartPtr.p->noLogFiles > ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logPartPtr.p->noLogFiles > cmaxLogFilesInPageZero) { jam(); - twmoNoLogDescriptors = ZMAX_LOG_FILES_IN_PAGE_ZERO; + twmoNoLogDescriptors = cmaxLogFilesInPageZero; } else { jam(); twmoNoLogDescriptors = logPartPtr.p->noLogFiles; }//if logPagePtr.p->logPageWord[ZPAGE_HEADER_SIZE + ZPOS_NO_FD] = twmoNoLogDescriptors; - wmoLogFilePtr.i = logFilePtr.i; - twmoLoop = 0; -WMO_LOOP: - jam(); - if (twmoLoop < twmoNoLogDescriptors) { - jam(); - ptrCheckGuard(wmoLogFilePtr, clogFileFileSize, logFileRecord); - for (twmoIndex = 0; twmoIndex <= ZNO_MBYTES_IN_FILE - 1; twmoIndex++) { + + { + Uint32 pos = ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE; + LogFileRecordPtr filePtr = logFilePtr; + for (Uint32 fd = 0; fd < twmoNoLogDescriptors; fd++) + { jam(); - arrGuard(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + twmoIndex, ZPAGE_SIZE); - logPagePtr.p->logPageWord[((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + twmoIndex] = - wmoLogFilePtr.p->logMaxGciCompleted[twmoIndex]; - arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + ZNO_MBYTES_IN_FILE) + - twmoIndex, ZPAGE_SIZE); - logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + ZNO_MBYTES_IN_FILE) + twmoIndex] = - wmoLogFilePtr.p->logMaxGciStarted[twmoIndex]; - arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + (2 * ZNO_MBYTES_IN_FILE)) + - twmoIndex, ZPAGE_SIZE); - logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (twmoLoop * ZFD_PART_SIZE)) + (2 * ZNO_MBYTES_IN_FILE)) + twmoIndex] = - wmoLogFilePtr.p->logLastPrepRef[twmoIndex]; - }//for - wmoLogFilePtr.i = wmoLogFilePtr.p->prevLogFile; - twmoLoop = twmoLoop + 1; - goto WMO_LOOP; - }//if - logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = - (ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (ZFD_PART_SIZE * twmoNoLogDescriptors); - arrGuard(logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX], ZPAGE_SIZE); - logPagePtr.p->logPageWord[logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]] = - ZNEXT_LOG_RECORD_TYPE; + ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord); + for (Uint32 mb = 0; mb < clogFileSize; mb ++) + { + jam(); + Uint32 pos0 = pos + fd * (ZFD_MBYTE_SIZE * clogFileSize) + mb; + Uint32 pos1 = pos0 + clogFileSize; + Uint32 pos2 = pos1 + clogFileSize; + arrGuard(pos0, ZPAGE_SIZE); + arrGuard(pos1, ZPAGE_SIZE); + arrGuard(pos2, ZPAGE_SIZE); + logPagePtr.p->logPageWord[pos0] = filePtr.p->logMaxGciCompleted[mb]; + logPagePtr.p->logPageWord[pos1] = filePtr.p->logMaxGciStarted[mb]; + logPagePtr.p->logPageWord[pos2] = filePtr.p->logLastPrepRef[mb]; + } + filePtr.i = filePtr.p->prevLogFile; + } + pos += (twmoNoLogDescriptors * ZFD_MBYTE_SIZE * clogFileSize); + arrGuard(pos, ZPAGE_SIZE); + logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = pos; + logPagePtr.p->logPageWord[pos] = ZNEXT_LOG_RECORD_TYPE; + } + /* ------------------------------------------------------- */ /* THIS IS A SPECIAL WRITE OF THE FIRST PAGE IN THE */ /* LOG FILE. THIS HAS SPECIAL SIGNIFANCE TO FIND */ @@ -13658,9 +13704,9 @@ void Dblqh::openSrLastFileLab(Signal* signal) void Dblqh::readSrLastFileLab(Signal* signal) { logPartPtr.p->logLap = logPagePtr.p->logPageWord[ZPOS_LOG_LAP]; - if (logPartPtr.p->noLogFiles > ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logPartPtr.p->noLogFiles > cmaxLogFilesInPageZero) { jam(); - initGciInLogFileRec(signal, ZMAX_LOG_FILES_IN_PAGE_ZERO); + initGciInLogFileRec(signal, cmaxLogFilesInPageZero); } else { jam(); initGciInLogFileRec(signal, logPartPtr.p->noLogFiles); @@ -13685,7 +13731,7 @@ void Dblqh::readSrLastMbyteLab(Signal* signal) logPartPtr.p->lastMbyte = logFilePtr.p->currentMbyte - 1; }//if }//if - arrGuard(logFilePtr.p->currentMbyte, 16); + arrGuard(logFilePtr.p->currentMbyte, clogFileSize); logFilePtr.p->logMaxGciCompleted[logFilePtr.p->currentMbyte] = logPagePtr.p->logPageWord[ZPOS_MAX_GCI_COMPLETED]; logFilePtr.p->logMaxGciStarted[logFilePtr.p->currentMbyte] = @@ -13693,7 +13739,7 @@ void Dblqh::readSrLastMbyteLab(Signal* signal) logFilePtr.p->logLastPrepRef[logFilePtr.p->currentMbyte] = logPagePtr.p->logPageWord[ZLAST_LOG_PREP_REF]; releaseLogpage(signal); - if (logFilePtr.p->currentMbyte < (ZNO_MBYTES_IN_FILE - 1)) { + if (logFilePtr.p->currentMbyte < (clogFileSize - 1)) { jam(); logFilePtr.p->currentMbyte++; readSinglePage(signal, ZPAGES_IN_MBYTE * logFilePtr.p->currentMbyte); @@ -13707,21 +13753,21 @@ void Dblqh::readSrLastMbyteLab(Signal* signal) * ---------------------------------------------------------------------- */ if (logPartPtr.p->lastMbyte == ZNIL) { jam(); - logPartPtr.p->lastMbyte = ZNO_MBYTES_IN_FILE - 1; + logPartPtr.p->lastMbyte = clogFileSize - 1; }//if }//if logFilePtr.p->logFileStatus = LogFileRecord::CLOSING_SR; closeFile(signal, logFilePtr, __LINE__); - if (logPartPtr.p->noLogFiles > ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logPartPtr.p->noLogFiles > cmaxLogFilesInPageZero) { Uint32 fileNo; - if (logFilePtr.p->fileNo >= ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logFilePtr.p->fileNo >= cmaxLogFilesInPageZero) { jam(); - fileNo = logFilePtr.p->fileNo - ZMAX_LOG_FILES_IN_PAGE_ZERO; + fileNo = logFilePtr.p->fileNo - cmaxLogFilesInPageZero; } else { jam(); fileNo = (logPartPtr.p->noLogFiles + logFilePtr.p->fileNo) - - ZMAX_LOG_FILES_IN_PAGE_ZERO; + cmaxLogFilesInPageZero; }//if if (fileNo == 0) { jam(); @@ -13731,11 +13777,11 @@ void Dblqh::readSrLastMbyteLab(Signal* signal) * -------------------------------------------------------------------- */ fileNo = 1; logPartPtr.p->srRemainingFiles = - logPartPtr.p->noLogFiles - (ZMAX_LOG_FILES_IN_PAGE_ZERO - 1); + logPartPtr.p->noLogFiles - (cmaxLogFilesInPageZero - 1); } else { jam(); logPartPtr.p->srRemainingFiles = - logPartPtr.p->noLogFiles - ZMAX_LOG_FILES_IN_PAGE_ZERO; + logPartPtr.p->noLogFiles - cmaxLogFilesInPageZero; }//if LogFileRecordPtr locLogFilePtr; findLogfile(signal, fileNo, logPartPtr, &locLogFilePtr); @@ -13760,9 +13806,9 @@ void Dblqh::openSrNextFileLab(Signal* signal) void Dblqh::readSrNextFileLab(Signal* signal) { - if (logPartPtr.p->srRemainingFiles > ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logPartPtr.p->srRemainingFiles > cmaxLogFilesInPageZero) { jam(); - initGciInLogFileRec(signal, ZMAX_LOG_FILES_IN_PAGE_ZERO); + initGciInLogFileRec(signal, cmaxLogFilesInPageZero); } else { jam(); initGciInLogFileRec(signal, logPartPtr.p->srRemainingFiles); @@ -13770,16 +13816,16 @@ void Dblqh::readSrNextFileLab(Signal* signal) releaseLogpage(signal); logFilePtr.p->logFileStatus = LogFileRecord::CLOSING_SR; closeFile(signal, logFilePtr, __LINE__); - if (logPartPtr.p->srRemainingFiles > ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logPartPtr.p->srRemainingFiles > cmaxLogFilesInPageZero) { Uint32 fileNo; - if (logFilePtr.p->fileNo >= ZMAX_LOG_FILES_IN_PAGE_ZERO) { + if (logFilePtr.p->fileNo >= cmaxLogFilesInPageZero) { jam(); - fileNo = logFilePtr.p->fileNo - ZMAX_LOG_FILES_IN_PAGE_ZERO; + fileNo = logFilePtr.p->fileNo - cmaxLogFilesInPageZero; } else { jam(); fileNo = (logPartPtr.p->noLogFiles + logFilePtr.p->fileNo) - - ZMAX_LOG_FILES_IN_PAGE_ZERO; + cmaxLogFilesInPageZero; }//if if (fileNo == 0) { jam(); @@ -13788,11 +13834,11 @@ void Dblqh::readSrNextFileLab(Signal* signal) * -------------------------------------------------------------------- */ fileNo = 1; logPartPtr.p->srRemainingFiles = - logPartPtr.p->srRemainingFiles - (ZMAX_LOG_FILES_IN_PAGE_ZERO - 1); + logPartPtr.p->srRemainingFiles - (cmaxLogFilesInPageZero - 1); } else { jam(); logPartPtr.p->srRemainingFiles = - logPartPtr.p->srRemainingFiles - ZMAX_LOG_FILES_IN_PAGE_ZERO; + logPartPtr.p->srRemainingFiles - cmaxLogFilesInPageZero; }//if LogFileRecordPtr locLogFilePtr; findLogfile(signal, fileNo, logPartPtr, &locLogFilePtr); @@ -14663,7 +14709,7 @@ void Dblqh::srLogLimits(Signal* signal) * EXECUTED. * ----------------------------------------------------------------------- */ while(true) { - ndbrequire(tmbyte < 16); + ndbrequire(tmbyte < clogFileSize); if (logPartPtr.p->logExecState == LogPartRecord::LES_SEARCH_STOP) { if (logFilePtr.p->logMaxGciCompleted[tmbyte] < logPartPtr.p->logLastGci) { jam(); @@ -14704,7 +14750,7 @@ void Dblqh::srLogLimits(Signal* signal) if (logPartPtr.p->logExecState != LogPartRecord::LES_EXEC_LOG) { if (tmbyte == 0) { jam(); - tmbyte = ZNO_MBYTES_IN_FILE - 1; + tmbyte = clogFileSize - 1; logFilePtr.i = logFilePtr.p->prevLogFile; ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord); } else { @@ -15098,7 +15144,7 @@ void Dblqh::execSr(Signal* signal) logPagePtr.p->logPageWord[ZPAGE_HEADER_SIZE + ZPOS_NO_FD]; logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = (ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (noFdDescriptors * ZFD_PART_SIZE); + (noFdDescriptors * ZFD_MBYTE_SIZE * clogFileSize); } break; /* ========================================================================= */ @@ -15138,11 +15184,11 @@ void Dblqh::execSr(Signal* signal) /*---------------------------------------------------------------------------*/ /* START EXECUTION OF A NEW MBYTE IN THE LOG. */ /*---------------------------------------------------------------------------*/ - if (logFilePtr.p->currentMbyte < (ZNO_MBYTES_IN_FILE - 1)) { + if (logFilePtr.p->currentMbyte < (clogFileSize - 1)) { jam(); logPartPtr.p->logExecState = LogPartRecord::LES_EXEC_LOG_NEW_MBYTE; } else { - ndbrequire(logFilePtr.p->currentMbyte == (ZNO_MBYTES_IN_FILE - 1)); + ndbrequire(logFilePtr.p->currentMbyte == (clogFileSize - 1)); jam(); /*---------------------------------------------------------------------------*/ /* WE HAVE TO CHANGE FILE. CLOSE THIS ONE AND THEN OPEN THE NEXT. */ @@ -15339,7 +15385,7 @@ void Dblqh::invalidateLogAfterLastGCI(Signal* signal) { jam(); releaseLfo(signal); releaseLogpage(signal); - if (logPartPtr.p->invalidatePageNo < (ZNO_MBYTES_IN_FILE * ZPAGES_IN_MBYTE - 1)) { + if (logPartPtr.p->invalidatePageNo < (clogFileSize * ZPAGES_IN_MBYTE - 1)) { // We continue in this file. logPartPtr.p->invalidatePageNo++; } else { @@ -16680,6 +16726,22 @@ void Dblqh::initialiseLogFile(Signal* signal) ptrAss(logFilePtr, logFileRecord); logFilePtr.p->nextLogFile = logFilePtr.i + 1; logFilePtr.p->logFileStatus = LogFileRecord::LFS_IDLE; + + logFilePtr.p->logLastPrepRef = new Uint32[clogFileSize]; + logFilePtr.p->logMaxGciCompleted = new Uint32[clogFileSize]; + logFilePtr.p->logMaxGciStarted = new Uint32[clogFileSize]; + + if (logFilePtr.p->logLastPrepRef == 0 || + logFilePtr.p->logMaxGciCompleted == 0 || + logFilePtr.p->logMaxGciStarted == 0) + { + char buf[256]; + BaseString::snprintf(buf, sizeof(buf), + "Failed to alloc mbyte(%u) arrays for logfile %u", + clogFileSize, logFilePtr.i); + progError(__LINE__, NDBD_EXIT_MEMALLOC, buf); + } + }//for logFilePtr.i = clogFileFileSize - 1; ptrAss(logFilePtr, logFileRecord); @@ -17008,41 +17070,31 @@ void Dblqh::initFragrec(Signal* signal, * ========================================================================= */ void Dblqh::initGciInLogFileRec(Signal* signal, Uint32 noFdDescriptors) { - LogFileRecordPtr iglLogFilePtr; - UintR tiglLoop; - UintR tiglIndex; - - tiglLoop = 0; - iglLogFilePtr.i = logFilePtr.i; - iglLogFilePtr.p = logFilePtr.p; -IGL_LOOP: - for (tiglIndex = 0; tiglIndex <= ZNO_MBYTES_IN_FILE - 1; tiglIndex++) { - arrGuard(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (tiglLoop * ZFD_PART_SIZE)) + tiglIndex, ZPAGE_SIZE); - iglLogFilePtr.p->logMaxGciCompleted[tiglIndex] = - logPagePtr.p->logPageWord[((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (tiglLoop * ZFD_PART_SIZE)) + tiglIndex]; - arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + ZNO_MBYTES_IN_FILE) + - (tiglLoop * ZFD_PART_SIZE)) + tiglIndex, ZPAGE_SIZE); - iglLogFilePtr.p->logMaxGciStarted[tiglIndex] = - logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - ZNO_MBYTES_IN_FILE) + - (tiglLoop * ZFD_PART_SIZE)) + tiglIndex]; - arrGuard((((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (2 * ZNO_MBYTES_IN_FILE)) + (tiglLoop * ZFD_PART_SIZE)) + - tiglIndex, ZPAGE_SIZE); - iglLogFilePtr.p->logLastPrepRef[tiglIndex] = - logPagePtr.p->logPageWord[(((ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) + - (2 * ZNO_MBYTES_IN_FILE)) + - (tiglLoop * ZFD_PART_SIZE)) + tiglIndex]; - }//for - tiglLoop = tiglLoop + 1; - if (tiglLoop < noFdDescriptors) { + LogFileRecordPtr filePtr = logFilePtr; + Uint32 pos = ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE; + for (Uint32 fd = 0; fd < noFdDescriptors; fd++) + { jam(); - iglLogFilePtr.i = iglLogFilePtr.p->prevLogFile; - ptrCheckGuard(iglLogFilePtr, clogFileFileSize, logFileRecord); - goto IGL_LOOP; - }//if + for (Uint32 mb = 0; mb < clogFileSize; mb++) + { + jam(); + Uint32 pos0 = pos + fd * (ZFD_MBYTE_SIZE * clogFileSize) + mb; + Uint32 pos1 = pos0 + clogFileSize; + Uint32 pos2 = pos1 + clogFileSize; + arrGuard(pos0, ZPAGE_SIZE); + arrGuard(pos1, ZPAGE_SIZE); + arrGuard(pos2, ZPAGE_SIZE); + filePtr.p->logMaxGciCompleted[mb] = logPagePtr.p->logPageWord[pos0]; + filePtr.p->logMaxGciStarted[mb] = logPagePtr.p->logPageWord[pos1]; + filePtr.p->logLastPrepRef[mb] = logPagePtr.p->logPageWord[pos2]; + } + if (fd + 1 < noFdDescriptors) + { + jam(); + filePtr.i = filePtr.p->prevLogFile; + ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord); + } + } }//Dblqh::initGciInLogFileRec() /* ========================================================================== @@ -18295,7 +18347,7 @@ void Dblqh::writeNextLog(Signal* signal) ndbrequire(logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] < ZPAGE_SIZE); logPagePtr.p->logPageWord[logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]] = ZNEXT_MBYTE_TYPE; - if (logFilePtr.p->currentMbyte == (ZNO_MBYTES_IN_FILE - 1)) { + if (logFilePtr.p->currentMbyte == (clogFileSize - 1)) { jam(); /* -------------------------------------------------- */ /* CALCULATE THE NEW REMAINING WORDS WHEN */ @@ -18384,7 +18436,7 @@ void Dblqh::writeNextLog(Signal* signal) systemError(signal, __LINE__); }//if }//if - if (logFilePtr.p->currentMbyte == (ZNO_MBYTES_IN_FILE - 1)) { + if (logFilePtr.p->currentMbyte == (clogFileSize - 1)) { jam(); twnlNextMbyte = 0; if (logFilePtr.p->fileChangeState != LogFileRecord::NOT_ONGOING) { diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index c10dacbee28..92ca24e8e0a 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -871,6 +871,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "3", STR_VALUE(MAX_INT_RNIL) }, + { + CFG_DB_REDOLOG_FILE_SIZE, + "FragmentLogFileSize", + DB_TOKEN, + "Size of each Redo log file", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "16M", + "4M", + "1G" }, + { CFG_DB_MAX_OPEN_FILES, "MaxNoOfOpenFiles", diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index fc0d53b6a6e..0587fac7e8a 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -179,7 +179,7 @@ ErrorBundle ErrorCodes[] = { { 873, DMEC, TR, "Out of attrinfo records for scan in tuple manager" }, { 899, DMEC, TR, "Rowid already allocated" }, { 1217, DMEC, TR, "Out of operation records in local data manager (increase MaxNoOfLocalOperations)" }, - { 1220, DMEC, TR, "REDO log files overloaded, consult online manual (decrease TimeBetweenLocalCheckpoints, and|or increase NoOfFragmentLogFiles)" }, + { 1220, DMEC, TR, "REDO log files overloaded, consult online manual (increase FragmentLogFileSize)" }, { 1222, DMEC, TR, "Out of transaction markers in LQH" }, { 4021, DMEC, TR, "Out of Send Buffer space in NDB API" }, { 4022, DMEC, TR, "Out of Send Buffer space in NDB API" }, From f8057c4b92f6c4a00efd8035fcc1b359628e670f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 10:32:32 +0200 Subject: [PATCH 052/156] ndb - update dl145a config for autotest storage/ndb/test/run-test/conf-dl145a.cnf: update dl145a config for autotest --- storage/ndb/test/run-test/conf-dl145a.cnf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/ndb/test/run-test/conf-dl145a.cnf b/storage/ndb/test/run-test/conf-dl145a.cnf index ea344f1a62a..5f61bee755d 100644 --- a/storage/ndb/test/run-test/conf-dl145a.cnf +++ b/storage/ndb/test/run-test/conf-dl145a.cnf @@ -21,3 +21,6 @@ BackupMemory = 64M MaxNoOfConcurrentScans = 100 MaxNoOfSavedMessages= 1000 SendBufferMemory = 2M +NoOfFragmentLogFiles = 4 +FragmentLogFileSize = 64M + From 253c2808b39576e0f26c2095b705123ef497005c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 11:58:25 +0200 Subject: [PATCH 053/156] ndb - bug#28726 make sure to remove LCP files aswell if specifying --initial storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Add removal of LCP/X directories --- .../src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 69673796fee..6fc88c5061f 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -2761,16 +2761,34 @@ void Ndbcntr::execSTART_ORD(Signal* signal){ c_missra.execSTART_ORD(signal); } +#define CLEAR_DX 13 +#define CLEAR_LCP 3 + void -Ndbcntr::clearFilesystem(Signal* signal){ +Ndbcntr::clearFilesystem(Signal* signal) +{ + const Uint32 lcp = c_fsRemoveCount >= CLEAR_DX; + FsRemoveReq * req = (FsRemoveReq *)signal->getDataPtrSend(); req->userReference = reference(); req->userPointer = 0; req->directory = 1; req->ownDirectory = 1; - FsOpenReq::setVersion(req->fileNumber, 3); - FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL); // Can by any... - FsOpenReq::v1_setDisk(req->fileNumber, c_fsRemoveCount); + + if (lcp == 0) + { + FsOpenReq::setVersion(req->fileNumber, 3); + FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL); // Can by any... + FsOpenReq::v1_setDisk(req->fileNumber, c_fsRemoveCount); + } + else + { + FsOpenReq::setVersion(req->fileNumber, 5); + FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_DATA); + FsOpenReq::v5_setLcpNo(req->fileNumber, c_fsRemoveCount - CLEAR_DX); + FsOpenReq::v5_setTableId(req->fileNumber, 0); + FsOpenReq::v5_setFragmentId(req->fileNumber, 0); + } sendSignal(NDBFS_REF, GSN_FSREMOVEREQ, signal, FsRemoveReq::SignalLength, JBA); c_fsRemoveCount++; @@ -2779,12 +2797,12 @@ Ndbcntr::clearFilesystem(Signal* signal){ void Ndbcntr::execFSREMOVECONF(Signal* signal){ jamEntry(); - if(c_fsRemoveCount == 13){ + if(c_fsRemoveCount == CLEAR_DX + CLEAR_LCP){ jam(); sendSttorry(signal); } else { jam(); - ndbrequire(c_fsRemoveCount < 13); + ndbrequire(c_fsRemoveCount < CLEAR_DX + CLEAR_LCP); clearFilesystem(signal); }//if } From 3d6304451e1fb53a8fe2857544f94779f4a35e38 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 14:12:31 +0200 Subject: [PATCH 054/156] BUG#28860 USE_TLS not defined for mysqlclient.lib client/CMakeLists.txt: Bug#28860 Define USE_TLS for mysqlclient.lib --- client/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6e37d02ecd8..a829876fec3 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -20,6 +20,10 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # The old Windows build method used renamed (.cc -> .cpp) source files, fails # in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. ADD_DEFINITIONS(-DUSING_CMAKE) + +# USE_TLS needed because of bug#28860 +ADD_DEFINITIONS(-DUSE_TLS) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include From 9c76ac256716bd148b8f4f9212f6e8eb083e8507 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 14:29:54 +0200 Subject: [PATCH 055/156] BUG#28860 port to 5.1 client/CMakeLists.txt: Use USE_TLS for mysqlclient.lib --- client/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8ec8b0111b0..69d39886e9a 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -20,6 +20,10 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # The old Windows build method used renamed (.cc -> .cpp) source files, fails # in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. ADD_DEFINITIONS(-DUSING_CMAKE) + +# USE_TLS needed because of bug#28860 +ADD_DEFINITIONS(-DUSE_TLS) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include From fce63f8f3f773f8013787f216a20ee67fc3e8f3e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Jun 2007 18:56:29 +0300 Subject: [PATCH 056/156] Bug #28488: Incorrect information in file: './test/t1_test#.frm' While executing ALTER TABLE ... PARTITION the server uses a temporary "shadow" table to create the updated table. This shadow table then gets renamed as the original table. The shadow table was not prefixed with the special prefix that marks temporary tables so it was picked up by SHOW TABLE STATUS. Fixed by isolating the code to create the shadow table name in a separate function and prefixing the shadow table name with the special prefix to exclude it from the list of user tables. See bug 18775 and WL1324 for details. mysql-test/r/partition.result: Bug #28488: test case mysql-test/t/partition.test: Bug #28488: test case sql/mysql_priv.h: Bug #28488: prefix shadow file with the temp prefix sql/sql_partition.cc: Bug #28488: prefix shadow file with the temp prefix sql/sql_table.cc: Bug #28488: prefix shadow file with the temp prefix --- mysql-test/r/partition.result | 10 ++++++++++ mysql-test/t/partition.test | 17 +++++++++++++++++ sql/mysql_priv.h | 2 ++ sql/sql_partition.cc | 9 +++------ sql/sql_table.cc | 28 ++++++++++++++++++++++++++-- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index de477310fe3..af90ac6c714 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1235,4 +1235,14 @@ aaa 2 drop table t1; create table t1 (s1 bigint) partition by list (s1) (partition p1 values in (-9223372036854775808)); drop table t1; +CREATE TABLE t1(a INT NOT NULL, b TINYBLOB, KEY(a)) +PARTITION BY RANGE(a) ( PARTITION p0 VALUES LESS THAN (32)); +INSERT INTO t1 VALUES (1, REPEAT('a', 10)); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +ALTER TABLE t1 ADD PARTITION (PARTITION p1 VALUES LESS THAN (64)); +ALTER TABLE t1 DROP PARTITION p1; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 68c13c0792a..186cf1d3e8a 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1448,4 +1448,21 @@ drop table t1; create table t1 (s1 bigint) partition by list (s1) (partition p1 values in (-9223372036854775808)); drop table t1; +# +# Bug #28488: Incorrect information in file: './test/t1_test#.frm' +# + +CREATE TABLE t1(a INT NOT NULL, b TINYBLOB, KEY(a)) + PARTITION BY RANGE(a) ( PARTITION p0 VALUES LESS THAN (32)); +INSERT INTO t1 VALUES (1, REPEAT('a', 10)); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; + +ALTER TABLE t1 ADD PARTITION (PARTITION p1 VALUES LESS THAN (64)); +ALTER TABLE t1 DROP PARTITION p1; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 71b8cc6d361..8cad35cc693 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1934,6 +1934,8 @@ uint filename_to_tablename(const char *from, char *to, uint to_length); uint tablename_to_filename(const char *from, char *to, uint to_length); uint build_table_filename(char *buff, size_t bufflen, const char *db, const char *table, const char *ext, uint flags); +uint build_table_shadow_filename(char *buff, size_t bufflen, + ALTER_PARTITION_PARAM_TYPE *lpt); /* Flags for conversion functions. */ #define FN_FROM_IS_TMP (1 << 0) #define FN_TO_IS_TMP (1 << 1) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 2c5fe91681e..a5d26fa700f 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5488,8 +5488,7 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt) char shadow_path[FN_LEN]; DBUG_ENTER("write_log_drop_shadow_frm"); - build_table_filename(shadow_path, sizeof(shadow_path), lpt->db, - lpt->table_name, "#", 0); + build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_replace_delete_frm(lpt, 0UL, NULL, (const char*)shadow_path, FALSE)) @@ -5537,8 +5536,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) part_info->first_log_entry= NULL; build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0); - build_table_filename(shadow_path, sizeof(shadow_path), lpt->db, - lpt->table_name, "#", 0); + build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE)) goto error; @@ -5703,8 +5701,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) part_info->first_log_entry= NULL; build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0); - build_table_filename(shadow_path, sizeof(shadow_path), lpt->db, - lpt->table_name, "#", 0); + build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION)) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6d5860240be..007315ce5f9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1262,6 +1262,31 @@ void release_ddl_log() */ +/** + @brief construct a temporary shadow file name. + + @details Make a shadow file name used by ALTER TABLE to construct the + modified table (with keeping the original). The modified table is then + moved back as original table. The name must start with the temp file + prefix so it gets filtered out by table files listing routines. + + @param[out] buff buffer to receive the constructed name + @param bufflen size of buff + @param lpt alter table data structure + + @retval path length +*/ + +uint build_table_shadow_filename(char *buff, size_t bufflen, + ALTER_PARTITION_PARAM_TYPE *lpt) +{ + char tmp_name[FN_REFLEN]; + my_snprintf (tmp_name, sizeof (tmp_name), "%s-%s", tmp_file_prefix, + lpt->table_name); + return build_table_filename(buff, bufflen, lpt->db, tmp_name, "", FN_IS_TMP); +} + + /* SYNOPSIS mysql_write_frm() @@ -1302,8 +1327,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) /* Build shadow frm file name */ - build_table_filename(shadow_path, sizeof(shadow_path), lpt->db, - lpt->table_name, "#", 0); + build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); strxmov(shadow_frm_name, shadow_path, reg_ext, NullS); if (flags & WFRM_WRITE_SHADOW) { From b9234b1f5eb85845c4bf29d5a22f84448420d38f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Jun 2007 03:16:02 +0500 Subject: [PATCH 057/156] BUG#27141 - Calling tell(-1) under Windows causes assertion failure in Debug mode Original problem was fixed by Magnus (see BUG25807). Currently only windows debug build causes assertion failure. This patch assures that my_tell gets correct file descriptor on any platform by DBUG_ASSERT macro. mysys/my_seek.c: Added assertion in case my_tell gets wrong file descriptor. --- mysys/my_seek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mysys/my_seek.c b/mysys/my_seek.c index 3d415400aa2..5c1a6c44b6f 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -88,6 +88,7 @@ my_off_t my_tell(File fd, myf MyFlags __attribute__((unused))) os_off_t pos; DBUG_ENTER("my_tell"); DBUG_PRINT("my",("Fd: %d MyFlags: %d",fd, MyFlags)); + DBUG_ASSERT(fd >= 0); #ifdef HAVE_TELL pos=tell(fd); #else From 1182b801d435d500c92ce4439b2531521ea6df33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Jun 2007 17:06:33 +0200 Subject: [PATCH 058/156] Bug #28899 not possible to set separate watchdog timeout at startup storage/ndb/include/mgmapi/mgmapi_config_parameters.h: add new configuration parameter TimeBetweenWatchDogCheckInitial storage/ndb/include/portlib/NdbTick.h: enable timing code storage/ndb/src/common/portlib/NdbTick.c: enable timing code storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: read watchdog timeout to set it after malloc storage/ndb/src/kernel/vm/Configuration.cpp: read initial watchdog timeout and set it in the beginning storage/ndb/src/kernel/vm/Configuration.hpp: read initial watchdog timeout and set it in the beginning storage/ndb/src/kernel/vm/SimulatedBlock.cpp: introduce new state for "action" malloc of memory storage/ndb/src/kernel/vm/SimulatedBlock.hpp: introduce new state for "action" malloc of memory storage/ndb/src/kernel/vm/WatchDog.cpp: rewrite watchdog to check every 100ms for being stuch, but keep shutdown after 3 * interval for "action" == 9 (malloc) keep old behavior and only output every interval storage/ndb/src/mgmsrv/ConfigInfo.cpp: add new configuration parameter TimeBetweenWatchDogCheckInitial --- .../include/mgmapi/mgmapi_config_parameters.h | 2 + storage/ndb/include/portlib/NdbTick.h | 4 - storage/ndb/src/common/portlib/NdbTick.c | 4 +- .../src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 8 + storage/ndb/src/kernel/vm/Configuration.cpp | 12 +- storage/ndb/src/kernel/vm/Configuration.hpp | 1 + storage/ndb/src/kernel/vm/SimulatedBlock.cpp | 18 +- storage/ndb/src/kernel/vm/SimulatedBlock.hpp | 3 +- storage/ndb/src/kernel/vm/WatchDog.cpp | 156 +++++++++++------- storage/ndb/src/mgmsrv/ConfigInfo.cpp | 12 ++ 10 files changed, 149 insertions(+), 71 deletions(-) diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index 119958d0ce0..45cfd5fd7bf 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -81,6 +81,8 @@ #define CFG_DB_BACKUP_WRITE_SIZE 136 #define CFG_DB_BACKUP_MAX_WRITE_SIZE 139 +#define CFG_DB_WATCHDOG_INTERVAL_INITIAL 141 + #define CFG_LOG_DESTINATION 147 #define CFG_DB_DISCLESS 148 diff --git a/storage/ndb/include/portlib/NdbTick.h b/storage/ndb/include/portlib/NdbTick.h index 59f580de38e..70c36fdfd1e 100644 --- a/storage/ndb/include/portlib/NdbTick.h +++ b/storage/ndb/include/portlib/NdbTick.h @@ -37,9 +37,6 @@ NDB_TICKS NdbTick_CurrentMillisecond(void); */ int NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros); - /*#define TIME_MEASUREMENT*/ -#ifdef TIME_MEASUREMENT - struct MicroSecondTimer { NDB_TICKS seconds; NDB_TICKS micro_seconds; @@ -54,7 +51,6 @@ struct MicroSecondTimer { NDB_TICKS NdbTick_getMicrosPassed(struct MicroSecondTimer start, struct MicroSecondTimer stop); int NdbTick_getMicroTimer(struct MicroSecondTimer* time_now); -#endif #ifdef __cplusplus } diff --git a/storage/ndb/src/common/portlib/NdbTick.c b/storage/ndb/src/common/portlib/NdbTick.c index eff6b28b7eb..f69c42c0ca0 100644 --- a/storage/ndb/src/common/portlib/NdbTick.c +++ b/storage/ndb/src/common/portlib/NdbTick.c @@ -15,7 +15,7 @@ #include -#include "NdbTick.h" +#include #define NANOSEC_PER_SEC 1000000000 #define MICROSEC_PER_SEC 1000000 @@ -71,7 +71,6 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ } #endif -#ifdef TIME_MEASUREMENT int NdbTick_getMicroTimer(struct MicroSecondTimer* input_timer) { @@ -102,4 +101,3 @@ NdbTick_getMicrosPassed(struct MicroSecondTimer start, } return ret_value; } -#endif diff --git a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 69673796fee..fd383de6f59 100644 --- a/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -277,6 +277,14 @@ void Ndbcntr::execSTTOR(Signal* signal) break; case ZSTART_PHASE_1: jam(); + { + Uint32 db_watchdog_interval = 0; + const ndb_mgm_configuration_iterator * p = + m_ctx.m_config.getOwnConfigIterator(); + ndb_mgm_get_int_parameter(p, CFG_DB_WATCHDOG_INTERVAL, &db_watchdog_interval); + ndbrequire(db_watchdog_interval); + update_watch_dog_timer(db_watchdog_interval); + } startPhase1Lab(signal); break; case ZSTART_PHASE_2: diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index e0b485eda59..fbda9873fd8 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -443,6 +443,11 @@ Configuration::setupConfiguration(){ "TimeBetweenWatchDogCheck missing"); } + if(iter.get(CFG_DB_WATCHDOG_INTERVAL_INITIAL, &_timeBetweenWatchDogCheckInitial)){ + ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, "Invalid configuration fetched", + "TimeBetweenWatchDogCheckInitial missing"); + } + /** * Get paths */ @@ -462,9 +467,12 @@ Configuration::setupConfiguration(){ * Create the watch dog thread */ { - Uint32 t = _timeBetweenWatchDogCheck; + if (_timeBetweenWatchDogCheckInitial < _timeBetweenWatchDogCheck) + _timeBetweenWatchDogCheckInitial = _timeBetweenWatchDogCheck; + + Uint32 t = _timeBetweenWatchDogCheckInitial; t = globalEmulatorData.theWatchDog ->setCheckInterval(t); - _timeBetweenWatchDogCheck = t; + _timeBetweenWatchDogCheckInitial = t; } ConfigValues* cf = ConfigValuesFactory::extractCurrentSection(iter.m_config); diff --git a/storage/ndb/src/kernel/vm/Configuration.hpp b/storage/ndb/src/kernel/vm/Configuration.hpp index 934261e40af..918a889a171 100644 --- a/storage/ndb/src/kernel/vm/Configuration.hpp +++ b/storage/ndb/src/kernel/vm/Configuration.hpp @@ -84,6 +84,7 @@ private: Uint32 _maxErrorLogs; Uint32 _lockPagesInMainMemory; Uint32 _timeBetweenWatchDogCheck; + Uint32 _timeBetweenWatchDogCheckInitial; ndb_mgm_configuration * m_ownConfig; ndb_mgm_configuration * m_clusterConfig; diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp index 3125fc33258..1ba7368c352 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -662,7 +663,7 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U void * p = NULL; size_t size = n*s; Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s); - refresh_watch_dog(); + refresh_watch_dog(9); if (real_size > 0){ #ifdef VM_TRACE_MEM ndbout_c("%s::allocRecord(%s, %u, %u) = %llu bytes", @@ -696,12 +697,12 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U char * ptr = (char*)p; const Uint32 chunk = 128 * 1024; while(size > chunk){ - refresh_watch_dog(); + refresh_watch_dog(9); memset(ptr, 0, chunk); ptr += chunk; size -= chunk; } - refresh_watch_dog(); + refresh_watch_dog(9); memset(ptr, 0, size); } } @@ -720,9 +721,16 @@ SimulatedBlock::deallocRecord(void ** ptr, } void -SimulatedBlock::refresh_watch_dog() +SimulatedBlock::refresh_watch_dog(Uint32 place) { - globalData.incrementWatchDogCounter(1); + globalData.incrementWatchDogCounter(place); +} + +void +SimulatedBlock::update_watch_dog_timer(Uint32 interval) +{ + extern EmulatorData globalEmulatorData; + globalEmulatorData.theWatchDog->setCheckInterval(interval); } void diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp index 37a8dde5956..01fb11e05e8 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -334,7 +334,8 @@ protected: * Refresh Watch Dog in initialising code * */ - void refresh_watch_dog(); + void refresh_watch_dog(Uint32 place = 1); + void update_watch_dog_timer(Uint32 interval); /** * Prog error diff --git a/storage/ndb/src/kernel/vm/WatchDog.cpp b/storage/ndb/src/kernel/vm/WatchDog.cpp index 2e24a5eaa6c..a7f5e8f5c2b 100644 --- a/storage/ndb/src/kernel/vm/WatchDog.cpp +++ b/storage/ndb/src/kernel/vm/WatchDog.cpp @@ -25,6 +25,8 @@ #include #include +#include + extern EventLogger g_eventLogger; extern "C" @@ -72,73 +74,115 @@ WatchDog::doStop(){ } } +const char *get_action(Uint32 IPValue) +{ + const char *action; + switch (IPValue) { + case 1: + action = "Job Handling"; + break; + case 2: + action = "Scanning Timers"; + break; + case 3: + action = "External I/O"; + break; + case 4: + action = "Print Job Buffers at crash"; + break; + case 5: + action = "Checking connections"; + break; + case 6: + action = "Performing Send"; + break; + case 7: + action = "Polling for Receive"; + break; + case 8: + action = "Performing Receive"; + break; + case 9: + action = "Allocating memory"; + break; + default: + action = "Unknown place"; + break; + }//switch + return action; +} + void -WatchDog::run(){ - unsigned int anIPValue; - unsigned int alerts = 0; +WatchDog::run() +{ + unsigned int anIPValue, sleep_time; unsigned int oldIPValue = 0; - + unsigned int theIntervalCheck = theInterval; + struct MicroSecondTimer start_time, last_time, now; + NdbTick_getMicroTimer(&start_time); + last_time = start_time; + // WatchDog for the single threaded NDB - while(!theStop){ - Uint32 tmp = theInterval / 500; - tmp= (tmp ? tmp : 1); - - while(!theStop && tmp > 0){ - NdbSleep_MilliSleep(500); - tmp--; - } - + while (!theStop) + { + sleep_time= 100; + + NdbSleep_MilliSleep(sleep_time); if(theStop) break; + NdbTick_getMicroTimer(&now); + if (NdbTick_getMicrosPassed(last_time, now)/1000 > sleep_time*2) + { + struct tms my_tms; + times(&my_tms); + g_eventLogger.info("Watchdog: User time: %llu System time: %llu", + (Uint64)my_tms.tms_utime, + (Uint64)my_tms.tms_stime); + g_eventLogger.warning("Watchdog: Warning overslept %u ms, expected %u ms.", + NdbTick_getMicrosPassed(last_time, now)/1000, + sleep_time); + } + last_time = now; + // Verify that the IP thread is not stuck in a loop anIPValue = *theIPValue; - if(anIPValue != 0) { + if (anIPValue != 0) + { oldIPValue = anIPValue; globalData.incrementWatchDogCounter(0); - alerts = 0; - } else { - const char *last_stuck_action; - alerts++; - switch (oldIPValue) { - case 1: - last_stuck_action = "Job Handling"; - break; - case 2: - last_stuck_action = "Scanning Timers"; - break; - case 3: - last_stuck_action = "External I/O"; - break; - case 4: - last_stuck_action = "Print Job Buffers at crash"; - break; - case 5: - last_stuck_action = "Checking connections"; - break; - case 6: - last_stuck_action = "Performing Send"; - break; - case 7: - last_stuck_action = "Polling for Receive"; - break; - case 8: - last_stuck_action = "Performing Receive"; - break; - default: - last_stuck_action = "Unknown place"; - break; - }//switch - g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action); + NdbTick_getMicroTimer(&start_time); + theIntervalCheck = theInterval; + } + else + { + int warn = 1; + Uint32 elapsed = NdbTick_getMicrosPassed(start_time, now)/1000; + /* + oldIPValue == 9 indicates malloc going on, this can take some time + so only warn if we pass the watchdog interval + */ + if (oldIPValue == 9) + if (elapsed < theIntervalCheck) + warn = 0; + else + theIntervalCheck += theInterval; + + if (warn) { - struct tms my_tms; - times(&my_tms); - g_eventLogger.info("User time: %llu System time: %llu", - (Uint64)my_tms.tms_utime, - (Uint64)my_tms.tms_stime); - } - if(alerts == 3){ - shutdownSystem(last_stuck_action); + const char *last_stuck_action = get_action(oldIPValue); + g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action); + { + struct tms my_tms; + times(&my_tms); + g_eventLogger.info("Watchdog: User time: %llu System time: %llu", + (Uint64)my_tms.tms_utime, + (Uint64)my_tms.tms_stime); + } + if (elapsed > 3 * theInterval) + { + shutdownSystem(last_stuck_action); + } } } } diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index c10dacbee28..3e76071a0db 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -571,6 +571,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "70", STR_VALUE(MAX_INT_RNIL) }, + { + CFG_DB_WATCHDOG_INTERVAL_INITIAL, + "TimeBetweenWatchDogCheckInitial", + DB_TOKEN, + "Time between execution checks inside a database node in the early start phases when memory is allocated", + ConfigInfo::CI_USED, + true, + ConfigInfo::CI_INT, + "6000", + "70", + STR_VALUE(MAX_INT_RNIL) }, + { CFG_DB_STOP_ON_ERROR, "StopOnError", From 35b2f212ba5f5cd98b9ee4bd8332012cf3bd3438 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Jun 2007 17:29:50 +0200 Subject: [PATCH 059/156] Bug #28751 Lots of memory locked in memory causes high kswapd - add odirect option for lcp+backup+redo log to lower CPU/kswapd usage - writing odirect removes need for kernel write buffers avoiding kswapd to kick in mysql-test/ndb/ndb_config_2_node.ini: run mysql-test-run using ODirect storage/ndb/include/mgmapi/mgmapi_config_parameters.h: add new config parameter to choose ODirect storage/ndb/include/ndb_global.h.in: specify alignment needed for odirect storage/ndb/src/kernel/blocks/backup/Backup.cpp: read odirect config param open LCP and Backup datafiles with odirect if specified insert empty padding record if odirect is used allocate buffers aligned to be able to use odirect storage/ndb/src/kernel/blocks/backup/Backup.hpp: odirect and padding options storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp: add empty_record in file format storage/ndb/src/kernel/blocks/backup/BackupInit.cpp: read odirect config and allocate aligned storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp: correct debug printouts storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp: read odirect config param and align buffers storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp: read odirect config param and align buffers storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: read config params and open redo log files with odirect if set storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp: aligned writing for odirect correct odirect open options with test+fallback if odirect fails storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: align + odirect check storage/ndb/src/kernel/blocks/restore.cpp: restor block to ignore new lcp padding empty_record storage/ndb/src/kernel/vm/SimulatedBlock.cpp: alligend log buffer allocation for odirect storage/ndb/src/kernel/vm/SimulatedBlock.hpp: alligend log buffer allocation for odirect storage/ndb/src/mgmsrv/ConfigInfo.cpp: new config param for odirect, default false storage/ndb/tools/restore/Restore.cpp: ndb_restore to skip empty_record alignment padding in backup file --- mysql-test/ndb/ndb_config_2_node.ini | 1 + .../include/mgmapi/mgmapi_config_parameters.h | 2 + storage/ndb/include/ndb_global.h.in | 2 + .../ndb/src/kernel/blocks/backup/Backup.cpp | 49 +++++- .../ndb/src/kernel/blocks/backup/Backup.hpp | 3 +- .../src/kernel/blocks/backup/BackupFormat.hpp | 10 +- .../src/kernel/blocks/backup/BackupInit.cpp | 7 +- .../ndb/src/kernel/blocks/backup/FsBuffer.hpp | 24 +-- storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 5 +- .../ndb/src/kernel/blocks/dblqh/DblqhInit.cpp | 14 +- .../ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 14 +- .../ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp | 151 +++++++++++++----- .../ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp | 4 + storage/ndb/src/kernel/blocks/restore.cpp | 3 + storage/ndb/src/kernel/vm/SimulatedBlock.cpp | 25 ++- storage/ndb/src/kernel/vm/SimulatedBlock.hpp | 1 + storage/ndb/src/mgmsrv/ConfigInfo.cpp | 12 ++ storage/ndb/tools/restore/Restore.cpp | 29 +++- 18 files changed, 279 insertions(+), 77 deletions(-) diff --git a/mysql-test/ndb/ndb_config_2_node.ini b/mysql-test/ndb/ndb_config_2_node.ini index 99f31150d8c..0badf3145c3 100644 --- a/mysql-test/ndb/ndb_config_2_node.ini +++ b/mysql-test/ndb/ndb_config_2_node.ini @@ -12,6 +12,7 @@ MaxNoOfAttributes= CHOOSE_MaxNoOfAttributes TimeBetweenGlobalCheckpoints= 500 NoOfFragmentLogFiles= 3 DiskPageBufferMemory= CHOOSE_DiskPageBufferMemory +ODirect= 1 # the following parametes just function as a small regression # test that the parameter exists InitialNoOfOpenFiles= 27 diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index 45cfd5fd7bf..661e24b53cc 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -115,6 +115,8 @@ #define CFG_DB_MEMREPORT_FREQUENCY 166 +#define CFG_DB_O_DIRECT 168 + #define CFG_DB_SGA 198 /* super pool mem */ #define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */ diff --git a/storage/ndb/include/ndb_global.h.in b/storage/ndb/include/ndb_global.h.in index 60d32f62ee3..c3ea909ba2e 100644 --- a/storage/ndb/include/ndb_global.h.in +++ b/storage/ndb/include/ndb_global.h.in @@ -146,4 +146,6 @@ extern "C" { #define MAX(x,y) (((x)>(y))?(x):(y)) #endif +#define NDB_O_DIRECT_WRITE_ALIGNMENT 512 + #endif diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index 57082eaccc8..645eb590ae3 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -2761,6 +2761,8 @@ Backup::openFiles(Signal* signal, BackupRecordPtr ptr) c_backupFilePool.getPtr(filePtr, ptr.p->dataFilePtr); filePtr.p->m_flags |= BackupFile::BF_OPENING; + if (c_defaults.m_o_direct) + req->fileFlags |= FsOpenReq::OM_DIRECT; req->userPointer = filePtr.i; FsOpenReq::setVersion(req->fileNumber, 2); FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_DATA); @@ -3735,12 +3737,31 @@ Backup::OperationRecord::newFragment(Uint32 tableId, Uint32 fragNo) } bool -Backup::OperationRecord::fragComplete(Uint32 tableId, Uint32 fragNo) +Backup::OperationRecord::fragComplete(Uint32 tableId, Uint32 fragNo, bool fill_record) { Uint32 * tmp; const Uint32 footSz = sizeof(BackupFormat::DataFile::FragmentFooter) >> 2; + Uint32 sz = footSz + 1; - if(dataBuffer.getWritePtr(&tmp, footSz + 1)) { + if (fill_record) + { + Uint32 * new_tmp; + if (!dataBuffer.getWritePtr(&tmp, sz)) + return false; + new_tmp = tmp + sz; + + if ((UintPtr)new_tmp & (sizeof(Page32)-1)) + { + /* padding is needed to get full write */ + new_tmp += 2 /* to fit empty header minimum 2 words*/; + new_tmp = (Uint32 *)(((UintPtr)new_tmp + sizeof(Page32)-1) & + ~(UintPtr)(sizeof(Page32)-1)); + /* new write sz */ + sz = new_tmp - tmp; + } + } + + if(dataBuffer.getWritePtr(&tmp, sz)) { jam(); * tmp = 0; // Finish record stream tmp++; @@ -3752,7 +3773,17 @@ Backup::OperationRecord::fragComplete(Uint32 tableId, Uint32 fragNo) foot->FragmentNo = htonl(fragNo); foot->NoOfRecords = htonl(noOfRecords); foot->Checksum = htonl(0); - dataBuffer.updateWritePtr(footSz + 1); + + if (sz != footSz + 1) + { + tmp += footSz; + memset(tmp, 0, (sz - footSz - 1) * 4); + *tmp = htonl(BackupFormat::EMPTY_ENTRY); + tmp++; + *tmp = htonl(sz - footSz - 1); + } + + dataBuffer.updateWritePtr(sz); return true; }//if return false; @@ -3854,8 +3885,13 @@ Backup::fragmentCompleted(Signal* signal, BackupFilePtr filePtr) return; }//if + BackupRecordPtr ptr LINT_SET_PTR; + c_backupPool.getPtr(ptr, filePtr.p->backupPtr); + OperationRecord & op = filePtr.p->operation; - if(!op.fragComplete(filePtr.p->tableId, filePtr.p->fragmentNo)) { + if(!op.fragComplete(filePtr.p->tableId, filePtr.p->fragmentNo, + c_defaults.m_o_direct)) + { jam(); signal->theData[0] = BackupContinueB::BUFFER_FULL_FRAG_COMPLETE; signal->theData[1] = filePtr.i; @@ -3865,9 +3901,6 @@ Backup::fragmentCompleted(Signal* signal, BackupFilePtr filePtr) filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_SCAN_THREAD; - BackupRecordPtr ptr LINT_SET_PTR; - c_backupPool.getPtr(ptr, filePtr.p->backupPtr); - if (ptr.p->is_lcp()) { ptr.p->slaveState.setState(STOPPING); @@ -4905,6 +4938,8 @@ Backup::lcp_open_file(Signal* signal, BackupRecordPtr ptr) FsOpenReq::OM_CREATE | FsOpenReq::OM_APPEND | FsOpenReq::OM_AUTOSYNC; + if (c_defaults.m_o_direct) + req->fileFlags |= FsOpenReq::OM_DIRECT; FsOpenReq::v2_setCount(req->fileNumber, 0xFFFFFFFF); req->auto_sync_size = c_defaults.m_disk_synch_size; diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.hpp b/storage/ndb/src/kernel/blocks/backup/Backup.hpp index 32f2e14ac92..3fd9b2967fd 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.hpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.hpp @@ -240,7 +240,7 @@ public: * Once per fragment */ bool newFragment(Uint32 tableId, Uint32 fragNo); - bool fragComplete(Uint32 tableId, Uint32 fragNo); + bool fragComplete(Uint32 tableId, Uint32 fragNo, bool fill_record); /** * Once per scan frag (next) req/conf @@ -534,6 +534,7 @@ public: Uint32 m_disk_write_speed; Uint32 m_disk_synch_size; Uint32 m_diskless; + Uint32 m_o_direct; }; /** diff --git a/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp b/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp index ace9dfe5c79..20f8f6650be 100644 --- a/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp +++ b/storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp @@ -32,7 +32,8 @@ struct BackupFormat { TABLE_LIST = 4, TABLE_DESCRIPTION = 5, GCP_ENTRY = 6, - FRAGMENT_INFO = 7 + FRAGMENT_INFO = 7, + EMPTY_ENTRY = 8 }; struct FileHeader { @@ -93,6 +94,13 @@ struct BackupFormat { Uint32 NoOfRecords; Uint32 Checksum; }; + + /* optional padding for O_DIRECT */ + struct EmptyEntry { + Uint32 SectionType; + Uint32 SectionLength; + /* not used data */ + }; }; /** diff --git a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp index 4faa02e494f..2cd2a8a2bee 100644 --- a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp +++ b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp @@ -148,10 +148,13 @@ Backup::execREAD_CONFIG_REQ(Signal* signal) c_defaults.m_disk_write_speed = 10 * (1024 * 1024); c_defaults.m_disk_write_speed_sr = 100 * (1024 * 1024); c_defaults.m_disk_synch_size = 4 * (1024 * 1024); - + c_defaults.m_o_direct = true; + Uint32 noBackups = 0, noTables = 0, noAttribs = 0, noFrags = 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &c_defaults.m_diskless)); + ndb_mgm_get_int_parameter(p, CFG_DB_O_DIRECT, + &c_defaults.m_o_direct); ndb_mgm_get_int_parameter(p, CFG_DB_CHECKPOINT_SPEED_SR, &c_defaults.m_disk_write_speed_sr); ndb_mgm_get_int_parameter(p, CFG_DB_CHECKPOINT_SPEED, @@ -204,7 +207,7 @@ Backup::execREAD_CONFIG_REQ(Signal* signal) / sizeof(Page32); // We need to allocate an additional of 2 pages. 1 page because of a bug in // ArrayPool and another one for DICTTAINFO. - c_pagePool.setSize(noPages + NO_OF_PAGES_META_FILE + 2); + c_pagePool.setSize(noPages + NO_OF_PAGES_META_FILE + 2, true); { // Init all tables SLList tables(c_tablePool); diff --git a/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp b/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp index d26f36ccf40..bb0bbd6d770 100644 --- a/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp +++ b/storage/ndb/src/kernel/blocks/backup/FsBuffer.hpp @@ -270,8 +270,8 @@ FsBuffer::getReadPtr(Uint32 ** ptr, Uint32 * sz, bool * _eof){ * ptr = &Tp[Tr]; - DEBUG(ndbout_c("getReadPtr() Tr: %d Tw: %d Ts: %d Tm: %d sz1: %d -> %d", - Tr, Tw, Ts, Tm, sz1, * sz)); + DEBUG(ndbout_c("getReadPtr() Tr: %d Tmw: %d Ts: %d Tm: %d sz1: %d -> %d", + Tr, Tmw, Ts, Tm, sz1, * sz)); return true; } @@ -279,8 +279,8 @@ FsBuffer::getReadPtr(Uint32 ** ptr, Uint32 * sz, bool * _eof){ if(!m_eof){ * _eof = false; - DEBUG(ndbout_c("getReadPtr() Tr: %d Tw: %d Ts: %d Tm: %d sz1: %d -> false", - Tr, Tw, Ts, Tm, sz1)); + DEBUG(ndbout_c("getReadPtr() Tr: %d Tmw: %d Ts: %d Tm: %d sz1: %d -> false", + Tr, Tmw, Ts, Tm, sz1)); return false; } @@ -289,8 +289,8 @@ FsBuffer::getReadPtr(Uint32 ** ptr, Uint32 * sz, bool * _eof){ * _eof = true; * ptr = &Tp[Tr]; - DEBUG(ndbout_c("getReadPtr() Tr: %d Tw: %d Ts: %d Tm: %d sz1: %d -> %d eof", - Tr, Tw, Ts, Tm, sz1, * sz)); + DEBUG(ndbout_c("getReadPtr() Tr: %d Tmw: %d Ts: %d Tm: %d sz1: %d -> %d eof", + Tr, Tmw, Ts, Tm, sz1, * sz)); return false; } @@ -316,13 +316,13 @@ FsBuffer::getWritePtr(Uint32 ** ptr, Uint32 sz){ if(sz1 > sz){ // Note at least 1 word of slack * ptr = &Tp[Tw]; - DEBUG(ndbout_c("getWritePtr(%d) Tr: %d Tw: %d Ts: %d sz1: %d -> true", - sz, Tr, Tw, Ts, sz1)); + DEBUG(ndbout_c("getWritePtr(%d) Tw: %d sz1: %d -> true", + sz, Tw, sz1)); return true; } - DEBUG(ndbout_c("getWritePtr(%d) Tr: %d Tw: %d Ts: %d sz1: %d -> false", - sz, Tr, Tw, Ts, sz1)); + DEBUG(ndbout_c("getWritePtr(%d) Tw: %d sz1: %d -> false", + sz, Tw, sz1)); return false; } @@ -339,11 +339,15 @@ FsBuffer::updateWritePtr(Uint32 sz){ m_free -= sz; if(Tnew < Ts){ m_writeIndex = Tnew; + DEBUG(ndbout_c("updateWritePtr(%d) m_writeIndex: %d", + sz, m_writeIndex)); return; } memcpy(Tp, &Tp[Ts], (Tnew - Ts) << 2); m_writeIndex = Tnew - Ts; + DEBUG(ndbout_c("updateWritePtr(%d) m_writeIndex: %d", + sz, m_writeIndex)); } inline diff --git a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 0f88933f617..21a887c23de 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -115,9 +115,6 @@ class Dbtup; /* ------------------------------------------------------------------------- */ /* VARIOUS CONSTANTS USED AS FLAGS TO THE FILE MANAGER. */ /* ------------------------------------------------------------------------- */ -#define ZOPEN_READ 0 -#define ZOPEN_WRITE 1 -#define ZOPEN_READ_WRITE 2 #define ZVAR_NO_LOG_PAGE_WORD 1 #define ZLIST_OF_PAIRS 0 #define ZLIST_OF_PAIRS_SYNCH 16 @@ -2686,6 +2683,7 @@ private: UintR clfoFileSize; LogPageRecord *logPageRecord; + void *logPageRecordUnaligned; LogPageRecordPtr logPagePtr; UintR cfirstfreeLogPage; UintR clogPageFileSize; @@ -2889,6 +2887,7 @@ private: UintR ctransidHash[1024]; Uint32 c_diskless; + Uint32 c_o_direct; Uint32 c_error_insert_table_id; public: diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index 8aaf86de73a..f597519d8f4 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -49,6 +49,7 @@ void Dblqh::initData() logFileRecord = 0; logFileOperationRecord = 0; logPageRecord = 0; + logPageRecordUnaligned= 0; pageRefRecord = 0; tablerec = 0; tcConnectionrec = 0; @@ -105,10 +106,13 @@ void Dblqh::initRecords() sizeof(LogFileOperationRecord), clfoFileSize); - logPageRecord = (LogPageRecord*)allocRecord("LogPageRecord", - sizeof(LogPageRecord), - clogPageFileSize, - false); + logPageRecord = + (LogPageRecord*)allocRecordAligned("LogPageRecord", + sizeof(LogPageRecord), + clogPageFileSize, + &logPageRecordUnaligned, + NDB_O_DIRECT_WRITE_ALIGNMENT, + false); pageRefRecord = (PageRefRecord*)allocRecord("PageRefRecord", sizeof(PageRefRecord), @@ -378,7 +382,7 @@ Dblqh::~Dblqh() sizeof(LogFileOperationRecord), clfoFileSize); - deallocRecord((void**)&logPageRecord, + deallocRecord((void**)&logPageRecordUnaligned, "LogPageRecord", sizeof(LogPageRecord), clogPageFileSize); diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 33696ebba27..644ff58cae5 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -1015,6 +1015,8 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) cmaxAccOps = cscanrecFileSize * MAX_PARALLEL_OP_PER_SCAN; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &c_diskless)); + c_o_direct = true; + ndb_mgm_get_int_parameter(p, CFG_DB_O_DIRECT, &c_o_direct); Uint32 tmp= 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_FRAG, &tmp)); @@ -13243,7 +13245,9 @@ void Dblqh::openFileRw(Signal* signal, LogFileRecordPtr olfLogFilePtr) signal->theData[3] = olfLogFilePtr.p->fileName[1]; signal->theData[4] = olfLogFilePtr.p->fileName[2]; signal->theData[5] = olfLogFilePtr.p->fileName[3]; - signal->theData[6] = ZOPEN_READ_WRITE | FsOpenReq::OM_AUTOSYNC; + signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_AUTOSYNC; + if (c_o_direct) + signal->theData[6] |= FsOpenReq::OM_DIRECT; req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord); sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA); }//Dblqh::openFileRw() @@ -13263,7 +13267,9 @@ void Dblqh::openLogfileInit(Signal* signal) signal->theData[3] = logFilePtr.p->fileName[1]; signal->theData[4] = logFilePtr.p->fileName[2]; signal->theData[5] = logFilePtr.p->fileName[3]; - signal->theData[6] = 0x302 | FsOpenReq::OM_AUTOSYNC; + signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_TRUNCATE | FsOpenReq::OM_CREATE | FsOpenReq::OM_AUTOSYNC; + if (c_o_direct) + signal->theData[6] |= FsOpenReq::OM_DIRECT; req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord); sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA); }//Dblqh::openLogfileInit() @@ -13299,7 +13305,9 @@ void Dblqh::openNextLogfile(Signal* signal) signal->theData[3] = onlLogFilePtr.p->fileName[1]; signal->theData[4] = onlLogFilePtr.p->fileName[2]; signal->theData[5] = onlLogFilePtr.p->fileName[3]; - signal->theData[6] = 2 | FsOpenReq::OM_AUTOSYNC; + signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_AUTOSYNC; + if (c_o_direct) + signal->theData[6] |= FsOpenReq::OM_DIRECT; req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord); sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA); }//if diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index 5f93ee31bc7..cf18bf34040 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -163,7 +163,12 @@ AsyncFile::run() theStartFlag = true; // Create write buffer for bigger writes theWriteBufferSize = WRITEBUFFERSIZE; - theWriteBuffer = (char *) ndbd_malloc(theWriteBufferSize); + theWriteBufferUnaligned = (char *) ndbd_malloc(theWriteBufferSize + + NDB_O_DIRECT_WRITE_ALIGNMENT-1); + theWriteBuffer = (char *) + (((UintPtr)theWriteBufferUnaligned + NDB_O_DIRECT_WRITE_ALIGNMENT - 1) & + ~(UintPtr)(NDB_O_DIRECT_WRITE_ALIGNMENT - 1)); + NdbMutex_Unlock(theStartMutexPtr); NdbCondition_Signal(theStartConditionPtr); @@ -247,6 +252,78 @@ AsyncFile::run() static char g_odirect_readbuf[2*GLOBAL_PAGE_SIZE -1]; #endif +int +AsyncFile::check_odirect_write(Uint32 flags, int& new_flags, int mode) +{ + assert(new_flags & (O_CREAT | O_TRUNC)); +#ifdef O_DIRECT + int ret; + char * bufptr = (char*)((UintPtr(g_odirect_readbuf)+(GLOBAL_PAGE_SIZE - 1)) & ~(GLOBAL_PAGE_SIZE - 1)); + while (((ret = ::write(theFd, bufptr, GLOBAL_PAGE_SIZE)) == -1) && + (errno == EINTR)); + if (ret == -1) + { + new_flags &= ~O_DIRECT; + ndbout_c("%s Failed to write using O_DIRECT, disabling", + theFileName.c_str()); + } + + close(theFd); + theFd = ::open(theFileName.c_str(), new_flags, mode); + if (theFd == -1) + return errno; +#endif + + return 0; +} + +int +AsyncFile::check_odirect_read(Uint32 flags, int &new_flags, int mode) +{ +#ifdef O_DIRECT + int ret; + char * bufptr = (char*)((UintPtr(g_odirect_readbuf)+(GLOBAL_PAGE_SIZE - 1)) & ~(GLOBAL_PAGE_SIZE - 1)); + while (((ret = ::read(theFd, bufptr, GLOBAL_PAGE_SIZE)) == -1) && + (errno == EINTR)); + if (ret == -1) + { + ndbout_c("%s Failed to read using O_DIRECT, disabling", + theFileName.c_str()); + goto reopen; + } + + if(lseek(theFd, 0, SEEK_SET) != 0) + { + return errno; + } + + if ((flags & FsOpenReq::OM_CHECK_SIZE) == 0) + { + struct stat buf; + if ((fstat(theFd, &buf) == -1)) + { + return errno; + } + else if ((buf.st_size % GLOBAL_PAGE_SIZE) != 0) + { + ndbout_c("%s filesize not a multiple of %d, disabling O_DIRECT", + theFileName.c_str(), GLOBAL_PAGE_SIZE); + goto reopen; + } + } + + return 0; + +reopen: + close(theFd); + new_flags &= ~O_DIRECT; + theFd = ::open(theFileName.c_str(), new_flags, mode); + if (theFd == -1) + return errno; +#endif + return 0; +} + void AsyncFile::openReq(Request* request) { m_auto_sync_freq = 0; @@ -312,7 +389,7 @@ void AsyncFile::openReq(Request* request) } #else Uint32 flags = request->par.open.flags; - Uint32 new_flags = 0; + int new_flags = 0; // Convert file open flags from Solaris to Liux if (flags & FsOpenReq::OM_CREATE) @@ -343,10 +420,6 @@ void AsyncFile::openReq(Request* request) { new_flags |= O_DIRECT; } -#elif defined O_SYNC - { - flags |= FsOpenReq::OM_SYNC; - } #endif if ((flags & FsOpenReq::OM_SYNC) && ! (flags & FsOpenReq::OM_INIT)) @@ -355,15 +428,19 @@ void AsyncFile::openReq(Request* request) new_flags |= O_SYNC; #endif } - + + const char * rw = ""; switch(flags & 0x3){ case FsOpenReq::OM_READONLY: + rw = "r"; new_flags |= O_RDONLY; break; case FsOpenReq::OM_WRITEONLY: + rw = "w"; new_flags |= O_WRONLY; break; case FsOpenReq::OM_READWRITE: + rw = "rw"; new_flags |= O_RDWR; break; default: @@ -404,11 +481,6 @@ no_odirect: if (new_flags & O_DIRECT) { new_flags &= ~O_DIRECT; - flags |= FsOpenReq::OM_SYNC; -#ifdef O_SYNC - if (! (flags & FsOpenReq::OM_INIT)) - new_flags |= O_SYNC; -#endif goto no_odirect; } #endif @@ -421,11 +493,6 @@ no_odirect: else if (new_flags & O_DIRECT) { new_flags &= ~O_DIRECT; - flags |= FsOpenReq::OM_SYNC; -#ifdef O_SYNC - if (! (flags & FsOpenReq::OM_INIT)) - new_flags |= O_SYNC; -#endif goto no_odirect; } #endif @@ -512,7 +579,6 @@ no_odirect: { ndbout_c("error on first write(%d), disable O_DIRECT", err); new_flags &= ~O_DIRECT; - flags |= FsOpenReq::OM_SYNC; close(theFd); theFd = ::open(theFileName.c_str(), new_flags, mode); if (theFd != -1) @@ -532,26 +598,32 @@ no_odirect: else if (flags & FsOpenReq::OM_DIRECT) { #ifdef O_DIRECT - do { - int ret; - char * bufptr = (char*)((UintPtr(g_odirect_readbuf)+(GLOBAL_PAGE_SIZE - 1)) & ~(GLOBAL_PAGE_SIZE - 1)); - while (((ret = ::read(theFd, bufptr, GLOBAL_PAGE_SIZE)) == -1) && (errno == EINTR)); - if (ret == -1) - { - ndbout_c("%s Failed to read using O_DIRECT, disabling", theFileName.c_str()); - flags |= FsOpenReq::OM_SYNC; - flags |= FsOpenReq::OM_INIT; - break; - } - if(lseek(theFd, 0, SEEK_SET) != 0) - { - request->error = errno; - return; - } - } while (0); + if (flags & (FsOpenReq::OM_TRUNCATE | FsOpenReq::OM_CREATE)) + { + request->error = check_odirect_write(flags, new_flags, mode); + } + else + { + request->error = check_odirect_read(flags, new_flags, mode); + } + + if (request->error) + return; #endif } - +#ifdef VM_TRACE + if (flags & FsOpenReq::OM_DIRECT) + { +#ifdef O_DIRECT + ndbout_c("%s %s O_DIRECT: %d", + theFileName.c_str(), rw, + !!(new_flags & O_DIRECT)); +#else + ndbout_c("%s %s O_DIRECT: 0", + theFileName.c_str(), rw); +#endif + } +#endif if ((flags & FsOpenReq::OM_SYNC) && (flags & FsOpenReq::OM_INIT)) { #ifdef O_SYNC @@ -562,6 +634,10 @@ no_odirect: new_flags &= ~(O_CREAT | O_TRUNC); new_flags |= O_SYNC; theFd = ::open(theFileName.c_str(), new_flags, mode); + if (theFd == -1) + { + request->error = errno; + } #endif } #endif @@ -1079,7 +1155,8 @@ AsyncFile::rmrfReq(Request * request, char * path, bool removePath){ void AsyncFile::endReq() { // Thread is ended with return - if (theWriteBuffer) ndbd_free(theWriteBuffer, theWriteBufferSize); + if (theWriteBufferUnaligned) + ndbd_free(theWriteBufferUnaligned, theWriteBufferSize); } diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp index e8f2deb016c..64567dd2bb8 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp @@ -232,9 +232,13 @@ private: bool theStartFlag; int theWriteBufferSize; char* theWriteBuffer; + void* theWriteBufferUnaligned; size_t m_write_wo_sync; // Writes wo/ sync size_t m_auto_sync_freq; // Auto sync freq in bytes + + int check_odirect_read(Uint32 flags, int&new_flags, int mode); + int check_odirect_write(Uint32 flags, int&new_flags, int mode); public: SimulatedBlock& m_fs; Ptr m_page_ptr; diff --git a/storage/ndb/src/kernel/blocks/restore.cpp b/storage/ndb/src/kernel/blocks/restore.cpp index 51644ef0712..2c204b912b1 100644 --- a/storage/ndb/src/kernel/blocks/restore.cpp +++ b/storage/ndb/src/kernel/blocks/restore.cpp @@ -559,6 +559,9 @@ Restore::restore_next(Signal* signal, FilePtr file_ptr) case BackupFormat::GCP_ENTRY: parse_gcp_entry(signal, file_ptr, data, len); break; + case BackupFormat::EMPTY_ENTRY: + // skip + break; case 0x4e444242: // 'NDBB' if (check_file_version(signal, ntohl(* (data+2))) == 0) { diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp index 1ba7368c352..7ad1d486a02 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -39,6 +39,9 @@ #include #include +#include +extern EventLogger g_eventLogger; + #define ljamEntry() jamEntryLine(30000 + __LINE__) #define ljam() jamLine(30000 + __LINE__) @@ -656,13 +659,19 @@ SimulatedBlock::getBatSize(Uint16 blockNo){ return sb->theBATSize; } +void* SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, Uint32 paramId) +{ + return allocRecordAligned(type, s, n, 0, 0, clear, paramId); +} + void* -SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, Uint32 paramId) +SimulatedBlock::allocRecordAligned(const char * type, size_t s, size_t n, void **unaligned_buffer, Uint32 align, bool clear, Uint32 paramId) { void * p = NULL; - size_t size = n*s; - Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s); + Uint32 over_alloc = unaligned_buffer ? (align - 1) : 0; + size_t size = n*s + over_alloc; + Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s) + over_alloc; refresh_watch_dog(9); if (real_size > 0){ #ifdef VM_TRACE_MEM @@ -705,6 +714,16 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U refresh_watch_dog(9); memset(ptr, 0, size); } + if (unaligned_buffer) + { + *unaligned_buffer = p; + p = (void *)(((UintPtr)p + over_alloc) & ~(UintPtr)(over_alloc)); +#ifdef VM_TRACE + g_eventLogger.info("'%s' (%u) %llu %llu, alignment correction %u bytes", + type, align, (Uint64)p, (Uint64)p+n*s, + (Uint32)((UintPtr)p - (UintPtr)*unaligned_buffer)); +#endif + } } return p; } diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp index 01fb11e05e8..86e26986f93 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -378,6 +378,7 @@ protected: * */ void* allocRecord(const char * type, size_t s, size_t n, bool clear = true, Uint32 paramId = 0); + void* allocRecordAligned(const char * type, size_t s, size_t n, void **unaligned_buffer, Uint32 align = NDB_O_DIRECT_WRITE_ALIGNMENT, bool clear = true, Uint32 paramId = 0); /** * Deallocate record diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index 3e76071a0db..d96942bbfb7 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -1313,6 +1313,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "0", STR_VALUE(MAX_INT_RNIL) }, + { + CFG_DB_O_DIRECT, + "ODirect", + DB_TOKEN, + "Use O_DIRECT file write/read when possible", + ConfigInfo::CI_USED, + true, + ConfigInfo::CI_BOOL, + "false", + "false", + "true"}, + /*************************************************************************** * API ***************************************************************************/ diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp index 3d466384782..15e442a4f35 100644 --- a/storage/ndb/tools/restore/Restore.cpp +++ b/storage/ndb/tools/restore/Restore.cpp @@ -867,13 +867,32 @@ bool RestoreDataIterator::readFragmentHeader(int & ret, Uint32 *fragmentId) debug << "RestoreDataIterator::getNextFragment" << endl; - if (buffer_read(&Header, sizeof(Header), 1) != 1){ + while (1) + { + /* read first part of header */ + if (buffer_read(&Header, 8, 1) != 1) + { + ret = 0; + return false; + } // if + + /* skip if EMPTY_ENTRY */ + Header.SectionType = ntohl(Header.SectionType); + Header.SectionLength = ntohl(Header.SectionLength); + if (Header.SectionType == BackupFormat::EMPTY_ENTRY) + { + void *tmp; + buffer_get_ptr(&tmp, Header.SectionLength*4-8, 1); + continue; + } + break; + } + /* read rest of header */ + if (buffer_read(((char*)&Header)+8, sizeof(Header)-8, 1) != 1) + { ret = 0; return false; - } // if - - Header.SectionType = ntohl(Header.SectionType); - Header.SectionLength = ntohl(Header.SectionLength); + } Header.TableId = ntohl(Header.TableId); Header.FragmentNo = ntohl(Header.FragmentNo); Header.ChecksumType = ntohl(Header.ChecksumType); From 0304a13ee7140727786adf4feb5e1639e85e8138 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 00:25:06 +0400 Subject: [PATCH 060/156] Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. This bug is introduced by the fix for bug#16377. Before the fix the Item_func_between::fix_length_and_dec method converted the second and third arguments to the type of the first argument if they were constant and the first argument is of the DATE/DATETIME type. That approach worked well for integer constants and sometimes produced bad result for string constants. The fix for the bug#16377 wrongly removed that code at all and as a result of this the comparison of a DATETIME field and an integer constant was carried out in a wrong way and sometimes led to wrong result sets. Now the Item_func_between::fix_length_and_dec method converts the second and third arguments to the type of the first argument if they are constant, the first argument is of the DATE/DATETIME type and the DATETIME comparator isn't applicable. sql/item_cmpfunc.cc: Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. Now the Item_func_between::fix_length_and_dec method converts the second and third arguments to the type of the first argument if they are constant, the first argument is of the DATE/DATETIME type and the DATETIME comparator isn't applicable. mysql-test/r/type_datetime.result: Added a test case for the bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. mysql-test/t/type_datetime.test: Added a test case for the bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an integer constants. --- mysql-test/r/type_datetime.result | 16 ++++++++++++++++ mysql-test/t/type_datetime.test | 11 +++++++++++ sql/item_cmpfunc.cc | 17 +++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index ba02f19712a..9e47b5da2b6 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -411,3 +411,19 @@ if(@bug28261 = f1, '', @bug28261:= f1) 2001-01-01 2002-02-02 drop table t1; +create table t1(f1 datetime); +insert into t1 values('2001-01-01'),('2002-02-02'); +select * from t1 where f1 between 20020101 and 20070101000000; +f1 +2002-02-02 00:00:00 +select * from t1 where f1 between 2002010 and 20070101000000; +f1 +2001-01-01 00:00:00 +2002-02-02 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1 +select * from t1 where f1 between 20020101 and 2007010100000; +f1 +Warnings: +Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 +drop table t1; diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index d420afbde37..ffda593f320 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -271,3 +271,14 @@ select if(@bug28261 = f1, '', @bug28261:= f1) from t1; select if(@bug28261 = f1, '', @bug28261:= f1) from t1; select if(@bug28261 = f1, '', @bug28261:= f1) from t1; drop table t1; + +# +# Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an +# integer constants. +# +create table t1(f1 datetime); +insert into t1 values('2001-01-01'),('2002-02-02'); +select * from t1 where f1 between 20020101 and 20070101000000; +select * from t1 where f1 between 2002010 and 20070101000000; +select * from t1 where f1 between 20020101 and 2007010100000; +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 06c825334c2..919015140c1 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1755,6 +1755,23 @@ void Item_func_between::fix_length_and_dec() ge_cmp.set_datetime_cmp_func(args, args + 1); le_cmp.set_datetime_cmp_func(args, args + 2); } + else if (args[0]->real_item()->type() == FIELD_ITEM && + thd->lex->sql_command != SQLCOM_CREATE_VIEW && + thd->lex->sql_command != SQLCOM_SHOW_CREATE) + { + Field *field=((Item_field*) (args[0]->real_item()))->field; + if (field->can_be_compared_as_longlong()) + { + /* + The following can't be recoded with || as convert_constant_item + changes the argument + */ + if (convert_constant_item(thd, field,&args[1])) + cmp_type=INT_RESULT; // Works for all types. + if (convert_constant_item(thd, field,&args[2])) + cmp_type=INT_RESULT; // Works for all types. + } + } } From 55c765925d4723c1702d84aef8f305cd97691fea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 04:42:41 +0500 Subject: [PATCH 061/156] BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Underlying table names, that merge engine fails to open were not reported. With this fix CHECK TABLE issued against merge table reports all underlying table names that it fails to open. Other statements are unaffected, that is underlying table names are not included into error message. This fix doesn't solve SHOW CREATE TABLE issue. myisammrg/myrg_def.h: Added myrg_print_wrong_table declaration. myisammrg/myrg_open.c: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. mysql-test/r/backup.result: Updated test result. mysql-test/r/key_cache.result: Updated test result - removed duplicate error. mysql-test/r/lock.result: Updated test result - added summary row. mysql-test/r/merge.result: A test case for BUG#26976. mysql-test/r/preload.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/ps.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/repair.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/rpl_failed_optimize.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/sp.result: Updated test result - removed duplicate error, added summary row. mysql-test/r/view.result: Updated test result - removed duplicate error, added summary row. mysql-test/t/merge.test: A test case for BUG#26976. sql/ha_myisam.cc: Do not report same error twice. sql/ha_myisammrg.cc: If HA_OPEN_FOR_REPAIR is passed to merge engine open function, report names of tables that we fail to open. Added dummy ha_myisammrg::check to not confuse users with "not implemented" error in case all underlying tables are fine. sql/ha_myisammrg.h: Added ha_myisammrg::check declaration. sql/share/errmsg.txt: Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is passed to merge engine handler open function. sql/sql_error.cc: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_error.h: warning_level_* are now public. It is required by mysql_admin_table to report message level. sql/sql_table.cc: Reorder mysql_admin_table arguments to meet it's definition. Report errors that are pending in thd->warn_list as results of admin function. --- myisammrg/myrg_def.h | 5 ++- myisammrg/myrg_open.c | 12 +++++ mysql-test/r/backup.result | 6 +-- mysql-test/r/key_cache.result | 4 +- mysql-test/r/lock.result | 3 +- mysql-test/r/merge.result | 32 ++++++++++++++ mysql-test/r/preload.result | 13 +++--- mysql-test/r/ps.result | 30 +++++-------- mysql-test/r/repair.result | 10 ++--- mysql-test/r/rpl_failed_optimize.result | 5 +-- mysql-test/r/sp.result | 33 +++++++------- mysql-test/r/view.result | 58 ++++++++++++++----------- mysql-test/t/merge.test | 21 +++++++++ sql/ha_myisam.cc | 21 +++++---- sql/ha_myisammrg.cc | 26 ++++++++++- sql/ha_myisammrg.h | 1 + sql/share/errmsg.txt | 3 +- sql/sql_error.cc | 4 +- sql/sql_error.h | 2 + sql/sql_table.cc | 49 ++++++++++----------- 20 files changed, 213 insertions(+), 125 deletions(-) diff --git a/myisammrg/myrg_def.h b/myisammrg/myrg_def.h index 344bd4edd3c..bc114523a80 100644 --- a/myisammrg/myrg_def.h +++ b/myisammrg/myrg_def.h @@ -29,4 +29,7 @@ extern pthread_mutex_t THR_LOCK_open; int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); int _myrg_mi_read_record(MI_INFO *info, byte *buf); - +#ifdef __cplusplus +extern "C" +#endif +void myrg_print_wrong_table(const char *table_name); diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index afab21dfa3d..0e82e429afd 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -90,6 +90,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) { my_errno= HA_ERR_WRONG_MRG_TABLE_DEF; + if (handle_locking & HA_OPEN_FOR_REPAIR) + { + myrg_print_wrong_table(buff); + continue; + } goto err; } if (!m_info) /* First file */ @@ -118,6 +123,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if (m_info->reclength != isam->s->base.reclength) { my_errno=HA_ERR_WRONG_MRG_TABLE_DEF; + if (handle_locking & HA_OPEN_FOR_REPAIR) + { + myrg_print_wrong_table(buff); + continue; + } goto err; } m_info->options|= isam->s->options; @@ -131,6 +141,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) m_info->tables); } + if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF) + goto err; if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), MYF(MY_WME | MY_ZEROFILL)))) goto err; diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index 29702e583cc..14313ba490f 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -4,18 +4,16 @@ create table t4(n int); backup table t4 to '../bogus'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) test.t4 backup status Operation failed -Warnings: -Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup status OK backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) test.t4 backup status Operation failed -Warnings: -Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) drop table t4; restore table t4 from '../tmp'; Table Op Msg_type Msg_text diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 1ab58c1ad6c..08d8059f61b 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -191,10 +191,8 @@ cache index t1 in unknown_key_cache; ERROR HY000: Unknown key cache 'unknown_key_cache' cache index t1 key (unknown_key) in keycache1; Table Op Msg_type Msg_text -test.t1 assign_to_keycache error Key 'unknown_key' doesn't exist in table 't1' +test.t1 assign_to_keycache Error Key 'unknown_key' doesn't exist in table 't1' test.t1 assign_to_keycache status Operation failed -Warnings: -Error 1176 Key 'unknown_key' doesn't exist in table 't1' select @@keycache2.key_buffer_size; @@keycache2.key_buffer_size 4194304 diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 079b0253ff6..a5a78ecc986 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -40,7 +40,8 @@ test.t1 check status OK lock tables t1 write; check table t2; Table Op Msg_type Msg_text -test.t2 check error Table 't2' was not locked with LOCK TABLES +test.t2 check Error Table 't2' was not locked with LOCK TABLES +test.t2 check error Corrupt insert into t1 select index1,nr from t1; ERROR HY000: Table 't1' was not locked with LOCK TABLES unlock tables; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 27465dd96f6..9f7d5f54d0e 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -844,4 +844,36 @@ insert into t1 values (1); ERROR HY000: Table 't1' is read only drop table t2; drop table t1; +CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2); +SELECT * FROM tm1; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +CHECK TABLE tm1; +Table Op Msg_type Msg_text +test.tm1 check Error Table './test/t1' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check error Corrupt +CREATE TABLE t1(a INT); +SELECT * FROM tm1; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +CHECK TABLE tm1; +Table Op Msg_type Msg_text +test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check error Corrupt +CREATE TABLE t2(a BLOB); +SELECT * FROM tm1; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +CHECK TABLE tm1; +Table Op Msg_type Msg_text +test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check error Corrupt +ALTER TABLE t2 MODIFY a INT; +SELECT * FROM tm1; +a +CHECK TABLE tm1; +Table Op Msg_type Msg_text +test.tm1 check status OK +DROP TABLE tm1, t1, t2; End of 5.0 tests diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result index 145fd22ffb6..24a6e594a14 100644 --- a/mysql-test/r/preload.result +++ b/mysql-test/r/preload.result @@ -143,10 +143,9 @@ Key_read_requests 0 Key_reads 0 load index into cache t3, t2 key (primary,b) ; Table Op Msg_type Msg_text -test.t3 preload_keys error Table 'test.t3' doesn't exist +test.t3 preload_keys Error Table 'test.t3' doesn't exist +test.t3 preload_keys error Corrupt test.t2 preload_keys status OK -Warnings: -Error 1146 Table 'test.t3' doesn't exist show status like "key_read%"; Variable_name Value Key_read_requests 478 @@ -159,12 +158,10 @@ Key_read_requests 0 Key_reads 0 load index into cache t3 key (b), t2 key (c) ; Table Op Msg_type Msg_text -test.t3 preload_keys error Table 'test.t3' doesn't exist -test.t2 preload_keys error Key 'c' doesn't exist in table 't2' +test.t3 preload_keys Error Table 'test.t3' doesn't exist +test.t3 preload_keys error Corrupt +test.t2 preload_keys Error Key 'c' doesn't exist in table 't2' test.t2 preload_keys status Operation failed -Warnings: -Error 1146 Table 'test.t3' doesn't exist -Error 1176 Key 'c' doesn't exist in table 't2' show status like "key_read%"; Variable_name Value Key_read_requests 0 diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 8a10a52ee65..fcf532320e0 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1378,45 +1378,39 @@ prepare stmt from "repair table t1, t4, t3"; execute stmt; Table Op Msg_type Msg_text test.t1 repair status OK -test.t4 repair error Table 'test.t4' doesn't exist +test.t4 repair Error Table 'test.t4' doesn't exist +test.t4 repair error Corrupt test.t3 repair status OK -Warnings: -Error 1146 Table 'test.t4' doesn't exist execute stmt; Table Op Msg_type Msg_text test.t1 repair status OK -test.t4 repair error Table 'test.t4' doesn't exist +test.t4 repair Error Table 'test.t4' doesn't exist +test.t4 repair error Corrupt test.t3 repair status OK -Warnings: -Error 1146 Table 'test.t4' doesn't exist prepare stmt from "optimize table t1, t3, t4"; execute stmt; Table Op Msg_type Msg_text test.t1 optimize status OK test.t3 optimize status OK -test.t4 optimize error Table 'test.t4' doesn't exist -Warnings: -Error 1146 Table 'test.t4' doesn't exist +test.t4 optimize Error Table 'test.t4' doesn't exist +test.t4 optimize error Corrupt execute stmt; Table Op Msg_type Msg_text test.t1 optimize status Table is already up to date test.t3 optimize status Table is already up to date -test.t4 optimize error Table 'test.t4' doesn't exist -Warnings: -Error 1146 Table 'test.t4' doesn't exist +test.t4 optimize Error Table 'test.t4' doesn't exist +test.t4 optimize error Corrupt prepare stmt from "analyze table t4, t1"; execute stmt; Table Op Msg_type Msg_text -test.t4 analyze error Table 'test.t4' doesn't exist +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze error Corrupt test.t1 analyze status Table is already up to date -Warnings: -Error 1146 Table 'test.t4' doesn't exist execute stmt; Table Op Msg_type Msg_text -test.t4 analyze error Table 'test.t4' doesn't exist +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze error Corrupt test.t1 analyze status Table is already up to date -Warnings: -Error 1146 Table 'test.t4' doesn't exist deallocate prepare stmt; drop table t1, t2, t3; create database mysqltest_long_database_name_to_thrash_heap; diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 417a5e0c990..bd746711f1f 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -26,16 +26,14 @@ t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled drop table t1; repair table t1 use_frm; Table Op Msg_type Msg_text -test.t1 repair error Table 'test.t1' doesn't exist -Warnings: -Error 1146 Table 'test.t1' doesn't exist +test.t1 repair Error Table 'test.t1' doesn't exist +test.t1 repair error Corrupt create table t1 engine=myisam SELECT 1,"table 1"; flush tables; repair table t1; Table Op Msg_type Msg_text -test.t1 repair error Incorrect file format 't1' -Warnings: -Error 130 Incorrect file format 't1' +test.t1 repair Error Incorrect file format 't1' +test.t1 repair error Corrupt repair table t1 use_frm; Table Op Msg_type Msg_text test.t1 repair warning Number of rows changed from 0 to 1 diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result index c2c07dc6343..33a8cdc4a2f 100644 --- a/mysql-test/r/rpl_failed_optimize.result +++ b/mysql-test/r/rpl_failed_optimize.result @@ -15,7 +15,6 @@ Warnings: Error 1205 Lock wait timeout exceeded; try restarting transaction OPTIMIZE TABLE non_existing; Table Op Msg_type Msg_text -test.non_existing optimize error Table 'test.non_existing' doesn't exist -Warnings: -Error 1146 Table 'test.non_existing' doesn't exist +test.non_existing optimize Error Table 'test.non_existing' doesn't exist +test.non_existing optimize error Corrupt drop table t1; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index b5b79af031e..558a34e5ab6 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4409,55 +4409,58 @@ Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt drop procedure bug13012| drop view v1; select * from t1| diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 8d9d802949d..f1aa4e64179 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1377,7 +1377,9 @@ test.t1 check status OK drop table t1; check table v1; Table Op Msg_type Msg_text -test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check Error Table 'test.t1' doesn't exist +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt drop view v1; create table t1 (a int); create table t2 (a int); @@ -1901,11 +1903,17 @@ CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; DROP TABLE t1; CHECK TABLE v1, v2, v3, v4, v5, v6; Table Op Msg_type Msg_text -test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check Error Table 'test.t1' doesn't exist +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt test.v2 check status OK -test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check Error Table 'test.t1' doesn't exist +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check error Corrupt test.v4 check status OK -test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check Error Table 'test.t1' doesn't exist +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check error Corrupt test.v6 check status OK drop view v1, v2, v3, v4, v5, v6; drop table t2; @@ -1925,11 +1933,17 @@ CREATE VIEW v6 AS SELECT f2() FROM t3; drop function f1; CHECK TABLE v1, v2, v3, v4, v5, v6; Table Op Msg_type Msg_text -test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check Error FUNCTION test.f1 does not exist +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt test.v2 check status OK -test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check Error FUNCTION test.f1 does not exist +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check error Corrupt test.v4 check status OK -test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check Error FUNCTION test.f1 does not exist +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check error Corrupt test.v6 check status OK create function f1 () returns int return (select max(col1) from t1); DROP TABLE t1; @@ -2376,35 +2390,29 @@ CREATE TABLE t1(id INT); CREATE VIEW v1 AS SELECT id FROM t1; OPTIMIZE TABLE v1; Table Op Msg_type Msg_text -test.v1 optimize error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt ANALYZE TABLE v1; Table Op Msg_type Msg_text -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt REPAIR TABLE v1; Table Op Msg_type Msg_text -test.v1 repair error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt DROP TABLE t1; OPTIMIZE TABLE v1; Table Op Msg_type Msg_text -test.v1 optimize error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt ANALYZE TABLE v1; Table Op Msg_type Msg_text -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt REPAIR TABLE v1; Table Op Msg_type Msg_text -test.v1 repair error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt DROP VIEW v1; create definer = current_user() sql security invoker view v1 as select 1; show create view v1; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index b3944416adc..c3e5cef5e63 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -486,4 +486,25 @@ insert into t1 values (1); drop table t2; drop table t1; +# +# BUG#26976 - Missing table in merge not noted in related error msg + SHOW +# CREATE TABLE fails +# +CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2); +--error 1168 +SELECT * FROM tm1; +CHECK TABLE tm1; +CREATE TABLE t1(a INT); +--error 1168 +SELECT * FROM tm1; +CHECK TABLE tm1; +CREATE TABLE t2(a BLOB); +--error 1168 +SELECT * FROM tm1; +CHECK TABLE tm1; +ALTER TABLE t2 MODIFY a INT; +SELECT * FROM tm1; +CHECK TABLE tm1; +DROP TABLE tm1, t1, t2; + --echo End of 5.0 tests diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 9a397ffbbac..5e953092436 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -109,6 +109,14 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, } length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - name); + /* + TODO: switch from protocol to push_warning here. The main reason we didn't + it yet is parallel repair. Due to following trace: + mi_check_print_msg/push_warning/sql_alloc/my_pthread_getspecific_ptr. + + Also we likely need to lock mutex here (in both cases with protocol and + push_warning). + */ protocol->prepare_for_resend(); protocol->store(name, length, system_charset_info); protocol->store(param->op_name, system_charset_info); @@ -1138,11 +1146,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) /* We only come here when the user did specify an index map */ key_map kmap; if (get_key_map_from_key_list(&kmap, table, table_list->use_index)) - { - errmsg= thd->net.last_error; - error= HA_ADMIN_FAILED; - goto err; - } + DBUG_RETURN(HA_ADMIN_FAILED); map= kmap.to_ulonglong(); } @@ -1155,7 +1159,6 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) error= HA_ADMIN_CORRUPT; } - err: if (error != HA_ADMIN_OK) { /* Send error to user */ @@ -1192,11 +1195,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) key_map kmap; get_key_map_from_key_list(&kmap, table, table_list->use_index); if (kmap.is_set_all()) - { - errmsg= thd->net.last_error; - error= HA_ADMIN_FAILED; - goto err; - } + DBUG_RETURN(HA_ADMIN_FAILED); if (!kmap.is_clear_all()) map= kmap.to_ulonglong(); } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 1202a733a16..e7baa6705ee 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -72,6 +72,13 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, uint t2_keys, uint t2_recs, bool strict); +extern "C" void myrg_print_wrong_table(const char *table_name) +{ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE), + table_name); +} + const char **ha_myisammrg::bas_ext() const { @@ -121,6 +128,8 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu", table->s->reclength, mean_rec_length)); + if (test_if_locked & HA_OPEN_FOR_REPAIR) + myrg_print_wrong_table(file->open_tables->table->filename); error= HA_ERR_WRONG_MRG_TABLE_DEF; goto err; } @@ -139,12 +148,19 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) u_table->table->s->base.keys, u_table->table->s->base.fields, false)) { - my_free((gptr) recinfo, MYF(0)); error= HA_ERR_WRONG_MRG_TABLE_DEF; - goto err; + if (test_if_locked & HA_OPEN_FOR_REPAIR) + myrg_print_wrong_table(u_table->table->filename); + else + { + my_free((gptr) recinfo, MYF(0)); + goto err; + } } } my_free((gptr) recinfo, MYF(0)); + if (error == HA_ERR_WRONG_MRG_TABLE_DEF) + goto err; #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 /* Merge table has more than 2G rows */ if (table->s->crashed) @@ -597,3 +613,9 @@ void ha_myisammrg::append_create_info(String *packet) } packet->append(')'); } + + +int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt) +{ + return HA_ADMIN_OK; +} diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index 16c734e2682..2ba5b6b551e 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -81,4 +81,5 @@ class ha_myisammrg: public handler void update_create_info(HA_CREATE_INFO *create_info); void append_create_info(String *packet); MYRG_INFO *myrg_info() { return file; } + int check(THD* thd, HA_CHECK_OPT* check_opt); }; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 1230287656e..a52ffa8216c 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5633,4 +5633,5 @@ ER_WRONG_STRING_LENGTH eng "String '%-.70s' is too long for %s (should be no longer than %d)" ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" - +ER_ADMIN_WRONG_MRG_TABLE + eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 61a7581908c..a25c82c7721 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -205,8 +205,8 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, TRUE Error sending data to client */ -static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; -static int warning_level_length[]= { 4, 7, 5, 1 }; +const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; +int warning_level_length[]= { 4, 7, 5, 1 }; bool mysqld_show_warnings(THD *thd, ulong levels_to_show) { diff --git a/sql/sql_error.h b/sql/sql_error.h index 28d946f14f8..4dbf3ada8f0 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -39,3 +39,5 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *format, ...); void mysql_reset_errors(THD *thd, bool force); bool mysqld_show_warnings(THD *thd, ulong levels_to_show); +extern const char *warning_level_names[]; +extern int warning_level_length[]; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 079cc0d6456..2456c3818a2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2283,33 +2283,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, */ if (!table->table) { - char buf[ERRMSGSIZE+ERRMSGSIZE+2]; - const char *err_msg; - protocol->prepare_for_resend(); - protocol->store(table_name, system_charset_info); - protocol->store(operator_name, system_charset_info); - protocol->store(STRING_WITH_LEN("error"), system_charset_info); - if (!(err_msg=thd->net.last_error)) - err_msg=ER(ER_CHECK_NO_SUCH_TABLE); + if (!thd->warn_list.elements) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE)); /* if it was a view will check md5 sum */ if (table->view && view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM) - { - strxmov(buf, err_msg, "; ", ER(ER_VIEW_CHECKSUM), NullS); - err_msg= (const char *)buf; - } - protocol->store(err_msg, system_charset_info); - lex->cleanup_after_one_table_open(); - thd->clear_error(); - /* - View opening can be interrupted in the middle of process so some - tables can be left opening - */ - close_thread_tables(thd); - lex->reset_query_tables_list(FALSE); - if (protocol->write()) - goto err; - continue; + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM)); + result_code= HA_ADMIN_CORRUPT; + goto send_result; } if (table->view) @@ -2391,6 +2374,22 @@ send_result: lex->cleanup_after_one_table_open(); thd->clear_error(); // these errors shouldn't get client + { + List_iterator_fast it(thd->warn_list); + MYSQL_ERROR *err; + while ((err= it++)) + { + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + protocol->store((char*) operator_name, system_charset_info); + protocol->store(warning_level_names[err->level], + warning_level_length[err->level], system_charset_info); + protocol->store(err->msg, system_charset_info); + if (protocol->write()) + goto err; + } + mysql_reset_errors(thd, true); + } protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store(operator_name, system_charset_info); @@ -2924,7 +2923,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) DBUG_ENTER("mysql_check_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, "check", lock_type, - 0, HA_OPEN_FOR_REPAIR, 0, 0, + 0, 0, HA_OPEN_FOR_REPAIR, 0, &handler::ha_check, &view_checksum)); } From a6f7f8a4fd760b84e6e43afb088a1bf58946e4f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 14:23:56 +0500 Subject: [PATCH 062/156] merging fix --- sql/sql_table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 64c8781d766..04e0fd70ece 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1262,7 +1262,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) { share->partition_info_buffer_size= syntax_len+1; if (!(share->partition_info= - alloc_root(&share->mem_root, syntax_len+1))) + (char*) alloc_root(&share->mem_root, syntax_len+1))) DBUG_RETURN(TRUE); } From 64255a3787fada258c6a7ee2027fb6b121832edc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 15:59:20 +0500 Subject: [PATCH 063/156] Bug#28580 Repeatation of status variables removed duplicated variable declarations mysql-test/r/variables.result: test result mysql-test/t/variables.test: test case sql/set_var.cc: removed duplicated variable declarations --- mysql-test/r/variables.result | 5 +++++ mysql-test/t/variables.test | 6 ++++++ sql/set_var.cc | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index e3368a4aeab..ff43993cfdb 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -970,3 +970,8 @@ set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; +show global variables where Variable_name='table_definition_cache' or +Variable_name='table_lock_wait_timeout'; +Variable_name Value +table_definition_cache # +table_lock_wait_timeout # diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 645a4d29633..efa2ce4a27c 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -760,3 +760,9 @@ set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; +# +# Bug#28580 Repeatation of status variables +# +--replace_column 2 # +show global variables where Variable_name='table_definition_cache' or +Variable_name='table_lock_wait_timeout'; diff --git a/sql/set_var.cc b/sql/set_var.cc index e794f708bad..103c77143ec 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -699,8 +699,6 @@ static SHOW_VAR fixed_vars[]= { #ifdef HAVE_SYS_UN_H {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR}, #endif - {"table_definition_cache", (char*) &table_def_size, SHOW_LONG}, - {"table_lock_wait_timeout", (char*) &table_lock_wait_timeout, SHOW_LONG }, #ifdef HAVE_THR_SETCONCURRENCY {"thread_concurrency", (char*) &concurrency, SHOW_LONG}, #endif From 62e88b779cb3cd563c64952a33294024631eb937 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 17:47:02 +0500 Subject: [PATCH 064/156] Bug#28007 Wrong default value for I_S.PARTITIONS.PARTITION_COMMENT The value of the PARTITION_COMMENT column is an empty string if there is no partition comment. mysql-test/r/information_schema_part.result: result fix mysql-test/r/ndb_dd_alter.result: result fix mysql-test/r/ndb_dd_backuprestore.result: result fix mysql-test/r/ndb_partition_range.result: result fix sql/sql_show.cc: The value of the PARTITION_COMMENT column is an empty string if there is no partition comment. --- mysql-test/r/information_schema_part.result | 54 +++++++++---------- mysql-test/r/ndb_dd_alter.result | 4 +- mysql-test/r/ndb_dd_backuprestore.result | 60 ++++++++++----------- mysql-test/r/ndb_partition_range.result | 6 +-- sql/sql_show.cc | 2 +- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/mysql-test/r/information_schema_part.result b/mysql-test/r/information_schema_part.result index df3abdbee0a..8455c8e014e 100644 --- a/mysql-test/r/information_schema_part.result +++ b/mysql-test/r/information_schema_part.result @@ -7,9 +7,9 @@ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); select * from information_schema.partitions where table_schema="test" and table_name="t1"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 x1 NULL 1 NULL LIST NULL b*a NULL 1 0 0 0 # 1024 0 # # NULL NULL default default ts1 -NULL test t1 x2 NULL 2 NULL LIST NULL b*a NULL 3,11,5,7 0 0 0 # 1024 0 # # NULL NULL default default ts2 -NULL test t1 x3 NULL 3 NULL LIST NULL b*a NULL 16,8,24,27 0 0 0 # 1024 0 # # NULL NULL default default ts3 +NULL test t1 x1 NULL 1 NULL LIST NULL b*a NULL 1 0 0 0 # 1024 0 # # NULL NULL default ts1 +NULL test t1 x2 NULL 2 NULL LIST NULL b*a NULL 3,11,5,7 0 0 0 # 1024 0 # # NULL NULL default ts2 +NULL test t1 x3 NULL 3 NULL LIST NULL b*a NULL 16,8,24,27 0 0 0 # 1024 0 # # NULL NULL default ts3 create table t2 (a int not null,b int not null,c int not null, primary key(a,b)) partition by range (a) partitions 3 @@ -19,27 +19,27 @@ partition x3 values less than maxvalue tablespace ts3); select * from information_schema.partitions where table_schema="test" and table_name="t2"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t2 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 1024 0 # # NULL NULL default default ts1 -NULL test t2 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 1024 0 # # NULL NULL default default ts2 -NULL test t2 x3 NULL 3 NULL RANGE NULL a NULL MAXVALUE 0 0 0 # 1024 0 # # NULL NULL default default ts3 +NULL test t2 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 1024 0 # # NULL NULL default ts1 +NULL test t2 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 1024 0 # # NULL NULL default ts2 +NULL test t2 x3 NULL 3 NULL RANGE NULL a NULL MAXVALUE 0 0 0 # 1024 0 # # NULL NULL default ts3 create table t3 (f1 date) partition by hash(month(f1)) partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t3"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t3 p0 NULL 1 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t3 p1 NULL 2 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t3 p2 NULL 3 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL +NULL test t3 p0 NULL 1 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t3 p1 NULL 2 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t3 p2 NULL 3 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL create table t4 (f1 date, f2 int) partition by key(f1,f2) partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t4"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t4 p0 NULL 1 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t4 p1 NULL 2 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t4 p2 NULL 3 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL +NULL test t4 p0 NULL 1 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t4 p1 NULL 2 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t4 p2 NULL 3 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL drop table t1,t2,t3,t4; create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) @@ -63,14 +63,14 @@ subpartition x22 tablespace t2) ); select * from information_schema.partitions where table_schema="test"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default default t1 -NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default default t2 -NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default default t1 -NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default default t2 -NULL test t2 x1 x11 1 1 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default default t1 -NULL test t2 x1 x12 1 2 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default default t2 -NULL test t2 x2 x21 2 1 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default default t1 -NULL test t2 x2 x22 2 2 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default default t2 +NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default t1 +NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default t2 +NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default t1 +NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default t2 +NULL test t2 x1 x11 1 1 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default t1 +NULL test t2 x1 x12 1 2 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default t2 +NULL test t2 x2 x21 2 1 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default t1 +NULL test t2 x2 x22 2 2 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default t2 drop table t1,t2; create table t1 ( a int not null, @@ -88,10 +88,10 @@ subpartition x22 tablespace t2 nodegroup 1) ); select * from information_schema.partitions where table_schema="test"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 0 t1 -NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 1 t2 -NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 0 t1 -NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 1 t2 +NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL 0 t1 +NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL 1 t2 +NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL 0 t1 +NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL 1 t2 show tables; Tables_in_test t1 @@ -107,9 +107,9 @@ partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t1"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 p0 NULL 1 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t1 p1 NULL 2 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL -NULL test t1 p2 NULL 3 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default default NULL +NULL test t1 p0 NULL 1 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t1 p1 NULL 2 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +NULL test t1 p2 NULL 3 NULL LINEAR HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL drop table t1; create table t1 (a int) PARTITION BY RANGE (a) diff --git a/mysql-test/r/ndb_dd_alter.result b/mysql-test/r/ndb_dd_alter.result index e4bd96ab384..94426546115 100644 --- a/mysql-test/r/ndb_dd_alter.result +++ b/mysql-test/r/ndb_dd_alter.result @@ -314,11 +314,11 @@ a1 20 SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE; SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts SELECT * FROM test.t1 ORDER BY a1; a1 a2 a3 1 2.2345 20000001 diff --git a/mysql-test/r/ndb_dd_backuprestore.result b/mysql-test/r/ndb_dd_backuprestore.result index 1dd609b932d..c82fe560121 100644 --- a/mysql-test/r/ndb_dd_backuprestore.result +++ b/mysql-test/r/ndb_dd_backuprestore.result @@ -223,31 +223,31 @@ t6 CREATE TABLE `t6` ( ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) */ SELECT * FROM information_schema.partitions WHERE table_name= 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 +NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 SELECT * FROM information_schema.partitions WHERE table_name= 't2'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 +NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 SELECT * FROM information_schema.partitions WHERE table_name= 't3'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 +NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 SELECT * FROM information_schema.partitions WHERE table_name= 't4'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT * FROM information_schema.partitions WHERE table_name= 't5'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT * FROM information_schema.partitions WHERE table_name= 't6'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT COUNT(*) FROM test.t1; COUNT(*) 250 @@ -389,31 +389,31 @@ t6 CREATE TABLE `t6` ( ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) */ SELECT * FROM information_schema.partitions WHERE table_name= 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 -NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space1 +NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 SELECT * FROM information_schema.partitions WHERE table_name= 't2'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 +NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 SELECT * FROM information_schema.partitions WHERE table_name= 't3'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 -NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default default table_space2 +NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 SELECT * FROM information_schema.partitions WHERE table_name= 't4'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT * FROM information_schema.partitions WHERE table_name= 't5'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT * FROM information_schema.partitions WHERE table_name= 't6'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL -NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default default NULL +NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL SELECT COUNT(*) FROM test.t1; COUNT(*) 250 diff --git a/mysql-test/r/ndb_partition_range.result b/mysql-test/r/ndb_partition_range.result index 8057ac59613..0c717ed55e9 100644 --- a/mysql-test/r/ndb_partition_range.result +++ b/mysql-test/r/ndb_partition_range.result @@ -17,9 +17,9 @@ INSERT into t1 values (10, 1, 1); INSERT into t1 values (15, 1, 1); select * from information_schema.partitions where table_name= 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 0 0 # # NULL NULL default default NULL -NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default default NULL -NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default default NULL +NULL test t1 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 0 0 # # NULL NULL default NULL +NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default NULL +NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default NULL select * from t1 order by a; a b c 1 1 1 diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 9aa444aa4c0..08caf6817e1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4044,7 +4044,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, table->field[22]->store(part_elem->part_comment, strlen(part_elem->part_comment), cs); else - table->field[22]->store(STRING_WITH_LEN("default"), cs); + table->field[22]->store(STRING_WITH_LEN(""), cs); if (part_elem->nodegroup_id != UNDEF_NODEGROUP) table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE); else From d3e8ed2c9e51f14553974eac53381a7657a73578 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 15:22:06 +0200 Subject: [PATCH 065/156] Raise version number after cloning 4.1.23 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index b9f84086e28..5d60de7fe34 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,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, 4.1.23) +AM_INIT_AUTOMAKE(mysql, 4.1.24) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -21,7 +21,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=4 NDB_VERSION_MINOR=1 -NDB_VERSION_BUILD=23 +NDB_VERSION_BUILD=24 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 593afb6a7389639aef111f198cff5f1d5192fad7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 18:29:15 +0500 Subject: [PATCH 066/156] Bug#28553 mysqld crash in "purge master log before(select time from information_schema)" forbid the use of subselect in PURGE LOGS BEFORE command mysql-test/r/subselect.result: test result mysql-test/t/subselect.test: test case sql/sql_yacc.yy: forbid the use of subselect in PURGE LOGS BEFORE command --- mysql-test/r/subselect.result | 2 ++ mysql-test/t/subselect.test | 7 ++++--- sql/sql_yacc.yy | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 5bb79a53771..ff120912902 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2834,6 +2834,8 @@ a 4 DROP TABLE t1,t2,t3; purge master logs before (select adddate(current_timestamp(), interval -4 day)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select adddate(current_timestamp(), interval -4 day))' at line 1 +purge master logs before adddate(current_timestamp(), interval -4 day); CREATE TABLE t1 (f1 INT); CREATE TABLE t2 (f2 INT); INSERT INTO t1 VALUES (1); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 67a18e7a30f..978c8f26552 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1815,11 +1815,12 @@ SELECT * FROM t1 DROP TABLE t1,t2,t3; # -# BUG #10308: purge log with subselect +# BUG#10308: purge log with subselect +# Bug#28553: mysqld crash in "purge master log before(select time from information_schema)" # - +--error 1064 purge master logs before (select adddate(current_timestamp(), interval -4 day)); - +purge master logs before adddate(current_timestamp(), interval -4 day); # # Bug#18503: Queries with a quantified subquery returning empty set may diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b72caac46a0..d53dba6bf1b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3567,7 +3567,8 @@ select_derived2: LEX *lex= Lex; lex->derived_tables= 1; if (lex->sql_command == (int)SQLCOM_HA_READ || - lex->sql_command == (int)SQLCOM_KILL) + lex->sql_command == (int)SQLCOM_KILL || + lex->sql_command == (int)SQLCOM_PURGE) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; @@ -4748,6 +4749,7 @@ purge: { LEX *lex=Lex; lex->type=0; + lex->sql_command = SQLCOM_PURGE; } purge_options {} ; @@ -4759,7 +4761,6 @@ purge_options: purge_option: TO_SYM TEXT_STRING_sys { - Lex->sql_command = SQLCOM_PURGE; Lex->to_log = $2.str; } | BEFORE_SYM expr @@ -6212,7 +6213,8 @@ subselect_start: { LEX *lex=Lex; if (lex->sql_command == (int)SQLCOM_HA_READ || - lex->sql_command == (int)SQLCOM_KILL) + lex->sql_command == (int)SQLCOM_KILL || + lex->sql_command == (int)SQLCOM_PURGE) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; From 64c6a91d40cd3885926a7706549cbfc7c3fe565c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Jun 2007 18:55:21 +0500 Subject: [PATCH 067/156] after merge fix --- mysql-test/r/subselect.result | 3 --- mysql-test/r/subselect_notembedded.result | 2 ++ mysql-test/t/subselect.test | 8 -------- mysql-test/t/subselect_notembedded.test | 7 ++++--- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index aa970e2b171..38f6e2d10e3 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2853,9 +2853,6 @@ a 3 4 DROP TABLE t1,t2,t3; -purge master logs before (select adddate(current_timestamp(), interval -4 day)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select adddate(current_timestamp(), interval -4 day))' at line 1 -purge master logs before adddate(current_timestamp(), interval -4 day); CREATE TABLE t1 (f1 INT); CREATE TABLE t2 (f2 INT); INSERT INTO t1 VALUES (1); diff --git a/mysql-test/r/subselect_notembedded.result b/mysql-test/r/subselect_notembedded.result index dd4b0701c32..44ae055425e 100644 --- a/mysql-test/r/subselect_notembedded.result +++ b/mysql-test/r/subselect_notembedded.result @@ -1 +1,3 @@ purge master logs before (select adddate(current_timestamp(), interval -4 day)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select adddate(current_timestamp(), interval -4 day))' at line 1 +purge master logs before adddate(current_timestamp(), interval -4 day); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 2ae48a0303f..33e58fe0c32 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1821,14 +1821,6 @@ SELECT * FROM t1 DROP TABLE t1,t2,t3; -# -# BUG#10308: purge log with subselect -# Bug#28553: mysqld crash in "purge master log before(select time from information_schema)" -# ---error 1064 -purge master logs before (select adddate(current_timestamp(), interval -4 day)); -purge master logs before adddate(current_timestamp(), interval -4 day); - # # Bug#18503: Queries with a quantified subquery returning empty set may # return a wrong result. diff --git a/mysql-test/t/subselect_notembedded.test b/mysql-test/t/subselect_notembedded.test index c5b23f6dac8..c112272e8ad 100644 --- a/mysql-test/t/subselect_notembedded.test +++ b/mysql-test/t/subselect_notembedded.test @@ -1,8 +1,9 @@ -- source include/not_embedded.inc # -# BUG #10308: purge log with subselect +# BUG#10308: purge log with subselect +# Bug#28553: mysqld crash in "purge master log before(select time from information_schema)" # - +--error 1064 purge master logs before (select adddate(current_timestamp(), interval -4 day)); - +purge master logs before adddate(current_timestamp(), interval -4 day); From 8d0d27b5a45b8d6224e9d94f77baef7a334e5959 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 00:30:00 +0400 Subject: [PATCH 068/156] Bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS flag is set. When the CLIENT_FOUND_ROWS flag is set then the server should return found number of rows independently whether they were updated or not. But this wasn't the case for the INSERT statement which always returned number of rows that were actually changed thus providing wrong info to the user. Now the select_insert::send_eof method and the mysql_insert function are sending the number of touched rows if the CLIENT_FOUND_ROWS flag is set. tests/mysql_client_test.c: Added a test case for the bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS flag is set. sql/sql_insert.cc: Bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS flag is set. Now the select_insert::send_eof method and the mysql_insert function are sending the number of touched rows if the CLIENT_FOUND_ROWS flag is set. --- sql/sql_insert.cc | 14 ++++++--- tests/mysql_client_test.c | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index bf37a3d6d69..f3ed3ebab24 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -947,20 +947,24 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) || !thd->cuted_fields)) { - thd->row_count_func= info.copied+info.deleted+info.updated; + thd->row_count_func= info.copied + info.deleted + + ((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); send_ok(thd, (ulong) thd->row_count_func, id); } else { char buff[160]; + ha_rows updated=((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); if (ignore) sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, (lock_type == TL_WRITE_DELAYED) ? (ulong) 0 : (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields); - thd->row_count_func= info.copied+info.deleted+info.updated; + (ulong) (info.deleted + updated), (ulong) thd->cuted_fields); + thd->row_count_func= info.copied + info.deleted + updated; ::send_ok(thd, (ulong) thd->row_count_func, id, buff); } thd->abort_on_warning= 0; @@ -2973,7 +2977,9 @@ bool select_insert::send_eof() else sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields); - thd->row_count_func= info.copied+info.deleted+info.updated; + thd->row_count_func= info.copied + info.deleted + + ((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); ::send_ok(thd, (ulong) thd->row_count_func, last_insert_id, buff); DBUG_RETURN(0); } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index e56dd693287..54d29dbd683 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15623,6 +15623,69 @@ static void test_bug27876() } +/* + Bug#28505: mysql_affected_rows() returns wrong value if CLIENT_FOUND_ROWS + flag is set. +*/ +static void test_bug28505() +{ + MYSQL *l_mysql; + my_bool error= 0; + my_ulonglong res; + + if (!(l_mysql= mysql_init(NULL))) + { + myerror("mysql_init() failed"); + DIE_UNLESS(1); + } + if (!(mysql_real_connect(l_mysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_FOUND_ROWS))) + { + myerror("connection failed"); + error= 1; + goto end; + } + l_mysql->reconnect= 1; + if (mysql_query(l_mysql, "drop table if exists t1")) + { + myerror(NULL); + error= 1; + goto end; + } + if (mysql_query(l_mysql, "create table t1(f1 int primary key)")) + { + myerror(NULL); + error= 1; + goto end; + } + if (mysql_query(l_mysql, "insert into t1 values(1)")) + { + myerror(NULL); + error= 1; + goto end; + } + if (mysql_query(l_mysql, + "insert into t1 values(1) on duplicate key update f1=1")) + { + myerror(NULL); + error= 1; + goto end; + } + res= mysql_affected_rows(l_mysql); + if (!res) + error= 1; + if (mysql_query(l_mysql, "drop table t1")) + { + myerror(NULL); + error= 1; + } +end: + mysql_close(l_mysql); + DIE_UNLESS(error == 0); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -15904,6 +15967,7 @@ static struct my_tests_st my_tests[]= { { "test_bug21635", test_bug21635 }, { "test_bug24179", test_bug24179 }, { "test_bug27876", test_bug27876 }, + { "test_bug28505", test_bug28505 }, { 0, 0 } }; From 970b26e67958f54eb5bed8bea00e9b5949612e7e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 10:08:44 +0300 Subject: [PATCH 069/156] Bug#28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML When making key reference buffers over CHAR fields whitespace (0x20) must be used to fill in the remaining space in the field's buffer. This is what Field_string::store() does. Fixed Field_string::get_key_image() to do the same. mysql-test/r/innodb_mysql.result: Bug#28878: test case mysql-test/t/innodb_mysql.test: Bug#28878: test case sql/field.cc: Bug#28878: Fill with space instead of binary zeros. --- mysql-test/r/innodb_mysql.result | 36 ++++++++++++++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 31 +++++++++++++++++++++++++++ sql/field.cc | 3 ++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 45cb116f08b..6aab2372706 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -617,4 +617,40 @@ EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx1,idx2 idx1 9 NULL 2 Using where; Using index DROP TABLE t1,t2; +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +a +uk +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +a +uk +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +a +uk +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +DROP TABLE t1,t2,t3; End of 5.0 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index d9e50add8bf..fbb114f9ce6 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -597,4 +597,35 @@ EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; DROP TABLE t1,t2; +# +# Bug #25866: Getting "#HY000 Can't find record in..." on and INSERT +# +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; + +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; + +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; + +DROP TABLE t1,t2,t3; + --echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 8ff615ee798..5ac8358acaa 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6249,7 +6249,8 @@ uint Field_string::get_key_image(char *buff, uint length, imagetype type_arg) length / field_charset->mbmaxlen); memcpy(buff, ptr, bytes); if (bytes < length) - bzero(buff + bytes, length - bytes); + field_charset->cset->fill(field_charset, buff + bytes, length - bytes, + field_charset->pad_char); return bytes; } From 89d96dd48e3c9a52d8fdeed3cb31d7ffa4a83c36 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 00:59:08 -0700 Subject: [PATCH 070/156] Fixed bug #28449: a crash may happen at some rare conditions when a temporary table has grown out of heap memory reserved for it and the remaining disk space is not big enough to store the table as a MyISAM table. The crash happens because the function create_myisam_from_heap does not handle safely the mem_root structure associated with the converted table in the case when an error has occurred. sql/sql_select.cc: Fixed bug #28449: a crash may happen at some rare conditions when a temporary table has grown out of heap memory reserved for it and the remaining disk space is not big enough to store the table as a MyISAM table. The crash happens because the function create_myisam_from_heap does not handle safely the mem_root structure associated with the converted table in the case when an error has occurred. As it's hard to create a sitiation that would throw an error a special code has been added that raises an error for a newly created test called error_simulation. mysql-test/r/error_simulation.result: New BitKeeper file ``mysql-test/r/error_simulation.result'' Added a test case for bug #28449. mysql-test/t/error_simulation-master.opt: New BitKeeper file ``mysql-test/t/error_simulation-master.opt'' mysql-test/t/error_simulation.test: New BitKeeper file ``mysql-test/t/error_simulation.test'' Added a test case for bug #28449. --- mysql-test/r/error_simulation.result | 19 ++++++++++++++++ mysql-test/t/error_simulation-master.opt | 1 + mysql-test/t/error_simulation.test | 29 ++++++++++++++++++++++++ sql/sql_select.cc | 7 ++++-- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/error_simulation.result create mode 100644 mysql-test/t/error_simulation-master.opt create mode 100644 mysql-test/t/error_simulation.test diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result new file mode 100644 index 00000000000..805e8fabbd8 --- /dev/null +++ b/mysql-test/r/error_simulation.result @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 ( +a varchar(32) character set utf8 collate utf8_bin NOT NULL, +b varchar(32) character set utf8 collate utf8_bin NOT NULL ) +ENGINE=MyISAM DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES +('AAAAAAAAAA','AAAAAAAAAA'), ('AAAAAAAAAB','AAAAAAAAAB '), +('AAAAAAAAAB','AAAAAAAAAB'), ('AAAAAAAAAC','AAAAAAAAAC'), +('AAAAAAAAAD','AAAAAAAAAD'), ('AAAAAAAAAE','AAAAAAAAAE'), +('AAAAAAAAAF','AAAAAAAAAF'), ('AAAAAAAAAG','AAAAAAAAAG'), +('AAAAAAAAAH','AAAAAAAAAH'), ('AAAAAAAAAI','AAAAAAAAAI'), +('AAAAAAAAAJ','AAAAAAAAAJ'), ('AAAAAAAAAK','AAAAAAAAAK'); +set tmp_table_size=1024; +SELECT MAX(a) FROM t1 GROUP BY a,b; +ERROR 23000: Can't write; duplicate key in table '' +set tmp_table_size=default; +DROP TABLE t1; diff --git a/mysql-test/t/error_simulation-master.opt b/mysql-test/t/error_simulation-master.opt new file mode 100644 index 00000000000..edb77cfa85e --- /dev/null +++ b/mysql-test/t/error_simulation-master.opt @@ -0,0 +1 @@ +--loose-debug=d,raise_error diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test new file mode 100644 index 00000000000..8c044224b8a --- /dev/null +++ b/mysql-test/t/error_simulation.test @@ -0,0 +1,29 @@ +-- source include/have_debug.inc + +# +# Bug #28499: crash for grouping query when tmp_table_size is too small +# + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 ( + a varchar(32) character set utf8 collate utf8_bin NOT NULL, + b varchar(32) character set utf8 collate utf8_bin NOT NULL ) +ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES + ('AAAAAAAAAA','AAAAAAAAAA'), ('AAAAAAAAAB','AAAAAAAAAB '), + ('AAAAAAAAAB','AAAAAAAAAB'), ('AAAAAAAAAC','AAAAAAAAAC'), + ('AAAAAAAAAD','AAAAAAAAAD'), ('AAAAAAAAAE','AAAAAAAAAE'), + ('AAAAAAAAAF','AAAAAAAAAF'), ('AAAAAAAAAG','AAAAAAAAAG'), + ('AAAAAAAAAH','AAAAAAAAAH'), ('AAAAAAAAAI','AAAAAAAAAI'), + ('AAAAAAAAAJ','AAAAAAAAAJ'), ('AAAAAAAAAK','AAAAAAAAAK'); + +set tmp_table_size=1024; + +--error ER_DUP_KEY +SELECT MAX(a) FROM t1 GROUP BY a,b; + +set tmp_table_size=default; + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 41688794721..ece37708370 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10147,7 +10147,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, /* copy all old rows */ while (!table->file->rnd_next(new_table.record[1])) { - if ((write_err=new_table.file->write_row(new_table.record[1]))) + write_err=new_table.file->write_row(new_table.record[1]); + DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;); + if (write_err) goto err; } /* copy row that filled HEAP table */ @@ -10174,7 +10176,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, err: DBUG_PRINT("error",("Got error: %d",write_err)); - table->file->print_error(error,MYF(0)); // Give table is full error + table->file->print_error(write_err, MYF(0)); // Give table is full error (void) table->file->ha_rnd_end(); (void) new_table.file->close(); err1: @@ -10182,6 +10184,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, delete new_table.file; err2: thd->proc_info=save_proc_info; + table->mem_root= new_table.mem_root; DBUG_RETURN(1); } From a42a97774f0028699e0c26dcdee7f127d9e2fe87 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 14:03:43 +0500 Subject: [PATCH 071/156] bug #28309 First insert violates UNIQUE constraint - was "memory" table empty? If we have lower_case_table_names == 2 (usually on case insensitive file systems) we sometimes make 'homedir' part of the path sent to the handler into lowercase. So in this case HEAP engine couldn't properly find and remove HP_SHARE, what caused the bug. sql/handler.cc: bug #28309 First insert violates UNIQUE constraint - was "memory" table empty? we don't turn homedirectory part of the path into lowercase sql/mysql_priv.h: bug #28309 First insert violates UNIQUE constraint - was "memory" table empty? mysql_data_home_len introduced sql/mysqld.cc: bug #28309 First insert violates UNIQUE constraint - was "memory" table empty? mysql_data_home_len value is set with the mysql_data_home --- sql/handler.cc | 47 ++++++++++++++++++++++++----------------------- sql/mysql_priv.h | 1 + sql/mysqld.cc | 4 ++++ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index afb88dc962d..7fc4e5e12b0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1392,6 +1392,25 @@ bool ha_flush_logs(handlerton *db_type) return FALSE; } +static const char *check_lowercase_names(handler *file, const char *path, + char *tmp_path) +{ + if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED)) + return path; + + /* Ensure that table handler get path in lower case */ + if (tmp_path != path) + strmov(tmp_path, path); + + /* + we only should turn into lowercase database/table part + so start the process after homedirectory + */ + my_casedn_str(files_charset_info, tmp_path + mysql_data_home_len); + return tmp_path; +} + + /** @brief This should return ENOENT if the file doesn't exists. The .frm file will be deleted only if we return 0 or ENOENT @@ -1415,13 +1434,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type))) DBUG_RETURN(ENOENT); - if (lower_case_table_names == 2 && !(file->ha_table_flags() & HA_FILE_BASED)) - { - /* Ensure that table handler get path in lower case */ - strmov(tmp_path, path); - my_casedn_str(files_charset_info, tmp_path); - path= tmp_path; - } + path= check_lowercase_names(file, path, tmp_path); if ((error= file->delete_table(path)) && generate_warning) { /* @@ -2598,15 +2611,7 @@ int ha_create_table(THD *thd, const char *path, if (update_create_info) update_create_info_from_table(create_info, &table); - name= share.path.str; - if (lower_case_table_names == 2 && - !(table.file->ha_table_flags() & HA_FILE_BASED)) - { - /* Ensure that handler gets name in lower case */ - strmov(name_buff, name); - my_casedn_str(files_charset_info, name_buff); - name= name_buff; - } + name= check_lowercase_names(table.file, share.path.str, name_buff); error= table.file->create(name, &table, create_info); VOID(closefrm(&table, 0)); @@ -2656,7 +2661,8 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) frmblob and frmlen are set, write the frm to disk */ - (void)strxnmov(path,FN_REFLEN-1,mysql_data_home,"/",db,"/",name,NullS); + (void)strxnmov(path,FN_REFLEN-1,mysql_data_home,FN_ROOTDIR, + db,FN_ROOTDIR,name,NullS); // Save the frm file error= writefrm(path, frmblob, frmlen); my_free(frmblob, MYF(0)); @@ -2677,12 +2683,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) update_create_info_from_table(&create_info, &table); create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE; - if (lower_case_table_names == 2 && - !(table.file->ha_table_flags() & HA_FILE_BASED)) - { - /* Ensure that handler gets name in lower case */ - my_casedn_str(files_charset_info, path); - } + check_lowercase_names(table.file, path, path); error=table.file->create(path,&table,&create_info); VOID(closefrm(&table, 1)); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6452ea2e77e..7fb60bd8a7e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1601,6 +1601,7 @@ extern int creating_table; // How many mysql_create_table() are running */ extern time_t server_start_time; +extern uint mysql_data_home_len; 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 8442d67515b..9b890dd4ff7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -491,6 +491,7 @@ key_map key_map_full(0); // Will be initialized later const char *opt_date_time_formats[3]; +uint mysql_data_home_len; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; char server_version[SERVER_VERSION_LENGTH]; char *mysqld_unix_port, *opt_mysql_tmpdir; @@ -3770,6 +3771,7 @@ int main(int argc, char **argv) mysql_data_home= mysql_data_home_buff; mysql_data_home[0]=FN_CURLIB; // all paths are relative from here mysql_data_home[1]=0; + mysql_data_home_len= 2; if ((user_info= check_user(mysqld_user))) { @@ -7056,6 +7058,7 @@ static void mysql_init_variables(void) sizeof(mysql_real_data_home)-1); mysql_data_home_buff[0]=FN_CURLIB; // all paths are relative from here mysql_data_home_buff[1]=0; + mysql_data_home_len= 2; /* Replication parameters */ master_user= (char*) "test"; @@ -7217,6 +7220,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1); /* Correct pointer set by my_getopt (for embedded library) */ mysql_data_home= mysql_real_data_home; + mysql_data_home_len= strlen(mysql_data_home); break; case 'u': if (!mysqld_user || !strcmp(mysqld_user, argument)) From bc671e2f904da70f42a8d6971295681720213e79 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 12:59:31 +0200 Subject: [PATCH 072/156] netware/*.def : Allocate 128K stack for all executables (bug#23504) netware/comp_err.def: Allocate 128K stack for all executables (bug#23504) netware/isamchk.def: Allocate 128K stack for all executables (bug#23504) netware/isamlog.def: Allocate 128K stack for all executables (bug#23504) netware/libmysql.def: Allocate 128K stack for all executables (bug#23504) netware/my_print_defaults.def: Allocate 128K stack for all executables (bug#23504) netware/myisam_ftdump.def: Allocate 128K stack for all executables (bug#23504) netware/myisamchk.def: Allocate 128K stack for all executables (bug#23504) netware/myisamlog.def: Allocate 128K stack for all executables (bug#23504) netware/myisampack.def: Allocate 128K stack for all executables (bug#23504) netware/mysql.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_install_db.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_test_run.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_waitpid.def: Allocate 128K stack for all executables (bug#23504) netware/mysqladmin.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlbinlog.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlcheck.def: Allocate 128K stack for all executables (bug#23504) netware/mysqld.def: Allocate 128K stack for all executables (bug#23504) netware/mysqld_safe.def: Allocate 128K stack for all executables (bug#23504) netware/mysqldump.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlimport.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlshow.def: Allocate 128K stack for all executables (bug#23504) netware/mysqltest.def: Allocate 128K stack for all executables (bug#23504) netware/pack_isam.def: Allocate 128K stack for all executables (bug#23504) netware/perror.def: Allocate 128K stack for all executables (bug#23504) netware/replace.def: Allocate 128K stack for all executables (bug#23504) netware/resolve_stack_dump.def: Allocate 128K stack for all executables (bug#23504) netware/resolveip.def: Allocate 128K stack for all executables (bug#23504) --- netware/comp_err.def | 1 + netware/isamchk.def | 2 +- netware/isamlog.def | 1 + netware/libmysql.def | 2 +- netware/my_print_defaults.def | 2 +- netware/myisam_ftdump.def | 2 +- netware/myisamchk.def | 2 +- netware/myisamlog.def | 2 +- netware/myisampack.def | 2 +- netware/mysql.def | 2 +- netware/mysql_install_db.def | 2 +- netware/mysql_test_run.def | 2 +- netware/mysql_waitpid.def | 2 +- netware/mysqladmin.def | 2 +- netware/mysqlbinlog.def | 2 +- netware/mysqlcheck.def | 2 +- netware/mysqld.def | 2 +- netware/mysqld_safe.def | 2 +- netware/mysqldump.def | 2 +- netware/mysqlimport.def | 2 +- netware/mysqlshow.def | 1 + netware/mysqltest.def | 1 + netware/pack_isam.def | 1 + netware/perror.def | 2 +- netware/replace.def | 1 + netware/resolve_stack_dump.def | 2 +- netware/resolveip.def | 1 + 27 files changed, 27 insertions(+), 20 deletions(-) diff --git a/netware/comp_err.def b/netware/comp_err.def index f27b40c7b78..f5b18bbdb9a 100644 --- a/netware/comp_err.def +++ b/netware/comp_err.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Error File Compiler" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/isamchk.def b/netware/isamchk.def index 31cf3fc569a..8ae2c0ca96c 100644 --- a/netware/isamchk.def +++ b/netware/isamchk.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL ISAM Table Check Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL ISAM Table Check Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/isamlog.def b/netware/isamlog.def index 52f9de0d928..777d73a7835 100644 --- a/netware/isamlog.def +++ b/netware/isamlog.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL ISAM Table Log Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/libmysql.def b/netware/libmysql.def index 8a34754e092..d9d4c752612 100644 --- a/netware/libmysql.def +++ b/netware/libmysql.def @@ -7,6 +7,6 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL Client Library" VERSION 4, 0 AUTOUNLOAD -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/my_print_defaults.def b/netware/my_print_defaults.def index f22fdec38af..e2a07cb86d2 100644 --- a/netware/my_print_defaults.def +++ b/netware/my_print_defaults.def @@ -5,7 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Print Defaults Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisam_ftdump.def b/netware/myisam_ftdump.def index 9639404b53b..78123537a54 100644 --- a/netware/myisam_ftdump.def +++ b/netware/myisam_ftdump.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Dump Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Dump Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisamchk.def b/netware/myisamchk.def index b7ec5ac9474..9805eb4ec1b 100644 --- a/netware/myisamchk.def +++ b/netware/myisamchk.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Check Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Check Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisamlog.def b/netware/myisamlog.def index 553a818a2ae..925650eac7b 100644 --- a/netware/myisamlog.def +++ b/netware/myisamlog.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Log Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Log Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisampack.def b/netware/myisampack.def index d1f85fe03f8..877a143fd2e 100644 --- a/netware/myisampack.def +++ b/netware/myisampack.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Pack Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Pack Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql.def b/netware/mysql.def index 16acc7babe1..4e44f4882d1 100644 --- a/netware/mysql.def +++ b/netware/mysql.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Monitor[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Monitor" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 MULTIPLE XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_install_db.def b/netware/mysql_install_db.def index 372bbf15570..e3dc57fe44c 100644 --- a/netware/mysql_install_db.def +++ b/netware/mysql_install_db.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Install" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Initial Database Installer" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_test_run.def b/netware/mysql_test_run.def index d4d4baee168..c8afd305978 100644 --- a/netware/mysql_test_run.def +++ b/netware/mysql_test_run.def @@ -2,10 +2,10 @@ # MySQL Test Run #------------------------------------------------------------------------------ MODULE libc.nlm -STACKSIZE 65536 SCREENNAME "MySQL Test Run" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Test Run" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_waitpid.def b/netware/mysql_waitpid.def index da0884ccba3..6e9cc76f139 100644 --- a/netware/mysql_waitpid.def +++ b/netware/mysql_waitpid.def @@ -6,7 +6,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Tool - Wait for a Program to Terminate" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqladmin.def b/netware/mysqladmin.def index 6532cab84a0..03f15dfdd08 100644 --- a/netware/mysqladmin.def +++ b/netware/mysqladmin.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Admin[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Admin Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlbinlog.def b/netware/mysqlbinlog.def index aced63429c5..88024acc318 100644 --- a/netware/mysqlbinlog.def +++ b/netware/mysqlbinlog.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Binary Log Dump Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Binary Log Dump Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlcheck.def b/netware/mysqlcheck.def index 1b90b2a1dbe..b9028c237d1 100644 --- a/netware/mysqlcheck.def +++ b/netware/mysqlcheck.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Check Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Check Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqld.def b/netware/mysqld.def index 42c2d176a1b..bb7b8129983 100644 --- a/netware/mysqld.def +++ b/netware/mysqld.def @@ -6,7 +6,7 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL Database Server" VERSION 4, 0 MULTIPLE -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqld_safe.def b/netware/mysqld_safe.def index ff3f1924906..5c436cc97ca 100644 --- a/netware/mysqld_safe.def +++ b/netware/mysqld_safe.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Database Server" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Database Server Monitor" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 MULTIPLE XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqldump.def b/netware/mysqldump.def index 5d7999c789f..2e745492cf3 100644 --- a/netware/mysqldump.def +++ b/netware/mysqldump.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Dump Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Dump Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlimport.def b/netware/mysqlimport.def index f98d8021a73..5db6b940ce7 100644 --- a/netware/mysqlimport.def +++ b/netware/mysqlimport.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Import[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Import Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlshow.def b/netware/mysqlshow.def index b7b84a94067..386cb98c091 100644 --- a/netware/mysqlshow.def +++ b/netware/mysqlshow.def @@ -6,6 +6,7 @@ SCREENNAME "MySQL Show[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Show Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqltest.def b/netware/mysqltest.def index e134acede07..f0ee5f7e6a4 100644 --- a/netware/mysqltest.def +++ b/netware/mysqltest.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Test Case Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/pack_isam.def b/netware/pack_isam.def index fff74806f39..ab9da594cb7 100644 --- a/netware/pack_isam.def +++ b/netware/pack_isam.def @@ -6,6 +6,7 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL ISAM Table Pack Tool" SCREENNAME "MySQL ISAM Table Pack Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/perror.def b/netware/perror.def index d67bd6191b4..fc95de3476a 100644 --- a/netware/perror.def +++ b/netware/perror.def @@ -5,7 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Error Code Description Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/replace.def b/netware/replace.def index 19348ee4245..7feccdbff41 100644 --- a/netware/replace.def +++ b/netware/replace.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Text Replacement Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/resolve_stack_dump.def b/netware/resolve_stack_dump.def index 01042699d61..20098c1b4e0 100644 --- a/netware/resolve_stack_dump.def +++ b/netware/resolve_stack_dump.def @@ -6,7 +6,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Stack Dump Resolve Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/resolveip.def b/netware/resolveip.def index 244f52bb969..1962d61be53 100644 --- a/netware/resolveip.def +++ b/netware/resolveip.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL IP/Hostname Resolve Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG From 18310fabf48626767c9aeb632be1be69d3756ed0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 00:33:03 +0400 Subject: [PATCH 073/156] Bug#28763: Selecting geometry fields in UNION caused server crash. This bug was introduced by the fix for the bug#27300. In this fix a section of code was added to the Item::tmp_table_field_from_field_type method. This section intended to create Field_geom fields for the Item_geometry_func class and its descendants. In order to get the geometry type of the current item it casted "this" to the Item_geometry_func* type. But the Item::tmp_table_field_from_field_type method is also used for creation of fields for UNION and in this case this method is called for an object of the Item_type_holder class and the cast to the Item_geometry_func* type causes a server crash. Now the Item::tmp_table_field_from_field_type method correctly works when it's called for both the Item_type_holder and the Item_geometry_func classes. The new geometry_type variable is added to the Item_type_holder class. The new method called get_geometry_type is added to the Item_field and the Field classes. It returns geometry type from the field for the Item_field and the Field_geom classes and fails an assert for other Field descendants. sql/field.h: Bug#28763: Selecting geometry fields in UNION caused server crash. The new method called get_geometry_type is added to the Field class. It returns geometry type of the field for the Field_geom class and fails an assert for other Field descendants. sql/item.cc: Bug#28763: Selecting geometry fields in UNION caused server crash. Now the Item::tmp_table_field_from_field_type method correctly works when it's called for both the Item_type_holder and the Item_geometry_func classes. mysql-test/r/gis.result: Added a test case for the bug#28763: Selecting geometry fields in UNION caused server crash. mysql-test/t/gis.test: Added a test case for the bug#28763: Selecting geometry fields in UNION caused server crash. sql/item.h: Bug#28763: Selecting geometry fields in UNION caused server crash. The new method called get_geometry_type is added to the Item_field class. It returns geometry type from the field. The new geometry_type variable is added to the Item_type_holder class. --- mysql-test/r/gis.result | 21 +++++++++++++++++++++ mysql-test/t/gis.test | 13 +++++++++++++ sql/field.h | 7 ++++++- sql/item.cc | 8 +++++++- sql/item.h | 7 +++++++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 73e5b054f80..d1f292cda0c 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -864,4 +864,25 @@ SELECT Overlaps(@horiz1, @point2) FROM DUAL; Overlaps(@horiz1, @point2) 0 DROP TABLE t1; +create table t1(f1 geometry, f2 point, f3 linestring); +select f1 from t1 union select f1 from t1; +f1 +insert into t1 (f2,f3) values (GeomFromText('POINT(1 1)'), +GeomFromText('LINESTRING(0 0,1 1,2 2)')); +select AsText(f2),AsText(f3) from t1; +AsText(f2) AsText(f3) +POINT(1 1) LINESTRING(0 0,1 1,2 2) +select AsText(a) from (select f2 as a from t1 union select f3 from t1) t; +AsText(a) +POINT(1 1) +LINESTRING(0 0,1 1,2 2) +create table t2 as select f2 as a from t1 union select f3 from t1; +desc t2; +Field Type Null Key Default Extra +a point YES NULL +select AsText(a) from t2; +AsText(a) +POINT(1 1) +LINESTRING(0 0,1 1,2 2) +drop table t1, t2; End of 5.0 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index ccc38db8dea..95ccc6272e2 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -557,4 +557,17 @@ SELECT Overlaps(@horiz1, @point2) FROM DUAL; DROP TABLE t1; +# +# Bug#28763: Selecting geometry fields in UNION caused server crash. +# +create table t1(f1 geometry, f2 point, f3 linestring); +select f1 from t1 union select f1 from t1; +insert into t1 (f2,f3) values (GeomFromText('POINT(1 1)'), + GeomFromText('LINESTRING(0 0,1 1,2 2)')); +select AsText(f2),AsText(f3) from t1; +select AsText(a) from (select f2 as a from t1 union select f3 from t1) t; +create table t2 as select f2 as a from t1 union select f3 from t1; +desc t2; +select AsText(a) from t2; +drop table t1, t2; --echo End of 5.0 tests diff --git a/sql/field.h b/sql/field.h index 37ce6b88453..39378addd4c 100644 --- a/sql/field.h +++ b/sql/field.h @@ -360,7 +360,11 @@ public: { return field_length / charset()->mbmaxlen; } - + virtual geometry_type get_geometry_type() + { + /* shouldn't get here. */ + DBUG_ASSERT(0); + } friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, ulonglong auto_increment_value); @@ -1325,6 +1329,7 @@ public: uint get_key_image(char *buff,uint length,imagetype type); uint size_of() const { return sizeof(*this); } int reset(void) { return !maybe_null() || Field_blob::reset(); } + geometry_type get_geometry_type() { return geom_type; }; }; #endif /*HAVE_SPATIAL*/ diff --git a/sql/item.cc b/sql/item.cc index 92ea35072f9..59708afdd19 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4317,7 +4317,9 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) case MYSQL_TYPE_GEOMETRY: return new Field_geom(max_length, maybe_null, name, table, (Field::geometry_type) - ((Item_geometry_func *)this)->get_geometry_type()); + ((type() == Item::TYPE_HOLDER) ? + ((Item_type_holder *)this)->get_geometry_type() : + ((Item_geometry_func *)this)->get_geometry_type())); } } @@ -6422,6 +6424,10 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) if (Field::result_merge_type(fld_type) == INT_RESULT) decimals= 0; prev_decimal_int_part= item->decimal_int_part(); + if (item->field_type() == MYSQL_TYPE_GEOMETRY) + geometry_type= (item->type() == Item::FIELD_ITEM) ? + ((Item_field *)item)->get_geometry_type() : + (Field::geometry_type)((Item_geometry_func *)item)->get_geometry_type(); } diff --git a/sql/item.h b/sql/item.h index 11dce3a7758..96936f0ff88 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1304,6 +1304,11 @@ public: int fix_outer_field(THD *thd, Field **field, Item **reference); virtual Item *update_value_transformer(byte *select_arg); void print(String *str); + Field::geometry_type get_geometry_type() + { + DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY); + return field->get_geometry_type(); + } friend class Item_default_value; friend class Item_insert_value; friend class st_select_lex_unit; @@ -2563,6 +2568,7 @@ class Item_type_holder: public Item protected: TYPELIB *enum_set_typelib; enum_field_types fld_type; + Field::geometry_type geometry_type; void get_full_info(Item *item); @@ -2582,6 +2588,7 @@ public: Field *make_field_by_type(TABLE *table); static uint32 display_length(Item *item); static enum_field_types get_real_type(Item *); + Field::geometry_type get_geometry_type() { return geometry_type; }; }; From db5aab1d2c7fcdb8a35a30063b63c8ce5b9fca55 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 23:05:18 +0200 Subject: [PATCH 074/156] Do not use the "thd" pointer to identify a thread in the embedded lib, but rather use the "thread_id" counter. Fixes bug#27078: Compile error: lib_sql.cc cast from 'THD*' to 'pthread_t' loses precision libmysqld/lib_sql.cc: Avoid casting a pointer to a (possibly) int, which will not compile on some platforms: Do not use the "thd" pointer to identify a thread in the embedded lib, but rather use the "thread_id" counter. Patch is proposed by Monty. Fixes bug#27078. --- libmysqld/lib_sql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 9ee8d48eec4..92b7b10f0c0 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -540,7 +540,7 @@ void *create_embedded_thd(int client_flag) thd->set_time(); thd->init_for_queries(); thd->client_capabilities= client_flag; - thd->real_id= (pthread_t) thd; + thd->real_id= thd->thread_id; thd->db= NULL; thd->db_length= 0; From 88d5c0146b78ddee5816fc256e9b2b0635df2445 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 15:04:39 -0700 Subject: [PATCH 075/156] Correction to remove compilee warnings and compiler errors on Windows. --- sql/field.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/field.h b/sql/field.h index 39378addd4c..ccdda7d04ce 100644 --- a/sql/field.h +++ b/sql/field.h @@ -364,6 +364,7 @@ public: { /* shouldn't get here. */ DBUG_ASSERT(0); + return GEOM_GEOMETRY; } friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, From d8e2f2622d29fb3c198d4895a1a06e2e61be476d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2007 22:35:31 -0700 Subject: [PATCH 076/156] Fixed bug #28811: crash for a query containing a subquery with ORDER BY and LIMIT 1. The bug was introduced by the patch for bug 21727. The patch erroneously skipped initialization of the array of headers for sorted records for non-first evaluations of the subquery. To fix the problem a new parameter has been added to the function make_char_array that performs the initialization. Now this function is called for any invocation of the filesort procedure. Yet it allocates the buffer for sorted records only if this parameter is NULL. mysql-test/r/subselect.result: Added a test case for bug #28811. mysql-test/t/subselect.test: Added a test case for bug #28811. --- mysql-test/r/subselect.result | 26 ++++++++++++++++++++++++++ mysql-test/t/subselect.test | 32 ++++++++++++++++++++++++++++++++ sql/filesort.cc | 19 +++++++++++-------- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 38f6e2d10e3..efd6a5ab572 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4080,4 +4080,30 @@ id select_type table type possible_keys key key_len ref rows Extra Warnings: Note 1003 select `res`.`count(*)` AS `count(*)` from (select count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`a`) `res` DROP TABLE t1; +CREATE TABLE t1 ( +a varchar(255) default NULL, +b timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +INDEX idx(a,b) +); +CREATE TABLE t2 ( +a varchar(255) default NULL +); +INSERT INTO t1 VALUES ('abcdefghijk','2007-05-07 06:00:24'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26'); +INSERT INTO `t2` VALUES ('abcdefghijk'); +INSERT INTO `t2` VALUES ('asdf'); +SET session sort_buffer_size=8192; +SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2; +d1 +1 +1 +DROP TABLE t1,t2; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 33e58fe0c32..12688fa4cf4 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2913,4 +2913,36 @@ SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res; DROP TABLE t1; +# +# Bug #28811: crash for query containing subquery with ORDER BY and LIMIT 1 +# + +CREATE TABLE t1 ( + a varchar(255) default NULL, + b timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + INDEX idx(a,b) +); +CREATE TABLE t2 ( + a varchar(255) default NULL +); + +INSERT INTO t1 VALUES ('abcdefghijk','2007-05-07 06:00:24'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26'); +INSERT INTO `t2` VALUES ('abcdefghijk'); +INSERT INTO `t2` VALUES ('asdf'); + +SET session sort_buffer_size=8192; + +SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2; + +DROP TABLE t1,t2; + --echo End of 5.0 tests. diff --git a/sql/filesort.cc b/sql/filesort.cc index a4bf04a6786..d518ddbb117 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -35,7 +35,8 @@ if (my_b_write((file),(byte*) (from),param->ref_length)) \ /* functions defined in this file */ -static char **make_char_array(register uint fields, uint length, myf my_flag); +static char **make_char_array(char **old_pos, register uint fields, + uint length, myf my_flag); static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffer_file, uint count); static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select, uchar * *sort_keys, IO_CACHE *buffer_file, @@ -202,9 +203,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, ulong old_memavl; ulong keys= memavl/(param.rec_length+sizeof(char*)); param.keys=(uint) min(records+1, keys); - if (table_sort.sort_keys || - (table_sort.sort_keys= (uchar **) make_char_array(param.keys, param.rec_length, - MYF(0)))) + if ((table_sort.sort_keys= + (uchar **) make_char_array((char **) table_sort.sort_keys, + param.keys, param.rec_length, MYF(0)))) break; old_memavl=memavl; if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory) @@ -346,14 +347,16 @@ void filesort_free_buffers(TABLE *table, bool full) /* Make a array of string pointers */ -static char **make_char_array(register uint fields, uint length, myf my_flag) +static char **make_char_array(char **old_pos, register uint fields, + uint length, myf my_flag) { register char **pos; - char **old_pos,*char_pos; + char *char_pos; DBUG_ENTER("make_char_array"); - if ((old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)), - my_flag))) + if (old_pos || + (old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)), + my_flag))) { pos=old_pos; char_pos=((char*) (pos+fields)) -length; while (fields--) *(pos++) = (char_pos+= length); From 5f26429db469128d189488fa161aedeb4eb7090a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 11:20:50 +0500 Subject: [PATCH 077/156] BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails After merge fixes. mysql-test/r/backup.result: Fixed test result. mysql-test/r/sp.result: Fixed test result. sql/sql_table.cc: Fixed wrongly merged line. Moved "deprecated" warnings from sql_yacc.yy to mysql_backup_tables/mysql_restore_table. sql/sql_yacc.yy: Moved "deprecated" warnings from sql_yacc.yy to mysql_backup_tables/mysql_restore_table. storage/myisam/ha_myisam.cc: Do not report the same error twice. storage/myisammrg/ha_myisammrg.cc: Removed wrongly merged line. --- mysql-test/r/backup.result | 40 +++++++++++------------------- mysql-test/r/sp.result | 41 +++++++++++++++---------------- sql/sql_table.cc | 8 +++++- sql/sql_yacc.yy | 4 --- storage/myisam/ha_myisam.cc | 13 ++-------- storage/myisammrg/ha_myisammrg.cc | 1 - 6 files changed, 43 insertions(+), 64 deletions(-) diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index be1a3efc5c6..154b577e61f 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -4,28 +4,24 @@ create table t4(n int); backup table t4 to '../bogus'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) test.t4 backup status Operation failed -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead -Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) backup table t4 to '../tmp'; Table Op Msg_type Msg_text +test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 backup status OK -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) test.t4 backup status Operation failed -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead -Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) drop table t4; restore table t4 from '../tmp'; Table Op Msg_type Msg_text +test.t4 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 restore status OK -Warnings: -Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead select count(*) from t4; count(*) 0 @@ -33,9 +29,8 @@ create table t1(n int); insert into t1 values (23),(45),(67); backup table t1 to '../tmp'; Table Op Msg_type Msg_text +test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 backup status OK -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead drop table t1; restore table t1 from '../bogus'; Table Op Msg_type Msg_text @@ -45,9 +40,8 @@ Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MyS Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X) restore table t1 from '../tmp'; Table Op Msg_type Msg_text +test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK -Warnings: -Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead select n from t1; n 23 @@ -59,18 +53,16 @@ insert into t2 values (123),(145),(167); insert into t3 values (223),(245),(267); backup table t2,t3 to '../tmp'; Table Op Msg_type Msg_text +test.t2 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t2 backup status OK test.t3 backup status OK -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead drop table t1,t2,t3; restore table t1,t2,t3 from '../tmp'; Table Op Msg_type Msg_text +test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK test.t2 restore status OK test.t3 restore status OK -Warnings: -Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead select n from t1; n 23 @@ -89,32 +81,28 @@ k drop table t1,t2,t3,t4; restore table t1 from '../tmp'; Table Op Msg_type Msg_text +test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK -Warnings: -Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead rename table t1 to t5; lock tables t5 write; backup table t5 to '../tmp'; unlock tables; Table Op Msg_type Msg_text +test.t5 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t5 backup status OK -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead drop table t5; DROP TABLE IF EXISTS `t+1`; CREATE TABLE `t+1` (c1 INT); INSERT INTO `t+1` VALUES (1), (2), (3); BACKUP TABLE `t+1` TO '../tmp'; Table Op Msg_type Msg_text +test.t+1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t+1 backup status OK -Warnings: -Warning 1543 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead DROP TABLE `t+1`; RESTORE TABLE `t+1` FROM '../tmp'; Table Op Msg_type Msg_text +test.t+1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t+1 restore status OK -Warnings: -Warning 1543 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead SELECT * FROM `t+1`; c1 1 diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 86ede7a8f00..7c64715fc80 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4404,8 +4404,10 @@ call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK Table Op Msg_type Msg_text +test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 backup status OK Table Op Msg_type Msg_text +test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK drop procedure bug13012| create view v1 as select * from t1| @@ -4420,61 +4422,58 @@ Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK -test.v1 repair error 'test.v1' is not BASE TABLE +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair error Corrupt Table Op Msg_type Msg_text test.t1 optimize status OK test.t2 optimize status OK test.t3 optimize status OK -test.v1 optimize error 'test.v1' is not BASE TABLE +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize error Corrupt Table Op Msg_type Msg_text test.t1 analyze status Table is already up to date test.t2 analyze status Table is already up to date test.t3 analyze status Table is already up to date -test.v1 analyze error 'test.v1' is not BASE TABLE -Warnings: -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE -Error 1347 'test.v1' is not BASE TABLE +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze error Corrupt drop procedure bug13012| drop view v1| select * from t1 order by data| diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ce292a9da60..7c13f9f2c54 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4175,7 +4175,9 @@ send_result: protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store((char*) operator_name, system_charset_info); - protocol->store(warning_level_names[err->level], system_charset_info); + protocol->store(warning_level_names[err->level].str, + warning_level_names[err->level].length, + system_charset_info); protocol->store(err->msg, system_charset_info); if (protocol->write()) goto err; @@ -4387,6 +4389,8 @@ send_result_message: bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_backup_table"); + WARN_DEPRECATED(thd, "5.2", "BACKUP TABLE", + "MySQL Administrator (mysqldump, mysql)"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, "backup", TL_READ, 0, 0, 0, 0, &handler::backup, 0)); @@ -4396,6 +4400,8 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) bool mysql_restore_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_restore_table"); + WARN_DEPRECATED(thd, "5.2", "RESTORE TABLE", + "MySQL Administrator (mysqldump, mysql)"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, "restore", TL_WRITE, 1, 1, 0, &prepare_for_restore, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1073c8141df..ec9fdc2c60a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5751,8 +5751,6 @@ restore: RESTORE_SYM table_or_tables { Lex->sql_command = SQLCOM_RESTORE_TABLE; - WARN_DEPRECATED(yythd, "5.2", "RESTORE TABLE", - "MySQL Administrator (mysqldump, mysql)"); } table_list FROM TEXT_STRING_sys { @@ -5763,8 +5761,6 @@ backup: BACKUP_SYM table_or_tables { Lex->sql_command = SQLCOM_BACKUP_TABLE; - WARN_DEPRECATED(yythd, "5.2", "BACKUP TABLE", - "MySQL Administrator (mysqldump, mysql)"); } table_list TO_SYM TEXT_STRING_sys { diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 351ec87fb51..12c722e8f80 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1224,11 +1224,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) table->keys_in_use_for_query.clear_all(); if (table_list->process_index_hints(table)) - { - errmsg= thd->net.last_error; - error= HA_ADMIN_FAILED; - goto err; - } + DBUG_RETURN(HA_ADMIN_FAILED); map= ~(ulonglong) 0; if (!table->keys_in_use_for_query.is_clear_all()) /* use all keys if there's no list specified by the user through hints */ @@ -1243,7 +1239,6 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) error= HA_ADMIN_CORRUPT; } - err: if (error != HA_ADMIN_OK) { /* Send error to user */ @@ -1278,11 +1273,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) table->keys_in_use_for_query.clear_all(); if (table_list->process_index_hints(table)) - { - errmsg= thd->net.last_error; - error= HA_ADMIN_FAILED; - goto err; - } + DBUG_RETURN(HA_ADMIN_FAILED); map= ~(ulonglong) 0; /* Check validity of the index references */ diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index c7907c53582..04a9938f315 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -129,7 +129,6 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) u_table->table->s->base.keys, u_table->table->s->base.fields, false)) { - my_free((uchar*) recinfo, MYF(0)); error= HA_ERR_WRONG_MRG_TABLE_DEF; if (test_if_locked & HA_OPEN_FOR_REPAIR) myrg_print_wrong_table(u_table->table->filename); From 5031a418e59ece8855ddf2bf34a457bc1df2ab5d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 14:42:08 +0500 Subject: [PATCH 078/156] Bug#18660 Can't grant any privileges on single table in database with underscore char In case of database level grant the database name may be a pattern, in case of table|column level grant the database name can not be a pattern. We use 'dont_check_global_grants' as a flag to determine if it's database level grant command (see SQLCOM_GRANT case, mysql_execute_command() function) and set db_is_pattern according to 'dont_check_global_grants' value. mysql-test/r/grant2.result: test result mysql-test/t/grant2.test: test case sql/sql_parse.cc: In case of database level grant the database name may be a pattern, in case of table|column level grant the database name can not be a pattern. We use 'dont_check_global_grants' as a flag to determine if it's database level grant command (see SQLCOM_GRANT case, mysql_execute_command() function) and set db_is_pattern according to 'dont_check_global_grants' value. --- mysql-test/r/grant2.result | 18 ++++++++++++++++++ mysql-test/t/grant2.test | 30 ++++++++++++++++++++++++++++++ sql/sql_parse.cc | 12 +++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 93098e68070..6de9a83aeed 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -403,4 +403,22 @@ use test; drop database mysqltest_1; drop database mysqltest_2; drop user mysqltest_u1@localhost; +grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; +grant usage on *.* to mysqltest_2@localhost; +create database mysqltest_1; +use mysqltest_1; +create table t1 (f1 int); +grant create on `mysqltest\_1`.* to mysqltest_2@localhost; +grant select on mysqltest_1.t1 to mysqltest_2@localhost; +create database mysqltest_3; +ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest_3' +use mysqltest_1; +create table t2(f1 int); +select * from t1; +f1 +drop database mysqltest_1; +revoke all privileges, grant option from mysqltest_1@localhost; +revoke all privileges, grant option from mysqltest_2@localhost; +drop user mysqltest_1@localhost; +drop user mysqltest_2@localhost; End of 5.0 tests diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 4a3324b1833..a3a8e2d5d53 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -555,5 +555,35 @@ drop database mysqltest_1; drop database mysqltest_2; drop user mysqltest_u1@localhost; +# +# Bug#18660 Can't grant any privileges on single table in database +# with underscore char +# +grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; +grant usage on *.* to mysqltest_2@localhost; +connect (con18600_1,localhost,mysqltest_1,,); + +create database mysqltest_1; +use mysqltest_1; +create table t1 (f1 int); + +grant create on `mysqltest\_1`.* to mysqltest_2@localhost; +grant select on mysqltest_1.t1 to mysqltest_2@localhost; +connect (con3,localhost,mysqltest_2,,); +connection con3; +--error 1044 +create database mysqltest_3; +use mysqltest_1; +create table t2(f1 int); +select * from t1; +connection default; +drop database mysqltest_1; + +revoke all privileges, grant option from mysqltest_1@localhost; +revoke all privileges, grant option from mysqltest_2@localhost; +drop user mysqltest_1@localhost; +drop user mysqltest_2@localhost; + + --echo End of 5.0 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6277a6c0c10..77525b49fdf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5252,7 +5252,17 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, Security_context *sctx= thd->security_ctx; #ifndef NO_EMBEDDED_ACCESS_CHECKS ulong db_access; - bool db_is_pattern= test(want_access & GRANT_ACL); + /* + GRANT command: + In case of database level grant the database name may be a pattern, + in case of table|column level grant the database name can not be a pattern. + We use 'dont_check_global_grants' as a flag to determine + if it's database level grant command + (see SQLCOM_GRANT case, mysql_execute_command() function) and + set db_is_pattern according to 'dont_check_global_grants' value. + */ + bool db_is_pattern= (test(want_access & GRANT_ACL) && + dont_check_global_grants); #endif ulong dummy; DBUG_ENTER("check_access"); From 9e692d86f83c672aef54218a80bd277524491bba Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 12:27:52 +0200 Subject: [PATCH 079/156] ndb - bug#28724 for blobs, op flag to not set error on trans (fix, recommit) storage/ndb/include/ndbapi/NdbOperation.hpp: add NdbOperation option m_noErrorPropagation. If AO_IgnoreError and it are set then operation error does not set error code on transaction. Private, and used by NdbBlob.cpp only. storage/ndb/src/ndbapi/NdbBlob.cpp: add NdbOperation option m_noErrorPropagation. If AO_IgnoreError and it are set then operation error does not set error code on transaction. Private, and used by NdbBlob.cpp only. storage/ndb/src/ndbapi/NdbOperation.cpp: add NdbOperation option m_noErrorPropagation. If AO_IgnoreError and it are set then operation error does not set error code on transaction. Private, and used by NdbBlob.cpp only. --- storage/ndb/include/ndbapi/NdbOperation.hpp | 7 +++++++ storage/ndb/src/ndbapi/NdbBlob.cpp | 3 +++ storage/ndb/src/ndbapi/NdbOperation.cpp | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/storage/ndb/include/ndbapi/NdbOperation.hpp b/storage/ndb/include/ndbapi/NdbOperation.hpp index 0fa2cac0a32..06111941df4 100644 --- a/storage/ndb/include/ndbapi/NdbOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbOperation.hpp @@ -1042,6 +1042,13 @@ protected: */ Int8 m_abortOption; + /* + * For blob impl, option to not propagate error to trans level. + * Could be AO_IgnoreError variant if we want it public. + * Ignored unless AO_IgnoreError is also set. + */ + Int8 m_noErrorPropagation; + friend struct Ndb_free_list_t; }; diff --git a/storage/ndb/src/ndbapi/NdbBlob.cpp b/storage/ndb/src/ndbapi/NdbBlob.cpp index 25dcafdef53..24d648b0241 100644 --- a/storage/ndb/src/ndbapi/NdbBlob.cpp +++ b/storage/ndb/src/ndbapi/NdbBlob.cpp @@ -1261,6 +1261,7 @@ NdbBlob::deletePartsUnknown(Uint32 part) DBUG_RETURN(-1); } tOp->m_abortOption= NdbOperation::AO_IgnoreError; + tOp->m_noErrorPropagation = true; n++; } DBUG_PRINT("info", ("bat=%u", bat)); @@ -1597,6 +1598,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) } if (isWriteOp()) { tOp->m_abortOption = NdbOperation::AO_IgnoreError; + tOp->m_noErrorPropagation = true; } theHeadInlineReadOp = tOp; // execute immediately @@ -1643,6 +1645,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) } if (isWriteOp()) { tOp->m_abortOption = NdbOperation::AO_IgnoreError; + tOp->m_noErrorPropagation = true; } theHeadInlineReadOp = tOp; // execute immediately diff --git a/storage/ndb/src/ndbapi/NdbOperation.cpp b/storage/ndb/src/ndbapi/NdbOperation.cpp index 903372ddb9d..50531292e40 100644 --- a/storage/ndb/src/ndbapi/NdbOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbOperation.cpp @@ -76,7 +76,8 @@ NdbOperation::NdbOperation(Ndb* aNdb, NdbOperation::Type aType) : m_keyInfoGSN(GSN_KEYINFO), m_attrInfoGSN(GSN_ATTRINFO), theBlobList(NULL), - m_abortOption(-1) + m_abortOption(-1), + m_noErrorPropagation(false) { theReceiver.init(NdbReceiver::NDB_OPERATION, this); theError.code = 0; @@ -101,7 +102,8 @@ NdbOperation::setErrorCode(int anErrorCode) theError.code = anErrorCode; theNdbCon->theErrorLine = theErrorLine; theNdbCon->theErrorOperation = this; - theNdbCon->setOperationErrorCode(anErrorCode); + if (!(m_abortOption == AO_IgnoreError && m_noErrorPropagation)) + theNdbCon->setOperationErrorCode(anErrorCode); } /****************************************************************************** @@ -116,6 +118,7 @@ NdbOperation::setErrorCodeAbort(int anErrorCode) theError.code = anErrorCode; theNdbCon->theErrorLine = theErrorLine; theNdbCon->theErrorOperation = this; + // ignore m_noErrorPropagation theNdbCon->setOperationErrorCodeAbort(anErrorCode); } @@ -161,6 +164,7 @@ NdbOperation::init(const NdbTableImpl* tab, NdbTransaction* myConnection){ theMagicNumber = 0xABCDEF01; theBlobList = NULL; m_abortOption = -1; + m_noErrorPropagation = false; m_no_disk_flag = 1; tSignal = theNdb->getSignal(); From 2b274a60d55fb76c4b903350352de29efc25dc6d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 13:42:10 +0300 Subject: [PATCH 080/156] Bug #28754: RPM builds differ from tar.gz in "ALTER ... RENAME" on views When constructing the path to the original .frm file ALTER .. RENAME was unnecessary (and incorrectly) lowercasing the whole path when not on a case-insensitive filesystem. This path should not be modified because of lower_case_table_names as it is already in the correct case according to that setting. Fixed by removing the lowercasing. Unfortunately testing this would require running the tests on a case sensitive filesystem in a directory that has uppercase letters. This cannot be guaranteed in all setups so no test case added. sql/sql_table.cc: Bug #28754: don't downcase the .frm path --- sql/sql_table.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 29ecf43a531..a44b087202b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3101,8 +3101,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, alter_info->tablespace_op)); sprintf(new_name_buff,"%s/%s/%s%s",mysql_data_home, db, table_name, reg_ext); unpack_filename(new_name_buff, new_name_buff); - if (lower_case_table_names != 2) - my_casedn_str(files_charset_info, new_name_buff); frm_type= mysql_frm_type(thd, new_name_buff, &table_type); /* Rename a view */ if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME)) From 4c2f2ac5e7601d0f9b229b40005049861209c290 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 18:17:51 +0500 Subject: [PATCH 081/156] Bug#27684 undocumented difference between SHOW ENGINES and I_S.ENGINES Changed SHOW ENGINES to work in the same way as I_S.ENGINES. For this: removed the functions mysqld_show_storage_engines and show_handlerton, and made SHOW ENGINES work via the common function iter_schema_engines. There in no test case because an engine (except of MyISAM) may be not compiled or disabled which may affect the test result. sql/sql_parse.cc: Changed SHOW ENGINES to work in the same way as I_S.ENGINES. sql/sql_show.cc: Changed SHOW ENGINES to work in the same way as I_S.ENGINES. For this: removed the functions mysqld_show_storage_engines and show_handlerton, and made SHOW ENGINES work via the common function iter_schema_engines. --- sql/sql_parse.cc | 4 +--- sql/sql_show.cc | 61 ++++-------------------------------------------- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8e55610df36..349bd6aa21b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1818,6 +1818,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: + case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SELECT: thd->status_var.last_query_cost= 0.0; if (all_tables) @@ -2920,9 +2921,6 @@ end_with_restore_list: thd->security_ctx->priv_user), lex->verbose); break; - case SQLCOM_SHOW_STORAGE_ENGINES: - res= mysqld_show_storage_engines(thd); - break; case SQLCOM_SHOW_AUTHORS: res= mysqld_show_authors(thd); break; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 08caf6817e1..bf86555641a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -79,58 +79,6 @@ append_algorithm(TABLE_LIST *table, String *buff); ** List all table types supported ***************************************************************************/ -static my_bool show_handlerton(THD *thd, plugin_ref plugin, - void *arg) -{ - handlerton *default_type= (handlerton *) arg; - Protocol *protocol= thd->protocol; - handlerton *hton= plugin_data(plugin, handlerton *); - - if (!(hton->flags & HTON_HIDDEN)) - { - protocol->prepare_for_resend(); - protocol->store(plugin_name(plugin)->str, plugin_name(plugin)->length, - system_charset_info); - const char *option_name= show_comp_option_name[(int) hton->state]; - - if (hton->state == SHOW_OPTION_YES && default_type == hton) - option_name= "DEFAULT"; - protocol->store(option_name, system_charset_info); - protocol->store(plugin_decl(plugin)->descr, system_charset_info); - protocol->store(hton->commit ? "YES" : "NO", system_charset_info); - protocol->store(hton->prepare ? "YES" : "NO", system_charset_info); - protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info); - - return protocol->write() ? 1 : 0; - } - return 0; -} - -bool mysqld_show_storage_engines(THD *thd) -{ - List field_list; - Protocol *protocol= thd->protocol; - DBUG_ENTER("mysqld_show_storage_engines"); - - field_list.push_back(new Item_empty_string("Engine",10)); - field_list.push_back(new Item_empty_string("Support",10)); - field_list.push_back(new Item_empty_string("Comment",80)); - field_list.push_back(new Item_empty_string("Transactions",3)); - field_list.push_back(new Item_empty_string("XA",3)); - field_list.push_back(new Item_empty_string("Savepoints",3)); - - if (protocol->send_fields(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(TRUE); - - if (plugin_foreach(thd, show_handlerton, - MYSQL_STORAGE_ENGINE_PLUGIN, ha_default_handlerton(thd))) - DBUG_RETURN(TRUE); - - send_eof(thd); - DBUG_RETURN(FALSE); -} - static int make_version_string(char *buf, int buf_length, uint version) { return my_snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff); @@ -3319,16 +3267,17 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, if (!(wild && wild[0] && wild_case_compare(scs, name->str,wild))) { - LEX_STRING state[2]= {{ C_STRING_WITH_LEN("ENABLED") }, - { C_STRING_WITH_LEN("DISABLED") }}; LEX_STRING yesno[2]= {{ C_STRING_WITH_LEN("NO") }, { C_STRING_WITH_LEN("YES") }}; LEX_STRING *tmp; + const char *option_name= show_comp_option_name[(int) hton->state]; restore_record(table, s->default_values); table->field[0]->store(name->str, name->length, scs); - tmp= &state[test(hton->state)]; - table->field[1]->store(tmp->str, tmp->length, scs); + if (hton->state == SHOW_OPTION_YES && + hton == thd->variables.table_type) + option_name= "DEFAULT"; + table->field[1]->store(option_name, strlen(option_name), scs); table->field[2]->store(plugin_decl(plugin)->descr, strlen(plugin_decl(plugin)->descr), scs); tmp= &yesno[test(hton->commit)]; From a9ce138822b4c051ab2c78eb4ff160102dae38b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 17:12:42 +0300 Subject: [PATCH 082/156] Bug #27816: Log tables ran with partitions crashes the server when logging is enabled. Currently the partition engine doesn't allow log tables to be partitioned. But this was not checked and the server crashed. Fixed by adding a check in ALTER TABLE to disable partitioning the log tables. While working on the cause of the problem improved the way the log thread structures are initialized before opening the log tables. mysql-test/r/partition.result: Bug #27816: test case mysql-test/t/partition.test: Bug #27816: test case sql/log.cc: Bug #27816: optional Improved initialization of the log threads before opening the log table. Remedies problems that arise from open_table() et. al. depending on a correctly initialized thd. Prerequisite for handling partitioned log tables : they call the parser while reading the .frm file. sql/sql_table.cc: Bug #27816: throw an error when paritioning the log tables : not supported by the partition engine. --- mysql-test/r/partition.result | 8 ++++++++ mysql-test/t/partition.test | 14 ++++++++++++++ sql/log.cc | 2 ++ sql/sql_table.cc | 36 ++++++++++++++++++++++------------- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index af90ac6c714..090ee4b7734 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1245,4 +1245,12 @@ INSERT INTO t1 SELECT a + 8, b FROM t1; ALTER TABLE t1 ADD PARTITION (PARTITION p1 VALUES LESS THAN (64)); ALTER TABLE t1 DROP PARTITION p1; DROP TABLE t1; +USE mysql; +SET GLOBAL general_log = 0; +ALTER TABLE general_log ENGINE = MyISAM; +ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time)) +(PARTITION p0 VALUES LESS THAN (733144), PARTITION p1 VALUES LESS THAN (3000000)); +ERROR HY000: Incorrect usage of PARTITION and log table +ALTER TABLE general_log ENGINE = CSV; +SET GLOBAL general_log = default; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 186cf1d3e8a..358b0501e32 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1465,4 +1465,18 @@ ALTER TABLE t1 DROP PARTITION p1; DROP TABLE t1; +# +# Bug #27816: Log tables ran with partitions crashes the server when logging +# is enabled. +# + +USE mysql; +SET GLOBAL general_log = 0; +ALTER TABLE general_log ENGINE = MyISAM; +--error ER_WRONG_USAGE +ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time)) + (PARTITION p0 VALUES LESS THAN (733144), PARTITION p1 VALUES LESS THAN (3000000)); +ALTER TABLE general_log ENGINE = CSV; +SET GLOBAL general_log = default; + --echo End of 5.1 tests diff --git a/sql/log.cc b/sql/log.cc index 6ef1c1ea912..ac6ea92c61a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -296,6 +296,8 @@ bool Log_to_csv_event_handler::open_log_table(uint log_table_type) table->db= log_thd->db; table->db_length= log_thd->db_length; + lex_start(log_thd); + log_thd->clear_error(); if (simple_open_n_lock_tables(log_thd, table) || table->table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) || table->table->file->ha_rnd_init(0)) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 04e0fd70ece..343222aba0c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5747,21 +5747,31 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, table_list->table_name_length, table_list->table_name, 0); - /* Disable alter of enabled log tables */ - if (table_kind && logger.is_log_table_enabled(table_kind)) + if (table_kind) { - my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER"); - DBUG_RETURN(TRUE); - } + /* Disable alter of enabled log tables */ + if (logger.is_log_table_enabled(table_kind)) + { + my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER"); + DBUG_RETURN(TRUE); + } - /* Disable alter of log tables to unsupported engine */ - if (table_kind && - (create_info->used_fields & HA_CREATE_USED_ENGINE) && - (!create_info->db_type || /* unknown engine */ - !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES))) - { - my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0)); - DBUG_RETURN(TRUE); + /* Disable alter of log tables to unsupported engine */ + if ((create_info->used_fields & HA_CREATE_USED_ENGINE) && + (!create_info->db_type || /* unknown engine */ + !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES))) + { + my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0)); + DBUG_RETURN(TRUE); + } + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (alter_info->flags & ALTER_PARTITION) + { + my_error(ER_WRONG_USAGE, MYF(0), "PARTITION", "log table"); + DBUG_RETURN(TRUE); + } +#endif } } From 37abc7a056b8e6f605b9b8561ee671e19417a1a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Jun 2007 17:02:48 +0200 Subject: [PATCH 083/156] Add a cast, needed by some platforms. Still part of the fix for bug#27078. libmysqld/lib_sql.cc: Some platforms need a cast. Still part of the fix for bug#27078. --- libmysqld/lib_sql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 92b7b10f0c0..7f2059db7cd 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -540,7 +540,7 @@ void *create_embedded_thd(int client_flag) thd->set_time(); thd->init_for_queries(); thd->client_capabilities= client_flag; - thd->real_id= thd->thread_id; + thd->real_id= (pthread_t)thd->thread_id; thd->db= NULL; thd->db_length= 0; From 99b4321ac5e577b965adf3fa0db6f5ae92450fe1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 00:39:23 +0500 Subject: [PATCH 084/156] Bug #28333 Test "flush" tries to create a new thread - on only one platform on PPC/Debian Linux default stack size for a thread is too big. As we use default thread settings in mysqltest, the thread creation fails if we create lots of threads (as it happens in flush.test). So now stack size is explicitly specified for the mysqltest client/mysqltest.c: Bug #28333 Test "flush" tries to create a new thread - on only one platform specify appropriate stack size for the 'query' thread --- client/mysqltest.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 5640d0c24ba..77cdb93dfe5 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -496,6 +496,10 @@ void handle_error(struct st_command*, void handle_no_error(struct st_command*); #ifdef EMBEDDED_LIBRARY + +/* attributes of the query thread */ +pthread_attr_t cn_thd_attrib; + /* send_one_query executes query in separate thread what is necessary in embedded library to run 'send' in proper way. @@ -534,7 +538,7 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len, cn->cur_query= q; cn->cur_query_len= q_len; cn->query_done= 0; - if (pthread_create(&tid, NULL, send_one_query, (void*)cn)) + if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn)) die("Cannot start new thread for query"); return 0; @@ -5999,6 +6003,12 @@ int main(int argc, char **argv) next_con= connections + 1; cur_con= connections; +#ifdef EMBEDDED_LIBRARY + /* set appropriate stack for the 'query' threads */ + (void) pthread_attr_init(&cn_thd_attrib); + pthread_attr_setstacksize(&cn_thd_attrib, DEFAULT_THREAD_STACK); +#endif /*EMBEDDED_LIBRARY*/ + /* Init file stack */ memset(file_stack, 0, sizeof(file_stack)); file_stack_end= From f65930a9e21dc1e9bdf51579158fc6988c433586 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 16:05:43 +0500 Subject: [PATCH 085/156] compilation error fix mysql-test/include/have_archive.inc: test fix(according to new 'support' column values) mysql-test/include/have_blackhole.inc: test fix(according to new 'support' column values) mysql-test/include/have_csv.inc: test fix(according to new 'support' column values) mysql-test/include/have_exampledb.inc: test fix(according to new 'support' column values) mysql-test/include/have_federated_db.inc: test fix(according to new 'support' column values) mysql-test/include/have_innodb.inc: test fix(according to new 'support' column values) mysql-test/include/have_multi_ndb.inc: test fix(according to new 'support' column values) mysql-test/include/have_ndb.inc: test fix(according to new 'support' column values) mysql-test/r/information_schema.result: result fix --- mysql-test/include/have_archive.inc | 2 +- mysql-test/include/have_blackhole.inc | 2 +- mysql-test/include/have_csv.inc | 2 +- mysql-test/include/have_exampledb.inc | 2 +- mysql-test/include/have_federated_db.inc | 2 +- mysql-test/include/have_innodb.inc | 2 +- mysql-test/include/have_multi_ndb.inc | 4 ++-- mysql-test/include/have_ndb.inc | 2 +- mysql-test/r/information_schema.result | 2 +- sql/sql_show.cc | 4 ++-- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mysql-test/include/have_archive.inc b/mysql-test/include/have_archive.inc index 9f0038db97a..82399ca4c6c 100644 --- a/mysql-test/include/have_archive.inc +++ b/mysql-test/include/have_archive.inc @@ -1,4 +1,4 @@ --disable_query_log --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'archive'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'archive'; --enable_query_log diff --git a/mysql-test/include/have_blackhole.inc b/mysql-test/include/have_blackhole.inc index e13cff52094..6c4da01d61d 100644 --- a/mysql-test/include/have_blackhole.inc +++ b/mysql-test/include/have_blackhole.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'blackhole'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'blackhole'; enable_query_log; diff --git a/mysql-test/include/have_csv.inc b/mysql-test/include/have_csv.inc index 3175fc16fe7..410caa95285 100644 --- a/mysql-test/include/have_csv.inc +++ b/mysql-test/include/have_csv.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'csv'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'csv'; enable_query_log; diff --git a/mysql-test/include/have_exampledb.inc b/mysql-test/include/have_exampledb.inc index e3fd068b485..db3985e3c7c 100644 --- a/mysql-test/include/have_exampledb.inc +++ b/mysql-test/include/have_exampledb.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'example'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'example'; enable_query_log; diff --git a/mysql-test/include/have_federated_db.inc b/mysql-test/include/have_federated_db.inc index abef5a64d30..041a29f460b 100644 --- a/mysql-test/include/have_federated_db.inc +++ b/mysql-test/include/have_federated_db.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'federated'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'federated'; enable_query_log; diff --git a/mysql-test/include/have_innodb.inc b/mysql-test/include/have_innodb.inc index be8850725e5..cbffe6a2574 100644 --- a/mysql-test/include/have_innodb.inc +++ b/mysql-test/include/have_innodb.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'innodb'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'innodb'; enable_query_log; diff --git a/mysql-test/include/have_multi_ndb.inc b/mysql-test/include/have_multi_ndb.inc index 819518b2674..e9baf7d56e5 100644 --- a/mysql-test/include/have_multi_ndb.inc +++ b/mysql-test/include/have_multi_ndb.inc @@ -10,7 +10,7 @@ drop table if exists t1, t2; --enable_warnings flush tables; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; # Check that server2 has NDB support @@ -21,7 +21,7 @@ drop table if exists t1, t2; --enable_warnings flush tables; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; # Check should be here as well... diff --git a/mysql-test/include/have_ndb.inc b/mysql-test/include/have_ndb.inc index c9603634508..638a88f3956 100644 --- a/mysql-test/include/have_ndb.inc +++ b/mysql-test/include/have_ndb.inc @@ -1,7 +1,7 @@ # Check that server is compiled and started with support for NDB disable_query_log; --require r/true.require -select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 745ec2e2248..157c82ec1fc 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1400,7 +1400,7 @@ VIEWS information_schema.VIEWS 1 End of 5.0 tests. select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO +MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO grant select on *.* to user3148@localhost; select user,db from information_schema.processlist; user db diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bf86555641a..81c66b8c835 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3259,6 +3259,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, handlerton *hton= plugin_data(plugin, handlerton *); const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; CHARSET_INFO *scs= system_charset_info; + handlerton *default_type= ha_default_handlerton(thd); DBUG_ENTER("iter_schema_engines"); if (!(hton->flags & HTON_HIDDEN)) @@ -3274,8 +3275,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, restore_record(table, s->default_values); table->field[0]->store(name->str, name->length, scs); - if (hton->state == SHOW_OPTION_YES && - hton == thd->variables.table_type) + if (hton->state == SHOW_OPTION_YES && default_type == hton) option_name= "DEFAULT"; table->field[1]->store(option_name, strlen(option_name), scs); table->field[2]->store(plugin_decl(plugin)->descr, From ce4e9f7580c02d1e7c5587bccb3a2a2ed7b0cc69 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 16:52:37 +0500 Subject: [PATCH 086/156] Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong IS_UPDATABLE flag is set to 'yes' when the view has at least one updatable column and the algorithm is not 'temporary'. mysql-test/r/information_schema.result: test result mysql-test/r/view.result: test result mysql-test/t/information_schema.test: test case mysql-test/t/view.test: test case sql/sql_show.cc: IS_UPDATABLE flag is set to 'yes' when the view has at least one updatable column and the algorithm is not 'temporary'. --- mysql-test/r/information_schema.result | 11 ++++++++++ mysql-test/r/view.result | 13 +++++++++++ mysql-test/t/information_schema.test | 15 +++++++++++++ mysql-test/t/view.test | 4 ++++ sql/sql_show.cc | 30 +++++++++++++++++++++++++- 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index db703df1f52..4947fd7aecc 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1315,3 +1315,14 @@ TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1 TRIGGERS information_schema.TRIGGERS 1 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1 VIEWS information_schema.VIEWS 1 +create table t1(f1 int); +create view v1 as select f1+1 as a from t1; +create table t2 (f1 int, f2 int); +create view v2 as select f1+1 as a, f2 as b from t2; +select table_name, is_updatable from information_schema.views; +table_name is_updatable +v1 NO +v2 YES +delete from v1; +drop view v1,v2; +drop table t1,t2; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 43e147724c8..3757c5fd451 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -23,6 +23,9 @@ c 5 6 11 +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +NO create temporary table t1 (a int, b int); select * from t1; a b @@ -322,6 +325,12 @@ create table t1 (a int, b int, primary key(a)); insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); create view v1 (a,c) as select a, b+1 from t1; create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +is_updatable +NO +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +YES update v1 set c=a+c; ERROR HY000: Column 'c' is not updatable update v2 set a=a+c; @@ -604,6 +613,10 @@ insert into t1 values(5,'Hello, world of views'); create view v1 as select * from t1; create view v2 as select * from v1; update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views; +is_updatable +YES +YES select * from t1; col1 col2 5 Hello, view world diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index f8922317eb3..1d368ac6075 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1023,4 +1023,19 @@ where t.table_schema = 'information_schema' and group by c2.column_type order by num limit 1) group by t.table_name order by num1, t.table_name; +# +# Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong +# +create table t1(f1 int); +create view v1 as select f1+1 as a from t1; +create table t2 (f1 int, f2 int); +create view v2 as select f1+1 as a, f2 as b from t2; +select table_name, is_updatable from information_schema.views; +# +# Note: we can perform 'delete' for non updatable view. +# +delete from v1; +drop view v1,v2; +drop table t1,t2; + # End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index f574451af08..3c370da4139 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -32,6 +32,7 @@ create view v1 (c,d) as select a,b from t1 # simple view create view v1 (c) as select b+1 from t1; select c from v1; +select is_updatable from information_schema.views where table_name='v1'; # temporary table should not hide table of view create temporary table t1 (a int, b int); @@ -228,6 +229,8 @@ create table t1 (a int, b int, primary key(a)); insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); create view v1 (a,c) as select a, b+1 from t1; create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +select is_updatable from information_schema.views where table_name='v1'; # try to update expression -- error 1348 update v1 set c=a+c; @@ -497,6 +500,7 @@ insert into t1 values(5,'Hello, world of views'); create view v1 as select * from t1; create view v2 as select * from v1; update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views; select * from t1; drop view v2, v1; drop table t1; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 16ed20cd479..a0db458be78 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3158,6 +3158,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, DBUG_ENTER("get_schema_views_record"); char definer[USER_HOST_BUFF_SIZE]; uint definer_len; + bool updatable_view; if (tables->view) { @@ -3195,7 +3196,34 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, else table->field[4]->store(STRING_WITH_LEN("NONE"), cs); - if (tables->updatable_view) + updatable_view= 0; + if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE) + { + /* + We should use tables->view->select_lex.item_list here and + can not use Field_iterator_view because the view always uses + temporary algorithm during opening for I_S and + TABLE_LIST fields 'field_translation' & 'field_translation_end' + are uninitialized is this case. + */ + List *fields= &tables->view->select_lex.item_list; + List_iterator it(*fields); + Item *item; + Item_field *field; + /* + chech that at least one coulmn in view is updatable + */ + while ((item= it++)) + { + if ((field= item->filed_for_view_update()) && field->field && + !field->field->table->pos_in_table_list->schema_table) + { + updatable_view= 1; + break; + } + } + } + if (updatable_view) table->field[5]->store(STRING_WITH_LEN("YES"), cs); else table->field[5]->store(STRING_WITH_LEN("NO"), cs); From 71aa571d09a0823dcf0b1528f6f0103a7adfcf72 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 17:46:09 +0500 Subject: [PATCH 087/156] Bug#28149 overflow in some "SHOW STATUS"-variables changed bytes_received, bytes_sent status variables to longlong sql/mysqld.cc: changed bytes_received, bytes_sent status variables to longlong sql/sql_class.h: changed bytes_received, bytes_sent status variables to longlong sql/sql_show.cc: changed bytes_received, bytes_sent status variables to longlong sql/structs.h: changed bytes_received, bytes_sent status variables to longlong --- sql/mysqld.cc | 4 ++-- sql/sql_class.h | 4 ++-- sql/sql_show.cc | 2 ++ sql/structs.h | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5dfb191c142..ca6bcff3b45 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6190,8 +6190,8 @@ struct show_var_st status_vars[]= { {"Aborted_connects", (char*) &aborted_connects, SHOW_LONG}, {"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG}, {"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG}, - {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONG_STATUS}, - {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONG_STATUS}, + {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS}, + {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS}, {"Com_admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS}, {"Com_alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS}, {"Com_alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 2ff5448f3e4..50c45d461e0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -606,8 +606,8 @@ struct system_variables typedef struct system_status_var { - ulong bytes_received; - ulong bytes_sent; + ulonglong bytes_received; + ulonglong bytes_sent; ulong com_other; ulong com_stat[(uint) SQLCOM_END]; ulong created_tmp_disk_tables; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a0db458be78..902b298e423 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1463,6 +1463,8 @@ static bool show_status_array(THD *thd, const char *wild, case SHOW_LONG_CONST: end= int10_to_str(*(long*) value, buff, 10); break; + case SHOW_LONGLONG_STATUS: + value= ((char *) status_var + (ulonglong) value); case SHOW_LONGLONG: end= longlong10_to_str(*(longlong*) value, buff, 10); break; diff --git a/sql/structs.h b/sql/structs.h index de4cc25db9f..28bdd8c1519 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -190,7 +190,8 @@ enum SHOW_TYPE SHOW_NET_COMPRESSION, SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING, SHOW_SLAVE_RETRIED_TRANS, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_CONST_LONG, SHOW_KEY_CACHE_LONGLONG, - SHOW_LONG_STATUS, SHOW_LONG_CONST_STATUS, SHOW_SLAVE_SKIP_ERRORS + SHOW_LONG_STATUS, SHOW_LONG_CONST_STATUS, SHOW_SLAVE_SKIP_ERRORS, + SHOW_LONGLONG_STATUS }; enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED}; From 59d139eb293e1bcf72cf544e2b8dbe9216ee7acb Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Jun 2007 18:18:34 +0500 Subject: [PATCH 088/156] compiler warning fix --- sql/item_strfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f9a0f715985..33e9b8de823 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3334,7 +3334,7 @@ String *Item_func_uuid::val_str(String *str) *--s=_dig_vec_lower[mac[i] >> 4]; } randominit(&uuid_rand, tmp + (ulong) server_start_time, - tmp + thd->status_var.bytes_sent); + tmp + (ulong) thd->status_var.bytes_sent); set_clock_seq_str(); } From 8becfb5fdba82271a65d1f7f4fdb8cb7cc2bc842 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 13:38:37 +0400 Subject: [PATCH 089/156] item_cmpfunc.cc, field.cc, sql_insert.cc, sql_class.h, sql_yacc.yy: Post merge fix. sql/sql_yacc.yy: Post merge fix. sql/sql_insert.cc: Post merge fix. sql/sql_class.h: Post merge fix. sql/item_cmpfunc.cc: Post merge fix. sql/field.cc: Post merge fix. --- sql/field.cc | 4 ++-- sql/item_cmpfunc.cc | 1 + sql/sql_class.h | 1 + sql/sql_insert.cc | 1 + sql/sql_yacc.yy | 6 ++++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index ff1b47441b0..ce30c5a4744 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6426,8 +6426,8 @@ uint Field_string::get_key_image(uchar *buff, uint length, imagetype type_arg) length / field_charset->mbmaxlen); memcpy(buff, ptr, bytes); if (bytes < length) - field_charset->cset->fill(field_charset, buff + bytes, length - bytes, - field_charset->pad_char); + field_charset->cset->fill(field_charset, (char*) buff + bytes, + length - bytes, field_charset->pad_char); return bytes; } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 19809ed08c7..39ea5ae1236 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1772,6 +1772,7 @@ void Item_func_between::fix_length_and_dec() int i; bool datetime_found= FALSE; compare_as_dates= TRUE; + THD *thd= current_thd; /* As some compare functions are generated after sql_yacc, diff --git a/sql/sql_class.h b/sql/sql_class.h index d9dc4117319..817a1e51e0e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -73,6 +73,7 @@ typedef struct st_copy_info { ha_rows updated; ha_rows copied; ha_rows error_count; + ha_rows touched; /* Number of touched records */ enum enum_duplicates handle_duplicates; int escape_char, last_errno; bool ignore; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index a97af9225f0..4a5bcd55e89 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1429,6 +1429,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } goto err; } + info->touched++; if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) || compare_record(table)) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 523fd254d6c..9ed512bb5fb 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7509,7 +7509,8 @@ select_derived2: { LEX *lex= Lex; lex->derived_tables|= DERIVED_SUBQUERY; - if (!lex->expr_allows_subselect) + if (!lex->expr_allows_subselect || + lex->sql_command == (int)SQLCOM_PURGE) { my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; @@ -11231,7 +11232,8 @@ subselect_init: subselect_start: { LEX *lex=Lex; - if (!lex->expr_allows_subselect) + if (!lex->expr_allows_subselect || + lex->sql_command == (int)SQLCOM_PURGE) { my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; From 2b42067f1adf4aed3c142c1bf20c92d613832618 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 17:02:16 +0400 Subject: [PATCH 090/156] error_simulation.result, item.cc, subselect.result, error_simulation.test: Post merge fix. mysql-test/t/error_simulation.test: Post merge fix. mysql-test/r/subselect.result: Post merge fix. mysql-test/r/error_simulation.result: Post merge fix. sql/item.cc: Post merge fix. --- mysql-test/r/error_simulation.result | 2 +- mysql-test/r/subselect.result | 12 ++++++------ mysql-test/t/error_simulation.test | 1 + sql/item.cc | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result index 805e8fabbd8..77599ba303b 100644 --- a/mysql-test/r/error_simulation.result +++ b/mysql-test/r/error_simulation.result @@ -14,6 +14,6 @@ INSERT INTO t1 VALUES ('AAAAAAAAAJ','AAAAAAAAAJ'), ('AAAAAAAAAK','AAAAAAAAAK'); set tmp_table_size=1024; SELECT MAX(a) FROM t1 GROUP BY a,b; -ERROR 23000: Can't write; duplicate key in table '' +ERROR 23000: Can't write; duplicate key in table 'tmp_table' set tmp_table_size=default; DROP TABLE t1; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 2982c44b3d6..92cd58f2ba3 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4074,6 +4074,12 @@ CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (1), (2); EXPLAIN EXTENDED SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 100.00 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `res`.`count(*)` AS `count(*)` from (select count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`a`) `res` +DROP TABLE t1; CREATE TABLE t1 ( a varchar(255) default NULL, b timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -4100,12 +4106,6 @@ d1 1 1 DROP TABLE t1,t2; -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL NULL NULL NULL NULL 2 100.00 -2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort -Warnings: -Note 1003 select `res`.`count(*)` AS `count(*)` from (select count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`a`) `res` -DROP TABLE t1; End of 5.0 tests. CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (2,22),(1,11),(2,22); diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index 8c044224b8a..2f6ea5eac87 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -21,6 +21,7 @@ INSERT INTO t1 VALUES set tmp_table_size=1024; +--replace_regex /in table '[^']+'/in table 'tmp_table'/ --error ER_DUP_KEY SELECT MAX(a) FROM t1 GROUP BY a,b; diff --git a/sql/item.cc b/sql/item.cc index c6d7e82cbd0..444f394f4fb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4403,7 +4403,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) field= new Field_blob(max_length, maybe_null, name, collation.collation); break; // Blob handled outside of case case MYSQL_TYPE_GEOMETRY: - return new Field_geom(max_length, maybe_null, name, table->s, + field= new Field_geom(max_length, maybe_null, name, table->s, (Field::geometry_type) ((type() == Item::TYPE_HOLDER) ? ((Item_type_holder *)this)->get_geometry_type() : From 2821723e0fc9738b33c188a8d3729586935186e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 17:19:20 +0200 Subject: [PATCH 091/156] internal interface to ndb (to be used by e.g. ndb_restore) storage/ndb/src/ndbapi/ndb_internal.hpp: New BitKeeper file ``storage/ndb/src/ndbapi/ndb_internal.hpp'' --- storage/ndb/include/ndbapi/Ndb.hpp | 1 + .../ndb/src/ndbapi/NdbEventOperationImpl.cpp | 3 ++- storage/ndb/src/ndbapi/ndb_internal.hpp | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 storage/ndb/src/ndbapi/ndb_internal.hpp diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp index 5f96408ea30..e677616f43b 100644 --- a/storage/ndb/include/ndbapi/Ndb.hpp +++ b/storage/ndb/include/ndbapi/Ndb.hpp @@ -1055,6 +1055,7 @@ class Ndb friend class NdbDictInterface; friend class NdbBlob; friend class NdbImpl; + friend class Ndb_internal; #endif public: diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 00acfe62ad9..bfedf30d201 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -41,6 +41,7 @@ #include #include "NdbEventOperationImpl.hpp" #include +#include "ndb_internal.hpp" #include extern EventLogger g_eventLogger; @@ -2838,7 +2839,7 @@ send_report: data[5]= apply_gci >> 32; data[6]= latest_gci & ~(Uint32)0; data[7]= latest_gci >> 32; - m_ndb->theImpl->send_event_report(data,8); + Ndb_internal().send_event_report(m_ndb, data,8); #ifdef VM_TRACE assert(m_total_alloc >= m_free_data_sz); #endif diff --git a/storage/ndb/src/ndbapi/ndb_internal.hpp b/storage/ndb/src/ndbapi/ndb_internal.hpp new file mode 100644 index 00000000000..488946dec83 --- /dev/null +++ b/storage/ndb/src/ndbapi/ndb_internal.hpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include + +class Ndb_internal +{ +private: + friend class NdbEventBuffer; + Ndb_internal() {} + virtual ~Ndb_internal() {} + int send_event_report(Ndb *ndb, Uint32 *data, Uint32 length) + { return ndb->theImpl->send_event_report(data, length); } +}; From 5e047ec91bfe6a644523643e1fd664cd2458fd3e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 17:28:52 +0200 Subject: [PATCH 092/156] change include file --- storage/ndb/src/ndbapi/ndb_internal.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/ndb/src/ndbapi/ndb_internal.hpp b/storage/ndb/src/ndbapi/ndb_internal.hpp index 488946dec83..2ed7a7ecc8c 100644 --- a/storage/ndb/src/ndbapi/ndb_internal.hpp +++ b/storage/ndb/src/ndbapi/ndb_internal.hpp @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include "NdbImpl.hpp" class Ndb_internal { From ab0df1eb16cf1838407e68bcfa45c84468b0c61a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 17:50:39 +0200 Subject: [PATCH 093/156] make function static --- storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp | 2 +- storage/ndb/src/ndbapi/ndb_internal.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index bfedf30d201..a82983fca8c 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -2839,7 +2839,7 @@ send_report: data[5]= apply_gci >> 32; data[6]= latest_gci & ~(Uint32)0; data[7]= latest_gci >> 32; - Ndb_internal().send_event_report(m_ndb, data,8); + Ndb_internal::send_event_report(m_ndb, data,8); #ifdef VM_TRACE assert(m_total_alloc >= m_free_data_sz); #endif diff --git a/storage/ndb/src/ndbapi/ndb_internal.hpp b/storage/ndb/src/ndbapi/ndb_internal.hpp index 2ed7a7ecc8c..f5f37f95a04 100644 --- a/storage/ndb/src/ndbapi/ndb_internal.hpp +++ b/storage/ndb/src/ndbapi/ndb_internal.hpp @@ -21,6 +21,6 @@ private: friend class NdbEventBuffer; Ndb_internal() {} virtual ~Ndb_internal() {} - int send_event_report(Ndb *ndb, Uint32 *data, Uint32 length) + static int send_event_report(Ndb *ndb, Uint32 *data, Uint32 length) { return ndb->theImpl->send_event_report(data, length); } }; From 023f3dd0df68b04f5bca6e0a15f1f4d426731383 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Jun 2007 22:55:21 +0400 Subject: [PATCH 094/156] grant2.result: Post merge fix. mysql-test/r/grant2.result: Post merge fix. --- mysql-test/r/grant2.result | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 3f466d02724..21bad4fddcb 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -380,24 +380,6 @@ drop function f2; drop table t2; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; drop user `a@`@localhost; -grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; -grant usage on *.* to mysqltest_2@localhost; -create database mysqltest_1; -use mysqltest_1; -create table t1 (f1 int); -grant create on `mysqltest\_1`.* to mysqltest_2@localhost; -grant select on mysqltest_1.t1 to mysqltest_2@localhost; -create database mysqltest_3; -ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest_3' -use mysqltest_1; -create table t2(f1 int); -select * from t1; -f1 -drop database mysqltest_1; -revoke all privileges, grant option from mysqltest_1@localhost; -revoke all privileges, grant option from mysqltest_2@localhost; -drop user mysqltest_1@localhost; -drop user mysqltest_2@localhost; SET GLOBAL log_bin_trust_function_creators = 0; drop database if exists mysqltest_1; drop database if exists mysqltest_2; @@ -422,4 +404,22 @@ use test; drop database mysqltest_1; drop database mysqltest_2; drop user mysqltest_u1@localhost; +grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; +grant usage on *.* to mysqltest_2@localhost; +create database mysqltest_1; +use mysqltest_1; +create table t1 (f1 int); +grant create on `mysqltest\_1`.* to mysqltest_2@localhost; +grant select on mysqltest_1.t1 to mysqltest_2@localhost; +create database mysqltest_3; +ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest_3' +use mysqltest_1; +create table t2(f1 int); +select * from t1; +f1 +drop database mysqltest_1; +revoke all privileges, grant option from mysqltest_1@localhost; +revoke all privileges, grant option from mysqltest_2@localhost; +drop user mysqltest_1@localhost; +drop user mysqltest_2@localhost; End of 5.0 tests From ccf393b67a9bcf52db91806f49c940ccd08545cc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 01:41:23 +0400 Subject: [PATCH 095/156] Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. When the INSERT .. ON DUPLICATE KEY UPDATE has to update a matched row but the new data is the same as in the record then it returns as if no rows were inserted or updated. Nevertheless the row is silently updated. This leads to a situation when zero updated rows are reported in the case when data has actually been changed. Now the write_record function updates a row only if new data differs from that in the record. sql/sql_insert.cc: Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. Now the write_record function updates a row only if new data differs from that in the record. mysql-test/r/insert_update.result: Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. mysql-test/t/insert_update.test: Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. --- mysql-test/r/insert_update.result | 14 ++++++++++++++ mysql-test/t/insert_update.test | 16 ++++++++++++++++ sql/sql_insert.cc | 28 ++++++++++++++-------------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index b3bca7517f3..20cde86101e 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -393,3 +393,17 @@ id c1 cnt 1 0 3 2 2 1 DROP TABLE t1; +create table t1(f1 int primary key, +f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @stamp1:=f2 from t1; +@stamp1:=f2 +# +insert into t1(f1) values(1) on duplicate key update f1=1; +select @stamp2:=f2 from t1; +@stamp2:=f2 +# +select if( @stamp1 = @stamp2, "correct", "wrong"); +if( @stamp1 = @stamp2, "correct", "wrong") +correct +drop table t1; diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index 725fbdb25d7..67108744ec6 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -290,3 +290,19 @@ INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2 SELECT * FROM t1; DROP TABLE t1; + +# +# Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it +# shouldn't. +# +create table t1(f1 int primary key, + f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +--replace_column 1 # +select @stamp1:=f2 from t1; +--sleep 2 +insert into t1(f1) values(1) on duplicate key update f1=1; +--replace_column 1 # +select @stamp2:=f2 from t1; +select if( @stamp1 = @stamp2, "correct", "wrong"); +drop table t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f3ed3ebab24..228fc8860ae 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1404,23 +1404,18 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) 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) - { - goto ok_or_after_trg_err; - } - goto err; - } - - if (table->next_number_field) - table->file->adjust_next_insert_id_after_explicit_value( - table->next_number_field->val_int()); - info->touched++; - if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || compare_record(table, thd->query_id)) { + if ((error=table->file->update_row(table->record[1],table->record[0]))) + { + if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) + { + goto ok_or_after_trg_err; + } + goto err; + } + info->updated++; trg_error= (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, @@ -1429,6 +1424,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) info->copied++; } + if (table->next_number_field) + table->file->adjust_next_insert_id_after_explicit_value( + table->next_number_field->val_int()); + info->touched++; + goto ok_or_after_trg_err; } else /* DUP_REPLACE */ From 1f90b253d4ff5d80f369c167aff8f8e775d75de0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 09:13:42 +0200 Subject: [PATCH 096/156] ndb - bug#29044 Improve buddy high order allocation Make removeCommonArea O(1) instead of O(N) Add limit to left/right search storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp: Add info to buddy module test about 1) loops being made in buddy 2) how much was allocated storage/ndb/src/kernel/blocks/dbtup/DbtupPagMan.cpp: 1) make removeCommonArea o(1) - as list is (after fix) double linked anyway 2) set page_state = ZFREE_COMMON insertCommonArea and ~ZFREE_COMMON in removeCommonArea 3) add max loops in search left/right 4) add more debug info --- .../src/kernel/blocks/dbtup/DbtupDebug.cpp | 47 +++++++++++--- .../src/kernel/blocks/dbtup/DbtupPagMan.cpp | 61 +++++++++++++------ 2 files changed, 83 insertions(+), 25 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp index ecee7e867f8..9b60d5d47ed 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp @@ -76,6 +76,10 @@ Dbtup::reportMemoryUsage(Signal* signal, int incDec){ sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 6, JBB); } +#ifdef VM_TRACE +extern Uint32 fc_left, fc_right, fc_remove; +#endif + void Dbtup::execDUMP_STATE_ORD(Signal* signal) { @@ -157,12 +161,20 @@ Dbtup::execDUMP_STATE_ORD(Signal* signal) return; }//if #endif -#if defined VM_TRACE && 0 - if (type == 1211){ - ndbout_c("Startar modul test av Page Manager"); +#if defined VM_TRACE + if (type == 1211 || type == 1212 || type == 1213){ + Uint32 seed = time(0); + if (signal->getLength() > 1) + seed = signal->theData[1]; + ndbout_c("Startar modul test av Page Manager (seed: 0x%x)", seed); + srand(seed); Vector chunks; const Uint32 LOOPS = 1000; + Uint32 sum_req = 0; + Uint32 sum_conf = 0; + Uint32 sum_loop = 0; + Uint32 max_loop = 0; for(Uint32 i = 0; i> 3) + (sum_conf >> 4); + } switch(c){ case 0:{ // Release const int ch = rand() % chunks.size(); @@ -192,23 +211,33 @@ Dbtup::execDUMP_STATE_ORD(Signal* signal) case 2: { // Seize(n) - fail alloc += free; // Fall through + sum_req += free; + goto doalloc; } case 1: { // Seize(n) (success) - + sum_req += alloc; + doalloc: Chunk chunk; allocConsPages(alloc, chunk.pageCount, chunk.pageId); ndbrequire(chunk.pageCount <= alloc); if(chunk.pageCount != 0){ chunks.push_back(chunk); if(chunk.pageCount != alloc) { - ndbout_c(" Tried to allocate %d - only allocated %d - free: %d", - alloc, chunk.pageCount, free); + if (type == 1211) + ndbout_c(" Tried to allocate %d - only allocated %d - free: %d", + alloc, chunk.pageCount, free); } } else { ndbout_c(" Failed to alloc %d pages with %d pages free", alloc, free); } + sum_conf += chunk.pageCount; + Uint32 tot = fc_left + fc_right + fc_remove; + sum_loop += tot; + if (tot > max_loop) + max_loop = tot; + for(Uint32 i = 0; i 0) { + Uint32 loop = 0; + while (allocPageRef > 0 && + ++loop < 16) + { ljam(); pageLastPtr.i = allocPageRef - 1; c_page_pool.getPtr(pageLastPtr); @@ -258,6 +268,9 @@ void Dbtup::findFreeLeftNeighbours(Uint32& allocPageRef, remainAllocate -= listSize; }//if }//if +#ifdef VM_TRACE + fc_left++; +#endif }//while }//Dbtup::findFreeLeftNeighbours() @@ -271,7 +284,10 @@ void Dbtup::findFreeRightNeighbours(Uint32& allocPageRef, ljam(); return; }//if - while ((allocPageRef + noPagesAllocated) < c_page_pool.getSize()) { + Uint32 loop = 0; + while ((allocPageRef + noPagesAllocated) < c_page_pool.getSize() && + ++loop < 16) + { ljam(); pageFirstPtr.i = allocPageRef + noPagesAllocated; c_page_pool.getPtr(pageFirstPtr); @@ -298,24 +314,37 @@ void Dbtup::findFreeRightNeighbours(Uint32& allocPageRef, remainAllocate -= listSize; }//if }//if +#ifdef VM_TRACE + fc_right++; +#endif }//while }//Dbtup::findFreeRightNeighbours() void Dbtup::insertCommonArea(Uint32 insPageRef, Uint32 insList) { cnoOfAllocatedPages -= (1 << insList); - PagePtr pageLastPtr, pageInsPtr; + PagePtr pageLastPtr, pageInsPtr, pageHeadPtr; + pageHeadPtr.i = cfreepageList[insList]; c_page_pool.getPtr(pageInsPtr, insPageRef); ndbrequire(insList < 16); pageLastPtr.i = (pageInsPtr.i + (1 << insList)) - 1; - pageInsPtr.p->next_cluster_page = cfreepageList[insList]; + pageInsPtr.p->page_state = ZFREE_COMMON; + pageInsPtr.p->next_cluster_page = pageHeadPtr.i; pageInsPtr.p->prev_cluster_page = RNIL; pageInsPtr.p->last_cluster_page = pageLastPtr.i; cfreepageList[insList] = pageInsPtr.i; + if (pageHeadPtr.i != RNIL) + { + jam(); + c_page_pool.getPtr(pageHeadPtr); + pageHeadPtr.p->prev_cluster_page = pageInsPtr.i; + } + c_page_pool.getPtr(pageLastPtr); + pageLastPtr.p->page_state = ZFREE_COMMON; pageLastPtr.p->first_cluster_page = pageInsPtr.i; pageLastPtr.p->next_page = RNIL; }//Dbtup::insertCommonArea() @@ -323,12 +352,13 @@ void Dbtup::insertCommonArea(Uint32 insPageRef, Uint32 insList) void Dbtup::removeCommonArea(Uint32 remPageRef, Uint32 list) { cnoOfAllocatedPages += (1 << list); - PagePtr pagePrevPtr, pageNextPtr, pageLastPtr, pageSearchPtr, remPagePtr; + PagePtr pagePrevPtr, pageNextPtr, pageLastPtr, remPagePtr; c_page_pool.getPtr(remPagePtr, remPageRef); ndbrequire(list < 16); if (cfreepageList[list] == remPagePtr.i) { ljam(); + ndbassert(remPagePtr.p->prev_cluster_page == RNIL); cfreepageList[list] = remPagePtr.p->next_cluster_page; pageNextPtr.i = cfreepageList[list]; if (pageNextPtr.i != RNIL) { @@ -337,30 +367,25 @@ void Dbtup::removeCommonArea(Uint32 remPageRef, Uint32 list) pageNextPtr.p->prev_cluster_page = RNIL; }//if } else { - pageSearchPtr.i = cfreepageList[list]; - while (true) { - ljam(); - c_page_pool.getPtr(pageSearchPtr); - pagePrevPtr = pageSearchPtr; - pageSearchPtr.i = pageSearchPtr.p->next_cluster_page; - if (pageSearchPtr.i == remPagePtr.i) { - ljam(); - break; - }//if - }//while + pagePrevPtr.i = remPagePtr.p->prev_cluster_page; pageNextPtr.i = remPagePtr.p->next_cluster_page; + c_page_pool.getPtr(pagePrevPtr); pagePrevPtr.p->next_cluster_page = pageNextPtr.i; - if (pageNextPtr.i != RNIL) { + if (pageNextPtr.i != RNIL) + { ljam(); c_page_pool.getPtr(pageNextPtr); pageNextPtr.p->prev_cluster_page = pagePrevPtr.i; - }//if + } }//if remPagePtr.p->next_cluster_page= RNIL; remPagePtr.p->last_cluster_page= RNIL; remPagePtr.p->prev_cluster_page= RNIL; + remPagePtr.p->page_state = ~ZFREE_COMMON; pageLastPtr.i = (remPagePtr.i + (1 << list)) - 1; c_page_pool.getPtr(pageLastPtr); pageLastPtr.p->first_cluster_page= RNIL; + pageLastPtr.p->page_state = ~ZFREE_COMMON; + }//Dbtup::removeCommonArea() From e164c08eafb005aa42da3fda2c97e374ee205c9b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 11:02:34 +0300 Subject: [PATCH 097/156] Bug #28934: server crash when receiving malformed com_execute packets Sometimes a parameter slot may not get a value because of the protocol data being plain wrong. Such cases should be detected and handled by returning an error. Fixed by checking data stream constraints where possible (like maximum length) and reacting to the case where a value cannot be constructed. sql/sql_prepare.cc: Bug #28934: - check for a parameter slot not being set because of wrong data - check if the length read from the stream is not greater than the maximum length of the field tests/mysql_client_test.c: Bug #28934: test case --- sql/sql_prepare.cc | 10 +++++ tests/mysql_client_test.c | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 42655608196..1453a377600 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -562,6 +562,8 @@ void set_param_date(Item_param *param, uchar **pos, ulong len) static void set_param_str(Item_param *param, uchar **pos, ulong len) { ulong length= get_param_length(pos, len); + if (length > len) + length= len; param->set_str((const char *)*pos, length); *pos+= length; } @@ -731,6 +733,8 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, if (read_pos >= data_end) DBUG_RETURN(1); param->set_param_func(param, &read_pos, data_end - read_pos); + if (param->state == Item_param::NO_VALUE) + DBUG_RETURN(1); } } res= param->query_val_str(&str); @@ -767,6 +771,8 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, if (read_pos >= data_end) DBUG_RETURN(1); param->set_param_func(param, &read_pos, data_end - read_pos); + if (param->state == Item_param::NO_VALUE) + DBUG_RETURN(1); } } if (param->convert_str_value(stmt->thd)) @@ -849,6 +855,8 @@ static bool emb_insert_params(Prepared_statement *stmt, String *expanded_query) client_param->length ? *client_param->length : client_param->buffer_length); + if (param->state == Item_param::NO_VALUE) + DBUG_RETURN(1); } } if (param->convert_str_value(thd)) @@ -890,6 +898,8 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query) client_param->length ? *client_param->length : client_param->buffer_length); + if (param->state == Item_param::NO_VALUE) + DBUG_RETURN(1); } } res= param->query_val_str(&str); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 54d29dbd683..7fc45b89b82 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15686,6 +15686,88 @@ end: } +/* + Bug#28934: server crash when receiving malformed com_execute packets +*/ + +static void test_bug28934() +{ + MYSQL *l_mysql; + my_bool error= 0; + my_ulonglong res; + MYSQL_BIND bind[5]; + MYSQL_STMT *stmt; + int cnt; + + if (!(l_mysql= mysql_init(NULL))) + { + myerror("mysql_init() failed"); + DIE_UNLESS(1); + } + if (!(mysql_real_connect(l_mysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_FOUND_ROWS))) + { + myerror("connection failed"); + error= 1; + goto end; + } + l_mysql->reconnect= 1; + if (mysql_query(l_mysql, "drop table if exists t1")) + { + myerror(NULL); + error= 1; + goto end; + } + if (mysql_query(l_mysql, "create table t1(id int)")) + { + myerror(NULL); + error= 1; + goto end; + } + if (mysql_query(l_mysql, "insert into t1 values(1),(2),(3),(4),(5)")) + { + myerror(NULL); + error= 1; + goto end; + } + if (!(stmt= mysql_simple_prepare(l_mysql, + "select * from t1 where id in(?,?,?,?,?)"))) + { + myerror(NULL); + error= 1; + goto end; + } + + memset (&bind, 0, sizeof (bind)); + for (cnt= 0; cnt < 5; cnt++) + { + bind[cnt].buffer_type= MYSQL_TYPE_LONG; + bind[cnt].buffer= (char*)&cnt; + bind[cnt].buffer_length= 0; + } + if(mysql_stmt_bind_param(stmt, bind)) + { + myerror(NULL); + error= 1; + goto end; + } + stmt->param_count=2; + error= mysql_stmt_execute(stmt); + DIE_UNLESS (error != 0); + myerror(NULL); + error= 0; + if (mysql_query(l_mysql, "drop table t1")) + { + myerror(NULL); + error= 1; + } +end: + mysql_close(l_mysql); + DIE_UNLESS(error == 0); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -15968,6 +16050,7 @@ static struct my_tests_st my_tests[]= { { "test_bug24179", test_bug24179 }, { "test_bug27876", test_bug27876 }, { "test_bug28505", test_bug28505 }, + { "test_bug28934", test_bug28934 }, { 0, 0 } }; From 98e08c79b029cc435f1a6fb61f822c709a9fedaa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 10:06:20 +0200 Subject: [PATCH 098/156] extend backup dump to give more info --- .../ndb/src/kernel/blocks/backup/Backup.cpp | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index 645eb590ae3..6ad81df20be 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -448,6 +448,41 @@ Backup::execDUMP_STATE_ORD(Signal* signal) filePtr.p->m_flags); } } + + ndbout_c("m_curr_disk_write_speed: %u m_words_written_this_period: %u m_overflow_disk_write: %u", + m_curr_disk_write_speed, m_words_written_this_period, m_overflow_disk_write); + ndbout_c("m_reset_delay_used: %u m_reset_disk_speed_time: %llu", + m_reset_delay_used, (Uint64)m_reset_disk_speed_time); + for(c_backups.first(ptr); ptr.i != RNIL; c_backups.next(ptr)) + { + ndbout_c("BackupRecord %u: BackupId: %u MasterRef: %x ClientRef: %x", + ptr.i, ptr.p->backupId, ptr.p->masterRef, ptr.p->clientRef); + ndbout_c(" State: %u", ptr.p->slaveState.getState()); + ndbout_c(" noOfByte: %llu noOfRecords: %llu", + ptr.p->noOfBytes, ptr.p->noOfRecords); + ndbout_c(" noOfLogBytes: %llu noOfLogRecords: %llu", + ptr.p->noOfLogBytes, ptr.p->noOfLogRecords); + ndbout_c(" errorCode: %u", ptr.p->errorCode); + BackupFilePtr filePtr; + for(ptr.p->files.first(filePtr); filePtr.i != RNIL; + ptr.p->files.next(filePtr)) + { + ndbout_c(" file %u: type: %u flags: H'%x tableId: %u fragmentId: %u", + filePtr.i, filePtr.p->fileType, filePtr.p->m_flags, + filePtr.p->tableId, filePtr.p->fragmentNo); + } + if (ptr.p->slaveState.getState() == SCANNING && ptr.p->dataFilePtr != RNIL) + { + c_backupFilePool.getPtr(filePtr, ptr.p->dataFilePtr); + OperationRecord & op = filePtr.p->operation; + Uint32 *tmp = NULL; + Uint32 sz = 0; + bool eof = FALSE; + bool ready = op.dataBuffer.getReadPtr(&tmp, &sz, &eof); + ndbout_c("ready: %s eof: %s", ready ? "TRUE" : "FALSE", eof ? "TRUE" : "FALSE"); + } + } + return; } if(signal->theData[0] == 24){ /** From 805d32bd0f4ad0faef62db9c09c76dcc50c66464 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 10:35:21 +0200 Subject: [PATCH 099/156] Bug#29044 - memory buddy allocator "unoptimal" memory handling - add config param to have better behavior with large tables --- .../ndb/include/mgmapi/mgmapi_config_parameters.h | 2 ++ storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 1 + storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 6 ++++++ storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp | 5 +++++ storage/ndb/src/mgmsrv/ConfigInfo.cpp | 12 ++++++++++++ 5 files changed, 26 insertions(+) diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index d0bd8be16a3..ac2cbf060fd 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -118,6 +118,8 @@ #define CFG_DB_O_DIRECT 168 +#define CFG_DB_MAX_ALLOCATE 169 + #define CFG_DB_SGA 198 /* super pool mem */ #define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */ diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index d59d5cd79f2..7845305da6c 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -2618,6 +2618,7 @@ private: ArrayPool c_page_pool; Uint32 cnoOfAllocatedPages; + Uint32 m_max_allocate_pages; Tablerec *tablerec; Uint32 cnoOfTablerec; diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index f4fd80a482a..3a8e996d435 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -308,6 +308,12 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) Uint32 noOfTriggers= 0; Uint32 tmp= 0; + + if (ndb_mgm_get_int_parameter(p, CFG_DB_MAX_ALLOCATE, &tmp)) + tmp = 32 * 1024 * 1024; + m_max_allocate_pages = (tmp + GLOBAL_PAGE_SIZE - 1) / GLOBAL_PAGE_SIZE; + + tmp = 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE_RANGE, &tmp)); initPageRangeSize(tmp); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_TABLE, &cnoOfTablerec)); diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp index 8493e0561cc..ed8f63ce3ad 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp @@ -434,6 +434,11 @@ void Dbtup::allocMoreFragPages(Fragrecord* const regFragPtr) // We will grow by 18.75% plus two more additional pages to grow // a little bit quicker in the beginning. /* -----------------------------------------------------------------*/ + + if (noAllocPages > m_max_allocate_pages) + { + noAllocPages = m_max_allocate_pages; + } Uint32 allocated = allocFragPages(regFragPtr, noAllocPages); regFragPtr->noOfPagesToGrow += allocated; }//Dbtup::allocMoreFragPages() diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index 56aacda214d..229824c49bf 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -1313,6 +1313,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "0", STR_VALUE(MAX_INT_RNIL) }, + { + CFG_DB_MAX_ALLOCATE, + "MaxAllocate", + DB_TOKEN, + "Maximum size of allocation to use when allocating memory for tables", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "32M", + "1M", + "1G" }, + { CFG_DB_MEMREPORT_FREQUENCY, "MemReportFrequency", From 030bb02b69944448b5fb5515d4f1cea26c57fa54 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 14:35:36 +0300 Subject: [PATCH 100/156] Bug #28992: trigger fails in pushbuild - fixed wrong test case for bug 20903 - closed the dangling connections in trigger.test - GET_LOCK() and RELEASE_LOCK() now produce more detailed log - fixed an omission in GET_LOCK() : assign the thread_id when acquiring the lock. mysql-test/r/trigger.result: Bug #28992: test case updated mysql-test/t/trigger.test: Bug #28992: test case updated. dangling connections closed. sql/item_func.cc: Bug #28992: - GET_LOCK() and RELEASE_LOCK() now produce more detailed log - fixed an omission in GET_LOCK() : assign the thread_id when acquiring the lock. --- mysql-test/r/trigger.result | 15 ++++++++------ mysql-test/t/trigger.test | 21 ++++++++++++++----- sql/item_func.cc | 41 +++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index fd9b15ab8ed..5405a632aa4 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1454,19 +1454,22 @@ CREATE TABLE t2 (id INTEGER); INSERT INTO t2 VALUES (1),(2); CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (new.id); -SELECT GET_LOCK('B26162',20); -GET_LOCK('B26162',20) +SELECT GET_LOCK('B26162',120); +GET_LOCK('B26162',120) 1 -SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1; +SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1; SET SESSION LOW_PRIORITY_UPDATES=1; SET GLOBAL LOW_PRIORITY_UPDATES=1; INSERT INTO t1 VALUES (5); SELECT 'rl_contender', id FROM t2 WHERE id > 1; SELECT RELEASE_LOCK('B26162'); RELEASE_LOCK('B26162') -0 -rl_acquirer GET_LOCK('B26162',5) id -rl_acquirer 0 1 +1 +rl_acquirer GET_LOCK('B26162',120) id +rl_acquirer 1 1 +SELECT RELEASE_LOCK('B26162'); +RELEASE_LOCK('B26162') +1 rl_contender id rl_contender 2 DROP TRIGGER t1_test; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 363df94eeb3..7158d02956e 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1763,6 +1763,9 @@ select * from t1; select * from t3; drop table t1, t2, t3; +disconnect addconroot1; +disconnect addconroot2; +disconnect addconwithoutdb; # # Bug #26162: Trigger DML ignores low_priority_updates setting # @@ -1776,19 +1779,23 @@ INSERT INTO t2 VALUES (1),(2); CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (new.id); +CONNECT (rl_holder, localhost, root,,); CONNECT (rl_acquirer, localhost, root,,); CONNECT (wl_acquirer, localhost, root,,); CONNECT (rl_contender, localhost, root,,); -SELECT GET_LOCK('B26162',20); +CONNECTION rl_holder; +SELECT GET_LOCK('B26162',120); CONNECTION rl_acquirer; --send -SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1; +SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1; CONNECTION wl_acquirer; SET SESSION LOW_PRIORITY_UPDATES=1; SET GLOBAL LOW_PRIORITY_UPDATES=1; +#need to wait for rl_acquirer to lock on the B26162 lock +sleep 2; --send INSERT INTO t1 VALUES (5); @@ -1798,13 +1805,16 @@ CONNECTION rl_contender; --send SELECT 'rl_contender', id FROM t2 WHERE id > 1; -CONNECTION default; +CONNECTION rl_holder; +#need to wait for wl_acquirer and rl_contender to lock on t2 +sleep 2; SELECT RELEASE_LOCK('B26162'); -CONNECTION wl_acquirer; ---reap CONNECTION rl_acquirer; --reap +SELECT RELEASE_LOCK('B26162'); +CONNECTION wl_acquirer; +--reap CONNECTION rl_contender; --reap @@ -1812,6 +1822,7 @@ CONNECTION default; DISCONNECT rl_acquirer; DISCONNECT wl_acquirer; DISCONNECT rl_contender; +DISCONNECT rl_holder; DROP TRIGGER t1_test; DROP TABLE t1,t2; diff --git a/sql/item_func.cc b/sql/item_func.cc index 580d19fbd4e..cc8830c6d6f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3449,6 +3449,7 @@ longlong Item_func_get_lock::val_int() THD *thd=current_thd; User_level_lock *ull; int error; + DBUG_ENTER("Item_func_get_lock::val_int"); /* In slave thread no need to get locks, everything is serialized. Anyway @@ -3458,7 +3459,7 @@ longlong Item_func_get_lock::val_int() it's not guaranteed to be same as on master. */ if (thd->slave_thread) - return 1; + DBUG_RETURN(1); pthread_mutex_lock(&LOCK_user_locks); @@ -3466,8 +3467,10 @@ longlong Item_func_get_lock::val_int() { pthread_mutex_unlock(&LOCK_user_locks); null_value=1; - return 0; + DBUG_RETURN(0); } + DBUG_PRINT("info", ("lock %.*s, thd=%ld", res->length(), res->ptr(), + (long) thd->real_id)); null_value=0; if (thd->ull) @@ -3486,14 +3489,17 @@ longlong Item_func_get_lock::val_int() delete ull; pthread_mutex_unlock(&LOCK_user_locks); null_value=1; // Probably out of memory - return 0; + DBUG_RETURN(0); } ull->thread=thd->real_id; + ull->thread_id=thd->thread_id; thd->ull=ull; pthread_mutex_unlock(&LOCK_user_locks); - return 1; // Got new lock + DBUG_PRINT("info", ("made new lock")); + DBUG_RETURN(1); // Got new lock } ull->count++; + DBUG_PRINT("info", ("ull->count=%d", ull->count)); /* Structure is now initialized. Try to get the lock. @@ -3507,9 +3513,13 @@ longlong Item_func_get_lock::val_int() error= 0; while (ull->locked && !thd->killed) { + DBUG_PRINT("info", ("waiting on lock")); error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime); if (error == ETIMEDOUT || error == ETIME) + { + DBUG_PRINT("info", ("lock wait timeout")); break; + } error= 0; } @@ -3533,6 +3543,7 @@ longlong Item_func_get_lock::val_int() ull->thread_id= thd->thread_id; thd->ull=ull; error=0; + DBUG_PRINT("info", ("got the lock")); } pthread_mutex_unlock(&LOCK_user_locks); @@ -3542,7 +3553,7 @@ longlong Item_func_get_lock::val_int() thd->mysys_var->current_cond= 0; pthread_mutex_unlock(&thd->mysys_var->mutex); - return !error ? 1 : 0; + DBUG_RETURN(!error ? 1 : 0); } @@ -3560,11 +3571,14 @@ longlong Item_func_release_lock::val_int() String *res=args[0]->val_str(&value); User_level_lock *ull; longlong result; + THD *thd=current_thd; + DBUG_ENTER("Item_func_release_lock::val_int"); if (!res || !res->length()) { null_value=1; - return 0; + DBUG_RETURN(0); } + DBUG_PRINT("info", ("lock %.*s", res->length(), res->ptr())); null_value=0; result=0; @@ -3577,19 +3591,20 @@ longlong Item_func_release_lock::val_int() } else { -#ifdef EMBEDDED_LIBRARY - if (ull->locked && pthread_equal(current_thd->real_id,ull->thread)) -#else - if (ull->locked && pthread_equal(pthread_self(),ull->thread)) -#endif + DBUG_PRINT("info", ("ull->locked=%d ull->thread=%ld thd=%ld", + (int) ull->locked, + (long)ull->thread, + (long)thd->real_id)); + if (ull->locked && pthread_equal(thd->real_id,ull->thread)) { + DBUG_PRINT("info", ("release lock")); result=1; // Release is ok item_user_lock_release(ull); - current_thd->ull=0; + thd->ull=0; } } pthread_mutex_unlock(&LOCK_user_locks); - return result; + DBUG_RETURN(result); } From 119412f8d0cc364678e8e3b3c36c42e6fea69e3d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 14:45:30 +0300 Subject: [PATCH 101/156] removed compilation warning --- tests/mysql_client_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7fc45b89b82..ed1f2d58278 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15694,7 +15694,6 @@ static void test_bug28934() { MYSQL *l_mysql; my_bool error= 0; - my_ulonglong res; MYSQL_BIND bind[5]; MYSQL_STMT *stmt; int cnt; From a8bb10ac9e9624f1987eb1412b19d0cad281db1d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 15:10:33 +0300 Subject: [PATCH 102/156] Bug#27634: group_by test fails On many architectures, e.g. 68000, x86, the double registers have higher precision than the IEEE standard prescribes. When compiled with flags -O and higher, some double's go into registers and therefore have higher precision. In one test case the cost information of the best and second-best key were close enough to be influenced by this effect, causing a failed test in distribution builds. Fixed by removing some rows from the table in question so that cost information is not influenced by decimals beyond standard definition of double. mysql-test/r/group_by.result: Bug#27634: Altered test reslut. The only difference in the results is in the 'rows' column. mysql-test/t/group_by.test: Bug#27634: Altered test case to avoid the corner case where excess precision causes non-minimum costs to appear minimal. --- mysql-test/r/group_by.result | 46 ++++++++++++++++++------------------ mysql-test/t/group_by.test | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index e3cd90b9b3d..ebe59331357 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1055,47 +1055,47 @@ INSERT INTO t1 SELECT a + 8,b FROM t1; INSERT INTO t1 SELECT a + 16,b FROM t1; INSERT INTO t1 SELECT a + 32,b FROM t1; INSERT INTO t1 SELECT a + 64,b FROM t1; -INSERT INTO t1 SELECT a + 128,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK EXPLAIN SELECT a FROM t1 WHERE a < 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 1 Using where; Using index EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 1 Using where; Using index EXPLAIN SELECT a FROM t1 WHERE a < 2 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 2 Using where; Using index +1 SIMPLE t1 range PRIMARY,i2 PRIMARY 4 NULL 1 Using where; Using index EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 256 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 256 Using index; Using filesort +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 256 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT a FROM t1 FORCE INDEX (i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT a FROM t1 USE INDEX (); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 USE INDEX () USE INDEX (i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 FORCE INDEX (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) @@ -1104,7 +1104,7 @@ USE INDEX (i2); ERROR HY000: Incorrect usage of USE INDEX and FORCE INDEX EXPLAIN SELECT a FROM t1 USE INDEX (i2) USE INDEX (); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT a FROM t1 FORCE INDEX (); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 EXPLAIN SELECT a FROM t1 IGNORE INDEX (); @@ -1112,34 +1112,34 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) USE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) FORCE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL i2 4 NULL 257 Using index for group-by +1 SIMPLE t1 range NULL i2 4 NULL 145 Using index for group-by EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 IGNORE INDEX (i2) USE INDEX (); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 256 +1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 USE INDEX FOR GROUP BY (i2) USE INDEX FOR ORDER BY (i2) USE INDEX FOR JOIN (i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) USE INDEX FOR JOIN (i2) USE INDEX FOR JOIN (i2,i2); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL i2 9 NULL 256 Using index +1 SIMPLE t1 index NULL i2 9 NULL 144 Using index EXPLAIN SELECT 1 FROM t1 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL PRIMARY 4 NULL 256 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 256 Using where +1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where CREATE TABLE t2 (a INT, b INT, KEY(a)); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; @@ -1152,7 +1152,7 @@ EXPLAIN SELECT 1 FROM t2 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 256 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where SHOW VARIABLES LIKE 'old'; Variable_name Value old OFF diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 4e21568377f..3db8972bc6b 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -780,7 +780,7 @@ INSERT INTO t1 SELECT a + 8,b FROM t1; INSERT INTO t1 SELECT a + 16,b FROM t1; INSERT INTO t1 SELECT a + 32,b FROM t1; INSERT INTO t1 SELECT a + 64,b FROM t1; -INSERT INTO t1 SELECT a + 128,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; ANALYZE TABLE t1; EXPLAIN SELECT a FROM t1 WHERE a < 2; EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; From 0a67a6e5b66ca8f1d84a8d5b8c6c29d97f8462e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 17:53:16 +0500 Subject: [PATCH 103/156] Bug #28757 Test program / embedded server crash in test "unsafe_binlog_innodb" the reported test failure is fixed by the patch to 28333, but there's a bit more to fix in the test itself - to drop tables created in this test at the test's beginning. mysql-test/include/unsafe_binlog.inc: remove tables created later in this test number error codes changed with the appropriate ER_something mysql-test/r/unsafe_binlog_innodb.result: test result fixed --- mysql-test/include/unsafe_binlog.inc | 22 +++++++++++----------- mysql-test/r/unsafe_binlog_innodb.result | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mysql-test/include/unsafe_binlog.inc b/mysql-test/include/unsafe_binlog.inc index 6fbbdcb6d6c..2fc2ad77bc9 100644 --- a/mysql-test/include/unsafe_binlog.inc +++ b/mysql-test/include/unsafe_binlog.inc @@ -23,7 +23,7 @@ # --disable_warnings -drop table if exists t1,t2; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; --enable_warnings eval create table t1 (id int not null, f_id int not null, f int not null, primary key(f_id, id)) engine = $engine_type; @@ -59,7 +59,7 @@ set autocommit = 0; # # S-lock to records (2,2),(4,2), and (6,2) should not be released in a update # ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT select * from t1 where a = 2 and b = 2 for update; connection a; commit; @@ -213,39 +213,39 @@ set autocommit = 0; create table t10(a int not null, b int, primary key(a)) select * from t2 for update; connection b; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection c; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection d; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection e; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection f; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection g; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection h; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection i; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection j; ---error 1205 +--error ER_LOCK_WAIT_TIMEOUT reap; connection a; diff --git a/mysql-test/r/unsafe_binlog_innodb.result b/mysql-test/r/unsafe_binlog_innodb.result index 54a24a52d57..b2cf16ad58f 100644 --- a/mysql-test/r/unsafe_binlog_innodb.result +++ b/mysql-test/r/unsafe_binlog_innodb.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; create table t1 (id int not null, f_id int not null, f int not null, primary key(f_id, id)) engine = InnoDB; create table t2 (id int not null,s_id int not null,s varchar(200), From 95ef943b9e08e30619425440a57c549aa61cb351 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 18:41:56 +0300 Subject: [PATCH 104/156] 5.0-opt -> 5.1-opt merge --- sql/item_func.cc | 6 +++--- sql/sql_insert.cc | 4 ++-- sql/sql_plugin.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index 606bb5fd561..70859aeb457 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3581,10 +3581,10 @@ longlong Item_func_release_lock::val_int() } else { - DBUG_PRINT("info", ("ull->locked=%d ull->thread=%ld thd=%ld", + DBUG_PRINT("info", ("ull->locked=%d ull->thread=%lu thd=%lu", (int) ull->locked, - (long)ull->thread, - (long)thd->real_id)); + (long)ull->thread_id, + (long)thd->thread_id)); if (ull->locked && current_thd->thread_id == ull->thread_id) { DBUG_PRINT("info", ("release lock")); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 66c48772c4e..0ce52779ce1 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1419,8 +1419,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto before_trg_err; table->file->restore_auto_increment(prev_insert_id); - if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || - compare_record(table, thd->query_id)) + if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) || + compare_record(table)) { if ((error=table->file->ha_update_row(table->record[1], table->record[0]))) diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 70ce21a64da..e8f2cb6ee5e 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -33,7 +33,8 @@ class sys_var; */ #define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \ SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \ - SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH + SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \ + SHOW_LONGLONG_STATUS #include #undef SHOW_FUNC typedef enum enum_mysql_show_type SHOW_TYPE; From 06b6749e2918a78324cd55e86e89fddcb169ffee Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 19:49:02 +0200 Subject: [PATCH 105/156] make_win_bin_dist: Aligned headers to include with Unix 'make install' scripts/make_win_bin_dist: Aligned headers to include with Unix 'make install' --- scripts/make_win_bin_dist | 44 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 30127b0043f..cecee4f57af 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -239,25 +239,45 @@ if [ x"$PACK_EMBEDDED" = x"" -a \ fi # ---------------------------------------------------------------------- -# FIXME why not copy it all in "include"?! +# Note: Make sure to sync with include/Makefile.am and WiX installer +# XML specifications # ---------------------------------------------------------------------- mkdir -p $DESTDIR/include -cp include/conf*.h \ - include/mysql*.h \ - include/errmsg.h \ - include/my_alloc.h \ - include/my_getopt.h \ - include/my_sys.h \ +cp include/mysql.h \ + include/mysql_com.h \ + include/mysql_time.h \ include/my_list.h \ - include/my_pthread.h \ + include/my_alloc.h \ + include/typelib.h \ include/my_dbug.h \ include/m_string.h \ - include/m_ctype.h \ - include/my_global.h \ + include/my_sys.h \ + include/my_xml.h \ + include/mysql_embed.h \ + include/my_pthread.h \ + include/my_no_pthread.h \ include/raid.h \ - include/typelib.h $DESTDIR/include/ -cp libmysql/libmysql.def $DESTDIR/include/ + include/decimal.h \ + include/errmsg.h \ + include/my_global.h \ + include/my_net.h \ + include/my_getopt.h \ + include/sslopt-longopts.h \ + include/my_dir.h \ + include/sslopt-vars.h \ + include/sslopt-case.h \ + include/sql_common.h \ + include/keycache.h \ + include/m_ctype.h \ + include/my_attribute.h \ + include/mysqld_error.h \ + include/sql_state.h \ + include/mysqld_ername.h + include/mysql_version.h \ + include/config-win.h \ + libmysql/libmysql.def \ + $DESTDIR/include/ # ---------------------------------------------------------------------- # Client libraries, and other libraries From cc4cfb3afd5ef49847cfa91ecc1f841dccbd13db Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Jun 2007 19:28:05 -0700 Subject: [PATCH 106/156] Bug#25800 "Embedded server requires mysql.plugin" Embedded builds should not print any error when the mysql.plugin table does not exist. This is achieved by checking for the existance of the mysql.plugin table before attempting to open it and proceed silently if it does not exist. sql/sql_plugin.cc: bug25800 Embedded builds should not print any error when the mysql.plugin table does not exist. This is achieved by checking for the existance of the mysql.plugin table before attempting to open it and proceed silently if it does not exist. --- sql/sql_plugin.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 37301751d03..ad521cb2ff7 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -210,6 +210,11 @@ static void reap_plugins(void); /* declared in set_var.cc */ extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error); +#ifdef EMBEDDED_LIBRARY +/* declared in sql_base.cc */ +extern bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists); +#endif /* EMBEDDED_LIBRARY */ + /**************************************************************************** Value type thunks, allows the C world to play in the C++ world @@ -1299,6 +1304,9 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) READ_RECORD read_record_info; int error; THD *new_thd; +#ifdef EMBEDDED_LIBRARY + bool table_exists; +#endif /* EMBEDDED_LIBRARY */ DBUG_ENTER("plugin_load"); if (!(new_thd= new THD)) @@ -1315,6 +1323,20 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) tables.alias= tables.table_name= (char*)"plugin"; tables.lock_type= TL_READ; tables.db= new_thd->db; + +#ifdef EMBEDDED_LIBRARY + /* + When building an embedded library, if the mysql.plugin table + does not exist, we silently ignore the missing table + */ + pthread_mutex_lock(&LOCK_open); + if (check_if_table_exists(new_thd, &tables, &table_exists)) + table_exists= FALSE; + pthread_mutex_unlock(&LOCK_open); + if (!table_exists) + goto end; +#endif /* EMBEDDED_LIBRARY */ + if (simple_open_n_lock_tables(new_thd, &tables)) { DBUG_PRINT("error",("Can't open plugin table")); From ff265ac842a6cc7f1866200397a8bd7fc27adee2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 11:44:58 +0200 Subject: [PATCH 107/156] BK changes for https://inside.mysql.com/wiki/MySQL's_Code_Reviews_Published_Externally BitKeeper/triggers/post-commit: 1) Add additional method of detecting merge changesets. 2) Remove code sending e-mail to dev-public@ or dev-bugs@. 3) Change code sending e-mail to commits@ to send to dev-private@ if a specific file is present in the BK root directory, denoting this tree as private. --- BitKeeper/triggers/post-commit | 56 +++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 229553cdccf..245d644e06a 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -26,6 +26,13 @@ then exit fi +IS_MERGE=`bk changes -r+ -k -m` +if [ "$IS_MERGE" = "" ] +then + echo Merge changeset, not sending mails + exit +fi + CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet` # @@ -41,42 +48,49 @@ WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \ s/.*\(WL#[0-9][0-9]*\)/ \1/p'` if [ "$BUG" = "" ] then - TO=dev-public@mysql.com +# TO=dev-public@mysql.com BS="" BH="" else - TO=dev-bugs@mysql.com +# TO=dev-bugs@mysql.com BS=" BUG#$BUG" # need newline here BH="X-Bug: $BUG " fi -#++ -# dev-public@ / dev-bugs@ -#-- - echo "Commit successful, notifying developers at $TO" - ( - cat < -From: $FROM -To: $TO -Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL} -X-CSetKey: <$CSETKEY> -$BH -EOF - bk changes -v -r+ - bk cset -r+ -d - ) | head -n $LIMIT | /usr/sbin/sendmail -t +##++ +## dev-public@ / dev-bugs@ +##-- +# echo "Commit successful, notifying developers at $TO" +# ( +# cat < +#From: $FROM +#To: $TO +#Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL} +#X-CSetKey: <$CSETKEY> +#$BH +#EOF +# bk changes -v -r+ +# bk cset -r+ -d +# ) | head -n $LIMIT | /usr/sbin/sendmail -t #++ -# commits@ mail +# commits@ or dev-private@ mail #-- - echo "Notifying commits list at $COMMITS" + +TO="commits" +if [ -f .tree-is-private ] +then + TO="dev-private" +fi + + echo "Notifying $TO list at $TO" ( cat < From: $FROM -To: $COMMITS +To: $TO@mysql.com Subject: bk commit into $VERSION tree ($CHANGESET)$BS X-CSetKey: <$CSETKEY> $BH From 9cbd0ae4b373ef730e37349ad2082d00967871aa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 13:33:00 +0200 Subject: [PATCH 108/156] sql/item_func.cc Improved check for thread identity in the "embedded" case, provided by Monty. This finishes the fixes for bug#27078. sql/item_func.cc: Improved check for thread identity in the "embedded" case, provided by Monty. This finishes the fixes for bug#27078. --- sql/item_func.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index 12bb6571369..f71297515d6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2243,7 +2243,7 @@ longlong Item_func_release_lock::val_int() else { #ifdef EMBEDDED_LIBRARY - if (ull->locked && pthread_equal(current_thd->real_id,ull->thread)) + if (ull->locked && (current_thd->real_id == ull->thread)) #else if (ull->locked && pthread_equal(pthread_self(),ull->thread)) #endif From e42de77219131385fa958224399c0c56ca08d8f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 22:54:00 +1000 Subject: [PATCH 109/156] [PATCH] BUG#29063 TESTCASE mgmapi: connect timeout set incorrectly Add test to testMgm for Connect timeout. add to autotest. Index: ndb-work/storage/ndb/test/ndbapi/testMgm.cpp =================================================================== storage/ndb/test/ndbapi/testMgm.cpp: BUG#29063 TESTCASE mgmapi: connect timeout set incorrectly storage/ndb/test/run-test/daily-basic-tests.txt: BUG#29063 TESTCASE mgmapi: connect timeout set incorrectly --- storage/ndb/test/ndbapi/testMgm.cpp | 75 +++++++++++++++++++ .../ndb/test/run-test/daily-basic-tests.txt | 4 + 2 files changed, 79 insertions(+) diff --git a/storage/ndb/test/ndbapi/testMgm.cpp b/storage/ndb/test/ndbapi/testMgm.cpp index cc074087bdb..e43972c8c29 100644 --- a/storage/ndb/test/ndbapi/testMgm.cpp +++ b/storage/ndb/test/ndbapi/testMgm.cpp @@ -212,6 +212,76 @@ int runTestApiSession(NDBT_Context* ctx, NDBT_Step* step) } } +int runTestApiConnectTimeout(NDBT_Context* ctx, NDBT_Step* step) +{ + char *mgm= ctx->getRemoteMgm(); + int result= NDBT_FAILED; + int cc= 0; + int mgmd_nodeid= 0; + ndb_mgm_reply reply; + + NdbMgmHandle h; + h= ndb_mgm_create_handle(); + ndb_mgm_set_connectstring(h, mgm); + + ndbout << "TEST connect timeout" << endl; + + ndb_mgm_set_timeout(h, 3000); + + struct timeval tstart, tend; + int secs; + timerclear(&tstart); + timerclear(&tend); + gettimeofday(&tstart,NULL); + + ndb_mgm_connect(h,0,0,0); + + gettimeofday(&tend,NULL); + + secs= tend.tv_sec - tstart.tv_sec; + ndbout << "Took about: " << secs <<" seconds"<getRemoteMgm(); @@ -727,6 +797,11 @@ TESTCASE("ApiSessionFailure", "Test failures in MGMAPI session"){ INITIALIZER(runTestApiSession); +} +TESTCASE("ApiConnectTimeout", + "Connect timeout tests for MGMAPI"){ + INITIALIZER(runTestApiConnectTimeout); + } TESTCASE("ApiTimeoutBasic", "Basic timeout tests for MGMAPI"){ diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index 6ce2da47670..0e1cdfc647e 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -898,6 +898,10 @@ max-time: 120 cmd: testMgm args: -n ApiSessionFailure T1 +max-time: 15 +cmd: testMgm +args: -n ApiConnectTimeout T1 + max-time: 120 cmd: testMgm args: -n ApiTimeoutBasic T1 From 495a9490bd98a888c7fbcf704cce09421625b27e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 22:54:14 +1000 Subject: [PATCH 110/156] [PATCH] BUG#29063 mgmapi: connect timeout set incorrectly correctly divide timeout by 1000 to convert to seconds for SocketClient Index: ndb-work/storage/ndb/src/mgmapi/mgmapi.cpp =================================================================== storage/ndb/src/mgmapi/mgmapi.cpp: BUG#29063 mgmapi: connect timeout set incorrectly --- storage/ndb/src/mgmapi/mgmapi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index e7dc1d1d503..5f975da8c73 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -524,7 +524,7 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET; Uint32 i; SocketClient s(0, 0); - s.set_connect_timeout(handle->timeout); + s.set_connect_timeout((handle->timeout+999)/1000); if (!s.init()) { fprintf(handle->errstream, From 18c6c75a35f15b4611360d9e77e4d9a2f4b248b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:33:37 +1000 Subject: [PATCH 111/156] [PATCH] Disable mysql_upgrade test (Bug#28560) Index: ndb-work/mysql-test/t/disabled.def =================================================================== mysql-test/t/disabled.def: Disable mysql_upgrade test (Bug#28560) --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index e283ca9458f..90fd997e615 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -40,3 +40,4 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb #rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms +mysql_upgrade : Bug#28560 test links to /usr/local/mysql/lib libraries, causes non-determinism and failures on ABI breakage From 1f2ce0eb4828f07db69e5fa06f3070dc130fc4f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:33:51 +1000 Subject: [PATCH 112/156] [PATCH] Add tests for ndb variables (related to BUG#26675) This is somewhat related to BUG#26675 (ndb_connectstring not reported in show global variables) Index: ndb-work/mysql-test/r/ndb_basic.result =================================================================== mysql-test/r/ndb_basic.result: Add tests for ndb variables (related to BUG#26675) mysql-test/t/ndb_basic.test: Add tests for ndb variables (related to BUG#26675) --- mysql-test/r/ndb_basic.result | 21 +++++++++++++++++++++ mysql-test/t/ndb_basic.test | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index c84c7fffd66..0f28e6ac497 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -1,5 +1,26 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; drop database if exists mysqltest; +SHOW GLOBAL STATUS LIKE 'ndb%'; +Variable_name Value +Ndb_cluster_node_id # +Ndb_config_from_host # +Ndb_config_from_port # +Ndb_number_of_data_nodes # +SHOW GLOBAL VARIABLES LIKE 'ndb%'; +Variable_name Value +ndb_autoincrement_prefetch_sz # +ndb_cache_check_time # +ndb_connectstring # +ndb_extra_logging # +ndb_force_send # +ndb_index_stat_cache_entries # +ndb_index_stat_enable # +ndb_index_stat_update_freq # +ndb_report_thresh_binlog_epoch_slip # +ndb_report_thresh_binlog_mem_usage # +ndb_use_copying_alter_table # +ndb_use_exact_count # +ndb_use_transactions # CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL, diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 870c7435d3e..6668ca86a94 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -22,6 +22,14 @@ drop database if exists mysqltest; # table handler is working # +# +# Show status and variables +# +--replace_column 2 # +SHOW GLOBAL STATUS LIKE 'ndb%'; +--replace_column 2 # +SHOW GLOBAL VARIABLES LIKE 'ndb%'; + # # Create a normal table with primary key # From 21819c2afa0e85595a01b2c3850c7bc60b451ca7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:34:09 +1000 Subject: [PATCH 113/156] [PATCH] BUG#29073 Store history for ndb_mgm Index: ndb-work/storage/ndb/src/mgmclient/main.cpp =================================================================== storage/ndb/src/mgmclient/main.cpp: BUG#29073 Store history for ndb_mgm --- storage/ndb/src/mgmclient/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp index 44408362f09..429ccb27b2e 100644 --- a/storage/ndb/src/mgmclient/main.cpp +++ b/storage/ndb/src/mgmclient/main.cpp @@ -155,10 +155,31 @@ int main(int argc, char** argv){ signal(SIGPIPE, handler); com = new Ndb_mgmclient(opt_connect_str,1); int ret= 0; + BaseString histfile; if (!opt_execute_str) { + char *histfile_env= getenv("NDB_MGM_HISTFILE"); + if (histfile_env) + histfile.assign(histfile_env,strlen(histfile_env)); + else if(getenv("HOME")) + { + histfile.assign(getenv("HOME"),strlen(getenv("HOME"))); + histfile.append("/.ndb_mgm_history"); + } + if (histfile.length()) + read_history(histfile.c_str()); + ndbout << "-- NDB Cluster -- Management Client --" << endl; while(read_and_execute(_try_reconnect)); + + if (histfile.length()) + { + BaseString histfile_tmp; + histfile_tmp.assign(histfile); + histfile_tmp.append(".TMP"); + if(!write_history(histfile_tmp.c_str())) + my_rename(histfile_tmp.c_str(), histfile.c_str(), MYF(MY_WME)); + } } else { From 85525c4a544f80ee9c8721aae944e7b815baa194 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:34:22 +1000 Subject: [PATCH 114/156] [PATCH] Enable test for (Closed) bug 16445 Bug was updated on May 30th by Tomas to say that hasn't been seen in PB since global dict cache rewrite. This test should probably be enabled then. Index: ndb-work/mysql-test/t/ndb_basic.test =================================================================== mysql-test/r/ndb_basic.result: Enable test for (Closed) bug 16445 mysql-test/t/ndb_basic.test: Enable test for (Closed) bug 16445 --- mysql-test/r/ndb_basic.result | 7 +++++++ mysql-test/t/ndb_basic.test | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 0f28e6ac497..4eddaeb1227 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -1,5 +1,12 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; drop database if exists mysqltest; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL, +attr2 INT, +attr3 VARCHAR(10) +) ENGINE=ndbcluster; +drop table t1; SHOW GLOBAL STATUS LIKE 'ndb%'; Variable_name Value Ndb_cluster_node_id # diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 6668ca86a94..90839ce6cab 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -6,16 +6,16 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; drop database if exists mysqltest; --enable_warnings -## workaround for bug#16445 -## remove to reproduce bug and run tests from ndb start -## and with ndb_autodiscover disabled. Fails on Linux 50 % of the times -#CREATE TABLE t1 ( -# pk1 INT NOT NULL PRIMARY KEY, -# attr1 INT NOT NULL, -# attr2 INT, -# attr3 VARCHAR(10) -#) ENGINE=ndbcluster; -#drop table t1; +# workaround for bug#16445 +# remove to reproduce bug and run tests from ndb start +# and with ndb_autodiscover disabled. Fails on Linux 50 % of the times +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) +) ENGINE=ndbcluster; +drop table t1; # # Basic test to show that the NDB From 42044a87abdc3212f87eacfbd57bfb9ad21a76c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:34:36 +1000 Subject: [PATCH 115/156] [PATCH] BUG#29074 preserve file timestamps in ndb_error_reporter Index: ndb-work/storage/ndb/tools/ndb_error_reporter =================================================================== storage/ndb/tools/ndb_error_reporter: BUG#29074 preserve file timestamps in ndb_error_reporter --- storage/ndb/tools/ndb_error_reporter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/ndb/tools/ndb_error_reporter b/storage/ndb/tools/ndb_error_reporter index 2b5aadb6171..7ad7a2f478a 100644 --- a/storage/ndb/tools/ndb_error_reporter +++ b/storage/ndb/tools/ndb_error_reporter @@ -62,13 +62,13 @@ foreach my $node (@nodes) (($config_get_fs)?" with filesystem":""). "\n\n"; my $recurse= ($config_get_fs)?'-r ':''; - system 'scp '.$recurse.$config_username.config($node,'host'). + system 'scp -p '.$recurse.$config_username.config($node,'host'). ':'.config($node,'datadir')."/ndb_".$node."* ". "$reportdir/\n"; } print "\n\n Copying configuration file...\n\n\t$config_file\n\n"; -system "cp $config_file $reportdir/"; +system "cp -p $config_file $reportdir/"; my $r = system 'bzip2 2>&1 > /dev/null < /dev/null'; my $outfile; From f344a35fee7b78011ed63986cf5c40166a1a8992 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:52:47 +1000 Subject: [PATCH 116/156] [PATCH] Add MAINTAINERS file for NDB Index: ndb-merge/storage/ndb/MAINTAINERS =================================================================== storage/ndb/MAINTAINERS: Add MAINTAINERS file for NDB --- storage/ndb/MAINTAINERS | 157 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 storage/ndb/MAINTAINERS diff --git a/storage/ndb/MAINTAINERS b/storage/ndb/MAINTAINERS new file mode 100644 index 00000000000..76318687dde --- /dev/null +++ b/storage/ndb/MAINTAINERS @@ -0,0 +1,157 @@ +MySQL Cluster MAINTAINERS +------------------------- + +This is a list of knowledgable people in parts of the NDB code. + +In changing that area of code, you probably want to talk to the +people who know a lot about it to look over the patch. + +When sending patches and queries, always CC the mailing list. + +If no list specified, assume internals@lists.mysql.com + +P: Person +M: Mail +L: Mailing list +W: Web page with status/info +C: Comment +SRC: Source directory (relative to this directory) +T: SCM tree type and location +S: Status, one of: + + Supported: Somebody is paid to maintain this. + Maintained: Not their primary job, but maintained. + Orphan: No current obvious maintainer. + Obsolete: Replaced by something else. + +------------------------------------------------------------- + +Binlog Injector +SRC: ha_ndbcluster_binlog.cc +C: see also row based replication +P: Stewart Smith +M: stewart@mysql.com +C: Original author +P: Tomas Ulin +M: tomas@mysql.com +C: Lots of updates +P: Martin Skold +M: martin@mysql.com +C: Metadata ops +S: Supported + +BLOBs +SRC: ha_ndbcluster.cc +SRC: src/ndbapi/NdbBlob* +P: Pekka +M: pekka@mysql.com +S: Supported + +cpcd/cpcc +SRC: src/cw/cpcd +SRC: src/cw/cpcc +C: Maintained only as part of autotest +P: Jonas Orland +M: jonas@mysql.com +S: Maintained + +cpcc-win32 +SRC: src/cw/cpcc-win32 +S: Obsolete + +Handler +SRC: ha_ndbcluster.cc +P: Martin Skold +M: martin@mysql.com +S: Supported + +Management Server +SRC: src/mgmsrv/ +P: Stewart Smith +M: stewart@mysql.com +S: Supported + +Management Client +SRC: src/mgmclient/ +P: Stewart Smith +M: stewart@mysql.com +S: Supported + +Management API +SRC: src/mgmapi/ +P: Stewart Smith +M: stewart@mysql.com +S: Supported + +NDB API Examples +SRC: ndbapi-examples/ +P: Tomas Ulin +M: tomas@mysql.com +C: Originally by Lars +P: Lars Thalmann +M: lars@mysql.com +S: Maintained + +tsman +C: Disk Data (Table Space MANager) +SRC: src/kernel/blocks/tsman.cpp +SRC: src/kernel/blocks/tsman.hpp +P: Jonas Oreland +M: jonas@mysql.com +S: Supported + +lgman +C: Disk Data (LoG MANager) +SRC: src/kernel/blocks/lgman.cpp +SRC: src/kernel/blocks/lgman.hpp +P: Jonas Oreland +M: jonas@mysql.com +S: Supported + +pgman +C: Disk Data (PaGe MANager) +SRC: src/kernel/blocks/lgman.cpp +SRC: src/kernel/blocks/lgman.hpp +P: Jonas Oreland +M: jonas@mysql.com +S: Supported + +SUMA +C: SUbscription MAnager +C: Used for replication +SRC: src/kernel/blocks/suma/ +P: Tomas Ulin +P: tomas@mysql.com +P: Jonas Oreland +P: jonas@mysql.com +S: Supported + +TRIX +C: TRiggers and IndeXs (but only online Index build) +SRC: src/kernel/blocks/trix +P: Martin Skold +P: mskold@mysql.com +S: Supported + +QMGR +C: Cluster (with a Q) ManaGeR +C: Heartbeats etc +SRC: src/kernel/blocks/qmgr +S: Supported + +NDBFS +C: NDB FileSystem +C: File System abstraction +SRC: src/kernel/blocks/ndbfs +S: Supported + +TRIX +C: TRiggers and IndeXs (but only online Index build) +SRC: src/kernel/blocks/trix +S: Supported + +TRIX +C: TRiggers and IndeXs (but only online Index build) +SRC: src/kernel/blocks/trix +S: Supported + From 29987e6e29990e24a90237bf360e9c1097f2a1e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 23:53:01 +1000 Subject: [PATCH 117/156] [PATCH] add knielsen as MAINTAINER of NDBAPI NdbRecord examples Index: ndb-merge/storage/ndb/MAINTAINERS =================================================================== storage/ndb/MAINTAINERS: add knielsen as MAINTAINER of NDBAPI NdbRecord examples --- storage/ndb/MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/ndb/MAINTAINERS b/storage/ndb/MAINTAINERS index 76318687dde..d1547d48234 100644 --- a/storage/ndb/MAINTAINERS +++ b/storage/ndb/MAINTAINERS @@ -92,6 +92,12 @@ P: Lars Thalmann M: lars@mysql.com S: Maintained +NDB API NdbRecord Examples +SRC: ndbapi-examples/ +P: Kristian Nielsen +M: knielsen@mysql.com +S: Maintained + tsman C: Disk Data (Table Space MANager) SRC: src/kernel/blocks/tsman.cpp From c0ebdff9c76c2b3e09bf5e44c22e68a35ef1affc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 09:32:36 -0700 Subject: [PATCH 118/156] Fixed bug #28980: the result of ROUND(,) was erroneously converted to double, while the result of ROUND(, ) was preserved as decimal. As a result of such a conversion the value of ROUND(D,A) could differ from the value of ROUND(D,val(A)) if D was a decimal expression. Now the result of the ROUND function is never converted to double if the first argument is decimal. mysql-test/r/type_decimal.result: Added a test case for bug #28980. mysql-test/t/type_decimal.test: Added a test case for bug #28980. --- mysql-test/r/type_decimal.result | 9 +++++++++ mysql-test/t/type_decimal.test | 14 ++++++++++++++ sql/item_func.cc | 8 +++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index c9c42d18d68..3cf24529421 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -790,3 +790,12 @@ Warning 1292 Truncated incorrect datetime value: '0000-00-00' Warning 1292 Truncated incorrect datetime value: '0000-00-00' Warning 1292 Truncated incorrect datetime value: '0000-00-00' drop table t1; +CREATE TABLE t1 ( +qty decimal(16,6) default NULL, +dps tinyint(3) unsigned default NULL +); +INSERT INTO t1 VALUES (1.1325,3); +SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; +ROUND(qty,3) dps ROUND(qty,dps) +1.133 3 1.133 +DROP TABLE t1; diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 4fdb0c8458f..5538f19f5f9 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -394,3 +394,17 @@ create table t1 as from (select 1 as s,'t' as t union select null, null ) as sub1; select group_concat(t) from t1 group by week(date)/10; drop table t1; + +# +# Bug#28980: ROUND(, ) returned double values +# + +CREATE TABLE t1 ( + qty decimal(16,6) default NULL, + dps tinyint(3) unsigned default NULL +); +INSERT INTO t1 VALUES (1.1325,3); + +SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; + +DROP TABLE t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index cc8830c6d6f..ab4a9c50332 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1957,7 +1957,13 @@ void Item_func_round::fix_length_and_dec() { max_length= args[0]->max_length; decimals= args[0]->decimals; - hybrid_type= REAL_RESULT; + if (args[0]->result_type() == DECIMAL_RESULT) + { + max_length++; + hybrid_type= DECIMAL_RESULT; + } + else + hybrid_type= REAL_RESULT; return; } From d1ee00acf1d1d60544c6af739c760c1e129bd25f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 19:19:11 +0200 Subject: [PATCH 119/156] fix make_win_bin_dist typo scripts/make_win_bin_dist: add missing backslash --- scripts/make_win_bin_dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index cecee4f57af..beb274ca1a3 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -273,7 +273,7 @@ cp include/mysql.h \ include/my_attribute.h \ include/mysqld_error.h \ include/sql_state.h \ - include/mysqld_ername.h + include/mysqld_ername.h \ include/mysql_version.h \ include/config-win.h \ libmysql/libmysql.def \ From 4f60c51169c1a8e6ff61ccccc5073e82cf1b0d8b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 19:23:13 +0200 Subject: [PATCH 120/156] fix. BitKeeper/triggers/post-commit: send to correct address. --- BitKeeper/triggers/post-commit | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 245d644e06a..5a7d6576d4e 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -79,18 +79,20 @@ fi # commits@ or dev-private@ mail #-- -TO="commits" +LIST="commits" +TO="commits@lists.mysql.com" if [ -f .tree-is-private ] then - TO="dev-private" + LIST="dev-private" + TO="dev-private@mysql.com" fi - echo "Notifying $TO list at $TO" + echo "Notifying $LIST list at $TO" ( cat < From: $FROM -To: $TO@mysql.com +To: $TO Subject: bk commit into $VERSION tree ($CHANGESET)$BS X-CSetKey: <$CSETKEY> $BH From 31608f67ab310e7c84477a79d5b2f683113365e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Jun 2007 16:24:21 -0400 Subject: [PATCH 121/156] Bug #28953 Using events in a replication let the slave crash. Fixed where the slave code would try to update the Lex->sphead which is NULL on an "alter table" commands. mysql-test/r/rpl_events.result: test that "alter event" replicates without crashing the slave mysql-test/t/rpl_events.test: test that "alter event" replicates without crashing the slave sql/sql_parse.cc: Added a check for lex->spd, which isn't set on an "alter event" command --- mysql-test/r/rpl_events.result | 6 ++++++ mysql-test/t/rpl_events.test | 23 +++++++++++++++++++++++ sql/sql_parse.cc | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_events.result b/mysql-test/r/rpl_events.result index debfcce0072..0d7e7bb28a7 100644 --- a/mysql-test/r/rpl_events.result +++ b/mysql-test/r/rpl_events.result @@ -157,3 +157,9 @@ test slave_terminate SLAVESIDE_DISABLED 2 DROP EVENT test.slave_terminate; "in the master" DROP TABLE t1; +CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR +DO BEGIN +select * from t1; +END;| +ALTER EVENT event1 RENAME TO event2; +DROP EVENT event2; diff --git a/mysql-test/t/rpl_events.test b/mysql-test/t/rpl_events.test index 895e94c438b..62ffead7dcb 100644 --- a/mysql-test/t/rpl_events.test +++ b/mysql-test/t/rpl_events.test @@ -22,3 +22,26 @@ set binlog_format=statement; # Embedded server doesn't support binlogging --source include/rpl_events.inc +# +# Bug #28953 Using events in a replication let the slave crash. +# + +connection master; + +DELIMITER |; +CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR +DO BEGIN + select * from t1; +END;| +DELIMITER ;| + +ALTER EVENT event1 RENAME TO event2; + +sync_slave_with_master; + +connection master; + +DROP EVENT event2; + +sync_slave_with_master; + diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 31e3196ded1..1b06f5567d8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1567,7 +1567,7 @@ bool sp_process_definer(THD *thd) if (lex->definer == NULL) DBUG_RETURN(TRUE); - if (thd->slave_thread) + if (thd->slave_thread && lex->sphead) lex->sphead->m_chistics->suid= SP_IS_NOT_SUID; } else From cb9817cc239ac7a42f4a12ef72379bdf0d18a934 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 11:59:25 +1000 Subject: [PATCH 122/156] fix build of mgm client with history - caught by pb. storage/ndb/src/mgmclient/main.cpp: fix build issues only caught by pb (mgm client history related) --- storage/ndb/src/mgmclient/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp index 429ccb27b2e..7513064d273 100644 --- a/storage/ndb/src/mgmclient/main.cpp +++ b/storage/ndb/src/mgmclient/main.cpp @@ -23,6 +23,8 @@ extern "C" { #elif !defined(__NETWARE__) #include extern "C" int add_history(const char *command); /* From readline directory */ +extern "C" int read_history(const char *command); +extern "C" int write_history(const char *command); #define HAVE_READLINE #endif } @@ -158,6 +160,7 @@ int main(int argc, char** argv){ BaseString histfile; if (!opt_execute_str) { +#ifdef HAVE_READLINE char *histfile_env= getenv("NDB_MGM_HISTFILE"); if (histfile_env) histfile.assign(histfile_env,strlen(histfile_env)); @@ -168,10 +171,12 @@ int main(int argc, char** argv){ } if (histfile.length()) read_history(histfile.c_str()); +#endif ndbout << "-- NDB Cluster -- Management Client --" << endl; while(read_and_execute(_try_reconnect)); +#ifdef HAVE_READLINE if (histfile.length()) { BaseString histfile_tmp; @@ -180,6 +185,7 @@ int main(int argc, char** argv){ if(!write_history(histfile_tmp.c_str())) my_rename(histfile_tmp.c_str(), histfile.c_str(), MYF(MY_WME)); } +#endif } else { From 0d5c6b702a516c8cff37b9020d918bc4be50f184 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 11:26:54 +0200 Subject: [PATCH 123/156] move all error codes to ndberror.c - step 1 mgmtsrvr error codes storage/ndb/src/mgmsrv/ndb_mgmd_error.h: New BitKeeper file ``storage/ndb/src/mgmsrv/ndb_mgmd_error.h'' --- storage/ndb/src/mgmsrv/MgmtSrvr.cpp | 76 +------------------------ storage/ndb/src/mgmsrv/MgmtSrvr.hpp | 39 ------------- storage/ndb/src/mgmsrv/ndb_mgmd_error.h | 33 +++++++++++ storage/ndb/src/ndbapi/ndberror.c | 30 ++++++++++ 4 files changed, 64 insertions(+), 114 deletions(-) create mode 100644 storage/ndb/src/mgmsrv/ndb_mgmd_error.h diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp index f84c79b704f..af708664a69 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -18,6 +18,7 @@ #include "MgmtSrvr.hpp" #include "MgmtErrorReporter.hpp" +#include "ndb_mgmd_error.h" #include #include @@ -239,13 +240,6 @@ MgmtSrvr::stopEventLog() // Nothing yet } -class ErrorItem -{ -public: - int _errorCode; - const char * _errorText; -}; - bool MgmtSrvr::setEventLogFilter(int severity, int enable) { @@ -268,62 +262,6 @@ MgmtSrvr::isEventLogFilterEnabled(int severity) return g_eventLogger.isEnable((Logger::LoggerLevel)severity); } -static ErrorItem errorTable[] = -{ - {MgmtSrvr::NO_CONTACT_WITH_PROCESS, "No contact with the process (dead ?)."}, - {MgmtSrvr::PROCESS_NOT_CONFIGURED, "The process is not configured."}, - {MgmtSrvr::WRONG_PROCESS_TYPE, - "The process has wrong type. Expected a DB process."}, - {MgmtSrvr::COULD_NOT_ALLOCATE_MEMORY, "Could not allocate memory."}, - {MgmtSrvr::SEND_OR_RECEIVE_FAILED, "Send to process or receive failed."}, - {MgmtSrvr::INVALID_LEVEL, "Invalid level. Should be between 1 and 30."}, - {MgmtSrvr::INVALID_ERROR_NUMBER, "Invalid error number. Should be >= 0."}, - {MgmtSrvr::INVALID_TRACE_NUMBER, "Invalid trace number."}, - {MgmtSrvr::NOT_IMPLEMENTED, "Not implemented."}, - {MgmtSrvr::INVALID_BLOCK_NAME, "Invalid block name"}, - - {MgmtSrvr::CONFIG_PARAM_NOT_EXIST, - "The configuration parameter does not exist for the process type."}, - {MgmtSrvr::CONFIG_PARAM_NOT_UPDATEABLE, - "The configuration parameter is not possible to update."}, - {MgmtSrvr::VALUE_WRONG_FORMAT_INT_EXPECTED, - "Incorrect value. Expected integer."}, - {MgmtSrvr::VALUE_TOO_LOW, "Value is too low."}, - {MgmtSrvr::VALUE_TOO_HIGH, "Value is too high."}, - {MgmtSrvr::VALUE_WRONG_FORMAT_BOOL_EXPECTED, - "Incorrect value. Expected TRUE or FALSE."}, - - {MgmtSrvr::CONFIG_FILE_OPEN_WRITE_ERROR, - "Could not open configuration file for writing."}, - {MgmtSrvr::CONFIG_FILE_OPEN_READ_ERROR, - "Could not open configuration file for reading."}, - {MgmtSrvr::CONFIG_FILE_WRITE_ERROR, - "Write error when writing configuration file."}, - {MgmtSrvr::CONFIG_FILE_READ_ERROR, - "Read error when reading configuration file."}, - {MgmtSrvr::CONFIG_FILE_CLOSE_ERROR, "Could not close configuration file."}, - - {MgmtSrvr::CONFIG_CHANGE_REFUSED_BY_RECEIVER, - "The change was refused by the receiving process."}, - {MgmtSrvr::COULD_NOT_SYNC_CONFIG_CHANGE_AGAINST_PHYSICAL_MEDIUM, - "The change could not be synced against physical medium."}, - {MgmtSrvr::CONFIG_FILE_CHECKSUM_ERROR, - "The config file is corrupt. Checksum error."}, - {MgmtSrvr::NOT_POSSIBLE_TO_SEND_CONFIG_UPDATE_TO_PROCESS_TYPE, - "It is not possible to send an update of a configuration variable " - "to this kind of process."}, - {MgmtSrvr::NODE_SHUTDOWN_IN_PROGESS, "Node shutdown in progress" }, - {MgmtSrvr::SYSTEM_SHUTDOWN_IN_PROGRESS, "System shutdown in progress" }, - {MgmtSrvr::NODE_SHUTDOWN_WOULD_CAUSE_SYSTEM_CRASH, - "Node shutdown would cause system crash" }, - {MgmtSrvr::UNSUPPORTED_NODE_SHUTDOWN, - "Unsupported multi node shutdown. Abort option required." }, - {MgmtSrvr::NODE_NOT_API_NODE, "The specified node is not an API node." }, - {MgmtSrvr::OPERATION_NOT_ALLOWED_START_STOP, - "Operation not allowed while nodes are starting or stopping."}, - {MgmtSrvr::NO_CONTACT_WITH_DB_NODES, "No contact with database nodes" } -}; - int MgmtSrvr::translateStopRef(Uint32 errCode) { switch(errCode){ @@ -343,8 +281,6 @@ int MgmtSrvr::translateStopRef(Uint32 errCode) return 4999; } -static int noOfErrorCodes = sizeof(errorTable) / sizeof(ErrorItem); - int MgmtSrvr::getNodeCount(enum ndb_mgm_node_type type) const { @@ -1969,18 +1905,8 @@ MgmtSrvr::dumpState(int nodeId, const Uint32 args[], Uint32 no) const char* MgmtSrvr::getErrorText(int errorCode, char *buf, int buf_sz) { - - for (int i = 0; i < noOfErrorCodes; ++i) { - if (errorCode == errorTable[i]._errorCode) { - BaseString::snprintf(buf, buf_sz, errorTable[i]._errorText); - buf[buf_sz-1]= 0; - return buf; - } - } - ndb_error_string(errorCode, buf, buf_sz); buf[buf_sz-1]= 0; - return buf; } diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp index a54b7866091..90287554ef8 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -148,45 +148,6 @@ public: */ bool isEventLogFilterEnabled(int severity); - STATIC_CONST( NO_CONTACT_WITH_PROCESS = 5000 ); - STATIC_CONST( PROCESS_NOT_CONFIGURED = 5001 ); - STATIC_CONST( WRONG_PROCESS_TYPE = 5002 ); - STATIC_CONST( COULD_NOT_ALLOCATE_MEMORY = 5003 ); - STATIC_CONST( SEND_OR_RECEIVE_FAILED = 5005 ); - STATIC_CONST( INVALID_LEVEL = 5006 ); - STATIC_CONST( INVALID_ERROR_NUMBER = 5007 ); - STATIC_CONST( INVALID_TRACE_NUMBER = 5008 ); - STATIC_CONST( NOT_IMPLEMENTED = 5009 ); - STATIC_CONST( INVALID_BLOCK_NAME = 5010 ); - - STATIC_CONST( CONFIG_PARAM_NOT_EXIST = 5011 ); - STATIC_CONST( CONFIG_PARAM_NOT_UPDATEABLE = 5012 ); - STATIC_CONST( VALUE_WRONG_FORMAT_INT_EXPECTED = 5013 ); - STATIC_CONST( VALUE_TOO_LOW = 5014 ); - STATIC_CONST( VALUE_TOO_HIGH = 5015 ); - STATIC_CONST( VALUE_WRONG_FORMAT_BOOL_EXPECTED = 5016 ); - - STATIC_CONST( CONFIG_FILE_OPEN_WRITE_ERROR = 5017 ); - STATIC_CONST( CONFIG_FILE_OPEN_READ_ERROR = 5018 ); - STATIC_CONST( CONFIG_FILE_WRITE_ERROR = 5019 ); - STATIC_CONST( CONFIG_FILE_READ_ERROR = 5020 ); - STATIC_CONST( CONFIG_FILE_CLOSE_ERROR = 5021 ); - - STATIC_CONST( CONFIG_CHANGE_REFUSED_BY_RECEIVER = 5022 ); - STATIC_CONST( COULD_NOT_SYNC_CONFIG_CHANGE_AGAINST_PHYSICAL_MEDIUM = 5023 ); - STATIC_CONST( CONFIG_FILE_CHECKSUM_ERROR = 5024 ); - STATIC_CONST( NOT_POSSIBLE_TO_SEND_CONFIG_UPDATE_TO_PROCESS_TYPE = 5025 ); - - STATIC_CONST( NODE_SHUTDOWN_IN_PROGESS = 5026 ); - STATIC_CONST( SYSTEM_SHUTDOWN_IN_PROGRESS = 5027 ); - STATIC_CONST( NODE_SHUTDOWN_WOULD_CAUSE_SYSTEM_CRASH = 5028 ); - - STATIC_CONST( NO_CONTACT_WITH_DB_NODES = 5030 ); - STATIC_CONST( UNSUPPORTED_NODE_SHUTDOWN = 5031 ); - - STATIC_CONST( NODE_NOT_API_NODE = 5062 ); - STATIC_CONST( OPERATION_NOT_ALLOWED_START_STOP = 5063 ); - /** * This enum specifies the different signal loggig modes possible to set * with the setSignalLoggingMode method. diff --git a/storage/ndb/src/mgmsrv/ndb_mgmd_error.h b/storage/ndb/src/mgmsrv/ndb_mgmd_error.h new file mode 100644 index 00000000000..2438f15c808 --- /dev/null +++ b/storage/ndb/src/mgmsrv/ndb_mgmd_error.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef NDB_MGMD_ERROR_H +#define NDB_MGMD_ERROR_H + +#define NO_CONTACT_WITH_PROCESS 5000 +#define WRONG_PROCESS_TYPE 5002 +#define SEND_OR_RECEIVE_FAILED 5005 +#define INVALID_ERROR_NUMBER 5007 +#define INVALID_TRACE_NUMBER 5008 +#define INVALID_BLOCK_NAME 5010 +#define NODE_SHUTDOWN_IN_PROGESS 5026 +#define SYSTEM_SHUTDOWN_IN_PROGRESS 5027 +#define NODE_SHUTDOWN_WOULD_CAUSE_SYSTEM_CRASH 5028 +#define NO_CONTACT_WITH_DB_NODES 5030 +#define UNSUPPORTED_NODE_SHUTDOWN 5031 +#define NODE_NOT_API_NODE 5062 +#define OPERATION_NOT_ALLOWED_START_STOP 5063 + +#endif diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index b10859c3180..914acd17c08 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -19,6 +19,9 @@ #include #include +#include "../mgmsrv/ndb_mgmd_error.h" + + typedef struct ErrorBundle { int code; int mysql_code; @@ -619,6 +622,33 @@ ErrorBundle ErrorCodes[] = { { 4273, DMEC, IE, "No blob table in dict cache" }, { 4274, DMEC, IE, "Corrupted main table PK in blob operation" }, { 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" }, + + { NO_CONTACT_WITH_PROCESS, DMEC, AE, + "No contact with the process (dead ?)."}, + { WRONG_PROCESS_TYPE, DMEC, AE, + "The process has wrong type. Expected a DB process."}, + { SEND_OR_RECEIVE_FAILED, DMEC, AE, + "Send to process or receive failed."}, + { INVALID_ERROR_NUMBER, DMEC, AE, + "Invalid error number. Should be >= 0."}, + { INVALID_TRACE_NUMBER, DMEC, AE, + "Invalid trace number."}, + { INVALID_BLOCK_NAME, DMEC, AE, + "Invalid block name"}, + { NODE_SHUTDOWN_IN_PROGESS, DMEC, AE, + "Node shutdown in progress" }, + { SYSTEM_SHUTDOWN_IN_PROGRESS, DMEC, AE, + "System shutdown in progress" }, + { NODE_SHUTDOWN_WOULD_CAUSE_SYSTEM_CRASH, DMEC, AE, + "Node shutdown would cause system crash" }, + { UNSUPPORTED_NODE_SHUTDOWN, DMEC, AE, + "Unsupported multi node shutdown. Abort option required." }, + { NODE_NOT_API_NODE, DMEC, AE, + "The specified node is not an API node." }, + { OPERATION_NOT_ALLOWED_START_STOP, DMEC, AE, + "Operation not allowed while nodes are starting or stopping."}, + { NO_CONTACT_WITH_DB_NODES, DMEC, AE, + "No contact with database nodes" } }; static From 37559e3db5f26a46aabef179ac61b90bc777591a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 12:53:13 +0300 Subject: [PATCH 124/156] Bug #28991: rpl_events failure in pushbuild In tests waiting on a timeout is not deterministic enough to make sure that an event actually finished executing. Fixed the test by waiting in a loop and checking the effect that the event is supposed to produce. mysql-test/include/rpl_events.inc: Bug #28991: wait until event has taken effect --- mysql-test/include/rpl_events.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/include/rpl_events.inc b/mysql-test/include/rpl_events.inc index 04885f31997..bbe52d3628b 100644 --- a/mysql-test/include/rpl_events.inc +++ b/mysql-test/include/rpl_events.inc @@ -29,6 +29,9 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name # wait 3 seconds, so the event can trigger --real_sleep 3 +let $wait_condition= + SELECT count(*) = 1 FROM t1 WHERE c = 'from justonce'; +--source include/wait_condition.inc # check that table t1 contains something --echo "in the master" From ef3ed50bc0be1170cf22bcdc914374b3a1a67407 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 12:35:35 +0200 Subject: [PATCH 125/156] get mgmapi error codes into perror storage/ndb/include/mgmapi/mgmapi_error.h: New BitKeeper file ``storage/ndb/include/mgmapi/mgmapi_error.h'' --- extra/perror.c | 20 +++- storage/ndb/include/mgmapi/mgmapi.h | 100 +----------------- storage/ndb/include/mgmapi/mgmapi_error.h | 121 ++++++++++++++++++++++ 3 files changed, 140 insertions(+), 101 deletions(-) create mode 100644 storage/ndb/include/mgmapi/mgmapi_error.h diff --git a/extra/perror.c b/extra/perror.c index c49869be681..6ab2afe0b71 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -25,6 +25,7 @@ #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #include "../storage/ndb/src/ndbapi/ndberror.c" #include "../storage/ndb/src/kernel/error/ndbd_exit_codes.c" +#include "../storage/ndb/include/mgmapi/mgmapi_error.h" #endif static my_bool verbose, print_all_codes; @@ -32,6 +33,20 @@ static my_bool verbose, print_all_codes; #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE static my_bool ndb_code; static char ndb_string[1024]; +int mgmapi_error_string(int err_no, char *str, int size) +{ + int i; + for (i= 0; i < ndb_mgm_noOfErrorMsgs; i++) + { + if (ndb_mgm_error_msgs[i].code == err_no) + { + my_snprintf(str, size-1, "%s", ndb_mgm_error_msgs[i].msg); + str[size-1]= '\0'; + return 0; + } + } + return -1; +} #endif static struct my_option my_long_options[] = @@ -238,8 +253,9 @@ int main(int argc,char *argv[]) #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE if (ndb_code) { - if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) && - (ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0)) + if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) && + (ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0) && + (mgmapi_error_string(code, ndb_string, sizeof(ndb_string)) < 0)) { msg= 0; } diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h index ffed44c7da1..0853f5a4422 100644 --- a/storage/ndb/include/mgmapi/mgmapi.h +++ b/storage/ndb/include/mgmapi/mgmapi.h @@ -18,6 +18,7 @@ #include "mgmapi_config_parameters.h" #include "ndb_logevent.h" +#include "mgmapi_error.h" #define MGM_LOGLEVELS CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1 #define NDB_MGM_MAX_LOGLEVEL 15 @@ -211,105 +212,6 @@ extern "C" { #endif }; - /** - * Error codes - */ - enum ndb_mgm_error { - /** Not an error */ - NDB_MGM_NO_ERROR = 0, - - /* Request for service errors */ - /** Supplied connectstring is illegal */ - NDB_MGM_ILLEGAL_CONNECT_STRING = 1001, - /** Supplied NdbMgmHandle is illegal */ - NDB_MGM_ILLEGAL_SERVER_HANDLE = 1005, - /** Illegal reply from server */ - NDB_MGM_ILLEGAL_SERVER_REPLY = 1006, - /** Illegal number of nodes */ - NDB_MGM_ILLEGAL_NUMBER_OF_NODES = 1007, - /** Illegal node status */ - NDB_MGM_ILLEGAL_NODE_STATUS = 1008, - /** Memory allocation error */ - NDB_MGM_OUT_OF_MEMORY = 1009, - /** Management server not connected */ - NDB_MGM_SERVER_NOT_CONNECTED = 1010, - /** Could not connect to socker */ - NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET = 1011, - /** Could not bind local address */ - NDB_MGM_BIND_ADDRESS = 1012, - - /* Alloc node id failures */ - /** Generic error, retry may succeed */ - NDB_MGM_ALLOCID_ERROR = 1101, - /** Non retriable error */ - NDB_MGM_ALLOCID_CONFIG_MISMATCH = 1102, - - /* Service errors - Start/Stop Node or System */ - /** Start failed */ - NDB_MGM_START_FAILED = 2001, - /** Stop failed */ - NDB_MGM_STOP_FAILED = 2002, - /** Restart failed */ - NDB_MGM_RESTART_FAILED = 2003, - - /* Service errors - Backup */ - /** Unable to start backup */ - NDB_MGM_COULD_NOT_START_BACKUP = 3001, - /** Unable to abort backup */ - NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002, - - /* Service errors - Single User Mode */ - /** Unable to enter single user mode */ - NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001, - /** Unable to exit single user mode */ - NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002, - - /* Usage errors */ - /** Usage error */ - NDB_MGM_USAGE_ERROR = 5001 - }; - -#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL - struct Ndb_Mgm_Error_Msg { - enum ndb_mgm_error code; - const char * msg; - }; - const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = { - { NDB_MGM_NO_ERROR, "No error" }, - - /* Request for service errors */ - { NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" }, - { NDB_MGM_ILLEGAL_SERVER_HANDLE, "Illegal server handle" }, - { NDB_MGM_ILLEGAL_SERVER_REPLY, "Illegal reply from server" }, - { NDB_MGM_ILLEGAL_NUMBER_OF_NODES, "Illegal number of nodes" }, - { NDB_MGM_ILLEGAL_NODE_STATUS, "Illegal node status" }, - { NDB_MGM_OUT_OF_MEMORY, "Out of memory" }, - { NDB_MGM_SERVER_NOT_CONNECTED, "Management server not connected" }, - { NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, "Could not connect to socket" }, - - /* Service errors - Start/Stop Node or System */ - { NDB_MGM_START_FAILED, "Start failed" }, - { NDB_MGM_STOP_FAILED, "Stop failed" }, - { NDB_MGM_RESTART_FAILED, "Restart failed" }, - - /* Service errors - Backup */ - { NDB_MGM_COULD_NOT_START_BACKUP, "Could not start backup" }, - { NDB_MGM_COULD_NOT_ABORT_BACKUP, "Could not abort backup" }, - - /* Service errors - Single User Mode */ - { NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, - "Could not enter single user mode" }, - { NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, - "Could not exit single user mode" }, - - /* Usage errors */ - { NDB_MGM_USAGE_ERROR, - "Usage error" } - }; - const int ndb_mgm_noOfErrorMsgs = - sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg); -#endif - /** * Status of a node in the cluster. * diff --git a/storage/ndb/include/mgmapi/mgmapi_error.h b/storage/ndb/include/mgmapi/mgmapi_error.h new file mode 100644 index 00000000000..2d0aa1ded0f --- /dev/null +++ b/storage/ndb/include/mgmapi/mgmapi_error.h @@ -0,0 +1,121 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef MGMAPI_ERROR_H +#define MGMAPI_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif + /** + * Error codes + */ + enum ndb_mgm_error { + /** Not an error */ + NDB_MGM_NO_ERROR = 0, + + /* Request for service errors */ + /** Supplied connectstring is illegal */ + NDB_MGM_ILLEGAL_CONNECT_STRING = 1001, + /** Supplied NdbMgmHandle is illegal */ + NDB_MGM_ILLEGAL_SERVER_HANDLE = 1005, + /** Illegal reply from server */ + NDB_MGM_ILLEGAL_SERVER_REPLY = 1006, + /** Illegal number of nodes */ + NDB_MGM_ILLEGAL_NUMBER_OF_NODES = 1007, + /** Illegal node status */ + NDB_MGM_ILLEGAL_NODE_STATUS = 1008, + /** Memory allocation error */ + NDB_MGM_OUT_OF_MEMORY = 1009, + /** Management server not connected */ + NDB_MGM_SERVER_NOT_CONNECTED = 1010, + /** Could not connect to socker */ + NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET = 1011, + /** Could not bind local address */ + NDB_MGM_BIND_ADDRESS = 1012, + + /* Alloc node id failures */ + /** Generic error, retry may succeed */ + NDB_MGM_ALLOCID_ERROR = 1101, + /** Non retriable error */ + NDB_MGM_ALLOCID_CONFIG_MISMATCH = 1102, + + /* Service errors - Start/Stop Node or System */ + /** Start failed */ + NDB_MGM_START_FAILED = 2001, + /** Stop failed */ + NDB_MGM_STOP_FAILED = 2002, + /** Restart failed */ + NDB_MGM_RESTART_FAILED = 2003, + + /* Service errors - Backup */ + /** Unable to start backup */ + NDB_MGM_COULD_NOT_START_BACKUP = 3001, + /** Unable to abort backup */ + NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002, + + /* Service errors - Single User Mode */ + /** Unable to enter single user mode */ + NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001, + /** Unable to exit single user mode */ + NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002, + + /* Usage errors */ + /** Usage error */ + NDB_MGM_USAGE_ERROR = 5001 + }; + struct Ndb_Mgm_Error_Msg { + enum ndb_mgm_error code; + const char * msg; + }; + const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = { + { NDB_MGM_NO_ERROR, "No error" }, + + /* Request for service errors */ + { NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" }, + { NDB_MGM_ILLEGAL_SERVER_HANDLE, "Illegal server handle" }, + { NDB_MGM_ILLEGAL_SERVER_REPLY, "Illegal reply from server" }, + { NDB_MGM_ILLEGAL_NUMBER_OF_NODES, "Illegal number of nodes" }, + { NDB_MGM_ILLEGAL_NODE_STATUS, "Illegal node status" }, + { NDB_MGM_OUT_OF_MEMORY, "Out of memory" }, + { NDB_MGM_SERVER_NOT_CONNECTED, "Management server not connected" }, + { NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, "Could not connect to socket" }, + + /* Service errors - Start/Stop Node or System */ + { NDB_MGM_START_FAILED, "Start failed" }, + { NDB_MGM_STOP_FAILED, "Stop failed" }, + { NDB_MGM_RESTART_FAILED, "Restart failed" }, + + /* Service errors - Backup */ + { NDB_MGM_COULD_NOT_START_BACKUP, "Could not start backup" }, + { NDB_MGM_COULD_NOT_ABORT_BACKUP, "Could not abort backup" }, + + /* Service errors - Single User Mode */ + { NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, + "Could not enter single user mode" }, + { NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, + "Could not exit single user mode" }, + + /* Usage errors */ + { NDB_MGM_USAGE_ERROR, + "Usage error" } + }; + const int ndb_mgm_noOfErrorMsgs = + sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg); +#ifdef __cplusplus +} +#endif + +#endif From 28444ac8b157fa2db16a886b2eb462161a73c97d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 12:51:13 +0200 Subject: [PATCH 126/156] Bug #29103 ndb_restore segfaults on NULL var[char|binary] mysql-test/r/ndb_restore.result: Bug #29103 ndb_restore segfaults on NULL var[char|binary] - add extra row with NULL value to test mysql-test/t/ndb_restore.test: Bug #29103 ndb_restore segfaults on NULL var[char|binary] - add extra row with NULL value to test storage/ndb/tools/restore/consumer_restore.cpp: Bug #29103 ndb_restore segfaults on NULL var[char|binary] - check that the attribute is not null --- mysql-test/r/ndb_restore.result | 20 ++++++------- mysql-test/t/ndb_restore.test | 2 +- .../ndb/tools/restore/consumer_restore.cpp | 29 ++++++++++--------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index 8ecffa437b0..d1c76192cef 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -18,7 +18,7 @@ CREATE TABLE `t2_c` ( PRIMARY KEY (`capgotod`), KEY `i quadaddsvr` (`gotod`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,''); CREATE TABLE `t3_c` ( `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', `capgotod` smallint(5) unsigned NOT NULL default '0', @@ -154,15 +154,15 @@ count(*) 5 select count(*) from t2; count(*) -6 +7 select count(*) from t2_c; count(*) -6 +7 select count(*) from (select * from t2 union select * from t2_c) a; count(*) -6 +7 select count(*) from t3; count(*) 4 @@ -286,15 +286,15 @@ count(*) 5 select count(*) from t2; count(*) -6 +7 select count(*) from t2_c; count(*) -6 +7 select count(*) from (select * from t2 union select * from t2_c) a; count(*) -6 +7 select count(*) from t3; count(*) 4 @@ -386,15 +386,15 @@ count(*) 5 select count(*) from t2; count(*) -6 +7 select count(*) from t2_c; count(*) -6 +7 select count(*) from (select * from t2 union select * from t2_c) a; count(*) -6 +7 select count(*) from t3; count(*) 4 diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 61927a1f90a..7f0cafdfd77 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -33,7 +33,7 @@ CREATE TABLE `t2_c` ( PRIMARY KEY (`capgotod`), KEY `i quadaddsvr` (`gotod`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,''); # Added ROW_FORMAT=FIXED to use below to see that setting is preserved # by restore diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index b7db8145c56..fde1f4c3074 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -1158,19 +1158,22 @@ void BackupRestore::tuple_a(restore_callback_t *cb) char * dataPtr = attr_data->string_value; Uint32 length = 0; - const unsigned char * src = (const unsigned char *)dataPtr; - switch(attr_desc->m_column->getType()){ - case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Varbinary: - length = src[0] + 1; - break; - case NdbDictionary::Column::Longvarchar: - case NdbDictionary::Column::Longvarbinary: - length = src[0] + (src[1] << 8) + 2; - break; - default: - length = attr_data->size; - break; + if (!attr_data->null) + { + const unsigned char * src = (const unsigned char *)dataPtr; + switch(attr_desc->m_column->getType()){ + case NdbDictionary::Column::Varchar: + case NdbDictionary::Column::Varbinary: + length = src[0] + 1; + break; + case NdbDictionary::Column::Longvarchar: + case NdbDictionary::Column::Longvarbinary: + length = src[0] + (src[1] << 8) + 2; + break; + default: + length = attr_data->size; + break; + } } if (j == 0 && tup.getTable()->have_auto_inc(i)) tup.getTable()->update_max_auto_val(dataPtr,size*arraySize); From 12d1dece300ad0c04fedb1765bb8f88ea08d8ae2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 12:57:32 +0200 Subject: [PATCH 127/156] Makefile.am: new public file needs to get into distribution storage/ndb/include/Makefile.am: new public file needs to get into distribution --- storage/ndb/include/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/ndb/include/Makefile.am b/storage/ndb/include/Makefile.am index bf8fe392072..9e6ad016d75 100644 --- a/storage/ndb/include/Makefile.am +++ b/storage/ndb/include/Makefile.am @@ -45,6 +45,7 @@ ndbapi/ndberror.h mgmapiinclude_HEADERS = \ mgmapi/mgmapi.h \ +mgmapi/mgmapi_error.h \ mgmapi/mgmapi_debug.h \ mgmapi/mgmapi_config_parameters.h \ mgmapi/mgmapi_config_parameters_debug.h \ From 5bc3eb2e1183dc5f73b007d48a509793cceb19f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 16:18:01 +0500 Subject: [PATCH 128/156] BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Addition to the fix: report db name + table name instead of table path. This solves embedded merge test failure. mysql-test/r/merge.result: BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Addition to the fix: report db name + table name instead of table path. sql/ha_myisammrg.cc: BUG#26976 - Missing table in merge not noted in related error msg + SHOW CREATE TABLE fails Addition to the fix: report db name + table name instead of table path. --- mysql-test/r/merge.result | 8 ++++---- sql/ha_myisammrg.cc | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 9f7d5f54d0e..42669eeb66f 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -849,8 +849,8 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Error Table './test/t1' is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt CREATE TABLE t1(a INT); @@ -858,7 +858,7 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt CREATE TABLE t2(a BLOB); @@ -866,7 +866,7 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt ALTER TABLE t2 MODIFY a INT; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index e7baa6705ee..60aa4bd6adc 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -72,11 +72,22 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, uint t2_keys, uint t2_recs, bool strict); +static void split_file_name(const char *file_name, + LEX_STRING *db, LEX_STRING *name); + + extern "C" void myrg_print_wrong_table(const char *table_name) { + LEX_STRING db, name; + char buf[FN_REFLEN]; + split_file_name(table_name, &db, &name); + memcpy(buf, db.str, db.length); + buf[db.length]= '.'; + memcpy(buf + db.length + 1, name.str, name.length); + buf[db.length + name.length + 1]= 0; push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE), - table_name); + buf); } From 805c446ca4c385d74ea0aaefd789ba5131486e68 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 16:28:33 +0500 Subject: [PATCH 129/156] Bug#26402 Server crashes with old-style named table Problem: crash on attempt to open a table having "#mysql50#" prefix in db or table name. Fix: This prefix is reserved for "mysql_upgrade" to access 5.0 tables whose file names are not encoded according to "5.1 tablename to filename encoded". Don't try open tables whose db name or table name has this prefix. mysql-test/r/show_check.result: Adding test case. mysql-test/t/show_check.test: Adding test case. sql/mysql_priv.h: Moving 5.0 prefix declarations into mysql_priv.h sql/sql_table.cc: Moving 5.0 prefix declarations into mysql_priv.h sql/table.cc: Don't try to do "normal" open of tables having '#mysql50#' prefix in db or table name. This prefix is reserved to access to unencoded table names when upgrading from 5.0 to 5.1. --- mysql-test/r/show_check.result | 2 ++ mysql-test/t/show_check.test | 6 ++++++ sql/mysql_priv.h | 4 ++++ sql/sql_table.cc | 4 ---- sql/table.cc | 19 +++++++++++++++++-- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index acab2f17910..dbb1f063513 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -752,4 +752,6 @@ Tables_in_test Table_type été BASE TABLE drop table `été`; set names latin1; +show columns from `#mysql50#????????`; +ERROR 42S02: Table 'test.#mysql50#????????' doesn't exist End of 5.1 tests diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 60e680c63f3..3aeb92ac203 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -593,4 +593,10 @@ show full tables; drop table `été`; set names latin1; +# +# Bug#26402 Server crashes with old-style named table +# +--error ER_NO_SUCH_TABLE +show columns from `#mysql50#????????`; + --echo End of 5.1 tests diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7fb4d95f1f6..921a940834f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1920,6 +1920,10 @@ uint filename_to_tablename(const char *from, char *to, uint to_length); uint tablename_to_filename(const char *from, char *to, uint to_length); uint build_table_filename(char *buff, size_t bufflen, const char *db, const char *table, const char *ext, uint flags); + +#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" +#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 + /* Flags for conversion functions. */ #define FN_FROM_IS_TMP (1 << 0) #define FN_TO_IS_TMP (1 << 1) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7c13f9f2c54..4378d69dd9f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,10 +54,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info); -#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" -#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 - - /* Translate a file name to a table name (WL #1324). diff --git a/sql/table.cc b/sql/table.cc index 745f3a2a34e..7076dc2d8f8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -343,10 +343,25 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) strxmov(path, share->normalized_path.str, reg_ext, NullS); if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0) { - if (strchr(share->table_name.str, '@')) + /* + We don't try to open 5.0 unencoded name, if + - non-encoded name contains '@' signs, + because '@' can be misinterpreted. + It is not clear if '@' is escape character in 5.1, + or a normal character in 5.0. + + - non-encoded db or table name contain "#mysql50#" prefix. + This kind of tables must have been opened only by the + my_open() above. + */ + if (strchr(share->table_name.str, '@') || + !strncmp(share->db.str, MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH) || + !strncmp(share->table_name.str, MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH)) goto err_not_open; - /* Try unecoded 5.0 name */ + /* Try unencoded 5.0 name */ uint length; strxnmov(path, sizeof(path)-1, mysql_data_home, "/", share->db.str, "/", From 4daad4ebfe1f6a6ec97621eec717a21948ecc8b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 19:40:44 +0800 Subject: [PATCH 130/156] Bug#27640, backup id not displayed in the output of "ndb_mgm start backup wait completed" ndb/include/debugger/EventLogger.hpp: add definition for new printLogEvent() function in CommandInterpreter.cpp ndb/src/mgmclient/CommandInterpreter.cpp: add a printLogEvent() function to print log event; filter "" by ndb_logevent_get_next() in event_thread_run(); filter "" by ndb_logevent_get_next() in executeStartBackup(); and make executeStartBackup() same in both 5.0 and 5.1 ndb/src/mgmclient/Makefile.am: add link to use ndb_logevent_get_next() mysql-test/r/ndb_backup_print.result: testcase result for ndb_backup_print produced by mysql_test_run.pl mysql-test/t/ndb_backup_print.test: add testcase for ndb_mgm -e "start backup", check outupt format --- mysql-test/r/ndb_backup_print.result | 64 ++++++ mysql-test/t/ndb_backup_print.test | 66 ++++++ ndb/include/debugger/EventLogger.hpp | 2 +- ndb/src/mgmclient/CommandInterpreter.cpp | 258 +++++++++++++++++------ ndb/src/mgmclient/Makefile.am | 3 +- 5 files changed, 322 insertions(+), 71 deletions(-) create mode 100644 mysql-test/r/ndb_backup_print.result create mode 100644 mysql-test/t/ndb_backup_print.test diff --git a/mysql-test/r/ndb_backup_print.result b/mysql-test/r/ndb_backup_print.result new file mode 100644 index 00000000000..872ec9d2b72 --- /dev/null +++ b/mysql-test/r/ndb_backup_print.result @@ -0,0 +1,64 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +Connected to Management Server at: : +Waiting for completed, this may take several minutes +Backup started from node +Backup started from node completed + StartGCP: StopGCP: + #Records: #LogRecords: + Data: bytes Log: bytes +create table t1 +(pk int key +,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) +,b1 TINYINT, b2 TINYINT UNSIGNED +,c1 SMALLINT, c2 SMALLINT UNSIGNED +,d1 INT, d2 INT UNSIGNED +,e1 BIGINT, e2 BIGINT UNSIGNED +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine ndb; +insert into t1 values +(1 +,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 +,127, 255 +,32767, 65535 +,2147483647, 4294967295 +,9223372036854775807, 18446744073709551615 +,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 +,0x12,0x123456789abcdef0, 0x00123450 +); +insert into t1 values +(2 +,0, 0, 0, 0, 0 +,-128, 0 +,-32768, 0 +,-2147483648, 0 +,-9223372036854775808, 0 +,'','','' + ,'','','' + ,0x0,0x0,0x0 +,0x0,0x0,0x0 +); +insert into t1 values +(3 +,NULL,NULL,NULL,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +); +Connected to Management Server at: : +Waiting for completed, this may take several minutes +Backup started from node +Backup started from node completed + StartGCP: StopGCP: + #Records: #LogRecords: + Data: bytes Log: bytes diff --git a/mysql-test/t/ndb_backup_print.test b/mysql-test/t/ndb_backup_print.test new file mode 100644 index 00000000000..34bdf519694 --- /dev/null +++ b/mysql-test/t/ndb_backup_print.test @@ -0,0 +1,66 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +#NO.1 test output of backup +--exec $NDB_TOOLS_DIR/../src/mgmclient/ndb_mgm -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' + +create table t1 + (pk int key + ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) + ,b1 TINYINT, b2 TINYINT UNSIGNED + ,c1 SMALLINT, c2 SMALLINT UNSIGNED + ,d1 INT, d2 INT UNSIGNED + ,e1 BIGINT, e2 BIGINT UNSIGNED + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine ndb; + +insert into t1 values + (1 + ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 + ,127, 255 + ,32767, 65535 + ,2147483647, 4294967295 + ,9223372036854775807, 18446744073709551615 + ,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 + ,0x12,0x123456789abcdef0, 0x00123450 + ); + +insert into t1 values + (2 + ,0, 0, 0, 0, 0 + ,-128, 0 + ,-32768, 0 + ,-2147483648, 0 + ,-9223372036854775808, 0 + ,'','','' + ,'','','' + ,0x0,0x0,0x0 + ,0x0,0x0,0x0 + ); + +insert into t1 values + (3 + ,NULL,NULL,NULL,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ); + +#NO.2 test output of backup after some simple SQL operations +--exec $NDB_TOOLS_DIR/../src/mgmclient/ndb_mgm -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' diff --git a/ndb/include/debugger/EventLogger.hpp b/ndb/include/debugger/EventLogger.hpp index 11df3f513fc..f6762743df0 100644 --- a/ndb/include/debugger/EventLogger.hpp +++ b/ndb/include/debugger/EventLogger.hpp @@ -175,5 +175,5 @@ private: char m_text[MAX_TEXT_LENGTH]; }; - +extern void getRestartAction(Uint32 action, BaseString &str); #endif diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 2ea98a57866..6212592461b 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -25,6 +25,7 @@ #include #include +#include class MgmtSrvr; @@ -125,7 +126,7 @@ public: int executeStatus(int processId, const char* parameters, bool all); int executeEventReporting(int processId, const char* parameters, bool all); int executeDumpState(int processId, const char* parameters, bool all); - int executeStartBackup(char * parameters); + int executeStartBackup(char * parameters, bool interactive); int executeAbortBackup(char * parameters); int executeStop(Vector &command_list, unsigned command_pos, int *node_ids, int no_of_nodes); @@ -768,6 +769,113 @@ CommandInterpreter::printError() } } +/* + * print log event from mgmsrv to console screen + */ +static void +printLogEvent(struct ndb_logevent* event) +{ + switch (event->type) { + /** + * NDB_MGM_EVENT_CATEGORY_BACKUP + */ + case NDB_LE_BackupStarted: + ndbout_c("Backup %d started from node %d", + event->BackupStarted.backup_id, event->BackupStarted.starting_node); + break; + case NDB_LE_BackupFailedToStart: + ndbout_c("Backup request from %d failed to start. Error: %d", + event->BackupFailedToStart.starting_node, event->BackupFailedToStart.error); + break; + case NDB_LE_BackupCompleted: + ndbout_c("Backup %u started from node %u completed\n" + " StartGCP: %u StopGCP: %u\n" + " #Records: %u #LogRecords: %u\n" + " Data: %u bytes Log: %u bytes", + event->BackupCompleted.backup_id, event->BackupCompleted.starting_node, + event->BackupCompleted.start_gci, event->BackupCompleted.stop_gci, + event->BackupCompleted.n_records, event->BackupCompleted.n_log_records, + event->BackupCompleted.n_bytes, event->BackupCompleted.n_log_bytes); + break; + case NDB_LE_BackupAborted: + ndbout_c("Backup %d started from %d has been aborted. Error: %d", + event->BackupAborted.backup_id, event->BackupAborted.starting_node, + event->BackupAborted.error); + break; + /** + * NDB_MGM_EVENT_CATEGORY_STARTUP + */ + case NDB_LE_NDBStartStarted: + ndbout_c("Start initiated (version %d.%d.%d)", + getMajor(event->NDBStartStarted.version), + getMinor(event->NDBStartStarted.version), + getBuild(event->NDBStartStarted.version)); + break; + case NDB_LE_NDBStartCompleted: + ndbout_c("Started (version %d.%d.%d)", + getMajor(event->NDBStartCompleted.version), + getMinor(event->NDBStartCompleted.version), + getBuild(event->NDBStartCompleted.version)); + break; + case NDB_LE_NDBStopStarted: + ndbout_c("%s shutdown initiated", + (event->NDBStopStarted.stoptype == 1 ? "Cluster" : "Node")); + break; + case NDB_LE_NDBStopCompleted: + { + BaseString action_str(""); + BaseString signum_str(""); + getRestartAction(event->NDBStopCompleted.action, action_str); + if (event->NDBStopCompleted.signum) + signum_str.appfmt(" Initiated by signal %d.", + event->NDBStopCompleted.signum); + ndbout_c("Node shutdown completed%s.%s", + action_str.c_str(), + signum_str.c_str()); + } + break; + case NDB_LE_NDBStopForced: + { + BaseString action_str(""); + BaseString reason_str(""); + BaseString sphase_str(""); + int signum = event->NDBStopForced.signum; + int error = event->NDBStopForced.error; + int sphase = event->NDBStopForced.sphase; + int extra = event->NDBStopForced.extra; + getRestartAction(event->NDBStopForced.action, action_str); + if (signum) + reason_str.appfmt(" Initiated by signal %d.", signum); + if (error) + { + ndbd_exit_classification cl; + ndbd_exit_status st; + const char *msg = ndbd_exit_message(error, &cl); + const char *cl_msg = ndbd_exit_classification_message(cl, &st); + const char *st_msg = ndbd_exit_status_message(st); + reason_str.appfmt(" Caused by error %d: \'%s(%s). %s\'.", + error, msg, cl_msg, st_msg); + if (extra != 0) + reason_str.appfmt(" (extra info %d)", extra); + } + if (sphase < 255) + sphase_str.appfmt(" Occured during startphase %u.", sphase); + ndbout_c("Forced node shutdown completed%s.%s%s", + action_str.c_str(), sphase_str.c_str(), + reason_str.c_str()); + } + break; + case NDB_LE_NDBStopAborted: + ndbout_c("Node shutdown aborted"); + break; + /** + * default nothing to print + */ + default: + break; + } +} + //***************************************************************************** //***************************************************************************** @@ -784,27 +892,21 @@ event_thread_run(void* p) int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 1, NDB_MGM_EVENT_CATEGORY_STARTUP, 0 }; - int fd = ndb_mgm_listen_event(handle, filter); - if (fd != NDB_INVALID_SOCKET) + + NdbLogEventHandle log_handle= NULL; + struct ndb_logevent log_event; + + log_handle= ndb_mgm_create_logevent_handle(handle, filter); + if (log_handle) { do_event_thread= 1; - char *tmp= 0; - char buf[1024]; - SocketInputStream in(fd,10); do { - if (tmp == 0) NdbSleep_MilliSleep(10); - if((tmp = in.gets(buf, 1024))) - { - const char ping_token[]= ""; - if (memcmp(ping_token,tmp,sizeof(ping_token)-1)) - if(tmp && strlen(tmp)) - { - Guard g(printmutex); - ndbout << tmp; - } - } + if (ndb_logevent_get_next(log_handle, &log_event, 2000) <= 0) + continue; + Guard g(printmutex); + printLogEvent(&log_event); } while(do_event_thread); - NDB_CLOSE_SOCKET(fd); + ndb_mgm_destroy_logevent_handle(&log_handle); } else { @@ -1054,7 +1156,7 @@ CommandInterpreter::execute_impl(const char *_line, bool interactive) else if(strcasecmp(firstToken, "START") == 0 && allAfterFirstToken != NULL && strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ - m_error= executeStartBackup(allAfterFirstToken); + m_error= executeStartBackup(allAfterFirstToken, interactive); DBUG_RETURN(true); } else if(strcasecmp(firstToken, "ABORT") == 0 && @@ -2518,20 +2620,11 @@ CommandInterpreter::executeEventReporting(int processId, * Backup *****************************************************************************/ int -CommandInterpreter::executeStartBackup(char* parameters) +CommandInterpreter::executeStartBackup(char* parameters, bool interactive) { struct ndb_mgm_reply reply; unsigned int backupId; -#if 0 - int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; - int fd = ndb_mgm_listen_event(m_mgmsrv, filter); - if (fd < 0) - { - ndbout << "Initializing start of backup failed" << endl; - printError(); - return fd; - } -#endif + Vector args; { BaseString(parameters).split(args); @@ -2544,25 +2637,20 @@ CommandInterpreter::executeStartBackup(char* parameters) int sz= args.size(); int result; - if (sz == 2 && - args[1] == "NOWAIT") + int flags = 2; + if (sz == 2 && args[1] == "NOWAIT") { - result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply); + flags = 0; } - else if (sz == 1 || - (sz == 3 && - args[1] == "WAIT" && - args[2] == "COMPLETED")) + else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] == "COMPLETED")) { + flags = 2; ndbout_c("Waiting for completed, this may take several minutes"); - result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply); } - else if (sz == 3 && - args[1] == "WAIT" && - args[2] == "STARTED") + else if (sz == 3 && args[1] == "WAIT" && args[2] == "STARTED") { ndbout_c("Waiting for started, this may take several minutes"); - result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply); + flags = 1; } else { @@ -2570,48 +2658,80 @@ CommandInterpreter::executeStartBackup(char* parameters) return -1; } + NdbLogEventHandle log_handle= NULL; + struct ndb_logevent log_event; + if (flags == 2 && !interactive) + { + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0, 0 }; + log_handle = ndb_mgm_create_logevent_handle(m_mgmsrv, filter); + if (!log_handle) + { + ndbout << "Initializing start of backup failed" << endl; + printError(); + return -1; + } + } + result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply); + if (result != 0) { ndbout << "Backup failed" << endl; printError(); -#if 0 - close(fd); -#endif + + if (log_handle) + ndb_mgm_destroy_logevent_handle(&log_handle); return result; } -#if 0 - ndbout_c("Waiting for completed, this may take several minutes"); - char *tmp; - char buf[1024]; + + /** + * If interactive, event listner thread is already running + */ + if (log_handle && !interactive) { - SocketInputStream in(fd); int count = 0; + int retry = 0; do { - tmp = in.gets(buf, 1024); - if(tmp) + if (ndb_logevent_get_next(log_handle, &log_event, 60000) > 0) { - ndbout << tmp; - unsigned int id; - if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){ - count++; - } + int print = 0; + switch (log_event.type) { + case NDB_LE_BackupStarted: + if (log_event.BackupStarted.backup_id == backupId) + print = 1; + break; + case NDB_LE_BackupCompleted: + if (log_event.BackupCompleted.backup_id == backupId) + print = 1; + break; + case NDB_LE_BackupAborted: + if (log_event.BackupAborted.backup_id == backupId) + print = 1; + break; + default: + break; + } + if (print) + { + Guard g(m_print_mutex); + printLogEvent(&log_event); + count++; + } } - } while(count < 2); + else + { + retry++; + } + } while(count < 2 && retry < 3); + + if (retry >= 3) + ndbout << "get backup event failed for " << retry << " times" << endl; + + ndb_mgm_destroy_logevent_handle(&log_handle); } - SocketInputStream in(fd, 10); - do { - tmp = in.gets(buf, 1024); - if(tmp && tmp[0] != 0) - { - ndbout << tmp; - } - } while(tmp && tmp[0] != 0); - - close(fd); -#endif return 0; } + int CommandInterpreter::executeAbortBackup(char* parameters) { diff --git a/ndb/src/mgmclient/Makefile.am b/ndb/src/mgmclient/Makefile.am index 8ce8bf4da45..99540160341 100644 --- a/ndb/src/mgmclient/Makefile.am +++ b/ndb/src/mgmclient/Makefile.am @@ -21,7 +21,8 @@ libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \ ../common/logger/liblogger.la \ ../common/portlib/libportlib.la \ ../common/util/libgeneral.la \ - ../common/portlib/libportlib.la + ../common/portlib/libportlib.la \ + ../common/debugger/libtrace.la ndb_mgm_SOURCES = main.cpp From e470fbe9221da4eb9d582e6c0659d2fe23b30a5e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 20:25:45 +0800 Subject: [PATCH 131/156] Bug#27640, backup id not dispalyed in the output of "ndb_mgm start backup wait completed" correct related sourcecode after merge from 5.0 storage/ndb/src/mgmclient/CommandInterpreter.cpp: correct something to ensure only related sourcecode are merged --- .../ndb/src/mgmclient/CommandInterpreter.cpp | 348 ++---------------- 1 file changed, 35 insertions(+), 313 deletions(-) diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp index 6212592461b..8175a1916b5 100644 --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp @@ -15,14 +15,7 @@ #include #include - -//#define HAVE_GLOBAL_REPLICATION - #include -#ifdef HAVE_GLOBAL_REPLICATION -#include "../rep/repapi/repapi.h" -#endif - #include #include #include @@ -168,11 +161,6 @@ private: int m_verbose; int try_reconnect; int m_error; -#ifdef HAVE_GLOBAL_REPLICATION - NdbRepHandle m_repserver; - const char *rep_host; - bool rep_connected; -#endif struct NdbThread* m_event_thread; NdbMutex *m_print_mutex; }; @@ -237,10 +225,6 @@ extern "C" { #include #include #include -#include -#ifdef HAVE_GLOBAL_REPLICATION - -#endif // HAVE_GLOBAL_REPLICATION #include "MgmtErrorReporter.hpp" #include #include @@ -268,9 +252,6 @@ static const char* helpText = "---------------------------------------------------------------------------\n" "HELP Print help text\n" "HELP COMMAND Print detailed help for COMMAND(e.g. SHOW)\n" -#ifdef HAVE_GLOBAL_REPLICATION -"HELP REPLICATION Help for global replication\n" -#endif // HAVE_GLOBAL_REPLICATION #ifdef VM_TRACE // DEBUG ONLY "HELP DEBUG Help for debug compiled version\n" #endif @@ -294,9 +275,6 @@ static const char* helpText = "EXIT SINGLE USER MODE Exit single user mode\n" " STATUS Print status\n" " CLUSTERLOG {=}+ Set log level for cluster log\n" -#ifdef HAVE_GLOBAL_REPLICATION -"REP CONNECT Connect to REP server on host:port\n" -#endif "PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n" "CONNECT [] Connect to management server (reconnect if already connected)\n" "QUIT Quit management client\n" @@ -596,39 +574,6 @@ static const char* helpTextQuit = ; -#ifdef HAVE_GLOBAL_REPLICATION -static const char* helpTextRep = -"---------------------------------------------------------------------------\n" -" NDB Cluster -- Management Client -- Help for Global Replication\n" -"---------------------------------------------------------------------------\n" -"Commands should be executed on the standby NDB Cluster\n" -"These features are in an experimental release state.\n" -"\n" -"Simple Commands:\n" -"REP START Start Global Replication\n" -"REP START REQUESTOR Start Global Replication Requestor\n" -"REP STATUS Show Global Replication status\n" -"REP STOP Stop Global Replication\n" -"REP STOP REQUESTOR Stop Global Replication Requestor\n" -"\n" -"Advanced Commands:\n" -"REP START Starts protocol\n" -"REP STOP Stops protocol\n" -" = TRANSFER | APPLY | DELETE\n" -"\n" -#ifdef VM_TRACE // DEBUG ONLY -"Debugging commands:\n" -"REP DELETE Removes epochs stored in primary and standy systems\n" -"REP DROP Drop a table in SS identified by table id\n" -"REP SLOWSTOP Stop Replication (Tries to synchonize with primary)\n" -"REP FASTSTOP Stop Replication (Stops in consistent state)\n" -" = SUBSCRIPTION\n" -" METALOG | METASCAN | DATALOG | DATASCAN\n" -" REQUESTOR | TRANSFER | APPLY | DELETE\n" -#endif -; -#endif // HAVE_GLOBAL_REPLICATION - #ifdef VM_TRACE // DEBUG ONLY static const char* helpTextDebug = "---------------------------------------------------------------------------\n" @@ -681,10 +626,6 @@ struct st_cmd_help { {"PURGE STALE SESSIONS", helpTextPurgeStaleSessions}, {"CONNECT", helpTextConnect}, {"QUIT", helpTextQuit}, -#ifdef HAVE_GLOBAL_REPLICATION - {"REPLICATION", helpTextRep}, - {"REP", helpTextRep}, -#endif // HAVE_GLOBAL_REPLICATION #ifdef VM_TRACE // DEBUG ONLY {"DEBUG", helpTextDebug}, #endif //VM_TRACE @@ -724,11 +665,6 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose) m_event_thread= NULL; try_reconnect = 0; m_print_mutex= NdbMutex_Create(); -#ifdef HAVE_GLOBAL_REPLICATION - rep_host = NULL; - m_repserver = NULL; - rep_connected = false; -#endif } /* @@ -1168,15 +1104,9 @@ CommandInterpreter::execute_impl(const char *_line, bool interactive) else if (strcasecmp(firstToken, "PURGE") == 0) { m_error = executePurge(allAfterFirstToken); DBUG_RETURN(true); - } -#ifdef HAVE_GLOBAL_REPLICATION - else if(strcasecmp(firstToken, "REPLICATION") == 0 || - strcasecmp(firstToken, "REP") == 0) { - m_error = executeRep(allAfterFirstToken); - DBUG_RETURN(true); - } -#endif // HAVE_GLOBAL_REPLICATION + } else if(strcasecmp(firstToken, "ENTER") == 0 && + allAfterFirstToken != NULL && allAfterFirstToken != NULL && strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", sizeof("SINGLE USER MODE") - 1) == 0){ @@ -1651,7 +1581,6 @@ CommandInterpreter::executePurge(char* parameters) return -1; } - int i; char *str; if (ndb_mgm_purge_stale_sessions(m_mgmsrv, &str)) { @@ -1730,8 +1659,8 @@ CommandInterpreter::executeShow(char* parameters) case NDB_MGM_NODE_TYPE_UNKNOWN: ndbout << "Error: Unknown Node Type" << endl; return -1; - case NDB_MGM_NODE_TYPE_REP: - abort(); + case NDB_MGM_NODE_TYPE_MAX: + break; /* purify: deadcode */ } } @@ -1769,7 +1698,6 @@ CommandInterpreter::executeConnect(char* parameters, bool interactive) { BaseString *basestring = NULL; - int retval; disconnect(); if (!emptyString(parameters)) { basestring= new BaseString(parameters); @@ -1806,7 +1734,15 @@ CommandInterpreter::executeClusterLog(char* parameters) char * item = strtok_r(tmpString, " ", &tmpPtr); int enable; - const unsigned int *enabled= ndb_mgm_get_logfilter(m_mgmsrv); + ndb_mgm_severity enabled[NDB_MGM_EVENT_SEVERITY_ALL] = + {{NDB_MGM_EVENT_SEVERITY_ON,0}, + {NDB_MGM_EVENT_SEVERITY_DEBUG,0}, + {NDB_MGM_EVENT_SEVERITY_INFO,0}, + {NDB_MGM_EVENT_SEVERITY_WARNING,0}, + {NDB_MGM_EVENT_SEVERITY_ERROR,0}, + {NDB_MGM_EVENT_SEVERITY_CRITICAL,0}, + {NDB_MGM_EVENT_SEVERITY_ALERT,0}}; + ndb_mgm_get_clusterlog_severity_filter(m_mgmsrv, &enabled[0], NDB_MGM_EVENT_SEVERITY_ALL); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); @@ -1819,25 +1755,25 @@ CommandInterpreter::executeClusterLog(char* parameters) ********************/ if (strcasecmp(item, "INFO") == 0) { DBUG_PRINT("info",("INFO")); - if(enabled[0] == 0) + if(enabled[0].value == 0) { ndbout << "Cluster logging is disabled." << endl; m_error = 0; DBUG_VOID_RETURN; } #if 0 - for(i = 0; i<7;i++) - printf("enabled[%d] = %d\n", i, enabled[i]); + for(i = 0; i &command_list, return -1; } + if (!nostart) + ndbout_c("Shutting down nodes with \"-n, no start\" option, to subsequently start the nodes."); + result= ndb_mgm_restart3(m_mgmsrv, no_of_nodes, node_ids, initialstart, nostart, abort, &need_disconnect); @@ -2204,7 +2143,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); @@ -2222,6 +2160,19 @@ CommandInterpreter::executeStatus(int processId, ndbout << processId << ": Node not found" << endl; return -1; } + if (cl->node_states[i].node_type != NDB_MGM_NODE_TYPE_NDB){ + if (cl->node_states[i].version != 0){ + version = cl->node_states[i].version; + ndbout << "Node "<< cl->node_states[i].node_id <<": connected" ; + ndbout_c(" (Version %d.%d.%d)", + getMajor(version) , + getMinor(version), + getBuild(version)); + + }else + ndbout << "Node "<< cl->node_states[i].node_id <<": not connected" << endl; + return 0; + } status = cl->node_states[i].node_status; startPhase = cl->node_states[i].start_phase; version = cl->node_states[i].version; @@ -2616,6 +2567,7 @@ CommandInterpreter::executeEventReporting(int processId, return retval; } + /***************************************************************************** * Backup *****************************************************************************/ @@ -2731,7 +2683,6 @@ CommandInterpreter::executeStartBackup(char* parameters, bool interactive) return 0; } - int CommandInterpreter::executeAbortBackup(char* parameters) { @@ -2762,233 +2713,4 @@ CommandInterpreter::executeAbortBackup(char* parameters) return -1; } -#ifdef HAVE_GLOBAL_REPLICATION -/***************************************************************************** - * Global Replication - * - * For information about the different commands, see - * GrepReq::Request in file signaldata/grepImpl.cpp. - * - * Below are commands as of 2003-07-05 (may change!): - * START = 0, ///< Start Global Replication (all phases) - * START_METALOG = 1, ///< Start Global Replication (all phases) - * START_METASCAN = 2, ///< Start Global Replication (all phases) - * START_DATALOG = 3, ///< Start Global Replication (all phases) - * START_DATASCAN = 4, ///< Start Global Replication (all phases) - * START_REQUESTOR = 5, ///< Start Global Replication (all phases) - * ABORT = 6, ///< Immediate stop (removes subscription) - * SLOW_STOP = 7, ///< Stop after finishing applying current GCI epoch - * FAST_STOP = 8, ///< Stop after finishing applying all PS GCI epochs - * START_TRANSFER = 9, ///< Start SS-PS transfer - * STOP_TRANSFER = 10, ///< Stop SS-PS transfer - * START_APPLY = 11, ///< Start applying GCI epochs in SS - * STOP_APPLY = 12, ///< Stop applying GCI epochs in SS - * STATUS = 13, ///< Status - * START_SUBSCR = 14, - * REMOVE_BUFFERS = 15, - * DROP_TABLE = 16 - - *****************************************************************************/ - -int -CommandInterpreter::executeRep(char* parameters) -{ - if (emptyString(parameters)) { - ndbout << helpTextRep; - return 0; - } - - char * line = my_strdup(parameters,MYF(MY_WME)); - My_auto_ptr ap1((char*)line); - char * firstToken = strtok(line, " "); - - struct ndb_rep_reply reply; - unsigned int repId; - - - if (!strcasecmp(firstToken, "CONNECT")) { - char * host = strtok(NULL, "\0"); - for (unsigned int i = 0; i < strlen(host); ++i) { - host[i] = tolower(host[i]); - } - - if(host == NULL) - { - ndbout_c("host:port must be specified."); - return -1; - } - - if(rep_connected) { - if(m_repserver != NULL) { - ndb_rep_disconnect(m_repserver); - rep_connected = false; - } - } - - if(m_repserver == NULL) - m_repserver = ndb_rep_create_handle(); - if(ndb_rep_connect(m_repserver, host) < 0){ - ndbout_c("Failed to connect to %s", host); - return -1; - } - else - rep_connected=true; - return 0; - - if(!rep_connected) { - ndbout_c("Not connected to REP server"); - return -1; - } - } - - /******** - * START - ********/ - if (!strcasecmp(firstToken, "START")) { - - unsigned int req; - char *startType = strtok(NULL, "\0"); - - if (startType == NULL) { - req = GrepReq::START; - } else if (!strcasecmp(startType, "SUBSCRIPTION")) { - req = GrepReq::START_SUBSCR; - } else if (!strcasecmp(startType, "METALOG")) { - req = GrepReq::START_METALOG; - } else if (!strcasecmp(startType, "METASCAN")) { - req = GrepReq::START_METASCAN; - } else if (!strcasecmp(startType, "DATALOG")) { - req = GrepReq::START_DATALOG; - } else if (!strcasecmp(startType, "DATASCAN")) { - req = GrepReq::START_DATASCAN; - } else if (!strcasecmp(startType, "REQUESTOR")) { - req = GrepReq::START_REQUESTOR; - } else if (!strcasecmp(startType, "TRANSFER")) { - req = GrepReq::START_TRANSFER; - } else if (!strcasecmp(startType, "APPLY")) { - req = GrepReq::START_APPLY; - } else if (!strcasecmp(startType, "DELETE")) { - req = GrepReq::START_DELETE; - } else { - ndbout_c("Illegal argument to command 'REPLICATION START'"); - return -1; - } - - int result = ndb_rep_command(m_repserver, req, &repId, &reply); - - if (result != 0) { - ndbout << "Start of Global Replication failed" << endl; - return -1; - } else { - ndbout << "Start of Global Replication ordered" << endl; - } - return 0; - } - - /******** - * STOP - ********/ - if (!strcasecmp(firstToken, "STOP")) { - unsigned int req; - char *startType = strtok(NULL, " "); - unsigned int epoch = 0; - - if (startType == NULL) { - /** - * Stop immediately - */ - req = GrepReq::STOP; - } else if (!strcasecmp(startType, "EPOCH")) { - char *strEpoch = strtok(NULL, "\0"); - if(strEpoch == NULL) { - ndbout_c("Epoch expected!"); - return -1; - } - req = GrepReq::STOP; - epoch=atoi(strEpoch); - } else if (!strcasecmp(startType, "SUBSCRIPTION")) { - req = GrepReq::STOP_SUBSCR; - } else if (!strcasecmp(startType, "METALOG")) { - req = GrepReq::STOP_METALOG; - } else if (!strcasecmp(startType, "METASCAN")) { - req = GrepReq::STOP_METASCAN; - } else if (!strcasecmp(startType, "DATALOG")) { - req = GrepReq::STOP_DATALOG; - } else if (!strcasecmp(startType, "DATASCAN")) { - req = GrepReq::STOP_DATASCAN; - } else if (!strcasecmp(startType, "REQUESTOR")) { - req = GrepReq::STOP_REQUESTOR; - } else if (!strcasecmp(startType, "TRANSFER")) { - req = GrepReq::STOP_TRANSFER; - } else if (!strcasecmp(startType, "APPLY")) { - req = GrepReq::STOP_APPLY; - } else if (!strcasecmp(startType, "DELETE")) { - req = GrepReq::STOP_DELETE; - } else { - ndbout_c("Illegal argument to command 'REPLICATION STOP'"); - return -1; - } - int result = ndb_rep_command(m_repserver, req, &repId, &reply, epoch); - - if (result != 0) { - ndbout << "Stop command failed" << endl; - return -1; - } else { - ndbout << "Stop ordered" << endl; - } - return 0; - } - - /********* - * STATUS - *********/ - if (!strcasecmp(firstToken, "STATUS")) { - struct rep_state repstate; - int result = - ndb_rep_get_status(m_repserver, &repId, &reply, &repstate); - - if (result != 0) { - ndbout << "Status request of Global Replication failed" << endl; - return -1; - } else { - ndbout << "Status request of Global Replication ordered" << endl; - ndbout << "See printout at one of the DB nodes" << endl; - ndbout << "(Better status report is under development.)" << endl; - ndbout << " SubscriptionId " << repstate.subid - << " SubscriptionKey " << repstate.subkey << endl; - } - return 0; - } - - /********* - * QUERY (see repapi.h for querable counters) - *********/ - if (!strcasecmp(firstToken, "QUERY")) { - char *query = strtok(NULL, "\0"); - int queryCounter=-1; - if(query != NULL) { - queryCounter = atoi(query); - } - struct rep_state repstate; - unsigned repId = 0; - int result = ndb_rep_query(m_repserver, (QueryCounter)queryCounter, - &repId, &reply, &repstate); - - if (result != 0) { - ndbout << "Query repserver failed" << endl; - return -1; - } else { - ndbout << "Query repserver sucessful" << endl; - ndbout_c("repstate : QueryCounter %d, f=%d l=%d" - " nodegroups %d" , - repstate.queryCounter, - repstate.first[0], repstate.last[0], - repstate.no_of_nodegroups ); - } - return 0; - } - return 0; -} -#endif // HAVE_GLOBAL_REPLICATION - template class Vector; From f0000401b48a74d40cf349ae496865cccb1cae30 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 15:38:52 +0300 Subject: [PATCH 132/156] corrected valgrind problems for bug 28505 and 28934 --- tests/mysql_client_test.c | 129 +++++++------------------------------- 1 file changed, 21 insertions(+), 108 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ed1f2d58278..0985b4d25ec 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15627,62 +15627,19 @@ static void test_bug27876() Bug#28505: mysql_affected_rows() returns wrong value if CLIENT_FOUND_ROWS flag is set. */ + static void test_bug28505() { - MYSQL *l_mysql; - my_bool error= 0; my_ulonglong res; - if (!(l_mysql= mysql_init(NULL))) - { - myerror("mysql_init() failed"); - DIE_UNLESS(1); - } - if (!(mysql_real_connect(l_mysql, opt_host, opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_FOUND_ROWS))) - { - myerror("connection failed"); - error= 1; - goto end; - } - l_mysql->reconnect= 1; - if (mysql_query(l_mysql, "drop table if exists t1")) - { - myerror(NULL); - error= 1; - goto end; - } - if (mysql_query(l_mysql, "create table t1(f1 int primary key)")) - { - myerror(NULL); - error= 1; - goto end; - } - if (mysql_query(l_mysql, "insert into t1 values(1)")) - { - myerror(NULL); - error= 1; - goto end; - } - if (mysql_query(l_mysql, - "insert into t1 values(1) on duplicate key update f1=1")) - { - myerror(NULL); - error= 1; - goto end; - } - res= mysql_affected_rows(l_mysql); - if (!res) - error= 1; - if (mysql_query(l_mysql, "drop table t1")) - { - myerror(NULL); - error= 1; - } -end: - mysql_close(l_mysql); - DIE_UNLESS(error == 0); + myquery(mysql_query(mysql, "drop table if exists t1")); + myquery(mysql_query(mysql, "create table t1(f1 int primary key)")); + myquery(mysql_query(mysql, "insert into t1 values(1)")); + myquery(mysql_query(mysql, + "insert into t1 values(1) on duplicate key update f1=1")); + res= mysql_affected_rows(mysql); + DIE_UNLESS(!res); + myquery(mysql_query(mysql, "drop table t1")); } @@ -15692,51 +15649,17 @@ end: static void test_bug28934() { - MYSQL *l_mysql; my_bool error= 0; MYSQL_BIND bind[5]; MYSQL_STMT *stmt; int cnt; - if (!(l_mysql= mysql_init(NULL))) - { - myerror("mysql_init() failed"); - DIE_UNLESS(1); - } - if (!(mysql_real_connect(l_mysql, opt_host, opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_FOUND_ROWS))) - { - myerror("connection failed"); - error= 1; - goto end; - } - l_mysql->reconnect= 1; - if (mysql_query(l_mysql, "drop table if exists t1")) - { - myerror(NULL); - error= 1; - goto end; - } - if (mysql_query(l_mysql, "create table t1(id int)")) - { - myerror(NULL); - error= 1; - goto end; - } - if (mysql_query(l_mysql, "insert into t1 values(1),(2),(3),(4),(5)")) - { - myerror(NULL); - error= 1; - goto end; - } - if (!(stmt= mysql_simple_prepare(l_mysql, - "select * from t1 where id in(?,?,?,?,?)"))) - { - myerror(NULL); - error= 1; - goto end; - } + myquery(mysql_query(mysql, "drop table if exists t1")); + myquery(mysql_query(mysql, "create table t1(id int)")); + + myquery(mysql_query(mysql, "insert into t1 values(1),(2),(3),(4),(5)")); + stmt= mysql_simple_prepare(mysql,"select * from t1 where id in(?,?,?,?,?)"); + check_stmt(stmt); memset (&bind, 0, sizeof (bind)); for (cnt= 0; cnt < 5; cnt++) @@ -15745,25 +15668,15 @@ static void test_bug28934() bind[cnt].buffer= (char*)&cnt; bind[cnt].buffer_length= 0; } - if(mysql_stmt_bind_param(stmt, bind)) - { - myerror(NULL); - error= 1; - goto end; - } + myquery(mysql_stmt_bind_param(stmt, bind)); + stmt->param_count=2; error= mysql_stmt_execute(stmt); - DIE_UNLESS (error != 0); + DIE_UNLESS(error != 0); myerror(NULL); - error= 0; - if (mysql_query(l_mysql, "drop table t1")) - { - myerror(NULL); - error= 1; - } -end: - mysql_close(l_mysql); - DIE_UNLESS(error == 0); + mysql_stmt_close(stmt); + + myquery(mysql_query(mysql, "drop table t1")); } From 9905b81e09c79be318167a861ab2c24baaaebded Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 15:15:45 +0200 Subject: [PATCH 133/156] correct warning --- extra/perror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/perror.c b/extra/perror.c index 6ab2afe0b71..f0b3d36f5d8 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -38,7 +38,7 @@ int mgmapi_error_string(int err_no, char *str, int size) int i; for (i= 0; i < ndb_mgm_noOfErrorMsgs; i++) { - if (ndb_mgm_error_msgs[i].code == err_no) + if ((int)ndb_mgm_error_msgs[i].code == err_no) { my_snprintf(str, size-1, "%s", ndb_mgm_error_msgs[i].msg); str[size-1]= '\0'; From 160489138d83098236700e7db8e18c38764e871f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 16:01:51 +0200 Subject: [PATCH 134/156] Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment_increment for Ndb, post review fix --- ndb/src/ndbapi/Ndb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 941bfc88b24..dcdee3d4ea1 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -882,8 +882,8 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_info* info, DBUG_PRINT("info", ("Next value fetched from database %lu", (ulong) opValue)); DBUG_PRINT("info", ("Increasing %lu by offset %lu, increment is %lu", (ulong) (ulong) opValue, (ulong) offset, (ulong) step)); Uint64 current, next; - next = ((Uint64) (opValue + step - offset)) / step; - next = next * step + offset; + Uint64 div = ((Uint64) (opValue + step - offset)) / step; + next = div * step + offset; current = (next < step) ? next : next - step; tupleId = (opValue <= current) ? current : next; DBUG_PRINT("info", ("Returning %lu", (ulong) tupleId)); From e59c1f5dd458624910f9886e43e10f889da1d5de Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 16:10:13 +0200 Subject: [PATCH 135/156] bug#29099 - slow backup for disk data - implement read ahead during disk data scan storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp: maximum read ahead storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp: maximum read ahead should not be larger than page buffer size maximum aslo set to 32 pages storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: read ahead for disk data scan storage/ndb/src/kernel/blocks/pgman.cpp: set higher max_io_waits for read ahead round off upwards in page_buffer size storage/ndb/src/kernel/vm/SimulatedBlock.cpp: add null callback to be used for read ahead (no callback needed) storage/ndb/src/kernel/vm/SimulatedBlock.hpp: add null callback to be used for read ahead (no callback needed) storage/ndb/src/ndbapi/TransporterFacade.cpp: remove the debug trace, not needed any more storage/ndb/test/tools/hugoFill.cpp: allow setting database in hugoFill --- storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp | 3 + .../ndb/src/kernel/blocks/dbtup/DbtupGen.cpp | 12 ++++ .../ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 64 ++++++++++++++++++- storage/ndb/src/kernel/blocks/pgman.cpp | 4 +- storage/ndb/src/kernel/vm/SimulatedBlock.cpp | 5 ++ storage/ndb/src/kernel/vm/SimulatedBlock.hpp | 4 ++ storage/ndb/src/ndbapi/TransporterFacade.cpp | 3 - storage/ndb/test/tools/hugoFill.cpp | 4 +- 8 files changed, 92 insertions(+), 7 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 7845305da6c..05f993dcece 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -2619,6 +2619,9 @@ private: ArrayPool c_page_pool; Uint32 cnoOfAllocatedPages; Uint32 m_max_allocate_pages; + + /* read ahead in pages during disk order scan */ + Uint32 m_max_page_read_ahead; Tablerec *tablerec; Uint32 cnoOfTablerec; diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index 3a8e996d435..3ea3deda04f 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -347,6 +347,18 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_BATCH_SIZE, &nScanBatch)); c_scanLockPool.setSize(nScanOp * nScanBatch); + + /* read ahead for disk scan can not be more that disk page buffer */ + { + Uint64 tmp = 64*1024*1024; + ndb_mgm_get_int64_parameter(p, CFG_DB_DISK_PAGE_BUFFER_MEMORY, &tmp); + m_max_page_read_ahead = (tmp + GLOBAL_PAGE_SIZE - 1) / GLOBAL_PAGE_SIZE; // in pages + // never read ahead more than 32 pages + if (m_max_page_read_ahead > 32) + m_max_page_read_ahead = 32; + } + + ScanOpPtr lcp; ndbrequire(c_scanOpPool.seize(lcp)); new (lcp.p) ScanOp(); diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index d7ee08f29dd..bb3d8cc0626 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -686,13 +686,74 @@ Dbtup::scanNext(Signal* signal, ScanOpPtr scanPtr) // move to next extent jam(); pos.m_extent_info_ptr_i = ext_ptr.i; - Extent_info* ext = c_extent_pool.getPtr(pos.m_extent_info_ptr_i); + ext = c_extent_pool.getPtr(pos.m_extent_info_ptr_i); key.m_file_no = ext->m_key.m_file_no; key.m_page_no = ext->m_first_page_no; } } key.m_page_idx = 0; pos.m_get = ScanPos::Get_page_dd; + /* + read ahead for scan in disk order + do read ahead every 8:th page + */ + if ((bits & ScanOp::SCAN_DD) && + (((key.m_page_no - ext->m_first_page_no) & 7) == 0)) + { + jam(); + // initialize PGMAN request + Page_cache_client::Request preq; + preq.m_page = pos.m_key; + preq.m_callback = TheNULLCallback; + + // set maximum read ahead + Uint32 read_ahead = m_max_page_read_ahead; + + while (true) + { + // prepare page read ahead in current extent + Uint32 page_no = preq.m_page.m_page_no; + Uint32 page_no_limit = page_no + read_ahead; + Uint32 limit = ext->m_first_page_no + alloc.m_extent_size; + if (page_no_limit > limit) + { + jam(); + // read ahead crosses extent, set limit for this extent + read_ahead = page_no_limit - limit; + page_no_limit = limit; + // and make sure we only read one extra extent next time around + if (read_ahead > alloc.m_extent_size) + read_ahead = alloc.m_extent_size; + } + else + { + jam(); + read_ahead = 0; // no more to read ahead after this + } + // do read ahead pages for this extent + while (page_no < page_no_limit) + { + // page request to PGMAN + jam(); + preq.m_page.m_page_no = page_no; + int flags = 0; + // ignore result + m_pgman.get_page(signal, preq, flags); + jamEntry(); + page_no++; + } + if (!read_ahead || !list.next(ext_ptr)) + { + // no more extents after this or read ahead done + jam(); + break; + } + // move to next extent and initialize PGMAN request accordingly + Extent_info* ext = c_extent_pool.getPtr(ext_ptr.i); + preq.m_page.m_file_no = ext->m_key.m_file_no; + preq.m_page.m_page_no = ext->m_first_page_no; + } + } // if ScanOp::SCAN_DD read ahead } /*FALLTHRU*/ case ScanPos::Get_page_dd: @@ -725,6 +786,7 @@ Dbtup::scanNext(Signal* signal, ScanOpPtr scanPtr) safe_cast(&Dbtup::disk_page_tup_scan_callback); int flags = 0; int res = m_pgman.get_page(signal, preq, flags); + jamEntry(); if (res == 0) { jam(); // request queued diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp index 78bc70427a9..3709748bae4 100644 --- a/storage/ndb/src/kernel/blocks/pgman.cpp +++ b/storage/ndb/src/kernel/blocks/pgman.cpp @@ -122,7 +122,7 @@ Pgman::execREAD_CONFIG_REQ(Signal* signal) if (page_buffer > 0) { - page_buffer /= GLOBAL_PAGE_SIZE; // in pages + page_buffer = (page_buffer + GLOBAL_PAGE_SIZE - 1) / GLOBAL_PAGE_SIZE; // in pages m_param.m_max_pages = page_buffer; m_page_entry_pool.setSize(m_param.m_lirs_stack_mult * page_buffer); m_param.m_max_hot_pages = (page_buffer * 9) / 10; @@ -144,7 +144,7 @@ Pgman::Param::Param() : m_lirs_stack_mult(10), m_max_hot_pages(56), m_max_loop_count(256), - m_max_io_waits(64), + m_max_io_waits(256), m_stats_loop_delay(1000), m_cleanup_loop_delay(200), m_lcp_loop_delay(0) diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp index 7ad1d486a02..bc16b9f364e 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -1658,6 +1658,11 @@ SimulatedBlock::sendFragmentedSignal(NodeReceiverGroup rg, } SimulatedBlock::Callback SimulatedBlock::TheEmptyCallback = {0, 0}; +void +SimulatedBlock::TheNULLCallbackFunction(class Signal*, Uint32, Uint32) +{ abort(); /* should never be called */ } +SimulatedBlock::Callback SimulatedBlock::TheNULLCallback = +{ &SimulatedBlock::TheNULLCallbackFunction, 0 }; void SimulatedBlock::sendFragmentedSignal(BlockReference ref, diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp index 86e26986f93..a78ee21fb8f 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -131,6 +131,8 @@ public: virtual const char* get_filename(Uint32 fd) const { return "";} protected: static Callback TheEmptyCallback; + void TheNULLCallbackFunction(class Signal*, Uint32, Uint32); + static Callback TheNULLCallback; void execute(Signal* signal, Callback & c, Uint32 returnCode); @@ -599,6 +601,8 @@ inline void SimulatedBlock::execute(Signal* signal, Callback & c, Uint32 returnCode){ CallbackFunction fun = c.m_callbackFunction; + if (fun == TheNULLCallback.m_callbackFunction) + return; ndbrequire(fun != 0); c.m_callbackFunction = NULL; (this->*fun)(signal, c.m_callbackData, returnCode); diff --git a/storage/ndb/src/ndbapi/TransporterFacade.cpp b/storage/ndb/src/ndbapi/TransporterFacade.cpp index f982c36cba1..19b384d8dc2 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.cpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp @@ -1403,9 +1403,6 @@ int PollGuard::wait_for_input_in_loop(int wait_time, bool forceSend) } if (wait_time == -1) { -#ifdef VM_TRACE - ndbout << "Waited WAITFOR_RESPONSE_TIMEOUT, continuing wait" << endl; -#endif continue; } wait_time= max_time - NdbTick_CurrentMillisecond(); diff --git a/storage/ndb/test/tools/hugoFill.cpp b/storage/ndb/test/tools/hugoFill.cpp index 713c2ca5152..20ceb61b066 100644 --- a/storage/ndb/test/tools/hugoFill.cpp +++ b/storage/ndb/test/tools/hugoFill.cpp @@ -30,9 +30,11 @@ int main(int argc, const char** argv){ const char* _tabname = NULL; int _help = 0; int _batch = 512; + const char* db = "TEST_DB"; struct getargs args[] = { { "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" }, + { "database", 'd', arg_string, &db, "Database", "" }, { "usage", '?', arg_flag, &_help, "Print help", "" } }; int num_args = sizeof(args) / sizeof(args[0]); @@ -55,7 +57,7 @@ int main(int argc, const char** argv){ { return NDBT_ProgramExit(NDBT_FAILED); } - Ndb MyNdb(&con, "TEST_DB" ); + Ndb MyNdb(&con, db); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); From 854353dd3c101313a570763984cdbfaa6ced88b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 20:33:57 +0500 Subject: [PATCH 136/156] fix the binlog-stm_ps.test for the embedded-server mysql-test/t/binlog_stm_ps.test: embedded server doesn't have binlogs --- mysql-test/t/binlog_stm_ps.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/binlog_stm_ps.test b/mysql-test/t/binlog_stm_ps.test index fa29eea7890..83add5af3d7 100644 --- a/mysql-test/t/binlog_stm_ps.test +++ b/mysql-test/t/binlog_stm_ps.test @@ -1,5 +1,6 @@ # This test is to verify replication with PS +-- source include/not_embedded.inc -- source include/have_binlog_format_mixed_or_statement.inc -- disable_query_log From ebcbfef85fb151d8a30a928906636219f360a15d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 18:40:32 +0200 Subject: [PATCH 137/156] Bug #27640 backup id not displayed in the output of "ndb_mgm start backup wait completed" - correction, missing node id --- mysql-test/r/ndb_backup_print.result | 8 +- mysql-test/t/ndb_backup_print.test | 4 +- ndb/src/mgmclient/CommandInterpreter.cpp | 96 ++++++++++++++---------- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/mysql-test/r/ndb_backup_print.result b/mysql-test/r/ndb_backup_print.result index 872ec9d2b72..fdd929802b2 100644 --- a/mysql-test/r/ndb_backup_print.result +++ b/mysql-test/r/ndb_backup_print.result @@ -2,8 +2,8 @@ use test; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; Connected to Management Server at: : Waiting for completed, this may take several minutes -Backup started from node -Backup started from node completed +Node : Backup started from node +Node : Backup started from node completed StartGCP: StopGCP: #Records: #LogRecords: Data: bytes Log: bytes @@ -57,8 +57,8 @@ insert into t1 values ); Connected to Management Server at: : Waiting for completed, this may take several minutes -Backup started from node -Backup started from node completed +Node : Backup started from node +Node : Backup started from node completed StartGCP: StopGCP: #Records: #LogRecords: Data: bytes Log: bytes diff --git a/mysql-test/t/ndb_backup_print.test b/mysql-test/t/ndb_backup_print.test index 34bdf519694..1e516f03ae6 100644 --- a/mysql-test/t/ndb_backup_print.test +++ b/mysql-test/t/ndb_backup_print.test @@ -8,7 +8,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; --enable_warnings #NO.1 test output of backup ---exec $NDB_TOOLS_DIR/../src/mgmclient/ndb_mgm -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' +--exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' create table t1 (pk int key @@ -63,4 +63,4 @@ insert into t1 values ); #NO.2 test output of backup after some simple SQL operations ---exec $NDB_TOOLS_DIR/../src/mgmclient/ndb_mgm -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' +--exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index a9e3dd48d97..8abce4f9cc4 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -772,6 +772,12 @@ CommandInterpreter::printError() /* * print log event from mgmsrv to console screen */ +#define make_uint64(a,b) (((Uint64)(a)) + (((Uint64)(b)) << 32)) +#define Q64(a) make_uint64(event->EVENT.a ## _lo, event->EVENT.a ## _hi) +#define R event->source_nodeid +#define Q(a) event->EVENT.a +#define QVERSION getMajor(Q(version)), getMinor(Q(version)), getBuild(Q(version)) +#define NDB_LE_(a) NDB_LE_ ## a static void printLogEvent(struct ndb_logevent* event) { @@ -779,71 +785,83 @@ printLogEvent(struct ndb_logevent* event) /** * NDB_MGM_EVENT_CATEGORY_BACKUP */ - case NDB_LE_BackupStarted: - ndbout_c("Backup %d started from node %d", - event->BackupStarted.backup_id, event->BackupStarted.starting_node); +#undef EVENT +#define EVENT BackupStarted + case NDB_LE_BackupStarted: + ndbout_c("Node %u: Backup %d started from node %d", + R, Q(backup_id), Q(starting_node)); break; +#undef EVENT +#define EVENT BackupFailedToStart case NDB_LE_BackupFailedToStart: - ndbout_c("Backup request from %d failed to start. Error: %d", - event->BackupFailedToStart.starting_node, event->BackupFailedToStart.error); + ndbout_c("Node %u: Backup request from %d failed to start. Error: %d", + R, Q(starting_node), Q(error)); break; +#undef EVENT +#define EVENT BackupCompleted case NDB_LE_BackupCompleted: - ndbout_c("Backup %u started from node %u completed\n" + ndbout_c("Node %u: Backup %u started from node %u completed\n" " StartGCP: %u StopGCP: %u\n" " #Records: %u #LogRecords: %u\n" - " Data: %u bytes Log: %u bytes", - event->BackupCompleted.backup_id, event->BackupCompleted.starting_node, - event->BackupCompleted.start_gci, event->BackupCompleted.stop_gci, - event->BackupCompleted.n_records, event->BackupCompleted.n_log_records, - event->BackupCompleted.n_bytes, event->BackupCompleted.n_log_bytes); + " Data: %u bytes Log: %u bytes", R, + Q(backup_id), Q(starting_node), + Q(start_gci), Q(stop_gci), + Q(n_records), Q(n_log_records), + Q(n_bytes), Q(n_log_bytes)); break; +#undef EVENT +#define EVENT BackupAborted case NDB_LE_BackupAborted: - ndbout_c("Backup %d started from %d has been aborted. Error: %d", - event->BackupAborted.backup_id, event->BackupAborted.starting_node, - event->BackupAborted.error); + ndbout_c("Node %u: Backup %d started from %d has been aborted. Error: %d", + R, Q(backup_id), Q(starting_node), Q(error)); break; /** * NDB_MGM_EVENT_CATEGORY_STARTUP */ +#undef EVENT +#define EVENT NDBStartStarted case NDB_LE_NDBStartStarted: - ndbout_c("Start initiated (version %d.%d.%d)", - getMajor(event->NDBStartStarted.version), - getMinor(event->NDBStartStarted.version), - getBuild(event->NDBStartStarted.version)); + ndbout_c("Node %u: Start initiated (version %d.%d.%d)", + R, QVERSION); break; +#undef EVENT +#define EVENT NDBStartCompleted case NDB_LE_NDBStartCompleted: - ndbout_c("Started (version %d.%d.%d)", - getMajor(event->NDBStartCompleted.version), - getMinor(event->NDBStartCompleted.version), - getBuild(event->NDBStartCompleted.version)); + ndbout_c("Node %u: Started (version %d.%d.%d)", + R, QVERSION); break; +#undef EVENT +#define EVENT NDBStopStarted case NDB_LE_NDBStopStarted: - ndbout_c("%s shutdown initiated", - (event->NDBStopStarted.stoptype == 1 ? "Cluster" : "Node")); + ndbout_c("Node %u: %s shutdown initiated", R, + (Q(stoptype) == 1 ? "Cluster" : "Node")); break; +#undef EVENT +#define EVENT NDBStopCompleted case NDB_LE_NDBStopCompleted: { BaseString action_str(""); BaseString signum_str(""); - getRestartAction(event->NDBStopCompleted.action, action_str); - if (event->NDBStopCompleted.signum) + getRestartAction(Q(action), action_str); + if (Q(signum)) signum_str.appfmt(" Initiated by signal %d.", - event->NDBStopCompleted.signum); - ndbout_c("Node shutdown completed%s.%s", - action_str.c_str(), - signum_str.c_str()); + Q(signum)); + ndbout_c("Node %u: Node shutdown completed%s.%s", + R, action_str.c_str(), signum_str.c_str()); } break; +#undef EVENT +#define EVENT NDBStopForced case NDB_LE_NDBStopForced: { BaseString action_str(""); BaseString reason_str(""); BaseString sphase_str(""); - int signum = event->NDBStopForced.signum; - int error = event->NDBStopForced.error; - int sphase = event->NDBStopForced.sphase; - int extra = event->NDBStopForced.extra; - getRestartAction(event->NDBStopForced.action, action_str); + int signum = Q(signum); + int error = Q(error); + int sphase = Q(sphase); + int extra = Q(extra); + getRestartAction(Q(action), action_str); if (signum) reason_str.appfmt(" Initiated by signal %d.", signum); if (error) @@ -860,13 +878,15 @@ printLogEvent(struct ndb_logevent* event) } if (sphase < 255) sphase_str.appfmt(" Occured during startphase %u.", sphase); - ndbout_c("Forced node shutdown completed%s.%s%s", - action_str.c_str(), sphase_str.c_str(), + ndbout_c("Node %u: Forced node shutdown completed%s.%s%s", + R, action_str.c_str(), sphase_str.c_str(), reason_str.c_str()); } break; +#undef EVENT +#define EVENT StopAborted case NDB_LE_NDBStopAborted: - ndbout_c("Node shutdown aborted"); + ndbout_c("Node %u: Node shutdown aborted", R); break; /** * default nothing to print From 4a009817ab562e3bc20edf496a6d0fda62ac3c1d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jun 2007 14:24:59 -0400 Subject: [PATCH 138/156] Bug#21723: Should be able to dump core after setuid() under Linux In many cases, binaries can no longer dump core after calling setuid(). Where the PR_SET_DUMPABLE macro is set, use the prctl() system call to tell the kernel that it's allowed to dump the core of the server. configure.in: Test system for "sys/prctl.h", to get access to prctl(). sql/mysqld.cc: Add a process-control operation that tells the Linux kernel that it is allowed to dump core after setuid(). --- configure.in | 1 + sql/mysqld.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/configure.in b/configure.in index d995fd107ad..812bcff0d97 100644 --- a/configure.in +++ b/configure.in @@ -776,6 +776,7 @@ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \ sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \ unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \ sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \ + sys/prctl.h \ sys/resource.h sys/param.h) #-------------------------------------------------------------------- diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 051bad5b310..b7f00afbcd2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -32,6 +32,9 @@ #ifdef HAVE_NDBCLUSTER_DB #include "ha_ndbcluster.h" #endif +#ifdef HAVE_SYS_PRCTL_H +#include +#endif #ifdef HAVE_INNOBASE_DB #define OPT_INNODB_DEFAULT 1 @@ -1365,6 +1368,15 @@ static struct passwd *check_user(const char *user) err: sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); unireg_abort(1); + +#ifdef PR_SET_DUMPABLE + if (test_flags & TEST_CORE_ON_SIGNAL) + { + /* inform kernel that process is dumpable */ + (void) prctl(PR_SET_DUMPABLE, 1); + } +#endif + #endif return NULL; } From 39700afdb9d32b6f8db4982e6ab3066db060e9f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 11:19:35 +0500 Subject: [PATCH 139/156] Bug#28862 Extended Latin1 characters get lost in CVS engine Problem: Temporary buffer which is used for quoting and escaping was initialized to character set utf8, and thus didn't allow to store data in other character sets. Fix: changing character set of the buffer to be able to store any arbitrary sequence of bytes. mysql-test/r/csv.result: Adding test case mysql-test/t/csv.test: Adding test case sql/examples/ha_tina.cc: Changing character set of the buffer to "binary". --- mysql-test/r/csv.result | 21 +++++++++++++++++++++ mysql-test/t/csv.test | 18 ++++++++++++++++++ sql/examples/ha_tina.cc | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 8ec79e9d7a9..3900597d2a6 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5009,3 +5009,24 @@ select * from bug15205; val drop table bug15205; drop table bug15205_2; +set names latin1; +create table t1 ( +c varchar(1), +name varchar(64) +) character set latin1 engine=csv; +insert into t1 values (0xC0,'LATIN CAPITAL LETTER A WITH GRAVE'); +insert into t1 values (0xE0,'LATIN SMALL LETTER A WITH GRAVE'); +insert into t1 values (0xEE,'LATIN SMALL LETTER I WITH CIRCUMFLEX'); +insert into t1 values (0xFE,'LATIN SMALL LETTER THORN'); +insert into t1 values (0xF7,'DIVISION SIGN'); +insert into t1 values (0xFF,'LATIN SMALL LETTER Y WITH DIAERESIS'); +select hex(c), c, name from t1 order by 1; +hex(c) c name +C0 À LATIN CAPITAL LETTER A WITH GRAVE +E0 à LATIN SMALL LETTER A WITH GRAVE +EE î LATIN SMALL LETTER I WITH CIRCUMFLEX +F7 ÷ DIVISION SIGN +FE þ LATIN SMALL LETTER THORN +FF ÿ LATIN SMALL LETTER Y WITH DIAERESIS +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 687f3ea3918..b724b4ce47c 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1410,3 +1410,21 @@ select * from bug15205; drop table bug15205; drop table bug15205_2; +# +# Bug#28862 "Extended Latin1 characters get lost in CVS engine" +# +set names latin1; +create table t1 ( + c varchar(1), + name varchar(64) +) character set latin1 engine=csv; +insert into t1 values (0xC0,'LATIN CAPITAL LETTER A WITH GRAVE'); +insert into t1 values (0xE0,'LATIN SMALL LETTER A WITH GRAVE'); +insert into t1 values (0xEE,'LATIN SMALL LETTER I WITH CIRCUMFLEX'); +insert into t1 values (0xFE,'LATIN SMALL LETTER THORN'); +insert into t1 values (0xF7,'DIVISION SIGN'); +insert into t1 values (0xFF,'LATIN SMALL LETTER Y WITH DIAERESIS'); +select hex(c), c, name from t1 order by 1; +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 00f927aa7b7..2c5226222e2 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -301,7 +301,7 @@ ha_tina::ha_tina(TABLE *table_arg) chain_size(DEFAULT_CHAIN_LENGTH), records_is_known(0) { /* Set our original buffers from pre-allocated memory */ - buffer.set(byte_buffer, IO_SIZE, system_charset_info); + buffer.set(byte_buffer, IO_SIZE, &my_charset_bin); chain= chain_buffer; } @@ -447,7 +447,7 @@ int ha_tina::find_current_row(byte *buf) else buffer.append(*mapped_ptr); } - (*field)->store(buffer.ptr(), buffer.length(), system_charset_info); + (*field)->store(buffer.ptr(), buffer.length(), buffer.charset()); } next_position= (end_ptr - share->mapped_file)+1; /* Maybe use \N for null? */ From a0091f64747abad47f3ea1ac103837c9a02eb168 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 11:53:46 +0500 Subject: [PATCH 140/156] Additional fix for bug N26402: An attempt to open file with name '????????.frm' can produce different errors: - ER_NO_SUCH_TABLE on Unix - ER_FILE_NOT_FOUND on Windows because QUESTION MARK has special meaning on Windows. Make sure that any of these two errors happens. mysql-test/r/show_check.result: Additional fix for bug N26402 mysql-test/t/show_check.test: Additional fix for bug N26402 --- mysql-test/r/show_check.result | 2 +- mysql-test/t/show_check.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index dbb1f063513..66cd929ee05 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -753,5 +753,5 @@ Tables_in_test Table_type drop table `été`; set names latin1; show columns from `#mysql50#????????`; -ERROR 42S02: Table 'test.#mysql50#????????' doesn't exist +Got one of the listed errors End of 5.1 tests diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 3aeb92ac203..8d41399df70 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -596,7 +596,7 @@ set names latin1; # # Bug#26402 Server crashes with old-style named table # ---error ER_NO_SUCH_TABLE +--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND show columns from `#mysql50#????????`; --echo End of 5.1 tests From 8ebcb3ee949087d87e311d7566589796a000b65c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 09:18:58 +0200 Subject: [PATCH 141/156] Added yassl and taocrypt sources to mysqlclientlib client/CMakeLists.txt: Fix for bug #27861: unresolved externals (yassl and taocrypt) --- client/CMakeLists.txt | 67 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6e37d02ecd8..e1bf2f2d8fc 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -19,16 +19,52 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # The old Windows build method used renamed (.cc -> .cpp) source files, fails # in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/zlib - ${CMAKE_SOURCE_DIR}/extra/yassl/include +ADD_DEFINITIONS(-DUSING_CMAKE -DYASSL_PREFIX) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/mysys ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) +SET(YASSL_SOURCES ../extra/yassl/src/buffer.cpp + ../extra/yassl/src/cert_wrapper.cpp + ../extra/yassl/src/crypto_wrapper.cpp + ../extra/yassl/src/handshake.cpp + ../extra/yassl/src/lock.cpp + ../extra/yassl/src/log.cpp + ../extra/yassl/src/socket_wrapper.cpp + ../extra/yassl/src/ssl.cpp + ../extra/yassl/src/timer.cpp + ../extra/yassl/src/yassl_error.cpp + ../extra/yassl/src/yassl_imp.cpp + ../extra/yassl/src/yassl_int.cpp) + +SET(TAOCRYPT_SOURCES ../extra/yassl/taocrypt/src/aes.cpp + ../extra/yassl/taocrypt/src/aestables.cpp + ../extra/yassl/taocrypt/src/algebra.cpp + ../extra/yassl/taocrypt/src/arc4.cpp + ../extra/yassl/taocrypt/src/asn.cpp + ../extra/yassl/taocrypt/src/coding.cpp + ../extra/yassl/taocrypt/src/des.cpp + ../extra/yassl/taocrypt/src/dh.cpp + ../extra/yassl/taocrypt/src/dsa.cpp + ../extra/yassl/taocrypt/src/file.cpp + ../extra/yassl/taocrypt/src/hash.cpp + ../extra/yassl/taocrypt/src/integer.cpp + ../extra/yassl/taocrypt/src/md2.cpp + ../extra/yassl/taocrypt/src/md4.cpp + ../extra/yassl/taocrypt/src/md5.cpp + ../extra/yassl/taocrypt/src/misc.cpp + ../extra/yassl/taocrypt/src/random.cpp + ../extra/yassl/taocrypt/src/ripemd.cpp + ../extra/yassl/taocrypt/src/rsa.cpp + ../extra/yassl/taocrypt/src/sha.cpp) + ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c @@ -63,39 +99,42 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c + ${YASSL_SOURCES} ${TAOCRYPT_SOURCES} + ) + ADD_DEPENDENCIES(mysqlclient GenError) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl taocrypt zlib dbug wsock32) +TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys yassl taocrypt zlib dbug regex wsock32) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug zlib wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(echo echo.c) From d36c1aef8a884132dd6faf73b914391e063d0009 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 09:52:58 +0200 Subject: [PATCH 142/156] BUG#27861 merge to 5.1 --- client/CMakeLists.txt | 65 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8ec8b0111b0..b2650edbe11 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -19,15 +19,52 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # The old Windows build method used renamed (.cc -> .cpp) source files, fails # in #include in mysqlbinlog.cc. So disable that using the USING_CMAKE define. -ADD_DEFINITIONS(-DUSING_CMAKE) +ADD_DEFINITIONS(-DUSING_CMAKE -DYASSL_PREFIX) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib - ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL ${CMAKE_SOURCE_DIR}/libmysql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings) +SET(YASSL_SOURCES ../extra/yassl/src/buffer.cpp + ../extra/yassl/src/cert_wrapper.cpp + ../extra/yassl/src/crypto_wrapper.cpp + ../extra/yassl/src/handshake.cpp + ../extra/yassl/src/lock.cpp + ../extra/yassl/src/log.cpp + ../extra/yassl/src/socket_wrapper.cpp + ../extra/yassl/src/ssl.cpp + ../extra/yassl/src/timer.cpp + ../extra/yassl/src/yassl_error.cpp + ../extra/yassl/src/yassl_imp.cpp + ../extra/yassl/src/yassl_int.cpp) + +SET(TAOCRYPT_SOURCES ../extra/yassl/taocrypt/src/aes.cpp + ../extra/yassl/taocrypt/src/aestables.cpp + ../extra/yassl/taocrypt/src/algebra.cpp + ../extra/yassl/taocrypt/src/arc4.cpp + ../extra/yassl/taocrypt/src/asn.cpp + ../extra/yassl/taocrypt/src/coding.cpp + ../extra/yassl/taocrypt/src/des.cpp + ../extra/yassl/taocrypt/src/dh.cpp + ../extra/yassl/taocrypt/src/dsa.cpp + ../extra/yassl/taocrypt/src/file.cpp + ../extra/yassl/taocrypt/src/hash.cpp + ../extra/yassl/taocrypt/src/integer.cpp + ../extra/yassl/taocrypt/src/md2.cpp + ../extra/yassl/taocrypt/src/md4.cpp + ../extra/yassl/taocrypt/src/md5.cpp + ../extra/yassl/taocrypt/src/misc.cpp + ../extra/yassl/taocrypt/src/random.cpp + ../extra/yassl/taocrypt/src/ripemd.cpp + ../extra/yassl/taocrypt/src/rsa.cpp + ../extra/yassl/taocrypt/src/sha.cpp) + + ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c @@ -62,43 +99,45 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c + ${YASSL_SOURCES} ${TAOCRYPT_SOURCES} + ) ADD_DEPENDENCIES(mysqlclient GenError) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) -TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl taocrypt zlib dbug wsock32) +TARGET_LINK_LIBRARIES(mysql mysqlclient mysys zlib dbug wsock32) ADD_EXECUTABLE(mysqltest mysqltest.c) -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys yassl taocrypt zlib dbug regex wsock32) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys zlib dbug regex wsock32) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient dbug zlib wsock32) ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug zlib wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c ../mysys/my_new.cc ../mysys/my_bit.c ../mysys/my_bitmap.c ../mysys/my_vle.c ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient dbug zlib wsock32) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug zlib wsock32) ADD_EXECUTABLE(mysqlslap mysqlslap.c) SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys yassl taocrypt zlib wsock32 dbug) +TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) ADD_EXECUTABLE(echo echo.c) From 608297467983e8504c5063f64399be16a5648cc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 13:53:36 +0500 Subject: [PATCH 143/156] Backport of mysql-test/include/wait_for_slave_io_to_stop.inc mysql-test/include/wait_for_slave_sql_to_stop.inc mysql-test/include/wait_for_slave_to_start.inc mysql-test/include/wait_for_slave_to_stop.inc from 5.1 mysql-test/include/wait_for_slave_io_to_stop.inc: New BitKeeper file ``mysql-test/include/wait_for_slave_io_to_stop.inc'' mysql-test/include/wait_for_slave_sql_to_stop.inc: New BitKeeper file ``mysql-test/include/wait_for_slave_sql_to_stop.inc'' mysql-test/include/wait_for_slave_to_start.inc: New BitKeeper file ``mysql-test/include/wait_for_slave_to_start.inc'' mysql-test/include/wait_for_slave_to_stop.inc: New BitKeeper file ``mysql-test/include/wait_for_slave_to_stop.inc'' --- .../include/wait_for_slave_io_to_stop.inc | 33 +++++++++++++++++ .../include/wait_for_slave_sql_to_stop.inc | 30 +++++++++++++++ .../include/wait_for_slave_to_start.inc | 35 ++++++++++++++++++ mysql-test/include/wait_for_slave_to_stop.inc | 37 +++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 mysql-test/include/wait_for_slave_io_to_stop.inc create mode 100644 mysql-test/include/wait_for_slave_sql_to_stop.inc create mode 100644 mysql-test/include/wait_for_slave_to_start.inc create mode 100644 mysql-test/include/wait_for_slave_to_stop.inc diff --git a/mysql-test/include/wait_for_slave_io_to_stop.inc b/mysql-test/include/wait_for_slave_io_to_stop.inc new file mode 100644 index 00000000000..004f8bbbd8d --- /dev/null +++ b/mysql-test/include/wait_for_slave_io_to_stop.inc @@ -0,0 +1,33 @@ +################################################### +#Author: Jeb +#Date: 2007-06-11 +#Purpose: used for io errors on the slave. If Slave gets an io +# error, the io trhead should stop +#Details: +# 1) Fill in and setup variables +# 2) loop through looking for +# sql threads to stop +# 3) If loops too long die. +#################################################### +connection slave; +let $my_show= SHOW SLAVE STATUS; +let $sql_running= Slave_IO_Running; +let $row_number= 1; +let $run= 1; +let $counter= 300; + +while ($run) +{ + let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number); + if (`SELECT '$io_result' = 'No'`){ + let $run= 0; + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave IO thread to stop" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} + diff --git a/mysql-test/include/wait_for_slave_sql_to_stop.inc b/mysql-test/include/wait_for_slave_sql_to_stop.inc new file mode 100644 index 00000000000..ee765c81f6a --- /dev/null +++ b/mysql-test/include/wait_for_slave_sql_to_stop.inc @@ -0,0 +1,30 @@ +################################################### +#Author: Jeb +#Date: 2007-06-11 +#Purpose: used for SQL errors on the slave. If Slave gets a sql +# error, the SQL trhead should stop +#Details: +# 1) Fill in and setup variables +# 2) loop through looking for +# sql threads to stop +# 3) If loops too long die. +#################################################### +connection slave; +let $row_number= 1; +let $run= 1; +let $counter= 300; + +while ($run) +{ + let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); + if (`SELECT '$sql_result' = 'No'`){ + let $run= 0; + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave SQL thread to stop" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} diff --git a/mysql-test/include/wait_for_slave_to_start.inc b/mysql-test/include/wait_for_slave_to_start.inc new file mode 100644 index 00000000000..84e1d646efe --- /dev/null +++ b/mysql-test/include/wait_for_slave_to_start.inc @@ -0,0 +1,35 @@ +################################################### +#Author: Jeb +#Date: 2007-06-11 +#Purpose: To wait a brief time for slave to start +#Details: +# 1) Fill in and setup variables +# 2) loop through looking for both +# io and sql threads to start +# 3) If loops too long die. +#################################################### +connection slave; +let $row_number= 1; +let $run= 1; +let $counter= 300; + +while ($run) +{ + let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number); + if (`SELECT '$io_result' = 'Yes'`){ + + let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); + if (`SELECT '$sql_result' = 'Yes'`){ + let $run= 0; + } + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave to start" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} + + diff --git a/mysql-test/include/wait_for_slave_to_stop.inc b/mysql-test/include/wait_for_slave_to_stop.inc new file mode 100644 index 00000000000..13acbecb835 --- /dev/null +++ b/mysql-test/include/wait_for_slave_to_stop.inc @@ -0,0 +1,37 @@ +################################################### +#Author: Jeb +#Date: 2007-06-11 +#Purpose: To replace the mysqltest.c executable +# wait_for_slave_to_stop function and +# return this to the test language. +#Details: +# 1) Fill in and setup variables +# 2) loop through looking for both +# io and sql threads to stop +# 3) If loops too long die. +#################################################### +connection slave; +let $row_number= 1; +let $run= 1; +let $counter= 300; + +while ($run) +{ + let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number); + if (`SELECT '$io_result' = 'No'`){ + + let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); + if (`SELECT '$sql_result' = 'No'`){ + let $run= 0; + } + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave to stop" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} + + From 9bba1059bf6219a8e924a2bbdd3b0afad92bfc3d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 11:28:15 +0200 Subject: [PATCH 144/156] follow-up fix include/violite.h: this may already be defined --- include/violite.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/violite.h b/include/violite.h index e0172008565..7b57667541a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -100,7 +100,9 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #define HEADER_DES_LOCL_H dummy_something #define YASSL_MYSQL_COMPATIBLE +#ifndef YASSL_PREFIX #define YASSL_PREFIX +#endif /* Set yaSSL to use same type as MySQL do for socket handles */ typedef my_socket YASSL_SOCKET_T; #define YASSL_SOCKET_T_DEFINED From d2f858aba3a9414d9bc247fccb13bc85f8799af0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 16:09:28 +0500 Subject: [PATCH 145/156] Fix for bug #28144: "Slave_IO_Running" differs in replication tests Problem: show slave status may return different Slave_IO_Running values running some tests. Fix: wait for a certain slave state if needed to get tests more predictable. mysql-test/r/rpl_log_pos.result: Fix for bug #28144: "Slave_IO_Running" differs in replication tests - test result adjusted. mysql-test/r/rpl_ssl.result: Fix for bug #28144: "Slave_IO_Running" differs in replication tests - test result adjusted. mysql-test/t/rpl_log_pos.test: Fix for bug #28144: "Slave_IO_Running" differs in replication tests - test has been rewritten to get certain slave state, now we use wait_for_slave_param.inc to ensure we get proper IO/SQL slave's threads states. mysql-test/t/rpl_ssl.test: Fix for bug #28144: "Slave_IO_Running" differs in replication tests - wait_for_slave_to_start.inc used to get certain slave states in order to be more predictable. mysql-test/include/wait_for_slave_param.inc: New BitKeeper file ``mysql-test/include/wait_for_slave_param.inc'' allow to wait until SHOW SLAVE STATUS has returned a spicified value. --- mysql-test/include/wait_for_slave_param.inc | 26 +++++++ mysql-test/r/rpl_log_pos.result | 83 +++++++++++++++++---- mysql-test/r/rpl_ssl.result | 1 + mysql-test/t/rpl_log_pos.test | 33 ++++---- mysql-test/t/rpl_ssl.test | 3 + 5 files changed, 112 insertions(+), 34 deletions(-) create mode 100644 mysql-test/include/wait_for_slave_param.inc diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc new file mode 100644 index 00000000000..fed97195aba --- /dev/null +++ b/mysql-test/include/wait_for_slave_param.inc @@ -0,0 +1,26 @@ +# include/wait_for_slave_param.inc +# +# SUMMARY +# +# Waits until SHOW SLAVE STATUS has returned a spicified value. +# +# USAGE +# +# let $slave_param= Slave_SQL_Running; +# let $slave_param_value= No; +# --source include/slave_wait_param.inc + +let $slave_wait_param_counter= 300; +let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1); +while (`select "$slave_value" != "$slave_param_value"`) +{ + dec $slave_wait_param_counter; + if (!$slave_wait_param_counter) + { + --echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value + query_vertical show slave status; + exit; + } + sleep 0.1; + let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1); +} diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index cf13756966e..b55326415bf 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -7,27 +7,78 @@ start slave; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 98 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 98 # # master-bin.000001 Yes Yes 0 0 98 # None 0 No # -stop slave; -change master to master_log_pos=73; -start slave; stop slave; change master to master_log_pos=73; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 # # master-bin.000001 No No 0 0 73 # None 0 No # +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 73 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +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 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 73 +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 # start slave; -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 # # master-bin.000001 No Yes 0 0 73 # None 0 No # stop slave; -change master to master_log_pos=173; -start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 # # master-bin.000001 No Yes 0 0 173 # None 0 No # +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 73 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +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 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 73 +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 # show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 98 @@ -35,7 +86,6 @@ create table if not exists t1 (n int); drop table if exists t1; create table t1 (n int); insert into t1 values (1),(2),(3); -stop slave; change master to master_log_pos=98; start slave; select * from t1; @@ -44,3 +94,4 @@ n 2 3 drop table t1; +End of 5.0 tests diff --git a/mysql-test/r/rpl_ssl.result b/mysql-test/r/rpl_ssl.result index 6bc1e996965..1d3f4762693 100644 --- a/mysql-test/r/rpl_ssl.result +++ b/mysql-test/r/rpl_ssl.result @@ -92,3 +92,4 @@ Master_SSL_Cert MYSQL_TEST_DIR/std_data/client-cert.pem Master_SSL_Cipher Master_SSL_Key MYSQL_TEST_DIR/std_data/client-key.pem Seconds_Behind_Master # +End of 5.0 tests diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test index 979b146bb22..ee8da494f86 100644 --- a/mysql-test/t/rpl_log_pos.test +++ b/mysql-test/t/rpl_log_pos.test @@ -4,31 +4,29 @@ source include/master-slave.inc; show master status; sync_slave_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -stop slave; -change master to master_log_pos=73; -start slave; -sleep 5; + stop slave; +--source include/wait_for_slave_to_stop.inc change master to master_log_pos=73; --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; +query_vertical show slave status; + start slave; -sleep 5; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; +let $slave_param= Slave_SQL_Running; +let $slave_param_value= Yes; +--source include/wait_for_slave_param.inc +let $slave_param= Slave_IO_Running; +let $slave_param_value= No; +--source include/wait_for_slave_param.inc stop slave; -change master to master_log_pos=173; -start slave; -sleep 2; +--source include/wait_for_slave_to_stop.inc + --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; +query_vertical show slave status; + connection master; show master status; create table if not exists t1 (n int); @@ -37,7 +35,6 @@ create table t1 (n int); insert into t1 values (1),(2),(3); save_master_pos; connection slave; -stop slave; change master to master_log_pos=98; start slave; sync_with_master; @@ -46,4 +43,4 @@ connection master; drop table t1; sync_slave_with_master; -# End of 4.1 tests +--echo End of 5.0 tests diff --git a/mysql-test/t/rpl_ssl.test b/mysql-test/t/rpl_ssl.test index f83f8b983b2..d08004cb00b 100644 --- a/mysql-test/t/rpl_ssl.test +++ b/mysql-test/t/rpl_ssl.test @@ -56,6 +56,9 @@ enable_query_log; connection master; insert into t1 values (NULL); sync_slave_with_master; +--source include/wait_for_slave_to_start.inc --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # query_vertical show slave status; + +--echo End of 5.0 tests From 290414712e654bd26c550188cdbf7f95a84c8c21 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 14:32:16 -0400 Subject: [PATCH 146/156] Embedded Server doesn't build on Windows. - Add build configuration parameter EMBEDDED_ONLY which will configure the VS solution to produce only mysql embedded binary. - Make necessary updates to successfully compile solution. CMakeLists.txt: Embedded Server doesn't build on Windows. - Remove leading space from various definitions. - Remove optimizations from RelWithDebInfo configuration for debugging. - Conditionally add the necessary build directories based on EMBEDDED_ONLY flag. BitKeeper/etc/ignore: Embedded Server doesn't build on Windows. - Ignore CMake's default configuration output directories. - Ignore autogenerated cmake_dummy.c file. libmysql/client_settings.h: Embedded Server doesn't build on Windows. - Build fixup libmysqld/CMakeLists.txt: Embedded Server doesn't build on Windows. - Update for recent changes. libmysqld/libmysqld.def: Embedded Server doesn't build on Windows. - Export necessary methods. libmysqld/examples/CMakeLists.txt: Embedded Server doesn't build on Windows. - Updated include directories. - test_libmysqld fixup. - Added mysqltest_embedded and mysql_client_test_embedded exes needed for testing. sql/mysqld.cc: Embedded Server doesn't build on Windows. - Build fixup. sql/sql_binlog.cc: Embedded Server doesn't build on Windows. - Build fixup. sql-common/client.c: Embedded Server doesn't build on Windows. - Build fixup. storage/federated/CMakeLists.txt: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. storage/heap/CMakeLists.txt: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. storage/innobase/CMakeLists.txt: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. storage/myisam/CMakeLists.txt: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. storage/myisam/ha_myisam.cc: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. storage/myisammrg/CMakeLists.txt: Embedded Server doesn't build on Windows. - Define USE_TLS for embedded only builds. win/configure.js: Embedded Server doesn't build on Windows. - Add EMBEDDED_ONLY build configuration. --- .bzrignore | 3 + CMakeLists.txt | 71 ++++++++++++-------- libmysql/client_settings.h | 2 +- libmysqld/CMakeLists.txt | 104 +++++++++++++++++------------- libmysqld/examples/CMakeLists.txt | 14 +++- libmysqld/libmysqld.def | 8 +++ sql-common/client.c | 2 +- sql/mysqld.cc | 2 + sql/sql_binlog.cc | 2 + storage/federated/CMakeLists.txt | 3 + storage/heap/CMakeLists.txt | 3 + storage/innobase/CMakeLists.txt | 3 + storage/myisam/CMakeLists.txt | 4 ++ storage/myisam/ha_myisam.cc | 2 + storage/myisammrg/CMakeLists.txt | 3 + win/configure.js | 1 + 16 files changed, 154 insertions(+), 73 deletions(-) diff --git a/.bzrignore b/.bzrignore index 8347800ffb3..bc7a7a6429d 100644 --- a/.bzrignore +++ b/.bzrignore @@ -39,6 +39,8 @@ */.pure */debug/* */release/* +*/relwithdebinfo/* +*/minsizerel/* *~ .*.swp ./CMakeCache.txt @@ -1020,6 +1022,7 @@ libmysqld/backup_dir libmysqld/client.c libmysqld/client_settings.h libmysqld/convert.cc +libmysqld/cmake_dummy.c libmysqld/derror.cc libmysqld/discover.cc libmysqld/emb_qcache.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b1268e0699..538c5cb122e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,50 +18,64 @@ PROJECT(MySql) # This reads user configuration, generated by configure.js. INCLUDE(win/configure.data) -# Hardcode support for CSV storage engine -SET(WITH_CSV_STORAGE_ENGINE TRUE) +# By default, CMake will create Release, Debug, RelWithDebInfo and MinSizeRel +# configurations. The EMBEDDED_ONLY build parameter is necessary because CMake +# doesn't support custom build configurations for VS2005. Since the Debug +# configuration does not work properly with USE_TLS defined +# (see mysys/CMakeLists.txt) the easiest way to debug the Embedded Server is to +# use the RelWithDebInfo configuration without optimizations. +# +# Debug default CXX_FLAGS "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" +# RelWithDebInfo default CXX_FLAGS "/MD /Zi /O2 /Ob1 /D NDEBUG" +# +IF(NOT EMBEDDED_ONLY) + # Hardcode support for CSV storage engine + SET(WITH_CSV_STORAGE_ENGINE TRUE) +ELSE(NOT EMBEDDED_ONLY) + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /Od /Ob0 /D NDEBUG" CACHE STRING "No Optimization" FORCE) +ENDIF(NOT EMBEDDED_ONLY) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) SET(WITH_HEAP_STORAGE_ENGINE TRUE) -ADD_DEFINITIONS(-D WITH_HEAP_STORAGE_ENGINE) +ADD_DEFINITIONS(-DWITH_HEAP_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin") SET(WITH_MYISAM_STORAGE_ENGINE TRUE) -ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE) +ADD_DEFINITIONS(-DWITH_MYISAM_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin") SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE) -ADD_DEFINITIONS(-D WITH_MYISAMMRG_STORAGE_ENGINE) +ADD_DEFINITIONS(-DWITH_MYISAMMRG_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") IF(WITH_ARCHIVE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_ARCHIVE_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_ARCHIVE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin") ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_BLACKHOLE_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_BLACKHOLE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_blackhole_plugin") ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_CSV_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_CSV_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_CSV_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_csv_plugin") ENDIF(WITH_CSV_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_EXAMPLE_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_EXAMPLE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_example_plugin") ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_INNOBASE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin") ENDIF(WITH_INNOBASE_STORAGE_ENGINE) IF(WITH_PARTITION_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_PARTITION_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_PARTITION_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin") ENDIF(WITH_PARTITION_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE) - ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE) + ADD_DEFINITIONS(-DWITH_FEDERATED_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin") ENDIF(WITH_FEDERATED_STORAGE_ENGINE) @@ -81,15 +95,15 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY) IF(__NT__) - ADD_DEFINITIONS(-D __NT__) + ADD_DEFINITIONS(-D__NT__) ENDIF(__NT__) IF(CYBOZU) - ADD_DEFINITIONS(-D CYBOZU) + ADD_DEFINITIONS(-DCYBOZU) ENDIF(CYBOZU) # in some places we use DBUG_OFF -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D DBUG_OFF") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D DBUG_OFF") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF") IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996") @@ -132,7 +146,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") -ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE") +ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE") IF(EMBED_MANIFESTS) # Search for the Manifest tool. CMake will first search it's defaults @@ -179,7 +193,7 @@ ADD_SUBDIRECTORY(extra) ADD_SUBDIRECTORY(storage/heap) ADD_SUBDIRECTORY(storage/myisam) ADD_SUBDIRECTORY(storage/myisammrg) -ADD_SUBDIRECTORY(client) + IF(WITH_ARCHIVE_STORAGE_ENGINE) ADD_SUBDIRECTORY(storage/archive) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) @@ -198,11 +212,16 @@ ENDIF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE) ADD_SUBDIRECTORY(storage/innobase) ENDIF(WITH_INNOBASE_STORAGE_ENGINE) -ADD_SUBDIRECTORY(sql) -ADD_SUBDIRECTORY(server-tools/instance-manager) -ADD_SUBDIRECTORY(libmysql) -ADD_SUBDIRECTORY(tests) - -# disable libmysqld until it's fixed, so we can use Cmake 2.2 and 2.4 -#ADD_SUBDIRECTORY(libmysqld) -#ADD_SUBDIRECTORY(libmysqld/examples) +# CMAKE will not allow custom VS7+ configurations. mysqld and libmysqld +# cannot be built at the same time as they require different configurations +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) + ADD_SUBDIRECTORY(libmysqld) + ADD_SUBDIRECTORY(libmysqld/examples) +ELSE(EMBEDDED_ONLY) + ADD_SUBDIRECTORY(client) + ADD_SUBDIRECTORY(sql) + ADD_SUBDIRECTORY(server-tools/instance-manager) + ADD_SUBDIRECTORY(libmysql) + ADD_SUBDIRECTORY(tests) +ENDIF(EMBEDDED_ONLY) diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 1d415488037..a803ff8372f 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -42,7 +42,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); void mysql_detach_stmt_list(LIST **stmt_list, const char *func_name); -MYSQL * +MYSQL * STDCALL cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag); diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 8a855ebdbf5..dd42bafcfe0 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -18,7 +18,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # Need to set USE_TLS, since __declspec(thread) approach to thread local # storage does not work properly in DLLs. -ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_SERVER -DEMBEDDED_LIBRARY) +ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_SERVER) # The old Windows build method used renamed (.cc -> .cpp) source files, fails # in #include in lib_sql.cc. So disable that using the USING_CMAKE define. @@ -38,47 +38,51 @@ SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc PROPERTIES GENERATED 1) ADD_LIBRARY(mysqldemb emb_qcache.cc libmysqld.c lib_sql.cc - ../client/get_password.c ../libmysql/errmsg.c - ../libmysql/libmysql.c ../sql/password.c ../sql-common/client.c - ../sql-common/my_time.c ../sql-common/my_user.c - ../sql-common/pack.c ../sql/derror.cc ../sql/event_scheduler.cc - ../sql/event_timed.cc ../sql/events.cc ../sql/discover.cc - ../sql/field_conv.cc ../sql/field.cc ../sql/filesort.cc - ../sql/gstream.cc ${mysql_se_ha_src} - ../sql/handler.cc ../sql/hash_filo.cc - ../sql/hostname.cc ../sql/init.cc ../sql/item_buff.cc - ../sql/item_cmpfunc.cc ../sql/item.cc ../sql/item_create.cc - ../sql/item_func.cc ../sql/item_geofunc.cc ../sql/item_row.cc - ../sql/item_strfunc.cc ../sql/item_subselect.cc ../sql/item_sum.cc - ../sql/item_timefunc.cc ../sql/item_uniq.cc ../sql/item_xmlfunc.cc - ../sql/key.cc ../sql/lock.cc ../sql/log.cc ../sql/log_event.cc - ../sql/mf_iocache.cc ../sql/my_decimal.cc ../sql/net_serv.cc - ../sql/opt_range.cc ../sql/opt_sum.cc ../sql/parse_file.cc - ../sql/procedure.cc ../sql/protocol.cc ../sql/records.cc - ../sql/repl_failsafe.cc ../sql/rpl_filter.cc ../sql/set_var.cc - ../sql/spatial.cc ../sql/sp_cache.cc ../sql/sp.cc - ../sql/sp_head.cc ../sql/sp_pcontext.cc ../sql/sp_rcontext.cc - ../sql/sql_acl.cc ../sql/sql_analyse.cc ../sql/sql_base.cc - ../sql/sql_cache.cc ../sql/sql_class.cc ../sql/sql_crypt.cc - ../sql/sql_cursor.cc ../sql/sql_db.cc ../sql/sql_delete.cc - ../sql/sql_derived.cc ../sql/sql_do.cc ../sql/sql_error.cc - ../sql/sql_handler.cc ../sql/sql_help.cc ../sql/sql_insert.cc - ../sql/sql_lex.cc ../sql/sql_list.cc ../sql/sql_load.cc - ../sql/sql_manager.cc ../sql/sql_map.cc ../sql/sql_parse.cc - ../sql/sql_partition.cc ../sql/sql_plugin.cc ../sql/sql_prepare.cc - ../sql/sql_rename.cc ../sql/sql_repl.cc ../sql/sql_select.cc - ../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc - ../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc - ../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc - ../sql/sql_update.cc ../sql/sql_view.cc - ../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc - ../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc - ../sql/partition_info.cc ../sql/sql_locale.cc - ../sql/sql_connect.cc ../sql/scheduler.cc - ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c - ../vio/viosslfactories.c - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc - ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h) + ../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c + ../sql-common/client.c ../sql-common/my_time.c + ../sql-common/my_user.c ../sql-common/pack.c + ../sql/password.c ../sql/discover.cc ../sql/derror.cc + ../sql/event_scheduler.cc ../sql/events.cc + ../sql/event_data_objects.cc ../sql/event_queue.cc + ../sql/event_db_repository.cc ../sql/field.cc ../sql/field_conv.cc + ../sql/filesort.cc ../sql/gstream.cc ../sql/ha_partition.cc + ../sql/handler.cc ../sql/hash_filo.cc ../sql/hostname.cc + ../sql/init.cc ../sql/item_buff.cc ../sql/item_cmpfunc.cc + ../sql/item.cc ../sql/item_create.cc ../sql/item_func.cc + ../sql/item_geofunc.cc ../sql/item_row.cc ../sql/item_strfunc.cc + ../sql/item_subselect.cc ../sql/item_sum.cc ../sql/item_timefunc.cc + ../sql/item_xmlfunc.cc ../sql/key.cc ../sql/lock.cc ../sql/log.cc + ../sql/log_event.cc ../sql/mf_iocache.cc ../sql/my_decimal.cc + ../sql/net_serv.cc ../sql/opt_range.cc ../sql/opt_sum.cc + ../sql/parse_file.cc ../sql/procedure.cc ../sql/protocol.cc + ../sql/records.cc ../sql/repl_failsafe.cc ../sql/rpl_filter.cc + ../sql/rpl_record.cc + ../sql/rpl_injector.cc ../sql/set_var.cc ../sql/spatial.cc + ../sql/sp_cache.cc ../sql/sp.cc ../sql/sp_head.cc + ../sql/sp_pcontext.cc ../sql/sp_rcontext.cc ../sql/sql_acl.cc + ../sql/sql_analyse.cc ../sql/sql_base.cc ../sql/sql_cache.cc + ../sql/sql_class.cc ../sql/sql_crypt.cc ../sql/sql_cursor.cc + ../sql/sql_db.cc ../sql/sql_delete.cc ../sql/sql_derived.cc + ../sql/sql_do.cc ../sql/sql_error.cc ../sql/sql_handler.cc + ../sql/sql_help.cc ../sql/sql_insert.cc ../sql/sql_lex.cc + ../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc + ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc + ../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc + ../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc + ../sql/sql_select.cc ../sql/sql_servers.cc ../sql/sql_builtin.cc + ../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc + ../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc + ../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc + ../sql/sql_update.cc ../sql/sql_view.cc + ../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc + ../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc + ../sql/partition_info.cc ../sql/sql_locale.cc ../sql/sql_connect.cc + ../sql/scheduler.cc + ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c + ../vio/viosslfactories.c + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h) +ADD_DEPENDENCIES(mysqldemb GenError) # Seems we cannot make a library without at least one source file. So use a # dummy empty file @@ -86,14 +90,20 @@ FILE(WRITE cmake_dummy.c " ") ADD_LIBRARY(mysqlserver cmake_dummy.c) TARGET_LINK_LIBRARIES(mysqlserver wsock32) -ADD_DEPENDENCIES(mysqlserver dbug mysys strings zlib mysqldemb regex myisam myisammrg - heap yassl taocrypt) +ADD_DEPENDENCIES(mysqlserver mysqldemb heap myisam myisammrg dbug mysys zlib strings mysqldemb regex + yassl taocrypt vio) IF(WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEPENDENCIES(mysqlserver archive) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE) ADD_DEPENDENCIES(mysqlserver example) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) +IF(WITH_BLACKHOLE_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqlserver blackhole) +ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) +IF(WITH_CSV_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(mysqlserver csv) +ENDIF(WITH_CSV_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE) ADD_DEPENDENCIES(mysqlserver federated) ENDIF(WITH_FEDERATED_STORAGE_ENGINE) @@ -104,3 +114,9 @@ ENDIF(WITH_INNOBASE_STORAGE_ENGINE) ADD_LIBRARY(libmysqld MODULE cmake_dummy.c libmysqld.def) TARGET_LINK_LIBRARIES(libmysqld wsock32) ADD_DEPENDENCIES(libmysqld mysqlserver) +IF(WITH_ARCHIVE_STORAGE_ENGINE) + ADD_DEPENDENCIES(libmysqld archive) +ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) +IF(WITH_BLACKHOLE_STORAGE_ENGINE) + TARGET_LINK_LIBRARIES(libmysqld blackhole) +ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index b33b4740c93..59fa390399d 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -15,12 +15,24 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include + ${CMAKE_SOURCE_DIR}/libmysqld/release + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include) # Currently does not work with DBUG, there are missing symbols reported. ADD_DEFINITIONS(-DDBUG_OFF) +ADD_DEFINITIONS(-DUSE_TLS) ADD_EXECUTABLE(test_libmysqld ../../client/completion_hash.cc ../../client/mysql.cc ../../client/readline.cc ../../client/sql_string.cc) -TARGET_LINK_LIBRARIES(test_libmysqld yassl taocrypt zlib wsock32) +TARGET_LINK_LIBRARIES(test_libmysqld mysys yassl taocrypt zlib dbug regex strings wsock32) ADD_DEPENDENCIES(test_libmysqld libmysqld) + +ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.c) +TARGET_LINK_LIBRARIES(mysqltest_embedded mysys yassl taocrypt zlib dbug regex strings wsock32) +ADD_DEPENDENCIES(mysqltest_embedded libmysqld) + +ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c) +TARGET_LINK_LIBRARIES(mysql_client_test_embedded dbug mysys yassl taocrypt zlib strings wsock32) +ADD_DEPENDENCIES(mysql_client_test_embedded libmysqld) diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index 6f7800ee207..21e61da15a7 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -41,7 +41,9 @@ EXPORTS mysql_commit mysql_data_seek mysql_debug + mysql_disable_rpl_parse mysql_dump_debug_info + mysql_enable_rpl_parse mysql_eof mysql_errno mysql_error @@ -55,6 +57,7 @@ EXPORTS mysql_field_seek mysql_field_tell mysql_free_result + mysql_get_character_set_info mysql_get_client_info mysql_get_host_info mysql_get_proto_info @@ -84,6 +87,8 @@ EXPORTS mysql_rollback mysql_row_seek mysql_row_tell + mysql_rpl_parse_enabled + mysql_rpl_probe mysql_select_db mysql_send_query mysql_shutdown @@ -109,6 +114,7 @@ EXPORTS get_tty_password sql_protocol_typelib mysql_get_server_version + mysql_set_character_set mysql_sqlstate charsets_dir disabled_my_option @@ -133,6 +139,8 @@ EXPORTS my_read llstr mysql_get_parameters + mysql_thread_init + mysql_thread_end mysql_stmt_bind_param mysql_stmt_bind_result mysql_stmt_execute diff --git a/sql-common/client.c b/sql-common/client.c index 50da5298591..42d3be17798 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -50,7 +50,7 @@ #define MYSQL_CLIENT #endif -#define CLI_MYSQL_REAL_CONNECT cli_mysql_real_connect +#define CLI_MYSQL_REAL_CONNECT STDCALL cli_mysql_real_connect #undef net_flush my_bool net_flush(NET *net); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1fa08a1d862..4d4eadd0ed9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1883,9 +1883,11 @@ static void init_signals(void) static void start_signal_handler(void) { +#ifndef EMBEDDED_LIBRARY // Save vm id of this process if (!opt_bootstrap) create_pid_file(); +#endif /* EMBEDDED_LIBRARY */ } diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 77432ce518e..87224b8eea0 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -172,6 +172,7 @@ void mysql_client_binlog_statement(THD* thd) not used at all: the rli_fake instance is used only for error reporting. */ +#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) if (IF_DBUG(int err= ) ev->apply_event(thd->rli_fake)) { DBUG_PRINT("info", ("apply_event() returned: %d", err)); @@ -182,6 +183,7 @@ void mysql_client_binlog_statement(THD* thd) my_error(ER_UNKNOWN_ERROR, MYF(0), "Error executing BINLOG statement"); goto end; } +#endif delete ev; ev= 0; diff --git a/storage/federated/CMakeLists.txt b/storage/federated/CMakeLists.txt index 1f1f4dcd517..359a8784877 100644 --- a/storage/federated/CMakeLists.txt +++ b/storage/federated/CMakeLists.txt @@ -15,6 +15,9 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex diff --git a/storage/heap/CMakeLists.txt b/storage/heap/CMakeLists.txt index 39953684b8f..f4732397cc4 100644 --- a/storage/heap/CMakeLists.txt +++ b/storage/heap/CMakeLists.txt @@ -15,6 +15,9 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/sql diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 873a73be0ec..d2b6162ba26 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -16,6 +16,9 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib include diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt index ad0efe4a4e4..ec7cde9a789 100644 --- a/storage/myisam/CMakeLists.txt +++ b/storage/myisam/CMakeLists.txt @@ -16,6 +16,10 @@ INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/sql diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 8b95cdb30fd..f35b6ae761b 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1437,8 +1437,10 @@ int ha_myisam::enable_indexes(uint mode) might have been set by the first repair. They can still be seen with SHOW WARNINGS then. */ +#ifndef EMBEDDED_LIBRARY if (! error) thd->clear_error(); +#endif /* EMBEDDED_LIBRARY */ } info(HA_STATUS_CONST); thd->proc_info=save_proc_info; diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt index 8c8c8bcf9fb..b35638ac91d 100644 --- a/storage/myisammrg/CMakeLists.txt +++ b/storage/myisammrg/CMakeLists.txt @@ -15,6 +15,9 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/sql diff --git a/win/configure.js b/win/configure.js index 7225fff119b..06c2fe56a51 100644 --- a/win/configure.js +++ b/win/configure.js @@ -47,6 +47,7 @@ try case "__NT__": case "CYBOZU": case "EMBED_MANIFESTS": + case "EMBEDDED_ONLY": configfile.WriteLine("SET (" + args.Item(i) + " TRUE)"); break; case "MYSQL_SERVER_SUFFIX": From 651a8e7f73429fb50024543e3ee263b666808301 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Jun 2007 23:57:53 +0200 Subject: [PATCH 147/156] binlog.result, binlog.test: Post-merge fix: replace xid=* with XID to isolate from number of transactions mysql-test/r/binlog.result: Post-merge fix: replace xid=* with XID to isolate from number of transactions mysql-test/t/binlog.test: Post-merge fix: replace xid=* with XID to isolate from number of transactions --- mysql-test/r/binlog.result | 4 ++-- mysql-test/t/binlog.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result index 4ed6c50c7f6..6807da16e66 100644 --- a/mysql-test/r/binlog.result +++ b/mysql-test/r/binlog.result @@ -17,7 +17,7 @@ master-bin.000001 # Query 1 # use `test`; insert t1 values (5) master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert t2 values (5) -master-bin.000001 # Xid 1 # COMMIT /* xid=13 */ +master-bin.000001 # Xid 1 # COMMIT /* XID */ drop table t1,t2; reset master; create table t1 (n int) engine=innodb; @@ -128,7 +128,7 @@ master-bin.000001 # Query 1 # use `test`; insert into t1 values(4 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(3 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(2 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(1 + 4) -master-bin.000001 # Xid 1 # COMMIT /* xid=20 */ +master-bin.000001 # Xid 1 # COMMIT /* XID */ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002' from 98; Log_name Pos Event_type Server_id End_log_pos Info diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test index 2a7df23a2f5..accfa6a577f 100644 --- a/mysql-test/t/binlog.test +++ b/mysql-test/t/binlog.test @@ -21,8 +21,8 @@ begin; insert t2 values (5); commit; # first COMMIT must be Query_log_event, second - Xid_log_event ---replace_result "xid=22" "xid=13" --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events from 98; drop table t1,t2; @@ -43,8 +43,8 @@ while ($1) --enable_query_log commit; drop table t1; ---replace_result "xid=33" "xid=20" --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events in 'master-bin.000001' from 98; --replace_column 2 # 5 # show binlog events in 'master-bin.000002' from 98; From e2380b98afafc67021bfa0db0171c320b02c25e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 Jun 2007 11:16:02 +0200 Subject: [PATCH 148/156] Bug #28949 - handler binlog's must be shutdoem before logger.cleanup_base --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 672ae570c5b..f8a215a130e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1143,13 +1143,14 @@ void clean_up(bool print_message) if (cleanup_done++) return; /* purecov: inspected */ - logger.cleanup_base(); - /* make sure that handlers finish up what they have that is dependent on the binlog */ ha_binlog_end(current_thd); + + logger.cleanup_base(); + injector::free_instance(); mysql_bin_log.cleanup(); From fbfa18daf0266131f64edbf088493bca933780c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 09:56:33 +0500 Subject: [PATCH 149/156] Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock The log tables are by nature PERFORMANCE_SCHEMA tables, which should not be affected by SET GLOBAL READ_ONLY or FLUSH TABLES WITH READ LOCK. The implementation of FLUSH TABLES WITH READ LOCK already ignored log tables. Now with this patch, the implementation of LOCK TABLE also ignore a global read lock for log tables, which was the missing symmetry. mysql-test/r/flush.result: Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - test result. mysql-test/t/flush.test: Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - test case. sql/lock.cc: Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - logger.is_privileged_thread() used. sql/log.h: Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - LOGGER::is_privileged_thread() introduced that returns TRUE if a given thread is either a general_log or a slow_log or a privileged thread. sql/sql_base.cc: Fix for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - pass MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK to the mysql_lock_tables() in case of call from a logger in order not to honor the GLOBAL READ LOCK and to avoid possible deadlocks. --- mysql-test/r/flush.result | 16 ++++++++++++++++ mysql-test/t/flush.test | 26 +++++++++++++++++++++++++- sql/lock.cc | 4 +--- sql/log.h | 6 ++++++ sql/sql_base.cc | 8 ++++++-- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index 7eb7fd16edb..dcbffd6f7c8 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -55,3 +55,19 @@ flush tables with read lock; insert into t2 values(1); unlock tables; drop table t1, t2; +End of 5.0 tests +set @old_general_log= @@general_log; +set @old_read_only= @@read_only; +set global general_log= on; +flush tables with read lock; +flush logs; +unlock tables; +set global read_only=1; +flush logs; +unlock tables; +flush tables with read lock; +flush logs; +unlock tables; +set global general_log= @old_general_log; +set global read_only= @old_read_only; +End of 5.1 tests diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 3a4f2f2f5f2..d58d038c3ea 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -133,4 +133,28 @@ disconnect con3; connection default; drop table t1, t2; -# End of 5.0 tests +--echo End of 5.0 tests + +# +# Bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock +# +set @old_general_log= @@general_log; +set @old_read_only= @@read_only; +set global general_log= on; + +flush tables with read lock; +flush logs; +unlock tables; + +set global read_only=1; +flush logs; +unlock tables; + +flush tables with read lock; +flush logs; +unlock tables; + +set global general_log= @old_general_log; +set global read_only= @old_read_only; + +--echo End of 5.1 tests diff --git a/sql/lock.cc b/sql/lock.cc index 6f1dd0669ee..9785bc4ac00 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -707,9 +707,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, if (!table_ptr[i]-> file-> check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type, table_ptr[i], count, i, &system_count, - (thd == logger.get_general_log_thd()) || - (thd == logger.get_slow_log_thd()) || - (thd == logger.get_privileged_thread()))) + logger.is_privileged_thread(thd))) DBUG_RETURN(0); } diff --git a/sql/log.h b/sql/log.h index 25bcbd6c62d..d92e0117bcc 100644 --- a/sql/log.h +++ b/sql/log.h @@ -600,6 +600,12 @@ public: else return NULL; } + bool is_privileged_thread(THD *thd) + { + return thd == get_general_log_thd() || + thd == get_slow_log_thd() || + thd == get_privileged_thread(); + } }; enum enum_binlog_format { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b798106082a..2450429fb69 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4018,6 +4018,11 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen) { DBUG_ASSERT(thd->lock == 0); // You must lock everything at once TABLE **start,**ptr; + uint lock_flag= MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN; + + /* Don't honor the GLOBAL READ LOCK if called from a logger */ + if (logger.is_privileged_thread(thd)) + lock_flag|= MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK; if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count))) DBUG_RETURN(-1); @@ -4046,8 +4051,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen) } if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), - MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN, - need_reopen))) + lock_flag, need_reopen))) { if (thd->lex->requires_prelocking()) { From 0cdd3e2fc4138fdb8ce7f52b33cc7b82efce190f Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 10:07:58 +0500 Subject: [PATCH 150/156] after-merge fix. --- mysql-test/r/rpl_log_pos.result | 85 ++++++++++++++++++++++++++------- mysql-test/r/rpl_ssl.result | 1 + mysql-test/t/rpl_log_pos.test | 2 +- 3 files changed, 71 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 28ddbaf33a0..7543814578a 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -7,27 +7,80 @@ start slave; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 106 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 106 # # master-bin.000001 Yes Yes 0 0 106 # None 0 No # No -stop slave; -change master to master_log_pos=75; -start slave; stop slave; change master to master_log_pos=75; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 75 # # master-bin.000001 No No 0 0 75 # None 0 No # No +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 75 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +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 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 75 +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 # +Master_SSL_Verify_Server_Cert No start slave; -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 75 # # master-bin.000001 No Yes 0 0 75 # None 0 No # No stop slave; -change master to master_log_pos=178; -start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 # Yes 0 0 178 # None 0 No # No +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 75 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +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 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 75 +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 # +Master_SSL_Verify_Server_Cert No show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 106 @@ -35,7 +88,6 @@ create table if not exists t1 (n int); drop table if exists t1; create table t1 (n int); insert into t1 values (1),(2),(3); -stop slave; change master to master_log_pos=106; start slave; select * from t1 ORDER BY n; @@ -44,3 +96,4 @@ n 2 3 drop table t1; +End of 5.0 tests diff --git a/mysql-test/r/rpl_ssl.result b/mysql-test/r/rpl_ssl.result index 908f0020188..64d52d63f78 100644 --- a/mysql-test/r/rpl_ssl.result +++ b/mysql-test/r/rpl_ssl.result @@ -96,3 +96,4 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No drop user replssl@localhost; drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test index 575dd0a112e..2c6c1d9868d 100644 --- a/mysql-test/t/rpl_log_pos.test +++ b/mysql-test/t/rpl_log_pos.test @@ -34,7 +34,7 @@ stop slave; --source include/wait_for_slave_to_stop.inc --replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 11 # 23 # 33 # +--replace_column 1 # 8 # 9 # 23 # 33 # query_vertical show slave status; connection master; From f2c7b62a3e0cf3f9aed3f6f68eec322e592d7a92 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 19:27:20 +0200 Subject: [PATCH 151/156] BUG#27640 - correct test and result file --- mysql-test/r/ndb_restore.result | 7 +++++++ mysql-test/t/ndb_restore.test | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index bc31798cee7..6799854c5b6 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -129,6 +129,13 @@ create table t7 engine=myisam as select * from t7_c; create table t8 engine=myisam as select * from t8_c; create table t9 engine=myisam as select * from t9_c; create table t10 engine=myisam as select * from t10_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id + +DROP TABLE test.backup_info; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; show tables; Tables_in_test diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 5b839a0d3aa..eba2df926d3 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -165,10 +165,10 @@ create table t9 engine=myisam as select * from t9_c; create table t10 engine=myisam as select * from t10_c; ---exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT +--source include/ndb_backup.inc drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT show tables; From 95497dcc282e91bdf8d84c2752fe24f27eea0e7d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 19:47:20 +0200 Subject: [PATCH 152/156] Bug #28989 hpux11 ps_row warnings - do not print 701 dictionary busy error sql/ha_ndbcluster.cc: save the ndb error such that it can be traced sql/ha_ndbcluster.h: save the ndb error such that it can be traced sql/ha_ndbcluster_binlog.cc: use the traced ndb error to determine if it is an error that should be printed --- sql/ha_ndbcluster.cc | 63 +++++++++++++++++++++++++++++++------ sql/ha_ndbcluster.h | 2 ++ sql/ha_ndbcluster_binlog.cc | 51 +++++++++++++++++++++++------- 3 files changed, 94 insertions(+), 22 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 70f3d9e1a91..edbb22c612e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -121,14 +121,14 @@ static uint ndbcluster_alter_table_flags(uint flags) #define ERR_RETURN(err) \ { \ const NdbError& tmp= err; \ - ERR_PRINT(tmp); \ + set_ndb_err(current_thd, tmp); \ DBUG_RETURN(ndb_to_mysql_error(&tmp)); \ } #define ERR_BREAK(err, code) \ { \ const NdbError& tmp= err; \ - ERR_PRINT(tmp); \ + set_ndb_err(current_thd, tmp); \ code= ndb_to_mysql_error(&tmp); \ break; \ } @@ -516,13 +516,51 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd) DBUG_VOID_RETURN; } +/* + Sets the latest ndb error code on the thd_ndb object such that it + can be retrieved later to know which ndb error caused the handler + error. +*/ +static void set_ndb_err(THD *thd, const NdbError &err) +{ + DBUG_ENTER("set_ndb_err"); + ERR_PRINT(err); + + Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (thd_ndb == NULL) + DBUG_VOID_RETURN; +#ifdef NOT_YET + /* + Check if error code is overwritten, in this case the original + failure cause will be lost. E.g. if 4350 error is given. So + push a warning so that it can be detected which is the root + error cause. + */ + if (thd_ndb->m_query_id == thd->query_id && + thd_ndb->m_error_code != 0 && + thd_ndb->m_error_code != err.code) + { + char buf[FN_REFLEN]; + ndb_error_string(thd_ndb->m_error_code, buf, sizeof(buf)); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_GET_ERRMSG, ER(ER_GET_ERRMSG), + thd_ndb->m_error_code, buf, "NDB"); + } +#endif + thd_ndb->m_query_id= thd->query_id; + thd_ndb->m_error_code= err.code; + DBUG_VOID_RETURN; +} + int ha_ndbcluster::ndb_err(NdbTransaction *trans) { + THD *thd= current_thd; int res; NdbError err= trans->getNdbError(); DBUG_ENTER("ndb_err"); - ERR_PRINT(err); + set_ndb_err(thd, err); + switch (err.classification) { case NdbError::SchemaError: { @@ -533,7 +571,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) 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); + close_cached_tables(thd, 0, &table_list); break; } default: @@ -4576,7 +4614,7 @@ static int ndbcluster_commit(handlerton *hton, THD *thd, bool all) { const NdbError err= trans->getNdbError(); const NdbOperation *error_op= trans->getNdbErrorOperation(); - ERR_PRINT(err); + set_ndb_err(thd, err); res= ndb_to_mysql_error(&err); if (res != -1) ndbcluster_print_error(res, error_op); @@ -4627,7 +4665,7 @@ static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all) { const NdbError err= trans->getNdbError(); const NdbOperation *error_op= trans->getNdbErrorOperation(); - ERR_PRINT(err); + set_ndb_err(thd, err); res= ndb_to_mysql_error(&err); if (res != -1) ndbcluster_print_error(res, error_op); @@ -5209,7 +5247,7 @@ int ha_ndbcluster::create(const char *name, if (dict->createTable(tab) != 0) { const NdbError err= dict->getNdbError(); - ERR_PRINT(err); + set_ndb_err(thd, err); my_errno= ndb_to_mysql_error(&err); DBUG_RETURN(my_errno); } @@ -5223,7 +5261,7 @@ int ha_ndbcluster::create(const char *name, { /* purecov: begin deadcode */ const NdbError err= dict->getNdbError(); - ERR_PRINT(err); + set_ndb_err(thd, err); my_errno= ndb_to_mysql_error(&err); DBUG_RETURN(my_errno); /* purecov: end */ @@ -5395,6 +5433,7 @@ int ha_ndbcluster::create_handler_files(const char *file, new_tab.setFrm(pack_data, pack_length); if (dict->alterTableGlobal(*tab, new_tab)) { + set_ndb_err(current_thd, dict->getNdbError()); error= ndb_to_mysql_error(&dict->getNdbError()); } my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); @@ -5870,6 +5909,7 @@ retry_temporary_error1: default: break; } + set_ndb_err(thd, dict->getNdbError()); res= ndb_to_mysql_error(&dict->getNdbError()); DBUG_PRINT("info", ("error(1) %u", res)); } @@ -5909,6 +5949,7 @@ retry_temporary_error1: } } } + set_ndb_err(thd, dict->getNdbError()); res= ndb_to_mysql_error(&dict->getNdbError()); DBUG_PRINT("info", ("error(2) %u", res)); break; @@ -6268,6 +6309,7 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) Ndb *ndb= get_ndb(); if (ndb->setDatabaseName(m_dbname)) { + set_ndb_err(current_thd, ndb->getNdbError()); res= ndb_to_mysql_error(&ndb->getNdbError()); break; } @@ -6628,7 +6670,7 @@ int ndbcluster_drop_database_impl(const char *path) const NdbError err= dict->getNdbError(); if (err.code != 709 && err.code != 723) { - ERR_PRINT(err); + set_ndb_err(thd, err); ret= ndb_to_mysql_error(&err); } } @@ -8348,6 +8390,7 @@ retry: my_sleep(retry_sleep); continue; } + set_ndb_err(current_thd, error); break; } while(1); DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr, @@ -9988,7 +10031,7 @@ int ndbcluster_alter_tablespace(handlerton *hton, ndberror: err= dict->getNdbError(); ndberror2: - ERR_PRINT(err); + set_ndb_err(thd, err); ndb_to_mysql_error(&err); my_error(error, MYF(0), errmsg); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index df621ff1938..591745076a1 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -207,6 +207,8 @@ class Thd_ndb NdbTransaction *stmt; bool m_error; bool m_slow_path; + int m_error_code; + uint32 m_query_id; /* query id whn m_error_code was set */ uint32 options; uint32 trans_options; List changed_tables; diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 5751bd0057a..a075c56ec53 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -81,6 +81,20 @@ static Ndb *injector_ndb= 0; static Ndb *schema_ndb= 0; static int ndbcluster_binlog_inited= 0; +/* + Flag "ndbcluster_binlog_terminating" set when shutting down mysqld. + Server main loop should call handlerton function: + + ndbcluster_hton->binlog_func == + ndbcluster_binlog_func(...,BFN_BINLOG_END,...) == + ndbcluster_binlog_end + + at shutdown, which sets the flag. And then server needs to wait for it + to complete. Otherwise binlog will not be complete. + + ndbcluster_hton->panic == ndbcluster_end() will not return until + ndb binlog is completed +*/ static int ndbcluster_binlog_terminating= 0; /* @@ -222,7 +236,7 @@ static void dbug_print_table(const char *info, TABLE *table) - creating the ndb_apply_status table */ static void run_query(THD *thd, char *buf, char *end, - my_bool print_error, my_bool disable_binlog) + const int *no_print_error, my_bool disable_binlog) { ulong save_query_length= thd->query_length; char *save_query= thd->query; @@ -242,11 +256,18 @@ static void run_query(THD *thd, char *buf, char *end, DBUG_PRINT("query", ("%s", thd->query)); mysql_parse(thd, thd->query, thd->query_length, &found_semicolon); - if (print_error && thd->query_error) + if (no_print_error && thd->query_error) { - sql_print_error("NDB: %s: error %s %d %d %d", - buf, thd->net.last_error, thd->net.last_errno, - thd->net.report_error, thd->query_error); + int i; + Thd_ndb *thd_ndb= get_thd_ndb(thd); + for (i= 0; no_print_error[i]; i++) + if (thd_ndb->m_error == no_print_error[i]) + break; + if (!no_print_error[i]) + sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d", + buf, thd->net.last_error, thd->net.last_errno, + thd_ndb->m_error, + thd->net.report_error, thd->query_error); } thd->options= save_thd_options; @@ -488,7 +509,7 @@ static int ndbcluster_reset_logs(THD *thd) char buf[1024]; char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE); - run_query(thd, buf, end, FALSE, TRUE); + run_query(thd, buf, end, NULL, TRUE); DBUG_RETURN(0); } @@ -513,7 +534,7 @@ ndbcluster_binlog_index_purge_file(THD *thd, const char *file) NDB_REP_DB "." NDB_REP_TABLE " WHERE File='"), file), "'"); - run_query(thd, buf, end, FALSE, TRUE); + run_query(thd, buf, end, NULL, TRUE); DBUG_RETURN(0); } @@ -630,7 +651,7 @@ static void ndbcluster_reset_slave(THD *thd) DBUG_ENTER("ndbcluster_reset_slave"); char buf[1024]; char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_APPLY_TABLE); - run_query(thd, buf, end, FALSE, TRUE); + run_query(thd, buf, end, NULL, TRUE); DBUG_VOID_RETURN; } @@ -755,7 +776,8 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd) " end_pos BIGINT UNSIGNED NOT NULL, " " PRIMARY KEY USING HASH (server_id) ) ENGINE=NDB"); - run_query(thd, buf, end, TRUE, TRUE); + const int no_print_error[2]= {701, 0}; // do not print error 701 + run_query(thd, buf, end, no_print_error, TRUE); DBUG_RETURN(0); } @@ -811,7 +833,8 @@ static int ndbcluster_create_schema_table(THD *thd) " type INT UNSIGNED NOT NULL," " PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB"); - run_query(thd, buf, end, TRUE, TRUE); + const int no_print_error[2]= {701, 0}; // do not print error 701 + run_query(thd, buf, end, no_print_error, TRUE); DBUG_RETURN(0); } @@ -1920,9 +1943,10 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, /* Drop the database locally if it only contains ndb tables */ if (! ndbcluster_check_if_local_tables_in_db(thd, schema->db)) { + const int no_print_error[1]= {0}; run_query(thd, schema->query, schema->query + schema->query_length, - TRUE, /* print error */ + no_print_error, /* print error */ TRUE); /* don't binlog the query */ /* binlog dropping database after any table operations */ post_epoch_log_list->push_back(schema, mem_root); @@ -1942,12 +1966,15 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, case SOT_CREATE_DB: /* fall through */ case SOT_ALTER_DB: + { + const int no_print_error[1]= {0}; run_query(thd, schema->query, schema->query + schema->query_length, - TRUE, /* print error */ + no_print_error, /* print error */ TRUE); /* don't binlog the query */ log_query= 1; break; + } case SOT_TABLESPACE: case SOT_LOGFILE_GROUP: log_query= 1; From c982517540027ac3cb7218b42a2af802587d64e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Jun 2007 22:04:01 +0200 Subject: [PATCH 153/156] correct test and result --- mysql-test/r/ndb_restore.result | 2 +- mysql-test/t/ndb_restore.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index 6799854c5b6..9faac2df0a4 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -283,4 +283,4 @@ Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length I X X X X X X X X X X 10001 X X X X X X X drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; -520093696,1 +520093696, diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index eba2df926d3..266a0c7fbc1 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -251,6 +251,6 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; # Test BUG#10287 # ---exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696 +--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,/" # End of 5.0 tests (4.1 test intermixed to save test time) From b2f86cd570e3d155b598d1c2f6527505c9d80dad Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Jun 2007 22:22:31 +0500 Subject: [PATCH 154/156] Sdditional fix-up for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock FLUSH LOGS should ignore SET GLOBAL READ_ONLY. sql/lock.cc: Sdditional fix-up for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - ignore SET GLOBAL READ_ONLY if MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY is set. sql/mysql_priv.h: Sdditional fix-up for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY added. sql/sql_base.cc: Sdditional fix-up for bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock - ignore SET GLOBAL READ_ONLY as well if called form a logger. --- sql/lock.cc | 11 ++++++----- sql/mysql_priv.h | 1 + sql/sql_base.cc | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 9785bc4ac00..9c5b5b9d88a 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -92,6 +92,7 @@ static void print_lock_error(int error, const char *); count The number of tables to lock. flags Options: MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock + MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables. MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN Instead of reopening altered or dropped tables by itself, @@ -150,11 +151,11 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, } } - if ( write_lock_used - && opt_readonly - && ! (thd->security_ctx->master_access & SUPER_ACL) - && ! thd->slave_thread - ) + if (!(flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY) && + write_lock_used && + opt_readonly && + !(thd->security_ctx->master_access & SUPER_ACL) && + !thd->slave_thread) { /* Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock. diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index bd786ed81ca..1f19458a332 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1765,6 +1765,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, #define MYSQL_LOCK_IGNORE_FLUSH 0x0002 #define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004 #define MYSQL_OPEN_TEMPORARY_ONLY 0x0008 +#define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0010 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2450429fb69..9b336e8a703 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4020,9 +4020,10 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen) TABLE **start,**ptr; uint lock_flag= MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN; - /* Don't honor the GLOBAL READ LOCK if called from a logger */ + /* Ignore GLOBAL READ LOCK and GLOBAL READ_ONLY if called from a logger */ if (logger.is_privileged_thread(thd)) - lock_flag|= MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK; + lock_flag|= (MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK | + MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY); if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count))) DBUG_RETURN(-1); From 5941479ee3f540a7dc6ce6ecb9246ee8edf5eb88 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Jun 2007 17:55:12 -0400 Subject: [PATCH 155/156] Bug #28921 Queries containing UDF functions are cached Fixed runtime to no longer allow the caching of queries with UDF calls. mysql-test/r/udf.result: Added a test that turns on caching and checks that querys calling UDFs don't get cached. mysql-test/t/udf.test: Added a test that turns on caching and checks that querys calling UDFs don't get cached. sql/sql_yacc.yy: Fixed code to set safe_to_cache_query=0 regardless if the function call is a UDF or SP. Where it was placed previously -- at the very end of the else testing for UDFs -- it only executed the statement if the function call was a stored procedure call. --- mysql-test/r/udf.result | 23 +++++++++++++++++++++++ mysql-test/t/udf.test | 24 ++++++++++++++++++++++++ sql/sql_yacc.yy | 4 ++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 7c52e7da496..2e9cf217ed6 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -273,4 +273,27 @@ drop function f3; drop function metaphon; drop function myfunc_double; drop function myfunc_int; +CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; +create table t1 (a char); +set GLOBAL query_cache_size=1355776; +reset query cache; +select metaphon('MySQL') from t1; +metaphon('MySQL') +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +select metaphon('MySQL') from t1; +metaphon('MySQL') +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +drop table t1; +drop function metaphon; +set GLOBAL query_cache_size=default; End of 5.0 tests. diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 0b582dc61b6..75af1f4be4b 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -288,4 +288,28 @@ drop function metaphon; drop function myfunc_double; drop function myfunc_int; +# +# Bug #28921: Queries containing UDF functions are cached +# + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +create table t1 (a char); + +set GLOBAL query_cache_size=1355776; +reset query cache; + +select metaphon('MySQL') from t1; +show status like "Qcache_hits"; +show status like "Qcache_queries_in_cache"; + +select metaphon('MySQL') from t1; +show status like "Qcache_hits"; +show status like "Qcache_queries_in_cache"; + +drop table t1; +drop function metaphon; +set GLOBAL query_cache_size=default; + + --echo End of 5.0 tests. diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 924a8bd6d7d..22ec7b31248 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5150,8 +5150,8 @@ simple_expr: $$= new Item_func_sp(Lex->current_context(), name, *$4); else $$= new Item_func_sp(Lex->current_context(), name); - lex->safe_to_cache_query=0; - } + } + lex->safe_to_cache_query=0; } | UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')' { From 54c531607df9b14f206fa8a44f39f2764f55ac82 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Jun 2007 21:11:10 -0400 Subject: [PATCH 156/156] Bug #28921 Queries containg UDF functions are cached Additional edits to the 5.0 ChangeSet|1.2519 that are necessary for the fix to work with the new code structure in 5.1. sql/item_create.cc: Added line to prevent a query that contains a UDF from being cached. In 5.0 this was handled in sql_yacc.cc but now the the individual Create_func builders will be responsible for clearing the flag. --- sql/item_create.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/item_create.cc b/sql/item_create.cc index 309bd78b04e..b3522ba352c 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -2437,6 +2437,7 @@ Create_udf_func::create(THD *thd, udf_func *udf, List *item_list) my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type"); } } + thd->lex->safe_to_cache_query= 0; return func; } #endif