List:Commits« Previous MessageNext Message »
From:tomas Date:March 1 2007 3:46am
Subject:bk commit into 5.1 tree (tomas:1.2439)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2439 07/03/01 09:46:22 tomas@stripped +6 -0
  tmp commit of ndb_restore patch

  storage/ndb/tools/restore/restore_main.cpp
    1.53 07/03/01 09:46:14 tomas@stripped +180 -12
    tmp commit of ndb_restore patch

  storage/ndb/tools/restore/consumer_printer.cpp
    1.8 07/03/01 09:46:14 tomas@stripped +13 -5
    tmp commit of ndb_restore patch

  storage/ndb/tools/restore/Restore.hpp
    1.28 07/03/01 09:46:14 tomas@stripped +5 -2
    tmp commit of ndb_restore patch

  storage/ndb/tools/restore/Restore.cpp
    1.46 07/03/01 09:46:14 tomas@stripped +10 -7
    tmp commit of ndb_restore patch

  storage/ndb/src/ndbapi/NdbRecAttr.cpp
    1.33 07/03/01 09:46:14 tomas@stripped +86 -24
    tmp commit of ndb_restore patch

  storage/ndb/include/ndbapi/NdbRecAttr.hpp
    1.20 07/03/01 09:46:14 tomas@stripped +19 -0
    tmp commit of ndb_restore patch

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.mysql.com
# Root:	/home/tomas/mysql-5.1-telco-6.1.4

--- 1.19/storage/ndb/include/ndbapi/NdbRecAttr.hpp	2006-12-24 02:20:08 +07:00
+++ 1.20/storage/ndb/include/ndbapi/NdbRecAttr.hpp	2007-03-01 09:46:14 +07:00
@@ -409,6 +409,25 @@ NdbRecAttr::setUNDEFINED()
 
 class NdbOut& operator <<(class NdbOut&, const NdbRecAttr &);
 
+class NdbRecAttrPrintFormat
+{
+public:
+  NdbRecAttrPrintFormat();
+  virtual ~NdbRecAttrPrintFormat();
+  const char *lines_terminated_by;
+  const char *fields_terminated_by;
+  const char *start_array_enclosure;
+  const char *end_array_enclosure;
+  const char *fields_enclosed_by;
+  const char *fields_optionally_enclosed_by;
+  const char *hex_prefix;
+  const char *null_string;
+  int hex_format;
+};
+NdbOut&
+ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
+                           const NdbRecAttrPrintFormat &f);
+
 #endif // ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
 
 #endif

--- 1.45/storage/ndb/tools/restore/Restore.cpp	2007-03-01 08:40:13 +07:00
+++ 1.46/storage/ndb/tools/restore/Restore.cpp	2007-03-01 09:46:14 +07:00
@@ -28,6 +28,8 @@
 
 #include "../../../../sql/ha_ndbcluster_tables.h"
 
+extern NdbRecAttrPrintFormat g_recattr_print_format;
+
 Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data
 Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data
 Uint64 Twiddle64(Uint64 in); // Byte shift 64-bit data
@@ -330,6 +332,7 @@ RestoreMetaData::markSysTables()
         if (table->getTableId() == (Uint32) id1) {
           if (table->isSysTable)
             blobTable->isSysTable = true;
+          blobTable->m_main_table = table;
           break;
         }
       }
@@ -427,6 +430,7 @@ TableS::TableS(Uint32 version, NdbTableI
   m_noOfRecords= 0;
   backupVersion = version;
   isSysTable = false;
+  m_main_table = NULL;
   
   for (int i = 0; i < tableImpl->getNoOfColumns(); i++)
     createAttr(tableImpl->getColumn(i));
@@ -896,6 +900,7 @@ bool RestoreDataIterator::readFragmentHe
     return false;
   }
 
+  info.setLevel(254);
   info << "_____________________________________________________" << endl
        << "Processing data in table: " << m_currentTable->getTableName() 
        << "(" << Header.TableId << ") fragment " 
@@ -1153,14 +1158,14 @@ operator<<(NdbOut& ndbout, const Attribu
 
   if (data.null)
   {
-    ndbout << "<NULL>";
+    ndbout << g_recattr_print_format.null_string;
     return ndbout;
   }
   
   NdbRecAttr tmprec(0);
-  tmprec.setup(desc.m_column, (char *)data.void_value);
+  tmprec.setup(desc.m_column, 0);
   tmprec.receive_data((Uint32*)data.void_value, data.size);
-  ndbout << tmprec;
+  ndbrecattr_print_formatted(ndbout, tmprec, g_recattr_print_format);
 
   return ndbout;
 }
@@ -1169,17 +1174,15 @@ operator<<(NdbOut& ndbout, const Attribu
 NdbOut& 
 operator<<(NdbOut& ndbout, const TupleS& tuple)
 {
-  ndbout << tuple.getTable()->getTableName() << "; ";
   for (int i = 0; i < tuple.getNoOfAttributes(); i++) 
   {
+    if (i > 0)
+      ndbout << g_recattr_print_format.fields_terminated_by;
     AttributeData * attr_data = tuple.getData(i);
     const AttributeDesc * attr_desc = tuple.getDesc(i);
     const AttributeS attr = {attr_desc, *attr_data};
     debug << i << " " << attr_desc->m_column->getName();
     ndbout << attr;
-    
-    if (i != (tuple.getNoOfAttributes() - 1))
-      ndbout << delimiter << " ";
   } // for
   return ndbout;
 }

--- 1.27/storage/ndb/tools/restore/Restore.hpp	2006-12-24 02:20:32 +07:00
+++ 1.28/storage/ndb/tools/restore/Restore.hpp	2007-03-01 09:46:14 +07:00
@@ -25,8 +25,6 @@
 #include <ndb_version.h>
 #include <version.h>
 
-static const char * delimiter = ";"; // Delimiter in file dump
-
 const int FileNameLenC = 256;
 const int TableNameLenC = 256;
 const int AttrNameLenC = 256;
@@ -142,6 +140,7 @@ class TableS {
   Uint64 m_max_auto_val;
 
   bool isSysTable;
+  TableS *m_main_table;
 
   Uint64 m_noOfRecords;
   Vector<FragmentInfo *> m_fragmentInfo;
@@ -237,6 +236,10 @@ public:
 
   bool getSysTable() const {
     return isSysTable;
+  }
+
+  const TableS *getMainTable() const {
+    return m_main_table;
   }
 
   TableS& operator=(TableS& org) ; 

--- 1.52/storage/ndb/tools/restore/restore_main.cpp	2007-01-06 07:21:25 +07:00
+++ 1.53/storage/ndb/tools/restore/restore_main.cpp	2007-03-01 09:46:14 +07:00
@@ -35,12 +35,20 @@ static int ga_backupId = 0;
 static bool ga_dont_ignore_systab_0 = false;
 static Vector<class BackupConsumer *> g_consumers;
 
-static const char* ga_backupPath = "." DIR_SEPARATOR;
+static const char* default_backupPath = "." DIR_SEPARATOR;
+static const char* ga_backupPath = default_backupPath;
 
 static const char *opt_nodegroup_map_str= 0;
 static unsigned opt_nodegroup_map_len= 0;
 static NODE_GROUP_MAP opt_nodegroup_map[MAX_NODE_GROUP_MAPS];
 #define OPT_NDB_NODEGROUP_MAP 'z'
+const char *opt_ndb_database= NULL;
+const char *opt_ndb_table= NULL;
+unsigned int opt_verbose;
+unsigned int opt_hex_format;
+Vector<BaseString> g_databases;
+Vector<BaseString> g_tables;
+NdbRecAttrPrintFormat g_recattr_print_format;
 
 NDB_STD_OPTS_VARS;
 
@@ -61,6 +69,24 @@ BaseString g_options("ndb_restore");
 
 const char *load_default_groups[]= { "mysql_cluster","ndb_restore",0 };
 
+enum ndb_restore_options {
+  OPT_PRINT= NDB_STD_OPTIONS_LAST,
+  OPT_PRINT_DATA,
+  OPT_PRINT_LOG,
+  OPT_PRINT_META,
+  OPT_BACKUP_PATH,
+  OPT_HEX_FORMAT,
+  OPT_FIELDS_ENCLOSED_BY,
+  OPT_FIELDS_TERMINATED_BY,
+  OPT_FIELDS_OPTIONALLY_ENCLOSED_BY,
+  OPT_LINES_TERMINATED_BY,
+  OPT_VERBOSE
+};
+const char *opt_fields_enclosed_by= "";
+const char *opt_fields_terminated_by= ";";
+const char *opt_fields_optionally_enclosed_by= "";
+const char *opt_lines_terminated_by= "\n";
+
 static struct my_option my_long_options[] =
 {
   NDB_STD_OPTS("ndb_restore"),
@@ -96,19 +122,19 @@ static struct my_option my_long_options[
     "(parallelism can be 1 to 1024)", 
     (gptr*) &ga_nParallelism, (gptr*) &ga_nParallelism, 0,
     GET_INT, REQUIRED_ARG, 128, 1, 1024, 0, 1, 0 },
-  { "print", 256, "Print data and log to stdout",
+  { "print", OPT_PRINT, "Print data and log to stdout",
     (gptr*) &_print, (gptr*) &_print, 0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
-  { "print_data", 257, "Print data to stdout", 
+  { "print_data", OPT_PRINT_DATA, "Print data to stdout", 
     (gptr*) &_print_data, (gptr*) &_print_data, 0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
-  { "print_meta", 258, "Print meta data to stdout",
+  { "print_meta", OPT_PRINT_META, "Print meta data to stdout",
     (gptr*) &_print_meta, (gptr*) &_print_meta,  0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
-  { "print_log", 259, "Print log to stdout",
+  { "print_log", OPT_PRINT_LOG, "Print log to stdout",
     (gptr*) &_print_log, (gptr*) &_print_log,  0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
-  { "backup_path", 260, "Path to backup files",
+  { "backup_path", OPT_BACKUP_PATH, "Path to backup files",
     (gptr*) &ga_backupPath, (gptr*) &ga_backupPath, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   { "dont_ignore_systab_0", 'f',
@@ -121,6 +147,30 @@ static struct my_option my_long_options[
     (gptr*) &opt_nodegroup_map_str,
     0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "fields-enclosed-by", OPT_FIELDS_ENCLOSED_BY, "",
+    (gptr*) &opt_fields_enclosed_by,
+    (gptr*) &opt_fields_enclosed_by,
+    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "fields-terminated-by", OPT_FIELDS_TERMINATED_BY, "",
+    (gptr*) &opt_fields_terminated_by,
+    (gptr*) &opt_fields_terminated_by,
+    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "fields-optionally-enclosed-by", OPT_FIELDS_OPTIONALLY_ENCLOSED_BY, "",
+    (gptr*) &opt_fields_optionally_enclosed_by,
+    (gptr*) &opt_fields_optionally_enclosed_by,
+    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "hex", OPT_HEX_FORMAT,
+    "print binary types in hex format", 
+    (gptr*) &opt_hex_format, (gptr*) &opt_hex_format, 0,
+    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+  { "lines-terminated-by", OPT_LINES_TERMINATED_BY, "",
+    (gptr*) &opt_lines_terminated_by,
+    (gptr*) &opt_lines_terminated_by,
+    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "verbose", OPT_VERBOSE,
+    "verbosity", 
+    (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0,
+    GET_INT, REQUIRED_ARG, 1, 0, 255, 0, 0, 0 },
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
@@ -255,20 +305,25 @@ get_one_option(int optid, const struct m
 #endif
   ndb_std_get_one_option(optid, opt, argument);
   switch (optid) {
+  case OPT_VERBOSE:
+    info.setThreshold(255-opt_verbose);
+    break;
   case 'n':
     if (ga_nodeId == 0)
     {
-      printf("Error in --nodeid,-n setting, see --help\n");
+      err << "Error in --nodeid,-n setting, see --help";
       exit(NDBT_ProgramExit(NDBT_WRONGARGS));
     }
+    info.setLevel(254);
     info << "Nodeid = " << ga_nodeId << endl;
     break;
   case 'b':
     if (ga_backupId == 0)
     {
-      printf("Error in --backupid,-b setting, see --help\n");
+      err << "Error in --backupid,-b setting, see --help";
       exit(NDBT_ProgramExit(NDBT_WRONGARGS));
     }
+    info.setLevel(254);
     info << "Backup Id = " << ga_backupId << endl;
     break;
   case OPT_NDB_NODEGROUP_MAP:
@@ -277,6 +332,8 @@ get_one_option(int optid, const struct m
       to nodegroup in new cluster.
     */
     opt_nodegroup_map_len= 0;
+
+    info.setLevel(254);
     info << "Analyse node group map" << endl;
     if (analyse_nodegroup_map(opt_nodegroup_map_str,
                               &opt_nodegroup_map[0]))
@@ -397,12 +454,53 @@ o verify nodegroup mapping
     BackupConsumer * c = restore;
     g_consumers.push_back(c);
   }
-  // Set backup file path
-  if (*pargv[0] != NULL) 
+  for (;;)
   {
-    ga_backupPath = *pargv[0];
+    int i= 0;
+    if (ga_backupPath == default_backupPath)
+    {
+      // Set backup file path
+      if ((*pargv)[i] == NULL)
+        break;
+      ga_backupPath = (*pargv)[i++];
+    }
+    if ((*pargv)[i] == NULL)
+      break;
+    g_databases.push_back((*pargv)[i++]);
+    while ((*pargv)[i] != NULL)
+    {
+      g_tables.push_back((*pargv)[i++]);
+    }
+    break;
   }
+  info.setLevel(254);
   info << "backup path = " << ga_backupPath << endl;
+  if (g_databases.size() > 0)
+  {
+    info << "Restoring only from database " << g_databases[0].c_str()
<< endl;
+    if (g_tables.size() > 0)
+      info << "Restoring only tables:";
+    for (unsigned i= 0; i < g_tables.size(); i++)
+    {
+      info << " " << g_tables[i].c_str();
+    }
+    if (g_tables.size() > 0)
+      info << endl;
+  }
+  g_recattr_print_format.fields_enclosed_by=
+    opt_fields_enclosed_by;
+  g_recattr_print_format.fields_terminated_by=
+    opt_fields_terminated_by;
+  g_recattr_print_format.fields_optionally_enclosed_by=
+    opt_fields_optionally_enclosed_by;
+  g_recattr_print_format.lines_terminated_by=
+    opt_lines_terminated_by;
+  if (g_recattr_print_format.fields_optionally_enclosed_by[0] == '\0')
+    g_recattr_print_format.null_string= "\\N";
+  else
+    g_recattr_print_format.null_string= "";
+  g_recattr_print_format.hex_prefix= "";
+  g_recattr_print_format.hex_format= opt_hex_format;
   return true;
 }
 
@@ -427,6 +525,65 @@ checkSysTable(const RestoreMetaData& met
   return checkSysTable(metaData[i]);
 }
 
+static inline bool
+checkDbAndTableName(const TableS* table)
+{
+  if (g_tables.size() == 0 &&
+      g_databases.size() == 0)
+    return true;
+  if (g_databases.size() == 0)
+    g_databases.push_back("TEST_DB");
+
+  // Filter on the main table name for indexes and blobs
+  const char *table_name;
+  const NdbTableImpl & tmptab = NdbTableImpl::getImpl(* table->m_dictTable);
+  if (table->getMainTable())
+    table_name= table->getMainTable()->getTableName();
+  else if ((int) tmptab.m_indexType !=
+           (int) NdbDictionary::Index::Undefined)
+    table_name= tmptab.m_primaryTable.c_str();
+  else
+    table_name= table->getTableName();
+
+  unsigned i;
+  for (i= 0; i < g_databases.size(); i++)
+  {
+    if (strncmp(table_name, g_databases[i].c_str(),
+                g_databases[i].length()) == 0 &&
+        table_name[g_databases[i].length()] == '/')
+    {
+      // we have a match
+      if (g_databases.size() > 1 || g_tables.size() == 0)
+        return true;
+      break;
+    }
+  }
+  if (i == g_databases.size())
+    return false; // no match found
+
+  while (*table_name != '/') table_name++;
+  table_name++;
+  while (*table_name != '/') table_name++;
+  table_name++;
+
+  for (i= 0; i < g_tables.size(); i++)
+  {
+    if (strcmp(table_name, g_tables[i].c_str()) == 0)
+    {
+      // we have a match
+      return true;
+    }
+  }
+  return false;
+}
+
+static inline bool
+checkDbAndTableName(const RestoreMetaData& metaData, uint i)
+{
+  assert(i < metaData.getNoOfTables());
+  return checkDbAndTableName(metaData[i]);
+}
+
 static void
 free_data_callback()
 {
@@ -557,6 +714,8 @@ main(int argc, char** argv)
   debug << "Restoring tables" << endl; 
   for(i = 0; i<metaData.getNoOfTables(); i++)
   {
+    if (!checkDbAndTableName(metaData, i))
+      continue;
     if (checkSysTable(metaData, i))
     {
       for(Uint32 j= 0; j < g_consumers.size(); j++)
@@ -604,6 +763,8 @@ main(int argc, char** argv)
 	const TupleS* tuple;
 	while ((tuple = dataIter.getNextTuple(res= 1)) != 0)
 	{
+          if (!checkDbAndTableName(tuple->getTable()))
+            continue;
 	  if (checkSysTable(tuple->getTable()))
 	    for(Uint32 i= 0; i < g_consumers.size(); i++) 
 	      g_consumers[i]->tuple(* tuple, fragmentId);
@@ -648,6 +809,8 @@ main(int argc, char** argv)
       const LogEntry * logEntry = 0;
       while ((logEntry = logIter.getNextLogEntry(res= 0)) != 0)
       {
+        if (!checkDbAndTableName(logEntry->m_table))
+          continue;
 	if (checkSysTable(logEntry->m_table))
 	  for(Uint32 i= 0; i < g_consumers.size(); i++)
 	    g_consumers[i]->logEntry(* logEntry);
@@ -667,6 +830,8 @@ main(int argc, char** argv)
     {
       for(i = 0; i<metaData.getNoOfTables(); i++)
       {
+        if (!checkDbAndTableName(metaData, i))
+          continue;
 	if (checkSysTable(metaData, i))
 	{
 	  for(Uint32 j= 0; j < g_consumers.size(); j++)
@@ -702,7 +867,10 @@ main(int argc, char** argv)
   }
   
   clearConsumers();
-  return NDBT_ProgramExit(NDBT_OK);
+  if (opt_verbose)
+    return NDBT_ProgramExit(NDBT_OK);
+  else
+    return 0;
 } // main
 
 template class Vector<BackupConsumer*>;

--- 1.32/storage/ndb/src/ndbapi/NdbRecAttr.cpp	2007-03-01 08:45:19 +07:00
+++ 1.33/storage/ndb/src/ndbapi/NdbRecAttr.cpp	2007-03-01 09:46:14 +07:00
@@ -138,8 +138,24 @@ NdbRecAttr::receive_data(const Uint32 * 
   return false;
 }
 
+NdbRecAttrPrintFormat::NdbRecAttrPrintFormat()
+{
+  fields_terminated_by= ";";
+  start_array_enclosure= "[";
+  end_array_enclosure= "]";
+  fields_enclosed_by= "";
+  fields_optionally_enclosed_by= "\"";
+  lines_terminated_by= "\n";
+  hex_prefix= "H'";
+  null_string= "[NULL]";
+  hex_format= 0;
+}
+NdbRecAttrPrintFormat::~NdbRecAttrPrintFormat() {};
+static const NdbRecAttrPrintFormat default_print_format;
+
 static void
-ndbrecattr_print_string(NdbOut& out, const char *type,
+ndbrecattr_print_string(NdbOut& out, const NdbRecAttrPrintFormat &f,
+                        const char *type, bool is_binary,
 			const char *aref, unsigned sz)
 {
   const unsigned char* ref = (const unsigned char*)aref;
@@ -150,6 +166,14 @@ ndbrecattr_print_string(NdbOut& out, con
     else break;
   if (sz == 0) return; // empty
 
+  if (is_binary && f.hex_format)
+  {
+    out.print("0x");
+    for (len=0; len < (int)sz; len++)
+      out.print("%02X", (int)ref[len]);
+    return;
+  }
+
   for (len=0; len < (int)sz && ref[i] != 0; len++)
     if (printable && !isprint((int)ref[i]))
       printable= 0;
@@ -168,37 +192,56 @@ ndbrecattr_print_string(NdbOut& out, con
     for (i= len+1; ref[i] != 0; i++)
     out.print("%u]",len-i);
     assert((int)sz > i);
-    ndbrecattr_print_string(out,type,aref+i,sz-i);
+    ndbrecattr_print_string(out,f,type,is_binary,aref+i,sz-i);
   }
 }
 
-NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
+NdbOut&
+ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
+                           const NdbRecAttrPrintFormat &f)
 {
   if (r.isNULL())
   {
-    out << "[NULL]";
+    out << f.null_string;
     return out;
   }
   
   const NdbDictionary::Column* c = r.getColumn();
   uint length = c->getLength();
-  if (length > 1)
-    out << "[";
-
-  for (Uint32 j = 0; j < length; j++) 
   {
-    if (j > 0)
-      out << " ";
-
+    const char *fields_optionally_enclosed_by;
+    if (f.fields_enclosed_by[0] == '\0')
+      fields_optionally_enclosed_by=
+        f.fields_optionally_enclosed_by;
+    else
+      fields_optionally_enclosed_by= "";
+    out << f.fields_enclosed_by;
+    Uint32 j;
     switch(r.getType()){
     case NdbDictionary::Column::Bigunsigned:
       out << r.u_64_value();
       break;
     case NdbDictionary::Column::Bit:
-      out << hex << "H'" << r.u_32_value() << dec;
+      for (j = (length-1)/32 + 1; j > 0; j--)
+        if (*((Uint32*)r.aRef() + j - 1))
+          break;
+      if (j == 0)
+      {
+        out << "0";
+        break;
+      }
+      out << f.hex_prefix << "0x";
+      for (; j > 0; j--)
+        out.print("%X", *((Uint32*)r.aRef() + j - 1));
       break;
     case NdbDictionary::Column::Unsigned:
-      out << *((Uint32*)r.aRef() + j);
+      if (length > 1)
+        out << f.start_array_enclosure;
+      out << *(Uint32*)r.aRef();
+      for (j = 1; j < length; j++)
+        out << " " << *((Uint32*)r.aRef() + j);
+      if (length > 1)
+        out << f.end_array_enclosure;
       break;
     case NdbDictionary::Column::Smallunsigned:
       out << r.u_short_value();
@@ -219,25 +262,33 @@ NdbOut& operator<<(NdbOut& out, const Nd
       out << (int) r.char_value();
       break;
     case NdbDictionary::Column::Binary:
+      out << fields_optionally_enclosed_by;
       j = r.get_size_in_bytes();
-      ndbrecattr_print_string(out,"Binary", r.aRef(), j);
+      ndbrecattr_print_string(out,f,"Binary", true, r.aRef(), j);
+      out << fields_optionally_enclosed_by;
       break;
     case NdbDictionary::Column::Char:
+      out << fields_optionally_enclosed_by;
       j = r.get_size_in_bytes();
-      ndbrecattr_print_string(out,"Char", r.aRef(), j);
+      ndbrecattr_print_string(out,f,"Char", false, r.aRef(), j);
+      out << fields_optionally_enclosed_by;
       break;
     case NdbDictionary::Column::Varchar:
     {
+      out << fields_optionally_enclosed_by;
       unsigned len = *(const unsigned char*)r.aRef();
-      ndbrecattr_print_string(out,"Varchar", r.aRef()+1,len);
+      ndbrecattr_print_string(out,f,"Varchar", false, r.aRef()+1,len);
       j = length;
+      out << fields_optionally_enclosed_by;
     }
     break;
     case NdbDictionary::Column::Varbinary:
     {
+      out << fields_optionally_enclosed_by;
       unsigned len = *(const unsigned char*)r.aRef();
-      ndbrecattr_print_string(out,"Varbinary", r.aRef()+1,len);
+      ndbrecattr_print_string(out,f,"Varbinary", true, r.aRef()+1,len);
       j = length;
+      out << fields_optionally_enclosed_by;
     }
     break;
     case NdbDictionary::Column::Float:
@@ -366,16 +417,26 @@ NdbOut& operator<<(NdbOut& out, const Nd
     break;
     case NdbDictionary::Column::Longvarchar:
     {
+      out << fields_optionally_enclosed_by;
       unsigned len = uint2korr(r.aRef());
-      ndbrecattr_print_string(out,"Longvarchar", r.aRef()+2,len);
+      ndbrecattr_print_string(out,f,"Longvarchar", false, r.aRef()+2,len);
       j = length;
+      out << fields_optionally_enclosed_by;
+    }
+    break;
+    case NdbDictionary::Column::Longvarbinary:
+    {
+      out << fields_optionally_enclosed_by;
+      unsigned len = uint2korr(r.aRef());
+      ndbrecattr_print_string(out,f,"Longvarbinary", true, r.aRef()+2,len);
+      j = length;
+      out << fields_optionally_enclosed_by;
     }
     break;
 
     case NdbDictionary::Column::Undefined:
     case NdbDictionary::Column::Mediumint:
     case NdbDictionary::Column::Mediumunsigned:
-    case NdbDictionary::Column::Longvarbinary:
     unknown:
     //default: /* no print functions for the rest, just print type */
     out << (int) r.getType();
@@ -384,14 +445,15 @@ NdbOut& operator<<(NdbOut& out, const Nd
       out << " " << j << " times";
     break;
     }
-  }
-
-  if (length > 1)
-  {
-    out << "]";
+    out << f.fields_enclosed_by;
   }
 
   return out;
+}
+
+NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
+{
+  return ndbrecattr_print_formatted(out, r, default_print_format);
 }
 
 Int64

--- 1.7/storage/ndb/tools/restore/consumer_printer.cpp	2006-12-24 02:20:32 +07:00
+++ 1.8/storage/ndb/tools/restore/consumer_printer.cpp	2007-03-01 09:46:14 +07:00
@@ -14,6 +14,8 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "consumer_printer.hpp"
+extern FilteredNdbOut info;
+extern NdbRecAttrPrintFormat g_recattr_print_format;
 
 bool
 BackupPrinter::table(const TableS & tab)
@@ -21,7 +23,8 @@ BackupPrinter::table(const TableS & tab)
   if (m_print || m_print_meta) 
   {
     m_ndbout << tab;
-    ndbout_c("Successfully printed table: %s", tab.m_dictTable->getName());
+    info.setLevel(1);
+    info << "Successfully printed table: ", tab.m_dictTable->getName();
   }
   return true;
 }
@@ -31,7 +34,11 @@ BackupPrinter::tuple(const TupleS & tup,
 {
   m_dataCount++;
   if (m_print || m_print_data)
-    m_ndbout << tup << endl;  
+  {
+    info.setLevel(254);
+    info << tup.getTable()->getTableName() << "; ";
+    m_ndbout << tup << g_recattr_print_format.lines_terminated_by;  
+  }
 }
 
 void
@@ -47,9 +54,10 @@ BackupPrinter::endOfLogEntrys()
 {
   if (m_print || m_print_log) 
   {
-    ndbout << "Printed " << m_dataCount << " tuples and "
-	   << m_logCount << " log entries" 
-	   << " to stdout." << endl;
+    info.setLevel(254);
+    info << "Printed " << m_dataCount << " tuples and "
+         << m_logCount << " log entries" 
+         << " to stdout." << endl;
   }
 }
 bool
Thread
bk commit into 5.1 tree (tomas:1.2439)tomas1 Mar