~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Brian Aker
  • Date: 2011-01-25 07:22:15 UTC
  • mfrom: (2109.1.7 drizzle-build)
  • Revision ID: brian@tangent.org-20110125072215-567z6uzy5vdvn4va
Merge in build/timestamp patches/fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
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
39
39
#include "drizzled/lock.h"
40
40
#include "drizzled/item/int.h"
41
41
#include "drizzled/item/empty_string.h"
42
 
#include "drizzled/field/timestamp.h"
 
42
#include "drizzled/field/epoch.h"
43
43
#include "drizzled/message/table.pb.h"
44
44
#include "drizzled/plugin/client.h"
45
45
#include "drizzled/internal/my_sys.h"
90
90
  if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
91
91
    return NULL;
92
92
 
93
 
  TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
 
93
  identifier::Table identifier(getTable()->getShare()->getSchemaName(),
94
94
                             getTable()->getShare()->getTableName(),
95
95
                             getTable()->getShare()->getType());
96
96
 
210
210
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
211
211
uint64_t Cursor::rowSize() { return getTable()->getRecordLength() + getTable()->sizeFields(); }
212
212
 
213
 
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
213
int Cursor::doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked)
214
214
{
215
215
  return open(identifier.getPath().c_str(), mode, test_if_locked);
216
216
}
221
221
  Try O_RDONLY if cannot open as O_RDWR
222
222
  Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
223
223
*/
224
 
int Cursor::ha_open(const TableIdentifier &identifier,
 
224
int Cursor::ha_open(const identifier::Table &identifier,
225
225
                    int mode,
226
226
                    int test_if_locked)
227
227
{
278
278
  if (stats.deleted < 10 || primary_key >= MAX_KEY ||
279
279
      !(getTable()->index_flags(primary_key) & HA_READ_ORDER))
280
280
  {
281
 
    (void) startTableScan(1);
282
 
    while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
283
 
    (void) endTableScan();
 
281
    error= startTableScan(1);
 
282
    if (error == 0)
 
283
    {
 
284
      while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
 
285
      (void) endTableScan();
 
286
    }
284
287
  }
285
288
  else
286
289
  {
287
290
    /* Find the first row through the primary key */
288
 
    (void) startIndexScan(primary_key, 0);
289
 
    error=index_first(buf);
290
 
    (void) endIndexScan();
 
291
    error= startIndexScan(primary_key, 0);
 
292
    if (error == 0)
 
293
    {
 
294
      error=index_first(buf);
 
295
      (void) endIndexScan();
 
296
    }
291
297
  }
292
298
  return error;
293
299
}
704
710
     */
705
711
    Session *const session= getTable()->in_use;
706
712
    TransactionServices &transaction_services= TransactionServices::singleton();
707
 
    transaction_services.truncateTable(session, getTable());
 
713
    transaction_services.truncateTable(*session, *getTable());
708
714
  }
709
715
 
710
716
  return result;
1305
1311
     * CREATE TABLE will commit the transaction containing
1306
1312
     * it).
1307
1313
     */
1308
 
    result= transaction_services.insertRecord(session, table);
 
1314
    result= transaction_services.insertRecord(*session, *table);
1309
1315
    break;
1310
1316
  case SQLCOM_REPLACE:
1311
1317
  case SQLCOM_REPLACE_SELECT:
1334
1340
       * as the row to delete (this is the conflicting row), so
1335
1341
       * we need to notify TransactionService to use that row.
1336
1342
       */
1337
 
      transaction_services.deleteRecord(session, table, true);
 
1343
      transaction_services.deleteRecord(*session, *table, true);
1338
1344
      /* 
1339
1345
       * We set the "current" statement message to NULL.  This triggers
1340
1346
       * the replication services component to generate a new statement
1341
1347
       * message for the inserted record which will come next.
1342
1348
       */
1343
 
      transaction_services.finalizeStatementMessage(*session->getStatementMessage(), session);
 
1349
      transaction_services.finalizeStatementMessage(*session->getStatementMessage(), *session);
1344
1350
    }
1345
1351
    else
1346
1352
    {
1347
1353
      if (before_record == NULL)
1348
 
        result= transaction_services.insertRecord(session, table);
 
1354
        result= transaction_services.insertRecord(*session, *table);
1349
1355
      else
1350
 
        transaction_services.updateRecord(session, table, before_record, after_record);
 
1356
        transaction_services.updateRecord(*session, *table, before_record, after_record);
1351
1357
    }
1352
1358
    break;
1353
1359
  case SQLCOM_INSERT:
1360
1366
     * an update.
1361
1367
     */
1362
1368
    if (before_record == NULL)
1363
 
      result= transaction_services.insertRecord(session, table);
 
1369
      result= transaction_services.insertRecord(*session, *table);
1364
1370
    else
1365
 
      transaction_services.updateRecord(session, table, before_record, after_record);
 
1371
      transaction_services.updateRecord(*session, *table, before_record, after_record);
1366
1372
    break;
1367
1373
 
1368
1374
  case SQLCOM_UPDATE:
1369
 
    transaction_services.updateRecord(session, table, before_record, after_record);
 
1375
    transaction_services.updateRecord(*session, *table, before_record, after_record);
1370
1376
    break;
1371
1377
 
1372
1378
  case SQLCOM_DELETE:
1373
 
    transaction_services.deleteRecord(session, table);
 
1379
    transaction_services.deleteRecord(*session, *table);
1374
1380
    break;
1375
1381
  default:
1376
1382
    break;