From: Date: February 11 2009 4:17pm Subject: bzr commit into mysql-5.1-telco-6.4 branch (Martin.Skold:3252) Bug#32662 Bug#39268 Bug#40464 Bug#42232 Bug#42591 List-Archive: http://lists.mysql.com/commits/65920 X-Bug: 32662,39268,40464,42232,42591 Message-Id: <200902111517.n1BFHAh5011854@quadfish.liljeholmen.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/marty/MySQL/mysql-5.1-telco-6.4_new/ 3252 Martin Skold 2009-02-11 [merge] Merge modified: mysql-test/suite/rpl_ndb/r/rpl_ndb_auto_inc.result mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.test sql/ha_ndbcluster.cc storage/ndb/include/ndbapi/NdbScanOperation.hpp storage/ndb/src/ndbapi/Ndb.cpp storage/ndb/src/ndbapi/NdbScanOperation.cpp storage/ndb/src/ndbapi/ndberror.c per-file messages: storage/ndb/src/ndbapi/Ndb.cpp Bug #39268 No transaction hints used to update SYSTAB_0 for autoincrement and PK-less table: disabled bugfix in mysql-5.1-telco-6.4 since it caused crash. === modified file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_auto_inc.result' --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_auto_inc.result 2008-09-29 21:55:56 +0000 +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_auto_inc.result 2009-02-10 16:30:54 +0000 @@ -168,3 +168,31 @@ a 32 42 drop table t1; +set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; +set ndb_autoincrement_prefetch_sz = 32; +CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT KEY) ENGINE=ndb; +INSERT INTO t1 () VALUES (),(),(); +set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; +set ndb_autoincrement_prefetch_sz = 32; +select * from t1 order by id; +id +1 +2 +3 +INSERT INTO t1 () VALUES (),(),(); +select * from t1 order by id; +id +1 +2 +3 +4 +5 +6 +set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; +select * from t1 order by id; +id +1 +2 +3 +drop table t1; +set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; === modified file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.test' --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.test 2007-06-27 12:29:10 +0000 +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.test 2009-02-05 13:27:46 +0000 @@ -111,8 +111,26 @@ sync_slave_with_master; --echo select * from t1 ORDER BY a; connection master; - drop table t1; +# +# Bug #42232 Cluster to cluster replication is not setting auto_increment +# on slave cluster +# +set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; +set ndb_autoincrement_prefetch_sz = 32; +CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT KEY) ENGINE=ndb; +INSERT INTO t1 () VALUES (),(),(); +sync_slave_with_master; +set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; +set ndb_autoincrement_prefetch_sz = 32; +select * from t1 order by id; +INSERT INTO t1 () VALUES (),(),(); +select * from t1 order by id; +set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; +connection master; +select * from t1 order by id; +drop table t1; +set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; # End cleanup sync_slave_with_master; === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2009-01-31 09:15:34 +0000 +++ b/sql/ha_ndbcluster.cc 2009-02-11 15:16:57 +0000 @@ -2889,7 +2889,7 @@ int ha_ndbcluster::ordered_index_scan(co if (lm == NdbOperation::LM_Read) options.scan_flags|= NdbScanOperation::SF_KeyInfo; if (sorted) - options.scan_flags|= NdbScanOperation::SF_OrderBy; + options.scan_flags|= NdbScanOperation::SF_OrderByFull; if (descending) options.scan_flags|= NdbScanOperation::SF_Descending; const NdbRecord *key_rec= m_index[active_index].ndb_record_key; @@ -9621,7 +9621,9 @@ ndbcluster_cache_retrieval_allowed(THD * { /* Don't allow qc to be used if table has been previously modified in transaction */ - Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (!check_ndb_in_thd(thd)) + DBUG_RETURN(FALSE); + Thd_ndb *thd_ndb= get_thd_ndb(thd); if (!thd_ndb->changed_tables.is_empty()) { NDB_SHARE* share; @@ -10727,7 +10729,7 @@ ha_ndbcluster::read_multi_range_first(KE if (lm == NdbOperation::LM_Read) options.scan_flags|= NdbScanOperation::SF_KeyInfo; if (sorted) - options.scan_flags|= NdbScanOperation::SF_OrderBy; + options.scan_flags|= NdbScanOperation::SF_OrderByFull; options.parallel=parallelism; === modified file 'storage/ndb/include/ndbapi/NdbScanOperation.hpp' --- a/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2008-11-08 21:43:03 +0000 +++ b/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2009-02-11 15:16:57 +0000 @@ -53,6 +53,12 @@ public: each fragment, to get a single sorted result set. */ SF_OrderBy = (1 << 24), + /** + * Same as order by, except that it will automatically + * add all key columns into the read-mask + */ + SF_OrderByFull = (16 << 24), + /* Index scan in descending order, instead of default ascending. */ SF_Descending = (2 << 24), /* @@ -393,12 +399,8 @@ protected: int handleScanGetValuesOldApi(); int addInterpretedCode(); int handleScanOptions(const ScanOptions *options); - int generatePackedReadAIs(const NdbRecord *reseult_record, - bool needAllKeys, - bool& haveBlob); - int scanImpl(const unsigned char* result_mask, - const NdbScanOperation::ScanOptions *options, - bool needAllKeys= false); + int generatePackedReadAIs(const NdbRecord *reseult_record, bool& haveBlob); + int scanImpl(const NdbScanOperation::ScanOptions *options); int scanTableImpl(const NdbRecord *result_record, NdbOperation::LockMode lock_mode, const unsigned char *result_mask, === modified file 'storage/ndb/src/ndbapi/Ndb.cpp' --- a/storage/ndb/src/ndbapi/Ndb.cpp 2008-12-12 14:30:54 +0000 +++ b/storage/ndb/src/ndbapi/Ndb.cpp 2009-02-11 15:16:57 +0000 @@ -1537,7 +1537,20 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* if (initAutoIncrement() == -1) goto error_handler; +/* + Fix for + Bug #39268 No transaction hints used to update SYSTAB_0 for autoincrement and PK-less table + causes crash in 6.4 + */ +#if 0 + // Start transaction with table id as hint + tConnection = this->startTransaction(table, + (const char *) &aTableId, + sizeof(Uint32)); +#else tConnection = this->startTransaction(); +#endif + if (tConnection == NULL) goto error_handler; === modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp' --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-04 06:54:44 +0000 +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-11 15:16:57 +0000 @@ -322,7 +322,6 @@ NdbScanOperation::handleScanOptions(cons */ int NdbScanOperation::generatePackedReadAIs(const NdbRecord *result_record, - bool needAllKeys, bool& haveBlob) { Bitmask readMask; @@ -341,10 +340,7 @@ NdbScanOperation::generatePackedReadAIs( /* Skip column if result_mask says so and we don't need * to read it */ - if ((!BitmaskImpl::get(MAXNROFATTRIBUTESINWORDS, - m_read_mask, attrId)) - && - !(needAllKeys && col->flags & NdbRecord::IsKey)) + if (!BitmaskImpl::get(MAXNROFATTRIBUTESINWORDS, m_read_mask, attrId)) continue; /* Blob reads are handled with a getValue() in NdbBlob.cpp. */ @@ -403,18 +399,12 @@ NdbScanOperation::generatePackedReadAIs( * types share */ inline int -NdbScanOperation::scanImpl(const unsigned char *result_mask, - const NdbScanOperation::ScanOptions *options, - bool needAllKeys) +NdbScanOperation::scanImpl(const NdbScanOperation::ScanOptions *options) { bool haveBlob= false; - m_attribute_record->copyMask(m_read_mask, result_mask); - /* Add AttrInfos for packed read of cols in result_record */ - if (generatePackedReadAIs(m_attribute_record, - needAllKeys, - haveBlob) != 0) + if (generatePackedReadAIs(m_attribute_record, haveBlob) != 0) return -1; theInitialReadSize= theTotalCurrAI_Len - AttrInfo::SectionSizeInfoLength; @@ -511,6 +501,7 @@ NdbScanOperation::scanTableImpl(const Nd #endif m_attribute_record= result_record; + m_attribute_record->copyMask(m_read_mask, result_mask); /* Process scan definition info */ res= processTableScanDefs(lock_mode, scan_flags, parallel, batch); @@ -518,9 +509,8 @@ NdbScanOperation::scanTableImpl(const Nd return -1; theStatus= NdbOperation::UseNdbRecord; - /* Call generic scan code */ - return scanImpl(result_mask, options); + return scanImpl(options); } @@ -862,7 +852,10 @@ NdbIndexScanOperation::scanIndexImpl(con return -1; } - if (scan_flags & NdbScanOperation::SF_OrderBy) + result_record->copyMask(m_read_mask, result_mask); + + if (scan_flags & (NdbScanOperation::SF_OrderBy | + NdbScanOperation::SF_OrderByFull)) { /** * For ordering, we need all keys in the result row. @@ -870,19 +863,34 @@ NdbIndexScanOperation::scanIndexImpl(con * So for each key column, check that it is included in the result * NdbRecord. */ + Uint32 keymask[MAXNROFATTRIBUTESINWORDS]; + BitmaskImpl::clear(MAXNROFATTRIBUTESINWORDS, keymask); + for (i = 0; i < key_record->key_index_length; i++) { - const NdbRecord::Attr *key_col = - &key_record->columns[key_record->key_indexes[i]]; - if (key_col->attrId >= result_record->m_attrId_indexes_length || - result_record->m_attrId_indexes[key_col->attrId] < 0) + Uint32 attrId = key_record->columns[key_record->key_indexes[i]].attrId; + if (attrId >= result_record->m_attrId_indexes_length || + result_record->m_attrId_indexes[attrId] < 0) { setErrorCodeAbort(4292); return -1; } + + BitmaskImpl::set(MAXNROFATTRIBUTESINWORDS, keymask, attrId); } - } + if (scan_flags & NdbScanOperation::SF_OrderByFull) + { + BitmaskImpl::bitOR(MAXNROFATTRIBUTESINWORDS, m_read_mask, keymask); + } + else if (!BitmaskImpl::contains(MAXNROFATTRIBUTESINWORDS, + m_read_mask, keymask)) + { + setErrorCodeAbort(4341); + return -1; + } + } + if (!(key_record->flags & NdbRecord::RecIsIndex)) { setErrorCodeAbort(4283); @@ -911,9 +919,8 @@ NdbIndexScanOperation::scanIndexImpl(con theStatus= NdbOperation::UseNdbRecord; /* Call generic scan code */ - res= scanImpl(result_mask, - options, - (scan_flags & NdbScanOperation::SF_OrderBy)); // needAllKeys + res= scanImpl(options); + if (!res) { /* @@ -956,6 +963,12 @@ NdbScanOperation::readTuples(NdbScanOper m_savedParallelOldApi= parallel; m_savedBatchOldApi= batch; + /** + * Old API always auto-added all key-colums + */ + if (scan_flags & SF_OrderBy) + m_savedScanFlagsOldApi |= SF_OrderByFull; + return 0; } @@ -1012,11 +1025,10 @@ NdbScanOperation::processTableScanDefs(N tupScan = false; } - if (rangeScan && (scan_flags & SF_OrderBy)) + if (rangeScan && (scan_flags & (SF_OrderBy | SF_OrderByFull))) parallel = fragCount; /* Frag count of ordered index == * Frag count of base table */ - theParallelism = parallel; if(fix_receivers(parallel) == -1){ @@ -1806,7 +1818,7 @@ int NdbScanOperation::finaliseScanOldApi * don't */ const unsigned char * resultMask= - ((m_savedScanFlagsOldApi & SF_OrderBy) !=0) ? + ((m_savedScanFlagsOldApi & (SF_OrderBy | SF_OrderByFull)) !=0) ? m_accessTable->m_pkMask : emptyMask; @@ -2964,7 +2976,7 @@ NdbIndexScanOperation::processIndexScanD Uint32 parallel, Uint32 batch) { - const bool order_by = scan_flags & SF_OrderBy; + const bool order_by = scan_flags & (SF_OrderBy | SF_OrderByFull); const bool order_desc = scan_flags & SF_Descending; const bool read_range_no = scan_flags & SF_ReadRangeNo; m_multi_range = scan_flags & SF_MultiRange; @@ -3459,7 +3471,7 @@ NdbIndexScanOperation::end_of_bound(Uint * back then check that range numbers are strictly * increasing */ - if ((m_savedScanFlagsOldApi & SF_OrderBy) && + if ((m_savedScanFlagsOldApi & (SF_OrderBy | SF_OrderByFull)) && (m_savedScanFlagsOldApi & SF_ReadRangeNo)) { Uint32 expectedNum= 0; === modified file 'storage/ndb/src/ndbapi/ndberror.c' --- a/storage/ndb/src/ndbapi/ndberror.c 2009-01-13 09:07:17 +0000 +++ b/storage/ndb/src/ndbapi/ndberror.c 2009-02-11 15:16:57 +0000 @@ -380,7 +380,7 @@ ErrorBundle ErrorCodes[] = { { 708, DMEC, SE, "No more attribute metadata records (increase MaxNoOfAttributes)" }, { 709, HA_ERR_NO_SUCH_TABLE, SE, "No such table existed" }, { 710, DMEC, SE, "Internal: Get by table name not supported, use table id." }, - { 721, HA_ERR_TABLE_EXIST, OE, "Table or index with given name already exists" }, + { 721, HA_ERR_TABLE_EXIST, OE, "Schema object with given name already exists" }, { 723, HA_ERR_NO_SUCH_TABLE, SE, "No such table existed" }, { 736, DMEC, SE, "Unsupported array size" }, { 737, HA_WRONG_CREATE_OPTION, SE, "Attribute array size too big" }, @@ -696,6 +696,7 @@ ErrorBundle ErrorCodes[] = { { 4290, DMEC, AE, "Missing column specification in NdbDictionary::RecordSpecification" }, { 4291, DMEC, AE, "Duplicate column specification in NdbDictionary::RecordSpecification" }, { 4292, DMEC, AE, "NdbRecord for tuple access is not an index key NdbRecord" }, + { 4341, DMEC, AE, "Not all keys read when using option SF_OrderBy" }, { 4293, DMEC, AE, "Error returned from application scanIndex() callback" }, { 4294, DMEC, AE, "Scan filter is too large, discarded" }, { 4295, DMEC, AE, "Column is NULL in Get/SetValueSpec structure" },