~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-08 12:51:19 UTC
  • mto: This revision was merged to the branch mainline in revision 2396.
  • Revision ID: olafvdspek@gmail.com-20110808125119-qcrkgv0frmxk03rn
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
589
589
  next_insert_id= 0;
590
590
}
591
591
 
592
 
void Cursor::drop_table(const char *)
 
592
void Cursor::drop_table()
593
593
{
594
594
  close();
595
595
}
596
596
 
597
 
 
598
 
/**
599
 
  Performs checks upon the table.
600
 
 
601
 
  @param session                thread doing CHECK Table operation
602
 
 
603
 
  @retval
604
 
    HA_ADMIN_OK               Successful upgrade
605
 
  @retval
606
 
    HA_ADMIN_NEEDS_UPGRADE    Table has structures requiring upgrade
607
 
  @retval
608
 
    HA_ADMIN_NEEDS_ALTER      Table has structures requiring ALTER Table
609
 
  @retval
610
 
    HA_ADMIN_NOT_IMPLEMENTED
611
 
*/
612
 
int Cursor::ha_check(Session *)
 
597
int Cursor::ha_check(Session*)
613
598
{
614
599
  return HA_ADMIN_OK;
615
600
}
743
728
  @sa Cursor::discard_or_import_tablespace()
744
729
*/
745
730
 
746
 
int
747
 
Cursor::ha_discard_or_import_tablespace(bool discard)
 
731
int Cursor::ha_discard_or_import_tablespace(bool discard)
748
732
{
749
733
  setTransactionReadWrite();
750
 
 
751
734
  return discard_or_import_tablespace(discard);
752
735
}
753
736
 
757
740
  @sa Cursor::drop_table()
758
741
*/
759
742
 
760
 
void
761
 
Cursor::closeMarkForDelete(const char *name)
 
743
void Cursor::closeMarkForDelete()
762
744
{
763
745
  setTransactionReadWrite();
764
 
 
765
 
  return drop_table(name);
 
746
  return drop_table();
766
747
}
767
748
 
768
749
int Cursor::index_next_same(unsigned char *buf, const unsigned char *key, uint32_t keylen)
769
750
{
770
 
  int error;
771
 
  if (!(error=index_next(buf)))
772
 
  {
773
 
    ptrdiff_t ptrdiff= buf - getTable()->getInsertRecord();
774
 
    unsigned char *save_record_0= NULL;
775
 
    KeyInfo *key_info= NULL;
776
 
    KeyPartInfo *key_part;
777
 
    KeyPartInfo *key_part_end= NULL;
778
 
 
779
 
    /*
780
 
      key_cmp_if_same() compares table->getInsertRecord() against 'key'.
781
 
      In parts it uses table->getInsertRecord() directly, in parts it uses
782
 
      field objects with their local pointers into table->getInsertRecord().
783
 
      If 'buf' is distinct from table->getInsertRecord(), we need to move
784
 
      all record references. This is table->getInsertRecord() itself and
785
 
      the field pointers of the fields used in this key.
786
 
    */
787
 
    if (ptrdiff)
788
 
    {
789
 
      save_record_0= getTable()->getInsertRecord();
790
 
      getTable()->record[0]= buf;
791
 
      key_info= getTable()->key_info + active_index;
792
 
      key_part= key_info->key_part;
793
 
      key_part_end= key_part + key_info->key_parts;
794
 
      for (; key_part < key_part_end; key_part++)
795
 
      {
796
 
        assert(key_part->field);
797
 
        key_part->field->move_field_offset(ptrdiff);
798
 
      }
799
 
    }
800
 
 
801
 
    if (key_cmp_if_same(getTable(), key, active_index, keylen))
802
 
    {
803
 
      getTable()->status=STATUS_NOT_FOUND;
804
 
      error=HA_ERR_END_OF_FILE;
805
 
    }
806
 
 
807
 
    /* Move back if necessary. */
808
 
    if (ptrdiff)
809
 
    {
810
 
      getTable()->record[0]= save_record_0;
811
 
      for (key_part= key_info->key_part; key_part < key_part_end; key_part++)
812
 
        key_part->field->move_field_offset(-ptrdiff);
813
 
    }
 
751
  int error= index_next(buf);
 
752
  if (error)
 
753
    return error;
 
754
 
 
755
  ptrdiff_t ptrdiff= buf - getTable()->getInsertRecord();
 
756
  unsigned char *save_record_0= NULL;
 
757
  KeyInfo *key_info= NULL;
 
758
  KeyPartInfo *key_part;
 
759
  KeyPartInfo *key_part_end= NULL;
 
760
 
 
761
  /*
 
762
  key_cmp_if_same() compares table->getInsertRecord() against 'key'.
 
763
  In parts it uses table->getInsertRecord() directly, in parts it uses
 
764
  field objects with their local pointers into table->getInsertRecord().
 
765
  If 'buf' is distinct from table->getInsertRecord(), we need to move
 
766
  all record references. This is table->getInsertRecord() itself and
 
767
  the field pointers of the fields used in this key.
 
768
  */
 
769
  if (ptrdiff)
 
770
  {
 
771
    save_record_0= getTable()->getInsertRecord();
 
772
    getTable()->record[0]= buf;
 
773
    key_info= getTable()->key_info + active_index;
 
774
    key_part= key_info->key_part;
 
775
    key_part_end= key_part + key_info->key_parts;
 
776
    for (; key_part < key_part_end; key_part++)
 
777
    {
 
778
      assert(key_part->field);
 
779
      key_part->field->move_field_offset(ptrdiff);
 
780
    }
 
781
  }
 
782
 
 
783
  if (key_cmp_if_same(getTable(), key, active_index, keylen))
 
784
  {
 
785
    getTable()->status=STATUS_NOT_FOUND;
 
786
    error= HA_ERR_END_OF_FILE;
 
787
  }
 
788
 
 
789
  /* Move back if necessary. */
 
790
  if (ptrdiff)
 
791
  {
 
792
    getTable()->record[0]= save_record_0;
 
793
    for (key_part= key_info->key_part; key_part < key_part_end; key_part++)
 
794
      key_part->field->move_field_offset(-ptrdiff);
814
795
  }
815
796
  return error;
816
797
}