~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/int32.cc

  • Committer: Brian Aker
  • Date: 2010-12-18 06:28:23 UTC
  • mto: This revision was merged to the branch mainline in revision 2016.
  • Revision ID: brian@tangent.org-20101218062823-ig7x8su0om67qnf9
Removed low byte from int32  (we don't port myisam tables, so this doesn't
much matter).

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
    error= get_int(cs, from, len, &rnd, UINT32_MAX, INT32_MIN, INT32_MAX);
53
53
    store_tmp= (long) rnd;
54
 
#ifdef WORDS_BIGENDIAN
55
 
    if (getTable()->getShare()->db_low_byte_first)
56
 
    {
57
 
      int4store(ptr, store_tmp);
58
 
    }
59
 
    else
60
 
#endif
61
 
      longstore(ptr, store_tmp);
 
54
    longstore(ptr, store_tmp);
 
55
 
62
56
    return error;
63
57
  }
64
58
 
87
81
    if (error)
88
82
      set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
89
83
 
90
 
#ifdef WORDS_BIGENDIAN
91
 
    if (getTable()->getShare()->db_low_byte_first)
92
 
    {
93
 
      int4store(ptr,res);
94
 
    }
95
 
    else
96
 
#endif
97
 
      longstore(ptr,res);
 
84
    longstore(ptr,res);
 
85
 
98
86
    return error;
99
87
  }
100
88
 
108
96
 
109
97
    if (nr < 0 && unsigned_val)
110
98
      nr= ((int64_t) INT32_MAX) + 1;           // Generate overflow
 
99
 
111
100
    if (nr < (int64_t) INT32_MIN)
112
101
    {
113
102
      res=(int32_t) INT32_MIN;
119
108
      error= 1;
120
109
    }
121
110
    else
 
111
    {
122
112
      res=(int32_t) nr;
 
113
    }
123
114
 
124
115
    if (error)
125
116
      set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
126
117
 
127
 
#ifdef WORDS_BIGENDIAN
128
 
    if (getTable()->getShare()->db_low_byte_first)
129
 
    {
130
 
      int4store(ptr,res);
131
 
    }
132
 
    else
133
 
#endif
134
 
      longstore(ptr,res);
 
118
    longstore(ptr,res);
 
119
 
135
120
    return error;
136
121
  }
137
122
 
142
127
 
143
128
    ASSERT_COLUMN_MARKED_FOR_READ;
144
129
 
145
 
#ifdef WORDS_BIGENDIAN
146
 
    if (getTable()->getShare()->db_low_byte_first)
147
 
      j=sint4korr(ptr);
148
 
    else
149
 
#endif
150
 
      longget(j,ptr);
 
130
    longget(j,ptr);
 
131
 
151
132
    return (double) j;
152
133
  }
153
134
 
157
138
 
158
139
    ASSERT_COLUMN_MARKED_FOR_READ;
159
140
 
160
 
    /* See the comment in Int32::store(int64_t) */
161
 
#ifdef WORDS_BIGENDIAN
162
 
    if (getTable()->getShare()->db_low_byte_first)
163
 
      j=sint4korr(ptr);
164
 
    else
165
 
#endif
166
 
      longget(j,ptr);
 
141
    longget(j,ptr);
 
142
 
167
143
    return (int64_t) j;
168
144
  }
169
145
 
170
 
  String *Int32::val_str(String *val_buffer,
171
 
                         String *)
 
146
  String *Int32::val_str(String *val_buffer, String *)
172
147
  {
173
148
    const CHARSET_INFO * const cs= &my_charset_bin;
174
149
    uint32_t length;
179
154
 
180
155
    ASSERT_COLUMN_MARKED_FOR_READ;
181
156
 
182
 
#ifdef WORDS_BIGENDIAN
183
 
    if (getTable()->getShare()->db_low_byte_first)
184
 
      j=sint4korr(ptr);
185
 
    else
186
 
#endif
187
 
      longget(j,ptr);
 
157
    longget(j,ptr);
188
158
 
189
159
    length=cs->cset->long10_to_str(cs,to,mlength,-10,(long) j);
190
160
    val_buffer->length(length);
195
165
  int Int32::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
196
166
  {
197
167
    int32_t a,b;
198
 
#ifdef WORDS_BIGENDIAN
199
 
    if (getTable()->getShare()->db_low_byte_first)
200
 
    {
201
 
      a=sint4korr(a_ptr);
202
 
      b=sint4korr(b_ptr);
203
 
    }
204
 
    else
205
 
#endif
206
 
    {
207
 
      longget(a,a_ptr);
208
 
      longget(b,b_ptr);
209
 
    }
 
168
 
 
169
    longget(a,a_ptr);
 
170
    longget(b,b_ptr);
210
171
 
211
172
    return (a < b) ? -1 : (a > b) ? 1 : 0;
212
173
  }
214
175
  void Int32::sort_string(unsigned char *to,uint32_t )
215
176
  {
216
177
#ifdef WORDS_BIGENDIAN
217
 
    if (!getTable()->getShare()->db_low_byte_first)
218
178
    {
219
179
      to[0] = (char) (ptr[0] ^ 128);            /* Revers signbit */
220
180
      to[1]   = ptr[1];
221
181
      to[2]   = ptr[2];
222
182
      to[3]   = ptr[3];
223
183
    }
224
 
    else
225
 
#endif
 
184
#else
226
185
    {
227
186
      to[0] = (char) (ptr[3] ^ 128);            /* Revers signbit */
228
187
      to[1]   = ptr[2];
229
188
      to[2]   = ptr[1];
230
189
      to[3]   = ptr[0];
231
190
    }
 
191
#endif
232
192
  }
233
193
 
234
194
 
238
198
    res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(), "int"));
239
199
  }
240
200
 
241
 
  unsigned char *Int32::pack(unsigned char* to, const unsigned char *from,
242
 
                             uint32_t,
243
 
#ifdef WORDS_BIGENDIAN
244
 
                             bool low_byte_first
245
 
#else
246
 
                             bool
247
 
#endif
248
 
                            )
 
201
  unsigned char *Int32::pack(unsigned char* to, const unsigned char *from, uint32_t, bool)
249
202
  {
250
203
    int32_t val;
251
 
#ifdef WORDS_BIGENDIAN
252
 
    if (getTable()->getShare()->db_low_byte_first)
253
 
      val = sint4korr(from);
254
 
    else
255
 
#endif
256
 
      longget(val, from);
 
204
    longget(val, from);
257
205
 
258
 
#ifdef WORDS_BIGENDIAN
259
 
    if (low_byte_first)
260
 
      int4store(to, val);
261
 
    else
262
 
#endif
263
 
      longstore(to, val);
 
206
    longstore(to, val);
264
207
    return to + sizeof(val);
265
208
  }
266
209
 
267
210
 
268
 
  const unsigned char *Int32::unpack(unsigned char* to, const unsigned char *from, uint32_t,
269
 
#ifdef WORDS_BIGENDIAN
270
 
                                     bool low_byte_first
271
 
#else
272
 
                                     bool
273
 
#endif
274
 
                                    )
 
211
  const unsigned char *Int32::unpack(unsigned char* to, const unsigned char *from, uint32_t, bool)
275
212
  {
276
213
    int32_t val;
277
 
#ifdef WORDS_BIGENDIAN
278
 
    if (low_byte_first)
279
 
      val = sint4korr(from);
280
 
    else
281
 
#endif
282
 
      longget(val, from);
283
 
 
284
 
#ifdef WORDS_BIGENDIAN
285
 
    if (getTable()->getShare()->db_low_byte_first)
286
 
      int4store(to, val);
287
 
    else
288
 
#endif
289
 
      longstore(to, val);
 
214
    longget(val, from);
 
215
 
 
216
    longstore(to, val);
 
217
 
290
218
    return from + sizeof(val);
291
219
  }
292
220