Commit fdde665e authored by unknown's avatar unknown
Browse files

WL 1682: Bitvector for updated/read fields in handler interface

Fixed clear issues of bitvector and memory allocation issues


sql/bitvector.cc:
  Made bitvector memroot class
sql/bitvector.h:
  Made bitvector memroot class
sql/handler.cc:
  Need to add updated fields to read set to ensure that they are
  updated since the update code doesn't update if records haven't
  changed
  Added DBUG printout's
sql/handler.h:
  Moved clear of bitvector's to reset function
  Introduced ha_reset for this purpose to ensure that it isn't
  necessary to perform this clear in all handlers.
sql/lock.cc:
  Removed clear that has been moved to ha_reset
sql/opt_range.cc:
  Changed reset to ha_reset
  Added delete file
sql/sql_base.cc:
  Removed clear and changed reset to ha_reset
sql/sql_insert.cc:
  Removed clear and changed reset to ha_reset
sql/sql_select.cc:
  Made sure delete file is done if needed
sql/sql_table.cc:
  Added delete file in another place needed
sql/sql_update.cc:
  Bug for multi-update fixed
parent dfb2d19f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include "mysql_priv.h"
#include <bitvector.h>

void bitvector::create_last_word_mask()
@@ -68,7 +69,7 @@ int bitvector::init(size_t size)
  DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
  DBUG_ASSERT(size > 0);
  m_size= size;
  m_data= (uchar*)my_malloc(byte_size_word_aligned(size), MYF(0));
  m_data= (uchar*)sql_alloc(byte_size_word_aligned(size));
  if (m_data)
  {
    create_last_word_mask();
+5 −9
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ namespace

/* Number returned when no bit found */
#define MYSQL_NO_BIT_FOUND 1 << 20
class bitvector
class bitvector :public Sql_alloc
{
private:
  /* Compute the number of bytes required to store 'bits' bits in an array. */
@@ -100,7 +100,7 @@ class bitvector

  explicit bitvector(size_t size, bool value= false) 
    : m_size(size),
      m_data((uchar*)my_malloc(byte_size_word_aligned(size), MYF(0)))
      m_data((uchar*)sql_alloc(byte_size_word_aligned(size)))
  {
    DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
@@ -115,7 +115,7 @@ class bitvector
   */
  explicit bitvector(byte const* data, size_t size)
    : m_size(size),
      m_data((uchar*)my_malloc(byte_size_word_aligned(size), MYF(0)))
      m_data((uchar*)sql_alloc(byte_size_word_aligned(size)))
  {
    DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
@@ -125,7 +125,7 @@ class bitvector

  bitvector(bitvector const& other) 
    : m_size(other.size()),
      m_data((uchar*)my_malloc(other.bytes(), MYF(0)))
      m_data((uchar*)sql_alloc(other.bytes()))
  {
    DBUG_ASSERT(m_size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
@@ -133,11 +133,7 @@ class bitvector
    tidy_last_word();
  }

  ~bitvector() 
  {
    if (m_data)
      my_free((char*)m_data, MYF(0));
  }
  ~bitvector() {}

  /*
    Allocate memory to the bitvector and create last word mask
+3 −2
Original line number Diff line number Diff line
@@ -1443,12 +1443,13 @@ void handler::ha_set_bit_in_rw_set(uint fieldnr, bool write_op)
{
  DBUG_ENTER("ha_set_bit_in_rw_set");
  if (!write_op) {
    DBUG_PRINT("info", ("Set bit in read set"));
    DBUG_PRINT("info", ("Set bit %u in read set", fieldnr));
    read_set->set_bit((size_t)fieldnr);
  }
  else
  {
    DBUG_PRINT("info", ("Set bit in write set"));
    DBUG_PRINT("info", ("Set bit %u in read and write set", fieldnr));
    read_set->set_bit((size_t)fieldnr);
    write_set->set_bit((size_t)fieldnr);
  }
  DBUG_VOID_RETURN;
+9 −1
Original line number Diff line number Diff line
@@ -443,6 +443,8 @@ class handler :public Sql_alloc
  virtual int rnd_init(bool scan) =0;
  virtual int rnd_end() { return 0; }

private:
  virtual int reset() { return extra(HA_EXTRA_RESET); }
public:
  byte *ref;				/* Pointer to current row */
  byte *dupp_ref;			/* Pointer to dupp row */
@@ -562,6 +564,13 @@ class handler :public Sql_alloc
    inited=NONE;
    DBUG_RETURN(rnd_end());
  }
  int ha_reset()
  {
    DBUG_ENTER("ha_reset");
    ha_clear_all_set();
    DBUG_RETURN(reset());
  }
    
  /* this is necessary in many places, e.g. in HANDLER command */
  int ha_index_or_rnd_end()
  {
@@ -664,7 +673,6 @@ class handler :public Sql_alloc
  { return 0; }
  virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
  { return extra(operation); }
  virtual int reset() { return extra(HA_EXTRA_RESET); }
  virtual int external_lock(THD *thd, int lock_type) { return 0; }
  virtual void unlock_row() {}
  virtual int start_stmt(THD *thd) {return 0;}
+0 −1
Original line number Diff line number Diff line
@@ -179,7 +179,6 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
	((*tables)->reginfo.lock_type >= TL_READ &&
	 (*tables)->reginfo.lock_type <= TL_READ_NO_INSERT))
      lock_type=F_RDLCK;
    (*tables)->file->ha_clear_all_set();
    if ((error=(*tables)->file->external_lock(thd,lock_type)))
    {
      print_lock_error(error, (*tables)->file->table_type());
Loading