~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-04-25 20:29:54 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090425202954-slopmkjj7vxal5lk
Migrated archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
27
 
29
 
namespace drizzled
30
 
{
31
 
 
32
 
String *Item_func_get_user_var::val_str(String *str)
 
28
String *
 
29
Item_func_get_user_var::val_str(String *str)
33
30
{
34
31
  assert(fixed == 1);
35
32
  if (!var_entry)
65
62
 
66
63
void Item_func_get_user_var::fix_length_and_dec()
67
64
{
 
65
  Session *session=current_session;
68
66
  maybe_null=1;
69
67
  decimals=NOT_FIXED_DEC;
70
68
  max_length=MAX_BLOB_WIDTH;
71
69
 
72
 
  var_entry= session.getVariable(name, false);
 
70
  var_entry= get_variable(&session->user_vars, name, 0);
73
71
 
74
72
  /*
75
73
    If the variable didn't exist it has been created as a STRING-type.
83
81
    max_length= var_entry->length;
84
82
 
85
83
    collation.set(var_entry->collation);
86
 
    switch(m_cached_result_type) 
87
 
    {
 
84
    switch(m_cached_result_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 */