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
=== modified file '.bzrignore'
--- .bzrignore 2011-12-27 16:09:18 +0000
+++ .bzrignore 2012-01-20 01:10:53 +0000
@@ -392,3 +392,6 @@
392libdrizzle-1.0/t/drizzle_query_st392libdrizzle-1.0/t/drizzle_query_st
393libdrizzle-1.0/t/drizzle_result_st393libdrizzle-1.0/t/drizzle_result_st
394libdrizzle-1.0/t/drizzle_st394libdrizzle-1.0/t/drizzle_st
395drizzled/sql_yacc.hh
396stripped_log
397total_warning_count
395398
=== modified file 'drizzled/plugin/catalog.cc'
--- drizzled/plugin/catalog.cc 2011-08-14 17:04:01 +0000
+++ drizzled/plugin/catalog.cc 2012-01-20 01:10:53 +0000
@@ -105,7 +105,9 @@
105 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())105 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
106 {106 {
107 if (ref->drop(identifier))107 if (ref->drop(identifier))
108 {
108 drop_count++;109 drop_count++;
110 }
109 }111 }
110 assert(drop_count < 2);112 assert(drop_count < 2);
111113
@@ -155,12 +157,16 @@
155bool plugin::Catalog::exist(const identifier::Catalog& identifier)157bool plugin::Catalog::exist(const identifier::Catalog& identifier)
156{158{
157 if (catalog::Cache::exist(identifier))159 if (catalog::Cache::exist(identifier))
160 {
158 return true;161 return true;
162 }
159163
160 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())164 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
161 {165 {
162 if (ref->exist(identifier))166 if (ref->exist(identifier))
167 {
163 return true;168 return true;
169 }
164 }170 }
165171
166 return false;172 return false;
@@ -196,7 +202,9 @@
196 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())202 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
197 {203 {
198 if ((message= ref->getMessage(identifier)))204 if ((message= ref->getMessage(identifier)))
205 {
199 return message;206 return message;
207 }
200 }208 }
201209
202 return message;210 return message;
@@ -208,7 +216,9 @@
208 catalog::Instance::shared_ptr instance= catalog::Cache::find(identifier, error);216 catalog::Instance::shared_ptr instance= catalog::Cache::find(identifier, error);
209217
210 if (instance)218 if (instance)
219 {
211 return instance;220 return instance;
221 }
212222
213 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())223 BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
214 {224 {
215225
=== modified file 'plugin/catalog/engine.cc'
--- plugin/catalog/engine.cc 2011-06-23 14:03:48 +0000
+++ plugin/catalog/engine.cc 2012-01-20 01:10:53 +0000
@@ -45,12 +45,14 @@
4545
46bool Engine::create(const drizzled::identifier::Catalog &identifier, drizzled::message::catalog::shared_ptr &message)46bool Engine::create(const drizzled::identifier::Catalog &identifier, drizzled::message::catalog::shared_ptr &message)
47{47{
48 if (mkdir(identifier.getPath().c_str(), 0777) == -1)48 if (::mkdir(identifier.getPath().c_str(), 0777) == -1)
49 {
49 return false;50 return false;
51 }
5052
51 if (not writeFile(identifier, message))53 if (not writeFile(identifier, message))
52 {54 {
53 rmdir(identifier.getPath().c_str());55 ::rmdir(identifier.getPath().c_str());
5456
55 return false;57 return false;
56 }58 }
@@ -65,23 +67,23 @@
65 file.append(CATALOG_OPT_EXT);67 file.append(CATALOG_OPT_EXT);
6668
67 // No catalog file, no love from us.69 // No catalog file, no love from us.
68 if (access(file.c_str(), F_OK))70 if (::access(file.c_str(), F_OK))
69 {71 {
70 perror(file.c_str());72 drizzled::sql_perror("access()", file);
71 return false;73 return false;
72 }74 }
7375
74 if (unlink(file.c_str()))76 if (::unlink(file.c_str()))
75 {77 {
76 perror(file.c_str());78 drizzled::sql_perror("unlink()", file);
77 return false;79 return false;
78 }80 }
7981
80 if (rmdir(identifier.getPath().c_str()))82 if (::rmdir(identifier.getPath().c_str()))
81 {83 {
82 perror(identifier.getPath().c_str());84 drizzled::sql_perror("rmdir()", identifier.getPath());
83 //@todo If this happens, we want a report of it. For the moment I dump85 //@todo If this happens, we want a report of it. For the moment I dump to
84 //to stderr so I can catch it in Hudson.86 //stderr so I can catch it in Hudson.
85 drizzled::CachedDirectory dir(identifier.getPath());87 drizzled::CachedDirectory dir(identifier.getPath());
86 }88 }
8789
@@ -122,7 +124,9 @@
122 drizzled::message::catalog::shared_ptr message;124 drizzled::message::catalog::shared_ptr message;
123125
124 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))126 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
127 {
125 continue;128 continue;
129 }
126130
127 drizzled::identifier::Catalog identifier(entry->filename);131 drizzled::identifier::Catalog identifier(entry->filename);
128132
@@ -131,11 +135,13 @@
131 messages.push_back(message);135 messages.push_back(message);
132136
133 if (drizzled::catalog::local_identifier() == identifier)137 if (drizzled::catalog::local_identifier() == identifier)
138 {
134 found_local= true;139 found_local= true;
140 }
135 }141 }
136 }142 }
137143
138 if (not found_local)144 if (found_local == false)
139 {145 {
140 messages.push_back(drizzled::catalog::local()->message());146 messages.push_back(drizzled::catalog::local()->message());
141 }147 }
@@ -146,7 +152,6 @@
146 char file_tmp[FN_REFLEN];152 char file_tmp[FN_REFLEN];
147 std::string file(identifier.getPath());153 std::string file(identifier.getPath());
148154
149
150 file.append(1, FN_LIBCHAR);155 file.append(1, FN_LIBCHAR);
151 file.append(CATALOG_OPT_EXT);156 file.append(CATALOG_OPT_EXT);
152157
@@ -156,7 +161,7 @@
156161
157 if (fd == -1)162 if (fd == -1)
158 {163 {
159 perror(file_tmp);164 drizzled::sql_perror("mkstemp()", file_tmp);
160165
161 return false;166 return false;
162 }167 }
@@ -171,34 +176,43 @@
171 success= false;176 success= false;
172 }177 }
173178
174 if (not success)179 if (success == false)
175 {180 {
176 drizzled::my_error(drizzled::ER_CORRUPT_CATALOG_DEFINITION, MYF(0), file.c_str(),181 drizzled::my_error(drizzled::ER_CORRUPT_CATALOG_DEFINITION, MYF(0), file.c_str(),
177 message->InitializationErrorString().empty() ? "unknown" : message->InitializationErrorString().c_str());182 message->InitializationErrorString().empty() ? "unknown" : message->InitializationErrorString().c_str());
178183
179 if (close(fd) == -1)184 if (::close(fd) == -1)
180 perror(file_tmp);185 {
181186 drizzled::sql_perror("close()", file_tmp);
182 if (unlink(file_tmp))187 }
183 perror(file_tmp);188
184189 if (::unlink(file_tmp))
185 return false;190 {
186 }191 drizzled::sql_perror("unlink()", file_tmp);
187192 }
188 if (close(fd) == -1)193
189 {194 return false;
190 perror(file_tmp);195 }
191196
192 if (unlink(file_tmp))197 if (::close(fd) == -1)
193 perror(file_tmp);198 {
194199 drizzled::sql_perror("close()", file_tmp);
195 return false;200
196 }201 if (::unlink(file_tmp))
197202 {
198 if (rename(file_tmp, file.c_str()) == -1)203 drizzled::sql_perror("unlink()", file_tmp);
199 {204 }
200 if (unlink(file_tmp))205
201 perror(file_tmp);206 return false;
207 }
208
209 if (::rename(file_tmp, file.c_str()) == -1)
210 {
211 drizzled::sql_perror("rename()", file_tmp);
212 if (::unlink(file_tmp))
213 {
214 drizzled::sql_perror("unlink()", file_tmp);
215 }
202216
203 return false;217 return false;
204 }218 }
@@ -238,7 +252,7 @@
238 }252 }
239 else253 else
240 {254 {
241 perror(path.c_str());255 drizzled::sql_perror("std::fstream::good()", path);
242 }256 }
243257
244 return drizzled::message::catalog::shared_ptr();258 return drizzled::message::catalog::shared_ptr();