~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/get_user_var.cc

Reverted 1103

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