List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:October 28 2011 1:46pm
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3576 to 3577)
View as plain text  
 3577 Ole John Aske	2011-10-28 [merge]
      merge telco-7.0 -> 7.0-spj-scan-scan

    added:
      storage/ndb/include/kernel/statedesc.hpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp
    modified:
      mysql-test/suite/ndb/r/ndbinfo.result
      mysql-test/suite/ndb/t/ndbinfo.test
      sql/ha_ndbcluster_connection.cc
      storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
      storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/tools/CMakeLists.txt
      storage/ndb/tools/Makefile.am
      storage/ndb/tools/ndbinfo_sql.cpp
 3576 Ole John Aske	2011-10-28 [merge]
      Merge telco-7.0 -> telco-7.0-spj-scan-scan

    modified:
      config/ac-macros/misc.m4
      sql/ha_ndb_index_stat.cc
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_binlog.h
      sql/ha_ndbcluster_connection.cc
      sql/ha_ndbinfo.cc
      storage/ndb/include/kernel/signaldata/DiGetNodes.hpp
      storage/ndb/include/util/OutputStream.hpp
      storage/ndb/src/common/debugger/EventLogger.cpp
      storage/ndb/src/common/debugger/SignalLoggerManager.cpp
      storage/ndb/src/common/logger/LogHandler.cpp
      storage/ndb/src/common/logger/Logger.cpp
      storage/ndb/src/common/portlib/NdbConfig.c
      storage/ndb/src/common/portlib/NdbDir.cpp
      storage/ndb/src/common/portlib/NdbThread.c
      storage/ndb/src/common/portlib/ndb_daemon.cc
      storage/ndb/src/common/transporter/TransporterRegistry.cpp
      storage/ndb/src/common/util/BaseString.cpp
      storage/ndb/src/common/util/ConfigValues.cpp
      storage/ndb/src/common/util/File.cpp
      storage/ndb/src/common/util/InputStream.cpp
      storage/ndb/src/common/util/NdbSqlUtil.cpp
      storage/ndb/src/common/util/OutputStream.cpp
      storage/ndb/src/common/util/Parser.cpp
      storage/ndb/src/common/util/Properties.cpp
      storage/ndb/src/common/util/ndb_init.cpp
      storage/ndb/src/common/util/ndbzio.c
      storage/ndb/src/common/util/socket_io.cpp
      storage/ndb/src/cw/cpcd/APIService.cpp
      storage/ndb/src/cw/cpcd/CPCD.cpp
      storage/ndb/src/cw/cpcd/Monitor.cpp
      storage/ndb/src/cw/cpcd/Process.cpp
      storage/ndb/src/kernel/blocks/backup/read.cpp
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
      storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp
      storage/ndb/src/kernel/blocks/dblqh/redoLogReader/reader.cpp
      storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
      storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp
      storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp
      storage/ndb/src/kernel/error/ErrorReporter.cpp
      storage/ndb/src/kernel/error/ndbd_exit_codes.c
      storage/ndb/src/kernel/vm/SimulatedBlock.cpp
      storage/ndb/src/mgmapi/mgmapi.cpp
      storage/ndb/src/mgmapi/ndb_logevent.cpp
      storage/ndb/src/mgmclient/CommandInterpreter.cpp
      storage/ndb/src/mgmsrv/Defragger.hpp
      storage/ndb/src/mgmsrv/InitConfigFileParser.cpp
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp
      storage/ndb/src/mgmsrv/Services.cpp
      storage/ndb/src/ndbapi/NdbBlob.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbOperationExec.cpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbTransaction.cpp
      storage/ndb/src/ndbapi/ndberror.c
      storage/ndb/test/include/NDBT_Table.hpp
      storage/ndb/test/include/NdbMgmd.hpp
      storage/ndb/test/ndbapi/ScanFunctions.hpp
      storage/ndb/test/ndbapi/testMgm.cpp
      storage/ndb/test/src/DbUtil.cpp
      storage/ndb/test/src/HugoQueries.cpp
      storage/ndb/test/src/HugoQueryBuilder.cpp
      storage/ndb/test/src/NDBT_Test.cpp
      storage/ndb/test/src/NdbBackup.cpp
      storage/ndb/test/src/NdbRestarter.cpp
      storage/ndb/test/src/getarg.c
      storage/ndb/test/tools/cpcc.cpp
      storage/ndb/tools/ndb_dump_frm_data.cpp
      storage/ndb/tools/restore/consumer_restore.cpp
      storage/ndb/tools/waiter.cpp
=== modified file 'mysql-test/suite/ndb/r/ndbinfo.result'
--- a/mysql-test/suite/ndb/r/ndbinfo.result	2011-10-13 10:17:51 +0000
+++ b/mysql-test/suite/ndb/r/ndbinfo.result	2011-10-28 09:56:57 +0000
@@ -318,6 +318,147 @@ node_id
 1
 2
 
+desc threadblocks;
+Field	Type	Null	Key	Default	Extra
+node_id	int(10) unsigned	YES		NULL	
+thr_no	int(10) unsigned	YES		NULL	
+block_name	varchar(512)	YES		NULL	
+block_instance	int(10) unsigned	YES		NULL	
+select distinct block_name from threadblocks order by 1;
+block_name
+BACKUP
+CMVMI
+DBACC
+DBDICT
+DBDIH
+DBINFO
+DBLQH
+DBSPJ
+DBTC
+DBTUP
+DBTUX
+DBUTIL
+LGMAN
+NDBCNTR
+NDBFS
+PGMAN
+QMGR
+RESTORE
+SUMA
+THRMAN
+TRIX
+TSMAN
+desc threadstat;
+Field	Type	Null	Key	Default	Extra
+node_id	int(10) unsigned	YES		NULL	
+thr_no	int(10) unsigned	YES		NULL	
+thr_nm	varchar(512)	YES		NULL	
+c_loop	bigint(20) unsigned	YES		NULL	
+c_exec	bigint(20) unsigned	YES		NULL	
+c_wait	bigint(20) unsigned	YES		NULL	
+c_l_sent_prioa	bigint(20) unsigned	YES		NULL	
+c_l_sent_priob	bigint(20) unsigned	YES		NULL	
+c_r_sent_prioa	bigint(20) unsigned	YES		NULL	
+c_r_sent_priob	bigint(20) unsigned	YES		NULL	
+os_tid	bigint(20) unsigned	YES		NULL	
+os_now	bigint(20) unsigned	YES		NULL	
+os_ru_utime	bigint(20) unsigned	YES		NULL	
+os_ru_stime	bigint(20) unsigned	YES		NULL	
+os_ru_minflt	bigint(20) unsigned	YES		NULL	
+os_ru_majflt	bigint(20) unsigned	YES		NULL	
+os_ru_nvcsw	bigint(20) unsigned	YES		NULL	
+os_ru_nivcsw	bigint(20) unsigned	YES		NULL	
+select count(*) > 0 block_name from threadstat;
+block_name
+1
+
+desc cluster_transactions;
+Field	Type	Null	Key	Default	Extra
+node_id	int(10) unsigned	YES		NULL	
+block_instance	int(10) unsigned	YES		NULL	
+transid	bigint(22) unsigned	YES		NULL	
+state	varchar(256)	YES		NULL	
+count_operations	int(10) unsigned	YES		NULL	
+outstanding_operations	int(10) unsigned	YES		NULL	
+inactive_seconds	int(10) unsigned	YES		NULL	
+client_node_id	bigint(21) unsigned	YES		NULL	
+client_block_ref	bigint(21) unsigned	YES		NULL	
+desc server_transactions;
+Field	Type	Null	Key	Default	Extra
+mysql_connection_id	bigint(21) unsigned	NO		0	
+node_id	int(10) unsigned	YES		NULL	
+block_instance	int(10) unsigned	YES		NULL	
+transid	bigint(22) unsigned	YES		NULL	
+state	varchar(256)	YES		NULL	
+count_operations	int(10) unsigned	YES		NULL	
+outstanding_operations	int(10) unsigned	YES		NULL	
+inactive_seconds	int(10) unsigned	YES		NULL	
+client_node_id	bigint(21) unsigned	YES		NULL	
+client_block_ref	bigint(21) unsigned	YES		NULL	
+desc cluster_operations;
+Field	Type	Null	Key	Default	Extra
+node_id	int(10) unsigned	YES		NULL	
+block_instance	int(10) unsigned	YES		NULL	
+transid	bigint(22) unsigned	YES		NULL	
+operation_type	varchar(9)	YES		NULL	
+state	varchar(256)	YES		NULL	
+tableid	int(10) unsigned	YES		NULL	
+fragmentid	int(10) unsigned	YES		NULL	
+client_node_id	bigint(21) unsigned	YES		NULL	
+client_block_ref	bigint(21) unsigned	YES		NULL	
+tc_node_id	bigint(21) unsigned	YES		NULL	
+tc_block_no	bigint(21) unsigned	YES		NULL	
+tc_block_instance	bigint(21) unsigned	YES		NULL	
+desc server_operations;
+Field	Type	Null	Key	Default	Extra
+mysql_connection_id	bigint(21) unsigned	NO		0	
+node_id	int(10) unsigned	YES		NULL	
+block_instance	int(10) unsigned	YES		NULL	
+transid	bigint(22) unsigned	YES		NULL	
+operation_type	varchar(9)	YES		NULL	
+state	varchar(256)	YES		NULL	
+tableid	int(10) unsigned	YES		NULL	
+fragmentid	int(10) unsigned	YES		NULL	
+client_node_id	bigint(21) unsigned	YES		NULL	
+client_block_ref	bigint(21) unsigned	YES		NULL	
+tc_node_id	bigint(21) unsigned	YES		NULL	
+tc_block_no	bigint(21) unsigned	YES		NULL	
+tc_block_instance	bigint(21) unsigned	YES		NULL	
+
+create table t1 (a int primary key) engine = ndb;
+begin;
+insert into t1 values (1);
+select state, count_operations, outstanding_operations,
+IF(client_node_id <= 255, "<client_node_id>", "<incorrect node id>") 
+  client_node_id
+from server_transactions;
+state	count_operations	outstanding_operations	client_node_id
+Started	1	0	<client_node_id>
+select node_id, operation_type, state,
+IF(tc_node_id <= 48, "<tc_node_id>", "<incorrect nodeid>") tc_node_id,
+IF(client_node_id <= 255, "<client_node_id>", "<incorrect node id>") 
+  client_node_id
+from server_operations
+order by 1;
+node_id	operation_type	state	tc_node_id	client_node_id
+1	INSERT	Prepared	<tc_node_id>	<client_node_id>
+2	INSERT	Prepared	<tc_node_id>	<client_node_id>
+
+select st.state, st.count_operations, st.outstanding_operations,
+       so.node_id, so.state, so.operation_type
+from server_transactions st,
+     server_operations so
+where st.transid = so.transid
+  and so.tc_node_id = st.node_id
+  and so.tc_block_instance = st.block_instance
+  and so.client_node_id = st.client_node_id
+  and so.client_block_ref = st.client_block_ref;
+state	count_operations	outstanding_operations	node_id	state	operation_type
+Started	1	0	1	Prepared	INSERT
+Started	1	0	2	Prepared	INSERT
+rollback;
+drop table t1;
+
 set @@global.ndbinfo_offline=TRUE;
 select @@ndbinfo_offline;
 @@ndbinfo_offline

=== modified file 'mysql-test/suite/ndb/t/ndbinfo.test'
--- a/mysql-test/suite/ndb/t/ndbinfo.test	2011-05-23 13:45:57 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo.test	2011-10-28 09:56:57 +0000
@@ -201,6 +201,44 @@ set @@ndbinfo_offline=1;
 let $q1 = SELECT DISTINCT(node_id) FROM ndbinfo.counters ORDER BY node_id;
 eval $q1;
 
+# new views
+desc threadblocks;
+select distinct block_name from threadblocks order by 1;
+desc threadstat;
+select count(*) > 0 block_name from threadstat;
+
+desc cluster_transactions;
+desc server_transactions;
+desc cluster_operations;
+desc server_operations;
+
+create table t1 (a int primary key) engine = ndb;
+begin;
+insert into t1 values (1);
+select state, count_operations, outstanding_operations,
+IF(client_node_id <= 255, "<client_node_id>", "<incorrect node id>") 
+  client_node_id
+from server_transactions;
+select node_id, operation_type, state,
+IF(tc_node_id <= 48, "<tc_node_id>", "<incorrect nodeid>") tc_node_id,
+IF(client_node_id <= 255, "<client_node_id>", "<incorrect node id>") 
+  client_node_id
+from server_operations
+order by 1;
+
+--sorted_result
+select st.state, st.count_operations, st.outstanding_operations,
+       so.node_id, so.state, so.operation_type
+from server_transactions st,
+     server_operations so
+where st.transid = so.transid
+  and so.tc_node_id = st.node_id
+  and so.tc_block_instance = st.block_instance
+  and so.client_node_id = st.client_node_id
+  and so.client_block_ref = st.client_block_ref; 
+rollback;
+drop table t1;
+
 # Turn on ndbinfo_offline
 set @@global.ndbinfo_offline=TRUE;
 select @@ndbinfo_offline;

=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc	2011-10-22 07:56:33 +0000
+++ b/sql/ha_ndbcluster_connection.cc	2011-10-28 09:32:10 +0000
@@ -346,7 +346,7 @@ ndb_transid_mysql_connection_map_fill_ta
 {
   DBUG_ENTER("ndb_transid_mysql_connection_map_fill_table");
 
-  const bool all = check_global_access(thd, PROCESS_ACL);
+  const bool all = (check_global_access(thd, PROCESS_ACL) == 0);
   const ulonglong self = thd_get_thread_id(thd);
 
   TABLE* table= tables->table;

=== added file 'storage/ndb/include/kernel/statedesc.hpp'
--- a/storage/ndb/include/kernel/statedesc.hpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/include/kernel/statedesc.hpp	2011-10-28 10:16:23 +0000
@@ -0,0 +1,32 @@
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#ifndef NDB_STATE_DESC_H
+#define NDB_STATE_DESC_H
+
+struct ndbkernel_state_desc
+{
+  unsigned value;
+  const char * name;
+  const char * friendly_name;
+  const char * description;
+};
+
+extern struct ndbkernel_state_desc g_dbtc_apiconnect_state_desc[];
+extern struct ndbkernel_state_desc g_dblqh_tcconnect_state_desc[];
+
+#endif

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2011-10-13 20:08:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2011-10-28 13:45:34 +0000
@@ -18,6 +18,7 @@
 #ifndef DBLQH_H
 #define DBLQH_H
 
+#ifndef DBLQH_STATE_EXTRACT
 #include <pc.hpp>
 #include <ndb_limits.h>
 #include <SimulatedBlock.hpp>
@@ -41,6 +42,7 @@
 class Dbacc;
 class Dbtup;
 class Lgman;
+#endif // DBLQH_STATE_EXTRACT
 
 #ifdef DBLQH_C
 // Constants
@@ -410,10 +412,15 @@ class Lgman;
  *  - TEST 
  *  - LOG 
  */
-class Dblqh: public SimulatedBlock {
+class Dblqh 
+#ifndef DBLQH_STATE_EXTRACT
+  : public SimulatedBlock
+#endif
+{
   friend class DblqhProxy;
 
 public:
+#ifndef DBLQH_STATE_EXTRACT
   enum LcpCloseState {
     LCP_IDLE = 0,
     LCP_RUNNING = 1,       // LCP is running
@@ -1940,7 +1947,7 @@ public:
     Uint32 usageCountW; // writers
   }; // Size 100 bytes
   typedef Ptr<Tablerec> TablerecPtr;
-
+#endif // DBLQH_STATE_EXTRACT
   struct TcConnectionrec {
     enum ListState {
       NOT_IN_LIST = 0,
@@ -2021,6 +2028,7 @@ public:
       COPY_CONNECTED = 2,
       LOG_CONNECTED = 3
     };
+#ifndef DBLQH_STATE_EXTRACT
     ConnectState connectState;
     UintR copyCountWords;
     Uint32 keyInfoIVal;
@@ -2131,8 +2139,10 @@ public:
       Uint32 m_page_id[2];
       Local_key m_disk_ref[2];
     } m_nr_delete;
+#endif // DBLQH_STATE_EXTRACT
   }; /* p2c: size = 280 bytes */
-  
+
+#ifndef DBLQH_STATE_EXTRACT
   typedef Ptr<TcConnectionrec> TcConnectionrecPtr;
 
   struct TcNodeFailRecord {
@@ -3278,8 +3288,9 @@ public:
 
   void sendFireTrigConfTc(Signal* signal, BlockReference ref, Uint32 Tdata[]);
   bool check_fire_trig_pass(Uint32 op, Uint32 pass);
+#endif
 };
-
+#ifndef DBLQH_STATE_EXTRACT
 inline
 bool
 Dblqh::ScanRecord::check_scan_batch_completed() const
@@ -3402,5 +3413,5 @@ Dblqh::TRACE_OP_CHECK(const TcConnection
 	   regTcPtr->operation == ZDELETE)) ||
     ERROR_INSERTED(5713);
 }
-
+#endif
 #endif

=== added file 'storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp	2011-10-28 09:56:57 +0000
@@ -0,0 +1,76 @@
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include <kernel/statedesc.hpp>
+#define DBLQH_STATE_EXTRACT
+#include "Dblqh.hpp"
+
+#define SDESC(a,b,c) { (unsigned)Dblqh::TcConnectionrec::a, #a, b, c }
+
+struct ndbkernel_state_desc g_dblqh_tcconnect_state_desc[] =
+{
+  SDESC(IDLE, "Idle", ""),
+  SDESC(WAIT_ACC, "WaitLock", ""),
+  SDESC(WAIT_TUPKEYINFO, "", ""),
+  SDESC(WAIT_ATTR, "WaitData", ""),
+  SDESC(WAIT_TUP, "WaitTup", ""),
+  SDESC(STOPPED, "Stopped", ""),
+  SDESC(LOG_QUEUED, "LogPrepare", ""),
+  SDESC(PREPARED, "Prepared", ""),
+  SDESC(LOG_COMMIT_WRITTEN_WAIT_SIGNAL, "", ""),
+  SDESC(LOG_COMMIT_QUEUED_WAIT_SIGNAL, "", ""),
+
+  // Commit in progress states
+  /* -------------------------------------------------------------------- */
+  SDESC(COMMIT_STOPPED, "CommittingStopped", ""),
+  SDESC(LOG_COMMIT_QUEUED, "Committing", ""),
+  SDESC(COMMIT_QUEUED, "Committing", ""),
+  SDESC(COMMITTED, "Committed", ""),
+  SDESC(WAIT_TUP_COMMIT, "Committing", ""),
+
+  /* -------------------------------------------------------------------- */
+  // Abort in progress states
+  /* -------------------------------------------------------------------- */
+  SDESC(WAIT_ACC_ABORT, "Aborting", ""),
+  SDESC(ABORT_QUEUED, "Aborting", ""),
+  SDESC(ABORT_STOPPED, "AbortingStopped", ""),
+  SDESC(WAIT_AI_AFTER_ABORT, "Aborting", ""),
+  SDESC(LOG_ABORT_QUEUED, "Aborting", ""),
+  SDESC(WAIT_TUP_TO_ABORT, "Aborting", ""),
+
+  /* -------------------------------------------------------------------- */
+  // Scan in progress states
+  /* -------------------------------------------------------------------- */
+  SDESC(WAIT_SCAN_AI, "Scanning", ""),
+  SDESC(SCAN_STATE_USED, "Scanning", ""),
+  SDESC(SCAN_FIRST_STOPPED, "Scanning", ""),
+  SDESC(SCAN_CHECK_STOPPED, "Scanning", ""),
+  SDESC(SCAN_STOPPED, "ScanningStopped", ""),
+  SDESC(SCAN_RELEASE_STOPPED, "ScanningStopped", ""),
+  SDESC(SCAN_CLOSE_STOPPED, "ScanningStopped", ""),
+  SDESC(COPY_CLOSE_STOPPED, "ScanningStopped", ""),
+  SDESC(COPY_FIRST_STOPPED, "ScanningStopped", ""),
+  SDESC(COPY_STOPPED, "ScanningStopped", ""),
+  SDESC(SCAN_TUPKEY, "Scanning", ""),
+  SDESC(COPY_TUPKEY, "NodeRecoveryScanning", ""),
+
+  SDESC(TC_NOT_CONNECTED, "Idle", ""),
+  SDESC(PREPARED_RECEIVED_COMMIT, "Committing", ""),
+  SDESC(LOG_COMMIT_WRITTEN, "Committing", ""),
+
+  { 0, 0, 0, 0 }
+};

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2011-10-13 20:08:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2011-10-28 13:45:34 +0000
@@ -18,6 +18,7 @@
 #ifndef DBTC_H
 #define DBTC_H
 
+#ifndef DBTC_STATE_EXTRACT
 #include <ndb_limits.h>
 #include <pc.hpp>
 #include <SimulatedBlock.hpp>
@@ -37,6 +38,7 @@
 #include <signaldata/EventReport.hpp>
 #include <trigger_definitions.h>
 #include <SignalCounter.hpp>
+#endif
 
 #ifdef DBTC_C
 /*
@@ -143,14 +145,20 @@
 #define ZTRANS_TOO_BIG 261
 #endif
 
-class Dbtc: public SimulatedBlock {
+class Dbtc
+#ifndef DBTC_STATE_EXTRACT
+  : public SimulatedBlock
+#endif
+{
 public:
 
+#ifndef DBTC_STATE_EXTRACT
   /**
    * Incase of mt-TC...only one instance will perform actual take-over
    *   let this be TAKE_OVER_INSTANCE
    */
   STATIC_CONST( TAKE_OVER_INSTANCE = 1 );
+#endif
 
   enum ConnectionState {
     CS_CONNECTED = 0,
@@ -188,6 +196,7 @@ public:
     CS_WAIT_FIRE_TRIG_REQ = 27
   };
 
+#ifndef DBTC_STATE_EXTRACT
   enum OperationState {
     OS_CONNECTED = 1,
     OS_OPERATING = 2,
@@ -2103,6 +2112,7 @@ private:
 #endif
   Uint32 m_deferred_enabled;
   Uint32 m_max_writes_per_trans;
+#endif
 };
 
 #endif

=== added file 'storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp	2011-10-28 09:56:57 +0000
@@ -0,0 +1,59 @@
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include <kernel/statedesc.hpp>
+#define DBTC_STATE_EXTRACT
+#include "Dbtc.hpp"
+
+#define SDESC(a,b,c) { (unsigned)Dbtc::a, #a, b, c }
+
+/**
+ * Value
+ * Friendly name
+ * Description
+ */
+struct ndbkernel_state_desc g_dbtc_apiconnect_state_desc[] =
+{
+  SDESC(CS_CONNECTED, "Connected",
+        "An allocated idle transaction object"),
+  SDESC(CS_DISCONNECTED, "Disconnected",
+        "An unallocated connection object"),
+  SDESC(CS_STARTED, "Started", "A started transaction"),
+  SDESC(CS_RECEIVING, "Receiving", "A transaction receiving operations"),
+  SDESC(CS_RESTART, "", ""),
+  SDESC(CS_ABORTING, "Aborting", "A transaction aborting"),
+  SDESC(CS_COMPLETING, "Completing", "A transaction completing"),
+  SDESC(CS_COMPLETE_SENT, "Completing", "A transaction completing"),
+  SDESC(CS_PREPARE_TO_COMMIT, "", ""),
+  SDESC(CS_COMMIT_SENT, "Committing", "A transaction committing"),
+  SDESC(CS_START_COMMITTING, "", ""),
+  SDESC(CS_COMMITTING, "Committing", "A transaction committing"),
+  SDESC(CS_REC_COMMITTING, "", ""),
+  SDESC(CS_WAIT_ABORT_CONF, "Aborting", ""),
+  SDESC(CS_WAIT_COMPLETE_CONF, "Completing", ""),
+  SDESC(CS_WAIT_COMMIT_CONF, "Committing", ""),
+  SDESC(CS_FAIL_ABORTING, "TakeOverAborting", ""),
+  SDESC(CS_FAIL_ABORTED, "TakeOverAborting", ""),
+  SDESC(CS_FAIL_PREPARED, "", ""),
+  SDESC(CS_FAIL_COMMITTING, "TakeOverCommitting", ""),
+  SDESC(CS_FAIL_COMMITTED, "TakeOverCommitting", ""),
+  SDESC(CS_FAIL_COMPLETED, "TakeOverCompleting", ""),
+  SDESC(CS_START_SCAN, "Scanning", ""),
+  SDESC(CS_SEND_FIRE_TRIG_REQ, "Precomitting", ""),
+  SDESC(CS_WAIT_FIRE_TRIG_REQ, "Precomitting", ""),
+  { 0, 0, 0, 0 }
+};

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-10-28 09:04:10 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-10-28 13:45:34 +0000
@@ -2464,6 +2464,7 @@ NdbQueryImpl::handleBatchComplete(NdbRoo
            << ", finalBatchFrags=" << m_finalBatchFrags
            <<  endl;
   }
+  assert(rootFrag.isFragBatchComplete());
 
   /* May received fragment data after a SCANREF() (timeout?) 
    * terminated the scan.  We are about to close this query, 
@@ -2471,8 +2472,6 @@ NdbQueryImpl::handleBatchComplete(NdbRoo
    */
   if (likely(m_errorReceived == 0))
   {
-    assert(rootFrag.isFragBatchComplete());
-
     assert(m_pendingFrags > 0);                // Check against underflow.
     assert(m_pendingFrags <= m_rootFragCount); // .... and overflow
     m_pendingFrags--;
@@ -2489,6 +2488,16 @@ NdbQueryImpl::handleBatchComplete(NdbRoo
     rootFrag.setReceivedMore();
     return true;
   }
+  else if (!getQueryDef().isScanQuery())  // A failed lookup query
+  {
+    /**
+     * A lookup query will retrieve the rows as part of ::execute().
+     * -> Error must be visible through API before we return control
+     *    to the application.
+     */
+    setErrorCode(m_errorReceived);
+    return true;
+  }
 
   return false;
 } // NdbQueryImpl::handleBatchComplete
@@ -4970,12 +4979,12 @@ NdbQueryOperationImpl::execTCKEYREF(cons
   if (&getRoot() == this || 
       ref->errorCode != static_cast<Uint32>(Err_TupleNotFound))
   {
-    getQuery().setErrorCode(ref->errorCode);
     if (aSignal->getLength() == TcKeyRef::SignalLength)
     {
       // Signal may contain additional error data
       getQuery().m_error.details = (char *)UintPtr(ref->errorData);
     }
+    getQuery().setFetchTerminated(ref->errorCode,false);
   }
 
   NdbRootFragment& rootFrag = getQuery().m_rootFrags[0];

=== modified file 'storage/ndb/tools/CMakeLists.txt'
--- a/storage/ndb/tools/CMakeLists.txt	2011-10-05 11:21:23 +0000
+++ b/storage/ndb/tools/CMakeLists.txt	2011-10-28 09:56:57 +0000
@@ -73,7 +73,11 @@ MYSQL_ADD_EXECUTABLE(ndb_config
 TARGET_LINK_LIBRARIES(ndb_config ndbmgmclient ndbconf)
 
 # Build ndbinfo_sql and run it to create ndbinfo.sql
-ADD_EXECUTABLE(ndbinfo_sql ndbinfo_sql.cpp)
+ADD_EXECUTABLE(ndbinfo_sql
+  ndbinfo_sql.cpp
+  ${CMAKE_SOURCE_DIR}/storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp
+  ${CMAKE_SOURCE_DIR}/storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp
+)
 TARGET_LINK_LIBRARIES(ndbinfo_sql ndbclient)
 GET_TARGET_PROPERTY(NDBINFO_SQL_EXE ndbinfo_sql LOCATION)
 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/storage/ndb/tools/ndbinfo.sql

=== modified file 'storage/ndb/tools/Makefile.am'
--- a/storage/ndb/tools/Makefile.am	2011-10-05 11:21:23 +0000
+++ b/storage/ndb/tools/Makefile.am	2011-10-28 09:56:57 +0000
@@ -70,7 +70,9 @@ ndb_restore_LDADD = $(top_builddir)/stor
 ndbinfo_sql_SOURCES = ndbinfo_sql.cpp \
 	../src/mgmsrv/Config.cpp \
 	../src/mgmsrv/InitConfigFileParser.cpp \
-        $(top_srcdir)/storage/ndb/src/kernel/vm/mt_thr_config.cpp
+        $(top_srcdir)/storage/ndb/src/kernel/vm/mt_thr_config.cpp \
+        $(top_srcdir)/storage/ndb/src/kernel/blocks/dbtc/DbtcStateDesc.cpp \
+        $(top_srcdir)/storage/ndb/src/kernel/blocks/dblqh/DblqhStateDesc.cpp
 
 ndbinfo_sql_CXXFLAGS = -I$(top_srcdir)/storage/ndb/src/mgmapi
 

=== modified file 'storage/ndb/tools/ndbinfo_sql.cpp'
--- a/storage/ndb/tools/ndbinfo_sql.cpp	2011-10-13 20:08:25 +0000
+++ b/storage/ndb/tools/ndbinfo_sql.cpp	2011-10-28 13:45:34 +0000
@@ -50,12 +50,12 @@ struct view {
     "used, total, high, entry_size, cp1.param_name AS param_name1, "
     "cp2.param_name AS param_name2, cp3.param_name AS param_name3, "
     "cp4.param_name AS param_name4 "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>pools p "
-    "LEFT JOIN <NDBINFO_DB>.blocks b ON p.block_number = b.block_number "
-    "LEFT JOIN <NDBINFO_DB>.config_params cp1 ON p.config_param1 = cp1.param_number "
-    "LEFT JOIN <NDBINFO_DB>.config_params cp2 ON p.config_param2 = cp2.param_number "
-    "LEFT JOIN <NDBINFO_DB>.config_params cp3 ON p.config_param3 = cp3.param_number "
-    "LEFT JOIN <NDBINFO_DB>.config_params cp4 ON p.config_param4 = cp4.param_number"
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>pools` p "
+    "LEFT JOIN `<NDBINFO_DB>`.blocks b ON p.block_number = b.block_number "
+    "LEFT JOIN `<NDBINFO_DB>`.config_params cp1 ON p.config_param1 = cp1.param_number "
+    "LEFT JOIN `<NDBINFO_DB>`.config_params cp2 ON p.config_param2 = cp2.param_number "
+    "LEFT JOIN `<NDBINFO_DB>`.config_params cp3 ON p.config_param3 = cp3.param_number "
+    "LEFT JOIN `<NDBINFO_DB>`.config_params cp4 ON p.config_param4 = cp4.param_number"
   },
 #endif
   { "transporters",
@@ -67,7 +67,7 @@ struct view {
     "  WHEN 3 THEN \"DISCONNECTING\""
     "  ELSE NULL "
     " END AS status "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>transporters"
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>transporters`"
   },
   { "logspaces",
     "SELECT node_id, "
@@ -77,7 +77,7 @@ struct view {
     "  ELSE NULL "
     " END AS log_type, "
     "log_id, log_part, total, used "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>logspaces"
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>logspaces`"
   },
   { "logbuffers",
     "SELECT node_id, "
@@ -87,7 +87,7 @@ struct view {
     "  ELSE \"<unknown>\" "
     " END AS log_type, "
     "log_id, log_part, total, used "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>logbuffers"
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>logbuffers`"
   },
   { "resources",
     "SELECT node_id, "
@@ -105,9 +105,9 @@ struct view {
     "  ELSE \"<unknown>\" "
     " END AS resource_name, "
     "reserved, used, max "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>resources"
-   },
-   { "counters",
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>resources`"
+  },
+  { "counters",
     "SELECT node_id, b.block_name, block_instance, "
     "counter_id, "
     "CASE counter_id"
@@ -137,11 +137,11 @@ struct view {
     "  ELSE \"<unknown>\" "
     " END AS counter_name, "
     "val "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>counters c "
-    "LEFT JOIN <NDBINFO_DB>.blocks b "
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>counters` c "
+    "LEFT JOIN `<NDBINFO_DB>`.blocks b "
     "ON c.block_number = b.block_number"
-   },
-   { "nodes",
+  },
+  { "nodes",
     "SELECT node_id, "
     "uptime, "
     "CASE status"
@@ -158,8 +158,8 @@ struct view {
     " END AS status, "
     "start_phase, "
     "config_generation "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>nodes"
-   },
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>nodes`"
+  },
   { "memoryusage",
     "SELECT node_id,"
     "  pool_name AS memory_type,"
@@ -167,17 +167,91 @@ struct view {
     "  SUM(used) AS used_pages,"
     "  SUM(total*entry_size) AS total,"
     "  SUM(total) AS total_pages "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>pools "
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>pools` "
     "WHERE block_number IN (248, 254) AND "
     "  (pool_name = \"Index memory\" OR pool_name = \"Data memory\") "
     "GROUP BY node_id, memory_type"
   },
-   { "diskpagebuffer",
+  { "diskpagebuffer",
      "SELECT node_id, block_instance, "
      "pages_written, pages_written_lcp, pages_read, log_waits, "
      "page_requests_direct_return, page_requests_wait_queue, page_requests_wait_io "
-     "FROM <NDBINFO_DB>.<TABLE_PREFIX>diskpagebuffer"
-   }
+     "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>diskpagebuffer`"
+  },
+  { "diskpagebuffer",
+     "SELECT node_id, block_instance, "
+     "pages_written, pages_written_lcp, pages_read, log_waits, "
+     "page_requests_direct_return, page_requests_wait_queue, page_requests_wait_io "
+     "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>diskpagebuffer`"
+  },
+  { "threadblocks",
+    "SELECT t.node_id, t.thr_no, b.block_name, t.block_instance "
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>threadblocks` t "
+    "LEFT JOIN `<NDBINFO_DB>`.blocks b "
+    "ON t.block_number = b.block_number"
+  },
+  { "threadstat",
+    "SELECT * from `<NDBINFO_DB>`.`<TABLE_PREFIX>threadstat`"
+  },
+  { "cluster_transactions",
+    "SELECT"
+    " t.node_id,"
+    " t.block_instance,"
+    " t.transid0 + (t.transid1 << 32) as transid,"
+    " s.state_friendly_name as state, "
+    " t.c_ops as count_operations, "
+    " t.outstanding as outstanding_operations, "
+    " t.timer as inactive_seconds, "
+    " (t.apiref & 65535) as client_node_id, "
+    " (t.apiref >> 16) as client_block_ref "
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>transactions` t"
+    " LEFT JOIN `<NDBINFO_DB>`.`<TABLE_PREFIX>dbtc_apiconnect_state` s"
+    "        ON s.state_int_value = t.state"
+  },
+  { "server_transactions",
+    "SELECT map.mysql_connection_id, t.*"
+    "FROM information_schema.ndb_transid_mysql_connection_map map "
+    "JOIN `<NDBINFO_DB>`.cluster_transactions t "
+    "  ON (map.ndb_transid >> 32) = (t.transid >> 32)"
+  },
+  { "cluster_operations",
+    "SELECT"
+    " o.node_id,"
+    " o.block_instance,"
+    " o.transid0 + (o.transid1 << 32) as transid,"
+    " case o.op "
+    " when 1 then \"READ\""
+    " when 2 then \"READ-SH\""
+    " when 3 then \"READ-EX\""
+    " when 4 then \"INSERT\""
+    " when 5 then \"UPDATE\""
+    " when 6 then \"DELETE\""
+    " when 7 then \"WRITE\""
+    " when 8 then \"UNLOCK\""
+    " when 9 then \"REFRESH\""
+    " when 257 then \"SCAN\""
+    " when 258 then \"SCAN-SH\""
+    " when 259 then \"SCAN-EX\""
+    " ELSE \"<unknown>\""
+    " END as operation_type, "
+    " s.state_friendly_name as state, "
+    " o.tableid, "
+    " o.fragmentid, "
+    " (o.apiref & 65535) as client_node_id, "
+    " (o.apiref >> 16) as client_block_ref, "
+    " (o.tcref & 65535) as tc_node_id, "
+    " ((o.tcref >> 16) & 511) as tc_block_no, "
+    " ((o.tcref >> (16 + 9)) & 127) as tc_block_instance "
+    "FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>operations` o"
+    " LEFT JOIN `<NDBINFO_DB>`.`<TABLE_PREFIX>dblqh_tcconnect_state` s"
+    "        ON s.state_int_value = o.state"
+  },
+  { "server_operations",
+    "SELECT map.mysql_connection_id, o.* "
+    "FROM `<NDBINFO_DB>`.cluster_operations o "
+    "JOIN information_schema.ndb_transid_mysql_connection_map map"
+    "  ON (map.ndb_transid >> 32) = (o.transid >> 32)"
+  }
 };
 
 size_t num_views = sizeof(views)/sizeof(views[0]);
@@ -214,6 +288,38 @@ static void fill_blocks(BaseString& sql)
   }
 }
 
+#include "kernel/statedesc.hpp"
+
+static void fill_dbtc_apiconnect_state(BaseString& sql)
+{
+  const char* separator = "";
+  for (unsigned i = 0; g_dbtc_apiconnect_state_desc[i].name != 0; i++)
+  {
+    sql.appfmt("%s(%u, \"%s\", \"%s\", \"%s\")",
+               separator,
+               g_dbtc_apiconnect_state_desc[i].value,
+               g_dbtc_apiconnect_state_desc[i].name,
+               g_dbtc_apiconnect_state_desc[i].friendly_name,
+               g_dbtc_apiconnect_state_desc[i].description);
+    separator = ", ";
+  }
+}
+
+static void fill_dblqh_tcconnect_state(BaseString& sql)
+{
+  const char* separator = "";
+  for (unsigned i = 0; g_dblqh_tcconnect_state_desc[i].name != 0; i++)
+  {
+    sql.appfmt("%s(%u, \"%s\", \"%s\", \"%s\")",
+               separator,
+               g_dblqh_tcconnect_state_desc[i].value,
+               g_dblqh_tcconnect_state_desc[i].name,
+               g_dblqh_tcconnect_state_desc[i].friendly_name,
+               g_dblqh_tcconnect_state_desc[i].description);
+    separator = ", ";
+  }
+}
+
 struct lookup {
   const char* name;
   const char* columns;
@@ -224,12 +330,28 @@ struct lookup {
     "block_number INT UNSIGNED PRIMARY KEY, "
     "block_name VARCHAR(512)",
     &fill_blocks
-   },
+  },
   { "config_params",
     "param_number INT UNSIGNED PRIMARY KEY, "
     "param_name VARCHAR(512)",
     &fill_config_params
-   }
+  },
+  {
+    "<TABLE_PREFIX>dbtc_apiconnect_state",
+    "state_int_value  INT UNSIGNED PRIMARY KEY, "
+    "state_name VARCHAR(256), "
+    "state_friendly_name VARCHAR(256), "
+    "state_description VARCHAR(256)",
+    &fill_dbtc_apiconnect_state
+  },
+  {
+    "<TABLE_PREFIX>dblqh_tcconnect_state",
+    "state_int_value  INT UNSIGNED PRIMARY KEY, "
+    "state_name VARCHAR(256), "
+    "state_friendly_name VARCHAR(256), "
+    "state_description VARCHAR(256)",
+    &fill_dblqh_tcconnect_state
+  }
 };
 
 size_t num_lookups = sizeof(lookups)/sizeof(lookups[0]);
@@ -339,7 +461,7 @@ int main(int argc, char** argv){
   printf("# Drop any old views in %s\n", opt_ndbinfo_db);
   for (size_t i = 0; i < num_views; i++)
   {
-    sql.assfmt("DROP VIEW IF EXISTS %s.%s",
+    sql.assfmt("DROP VIEW IF EXISTS `%s`.`%s`",
                opt_ndbinfo_db, views[i].name);
     print_conditional_sql(sql);
   }
@@ -347,8 +469,10 @@ int main(int argc, char** argv){
   printf("# Drop any old lookup tables in %s\n", opt_ndbinfo_db);
   for (size_t i = 0; i < num_lookups; i++)
   {
-    sql.assfmt("DROP TABLE IF EXISTS %s.%s",
-               opt_ndbinfo_db, lookups[i].name);
+    BaseString table_name = replace_tags(lookups[i].name);
+
+    sql.assfmt("DROP TABLE IF EXISTS `%s`.`%s`",
+               opt_ndbinfo_db, table_name.c_str());
     print_conditional_sql(sql);
   }
 
@@ -409,16 +533,17 @@ int main(int argc, char** argv){
   for (size_t i = 0; i < num_lookups; i++)
   {
     lookup l = lookups[i];
-    printf("# %s.%s\n", opt_ndbinfo_db, l.name);
+    BaseString table_name = replace_tags(l.name);
+    printf("# %s.%s\n", opt_ndbinfo_db, table_name.c_str());
 
     /* Create lookup table */
     sql.assfmt("CREATE TABLE `%s`.`%s` (%s)",
-               opt_ndbinfo_db, l.name, l.columns);
+               opt_ndbinfo_db, table_name.c_str(), l.columns);
     print_conditional_sql(sql);
 
     /* Insert data */
     sql.assfmt("INSERT INTO `%s`.`%s` VALUES ",
-               opt_ndbinfo_db, l.name);
+               opt_ndbinfo_db, table_name.c_str());
     l.fill(sql);
     print_conditional_sql(sql);
   }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3576 to 3577) Ole John Aske1 Nov