~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/set_user_var.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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
91
91
  {
92
92
    Table *table= (Table *) arg;
93
93
    if (result_field->getTable() == table || !table)
94
 
      result_field->getTable()->setReadSet(result_field->field_index);
 
94
      result_field->getTable()->setReadSet(result_field->position());
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(&value) :
159
 
                       args[0]->val_str(&value);
160
 
    break;
161
 
  }
 
157
    {
 
158
      save_result.vstr= use_result_field ? result_field->val_str_internal(&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:
171
170
    // This case should never be chosen
172
171
    assert(0);
173
172
    break;
174
173
  }
175
 
  return(false);
 
174
 
 
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
 
  }
 
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
 
205
206
  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
 
  }
 
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
 
212
214
  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
 
  }
 
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
 
224
227
  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
 
  }
 
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
 
235
239
  case ROW_RESULT:
236
 
  default:
237
240
    // This case should never be chosen
238
241
    assert(0);
239
242
    break;
240
243
  }
 
244
 
241
245
  return(res);
242
246
}
243
247
 
266
270
}
267
271
 
268
272
 
269
 
my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
 
273
type::Decimal *Item_func_set_user_var::val_decimal(type::Decimal *val)
270
274
{
271
275
  assert(fixed == 1);
272
276
  check(0);
299
303
}
300
304
 
301
305
 
302
 
my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
 
306
type::Decimal *Item_func_set_user_var::val_decimal_result(type::Decimal *val)
303
307
{
304
308
  assert(fixed == 1);
305
309
  check(true);
337
341
      tmp_field->col_name=Item::name;               // Use user supplied name
338
342
  }
339
343
  else
 
344
  {
340
345
    Item::make_field(tmp_field);
 
346
  }
341
347
}
342
348
 
343
349
/*
420
426
  }
421
427
  else if (result_type() == DECIMAL_RESULT)
422
428
  {
423
 
    my_decimal decimal_value;
424
 
    my_decimal *val= entry->val_decimal(&null_value, &decimal_value);
 
429
    type::Decimal decimal_value;
 
430
    type::Decimal *val= entry->val_decimal(&null_value, &decimal_value);
425
431
    if (null_value)
426
432
      return set_field_to_null(field);
427
433
    field->set_notnull();