1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
30
#include "drizzled/my_hash.h"
30
31
#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"
33
#include "drizzled/probes.h"
34
#include "drizzled/sql_parse.h"
39
35
#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"
43
#include "drizzled/probes.h"
44
36
#include "drizzled/session.h"
45
37
#include "drizzled/sql_base.h"
46
#include "drizzled/sql_parse.h"
47
38
#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"
49
48
using namespace std;
91
90
if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
94
identifier::Table identifier(getTable()->getShare()->getSchemaName(),
93
TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
95
94
getTable()->getShare()->getTableName(),
96
95
getTable()->getShare()->getType());
211
210
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
212
211
uint64_t Cursor::rowSize() { return getTable()->getRecordLength() + getTable()->sizeFields(); }
214
int Cursor::doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked)
213
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
216
215
return open(identifier.getPath().c_str(), mode, test_if_locked);
222
221
Try O_RDONLY if cannot open as O_RDWR
223
222
Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
225
int Cursor::ha_open(const identifier::Table &identifier,
224
int Cursor::ha_open(const TableIdentifier &identifier,
227
226
int test_if_locked)
279
278
if (stats.deleted < 10 || primary_key >= MAX_KEY ||
280
279
!(getTable()->index_flags(primary_key) & HA_READ_ORDER))
282
error= startTableScan(1);
285
while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
286
(void) endTableScan();
281
(void) startTableScan(1);
282
while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
283
(void) endTableScan();
291
287
/* Find the first row through the primary key */
292
error= startIndexScan(primary_key, 0);
295
error=index_first(buf);
296
(void) endIndexScan();
288
(void) startIndexScan(primary_key, 0);
289
error=index_first(buf);
290
(void) endIndexScan();
712
705
Session *const session= getTable()->in_use;
713
706
TransactionServices &transaction_services= TransactionServices::singleton();
714
transaction_services.truncateTable(*session, *getTable());
707
transaction_services.truncateTable(session, getTable());
915
908
This method (or an overriding one in a derived class) must check for
916
session->getKilled() and return HA_POS_ERROR if it is not zero. This is required
909
session->killed and return HA_POS_ERROR if it is not zero. This is required
917
910
for a user to be able to interrupt the calculation by killing the
918
911
connection/query.
1312
1305
* CREATE TABLE will commit the transaction containing
1315
result= transaction_services.insertRecord(*session, *table);
1308
result= transaction_services.insertRecord(session, table);
1317
1310
case SQLCOM_REPLACE:
1318
1311
case SQLCOM_REPLACE_SELECT:
1341
1334
* as the row to delete (this is the conflicting row), so
1342
1335
* we need to notify TransactionService to use that row.
1344
transaction_services.deleteRecord(*session, *table, true);
1337
transaction_services.deleteRecord(session, table, true);
1346
1339
* We set the "current" statement message to NULL. This triggers
1347
1340
* the replication services component to generate a new statement
1348
1341
* message for the inserted record which will come next.
1350
transaction_services.finalizeStatementMessage(*session->getStatementMessage(), *session);
1343
transaction_services.finalizeStatementMessage(*session->getStatementMessage(), session);
1354
1347
if (before_record == NULL)
1355
result= transaction_services.insertRecord(*session, *table);
1348
result= transaction_services.insertRecord(session, table);
1357
transaction_services.updateRecord(*session, *table, before_record, after_record);
1350
transaction_services.updateRecord(session, table, before_record, after_record);
1360
1353
case SQLCOM_INSERT:
1369
1362
if (before_record == NULL)
1370
result= transaction_services.insertRecord(*session, *table);
1363
result= transaction_services.insertRecord(session, table);
1372
transaction_services.updateRecord(*session, *table, before_record, after_record);
1365
transaction_services.updateRecord(session, table, before_record, after_record);
1375
1368
case SQLCOM_UPDATE:
1376
transaction_services.updateRecord(*session, *table, before_record, after_record);
1369
transaction_services.updateRecord(session, table, before_record, after_record);
1379
1372
case SQLCOM_DELETE:
1380
transaction_services.deleteRecord(*session, *table);
1373
transaction_services.deleteRecord(session, table);