~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-05 12:26:58 UTC
  • mto: (2278.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2272.
  • Revision ID: olafvdspek@gmail.com-20110405122658-xxrvmobwwwwf3oct
Refactor Open_tables_state

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
*/
25
25
 
26
26
#include <config.h>
27
 
 
28
27
#include <fcntl.h>
29
 
 
30
28
#include <drizzled/error.h>
31
29
#include <drizzled/field/epoch.h>
32
30
#include <drizzled/gettext.h>
35
33
#include <drizzled/item/int.h>
36
34
#include <drizzled/lock.h>
37
35
#include <drizzled/message/table.h>
38
 
#include <drizzled/my_hash.h>
39
36
#include <drizzled/optimizer/cost_vector.h>
40
37
#include <drizzled/plugin/client.h>
41
38
#include <drizzled/plugin/event_observer.h>
45
42
#include <drizzled/sql_base.h>
46
43
#include <drizzled/sql_parse.h>
47
44
#include <drizzled/transaction_services.h>
 
45
#include <drizzled/key.h>
 
46
#include <drizzled/sql_lex.h>
 
47
#include <drizzled/resource_context.h>
 
48
#include <drizzled/statistics_variables.h>
 
49
#include <drizzled/system_variables.h>
48
50
 
49
51
using namespace std;
50
52
 
51
 
namespace drizzled
52
 
{
 
53
namespace drizzled {
53
54
 
54
55
/****************************************************************************
55
56
** General Cursor functions
478
479
 
479
480
  if ((nr= next_insert_id) >= auto_inc_interval_for_cur_row.maximum())
480
481
  {
481
 
    /* next_insert_id is beyond what is reserved, so we reserve more. */
482
 
    const Discrete_interval *forced=
483
 
      session->auto_inc_intervals_forced.get_next();
484
 
    if (forced != NULL)
485
 
    {
486
 
      nr= forced->minimum();
487
 
      nb_reserved_values= forced->values();
488
 
    }
489
 
    else
490
482
    {
491
483
      /*
492
484
        Cursor::estimation_rows_to_insert was set by
493
485
        Cursor::ha_start_bulk_insert(); if 0 it means "unknown".
494
486
      */
495
 
      uint32_t nb_already_reserved_intervals=
496
 
        session->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements();
 
487
      uint32_t nb_already_reserved_intervals= 0;
497
488
      uint64_t nb_desired_values;
498
489
      /*
499
490
        If an estimation was given to the engine:
568
559
      nr= getTable()->next_number_field->val_int();
569
560
  }
570
561
  if (append)
571
 
  {
572
 
    auto_inc_interval_for_cur_row.replace(nr, nb_reserved_values,
573
 
                                          variables->auto_increment_increment);
574
 
  }
 
562
    auto_inc_interval_for_cur_row.replace(nr, nb_reserved_values, variables->auto_increment_increment);
575
563
 
576
564
  /*
577
565
    Record this autogenerated value. If the caller then
612
600
  release_auto_increment();
613
601
  insert_id_for_cur_row= 0;
614
602
  auto_inc_interval_for_cur_row.replace(0, 0, 0);
615
 
  if (next_insert_id > 0)
616
 
  {
617
 
    next_insert_id= 0;
618
 
    /*
619
 
      this statement used forced auto_increment values if there were some,
620
 
      wipe them away for other statements.
621
 
    */
622
 
    getTable()->in_use->auto_inc_intervals_forced.empty();
623
 
  }
 
603
  next_insert_id= 0;
624
604
}
625
605
 
626
606
void Cursor::drop_table(const char *)
658
638
void
659
639
Cursor::setTransactionReadWrite()
660
640
{
661
 
  ResourceContext *resource_context;
662
 
 
663
641
  /*
664
642
   * If the cursor has not context for execution then there should be no
665
643
   * possible resource to gain (and if there is... then there is a bug such
668
646
  if (not getTable()->in_use)
669
647
    return;
670
648
 
671
 
  resource_context= getTable()->in_use->getResourceContext(getEngine());
672
649
  /*
673
650
    When a storage engine method is called, the transaction must
674
651
    have been started, unless it's a DDL call, for which the
677
654
    Unfortunately here we can't know know for sure if the engine
678
655
    has registered the transaction or not, so we must check.
679
656
  */
680
 
  if (resource_context->isStarted())
681
 
  {
682
 
    resource_context->markModifiedData();
683
 
  }
 
657
  ResourceContext& resource_context= getTable()->in_use->getResourceContext(*getEngine());
 
658
  if (resource_context.isStarted())
 
659
    resource_context.markModifiedData();
684
660
}
685
661
 
686
662
 
1300
1276
 
1301
1277
  bool result= false;
1302
1278
 
1303
 
  switch (session->getLex()->sql_command)
 
1279
  switch (session->lex().sql_command)
1304
1280
  {
1305
1281
  case SQLCOM_CREATE_TABLE:
1306
1282
    /*