3631 Magnus Blåudd 2011-10-27
ndbcluster
- move Ndb_binlog_extra_row_info to it's own file
added:
sql/ndb_binlog_extra_row_info.cc
sql/ndb_binlog_extra_row_info.h
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_binlog.h
storage/ndb/CMakeLists.txt
3630 Magnus Blåudd 2011-10-27
ndbcluster
- move' ndbcluster_find_all_files' to the only place where it's used in ha_ndbcluster_binlog.cc and make it static
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_binlog.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2011-10-27 09:17:34 +0000
+++ b/sql/ha_ndbcluster.cc 2011-10-27 09:34:06 +0000
@@ -52,6 +52,7 @@
#include "ndb_mi.h"
#include "ndb_conflict_trans.h"
#include "ndb_anyvalue.h"
+#include "ndb_binlog_extra_row_info.h"
// ndb interface initialization/cleanup
extern "C" void ndb_init_internal();
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-10-27 09:17:34 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-10-27 09:34:06 +0000
@@ -57,6 +57,7 @@ bool ndb_log_empty_epochs(void);
#include "ndb_dist_priv_util.h"
#include "ndb_anyvalue.h"
+#include "ndb_binlog_extra_row_info.h"
/*
Timeout for syncing schema events between
@@ -7588,121 +7589,5 @@ ulong opt_server_id_mask = ~0;
#endif
-Ndb_binlog_extra_row_info::
-Ndb_binlog_extra_row_info()
-{
- flags = 0;
- transactionId = InvalidTransactionId;
- /* Prepare buffer with extra row info buffer bytes */
- buff[ EXTRA_ROW_INFO_LEN_OFFSET ] = 0;
- buff[ EXTRA_ROW_INFO_FORMAT_OFFSET ] = ERIF_NDB;
-}
-
-void
-Ndb_binlog_extra_row_info::
-setFlags(Uint16 _flags)
-{
- flags = _flags;
-}
-
-void
-Ndb_binlog_extra_row_info::
-setTransactionId(Uint64 _transactionId)
-{
- assert(_transactionId != InvalidTransactionId);
- transactionId = _transactionId;
-};
-
-int
-Ndb_binlog_extra_row_info::
-loadFromBuffer(const uchar* extra_row_info)
-{
- assert(extra_row_info);
-
- Uint8 length = extra_row_info[ EXTRA_ROW_INFO_LEN_OFFSET ];
- assert(length >= EXTRA_ROW_INFO_HDR_BYTES);
- Uint8 payload_length = length - EXTRA_ROW_INFO_HDR_BYTES;
- Uint8 format = extra_row_info[ EXTRA_ROW_INFO_FORMAT_OFFSET ];
-
- if (likely(format == ERIF_NDB))
- {
- if (likely(payload_length >= FLAGS_SIZE))
- {
- const uchar* data = &extra_row_info[ EXTRA_ROW_INFO_HDR_BYTES ];
- Uint8 nextPos = 0;
-
- /* Have flags at least */
- Uint16 netFlags;
- memcpy(&netFlags, &data[ nextPos ], FLAGS_SIZE);
- nextPos += FLAGS_SIZE;
- flags = uint2korr((const char*) &netFlags);
-
- if (flags & NDB_ERIF_TRANSID)
- {
- if (likely((nextPos + TRANSID_SIZE) <= payload_length))
- {
- /*
- Correct length, retrieve transaction id, converting from
- little endian if necessary.
- */
- Uint64 netTransId;
- memcpy(&netTransId,
- &data[ nextPos ],
- TRANSID_SIZE);
- nextPos += TRANSID_SIZE;
- transactionId = uint8korr((const char*) &netTransId);
- }
- else
- {
- /*
- Error - supposed to have transaction id, but
- buffer too short
- */
- return -1;
- }
- }
- }
- }
-
- /* We currently ignore other formats of extra binlog info, and
- * different lengths.
- */
-
- return 0;
-}
-
-uchar*
-Ndb_binlog_extra_row_info::generateBuffer()
-{
- /*
- Here we write out the buffer in network format,
- based on the current member settings.
- */
- Uint8 nextPos = EXTRA_ROW_INFO_HDR_BYTES;
-
- if (flags)
- {
- /* Write current flags into buff */
- Uint16 netFlags = uint2korr((const char*) &flags);
- memcpy(&buff[ nextPos ], &netFlags, FLAGS_SIZE);
- nextPos += FLAGS_SIZE;
-
- if (flags & NDB_ERIF_TRANSID)
- {
- Uint64 netTransactionId = uint8korr((const char*) &transactionId);
- memcpy(&buff[ nextPos ], &netTransactionId, TRANSID_SIZE);
- nextPos += TRANSID_SIZE;
- }
-
- assert( nextPos <= MaxLen );
- /* Set length */
- assert( buff[ EXTRA_ROW_INFO_FORMAT_OFFSET ] == ERIF_NDB );
- buff[ EXTRA_ROW_INFO_LEN_OFFSET ] = nextPos;
-
- return buff;
- }
- return 0;
-}
-
// #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
#endif
=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h 2011-10-27 09:17:34 +0000
+++ b/sql/ha_ndbcluster_binlog.h 2011-10-27 09:34:06 +0000
@@ -221,48 +221,3 @@ ndbcluster_check_if_local_table(const ch
bool
ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname);
-/*
- Helper for reading/writing Binlog extra row info
- in Ndb format.
- It contains an internal buffer, which can be passed
- in the thd variable when writing binlog entries if
- the object stays in scope around the write.
-*/
-class Ndb_binlog_extra_row_info
-{
-public:
- static const Uint32 FLAGS_SIZE = sizeof(Uint16);
- static const Uint32 TRANSID_SIZE = sizeof(Uint64);
- static const Uint32 MaxLen =
- EXTRA_ROW_INFO_HDR_BYTES +
- FLAGS_SIZE +
- TRANSID_SIZE;
-
- static const Uint64 InvalidTransactionId = ~Uint64(0);
-
- enum Flags
- {
- NDB_ERIF_TRANSID = 0x1
- };
-
- Ndb_binlog_extra_row_info();
-
- int loadFromBuffer(const uchar* extra_row_info_ptr);
-
- Uint16 getFlags() const
- {
- return flags;
- }
- void setFlags(Uint16 _flags);
- Uint64 getTransactionId() const
- { return transactionId; };
- void setTransactionId(Uint64 _transactionId);
- uchar* getBuffPtr()
- { return buff; };
- uchar* generateBuffer();
-private:
- uchar buff[MaxLen];
- Uint16 flags;
- Uint64 transactionId;
-};
-
=== added file 'sql/ndb_binlog_extra_row_info.cc'
--- a/sql/ndb_binlog_extra_row_info.cc 1970-01-01 00:00:00 +0000
+++ b/sql/ndb_binlog_extra_row_info.cc 2011-10-27 09:34:06 +0000
@@ -0,0 +1,136 @@
+/*
+ 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 "ndb_binlog_extra_row_info.h"
+#include <string.h> // memcpy
+
+
+Ndb_binlog_extra_row_info::
+Ndb_binlog_extra_row_info()
+{
+ flags = 0;
+ transactionId = InvalidTransactionId;
+ /* Prepare buffer with extra row info buffer bytes */
+ buff[ EXTRA_ROW_INFO_LEN_OFFSET ] = 0;
+ buff[ EXTRA_ROW_INFO_FORMAT_OFFSET ] = ERIF_NDB;
+}
+
+void
+Ndb_binlog_extra_row_info::
+setFlags(Uint16 _flags)
+{
+ flags = _flags;
+}
+
+void
+Ndb_binlog_extra_row_info::
+setTransactionId(Uint64 _transactionId)
+{
+ assert(_transactionId != InvalidTransactionId);
+ transactionId = _transactionId;
+};
+
+int
+Ndb_binlog_extra_row_info::
+loadFromBuffer(const uchar* extra_row_info)
+{
+ assert(extra_row_info);
+
+ Uint8 length = extra_row_info[ EXTRA_ROW_INFO_LEN_OFFSET ];
+ assert(length >= EXTRA_ROW_INFO_HDR_BYTES);
+ Uint8 payload_length = length - EXTRA_ROW_INFO_HDR_BYTES;
+ Uint8 format = extra_row_info[ EXTRA_ROW_INFO_FORMAT_OFFSET ];
+
+ if (likely(format == ERIF_NDB))
+ {
+ if (likely(payload_length >= FLAGS_SIZE))
+ {
+ const uchar* data = &extra_row_info[ EXTRA_ROW_INFO_HDR_BYTES ];
+ Uint8 nextPos = 0;
+
+ /* Have flags at least */
+ Uint16 netFlags;
+ memcpy(&netFlags, &data[ nextPos ], FLAGS_SIZE);
+ nextPos += FLAGS_SIZE;
+ flags = uint2korr((const char*) &netFlags);
+
+ if (flags & NDB_ERIF_TRANSID)
+ {
+ if (likely((nextPos + TRANSID_SIZE) <= payload_length))
+ {
+ /*
+ Correct length, retrieve transaction id, converting from
+ little endian if necessary.
+ */
+ Uint64 netTransId;
+ memcpy(&netTransId,
+ &data[ nextPos ],
+ TRANSID_SIZE);
+ nextPos += TRANSID_SIZE;
+ transactionId = uint8korr((const char*) &netTransId);
+ }
+ else
+ {
+ /*
+ Error - supposed to have transaction id, but
+ buffer too short
+ */
+ return -1;
+ }
+ }
+ }
+ }
+
+ /* We currently ignore other formats of extra binlog info, and
+ * different lengths.
+ */
+
+ return 0;
+}
+
+uchar*
+Ndb_binlog_extra_row_info::generateBuffer()
+{
+ /*
+ Here we write out the buffer in network format,
+ based on the current member settings.
+ */
+ Uint8 nextPos = EXTRA_ROW_INFO_HDR_BYTES;
+
+ if (flags)
+ {
+ /* Write current flags into buff */
+ Uint16 netFlags = uint2korr((const char*) &flags);
+ memcpy(&buff[ nextPos ], &netFlags, FLAGS_SIZE);
+ nextPos += FLAGS_SIZE;
+
+ if (flags & NDB_ERIF_TRANSID)
+ {
+ Uint64 netTransactionId = uint8korr((const char*) &transactionId);
+ memcpy(&buff[ nextPos ], &netTransactionId, TRANSID_SIZE);
+ nextPos += TRANSID_SIZE;
+ }
+
+ assert( nextPos <= MaxLen );
+ /* Set length */
+ assert( buff[ EXTRA_ROW_INFO_FORMAT_OFFSET ] == ERIF_NDB );
+ buff[ EXTRA_ROW_INFO_LEN_OFFSET ] = nextPos;
+
+ return buff;
+ }
+ return 0;
+}
=== added file 'sql/ndb_binlog_extra_row_info.h'
--- a/sql/ndb_binlog_extra_row_info.h 1970-01-01 00:00:00 +0000
+++ b/sql/ndb_binlog_extra_row_info.h 2011-10-27 09:34:06 +0000
@@ -0,0 +1,71 @@
+/*
+ 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_BINLOG_EXTRA_ROW_INFO_H
+#define NDB_BINLOG_EXTRA_ROW_INFO_H
+
+#include <my_global.h>
+#include <ndb_types.h>
+#include <rpl_constants.h>
+
+/*
+ Helper for reading/writing Binlog extra row info
+ in Ndb format.
+ It contains an internal buffer, which can be passed
+ in the thd variable when writing binlog entries if
+ the object stays in scope around the write.
+*/
+class Ndb_binlog_extra_row_info
+{
+public:
+ static const Uint32 FLAGS_SIZE = sizeof(Uint16);
+ static const Uint32 TRANSID_SIZE = sizeof(Uint64);
+ static const Uint32 MaxLen =
+ EXTRA_ROW_INFO_HDR_BYTES +
+ FLAGS_SIZE +
+ TRANSID_SIZE;
+
+ static const Uint64 InvalidTransactionId = ~Uint64(0);
+
+ enum Flags
+ {
+ NDB_ERIF_TRANSID = 0x1
+ };
+
+ Ndb_binlog_extra_row_info();
+
+ int loadFromBuffer(const uchar* extra_row_info_ptr);
+
+ Uint16 getFlags() const
+ {
+ return flags;
+ }
+ void setFlags(Uint16 _flags);
+ Uint64 getTransactionId() const
+ { return transactionId; };
+ void setTransactionId(Uint64 _transactionId);
+ uchar* getBuffPtr()
+ { return buff; };
+ uchar* generateBuffer();
+private:
+ uchar buff[MaxLen];
+ Uint16 flags;
+ Uint64 transactionId;
+};
+
+
+#endif
=== modified file 'storage/ndb/CMakeLists.txt'
--- a/storage/ndb/CMakeLists.txt 2011-10-27 08:27:44 +0000
+++ b/storage/ndb/CMakeLists.txt 2011-10-27 09:34:06 +0000
@@ -82,6 +82,7 @@ SET(NDBCLUSTER_SOURCES
../../sql/ndb_conflict_trans.cc
../../sql/ndb_anyvalue.cc
../../sql/ndb_ndbapi_util.cc
+ ../../sql/ndb_binlog_extra_row_info.cc
)
# Include directories used when building ha_ndbcluster
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (magnus.blaudd:3630 to 3631) | Magnus Blåudd | 27 Oct |