~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/set_user_var.cc

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
91
91
  {
92
92
    Table *table= (Table *) arg;
93
93
    if (result_field->getTable() == table || !table)
94
 
      result_field->getTable()->setReadSet(result_field->position());
 
94
      result_field->getTable()->setReadSet(result_field->field_index);
95
95
  }
96
96
  return 0;
97
97
}
140
140
 
141
141
  switch (cached_result_type) {
142
142
  case REAL_RESULT:
143
 
    {
144
 
      save_result.vreal= use_result_field ? result_field->val_real() :
145
 
        args[0]->val_real();
146
 
      break;
147
 
    }
 
143
  {
 
144
    save_result.vreal= use_result_field ? result_field->val_real() :
 
145
                        args[0]->val_real();
 
146
    break;
 
147
  }
148
148
  case INT_RESULT:
149
 
    {
150
 
      save_result.vint= use_result_field ? result_field->val_int() :
151
 
        args[0]->val_int();
152
 
      unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
153
 
        args[0]->unsigned_flag;
154
 
      break;
155
 
    }
 
149
  {
 
150
    save_result.vint= use_result_field ? result_field->val_int() :
 
151
                       args[0]->val_int();
 
152
    unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
 
153
                    args[0]->unsigned_flag;
 
154
    break;
 
155
  }
156
156
  case STRING_RESULT:
157
 
    {
158
 
      save_result.vstr= use_result_field ? result_field->val_str_internal(&value) :
159
 
        args[0]->val_str(&value);
160
 
      break;
161
 
    }
 
157
  {
 
158
    save_result.vstr= use_result_field ? result_field->val_str(&value) :
 
159
                       args[0]->val_str(&value);
 
160
    break;
 
161
  }
162
162
  case DECIMAL_RESULT:
163
 
    {
164
 
      save_result.vdec= use_result_field ?
165
 
        result_field->val_decimal(&decimal_buff) :
166
 
        args[0]->val_decimal(&decimal_buff);
167
 
      break;
168
 
    }
 
163
  {
 
164
    save_result.vdec= use_result_field ?
 
165
                       result_field->val_decimal(&decimal_buff) :
 
166
                       args[0]->val_decimal(&decimal_buff);
 
167
    break;
 
168
  }
169
169
  case ROW_RESULT:
 
170
  default:
170
171
    // This case should never be chosen
171
172
    assert(0);
172
173
    break;
173
174
  }
174
 
 
175
 
  return false;
 
175
  return(false);
176
176
}
177
177
 
178
178
/**
197
197
 
198
198
  switch (cached_result_type) {
199
199
  case REAL_RESULT:
200
 
    {
201
 
      res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
202
 
                       REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
203
 
      break;
204
 
    }
205
 
 
 
200
  {
 
201
    res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
 
202
                     REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
 
203
    break;
 
204
  }
206
205
  case INT_RESULT:
207
 
    {
208
 
      res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
209
 
                       INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
210
 
                       unsigned_flag);
211
 
      break;
212
 
    }
213
 
 
 
206
  {
 
207
    res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
 
208
                     INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
 
209
                     unsigned_flag);
 
210
    break;
 
211
  }
214
212
  case STRING_RESULT:
215
 
    {
216
 
      if (!save_result.vstr)                                      // Null value
217
 
        res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
218
 
                         DERIVATION_IMPLICIT, 0);
219
 
      else
220
 
        res= update_hash((void*) save_result.vstr->ptr(),
221
 
                         save_result.vstr->length(), STRING_RESULT,
222
 
                         save_result.vstr->charset(),
223
 
                         DERIVATION_IMPLICIT, 0);
224
 
      break;
225
 
    }
226
 
 
 
213
  {
 
214
    if (!save_result.vstr)                                      // Null value
 
215
      res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
 
216
                       DERIVATION_IMPLICIT, 0);
 
217
    else
 
218
      res= update_hash((void*) save_result.vstr->ptr(),
 
219
                       save_result.vstr->length(), STRING_RESULT,
 
220
                       save_result.vstr->charset(),
 
221
                       DERIVATION_IMPLICIT, 0);
 
222
    break;
 
223
  }
227
224
  case DECIMAL_RESULT:
228
 
    {
229
 
      if (!save_result.vdec)                                      // Null value
230
 
        res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
231
 
                         DERIVATION_IMPLICIT, 0);
232
 
      else
233
 
        res= update_hash((void*) save_result.vdec,
234
 
                         sizeof(type::Decimal), DECIMAL_RESULT,
235
 
                         &my_charset_bin, DERIVATION_IMPLICIT, 0);
236
 
      break;
237
 
    }
238
 
 
 
225
  {
 
226
    if (!save_result.vdec)                                      // Null value
 
227
      res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
 
228
                       DERIVATION_IMPLICIT, 0);
 
229
    else
 
230
      res= update_hash((void*) save_result.vdec,
 
231
                       sizeof(my_decimal), DECIMAL_RESULT,
 
232
                       &my_charset_bin, DERIVATION_IMPLICIT, 0);
 
233
    break;
 
234
  }
239
235
  case ROW_RESULT:
 
236
  default:
240
237
    // This case should never be chosen
241
238
    assert(0);
242
239
    break;
243
240
  }
244
 
 
245
241
  return(res);
246
242
}
247
243
 
270
266
}
271
267
 
272
268
 
273
 
type::Decimal *Item_func_set_user_var::val_decimal(type::Decimal *val)
 
269
my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
274
270
{
275
271
  assert(fixed == 1);
276
272
  check(0);
303
299
}
304
300
 
305
301
 
306
 
type::Decimal *Item_func_set_user_var::val_decimal_result(type::Decimal *val)
 
302
my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
307
303
{
308
304
  assert(fixed == 1);
309
305
  check(true);
341
337
      tmp_field->col_name=Item::name;               // Use user supplied name
342
338
  }
343
339
  else
344
 
  {
345
340
    Item::make_field(tmp_field);
346
 
  }
347
341
}
348
342
 
349
343
/*
426
420
  }
427
421
  else if (result_type() == DECIMAL_RESULT)
428
422
  {
429
 
    type::Decimal decimal_value;
430
 
    type::Decimal *val= entry->val_decimal(&null_value, &decimal_value);
 
423
    my_decimal decimal_value;
 
424
    my_decimal *val= entry->val_decimal(&null_value, &decimal_value);
431
425
    if (null_value)
432
426
      return set_field_to_null(field);
433
427
    field->set_notnull();