~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/transaction_reader.cc

  • Committer: Brian Aker
  • Date: 2009-11-12 16:57:30 UTC
  • mfrom: (1143.2.37 transaction-log)
  • Revision ID: brian@gaz-20091112165730-drc1242xr96jampa
Jay's replication patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
using namespace drizzled;
44
44
using namespace google;
45
45
 
 
46
static const char *replace_with_spaces= "\n\r";
 
47
 
46
48
static void printStatement(const message::Statement &statement)
47
49
{
48
50
  vector<string> sql_strings;
49
51
 
50
52
  message::transformStatementToSql(statement, sql_strings, message::DRIZZLE);
51
53
 
52
 
  vector<string>::iterator sql_string_iter= sql_strings.begin();
53
 
  const std::string newline= "\n";
54
 
  while (sql_string_iter != sql_strings.end())
 
54
  for (vector<string>::iterator sql_string_iter= sql_strings.begin();
 
55
       sql_string_iter != sql_strings.end();
 
56
       ++sql_string_iter)
55
57
  {
56
58
    string &sql= *sql_string_iter;
 
59
 
57
60
    /* 
58
 
     * Replace \n with spaces so that SQL statements 
 
61
     * Replace \n and \r with spaces so that SQL statements 
59
62
     * are always on a single line 
60
63
     */
61
 
    while (sql.find(newline) != std::string::npos)
62
 
      sql.replace(sql.find(newline), 1, " ");
 
64
    {
 
65
      string::size_type found= sql.find_first_of(replace_with_spaces);
 
66
      while (found != string::npos)
 
67
      {
 
68
        sql[found]= ' ';
 
69
        found= sql.find_first_of(replace_with_spaces, found);
 
70
      }
 
71
    }
 
72
 
 
73
    /*
 
74
     * Embedded NUL characters are a pain in the ass.
 
75
     */
 
76
    {
 
77
      string::size_type found= sql.find_first_of('\0');
 
78
      while (found != string::npos)
 
79
      {
 
80
        sql[found]= '\\';
 
81
        sql.insert(found + 1, 1, '0');
 
82
        found= sql.find_first_of('\0', found);
 
83
      }
 
84
    }
63
85
 
64
86
    cout << sql << ';' << endl;
65
 
    ++sql_string_iter;
66
87
  }
67
88
}
68
89