~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.cc

  • Committer: patrick crews
  • Date: 2010-09-29 15:15:19 UTC
  • mfrom: (1099.4.188 drizzle)
  • Revision ID: gleebix@gmail.com-20100929151519-6mrmzd1ciw2p9nws
Tags: 2010.09.1802
Update translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
 
21
 
21
22
#include "config.h"
22
 
#include <boost/lexical_cast.hpp>
23
23
#include "drizzled/field/enum.h"
24
24
#include "drizzled/error.h"
25
25
#include "drizzled/table.h"
43
43
  value--; /* we store as starting from 0, although SQL starts from 1 */
44
44
 
45
45
#ifdef WORDS_BIGENDIAN
46
 
  if (getTable()->getShare()->db_low_byte_first)
 
46
  if (getTable()->s->db_low_byte_first)
47
47
  {
48
48
    int4store(ptr, (unsigned short) value);
49
49
  }
110
110
 
111
111
  if (from <= 0 || (uint64_t) from > typelib->count)
112
112
  {
113
 
    /* Convert the integer to a string using boost::lexical_cast */
114
 
    std::string tmp(boost::lexical_cast<std::string>(from));
 
113
    /* Convert the integer to a string using stringstream */
 
114
    std::stringstream ss;
 
115
    std::string tmp;
 
116
    ss << from; ss >> tmp;
115
117
 
116
118
    my_error(ER_INVALID_ENUM_VALUE, MYF(ME_FATALERROR), tmp.c_str());
117
119
    return 1;
131
133
 
132
134
  uint16_t tmp;
133
135
#ifdef WORDS_BIGENDIAN
134
 
  if (getTable()->getShare()->db_low_byte_first)
 
136
  if (getTable()->s->db_low_byte_first)
135
137
    tmp= sint4korr(ptr);
136
138
  else
137
139
#endif
145
147
 
146
148
  ASSERT_COLUMN_MARKED_FOR_READ;
147
149
 
148
 
  if (not tmp || tmp > typelib->count)
 
150
  if (!tmp || tmp > typelib->count)
149
151
  {
150
152
    val_ptr->set("", 0, field_charset);
151
153
  }
191
193
  uint32_t *len= typelib->type_lengths;
192
194
  for (const char **pos= typelib->type_names; *pos; pos++, len++)
193
195
  {
194
 
    size_t dummy_errors;
 
196
    uint32_t dummy_errors;
195
197
    if (flag)
196
198
      res.append(',');
197
199
    /* convert to res.charset() == utf8, then quote */
208
210
  Field_enum *res= (Field_enum*) Field::new_field(root, new_table, keep_type);
209
211
  if (res)
210
212
  {
211
 
    res->typelib= typelib->copy_typelib(root);
 
213
    res->typelib= copy_typelib(root, typelib);
212
214
  }
213
215
  return res;
214
216
}