~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Lee Bieber
  • Date: 2010-12-23 23:11:00 UTC
  • mfrom: (2024.1.1 clean)
  • Revision ID: kalebral@gmail.com-20101223231100-0rqirgz7ugkl10yp
Merge Brian - session list cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include <fcntl.h>
29
29
 
 
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/epoch.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
47
 
49
48
using namespace std;
50
49
 
91
90
  if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
92
91
    return NULL;
93
92
 
94
 
  identifier::Table identifier(getTable()->getShare()->getSchemaName(),
 
93
  TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
95
94
                             getTable()->getShare()->getTableName(),
96
95
                             getTable()->getShare()->getType());
97
96
 
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(); }
213
212
 
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)
215
214
{
216
215
  return open(identifier.getPath().c_str(), mode, test_if_locked);
217
216
}
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
224
223
*/
225
 
int Cursor::ha_open(const identifier::Table &identifier,
 
224
int Cursor::ha_open(const TableIdentifier &identifier,
226
225
                    int mode,
227
226
                    int test_if_locked)
228
227
{
279
278
  if (stats.deleted < 10 || primary_key >= MAX_KEY ||
280
279
      !(getTable()->index_flags(primary_key) & HA_READ_ORDER))
281
280
  {
282
 
    error= startTableScan(1);
283
 
    if (error == 0)
284
 
    {
285
 
      while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
286
 
      (void) endTableScan();
287
 
    }
 
281
    (void) startTableScan(1);
 
282
    while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
 
283
    (void) endTableScan();
288
284
  }
289
285
  else
290
286
  {
291
287
    /* Find the first row through the primary key */
292
 
    error= startIndexScan(primary_key, 0);
293
 
    if (error == 0)
294
 
    {
295
 
      error=index_first(buf);
296
 
      (void) endIndexScan();
297
 
    }
 
288
    (void) startIndexScan(primary_key, 0);
 
289
    error=index_first(buf);
 
290
    (void) endIndexScan();
298
291
  }
299
292
  return error;
300
293
}
711
704
     */
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());
715
708
  }
716
709
 
717
710
  return result;
1312
1305
     * CREATE TABLE will commit the transaction containing
1313
1306
     * it).
1314
1307
     */
1315
 
    result= transaction_services.insertRecord(*session, *table);
 
1308
    result= transaction_services.insertRecord(session, table);
1316
1309
    break;
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.
1343
1336
       */
1344
 
      transaction_services.deleteRecord(*session, *table, true);
 
1337
      transaction_services.deleteRecord(session, table, true);
1345
1338
      /* 
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.
1349
1342
       */
1350
 
      transaction_services.finalizeStatementMessage(*session->getStatementMessage(), *session);
 
1343
      transaction_services.finalizeStatementMessage(*session->getStatementMessage(), session);
1351
1344
    }
1352
1345
    else
1353
1346
    {
1354
1347
      if (before_record == NULL)
1355
 
        result= transaction_services.insertRecord(*session, *table);
 
1348
        result= transaction_services.insertRecord(session, table);
1356
1349
      else
1357
 
        transaction_services.updateRecord(*session, *table, before_record, after_record);
 
1350
        transaction_services.updateRecord(session, table, before_record, after_record);
1358
1351
    }
1359
1352
    break;
1360
1353
  case SQLCOM_INSERT:
1367
1360
     * an update.
1368
1361
     */
1369
1362
    if (before_record == NULL)
1370
 
      result= transaction_services.insertRecord(*session, *table);
 
1363
      result= transaction_services.insertRecord(session, table);
1371
1364
    else
1372
 
      transaction_services.updateRecord(*session, *table, before_record, after_record);
 
1365
      transaction_services.updateRecord(session, table, before_record, after_record);
1373
1366
    break;
1374
1367
 
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);
1377
1370
    break;
1378
1371
 
1379
1372
  case SQLCOM_DELETE:
1380
 
    transaction_services.deleteRecord(*session, *table);
 
1373
    transaction_services.deleteRecord(session, table);
1381
1374
    break;
1382
1375
  default:
1383
1376
    break;