~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Monty Taylor
  • Date: 2011-02-14 20:25:28 UTC
  • mto: (2168.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2169.
  • Revision ID: mordred@inaugust.com-20110214202528-wfb2a5h51ntbl5ct
Fix daemonize c++ patch.

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