4190 Jonas Oreland 2011-05-12 [merge]
ndb - merge 70 to 71
modified:
mysql-test/suite/ndb/r/ndb_rename.result
mysql-test/suite/ndb/t/ndb_rename.test
storage/ndb/include/ndbapi/NdbReceiver.hpp
storage/ndb/src/common/portlib/CMakeLists.txt
storage/ndb/src/common/portlib/Makefile.am
storage/ndb/src/common/portlib/NdbTCP.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
storage/ndb/src/mgmsrv/MgmtSrvr.cpp
storage/ndb/src/ndbapi/DictCache.cpp
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
storage/ndb/src/ndbapi/NdbOperationExec.cpp
storage/ndb/src/ndbapi/NdbQueryOperation.cpp
storage/ndb/src/ndbapi/NdbReceiver.cpp
storage/ndb/src/ndbapi/NdbScanOperation.cpp
4189 Craig L Russell 2011-05-11
Fix bit(64) column types on big endian architectures
modified:
storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java
=== modified file 'mysql-test/suite/ndb/r/ndb_rename.result'
--- a/mysql-test/suite/ndb/r/ndb_rename.result 2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/ndb/r/ndb_rename.result 2011-05-12 09:01:21 +0000
@@ -21,4 +21,11 @@ SELECT * FROM ndbtest.t2 WHERE attr1 = 1
pk1 attr1 attr2 attr3
1 1 1 one
drop table ndbtest.t2;
+create table t1 (
+pk1 INT NOT NULL PRIMARY KEY,
+b blob
+) engine = ndbcluster;
+alter table t1 rename ndbtest.t1;
+alter table ndbtest.t1 rename test.t1;
+drop table test.t1;
drop database ndbtest;
=== modified file 'mysql-test/suite/ndb/t/ndb_rename.test'
--- a/mysql-test/suite/ndb/t/ndb_rename.test 2007-11-29 10:29:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_rename.test 2011-05-12 09:01:21 +0000
@@ -30,6 +30,17 @@ alter table t2 rename ndbtest.t2;
SELECT * FROM ndbtest.t2 WHERE attr1 = 1;
drop table ndbtest.t2;
+
+create table t1 (
+ pk1 INT NOT NULL PRIMARY KEY,
+ b blob
+) engine = ndbcluster;
+
+alter table t1 rename ndbtest.t1;
+alter table ndbtest.t1 rename test.t1;
+
+drop table test.t1;
+
drop database ndbtest;
# End of 4.1 tests
=== modified file 'storage/ndb/include/ndbapi/NdbReceiver.hpp'
--- a/storage/ndb/include/ndbapi/NdbReceiver.hpp 2011-02-09 14:18:53 +0000
+++ b/storage/ndb/include/ndbapi/NdbReceiver.hpp 2011-05-11 13:31:44 +0000
@@ -118,7 +118,7 @@ private:
*/
void do_setup_ndbrecord(const NdbRecord *ndb_record, Uint32 batch_size,
Uint32 key_size, Uint32 read_range_no,
- Uint32 rowsize, char *buf, Uint32 column_count);
+ Uint32 rowsize, char *buf);
static
Uint32 ndbrecord_rowsize(const NdbRecord *ndb_record,
@@ -137,33 +137,27 @@ private:
new NdbRecord style operation.
*/
bool m_using_ndb_record;
- union {
- /* members used for NdbRecAttr operation. */
- struct {
- Uint32 m_hidden_count;
- } m_recattr;
-
- /* members used for NdbRecord operation. */
- struct {
- Uint32 m_column_count;
- const NdbRecord *m_ndb_record;
- char *m_row;
- /* Block of memory used to receive all rows in a batch during scan. */
- char *m_row_buffer;
- /*
- Offsets between two rows in m_row_buffer.
- This can be different from m_ndb_record->m_row_size, as we sometimes
- store extra information after each row (range_no and keyinfo).
- For non-scan operations, this is set to zero.
- */
- Uint32 m_row_offset;
- /*
- m_read_range_no is true if we are storing the range_no at the end of
- each row during scans.
- */
- bool m_read_range_no;
- } m_record;
- };
+
+ /* members used for NdbRecord operation. */
+ struct {
+ const NdbRecord *m_ndb_record;
+ char *m_row;
+ /* Block of memory used to receive all rows in a batch during scan. */
+ char *m_row_buffer;
+ /*
+ Offsets between two rows in m_row_buffer.
+ This can be different from m_ndb_record->m_row_size, as we sometimes
+ store extra information after each row (range_no and keyinfo).
+ For non-scan operations, this is set to zero.
+ */
+ Uint32 m_row_offset;
+ /*
+ m_read_range_no is true if we are storing the range_no at the end of
+ each row during scans.
+ */
+ bool m_read_range_no;
+ } m_record;
+
class NdbRecAttr* theFirstRecAttr;
class NdbRecAttr* theCurrentRecAttr;
@@ -212,7 +206,6 @@ private:
bool hasResults() const { return m_result_rows > 0; }
bool nextResult() const { return m_current_row < m_result_rows; }
- NdbRecAttr* copyout(NdbReceiver&);
Uint32 receive_packed_recattr(NdbRecAttr**, Uint32 bmlen,
const Uint32* aDataPtr, Uint32 aLength);
Uint32 receive_packed_ndbrecord(Uint32 bmlen,
=== modified file 'storage/ndb/src/common/portlib/CMakeLists.txt'
--- a/storage/ndb/src/common/portlib/CMakeLists.txt 2011-02-02 00:40:07 +0000
+++ b/storage/ndb/src/common/portlib/CMakeLists.txt 2011-05-11 12:23:24 +0000
@@ -37,4 +37,8 @@ SET_TARGET_PROPERTIES(NdbDir-t
PROPERTIES COMPILE_FLAGS "-DTEST_NDBDIR")
TARGET_LINK_LIBRARIES(NdbDir-t ndbportlib)
+ADD_EXECUTABLE(NdbGetInAddr-t NdbTCP.cpp)
+SET_TARGET_PROPERTIES(NdbGetInAddr-t
+ PROPERTIES COMPILE_FLAGS "-DTEST_NDBGETINADDR")
+
=== modified file 'storage/ndb/src/common/portlib/Makefile.am'
--- a/storage/ndb/src/common/portlib/Makefile.am 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/common/portlib/Makefile.am 2011-05-11 12:23:24 +0000
@@ -33,7 +33,7 @@ EXTRA_PROGRAMS = memtest PortLibTest mun
PortLibTest_SOURCES = NdbPortLibTest.cpp
munmaptest_SOURCES = munmaptest.cpp
-noinst_PROGRAMS = NdbDir-t NdbNuma-t
+noinst_PROGRAMS = NdbDir-t NdbNuma-t NdbGetInAddr-t
NdbDir_t_SOURCES = NdbDir.cpp \
$(top_srcdir)/storage/ndb/src/common/util/basestring_vsnprintf.c
@@ -46,3 +46,5 @@ NdbNuma_t_SOURCES = NdbNuma.cpp
NdbNuma_t_CXXFLAGS = -DTEST_NDBNUMA
NdbNuma_t_LDADD = $(top_builddir)/mysys/libmysyslt.la @LIBDL@
+NdbGetInAddr_t_SOURCES = NdbTCP.cpp
+NdbGetInAddr_t_CXXFLAGS = -DTEST_NDBGETINADDR
=== modified file 'storage/ndb/src/common/portlib/NdbTCP.cpp'
--- a/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-05-11 19:12:56 +0000
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 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
@@ -17,45 +17,198 @@
#include <ndb_global.h>
-#include <my_net.h>
#include <NdbTCP.h>
-
-
extern "C"
-int
+int
Ndb_getInAddr(struct in_addr * dst, const char *address)
{
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET; // Only IPv4 address
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ struct addrinfo* ai_list;
+ if (getaddrinfo(address, NULL, &hints, &ai_list) != 0)
+ {
+ dst->s_addr = INADDR_NONE;
+ return -1;
+ }
+
+ /* Return sin_addr for the first address returned */
+ struct sockaddr_in* sin = (struct sockaddr_in*)ai_list->ai_addr;
+ memcpy(dst, &sin->sin_addr, sizeof(struct in_addr));
+
+ freeaddrinfo(ai_list);
+ return 0;
+}
+
+#ifdef TEST_NDBGETINADDR
+#include <NdbTap.hpp>
+
+static void
+CHECK(const char* address, int expected_res, bool is_numeric= false)
+{
+ struct in_addr addr;
+
+ fprintf(stderr, "Testing '%s'\n", address);
+
+ int res= Ndb_getInAddr(&addr, address);
+
+ if (res != expected_res)
+ {
+ fprintf(stderr, "> unexpected result: %d, expected: %d\n",
+ res, expected_res);
+ abort();
+ }
+
+ if (res != 0)
{
- int tmp_errno;
- struct hostent tmp_hostent, *hp;
- char buff[GETHOSTBYNAME_BUFF_SIZE];
- hp = my_gethostbyname_r(address,&tmp_hostent,buff,sizeof(buff),
- &tmp_errno);
- if (hp)
+ fprintf(stderr, "> returned -1, checking INADDR_NONE\n");
+
+ // Should return INADDR_NONE when when lookup fails
+ struct in_addr none;
+ none.s_addr = INADDR_NONE;
+ if (memcmp(&addr, &none, sizeof(none)) != 0)
{
- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0;
+ fprintf(stderr, "> didn't return INADDR_NONE after failure, "
+ "got: '%s', expected; '%s'\n",
+ inet_ntoa(addr), inet_ntoa(none));
+ abort();
}
- my_gethostbyname_r_free();
+ fprintf(stderr, "> ok\n");
+ return;
+ }
+
+ fprintf(stderr, "> '%s' -> '%s'\n", address, inet_ntoa(addr));
+
+ if (is_numeric)
+ {
+ // Check that numeric address always map back to itself
+ // ie. compare to value returned by 'inet_aton'
+ fprintf(stderr, "> Checking numeric address against inet_addr\n");
+ struct in_addr addr2;
+ addr2.s_addr = inet_addr(address);
+ fprintf(stderr, "> inet_addr(%s) -> '%s'\n", address, inet_ntoa(addr2));
+
+ if (memcmp(&addr, &addr2, sizeof(struct in_addr)) != 0)
+ {
+ fprintf(stderr, "> numeric address '%s' didn't map to same value as "
+ "inet_addr: '%s'", address, inet_ntoa(addr2));
+ abort();
+ }
+ fprintf(stderr, "> ok\n");
+ }
+}
+
+
+/*
+ socket_library_init
+ - Normally done by ndb_init(), but to avoid
+ having to link with "everything", implement it locally
+*/
+
+static void
+socket_library_init(void)
+{
+#ifdef _WIN32
+ WORD requested_version = MAKEWORD( 2, 0 );
+ WSADATA wsa_data;
+ if (WSAStartup( requested_version, &wsa_data ))
+ {
+ fprintf(stderr, "failed to init Winsock\n");
+ abort();
+ }
+
+ // Confirm that the requested version of the library was loaded
+ if (wsa_data.wVersion != requested_version)
+ {
+ (void)WSACleanup();
+ fprintf(stderr, "Wrong version of Winsock loaded\n");
+ abort();
}
- /* Try it as aaa.bbb.ccc.ddd. */
- dst->s_addr = inet_addr(address);
- if (dst->s_addr !=
-#ifdef INADDR_NONE
- INADDR_NONE
-#else
- -1
#endif
- )
+}
+
+
+static void
+socket_library_end()
+{
+#ifdef _WIN32
+ (void)WSACleanup();
+#endif
+}
+
+static bool
+can_resolve_hostname(const char* name)
+{
+ fprintf(stderr, "Checking if '%s' can be used for testing\n", name);
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET; // Only IPv4 address
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ struct addrinfo* ai_list;
+ int err = getaddrinfo(name, NULL, &hints, &ai_list);
+
+ if (err)
{
- return 0;
+ fprintf(stderr, "> '%s' -> error: %d '%s'\n",
+ name, err, gai_strerror(err));
+
+ if (err == EAI_NODATA ||
+ err == EAI_NONAME)
+ {
+ // An OK error
+ fprintf(stderr, "> skipping tests with this name...\n");
+ return false;
+ }
+
+ // Another unhandled error
+ abort();
}
- return -1;
+
+ freeaddrinfo(ai_list);
+
+ return true;
}
+TAPTEST(NdbGetInAddr)
+{
+ socket_library_init();
+
+ if (can_resolve_hostname("localhost"))
+ CHECK("localhost", 0);
+ CHECK("127.0.0.1", 0, true);
+
+ char hostname_buf[256];
+ if (gethostname(hostname_buf, sizeof(hostname_buf)) == 0 &&
+ can_resolve_hostname(hostname_buf))
+ {
+ // Check this machines hostname
+ CHECK(hostname_buf, 0);
+
+ struct in_addr addr;
+ Ndb_getInAddr(&addr, hostname_buf);
+ // Convert hostname to dotted decimal string ip and check
+ CHECK(inet_ntoa(addr), 0, true);
+ }
+ CHECK("unknown_?host", -1); // Does not exist
+ CHECK("3ffe:1900:4545:3:200:f8ff:fe21:67cf", -1); // No IPv6
+ CHECK("fe80:0:0:0:200:f8ff:fe21:67cf", -1);
+ CHECK("fe80::200:f8ff:fe21:67cf", -1);
+ CHECK("::1", -1); // the loopback, but still No IPv6
+
+ socket_library_end();
+
+ return 1; // OK
+}
+#endif
+
+
static inline
int my_socket_nfds(ndb_socket_t s, int nfds)
{
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2011-04-11 13:36:12 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2011-05-12 09:01:21 +0000
@@ -8028,9 +8028,23 @@ Dbdict::alterTable_parse(Signal* signal,
// the new temporary table record seized from pool
newTablePtr = parseRecord.tablePtr;
+ alterTabPtr.p->m_newTable_realObjectId = newTablePtr.p->tableId;
newTablePtr.p->tableId = impl_req->tableId; // set correct table id...(not the temporary)
}
+
+ {
+ /**
+ * Mark SchemaObject as in-use so that it's won't be found by other op
+ * choose a state that will be automatically cleaned incase we crash
+ */
+ SchemaFile::TableEntry * objEntry =
+ objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
+ objEntry->m_tableType = DictTabInfo::SchemaTransaction;
+ objEntry->m_tableState = SchemaFile::SF_STARTED;
+ objEntry->m_transId = trans_ptr.p->m_transId + 1;
+ }
+
// set the new version now
impl_req->newTableVersion =
newTablePtr.p->tableVersion =
@@ -9469,6 +9483,15 @@ Dbdict::alterTable_fromCommitComplete(Si
JBB, ptr, 1);
}
+ {
+ // Remark object as free
+ SchemaFile::TableEntry * objEntry =
+ objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
+ objEntry->m_tableType = DictTabInfo::SchemaTransaction;
+ objEntry->m_tableState = SchemaFile::SF_UNUSED;
+ objEntry->m_transId = 0;
+ }
+
releaseTableObject(alterTabPtr.p->m_newTablePtr.i, false);
sendTransConf(signal, op_ptr);
}
@@ -9551,6 +9574,16 @@ Dbdict::alterTable_abortParse(Signal* si
if (!newTablePtr.isNull()) {
jam();
// release the temporary work table
+
+ {
+ // Remark object as free
+ SchemaFile::TableEntry * objEntry =
+ objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
+ objEntry->m_tableType = DictTabInfo::SchemaTransaction;
+ objEntry->m_tableState = SchemaFile::SF_UNUSED;
+ objEntry->m_transId = 0;
+ }
+
releaseTableObject(newTablePtr.i, false);
newTablePtr.setNull();
}
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2011-02-16 14:53:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2011-05-12 09:01:21 +0000
@@ -2365,6 +2365,7 @@ private:
// current and new temporary work table
TableRecordPtr m_tablePtr;
TableRecordPtr m_newTablePtr;
+ Uint32 m_newTable_realObjectId;
// before image
RopeHandle m_oldTableName;
=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2011-04-15 17:56:38 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2011-05-12 09:40:20 +0000
@@ -1345,7 +1345,7 @@ int MgmtSrvr::sendSTOP_REQ(const Vector<
ndb_nodes_to_stop.copyto(NdbNodeBitmask::Size, stopReq->nodes);
StopReq::setStopNodes(stopReq->requestInfo, 1);
}
- else
+ else if (ndb_nodes_to_stop.count() == 1)
{
Uint32 nodeId = ndb_nodes_to_stop.find(0);
if (okToSendTo(nodeId, true) == 0)
=== modified file 'storage/ndb/src/ndbapi/DictCache.cpp'
--- a/storage/ndb/src/ndbapi/DictCache.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/ndbapi/DictCache.cpp 2011-05-12 09:01:21 +0000
@@ -457,7 +457,6 @@ GlobalDictCache::alter_table_rep(const c
bool altered)
{
DBUG_ENTER("GlobalDictCache::alter_table_rep");
- assert(! is_ndb_blob_table(name));
const Uint32 len = (Uint32)strlen(name);
Vector<TableVersion> * vers =
m_tableHash.getData(name, len);
@@ -467,6 +466,7 @@ GlobalDictCache::alter_table_rep(const c
DBUG_VOID_RETURN;
}
+ assert(! is_ndb_blob_table(name));
const Uint32 sz = vers->size();
if(sz == 0)
{
=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2011-02-23 13:20:20 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2011-05-12 09:40:20 +0000
@@ -938,6 +938,72 @@ NdbTableImpl::getName() const
return m_externalName.c_str();
}
+int
+NdbTableImpl::getDbName(char buf[], size_t len) const
+{
+ if (len == 0)
+ return -1;
+
+ // db/schema/table
+ const char *ptr = m_internalName.c_str();
+
+ size_t pos = 0;
+ while (ptr[pos] && ptr[pos] != table_name_separator)
+ {
+ buf[pos] = ptr[pos];
+ pos++;
+
+ if (pos == len)
+ return -1;
+ }
+ buf[pos] = 0;
+ return 0;
+}
+
+int
+NdbTableImpl::getSchemaName(char buf[], size_t len) const
+{
+ if (len == 0)
+ return -1;
+
+ // db/schema/table
+ const char *ptr = m_internalName.c_str();
+
+ // skip over "db"
+ while (*ptr && *ptr != table_name_separator)
+ ptr++;
+
+ buf[0] = 0;
+ if (*ptr == table_name_separator)
+ {
+ ptr++;
+ size_t pos = 0;
+ while (ptr[pos] && ptr[pos] != table_name_separator)
+ {
+ buf[pos] = ptr[pos];
+ pos++;
+
+ if (pos == len)
+ return -1;
+ }
+ buf[pos] = 0;
+ }
+
+ return 0;
+}
+
+void
+NdbTableImpl::setDbSchema(const char * db, const char * schema)
+{
+ m_internalName.assfmt("%s%c%s%c%s",
+ db,
+ table_name_separator,
+ schema,
+ table_name_separator,
+ m_externalName.c_str());
+ updateMysqlName();
+}
+
void
NdbTableImpl::computeAggregates()
{
@@ -3090,7 +3156,8 @@ int NdbDictionaryImpl::alterTableGlobal(
{
DBUG_ENTER("NdbDictionaryImpl::alterTableGlobal");
// Alter the table
- int ret = m_receiver.alterTable(m_ndb, old_impl, impl);
+ Uint32 changeMask = 0;
+ int ret = m_receiver.alterTable(m_ndb, old_impl, impl, changeMask);
#if ndb_bug41905
old_impl.m_status = NdbDictionary::Object::Invalid;
#endif
@@ -3107,18 +3174,93 @@ int NdbDictionaryImpl::alterTableGlobal(
m_globalHash->unlock();
if (ret != 0)
m_error.code = 723;
+
+ if (ret == 0 && AlterTableReq::getNameFlag(changeMask) != 0)
+ {
+ char db0[MAX_TAB_NAME_SIZE];
+ char db1[MAX_TAB_NAME_SIZE];
+ if (old_impl.getDbName(db0, sizeof(db0)) != 0)
+ {
+ m_error.code = 705;
+ DBUG_RETURN(-1);
+ }
+ if (impl.getDbName(db1, sizeof(db0)) != 0)
+ {
+ m_error.code = 705;
+ DBUG_RETURN(-1);
+ }
+
+ bool db_change = strcmp(db0, db1) != 0;
+ if (old_impl.getSchemaName(db0, sizeof(db0)) != 0)
+ {
+ m_error.code = 705;
+ DBUG_RETURN(-1);
+ }
+ if (impl.getSchemaName(db1, sizeof(db0)) != 0)
+ {
+ m_error.code = 705;
+ DBUG_RETURN(-1);
+ }
+
+ bool schema_change = strcmp(db0, db1) != 0;
+ if (db_change || schema_change)
+ {
+ if (renameBlobTables(old_impl, impl) != 0)
+ {
+ DBUG_RETURN(-1);
+ }
+ }
+ }
DBUG_RETURN(ret);
}
ERR_RETURN(getNdbError(), ret);
}
int
+NdbDictionaryImpl::renameBlobTables(const NdbTableImpl & old_tab,
+ const NdbTableImpl & new_tab)
+{
+ if (old_tab.m_noOfBlobs == 0)
+ return 0;
+
+ char db[MAX_TAB_NAME_SIZE];
+ char schema[MAX_TAB_NAME_SIZE];
+ new_tab.getDbName(db, sizeof(db));
+ new_tab.getSchemaName(schema, sizeof(schema));
+
+ for (unsigned i = 0; i < old_tab.m_columns.size(); i++)
+ {
+ NdbColumnImpl & c = *old_tab.m_columns[i];
+ if (! c.getBlobType() || c.getPartSize() == 0)
+ continue;
+ NdbTableImpl* _bt = c.m_blobTable;
+ if (_bt == NULL)
+ {
+ continue; // "force" mode on
+ }
+
+ NdbDictionary::Table& bt = * _bt->m_facade;
+ NdbDictionary::Table new_bt(bt);
+ new_bt.m_impl.setDbSchema(db, schema);
+
+ Uint32 changeMask = 0;
+ int ret = m_receiver.alterTable(m_ndb, bt.m_impl, new_bt.m_impl,changeMask);
+ if (ret != 0)
+ {
+ return ret;
+ }
+ assert(AlterTableReq::getNameFlag(changeMask) != 0);
+ }
+ return 0;
+}
+
+int
NdbDictInterface::alterTable(Ndb & ndb,
const NdbTableImpl &old_impl,
- NdbTableImpl &impl)
+ NdbTableImpl &impl,
+ Uint32 & change_mask)
{
int ret;
- Uint32 change_mask;
DBUG_ENTER("NdbDictInterface::alterTable");
@@ -3168,8 +3310,9 @@ NdbDictInterface::compChangeMask(const N
impl.m_internalName.c_str()));
if(impl.m_internalName != old_impl.m_internalName)
{
- if (unlikely(is_ndb_blob_table(old_impl.m_externalName.c_str()) ||
- is_ndb_blob_table(impl.m_externalName.c_str())))
+ bool old_blob = is_ndb_blob_table(old_impl.m_externalName.c_str());
+ bool new_blob = is_ndb_blob_table(impl.m_externalName.c_str());
+ if (unlikely(old_blob != new_blob))
{
/* Attempt to alter to/from Blob part table name */
DBUG_PRINT("info", ("Attempt to alter to/from Blob part table name"));
@@ -3260,7 +3403,9 @@ NdbDictInterface::compChangeMask(const N
col->m_autoIncrement || // ToDo: allow this?
(col->getBlobType() && col->getPartSize())
)
+ {
goto invalid_alter_table;
+ }
}
AlterTableReq::setAddAttrFlag(change_mask, true);
}
=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2011-02-23 13:20:20 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2011-05-12 09:40:20 +0000
@@ -185,14 +185,18 @@ public:
int validate(NdbError& error);
Uint32 m_primaryTableId;
- BaseString m_internalName;
- BaseString m_externalName;
- BaseString m_mysqlName;
+ BaseString m_internalName; // db/schema/table
+ BaseString m_externalName; // table
+ BaseString m_mysqlName; // db/table
UtilBuffer m_frm;
Vector<Uint32> m_fd;
Vector<Int32> m_range;
NdbDictionary::Object::FragmentType m_fragmentType;
+ int getDbName(char * buf, size_t len) const;
+ int getSchemaName(char * buf, size_t len) const;
+ void setDbSchema(const char * db, const char * schema);
+
/**
*
*/
@@ -617,7 +621,7 @@ public:
int createTable(class Ndb & ndb, NdbTableImpl &);
bool supportedAlterTable(const NdbTableImpl &,
NdbTableImpl &);
- int alterTable(class Ndb & ndb, const NdbTableImpl &, NdbTableImpl &);
+ int alterTable(class Ndb & ndb, const NdbTableImpl &, NdbTableImpl&, Uint32&);
void syncInternalName(Ndb & ndb, NdbTableImpl &impl);
int compChangeMask(const NdbTableImpl &old_impl,
const NdbTableImpl &impl,
@@ -828,6 +832,7 @@ public:
int dropTable(const char * name);
int dropTable(NdbTableImpl &);
int dropBlobTables(NdbTableImpl &);
+ int renameBlobTables(const NdbTableImpl &old_impl, const NdbTableImpl &impl);
int invalidateObject(NdbTableImpl &);
int removeCachedObject(NdbTableImpl &);
=== modified file 'storage/ndb/src/ndbapi/NdbOperationExec.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperationExec.cpp 2011-04-28 07:47:53 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperationExec.cpp 2011-05-11 13:31:44 +0000
@@ -1032,7 +1032,6 @@ NdbOperation::buildSignalsNdbRecord(Uint
readMask.set(attrId);
requestedCols++;
}
- theReceiver.m_record.m_column_count= requestedCols;
/* Are there any columns to read via NdbRecord? */
if (requestedCols > 0)
=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp 2011-05-05 11:06:08 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp 2011-05-11 13:31:44 +0000
@@ -4069,8 +4069,7 @@ NdbQueryOperationImpl::prepareReceiver()
0 /*key_size*/,
0 /*read_range_no*/,
getRowSize(),
- rowBuf,
- 0);
+ rowBuf);
m_resultStreams[i]->getReceiver().prepareSend();
}
// So that we can test for for buffer overrun.
=== modified file 'storage/ndb/src/ndbapi/NdbReceiver.cpp'
--- a/storage/ndb/src/ndbapi/NdbReceiver.cpp 2011-04-06 14:16:13 +0000
+++ b/storage/ndb/src/ndbapi/NdbReceiver.cpp 2011-05-11 13:31:44 +0000
@@ -60,7 +60,6 @@ NdbReceiver::init(ReceiverType type, boo
m_record.m_row_buffer= NULL;
m_record.m_row_offset= 0;
m_record.m_read_range_no= false;
- m_record.m_column_count= 0;
}
theFirstRecAttr = NULL;
theCurrentRecAttr = NULL;
@@ -216,8 +215,7 @@ NdbReceiver::calculate_batch_size(Uint32
void
NdbReceiver::do_setup_ndbrecord(const NdbRecord *ndb_record, Uint32 batch_size,
Uint32 key_size, Uint32 read_range_no,
- Uint32 rowsize, char *row_buffer,
- Uint32 column_count)
+ Uint32 rowsize, char *row_buffer)
{
m_using_ndb_record= true;
m_record.m_ndb_record= ndb_record;
@@ -225,7 +223,6 @@ NdbReceiver::do_setup_ndbrecord(const Nd
m_record.m_row_buffer= row_buffer;
m_record.m_row_offset= rowsize;
m_record.m_read_range_no= read_range_no;
- m_record.m_column_count= column_count;
}
//static
@@ -261,26 +258,6 @@ NdbReceiver::ndbrecord_rowsize(const Ndb
return rowsize;
}
-NdbRecAttr*
-NdbReceiver::copyout(NdbReceiver & dstRec){
- assert(!m_using_ndb_record);
- NdbRecAttr *src = m_rows[m_current_row++];
- NdbRecAttr *dst = dstRec.theFirstRecAttr;
- NdbRecAttr *start = src;
- Uint32 tmp = m_recattr.m_hidden_count;
- while(tmp--)
- src = src->next();
-
- while(dst){
- Uint32 len = src->get_size_in_bytes();
- dst->receive_data((Uint32*)src->aRef(), len);
- src = src->next();
- dst = dst->next();
- }
-
- return start;
-}
-
/**
* pad
* This function determines how much 'padding' should be applied
=== modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2011-04-27 10:48:16 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2011-05-11 13:31:44 +0000
@@ -395,8 +395,6 @@ NdbScanOperation::generatePackedReadAIs(
columnCount++;
}
- theReceiver.m_record.m_column_count= columnCount;
-
int result= 0;
/* Are there any columns to read via NdbRecord?
@@ -2335,8 +2333,7 @@ int NdbScanOperation::prepareSendScan(Ui
{
m_receivers[i]->do_setup_ndbrecord(m_attribute_record, batch_size,
key_size, m_read_range_no,
- rowsize, buf,
- theReceiver.m_record.m_column_count);
+ rowsize, buf);
buf+= bufsize;
}
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.1 branch (jonas:4189 to 4190) | Jonas Oreland | 12 May |