~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance/base.cc

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
762
762
    {
763
763
      keyinfo->flags|= HA_USES_COMMENT;
764
764
      keyinfo->comment.length= indx.comment().length();
765
 
      keyinfo->comment.str= strdup(indx.comment().c_str(), keyinfo->comment.length);
 
765
      keyinfo->comment.str= mem().strdup(indx.comment());
766
766
    }
767
767
 
768
 
    keyinfo->name= strdup(indx.name().c_str(), indx.name().length());
 
768
    keyinfo->name= mem().strdup(indx.name());
769
769
 
770
770
    addKeyName(string(keyinfo->name, indx.name().length()));
771
771
  }
931
931
 
932
932
    for (int n= 0; n < field_options.field_value_size(); n++)
933
933
    {
934
 
      t->type_names[n]= strdup(field_options.field_value(n).c_str(), field_options.field_value(n).length());
 
934
      t->type_names[n]= mem().strdup(field_options.field_value(n));
935
935
 
936
936
      /* 
937
937
       * Go ask the charset what the length is as for "" length=1
938
938
       * and there's stripping spaces or some other crack going on.
939
939
     */
940
 
      uint32_t lengthsp;
941
 
      lengthsp= charset->cset->lengthsp(charset,
942
 
                                        t->type_names[n],
943
 
                                        field_options.field_value(n).length());
944
 
      t->type_lengths[n]= lengthsp;
 
940
      t->type_lengths[n]= charset->cset->lengthsp(charset, t->type_names[n], field_options.field_value(n).length());
945
941
    }
946
942
    interval_nr++;
947
943
  }
1001
997
    }
1002
998
    else
1003
999
    {
1004
 
      size_t len= pfield.comment().length();
1005
 
      const char* str= pfield.comment().c_str();
1006
 
 
1007
 
      comment.str= strdup(str, len);
1008
 
      comment.length= len;
 
1000
      comment.str= mem().strdup(pfield.comment());
 
1001
      comment.length= pfield.comment().size();
1009
1002
    }
1010
1003
 
1011
1004
    enum_field_types field_type;
1608
1601
  return ret;
1609
1602
}
1610
1603
 
1611
 
int TableShare::open_table_from_share_inner(Session *session,
1612
 
                                            const char *alias,
1613
 
                                            uint32_t db_stat,
1614
 
                                            Table &outparam)
 
1604
int TableShare::open_table_from_share_inner(Session *session, const char *alias, uint32_t db_stat, Table &outparam)
1615
1605
{
1616
 
  int local_error;
1617
 
  uint32_t records;
1618
 
  unsigned char *record= NULL;
1619
 
  Field **field_ptr;
1620
 
 
1621
 
  local_error= 1;
 
1606
  int local_error= 1;
1622
1607
  outparam.resetTable(session, this, db_stat);
1623
1608
 
1624
1609
  outparam.setAlias(alias);
1628
1613
    return local_error;
1629
1614
 
1630
1615
  local_error= 4;
1631
 
  records= 0;
1632
 
  if ((db_stat & HA_OPEN_KEYFILE))
 
1616
  uint32_t records= 0;
 
1617
  if (db_stat & HA_OPEN_KEYFILE)
1633
1618
    records=1;
1634
1619
 
1635
1620
  records++;
1636
1621
 
1637
 
  record= outparam.alloc(rec_buff_length * records);
 
1622
  unsigned char* record= outparam.alloc(rec_buff_length * records);
1638
1623
 
1639
1624
  if (records == 0)
1640
1625
  {
1668
1653
    memcpy(outparam.getUpdateRecord(), getDefaultValues(), null_bytes);
1669
1654
  }
1670
1655
 
1671
 
  field_ptr = new (outparam.mem()) Field*[_field_size + 1];
 
1656
  Field** field_ptr = new (outparam.mem()) Field*[_field_size + 1];
1672
1657
 
1673
1658
  outparam.setFields(field_ptr);
1674
1659
 
1693
1678
  /* Fix key->name and key_part->field */
1694
1679
  if (key_parts)
1695
1680
  {
1696
 
    KeyInfo     *local_key_info, *key_info_end;
1697
 
    KeyPartInfo *key_part;
1698
 
    uint32_t n_length;
1699
 
    n_length= keys*sizeof(KeyInfo) + key_parts*sizeof(KeyPartInfo);
1700
 
    local_key_info= (KeyInfo*) outparam.alloc(n_length);
 
1681
    uint32_t n_length= keys * sizeof(KeyInfo) + key_parts * sizeof(KeyPartInfo);
 
1682
    KeyInfo* local_key_info= (KeyInfo*) outparam.alloc(n_length);
1701
1683
    outparam.key_info= local_key_info;
1702
 
    key_part= (reinterpret_cast<KeyPartInfo*> (local_key_info+keys));
 
1684
    KeyPartInfo* key_part= reinterpret_cast<KeyPartInfo*>(local_key_info+keys);
1703
1685
 
1704
1686
    memcpy(local_key_info, key_info, sizeof(*local_key_info)*keys);
1705
 
    memcpy(key_part, key_info[0].key_part, (sizeof(*key_part) *
1706
 
                                            key_parts));
 
1687
    memcpy(key_part, key_info[0].key_part, sizeof(*key_part) * key_parts);
1707
1688
 
1708
 
    for (key_info_end= local_key_info + keys ;
1709
 
         local_key_info < key_info_end ;
1710
 
         local_key_info++)
 
1689
    for (KeyInfo* key_info_end= local_key_info + keys; local_key_info < key_info_end; local_key_info++)
1711
1690
    {
1712
 
      KeyPartInfo *key_part_end;
1713
 
 
1714
1691
      local_key_info->table= &outparam;
1715
1692
      local_key_info->key_part= key_part;
1716
1693
 
1717
 
      for (key_part_end= key_part+ local_key_info->key_parts ;
1718
 
           key_part < key_part_end ;
1719
 
           key_part++)
 
1694
      for (KeyPartInfo* key_part_end= key_part+ local_key_info->key_parts; key_part < key_part_end; key_part++)
1720
1695
      {
1721
1696
        Field *local_field= key_part->field= outparam.getField(key_part->fieldnr-1);
1722
1697
 
1723
 
        if (local_field->key_length() != key_part->length &&
1724
 
            !(local_field->flags & BLOB_FLAG))
 
1698
        if (local_field->key_length() != key_part->length && not (local_field->flags & BLOB_FLAG))
1725
1699
        {
1726
1700
          /*
1727
1701
            We are using only a prefix of the column as a key:
2003
1977
                                        field_name,
2004
1978
                                        this);
2005
1979
  case DRIZZLE_TYPE_TIME:
2006
 
    return new (&mem_root) field::Time(ptr,
2007
 
                                       field_length,
2008
 
                                       null_pos,
2009
 
                                       null_bit,
2010
 
                                       field_name);
 
1980
    return new (&mem_root) field::Time(ptr, field_length, null_pos, null_bit, field_name);
2011
1981
  case DRIZZLE_TYPE_DATE:
2012
 
    return new (&mem_root) Field_date(ptr,
2013
 
                                 null_pos,
2014
 
                                 null_bit,
2015
 
                                 field_name);
 
1982
    return new (&mem_root) Field_date(ptr, null_pos, null_bit, field_name);
2016
1983
  case DRIZZLE_TYPE_DATETIME:
2017
 
    return new (&mem_root) Field_datetime(ptr,
2018
 
                                     null_pos,
2019
 
                                     null_bit,
2020
 
                                     field_name);
 
1984
    return new (&mem_root) Field_datetime(ptr, null_pos, null_bit, field_name);
2021
1985
  case DRIZZLE_TYPE_NULL:
2022
 
    return new (&mem_root) Field_null(ptr,
2023
 
                                      field_length,
2024
 
                                      field_name);
 
1986
    return new (&mem_root) Field_null(ptr, field_length, field_name);
2025
1987
  }
2026
 
  assert(0);
 
1988
  assert(false);
2027
1989
  abort();
2028
1990
}
2029
1991