~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/user_var_entry.cc

  • Committer: Patrick Crews
  • Date: 2010-12-07 20:02:50 UTC
  • Revision ID: gleebix@gmail.com-20101207200250-6a27jgqalgw5bsb5
Added disabled.def file to disable drizzleslap due to Bug#684269.  Need to skip for tarball release this round

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
34
34
  switch (type) {
35
35
  case REAL_RESULT:
36
36
    return *(double*) value;
37
 
 
38
37
  case INT_RESULT:
39
38
    return (double) *(int64_t*) value;
40
 
 
41
39
  case DECIMAL_RESULT:
42
 
    {
43
 
      double result;
44
 
      class_decimal2double(E_DEC_FATAL_ERROR, (type::Decimal *)value, &result);
45
 
      return result;
46
 
    }
47
 
 
 
40
  {
 
41
    double result;
 
42
    my_decimal2double(E_DEC_FATAL_ERROR, (my_decimal *)value, &result);
 
43
    return result;
 
44
  }
48
45
  case STRING_RESULT:
49
46
    return internal::my_atof(value);                      // This is null terminated
50
 
 
51
47
  case ROW_RESULT:
52
48
    assert(1);                          // Impossible
53
49
    break;
66
62
  switch (type) {
67
63
  case REAL_RESULT:
68
64
    return (int64_t) *(double*) value;
69
 
 
70
65
  case INT_RESULT:
71
66
    return *(int64_t*) value;
72
 
 
73
67
  case DECIMAL_RESULT:
74
 
    {
75
 
      int64_t result;
76
 
      ((type::Decimal *)(value))->val_int32(E_DEC_FATAL_ERROR, 0, &result);
77
 
      return result;
78
 
    }
79
 
 
 
68
  {
 
69
    int64_t result;
 
70
    my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, &result);
 
71
    return result;
 
72
  }
80
73
  case STRING_RESULT:
81
 
    {
82
 
      int error;
83
 
      return internal::my_strtoll10(value, (char**) 0, &error);// String is null terminated
84
 
    }
85
 
 
 
74
  {
 
75
    int error;
 
76
    return internal::my_strtoll10(value, (char**) 0, &error);// String is null terminated
 
77
  }
86
78
  case ROW_RESULT:
87
79
    assert(1);                          // Impossible
88
80
    break;
89
81
  }
90
 
 
91
82
  return 0L;                                    // Impossible
92
83
}
93
84
 
104
95
  case REAL_RESULT:
105
96
    str->set_real(*(double*) value, decimals, &my_charset_bin);
106
97
    break;
107
 
 
108
98
  case INT_RESULT:
109
99
    if (!unsigned_flag)
110
100
      str->set(*(int64_t*) value, &my_charset_bin);
111
101
    else
112
102
      str->set(*(uint64_t*) value, &my_charset_bin);
113
103
    break;
114
 
 
115
104
  case DECIMAL_RESULT:
116
 
    class_decimal2string((type::Decimal *)value, 0, str);
 
105
    my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str);
117
106
    break;
118
 
 
119
107
  case STRING_RESULT:
120
108
    if (str->copy(value, length, collation.collation))
121
109
      str= 0;                                   // EOM error
122
 
 
123
110
  case ROW_RESULT:
124
111
    assert(1);                          // Impossible
125
112
    break;
126
113
  }
127
 
 
128
114
  return(str);
129
115
}
130
116
 
131
117
/** Get the value of a variable as a decimal. */
132
118
 
133
 
type::Decimal *user_var_entry::val_decimal(bool *null_value, type::Decimal *val)
 
119
my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
134
120
{
135
121
  if ((*null_value= (value == 0)))
136
122
    return 0;
137
123
 
138
124
  switch (type) {
139
125
  case REAL_RESULT:
140
 
    double2_class_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
 
126
    double2my_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
141
127
    break;
142
 
 
143
128
  case INT_RESULT:
144
 
    int2_class_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
 
129
    int2my_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
145
130
    break;
146
 
 
147
131
  case DECIMAL_RESULT:
148
 
    val= (type::Decimal *)value;
 
132
    val= (my_decimal *)value;
149
133
    break;
150
 
 
151
134
  case STRING_RESULT:
152
 
    val->store(E_DEC_FATAL_ERROR, value, length, collation.collation);
 
135
    str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
153
136
    break;
154
 
 
155
137
  case ROW_RESULT:
156
138
    assert(1);                          // Impossible
157
139
    break;
158
140
  }
159
 
 
160
141
  return(val);
161
142
}
162
143
 
217
198
 
218
199
    memcpy(value, ptr, arg_length);
219
200
    if (arg_type == DECIMAL_RESULT)
220
 
      ((type::Decimal*)value)->fix_buffer_pointer();
 
201
      ((my_decimal*)value)->fix_buffer_pointer();
221
202
    length= arg_length;
222
203
    collation.set(cs, dv);
223
204
    unsigned_flag= unsigned_arg;