From: Maitrayi Sabaratnam Date: January 14 2013 12:28pm Subject: bzr push into mysql-5.1-telco-7.1 branch (maitrayi.sabaratnam:4701 to 4702) List-Archive: http://lists.mysql.com/commits/145603 Message-Id: <20130114122834.22541.67278.4702@asator03-z7.no.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4702 Maitrayi Sabaratnam 2013-01-14 [merge] Merge 7.0->7.1 modified: mysql-test/suite/ndb_binlog/r/ndb_binlog_basic.result mysql-test/suite/ndb_binlog/t/ndb_binlog_basic.test storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp 4701 Frazer Clement 2013-01-10 [merge] Merge 7.0->7.1 modified: mysql-test/suite/ndb/r/ndb_mgm.result mysql-test/suite/ndb/t/ndb_mgm.test storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp === modified file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_basic.result' --- a/mysql-test/suite/ndb_binlog/r/ndb_binlog_basic.result 2008-02-25 13:50:20 +0000 +++ b/mysql-test/suite/ndb_binlog/r/ndb_binlog_basic.result 2013-01-11 16:21:06 +0000 @@ -49,3 +49,17 @@ select inserts,updates,deletes from mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 0; inserts updates deletes 2 0 0 +create table t1 (c1 int not null primary key, c2 blob default null) engine=ndbcluster default charset=latin1; +insert into t1 values (1, null), (2, null), (3, null), (4, null); +insert into t1 select c1+4,c2 from t1; +insert into t1 select c1+8,c2 from t1; +insert into t1 select c1+16,c2 from t1; +insert into t1 select c1+32,c2 from t1; +insert into t1 select c1+64,c2 from t1; +insert into t1 select c1+128,c2 from t1; +insert into t1 select c1+256,c2 from t1; +insert into t1 select c1+512,c2 from t1; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +drop table t1; === modified file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_basic.test' --- a/mysql-test/suite/ndb_binlog/t/ndb_binlog_basic.test 2008-02-25 13:50:20 +0000 +++ b/mysql-test/suite/ndb_binlog/t/ndb_binlog_basic.test 2013-01-11 16:21:06 +0000 @@ -79,3 +79,43 @@ drop table t1; drop database mysqltest; select inserts,updates,deletes from mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 0; + +# +# Check optimize table does not send any event to binlog +# + +create table t1 (c1 int not null primary key, c2 blob default null) engine=ndbcluster default charset=latin1; +insert into t1 values (1, null), (2, null), (3, null), (4, null); +insert into t1 select c1+4,c2 from t1; +insert into t1 select c1+8,c2 from t1; +insert into t1 select c1+16,c2 from t1; +insert into t1 select c1+32,c2 from t1; +insert into t1 select c1+64,c2 from t1; +insert into t1 select c1+128,c2 from t1; +insert into t1 select c1+256,c2 from t1; +insert into t1 select c1+512,c2 from t1; + +# wait for last gcp to complete, ensuring that we have +# the expected data in the binlog +save_master_pos; + +let $before = `select count(*) + from mysql.ndb_binlog_index + where epoch > @max_epoch and + (inserts > 0 or updates > 0 or deletes > 0)`; + +optimize table t1; +save_master_pos; + +# Ensure that optimize have not sent any event to binlog +let $optimize_diff = `select count(*) <> $before + from mysql.ndb_binlog_index + where epoch > @max_epoch and + (inserts > 0 or updates > 0 or deletes > 0)`; + +if ($optimize_diff) +{ + die Optimize table should not send any events to binlog; +} + +drop table t1; === modified file 'storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp' --- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2011-12-01 10:45:07 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2013-01-11 16:21:06 +0000 @@ -834,6 +834,11 @@ struct Operationrec { unsigned int m_load_diskpage_on_commit : 1; unsigned int m_wait_log_buffer : 1; unsigned int m_gci_written : 1; + /* If the op has no logical effect, it should not be logged + * or sent as an event. Example op is OPTIMIZE table, + * which uses ZUPDATE to move varpart values physically. + */ + unsigned int m_physical_only_op : 1; }; union { OpBitFields op_struct; === modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp' --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp 2012-12-03 09:04:21 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp 2013-01-14 10:02:18 +0000 @@ -626,6 +626,7 @@ void Dbtup::execTUPKEYREQ(Signal* signal regOperPtr->m_copy_tuple_location.setNull(); regOperPtr->tupVersion= ZNIL; + regOperPtr->op_struct.m_physical_only_op = 0; sig1= tupKeyReq->savePointId; sig2= tupKeyReq->primaryReplica; === modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp' --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp 2011-06-30 15:59:25 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp 2013-01-11 16:21:06 +0000 @@ -1743,6 +1743,11 @@ int Dbtup::updateAttributes(KeyReqStruct AttributeHeader::OPTIMIZE_OPTIONS_MASK; inBufIndex += 1 + sz; req_struct->in_buf_index = inBufIndex; + if (inBufIndex == 1 + sz && inBufIndex == inBufLen) + { + // No table attributes are updated. Optimize op only. + regOperPtr->op_struct.m_physical_only_op = 1; + } } else if (attributeId == AttributeHeader::ROW_AUTHOR) { === modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp' --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp 2011-12-23 17:00:22 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp 2013-01-14 10:02:18 +0000 @@ -1637,6 +1637,27 @@ bool Dbtup::readTriggerInfo(TupTriggerDa req_struct->check_offset[DD]= regTabPtr->get_check_offset(DD); req_struct->attr_descr= &tableDescriptor[descr_start]; + if ((regOperPtr->op_struct.m_physical_only_op == 1) && + (refToMain(trigPtr->m_receiverRef) == SUMA || + refToMain(trigPtr->m_receiverRef) == BACKUP)) + { + /* Operations that have no logical effect need not be backed up + * or sent as an event. Eg. OPTIMIZE TABLE is performed as a + * ZUPDATE operation on table records, moving the varpart + * column-values between pages, to be storage-effective. + */ + Uint32 changed_attribs = 0; + for (Uint32 i = 0; i < regTabPtr->m_no_of_attributes; i++) { + jam(); + if (req_struct->changeMask.get(i)) { + jam(); + changed_attribs++; + } + } + ndbrequire(changed_attribs == 0); + return false; + } + //-------------------------------------------------------------------- // Read Primary Key Values //-------------------------------------------------------------------- No bundle (reason: useless for push emails).