~ubuntu-branches/ubuntu/trusty/drizzle/trusty-updates

« back to all changes in this revision

Viewing changes to plugin/catalog/engine.cc

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2012-04-04 15:12:07 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120404151207-xwsgn1xegslle4p0
Tags: 1:7.1.32-rc-1
* New upstream release.
* Plugin-filtered-replicator upstream removed and will no longer be built.
* Updating d/*install files to accommodate upstream changes from drizzle7
  to drizzle
* Added symlink in libdrizzledmessage-dev to library
* libdrizzle: soname-bump
* Rename package drizzle-plugin-performance-dictionary to shorten package name
  (due to linitan warning package-has-long-file-name)
* Debian/control: removed unused substitution variable ${shlibs:Depends} for
  -dbg and -dev packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
bool 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
50
    return false;
 
51
  }
50
52
 
51
53
  if (not writeFile(identifier, message))
52
54
  {
53
 
    rmdir(identifier.getPath().c_str());
 
55
    ::rmdir(identifier.getPath().c_str());
54
56
 
55
57
    return false;
56
58
  }
65
67
  file.append(CATALOG_OPT_EXT);
66
68
 
67
69
  // No catalog file, no love from us.
68
 
  if (access(file.c_str(), F_OK))
69
 
  {
70
 
    perror(file.c_str());
71
 
    return false;
72
 
  }
73
 
 
74
 
  if (unlink(file.c_str()))
75
 
  {
76
 
    perror(file.c_str());
77
 
    return false;
78
 
  }
79
 
 
80
 
  if (rmdir(identifier.getPath().c_str()))
81
 
  {
82
 
    perror(identifier.getPath().c_str());
83
 
    //@todo If this happens, we want a report of it. For the moment I dump
84
 
    //to stderr so I can catch it in Hudson.
 
70
  if (::access(file.c_str(), F_OK))
 
71
  {
 
72
    drizzled::sql_perror("access()", file);
 
73
    return false;
 
74
  }
 
75
 
 
76
  if (::unlink(file.c_str()))
 
77
  {
 
78
    drizzled::sql_perror("unlink()", file);
 
79
    return false;
 
80
  }
 
81
 
 
82
  if (::rmdir(identifier.getPath().c_str()))
 
83
  {
 
84
    drizzled::sql_perror("rmdir()", identifier.getPath());
 
85
    //@todo If this happens, we want a report of it. For the moment I dump to
 
86
    //stderr so I can catch it in Hudson.
85
87
    drizzled::CachedDirectory dir(identifier.getPath());
86
88
  }
87
89
 
122
124
    drizzled::message::catalog::shared_ptr message;
123
125
 
124
126
    if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
 
127
    {
125
128
      continue;
 
129
    }
126
130
 
127
131
    drizzled::identifier::Catalog identifier(entry->filename);
128
132
 
131
135
      messages.push_back(message);
132
136
 
133
137
      if (drizzled::catalog::local_identifier() == identifier)
 
138
      {
134
139
        found_local= true;
 
140
      }
135
141
    }
136
142
  }
137
143
 
138
 
  if (not found_local)
 
144
  if (found_local == false)
139
145
  {
140
146
    messages.push_back(drizzled::catalog::local()->message());
141
147
  }
146
152
  char file_tmp[FN_REFLEN];
147
153
  std::string file(identifier.getPath());
148
154
 
149
 
 
150
155
  file.append(1, FN_LIBCHAR);
151
156
  file.append(CATALOG_OPT_EXT);
152
157
 
156
161
 
157
162
  if (fd == -1)
158
163
  {
159
 
    perror(file_tmp);
 
164
    drizzled::sql_perror("mkstemp()", file_tmp);
160
165
 
161
166
    return false;
162
167
  }
171
176
    success= false;
172
177
  }
173
178
 
174
 
  if (not success)
 
179
  if (success == false)
175
180
  {
176
181
    drizzled::my_error(drizzled::ER_CORRUPT_CATALOG_DEFINITION, MYF(0), file.c_str(),
177
182
                       message->InitializationErrorString().empty() ? "unknown" :  message->InitializationErrorString().c_str());
178
183
 
179
 
    if (close(fd) == -1)
180
 
      perror(file_tmp);
181
 
 
182
 
    if (unlink(file_tmp))
183
 
      perror(file_tmp);
184
 
 
185
 
    return false;
186
 
  }
187
 
 
188
 
  if (close(fd) == -1)
189
 
  {
190
 
    perror(file_tmp);
191
 
 
192
 
    if (unlink(file_tmp))
193
 
      perror(file_tmp);
194
 
 
195
 
    return false;
196
 
  }
197
 
 
198
 
  if (rename(file_tmp, file.c_str()) == -1)
199
 
  {
200
 
    if (unlink(file_tmp))
201
 
      perror(file_tmp);
 
184
    if (::close(fd) == -1)
 
185
    {
 
186
      drizzled::sql_perror("close()", file_tmp);
 
187
    }
 
188
 
 
189
    if (::unlink(file_tmp))
 
190
    {
 
191
      drizzled::sql_perror("unlink()", file_tmp);
 
192
    }
 
193
 
 
194
    return false;
 
195
  }
 
196
 
 
197
  if (::close(fd) == -1)
 
198
  {
 
199
    drizzled::sql_perror("close()", file_tmp);
 
200
 
 
201
    if (::unlink(file_tmp))
 
202
    {
 
203
      drizzled::sql_perror("unlink()", file_tmp);
 
204
    }
 
205
 
 
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
    }
202
216
 
203
217
    return false;
204
218
  }
238
252
  }
239
253
  else
240
254
  {
241
 
    perror(path.c_str());
 
255
    drizzled::sql_perror("std::fstream::good()", path);
242
256
  }
243
257
 
244
258
  return drizzled::message::catalog::shared_ptr();