Commit 7689fcfb authored by unknown's avatar unknown
Browse files

WL 1682: After review fixes + update bitvector class + bitvector test

cases + bug fixes


mysys/my_bitmap.c:
  Removed debug comments
sql/bitvector.h:
  Changed a number of things
  Added new methods, new handling of end bits, faster search
  for bits using word by word search..
sql/field.h:
  Added comment
sql/ha_federated.cc:
  Fixes
sql/ha_innodb.cc:
  Fixes
sql/ha_innodb.h:
  InnoDB still needs the extra calls not needed by anybody else
sql/ha_ndbcluster.cc:
  Removed some timestamp set bit stuff
  Always write all fields in write_row
sql/handler.cc:
  No inline methods in bit interface (caused strange bugs)
  initialise method
sql/handler.h:
  Changed to bitvector from bitmap
  Removed init variable
sql/opt_range.cc:
  Removed all extra HA_EXTRA_RETRIEVE_*
sql/sql_acl.cc:
  Removed all extra HA_EXTRA_RETRIEVE_*
sql/sql_base.cc:
  Set bits previously missed
sql/sql_insert.cc:
  Removed all extra HA_EXTRA_RETRIEVE_*
  Timestamp handling
sql/sql_load.cc:
  Updated comments plus set all bits in bitvector
sql/sql_select.cc:
  Removed ifdef since NDB and Federated needs the same calls
  Added comment or rather changed comment.
sql/sql_table.cc:
  Removed HA_EXTRA_RETRIEVE_* calls
  Updated comments
sql/sql_udf.cc:
  Removed HA_EXTRA_RETRIEVE_* calls
  Updated comments
sql/sql_update.cc:
  Removed HA_EXTRA_RETRIEVE_* calls
  Timstamp updating
parent 5d3af2b0
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -102,14 +102,6 @@ void bitmap_free(MY_BITMAP *map)

void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit)
{
  if (map->bitmap)
  {
    DBUG_PRINT("info", ("Bitmap not defined"));
  }
  if (bitmap_bit >= map->bitmap_size*8)
  {
    DBUG_PRINT("info", ("bit %d size in bytes %d", bitmap_bit, map->bitmap_size));
  }
  DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8);
  bitmap_lock(map);
  bitmap_fast_set_bit(map, bitmap_bit);

sql/bitvector.cc

0 → 100644
+320 −0
Original line number Diff line number Diff line
/* -*- Mode: C++ -*-

   Copyright (C) 2005 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include <bitvector.h>

void bitvector::create_last_word_mask()
{

  /* Get the number of used bits (1..8) in the last byte */
  unsigned int const used= 1U + ((size()-1U) & 0x7U);

  /*
   * Create a mask with the upper 'unused' bits set and the lower 'used'
   * bits clear. The bits within each byte is stored in big-endian order.
   */
  unsigned char const mask= (~((1 << used) - 1)) & 255;
  last_word_ptr= (uint32*)(m_data+((bytes()-1U)>>2));

  /*
    The first bytes are to be set to zero since they represent real  bits
    in the bitvector. The last bytes are set to 0xFF since they  represent
    bytes not used by the bitvector. Finally the last byte contains  bits
    as set by the mask above.
  */

  unsigned char *ptr= (unsigned char*)&last_word_mask;
  switch (bytes()&3)
  {
  case 1:
    last_word_mask= ~0U;
    ptr[0]= mask;
    return;
  case 2:
    last_word_mask= ~0U;
    ptr[0]= 0;
    ptr[1]= mask;
    return;
  case 3:
    last_word_mask= 0U;
    ptr[2]= mask;
    ptr[3]= 0xFFU;
    return;
  case 0:
    last_word_mask= 0U;
    ptr[3]= mask;
    return;
  }
}

int bitvector::init(size_t size)
{
  DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
  m_size= size;
  m_data= (uchar*)my_malloc(byte_size_word_aligned(size), MYF(0));
  if (m_data)
  {
    create_last_word_mask();
    clear_all();
    return FALSE;
  }
  return TRUE;
}

uint bitvector::no_bits_set()
{
  uint no_bytes= bytes(), res=0, i;
  uchar *ptr= m_data;
  *last_word_ptr^=last_word_mask; //Reset last bits to zero
  for (i=0; i< no_bytes; i++, ptr++)
    res+=my_count_bits_ushort(*ptr);
  *last_word_ptr^=last_word_mask; //Set last bits to one again
  return res;
}

uint bitvector::get_first_bit_set()
{
  uchar *byte_ptr;
  uint32 *data_ptr= (uint32*)data(), bit_found,i,j,k;
  for (i=0; data_ptr <= last_word_ptr; data_ptr++, i++)
  {
    if (*data_ptr)
    {
      byte_ptr= (uchar*)data_ptr;
      for (j=0; j < 4; j++, byte_ptr++)
      {
        if (*byte_ptr)
        {
          for (k=0; k < 8; k++)
          {
            if (*byte_ptr & (1 << k))
            {
              bit_found= (i << 5) + (j << 3) + k;
              if (bit_found == m_size)
                return MYSQL_NO_BIT_FOUND;
              else
                return bit_found;
            }
          }
          DBUG_ASSERT(1);
        }
      }
      DBUG_ASSERT(1);
    }
  }
  return MYSQL_NO_BIT_FOUND;
}

uint bitvector::get_first_bit_unset()
{
  uchar *byte_ptr;
  uint32 *data_ptr= (uint32*)data(), bit_found,i,j,k;
  for (i=0; data_ptr <= last_word_ptr; data_ptr++, i++)
  {
    if (*data_ptr != 0xFFFFFFFF)
    {
      byte_ptr= (uchar*)data_ptr;
      for (j=0; j < 4; j++, byte_ptr++)
      {
        if (*byte_ptr != 0xFF)
        {
          for (k=0; k < 8; k++)
          {
            if (!(*byte_ptr & (1 << k)))
            {
              bit_found= (i << 5) + (j << 3) + k;
              if (bit_found == m_size)
                return MYSQL_NO_BIT_FOUND;
              else
                return bit_found;
            }
          }
          DBUG_ASSERT(1);
        }
      }
      DBUG_ASSERT(1);
    }
  }
  return MYSQL_NO_BIT_FOUND;
}

#ifdef TEST_BITVECTOR

int main()
{
  int i;
  for (i= 0; i < 4096; i++)
    if (do_test(i))
      return -1;
  return 0;
}

bool do_test(uint bitsize)
{
  bitvector *bv;
  bv = new bitvector;
  bv->init(bitsize);
  if (test_set_get_clear_bit(bv,bitsize))
    return TRUE;
  if (test_flip_bit(bv,bitsize))
    return TRUE;
  if (test_operators(bv,bitsize))
    return TRUE;
  if (test_get_all_bits(bvbitsize))
    return TRUE;
  if (test_compare_operators(bv,bitsize))
    return TRUE;
  if (test_count_bits_set(bv,bitsize))
    return TRUE;
  if (test_get_first_bit(bv,bitsize))
    return TRUE;
  if (test_get_next_bit(bv,bitsize))
    return TRUE;
  printf("OK");
  return FALSE;
}

uint get_rand_bit(uint bitsize)
{
  return (rand() % bitsize);
}

bool test_set_get_clear_bit(bitvector *bv, uint bitsize)
{
  uint i, test_bit;
  uint no_loops= bitsize > 128 ? 128 : bitsize;
  for (i=0; i < no_loops; i++)
  {
    test_bit= get_rand_bit(bitsize);
    bv->set_bit(test_bit)
    if (!bv->get_bit(test_bit))
      goto error1;
    bv->clear_bit(test_bit);
    if (bv->get_bit(test_bit))
      goto error2;
  }
  return FALSE;
error1:
  printf("Error in set bit, bit %u, bitsize = %u", test_bit, bitsize);
  return TRUE;
error2:
  printf("Error in clear bit, bit %u, bitsize = %u", test_bit, bitsize);
  return TRUE;
}

bool test_flip_bit(bitvector *bv, uint bitsize)
{
  uint i test_bit;
  uint no_loops= bitsize > 128 ? 128 : bitsize;
  for (i=0; i < no_loops; i++)
  {
    test_bit= get_rand_bit(bitsize);
    bv->flip_bit(test_bit)
    if (!bv->get_bit(test_bit))
      goto error1;
    bv->flip_bit(test_bit);
    if (bv->get_bit(test_bit))
      goto error2;
  }
  return FALSE;
error1:
  printf("Error in flip bit 1, bit %u, bitsize = %u", test_bit, bitsize);
  return TRUE;
error2:
  printf("Error in flip bit 2, bit %u, bitsize = %u", test_bit, bitsize);
  return TRUE;
}

bool test_operators(bitvector *bv, uint bitsize)
{
  return FALSE;
}

bool test_get_all_bits(bitvector *bv, uint bitsize)
{
  uint i;
  bv->set_all();
  if (!bv->get_all_bits_set())
    goto error1;
  bv->clear_all();
  if (!bv->get_all_bits_clear())
    goto error2;
  for (i=0; i<bitsize;i++)
    bv->set_bit(i);
  if (!bv->get_all_bits_set())
    goto error3;
  for (i=0; i<bitsize;i++)
    bv->clear_bit(i);
  if (!bv->get_all_bits_clear())
    goto error4;
  return FALSE;
error1:
  printf("Error in set_all, bitsize = %u", bitsize);
  return TRUE;
error2:
  printf("Error in clear_all, bitsize = %u", bitsize);
  return TRUE;
error3:
  printf("Error in bitwise set all, bitsize = %u", bitsize);
  return TRUE;
error4:
  printf("Error in bitwise clear all, bitsize = %u", bitsize);
  return TRUE;
}

bool test_compare_operators(bitvector *bv, uint bitsize)
{
  return FALSE;
}

bool test_count_bits_set(bitvector *bv, uint bitsize)
{
  uint i, bit_count=0;
  uint no_loops= bitsize > 128 ? 128 : bitsize;
  for (i=0; i < no_loops; i++)
  {
    test_bit=get_rand_bit(bitsize);
    if (!bv->get_bit(test_bit))
    {
      bv->set_bit(test_bit);
      bit_count++;
    }
  }
  if (bit_count==0 && bitsize > 0)
    error1;
  if (bv->no_bits_set() != bit_count)
    error2;
  return FALSE;
error1:
  printf("No bits set  bitsize = %u", bitsize);
  return TRUE;
error2:
  printf("Wrong count of bits set, bitsize = %u", bitsize);
  return TRUE;
}

bool test_get_first_bit(bitvector *bv, uint bitsize)
{
  return FALSE;
}

bool test_get_next_bit(bitvector *bv, uint bitsize)
{
  return FALSE;
}
#endif
+231 −66
Original line number Diff line number Diff line
@@ -68,64 +68,70 @@ namespace
    inlining code.
*/

/* Number returned when no bit found */
#define MYSQL_NO_BIT_FOUND 1 << 20
class bitvector
{
private:
  /* Helper classes */
  struct flip_bit_op
  { 
    void operator()(byte* p, byte m) { *p^= m; }
  };

  struct set_bit_op
  { 
    void operator()(byte* p, byte m) { *p|= m; }
  };

  struct clear_bit_op
  { 
    void operator()(byte* p, byte m) { *p&= ~m; }
  };

  struct test_bit_op
  { 
    bool operator()(byte* p, byte m) { return *p & m; }
  };

  /* Compute the number of bytes required to store 'bits' bits in an array. */
  static inline size_t byte_size(size_t bits)
  { 
    int const byte_bits = sizeof(byte) * CHAR_BIT;
    uint const byte_bits = sizeof(byte) * CHAR_BIT;
    return (bits + (byte_bits-1)) / byte_bits; 
  }

  /* Tidy the last byte (by clearing the unused bits) of the bitvector to make
   * comparison easy.  This code is assuming that we're working with 8-bit
   * bytes.
   */
  void tidy_last_byte()
  static inline size_t byte_size_word_aligned(size_t bits)
  {
    return ((bits + 31) >> 5) << 2;
  }

  void create_last_word_mask()
  {
    byte* const last_byte= m_data + bytes() - 1;

    /* Get the number of used bits (1..8) in the last byte */
    unsigned int const used= 1U + ((size()-1U) & 0x7U);

    /* Create a mask with the upper 'unused' bits clear and the lower 'used'
     * bits set. The bits within each byte is stored in big-endian order.
    /*
     * Create a mask with the upper 'unused' bits set and the lower 'used'
     * bits clear. The bits within each byte is stored in big-endian order.
     */
    unsigned int const mask= ((1 << used) - 1);
    unsigned char const mask= (~((1 << used) - 1)) & 255;
    last_word_ptr= (uint32*)(m_data+((bytes()-1U)>>2));

    /* Mask the last byte */
    *last_byte&= mask;
    /*
      The first bytes are to be set to zero since they represent real  bits
      in the bitvector. The last bytes are set to 0xFF since they  represent
      bytes not used by the bitvector. Finally the last byte contains  bits
      as set by the mask above.
    */

    unsigned char *ptr= (unsigned char*)&last_word_mask;
    switch (bytes()&3)
    {
    case 1:
      last_word_mask= ~0U;
      ptr[0]= mask;
      return;
    case 2:
      last_word_mask= ~0U;
      ptr[0]= 0;
      ptr[1]= mask;
      return;
    case 3:
      last_word_mask= 0U;
      ptr[2]= mask;
      ptr[3]= 0xFFU;
      return;
    case 0:
      last_word_mask= 0U;
      ptr[3]= mask;
      return;
    }
  }

  template <class ReturnType, class Func>
  inline ReturnType apply_to_byte(size_t const pos, Func op) const
  inline void tidy_last_word()
  {
    /* Here I'm assuming that we're working with 8-bit bytes. */
    ptrdiff_t const byte_pos= pos >> 3;
    byte const mask= (1 << (pos & 0x7U));
    return op(&m_data[byte_pos], mask);
    *last_word_ptr|= last_word_mask;
  }

public:
@@ -135,8 +141,11 @@ class bitvector
  }

  explicit bitvector(size_t size, bool value= false) 
    : m_size(size), m_data(my_malloc(byte_size(size), MYF(0)))
    : m_size(size),
      m_data((uchar*)my_malloc(byte_size_word_aligned(size), MYF(0)))
  {
    DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
    if (value)
      set_all();
    else
@@ -147,32 +156,43 @@ class bitvector
   * number of *bits* in the bitvector. 
   */
  explicit bitvector(byte const* data, size_t size)
    : m_size(size), m_data(my_malloc(byte_size(size), MYF(0)))
    : m_size(size),
      m_data((uchar*)my_malloc(byte_size_word_aligned(size), MYF(0)))
  {
    /* std::copy(data, data + byte_size(size), m_data); */
    DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
    memcpy(m_data, data, byte_size(size));
    tidy_last_byte();
    tidy_last_word();
  }

  bitvector(bitvector const& other) 
    : m_size(other.size()), m_data(my_malloc(other.bytes(), MYF(0)))
    : m_size(other.size()),
      m_data((uchar*)my_malloc(other.bytes(), MYF(0)))
  {
    /* std::copy(other.m_data, other.m_data + other.bytes(), m_data); */
    DBUG_ASSERT(m_size < MYSQL_NO_BIT_FOUND);
    create_last_word_mask();
    memcpy(m_data, other.data(), other.bytes());
    tidy_last_byte();           /* Just a precaution */
    tidy_last_word();
  }

  /* Assignment operator */
  bitvector& operator=(bitvector other)
  ~bitvector() 
  {
    swap(other);
    return *this;
    if (m_data)
      my_free((char*)m_data, MYF(0));
  }

  ~bitvector() 
  int init(size_t size)
  {
    DBUG_ASSERT(size < MYSQL_NO_BIT_FOUND);
    m_size= size;
    m_data= (uchar*)my_malloc(byte_size_word_aligned(size), MYF(0));
    if (m_data)
      my_free(m_data, MYF(0));
    {
      create_last_word_mask();
      clear_all();
      return FALSE;
    }
    return TRUE;
  }

  /* Swap the guts of this instance with another instance. */
@@ -182,8 +202,35 @@ class bitvector
    my_swap(m_data, other.m_data);
  }

  bitvector &operator=(const bitvector &rhs)
  {
    DBUG_ASSERT(rhs.size() == size());
    memcpy(m_data, rhs.data(), byte_size_word_aligned(m_size));
    return *this;
  }

  bool get_all_bits_set()
  {
    uint32 *data_ptr= (uint32*)&m_data[0];
    for (; data_ptr <= last_word_ptr; data_ptr++)
      if (*data_ptr != 0xFFFFFFFF)
        return FALSE;
    return TRUE;
  }

  bool get_all_bits_clear()
  {
    uint32 *data_ptr= (uint32*)&m_data[0];
    if (*last_word_ptr ^ last_word_mask)
      return FALSE;
    for (; data_ptr < last_word_ptr; data_ptr++)
      if (*data_ptr)
        return FALSE;
    return TRUE;
  }

  /* A pointer to the bytes representing the bits */
  byte const *data() const { return m_data; }
  uchar const *data() const { return m_data; }

  /* The size of the data in *bytes* */
  size_t bytes() const { return byte_size(m_size); }
@@ -194,47 +241,44 @@ class bitvector
  /* Set all bits in the vector */
  void set_all()
  { 
    /* std::fill_n(m_data, bytes(), 255); */
    memset(m_data, 255, bytes()); 
    tidy_last_byte();
    memset(m_data, 255, byte_size_word_aligned(m_size)); 
  }

  /* Set a bit to a value */
  void set_bit(size_t pos)
  {
    apply_to_byte<void>(pos, set_bit_op());
    *(uchar*)(m_data + (pos >> 3)) |= (uchar)(1 << (pos & 0x7U));
  }

  /* Reset (clear) all bits in the vector */
  void clear_all()
  { 
    /* std::fill_n(m_data, bytes(), 0); */
    memset(m_data, 0, bytes()); 
    tidy_last_byte();
    tidy_last_word();
  }

  /* Reset one bit in the vector */
  void clear_bit(size_t pos)
  {
    apply_to_byte<void>(pos, clear_bit_op());
    *(u_char*)(m_data + (pos >> 3)) &= (u_char)(~(1 << (pos & 0x7U)));
  }

  void flip_bit(size_t pos)
  {
    apply_to_byte<void>(pos, flip_bit_op());
    *(uchar*)(m_data + (pos >> 3)) ^= (uchar)(1 << (pos & 0x7U));
  }

  bool get_bit(size_t pos) const
  {
    return apply_to_byte<bool>(pos, test_bit_op());
    (bool)(*(uchar*)(m_data + (pos >> 3))) & (uchar)(1 << (pos & 0x7U));
  };

  bool operator==(bitvector const& rhs) const
  {
    if (size() != rhs.size())
      return false;
    /* This works since I have ensured that the last byte of the array contain
     * sensible data.
    /* This works since I have ensured that the last byte of the array
     * contain sensible data.
     */
    if (memcmp(data(), rhs.data(), bytes()) != 0)
      return false;
@@ -246,9 +290,130 @@ class bitvector
    return !(*this == rhs);
  }

  bitvector &operator&=(bitvector const& rhs)
  {
    DBUG_ASSERT(size() == rhs.size());
    uint32 *data_ptr=(uint32*)data(), *rhs_data_ptr=(uint32*)rhs.data();
    uint32 *last_ptr= last_word_ptr;
    for (; data_ptr <= last_ptr; data_ptr++, rhs_data_ptr++)
      *data_ptr&=*rhs_data_ptr;
    return *this;
  }

  bitvector &operator|=(bitvector const& rhs)
  {
    DBUG_ASSERT(size() == rhs.size());
    uint32 *data_ptr=(uint32*)data(), *rhs_data_ptr=(uint32*)rhs.data();
    uint32 *last_ptr= last_word_ptr;
    for (; data_ptr <= last_ptr; data_ptr++, rhs_data_ptr++)
      *data_ptr|=*rhs_data_ptr;
    return *this;
  }

  bitvector &operator^=(bitvector const& rhs)
  {
    DBUG_ASSERT(size() == rhs.size());
    uint32 *data_ptr=(uint32*)data(), *rhs_data_ptr=(uint32*)rhs.data();
    uint32 *last_ptr= last_word_ptr;
    for (; data_ptr <= last_ptr; data_ptr++, rhs_data_ptr++)
      *data_ptr^=*rhs_data_ptr;
    tidy_last_word();
    return *this;
  }

  bitvector &operator~()
  {
    uint32 *data_ptr= (uint32*)data();
    uint32 *last_ptr= last_word_ptr;
    for (; data_ptr <= last_ptr; data_ptr++)
      *data_ptr^=0xFFFFFFFF;
    tidy_last_word();
    return *this;
  }

  uint no_bits_set()
  {
    uint no_bytes= bytes(), res=0, i;
    uchar *ptr= m_data;
    *last_word_ptr^=last_word_mask; //Reset last bits to zero
    for (i=0; i< no_bytes; i++, ptr++)
      res+=my_count_bits_ushort(*ptr);
    *last_word_ptr^=last_word_mask; //Set last bits to one again
    return res;
  }

  uint get_first_bit_set()
  {
    uchar *byte_ptr;
    uint32 *data_ptr= (uint32*)data(), bit_found,i,j,k;
    for (i=0; data_ptr <= last_word_ptr; data_ptr++, i++)
    {
      if (*data_ptr)
      {
        byte_ptr= (uchar*)data_ptr;
        for (j=0; j < 4; j++, byte_ptr++)
        {
          if (*byte_ptr)
          {
            for (k=0; k < 8; k++)
            {
              if (*byte_ptr & (1 << k))
              {
                bit_found= (i << 5) + (j << 3) + k;
                if (bit_found == m_size)
                  return MYSQL_NO_BIT_FOUND;
                else
                  return bit_found;
              }
            }
            DBUG_ASSERT(1);
          }
        }
        DBUG_ASSERT(1);
      }
    }
    return MYSQL_NO_BIT_FOUND;
  }

  uint get_first_bit_unset()
  {
    uchar *byte_ptr;
    uint32 *data_ptr= (uint32*)data(), bit_found,i,j,k;
    for (i=0; data_ptr <= last_word_ptr; data_ptr++, i++)
    {
      if (*data_ptr != 0xFFFFFFFF)
      {
        byte_ptr= (uchar*)data_ptr;
        for (j=0; j < 4; j++, byte_ptr++)
        {
          if (*byte_ptr != 0xFF)
          {
            for (k=0; k < 8; k++)
            {
              if (!(*byte_ptr & (1 << k)))
              {
                bit_found= (i << 5) + (j << 3) + k;
                if (bit_found == m_size)
                  return MYSQL_NO_BIT_FOUND;
                else
                  return bit_found;
              }
            }
            DBUG_ASSERT(1);
          }
        }
        DBUG_ASSERT(1);
      }
    }
    return MYSQL_NO_BIT_FOUND;
  }


private:
  size_t m_size;
  byte *m_data;
  uint32 last_word_mask;
  uchar *m_data;
  uint32 *last_word_ptr;
};

#endif /* BITVECTOR_H */
+4 −1
Original line number Diff line number Diff line
@@ -86,7 +86,10 @@ class Field
  utype		unireg_check;
  uint32	field_length;		// Length of field
  uint16	flags;
  uint16        fieldnr;                // Field number
  /* fieldnr is the id of the field (first field = 1) as is also
     used in key_part.
  */
  uint16        fieldnr;
  uchar		null_bit;		// Bit used to test null bit

  Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,uchar null_bit_arg,
+5 −4
Original line number Diff line number Diff line
@@ -1113,7 +1113,7 @@ int ha_federated::write_row(byte *buf)
    loop through the field pointer array, add any fields to both the values
    list and the fields list that is part of the write set
  */
  for (x=0, num_fields= 0, field= table->field; *field; field++, x++)
  for (num_fields= 0, field= table->field; *field; field++)
  {
    /* if there is a query id and if it's equal to the current query id */
    if (ha_get_bit_in_write_set((*field)->fieldnr))
@@ -1122,15 +1122,16 @@ int ha_federated::write_row(byte *buf)

      if ((*field)->is_null())
      {
        DBUG_PRINT("info", ("column %d field is_null", x));
        DBUG_PRINT("info", ("column %d field is_null", num_fields-1));
        insert_field_value_string.append("NULL");
      }
      else
      {
        DBUG_PRINT("info", ("column %d field is not null", x));
        DBUG_PRINT("info", ("column %d field is not null", num_fields-1));
        (*field)->val_str(&insert_field_value_string);
        /* quote these fields if they require it */
        (*field)->quote_data(&insert_field_value_string); }
        (*field)->quote_data(&insert_field_value_string); 
      }
      /* append the field name */
      insert_string.append((*field)->field_name);

Loading