~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/double.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include <config.h>
 
22
#include "config.h"
23
23
 
24
24
#include <float.h>
25
25
#include <math.h>
30
30
#include <drizzled/error.h>
31
31
#include <drizzled/table.h>
32
32
#include <drizzled/session.h>
33
 
#include <drizzled/current_session.h>
34
 
#include <drizzled/internal/m_string.h>
 
33
#include "drizzled/internal/m_string.h"
35
34
 
36
35
using namespace std;
37
36
 
38
 
namespace drizzled
39
 
{
40
37
 
41
38
/****************************************************************************
42
39
  double precision floating point numbers
49
46
  double nr= my_strntod(cs,(char*) from, len, &end, &error);
50
47
 
51
48
  ASSERT_COLUMN_MARKED_FOR_WRITE;
52
 
  if (error || (!len || (((uint32_t) (end-from) != len) && getTable()->in_use->count_cuted_fields)))
 
49
  if (error || (!len || (((uint32_t) (end-from) != len) && table->in_use->count_cuted_fields)))
53
50
  {
54
51
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
55
52
                (error ? ER_WARN_DATA_OUT_OF_RANGE : ER_WARN_DATA_TRUNCATED), 1);
67
64
  ASSERT_COLUMN_MARKED_FOR_WRITE;
68
65
 
69
66
#ifdef WORDS_BIGENDIAN
70
 
  if (getTable()->getShare()->db_low_byte_first)
 
67
  if (table->s->db_low_byte_first)
71
68
  {
72
69
    float8store(ptr,nr);
73
70
  }
84
81
                             (double) nr);
85
82
}
86
83
 
87
 
double Field_double::val_real(void) const
 
84
double Field_double::val_real(void)
88
85
{
89
86
  double j;
90
87
 
91
88
  ASSERT_COLUMN_MARKED_FOR_READ;
92
89
 
93
90
#ifdef WORDS_BIGENDIAN
94
 
  if (getTable()->getShare()->db_low_byte_first)
 
91
  if (table->s->db_low_byte_first)
95
92
  {
96
93
    float8get(j,ptr);
97
94
  }
101
98
  return j;
102
99
}
103
100
 
104
 
int64_t Field_double::val_int(void) const
 
101
int64_t Field_double::val_int(void)
105
102
{
106
103
  double j;
107
104
  int64_t res;
109
106
  ASSERT_COLUMN_MARKED_FOR_READ;
110
107
 
111
108
#ifdef WORDS_BIGENDIAN
112
 
  if (getTable()->getShare()->db_low_byte_first)
 
109
  if (table->s->db_low_byte_first)
113
110
  {
114
111
    float8get(j,ptr);
115
112
  }
134
131
    char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
135
132
    String tmp(buf, sizeof(buf), &my_charset_utf8_general_ci), *str;
136
133
    str= val_str(&tmp, &tmp);
137
 
    Session *session= getTable() ? getTable()->in_use : current_session;
138
 
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
134
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
139
135
                        ER_TRUNCATED_WRONG_VALUE,
140
136
                        ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
141
137
                        str->c_ptr());
144
140
}
145
141
 
146
142
 
147
 
String *Field_double::val_str(String *val_buffer, String *) const
 
143
String *Field_double::val_str(String *val_buffer,
 
144
                              String *)
148
145
{
149
146
  double nr;
150
147
 
151
148
  ASSERT_COLUMN_MARKED_FOR_READ;
152
149
 
153
150
#ifdef WORDS_BIGENDIAN
154
 
  if (getTable()->getShare()->db_low_byte_first)
 
151
  if (table->s->db_low_byte_first)
155
152
  {
156
153
    float8get(nr,ptr);
157
154
  }
165
162
  size_t len;
166
163
 
167
164
  if (dec >= NOT_FIXED_DEC)
168
 
    len= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, to_length - 1, to, NULL);
 
165
    len= my_gcvt(nr, MY_GCVT_ARG_DOUBLE, to_length - 1, to, NULL);
169
166
  else
170
 
    len= internal::my_fcvt(nr, dec, to, NULL);
 
167
    len= my_fcvt(nr, dec, to, NULL);
171
168
 
172
169
  val_buffer->length((uint32_t) len);
173
170
 
178
175
{
179
176
  double a,b;
180
177
#ifdef WORDS_BIGENDIAN
181
 
  if (getTable()->getShare()->db_low_byte_first)
 
178
  if (table->s->db_low_byte_first)
182
179
  {
183
180
    float8get(a,a_ptr);
184
181
    float8get(b,b_ptr);
199
196
{
200
197
  double nr;
201
198
#ifdef WORDS_BIGENDIAN
202
 
  if (getTable()->getShare()->db_low_byte_first)
 
199
  if (table->s->db_low_byte_first)
203
200
  {
204
201
    float8get(nr,ptr);
205
202
  }
224
221
  }
225
222
}
226
223
 
227
 
} /* namespace drizzled */