~barry-leslie/drizzle/drizzle_pbmsV2

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2011-04-04 14:40:45 UTC
  • mfrom: (1919.2.344 build)
  • Revision ID: barry.leslie@primebase.com-20110404144045-etbtnq340cgy2dw3
MergedĀ inĀ lp:drizzle.

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