~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/set_user_var.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
 
22
22
#include <drizzled/function/set_user_var.h>
23
23
#include <drizzled/field/num.h>
24
24
#include <drizzled/session.h>
25
25
#include <drizzled/plugin/client.h>
 
26
#include <drizzled/user_var_entry.h>
26
27
 
27
28
namespace drizzled
28
29
{
91
92
  {
92
93
    Table *table= (Table *) arg;
93
94
    if (result_field->getTable() == table || !table)
94
 
      result_field->getTable()->setReadSet(result_field->field_index);
 
95
      result_field->getTable()->setReadSet(result_field->position());
95
96
  }
96
97
  return 0;
97
98
}
140
141
 
141
142
  switch (cached_result_type) {
142
143
  case REAL_RESULT:
143
 
  {
144
 
    save_result.vreal= use_result_field ? result_field->val_real() :
145
 
                        args[0]->val_real();
146
 
    break;
147
 
  }
 
144
    {
 
145
      save_result.vreal= use_result_field ? result_field->val_real() :
 
146
        args[0]->val_real();
 
147
      break;
 
148
    }
148
149
  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
 
  }
 
150
    {
 
151
      save_result.vint= use_result_field ? result_field->val_int() :
 
152
        args[0]->val_int();
 
153
      unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
 
154
        args[0]->unsigned_flag;
 
155
      break;
 
156
    }
156
157
  case STRING_RESULT:
157
 
  {
158
 
    save_result.vstr= use_result_field ? result_field->val_str(&value) :
159
 
                       args[0]->val_str(&value);
160
 
    break;
161
 
  }
 
158
    {
 
159
      save_result.vstr= use_result_field ? result_field->val_str_internal(&value) :
 
160
        args[0]->val_str(&value);
 
161
      break;
 
162
    }
162
163
  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
 
  }
 
164
    {
 
165
      save_result.vdec= use_result_field ?
 
166
        result_field->val_decimal(&decimal_buff) :
 
167
        args[0]->val_decimal(&decimal_buff);
 
168
      break;
 
169
    }
169
170
  case ROW_RESULT:
170
 
  default:
171
171
    // This case should never be chosen
172
172
    assert(0);
173
173
    break;
174
174
  }
175
 
  return(false);
 
175
 
 
176
  return false;
176
177
}
177
178
 
178
179
/**
197
198
 
198
199
  switch (cached_result_type) {
199
200
  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
 
  }
 
201
    {
 
202
      res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
 
203
                       REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
 
204
      break;
 
205
    }
 
206
 
205
207
  case INT_RESULT:
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
 
  }
 
208
    {
 
209
      res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
 
210
                       INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
 
211
                       unsigned_flag);
 
212
      break;
 
213
    }
 
214
 
212
215
  case STRING_RESULT:
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
 
  }
 
216
    {
 
217
      if (!save_result.vstr)                                      // Null value
 
218
        res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
 
219
                         DERIVATION_IMPLICIT, 0);
 
220
      else
 
221
        res= update_hash((void*) save_result.vstr->ptr(),
 
222
                         save_result.vstr->length(), STRING_RESULT,
 
223
                         save_result.vstr->charset(),
 
224
                         DERIVATION_IMPLICIT, 0);
 
225
      break;
 
226
    }
 
227
 
224
228
  case DECIMAL_RESULT:
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
 
  }
 
229
    {
 
230
      if (!save_result.vdec)                                      // Null value
 
231
        res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
 
232
                         DERIVATION_IMPLICIT, 0);
 
233
      else
 
234
        res= update_hash((void*) save_result.vdec,
 
235
                         sizeof(type::Decimal), DECIMAL_RESULT,
 
236
                         &my_charset_bin, DERIVATION_IMPLICIT, 0);
 
237
      break;
 
238
    }
 
239
 
235
240
  case ROW_RESULT:
236
 
  default:
237
241
    // This case should never be chosen
238
242
    assert(0);
239
243
    break;
240
244
  }
 
245
 
241
246
  return(res);
242
247
}
243
248
 
266
271
}
267
272
 
268
273
 
269
 
my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
 
274
type::Decimal *Item_func_set_user_var::val_decimal(type::Decimal *val)
270
275
{
271
276
  assert(fixed == 1);
272
277
  check(0);
299
304
}
300
305
 
301
306
 
302
 
my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
 
307
type::Decimal *Item_func_set_user_var::val_decimal_result(type::Decimal *val)
303
308
{
304
309
  assert(fixed == 1);
305
310
  check(true);
337
342
      tmp_field->col_name=Item::name;               // Use user supplied name
338
343
  }
339
344
  else
 
345
  {
340
346
    Item::make_field(tmp_field);
 
347
  }
341
348
}
342
349
 
343
350
/*
420
427
  }
421
428
  else if (result_type() == DECIMAL_RESULT)
422
429
  {
423
 
    my_decimal decimal_value;
424
 
    my_decimal *val= entry->val_decimal(&null_value, &decimal_value);
 
430
    type::Decimal decimal_value;
 
431
    type::Decimal *val= entry->val_decimal(&null_value, &decimal_value);
425
432
    if (null_value)
426
433
      return set_field_to_null(field);
427
434
    field->set_notnull();