List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:May 12 2011 7:21am
Subject:bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3335)
View as plain text  
#At file:///data0/magnus/mysql/5.5-cluster/ based on revid:magnus.blaudd@strippedx

 3335 Magnus Blåudd	2011-05-12 [merge]
      Merge 7.0 -> 5.5-cluster

    modified:
      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/ndbapi/NdbOperationExec.cpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbReceiver.cpp
      storage/ndb/src/ndbapi/NdbScanOperation.cpp
=== 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-04 09:45:35 +0000
+++ b/storage/ndb/src/common/portlib/Makefile.am	2011-05-12 07:21:14 +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/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: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3335) Magnus Blåudd12 May