From 03b590d3b7a28631b88454a1310c146c4f887f0e Mon Sep 17 00:00:00 2001 From: "gni/root@dev3-127.(none)" <> Date: Wed, 29 Nov 2006 16:45:18 +0800 Subject: BUG#21033 The error log of mysqld shows useless information, and hides the real error. --- ndb/src/ndbapi/Ndb.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 9d1c78a5972..26e8b7168ce 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -980,6 +980,8 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op) Uint64 tValue; NdbRecAttr* tRecAttrResult; + NdbError savedError; + CHECK_STATUS_MACRO_ZERO; BaseString currentDb(getDatabaseName()); @@ -1074,7 +1076,12 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op) error_handler: theError.code = tConnection->theError.code; + + savedError = theError; + this->closeTransaction(tConnection); + theError = savedError; + error_return: // Restore current name space setDatabaseName(currentDb.c_str()); -- cgit v1.2.1 From 19e0ae8a7ff8d15f1fa475b327d77d03634a601a Mon Sep 17 00:00:00 2001 From: "gni/root@dev3-221.dev.cn.tlan" <> Date: Wed, 6 Dec 2006 12:01:19 +0800 Subject: BUG#21715 mgm client command STATUS returns "not connected" for non-data nodes --- ndb/src/mgmclient/CommandInterpreter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 65d5b038707..ea5dc218898 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1627,6 +1627,18 @@ 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){ + 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; -- cgit v1.2.1 From 5cd40ad30b8d340bed6b80e1b05dac7e452f8132 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 31 Jan 2007 22:38:06 +0100 Subject: Bug #25522 Update with IN syntax Clustertable + Trigger leads to mysqld segfault: in start_stmt, only change query_state if starting a new transactions, in read_multi_range_next, change query state when end is reached --- mysql-test/r/ndb_read_multi_range.result | 17 +++++++++++++++++ mysql-test/t/ndb_read_multi_range.test | 29 +++++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 8 ++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_read_multi_range.result b/mysql-test/r/ndb_read_multi_range.result index e2a076ef99f..d279485e48e 100644 --- a/mysql-test/r/ndb_read_multi_range.result +++ b/mysql-test/r/ndb_read_multi_range.result @@ -381,3 +381,20 @@ SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); id tag doc type sakila 1 Some text goes here text DROP TABLE t1; +CREATE TABLE t1 ( +var1 int(2) NOT NULL, +var2 int(2) NOT NULL, +PRIMARY KEY (var1) +) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; +CREATE TABLE t2 ( +var1 int(2) NOT NULL, +var2 int(2) NOT NULL, +PRIMARY KEY (var1) +) ENGINE=MyISAM DEFAULT CHARSET=ascii CHECKSUM=1; +CREATE TRIGGER testtrigger +AFTER UPDATE ON t1 FOR EACH ROW BEGIN +REPLACE INTO t2 SELECT * FROM t1 WHERE t1.var1 = NEW.var1;END| +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); +DROP TRIGGER testtrigger; +DROP TABLE t1, t2; diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test index 99edab5d23c..cfbf0561d1e 100644 --- a/mysql-test/t/ndb_read_multi_range.test +++ b/mysql-test/t/ndb_read_multi_range.test @@ -253,3 +253,32 @@ SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); DROP TABLE t1; + +#bug#25522 +CREATE TABLE t1 ( + var1 int(2) NOT NULL, + var2 int(2) NOT NULL, + PRIMARY KEY (var1) + ) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; + + +CREATE TABLE t2 ( + var1 int(2) NOT NULL, + var2 int(2) NOT NULL, + PRIMARY KEY (var1) + ) ENGINE=MyISAM DEFAULT CHARSET=ascii CHECKSUM=1; + + +DELIMITER |; +CREATE TRIGGER testtrigger + AFTER UPDATE ON t1 FOR EACH ROW BEGIN + REPLACE INTO t2 SELECT * FROM t1 WHERE t1.var1 = NEW.var1;END| +DELIMITER ;| + +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); + +UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); + +DROP TRIGGER testtrigger; + +DROP TABLE t1, t2; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 34a3a001b21..029cebb34b3 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3877,10 +3877,10 @@ int ha_ndbcluster::start_stmt(THD *thd, thr_lock_type lock_type) ERR_RETURN(ndb->getNdbError()); no_uncommitted_rows_reset(thd); thd_ndb->stmt= trans; + thd_ndb->query_state&= NDB_QUERY_NORMAL; + m_active_trans= trans; trans_register_ha(thd, FALSE, &ndbcluster_hton); } - thd_ndb->query_state&= NDB_QUERY_NORMAL; - m_active_trans= trans; // Start of statement m_retrieve_all_fields= FALSE; @@ -6512,7 +6512,11 @@ close_scan: } if (multi_range_curr == multi_range_end) + { + Thd_ndb *thd_ndb= get_thd_ndb(current_thd); + thd_ndb->query_state&= NDB_QUERY_NORMAL; DBUG_RETURN(HA_ERR_END_OF_FILE); + } /** * Read remaining ranges -- cgit v1.2.1 From c16251ad7c87cdab668ef48f8b57e271180b9da8 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Thu, 1 Feb 2007 09:48:45 +0100 Subject: Bug #25522 Update with IN syntax Clustertable + Trigger leads to mysqld segfault: moved back assignment --- sql/ha_ndbcluster.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 029cebb34b3..080abf2ce54 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3878,10 +3878,9 @@ int ha_ndbcluster::start_stmt(THD *thd, thr_lock_type lock_type) no_uncommitted_rows_reset(thd); thd_ndb->stmt= trans; thd_ndb->query_state&= NDB_QUERY_NORMAL; - m_active_trans= trans; trans_register_ha(thd, FALSE, &ndbcluster_hton); } - + m_active_trans= trans; // Start of statement m_retrieve_all_fields= FALSE; m_retrieve_primary_key= FALSE; -- cgit v1.2.1 From 0446aa9cbd0513fdb1e67601ccbac8b935fc7183 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Tue, 6 Feb 2007 23:06:58 +0100 Subject: Fix for bug#25821 Excessive partition pruning for multi-range index scan in NDB API: don't set distribution key if multi_range --- mysql-test/r/ndb_read_multi_range.result | 7 +++++++ mysql-test/t/ndb_read_multi_range.test | 9 +++++++++ ndb/include/ndbapi/NdbIndexScanOperation.hpp | 6 ++++-- ndb/include/ndbapi/NdbScanOperation.hpp | 5 ++++- ndb/src/ndbapi/NdbScanOperation.cpp | 5 +++-- sql/ha_ndbcluster.cc | 2 +- sql/ha_ndbcluster.h | 1 + 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ndb_read_multi_range.result b/mysql-test/r/ndb_read_multi_range.result index d279485e48e..64a6749bed1 100644 --- a/mysql-test/r/ndb_read_multi_range.result +++ b/mysql-test/r/ndb_read_multi_range.result @@ -398,3 +398,10 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3); UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); DROP TRIGGER testtrigger; DROP TABLE t1, t2; +create table t2 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; +insert into t2 values (1,1), (10,10); +select * from t2 use index (ab) where a in(1,10) order by a; +a b +1 1 +10 10 +drop table t2; diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test index cfbf0561d1e..e1f1dfc1150 100644 --- a/mysql-test/t/ndb_read_multi_range.test +++ b/mysql-test/t/ndb_read_multi_range.test @@ -282,3 +282,12 @@ UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); DROP TRIGGER testtrigger; DROP TABLE t1, t2; + +#bug#25821 +create table t2 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; + +insert into t2 values (1,1), (10,10); + +select * from t2 use index (ab) where a in(1,10) order by a; + +drop table t2; diff --git a/ndb/include/ndbapi/NdbIndexScanOperation.hpp b/ndb/include/ndbapi/NdbIndexScanOperation.hpp index 7ef66f9a30b..ae7e2579dd8 100644 --- a/ndb/include/ndbapi/NdbIndexScanOperation.hpp +++ b/ndb/include/ndbapi/NdbIndexScanOperation.hpp @@ -64,12 +64,14 @@ public: bool order_by, bool order_desc = false, bool read_range_no = false, - bool keyinfo = false) { + bool keyinfo = false, + bool multi_range = false) { Uint32 scan_flags = (SF_OrderBy & -(Int32)order_by) | (SF_Descending & -(Int32)order_desc) | (SF_ReadRangeNo & -(Int32)read_range_no) | - (SF_KeyInfo & -(Int32)keyinfo); + (SF_KeyInfo & -(Int32)keyinfo) | + (SF_MultiRange & -(Int32)multi_range); return readTuples(lock_mode, scan_flags, parallel, batch); } diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index beaf9402b77..1e03eee5a39 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -45,6 +45,7 @@ public: SF_OrderBy = (1 << 24), // index scan in order SF_Descending = (2 << 24), // index scan in descending order SF_ReadRangeNo = (4 << 24), // enable @ref get_range_no + SF_MultiRange = (8 << 24), // scan is part of multi-range scan SF_KeyInfo = 1 // request KeyInfo to be sent back }; @@ -71,7 +72,8 @@ public: */ #ifdef ndb_readtuples_impossible_overload int readTuples(LockMode lock_mode = LM_Read, - Uint32 batch = 0, Uint32 parallel = 0, bool keyinfo = false); + Uint32 batch = 0, Uint32 parallel = 0, + bool keyinfo = false, bool multi_range); #endif inline int readTuples(int parallell){ @@ -263,6 +265,7 @@ protected: bool m_descending; Uint32 m_read_range_no; NdbRecAttr *m_curr_row; // Pointer to last returned row + bool m_multi_range; // Mark if operation is part of multi-range scan }; inline diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index a0322f09256..bccf391acef 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1189,7 +1189,7 @@ NdbIndexScanOperation::setBound(const NdbColumnImpl* tAttrInfo, * so it's safe to use [tIndexAttrId] * (instead of looping as is NdbOperation::equal_impl) */ - if(type == BoundEQ && tDistrKey) + if(type == BoundEQ && tDistrKey && !m_multi_range) { theNoOfTupKeyLeft--; return handle_distribution_key((Uint64*)aValue, sizeInWords); @@ -1250,7 +1250,8 @@ NdbIndexScanOperation::readTuples(LockMode lm, const bool order_by = scan_flags & SF_OrderBy; const bool order_desc = scan_flags & SF_Descending; const bool read_range_no = scan_flags & SF_ReadRangeNo; - + m_multi_range = scan_flags & SF_MultiRange; + int res = NdbScanOperation::readTuples(lm, scan_flags, parallel, batch); if(!res && read_range_no) { diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 080abf2ce54..f53e1673a16 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6348,7 +6348,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, } else if ((scanOp= m_active_trans->getNdbIndexScanOperation(idx, tab)) &&!scanOp->readTuples(lm, 0, parallelism, sorted, - FALSE, TRUE, need_pk) + FALSE, TRUE, need_pk, TRUE) &&!generate_scan_filter(m_cond_stack, scanOp) &&!define_read_attrs(end_of_buffer-reclength, scanOp)) { diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 5d66a7920f9..eeca67d506a 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -661,6 +661,7 @@ private: const NdbOperation *first, const NdbOperation *last, uint errcode); + bool key_fields_not_in_write_set(THD *thd, const KEY* key_info); int peek_indexed_rows(const byte *record, bool check_pk); int unique_index_read(const byte *key, uint key_len, byte *buf); -- cgit v1.2.1 From 259d3dce267c9a765ff8509267dafef83aa08979 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 7 Feb 2007 09:19:33 +0100 Subject: bug#25821 Excessive partition pruning for multi-range index scan in NDB API: post-review fix, added default value --- ndb/include/ndbapi/NdbScanOperation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index 1e03eee5a39..d1af4732525 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -73,7 +73,7 @@ public: #ifdef ndb_readtuples_impossible_overload int readTuples(LockMode lock_mode = LM_Read, Uint32 batch = 0, Uint32 parallel = 0, - bool keyinfo = false, bool multi_range); + bool keyinfo = false, bool multi_range = false); #endif inline int readTuples(int parallell){ -- cgit v1.2.1 From 2d0bd82a06ef744fb4a1b4bd7b974279437f6632 Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Wed, 7 Feb 2007 11:36:34 +0100 Subject: NdbScanOperation.hpp, NdbScanOperation.cpp, ha_ndbcluster.cc: bug#25821 Excessive partition pruning for multi-range index scan in NDB API: added multi_range error checking in end_of_bound ha_ndbcluster.h: Removed stray mthod declaration --- ndb/include/ndbapi/NdbScanOperation.hpp | 3 ++- ndb/src/ndbapi/NdbScanOperation.cpp | 10 ++++++++-- sql/ha_ndbcluster.cc | 6 ++---- sql/ha_ndbcluster.h | 1 - 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index d1af4732525..88f96c88031 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -38,7 +38,8 @@ class NdbScanOperation : public NdbOperation { public: /** * Scan flags. OR-ed together and passed as second argument to - * readTuples. + * readTuples. Note that SF_MultiRange has to be set if several + * ranges (bounds) are to be passed. */ enum ScanFlag { SF_TupScan = (1 << 16), // scan TUP diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index bccf391acef..e30e9cb66e9 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1718,6 +1718,12 @@ NdbIndexScanOperation::reset_bounds(bool forceSend){ int NdbIndexScanOperation::end_of_bound(Uint32 no) { + DBUG_ENTER("end_of_bound"); + DBUG_PRINT("info", ("Range number %u", no)); + /* Check that SF_MultiRange has been specified if more + than one range is specified */ + if (no > 0 && !m_multi_range) + DBUG_RETURN(-1); if(no < (1 << 13)) // Only 12-bits no of ranges { Uint32 bound_head = * m_first_bound_word; @@ -1726,9 +1732,9 @@ NdbIndexScanOperation::end_of_bound(Uint32 no) m_first_bound_word = theKEYINFOptr + theTotalNrOfKeyWordInSignal;; m_this_bound_start = theTupKeyLen; - return 0; + DBUG_RETURN(0); } - return -1; + DBUG_RETURN(-1); } int diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f53e1673a16..514d4b83a04 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1996,8 +1996,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, DBUG_PRINT("error", ("key %d unknown flag %d", j, p.key->flag)); DBUG_ASSERT(FALSE); // Stop setting bounds but continue with what we have - op->end_of_bound(range_no); - DBUG_RETURN(0); + DBUG_RETURN(op->end_of_bound(range_no)); } } } @@ -2044,8 +2043,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, tot_len+= part_store_len; } - op->end_of_bound(range_no); - DBUG_RETURN(0); + DBUG_RETURN(op->end_of_bound(range_no)); } /* diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index eeca67d506a..5d66a7920f9 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -661,7 +661,6 @@ private: const NdbOperation *first, const NdbOperation *last, uint errcode); - bool key_fields_not_in_write_set(THD *thd, const KEY* key_info); int peek_indexed_rows(const byte *record, bool check_pk); int unique_index_read(const byte *key, uint key_len, byte *buf); -- cgit v1.2.1