Merge lp:~brianaker/drizzle/catalog-errors-to-error-system into lp:~drizzle-trunk/drizzle/development

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: 2493
Merged at revision: 2496
Proposed branch: lp:~brianaker/drizzle/catalog-errors-to-error-system
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 242 lines (+74/-47)
3 files modified
.bzrignore (+3/-0)
drizzled/plugin/catalog.cc (+10/-0)
plugin/catalog/engine.cc (+61/-47)
To merge this branch: bzr merge lp:~brianaker/drizzle/catalog-errors-to-error-system
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+89368@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-12-27 16:09:18 +0000
3+++ .bzrignore 2012-01-20 01:10:53 +0000
4@@ -392,3 +392,6 @@
5 libdrizzle-1.0/t/drizzle_query_st
6 libdrizzle-1.0/t/drizzle_result_st
7 libdrizzle-1.0/t/drizzle_st
8+drizzled/sql_yacc.hh
9+stripped_log
10+total_warning_count
11
12=== modified file 'drizzled/plugin/catalog.cc'
13--- drizzled/plugin/catalog.cc 2011-08-14 17:04:01 +0000
14+++ drizzled/plugin/catalog.cc 2012-01-20 01:10:53 +0000
15@@ -105,7 +105,9 @@
16 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
17 {
18 if (ref->drop(identifier))
19+ {
20 drop_count++;
21+ }
22 }
23 assert(drop_count < 2);
24
25@@ -155,12 +157,16 @@
26 bool plugin::Catalog::exist(const identifier::Catalog& identifier)
27 {
28 if (catalog::Cache::exist(identifier))
29+ {
30 return true;
31+ }
32
33 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
34 {
35 if (ref->exist(identifier))
36+ {
37 return true;
38+ }
39 }
40
41 return false;
42@@ -196,7 +202,9 @@
43 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
44 {
45 if ((message= ref->getMessage(identifier)))
46+ {
47 return message;
48+ }
49 }
50
51 return message;
52@@ -208,7 +216,9 @@
53 catalog::Instance::shared_ptr instance= catalog::Cache::find(identifier, error);
54
55 if (instance)
56+ {
57 return instance;
58+ }
59
60 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
61 {
62
63=== modified file 'plugin/catalog/engine.cc'
64--- plugin/catalog/engine.cc 2011-06-23 14:03:48 +0000
65+++ plugin/catalog/engine.cc 2012-01-20 01:10:53 +0000
66@@ -45,12 +45,14 @@
67
68 bool Engine::create(const drizzled::identifier::Catalog &identifier, drizzled::message::catalog::shared_ptr &message)
69 {
70- if (mkdir(identifier.getPath().c_str(), 0777) == -1)
71+ if (::mkdir(identifier.getPath().c_str(), 0777) == -1)
72+ {
73 return false;
74+ }
75
76 if (not writeFile(identifier, message))
77 {
78- rmdir(identifier.getPath().c_str());
79+ ::rmdir(identifier.getPath().c_str());
80
81 return false;
82 }
83@@ -65,23 +67,23 @@
84 file.append(CATALOG_OPT_EXT);
85
86 // No catalog file, no love from us.
87- if (access(file.c_str(), F_OK))
88- {
89- perror(file.c_str());
90- return false;
91- }
92-
93- if (unlink(file.c_str()))
94- {
95- perror(file.c_str());
96- return false;
97- }
98-
99- if (rmdir(identifier.getPath().c_str()))
100- {
101- perror(identifier.getPath().c_str());
102- //@todo If this happens, we want a report of it. For the moment I dump
103- //to stderr so I can catch it in Hudson.
104+ if (::access(file.c_str(), F_OK))
105+ {
106+ drizzled::sql_perror("access()", file);
107+ return false;
108+ }
109+
110+ if (::unlink(file.c_str()))
111+ {
112+ drizzled::sql_perror("unlink()", file);
113+ return false;
114+ }
115+
116+ if (::rmdir(identifier.getPath().c_str()))
117+ {
118+ drizzled::sql_perror("rmdir()", identifier.getPath());
119+ //@todo If this happens, we want a report of it. For the moment I dump to
120+ //stderr so I can catch it in Hudson.
121 drizzled::CachedDirectory dir(identifier.getPath());
122 }
123
124@@ -122,7 +124,9 @@
125 drizzled::message::catalog::shared_ptr message;
126
127 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
128+ {
129 continue;
130+ }
131
132 drizzled::identifier::Catalog identifier(entry->filename);
133
134@@ -131,11 +135,13 @@
135 messages.push_back(message);
136
137 if (drizzled::catalog::local_identifier() == identifier)
138+ {
139 found_local= true;
140+ }
141 }
142 }
143
144- if (not found_local)
145+ if (found_local == false)
146 {
147 messages.push_back(drizzled::catalog::local()->message());
148 }
149@@ -146,7 +152,6 @@
150 char file_tmp[FN_REFLEN];
151 std::string file(identifier.getPath());
152
153-
154 file.append(1, FN_LIBCHAR);
155 file.append(CATALOG_OPT_EXT);
156
157@@ -156,7 +161,7 @@
158
159 if (fd == -1)
160 {
161- perror(file_tmp);
162+ drizzled::sql_perror("mkstemp()", file_tmp);
163
164 return false;
165 }
166@@ -171,34 +176,43 @@
167 success= false;
168 }
169
170- if (not success)
171+ if (success == false)
172 {
173 drizzled::my_error(drizzled::ER_CORRUPT_CATALOG_DEFINITION, MYF(0), file.c_str(),
174 message->InitializationErrorString().empty() ? "unknown" : message->InitializationErrorString().c_str());
175
176- if (close(fd) == -1)
177- perror(file_tmp);
178-
179- if (unlink(file_tmp))
180- perror(file_tmp);
181-
182- return false;
183- }
184-
185- if (close(fd) == -1)
186- {
187- perror(file_tmp);
188-
189- if (unlink(file_tmp))
190- perror(file_tmp);
191-
192- return false;
193- }
194-
195- if (rename(file_tmp, file.c_str()) == -1)
196- {
197- if (unlink(file_tmp))
198- perror(file_tmp);
199+ if (::close(fd) == -1)
200+ {
201+ drizzled::sql_perror("close()", file_tmp);
202+ }
203+
204+ if (::unlink(file_tmp))
205+ {
206+ drizzled::sql_perror("unlink()", file_tmp);
207+ }
208+
209+ return false;
210+ }
211+
212+ if (::close(fd) == -1)
213+ {
214+ drizzled::sql_perror("close()", file_tmp);
215+
216+ if (::unlink(file_tmp))
217+ {
218+ drizzled::sql_perror("unlink()", file_tmp);
219+ }
220+
221+ return false;
222+ }
223+
224+ if (::rename(file_tmp, file.c_str()) == -1)
225+ {
226+ drizzled::sql_perror("rename()", file_tmp);
227+ if (::unlink(file_tmp))
228+ {
229+ drizzled::sql_perror("unlink()", file_tmp);
230+ }
231
232 return false;
233 }
234@@ -238,7 +252,7 @@
235 }
236 else
237 {
238- perror(path.c_str());
239+ drizzled::sql_perror("std::fstream::good()", path);
240 }
241
242 return drizzled::message::catalog::shared_ptr();