43
43
using namespace drizzled;
44
44
using namespace google;
46
static const char *replace_with_spaces= "\n\r";
46
48
static void printStatement(const message::Statement &statement)
48
50
vector<string> sql_strings;
50
52
message::transformStatementToSql(statement, sql_strings, message::DRIZZLE);
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
58
string &sql= *sql_string_iter;
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
61
while (sql.find(newline) != std::string::npos)
62
sql.replace(sql.find(newline), 1, " ");
65
string::size_type found= sql.find_first_of(replace_with_spaces);
66
while (found != string::npos)
69
found= sql.find_first_of(replace_with_spaces, found);
74
* Embedded NUL characters are a pain in the ass.
77
string::size_type found= sql.find_first_of('\0');
78
while (found != string::npos)
81
sql.insert(found + 1, 1, '0');
82
found= sql.find_first_of('\0', found);
64
86
cout << sql << ';' << endl;