42
42
#include "drizzled/sql_base.h"
43
43
#include "drizzled/pthread_globals.h"
44
44
#include "drizzled/internal/my_pthread.h"
45
#include "drizzled/plugin/event_observer.h"
47
46
#include "drizzled/table.h"
48
47
#include "drizzled/table/shell.h"
425
422
blob_ptr_size(portable_sizeof_char_ptr),
426
423
db_low_byte_first(false),
429
event_observers(NULL)
431
427
private_key_for_cache= identifier.getKey();
432
428
assert(identifier.getPath().size()); // Since we are doing a create table, this should be a positive value
583
576
getTableMessage()->set_schema(identifier_arg.getSchemaName());
586
int TableShare::inner_parse_table_proto(Session& session, message::Table &table)
579
bool TableShare::parse_table_proto(Session& session, message::Table &table)
581
drizzled::error_t local_error= EE_OK;
590
583
if (! table.IsInitialized())
1261
1253
if (res != 0 && res != 3) /* @TODO Huh? */
1263
1255
my_error(ER_INVALID_DEFAULT, MYF(0), f->field_name);
1256
local_error= ER_INVALID_DEFAULT;
1269
1261
else if (f->real_type() == DRIZZLE_TYPE_ENUM && (f->flags & NOT_NULL_FLAG))
1502
1494
all_set.resize(_field_size);
1508
int TableShare::parse_table_proto(Session& session, message::Table &table)
1510
int local_error= inner_parse_table_proto(session, table);
1512
if (not local_error)
1518
open_table_error(local_error, open_errno, 0);
1497
return local_error != EE_OK;
1525
1501
Read table definition from a binary / text based .frm cursor
1548
1524
int TableShare::open_table_def(Session& session, const identifier::Table &identifier)
1556
message::table::shared_ptr table;
1558
local_error= plugin::StorageEngine::getTableDefinition(session, identifier, table);
1561
if (local_error != EEXIST)
1563
if (local_error > 0)
1570
if (not table->IsInitialized())
1578
local_error= parse_table_proto(session, *table);
1580
setTableCategory(TABLE_CATEGORY_USER);
1583
if (local_error && !error_given)
1586
open_table_error(error, (open_errno= errno), 0);
1526
drizzled::error_t local_error= EE_OK;
1528
message::table::shared_ptr table= plugin::StorageEngine::getTableMessage(session, identifier, local_error);
1530
if (table and table->IsInitialized())
1532
if (parse_table_proto(session, *table))
1534
local_error= ER_CORRUPT_TABLE_DEFINITION_UNKNOWN;
1535
my_error(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN, identifier);
1539
setTableCategory(TABLE_CATEGORY_USER);
1543
else if (table and not table->IsInitialized())
1545
local_error= ER_CORRUPT_TABLE_DEFINITION_UNKNOWN;
1546
my_error(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN, identifier);
1550
local_error= ER_TABLE_UNKNOWN;
1551
my_error(ER_TABLE_UNKNOWN, identifier);
1554
return static_cast<int>(local_error);
1841
1806
if (db_errno == ENOENT)
1843
my_error(ER_NO_SUCH_TABLE, MYF(0), db.str, table_name.str);
1808
identifier::Table identifier(db.str, table_name.str);
1809
my_error(ER_TABLE_UNKNOWN, identifier);
1971
1937
field_charset);
1972
1938
case DRIZZLE_TYPE_BLOB:
1973
1939
return new (&mem_root) Field_blob(ptr,
1979
1945
case DRIZZLE_TYPE_DECIMAL:
1980
1946
return new (&mem_root) Field_decimal(ptr,
1987
1953
case DRIZZLE_TYPE_DOUBLE:
1988
1954
return new (&mem_root) Field_double(ptr,