~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.cc

  • Committer: Brian Aker
  • Date: 2011-01-17 23:44:48 UTC
  • mfrom: (2088.1.5 drizzle-build)
  • Revision ID: brian@tangent.org-20110117234448-0tt6rd6fxa3csdaf
Rollup of all changes for identifier/error

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <assert.h>
24
24
#include <boost/lexical_cast.hpp>
25
25
#include "drizzled/identifier.h"
26
 
#include "drizzled/session.h"
27
26
#include "drizzled/internal/my_sys.h"
28
27
 
29
 
#include "drizzled/table.h"
 
28
#include <drizzled/error.h>
 
29
#include <drizzled/errmsg_print.h>
 
30
#include <drizzled/gettext.h>
 
31
 
 
32
#include <drizzled/table.h>
30
33
 
31
34
#include "drizzled/util/string.h"
32
35
#include "drizzled/util/tablename_to_filename.h"
42
45
namespace drizzled
43
46
{
44
47
 
45
 
class SchemaIdentifier;
 
48
class Table;
46
49
 
47
50
extern std::string drizzle_tmpdir;
48
51
extern pid_t current_pid;
49
52
 
 
53
namespace identifier {
 
54
class Schema;
 
55
 
50
56
static const char hexchars[]= "0123456789abcdef";
51
57
 
52
58
/*
61
67
  RETURN
62
68
    Table name length.
63
69
*/
64
 
uint32_t TableIdentifier::filename_to_tablename(const char *from, char *to, uint32_t to_length)
 
70
uint32_t Table::filename_to_tablename(const char *from, char *to, uint32_t to_length)
65
71
{
66
72
  uint32_t length= 0;
67
73
 
139
145
 
140
146
#endif
141
147
 
142
 
size_t TableIdentifier::build_tmptable_filename(std::string &buffer)
 
148
size_t Table::build_tmptable_filename(std::string &buffer)
143
149
{
144
150
  size_t tmpdir_length;
145
151
  ostringstream post_tmpdir_str;
157
163
  return buffer.length();
158
164
}
159
165
 
160
 
size_t TableIdentifier::build_tmptable_filename(std::vector<char> &buffer)
 
166
size_t Table::build_tmptable_filename(std::vector<char> &buffer)
161
167
{
162
168
  ostringstream post_tmpdir_str;
163
169
 
204
210
    path length on success, 0 on failure
205
211
*/
206
212
 
207
 
size_t TableIdentifier::build_table_filename(std::string &in_path, const std::string &in_db, const std::string &in_table_name, bool is_tmp)
 
213
size_t Table::build_table_filename(std::string &in_path, const std::string &in_db, const std::string &in_table_name, bool is_tmp)
208
214
{
209
215
  bool conversion_error= false;
210
216
 
238
244
  return in_path.length();
239
245
}
240
246
 
241
 
TableIdentifier::TableIdentifier(const drizzled::Table &table) :
242
 
  SchemaIdentifier(table.getShare()->getSchemaName()),
 
247
Table::Table(const drizzled::Table &table) :
 
248
  identifier::Schema(table.getShare()->getSchemaName()),
243
249
  type(table.getShare()->getTableType()),
244
250
  table_name(table.getShare()->getTableName())
245
251
{
249
255
  init();
250
256
}
251
257
 
252
 
void TableIdentifier::init()
 
258
void Table::init()
253
259
{
254
260
  switch (type) {
255
261
  case message::Table::FUNCTION:
279
285
}
280
286
 
281
287
 
282
 
const std::string &TableIdentifier::getPath() const
 
288
const std::string &Table::getPath() const
283
289
{
284
290
  return path;
285
291
}
286
292
 
287
 
void TableIdentifier::getSQLPath(std::string &sql_path) const  // @todo this is just used for errors, we should find a way to optimize it
 
293
void Table::getSQLPath(std::string &sql_path) const  // @todo this is just used for errors, we should find a way to optimize it
288
294
{
289
295
  switch (type) {
290
296
  case message::Table::FUNCTION:
305
311
  }
306
312
}
307
313
 
308
 
bool TableIdentifier::isValid() const
 
314
bool Table::isValid() const
309
315
{
310
 
  if (not SchemaIdentifier::isValid())
 
316
  if (not identifier::Schema::isValid())
311
317
    return false;
312
318
 
313
319
  bool error= false;
365
371
}
366
372
 
367
373
 
368
 
void TableIdentifier::copyToTableMessage(message::Table &message) const
 
374
void Table::copyToTableMessage(message::Table &message) const
369
375
{
370
376
  message.set_name(table_name);
371
377
  message.set_schema(getSchemaName());
372
378
}
373
379
 
374
 
void TableIdentifier::Key::set(size_t resize_arg, const std::string &a, const std::string &b)
 
380
void Table::Key::set(size_t resize_arg, const std::string &a, const std::string &b)
375
381
{
376
382
  key_buffer.resize(resize_arg);
377
383
 
382
388
  hash_value= hasher(key_buffer);
383
389
}
384
390
 
385
 
std::size_t hash_value(TableIdentifier const& b)
386
 
{
387
 
  return b.getHashValue();
388
 
}
389
 
 
390
 
std::size_t hash_value(TableIdentifier::Key const& b)
391
 
{
392
 
  return b.getHashValue();
393
 
}
394
 
 
 
391
std::size_t hash_value(Table const& b)
 
392
{
 
393
  return b.getHashValue();
 
394
}
 
395
 
 
396
std::size_t hash_value(Table::Key const& b)
 
397
{
 
398
  return b.getHashValue();
 
399
}
 
400
 
 
401
} /* namespace identifier */
395
402
} /* namespace drizzled */