30
#include "drizzled/my_hash.h"
31
30
#include "drizzled/error.h"
31
#include "drizzled/field/epoch.h"
32
32
#include "drizzled/gettext.h"
33
#include "drizzled/internal/my_sys.h"
34
#include "drizzled/item/empty_string.h"
35
#include "drizzled/item/int.h"
36
#include "drizzled/lock.h"
37
#include "drizzled/message/table.h"
38
#include "drizzled/my_hash.h"
39
#include "drizzled/optimizer/cost_vector.h"
40
#include "drizzled/plugin/client.h"
41
#include "drizzled/plugin/event_observer.h"
42
#include "drizzled/plugin/storage_engine.h"
33
43
#include "drizzled/probes.h"
34
#include "drizzled/sql_parse.h"
35
#include "drizzled/optimizer/cost_vector.h"
36
44
#include "drizzled/session.h"
37
45
#include "drizzled/sql_base.h"
46
#include "drizzled/sql_parse.h"
38
47
#include "drizzled/transaction_services.h"
39
#include "drizzled/lock.h"
40
#include "drizzled/item/int.h"
41
#include "drizzled/item/empty_string.h"
42
#include "drizzled/field/timestamp.h"
43
#include "drizzled/message/table.pb.h"
44
#include "drizzled/plugin/client.h"
45
#include "drizzled/internal/my_sys.h"
46
#include "drizzled/plugin/event_observer.h"
48
49
using namespace std;
90
91
if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
93
TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
94
identifier::Table identifier(getTable()->getShare()->getSchemaName(),
94
95
getTable()->getShare()->getTableName(),
95
96
getTable()->getShare()->getType());
210
211
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
211
212
uint64_t Cursor::rowSize() { return getTable()->getRecordLength() + getTable()->sizeFields(); }
213
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
214
int Cursor::doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked)
215
216
return open(identifier.getPath().c_str(), mode, test_if_locked);
221
222
Try O_RDONLY if cannot open as O_RDWR
222
223
Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
224
int Cursor::ha_open(const TableIdentifier &identifier,
225
int Cursor::ha_open(const identifier::Table &identifier,
226
227
int test_if_locked)
278
279
if (stats.deleted < 10 || primary_key >= MAX_KEY ||
279
280
!(getTable()->index_flags(primary_key) & HA_READ_ORDER))
281
(void) startTableScan(1);
282
while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
283
(void) endTableScan();
282
error= startTableScan(1);
285
while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
286
(void) endTableScan();
287
291
/* Find the first row through the primary key */
288
(void) startIndexScan(primary_key, 0);
289
error=index_first(buf);
290
(void) endIndexScan();
292
error= startIndexScan(primary_key, 0);
295
error=index_first(buf);
296
(void) endIndexScan();
705
712
Session *const session= getTable()->in_use;
706
713
TransactionServices &transaction_services= TransactionServices::singleton();
707
transaction_services.truncateTable(session, getTable());
714
transaction_services.truncateTable(*session, *getTable());
1305
1312
* CREATE TABLE will commit the transaction containing
1308
result= transaction_services.insertRecord(session, table);
1315
result= transaction_services.insertRecord(*session, *table);
1310
1317
case SQLCOM_REPLACE:
1311
1318
case SQLCOM_REPLACE_SELECT:
1334
1341
* as the row to delete (this is the conflicting row), so
1335
1342
* we need to notify TransactionService to use that row.
1337
transaction_services.deleteRecord(session, table, true);
1344
transaction_services.deleteRecord(*session, *table, true);
1339
1346
* We set the "current" statement message to NULL. This triggers
1340
1347
* the replication services component to generate a new statement
1341
1348
* message for the inserted record which will come next.
1343
transaction_services.finalizeStatementMessage(*session->getStatementMessage(), session);
1350
transaction_services.finalizeStatementMessage(*session->getStatementMessage(), *session);
1347
1354
if (before_record == NULL)
1348
result= transaction_services.insertRecord(session, table);
1355
result= transaction_services.insertRecord(*session, *table);
1350
transaction_services.updateRecord(session, table, before_record, after_record);
1357
transaction_services.updateRecord(*session, *table, before_record, after_record);
1353
1360
case SQLCOM_INSERT:
1362
1369
if (before_record == NULL)
1363
result= transaction_services.insertRecord(session, table);
1370
result= transaction_services.insertRecord(*session, *table);
1365
transaction_services.updateRecord(session, table, before_record, after_record);
1372
transaction_services.updateRecord(*session, *table, before_record, after_record);
1368
1375
case SQLCOM_UPDATE:
1369
transaction_services.updateRecord(session, table, before_record, after_record);
1376
transaction_services.updateRecord(*session, *table, before_record, after_record);
1372
1379
case SQLCOM_DELETE:
1373
transaction_services.deleteRecord(session, table);
1380
transaction_services.deleteRecord(*session, *table);