~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/user_var_entry.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-21 16:39:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20101221163940-c1pfo1jjvx7909xq
Tags: 2010.12.06-0ubuntu1
* New upstream release.
* Added libaio-dev build depend for InnoDB.
* Removed libpcre patch - applied upstream.

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