~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/get_user_var.cc

  • Committer: Monty Taylor
  • Date: 2009-03-08 23:45:12 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 921.
  • Revision ID: mordred@inaugust.com-20090308234512-tqkygxtu1iaig23s
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards!

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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
22
 
#include <float.h>
23
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
24
22
#include <drizzled/function/get_user_var.h>
 
23
#include <drizzled/function/get_variable.h>
25
24
#include <drizzled/item/null.h>
26
25
#include <drizzled/sql_parse.h>
27
26
#include <drizzled/session.h>
28
 
#include <drizzled/user_var_entry.h>
29
 
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
String *Item_func_get_user_var::val_str(String *str)
 
27
 
 
28
String *
 
29
Item_func_get_user_var::val_str(String *str)
34
30
{
35
31
  assert(fixed == 1);
36
32
  if (!var_entry)
48
44
}
49
45
 
50
46
 
51
 
type::Decimal *Item_func_get_user_var::val_decimal(type::Decimal *dec)
 
47
my_decimal *Item_func_get_user_var::val_decimal(my_decimal *dec)
52
48
{
53
49
  assert(fixed == 1);
54
50
  if (!var_entry)
66
62
 
67
63
void Item_func_get_user_var::fix_length_and_dec()
68
64
{
 
65
  Session *session=current_session;
69
66
  maybe_null=1;
70
67
  decimals=NOT_FIXED_DEC;
71
68
  max_length=MAX_BLOB_WIDTH;
72
69
 
73
 
  var_entry= session.getVariable(name, false);
 
70
  var_entry= get_variable(&session->user_vars, name, 0);
74
71
 
75
72
  /*
76
73
    If the variable didn't exist it has been created as a STRING-type.
84
81
    max_length= var_entry->length;
85
82
 
86
83
    collation.set(var_entry->collation);
87
 
    switch(m_cached_result_type) 
88
 
    {
 
84
    switch(m_cached_result_type) {
89
85
    case REAL_RESULT:
90
86
      max_length= DBL_DIG + 8;
91
87
      break;
92
 
 
93
88
    case INT_RESULT:
94
89
      max_length= MAX_BIGINT_WIDTH;
95
90
      decimals=0;
97
92
    case STRING_RESULT:
98
93
      max_length= MAX_BLOB_WIDTH;
99
94
      break;
100
 
 
101
95
    case DECIMAL_RESULT:
102
96
      max_length= DECIMAL_MAX_STR_LENGTH;
103
97
      decimals= DECIMAL_MAX_SCALE;
104
98
      break;
105
 
 
106
99
    case ROW_RESULT:                            // Keep compiler happy
 
100
    default:
107
101
      assert(0);
108
102
      break;
109
103
    }
120
114
 
121
115
bool Item_func_get_user_var::const_item() const
122
116
{
123
 
  return (!var_entry || session.getQueryId() != var_entry->update_query_id);
 
117
  return (!var_entry || current_session->query_id != var_entry->update_query_id);
124
118
}
125
119
 
126
120
 
153
147
  return (name.length == other->name.length &&
154
148
          !memcmp(name.str, other->name.str, name.length));
155
149
}
156
 
 
157
 
} /* namespace drizzled */