~posulliv/drizzle/memcached_applier

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Jay Pipes
  • Date: 2009-08-03 14:23:22 UTC
  • mfrom: (1039.2.68 staging)
  • mto: This revision was merged to the branch mainline in revision 1078.
  • Revision ID: jpipes@serialcoder-20090803142322-1g67h7su9mocg9ig
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/error.h>
21
21
#include <drizzled/gettext.h>
22
22
 
23
 
#include <drizzled/semi_join_table.h>
24
23
#include <drizzled/nested_join.h>
25
24
#include <drizzled/sql_parse.h>
26
25
#include <drizzled/item/sum.h>
40
39
#include <drizzled/item/float.h>
41
40
#include <drizzled/item/null.h>
42
41
 
 
42
#include <drizzled/table_proto.h>
 
43
 
43
44
#include <string>
44
45
#include <vector>
45
46
#include <algorithm>
92
93
  return name + strlen(name);
93
94
}
94
95
 
95
 
TABLE_CATEGORY get_table_category(const LEX_STRING *db, const LEX_STRING *name)
 
96
static TABLE_CATEGORY get_table_category(const LEX_STRING *db)
96
97
{
97
98
  assert(db != NULL);
98
 
  assert(name != NULL);
99
99
 
100
100
  if ((db->length == INFORMATION_SCHEMA_NAME.length()) &&
101
101
      (my_strcasecmp(system_charset_info,
274
274
  return default_item;
275
275
}
276
276
 
277
 
static int parse_table_proto(Session *session,
278
 
                             drizzled::message::Table &table,
279
 
                             TableShare *share)
 
277
int parse_table_proto(Session *session,
 
278
                      drizzled::message::Table &table,
 
279
                      TableShare *share)
280
280
{
281
281
  int error= 0;
282
282
  handler *handler_file= NULL;
283
283
 
284
284
  {
285
 
    LEX_STRING engine_name= { (char*)table.engine().name().c_str(),
286
 
                              strlen(table.engine().name().c_str()) };
287
 
    share->storage_engine= ha_resolve_by_name(session, &engine_name);
 
285
    share->storage_engine= ha_resolve_by_name(session, table.engine().name());
288
286
  }
289
287
 
290
288
  drizzled::message::Table::TableOptions table_options;
1232
1230
{
1233
1231
  int error;
1234
1232
  bool error_given;
1235
 
  string proto_path("");
1236
1233
 
1237
1234
  error= 1;
1238
1235
  error_given= 0;
1239
1236
 
1240
 
  proto_path.reserve(FN_REFLEN);
1241
 
  proto_path.append(share->normalized_path.str);
1242
 
 
1243
 
  proto_path.append(".dfe");
1244
 
 
1245
1237
  drizzled::message::Table table;
1246
1238
 
1247
 
  if ((error= drizzle_read_table_proto(proto_path.c_str(), &table)))
 
1239
  error= StorageEngine::getTableProto(share->normalized_path.str, &table);
 
1240
 
 
1241
  if (error != EEXIST)
1248
1242
  {
1249
1243
    if (error>0)
1250
1244
    {
1263
1257
 
1264
1258
  error= parse_table_proto(session, table, share);
1265
1259
 
1266
 
  share->table_category= get_table_category(& share->db, & share->table_name);
 
1260
  share->table_category= get_table_category(& share->db);
1267
1261
 
1268
1262
  if (!error)
1269
1263
    session->status_var.opened_shares++;
1655
1649
} /* open_table_error */
1656
1650
 
1657
1651
 
1658
 
TYPELIB *typelib(MEM_ROOT *mem_root, vector<String*> &strings)
 
1652
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings)
1659
1653
{
1660
1654
  TYPELIB *result= (TYPELIB*) alloc_root(mem_root, sizeof(TYPELIB));
1661
1655
  if (!result)
1662
1656
    return 0;
1663
 
  result->count= strings.size();
 
1657
  result->count= strings.elements;
1664
1658
  result->name= "";
1665
1659
  uint32_t nbytes= (sizeof(char*) + sizeof(uint32_t)) * (result->count + 1);
1666
1660
  
1669
1663
    
1670
1664
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
1671
1665
 
1672
 
  vector<String*>::iterator it= strings.begin();
1673
 
  for (int i= 0; it != strings.end(); ++it, ++i )
 
1666
  List_iterator<String> it(strings);
 
1667
  String *tmp;
 
1668
  for (uint32_t i= 0; (tmp= it++); i++)
1674
1669
  {
1675
 
    result->type_names[i]= (*it)->c_ptr();
1676
 
    result->type_lengths[i]= (*it)->length();
 
1670
    result->type_names[i]= tmp->ptr();
 
1671
    result->type_lengths[i]= tmp->length();
1677
1672
  }
1678
1673
 
1679
1674
  result->type_names[result->count]= 0;   // End marker