Merge lp:~linuxjedi/drizzle/trunk-bug-660619 into lp:~drizzle-trunk/drizzle/development

Proposed by Andrew Hutchings
Status: Merged
Approved by: Brian Aker
Approved revision: 1856
Merged at revision: 1857
Proposed branch: lp:~linuxjedi/drizzle/trunk-bug-660619
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 158 lines (+45/-24)
3 files modified
client/drizzledump.cc (+12/-2)
client/drizzledump_data.cc (+14/-4)
client/drizzledump_data.h (+19/-18)
To merge this branch: bzr merge lp:~linuxjedi/drizzle/trunk-bug-660619
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+38585@code.launchpad.net

Description of the change

DrizzleDump fixes:
* Fix error handling on --destination=database
* Stop --show-progress-size displaying by default
* Stop erroneous "),(" before "INSERT"
* Fix line length counting for --destination=database
* Fix some indentation

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

Small request, in the future please try to use "x" or something other then "i" as an iterator. As you get older "i" is very difficult to distinguish :)

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

lol, no problem :)

Revision history for this message
Jay Pipes (jaypipes) wrote :

also, destination is misspelled "destnation"

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

doh! and that will teach me not to copy/paste ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/drizzledump.cc'
2--- client/drizzledump.cc 2010-10-06 07:31:26 +0000
3+++ client/drizzledump.cc 2010-10-15 19:09:43 +0000
4@@ -207,6 +207,7 @@
5 }
6 sbuf.setConnection(destination_connection);
7 std::ostream sout(&sbuf);
8+ sout.exceptions(ios_base::badbit);
9
10 if (path.empty())
11 {
12@@ -219,8 +220,17 @@
13
14 for (i= database_store.begin(); i != database_store.end(); ++i)
15 {
16- DrizzleDumpDatabase *database= *i;
17- sout << *database;
18+ try
19+ {
20+ DrizzleDumpDatabase *database= *i;
21+ sout << *database;
22+ }
23+ catch (...)
24+ {
25+ std::cout << _("Error inserting into destnation database") << std::endl;
26+ if (not ignore_errors)
27+ maybe_exit(EX_DRIZZLEERR);
28+ }
29 }
30
31 if (path.empty())
32
33=== modified file 'client/drizzledump_data.cc'
34--- client/drizzledump_data.cc 2010-10-10 08:28:30 +0000
35+++ client/drizzledump_data.cc 2010-10-15 19:09:43 +0000
36@@ -222,6 +222,7 @@
37 bool new_insert= true;
38 bool first= true;
39 uint64_t rownr= 0;
40+ size_t byte_counter= 0;
41
42 drizzle_row_t row;
43
44@@ -256,18 +257,22 @@
45 while((row= drizzle_row_next(obj.result)))
46 {
47 rownr++;
48- if ((rownr % show_progress_size) == 0)
49+ if (verbose and (rownr % show_progress_size) == 0)
50 {
51 std::cerr << "-- " << rownr << _(" rows dumped for table ") << obj.table->displayName << std::endl;
52 }
53
54 size_t* row_sizes= drizzle_row_field_sizes(obj.result);
55- if (not first)
56+ for (uint32_t i= 0; i < drizzle_result_column_count(obj.result); i++)
57+ byte_counter+= row_sizes[i];
58+
59+ if (not first and not new_insert)
60 {
61 if (extended_insert)
62 os << "),(";
63 else
64 os << ");" << std::endl;
65+ byte_counter+= 3;
66 }
67 else
68 first= false;
69@@ -283,6 +288,7 @@
70 os << "IGNORE ";
71 }
72 os << "INTO `" << obj.table->displayName << "` VALUES (";
73+ byte_counter+= 28 + obj.table->displayName.length();
74 if (extended_insert)
75 new_insert= false;
76 }
77@@ -304,9 +310,13 @@
78 /* Hex blob processing or escape text */
79 if (((obj.table->fields[i]->type.compare("BLOB") == 0) or
80 (obj.table->fields[i]->type.compare("VARBINARY") == 0)))
81+ {
82 os << obj.convertHex((unsigned char*)row[i], row_sizes[i]);
83+ byte_counter+= row_sizes[i];
84+ }
85 else
86 os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'";
87+ byte_counter+= 3;
88 }
89 else
90 os << row[i];
91@@ -316,11 +326,11 @@
92 }
93 /* Break insert up if it is too long */
94 if (extended_insert and
95- ((os.tellp() - out_position) >= DRIZZLE_MAX_LINE_LENGTH))
96+ (byte_counter >= DRIZZLE_MAX_LINE_LENGTH))
97 {
98 os << ");" << std::endl;
99 new_insert= true;
100- out_position= os.tellp();
101+ byte_counter= 0;
102 }
103 }
104 os << ");" << std::endl;
105
106=== modified file 'client/drizzledump_data.h'
107--- client/drizzledump_data.h 2010-10-05 21:10:25 +0000
108+++ client/drizzledump_data.h 2010-10-15 19:09:43 +0000
109@@ -226,7 +226,8 @@
110
111 void writeString(std::string &str)
112 {
113- connection->queryNoResult(str);
114+ if (not connection->queryNoResult(str))
115+ throw 1;
116 }
117
118 void setConnection(DrizzleDumpConnection *conn) { connection= conn; }
119@@ -255,23 +256,23 @@
120
121 int sync()
122 {
123- size_t len = size_t(pptr() - pbase());
124- std::string temp(pbase(), len);
125-
126- /* Drop newlines */
127- temp.erase(std::remove(temp.begin(), temp.end(), '\n'), temp.end());
128-
129- if (temp.compare(0, 2, "--") == 0)
130- {
131- /* Drop comments */
132- setp(pbase(), epptr());
133- }
134- if (temp.find(";") != std::string::npos)
135- {
136- writeString(temp);
137- setp(pbase(), epptr());
138- }
139- return 0;
140+ size_t len = size_t(pptr() - pbase());
141+ std::string temp(pbase(), len);
142+
143+ /* Drop newlines */
144+ temp.erase(std::remove(temp.begin(), temp.end(), '\n'), temp.end());
145+
146+ if (temp.compare(0, 2, "--") == 0)
147+ {
148+ /* Drop comments */
149+ setp(pbase(), epptr());
150+ }
151+ if (temp.find(";") != std::string::npos)
152+ {
153+ writeString(temp);
154+ setp(pbase(), epptr());
155+ }
156+ return 0;
157 }
158 };
159