~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_item.cc

  • Committer: Monty Taylor
  • Date: 2009-03-20 04:49:49 UTC
  • mto: (950.1.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 958.
  • Revision ID: mordred@inaugust.com-20090320044949-nfx7ygyy89ojl6v5
RemovedĀ unusedĀ code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
  Buffers to save and compare item values
25
25
*/
26
26
 
27
 
#include "config.h"
 
27
#include <drizzled/server_includes.h>
28
28
#include <drizzled/cached_item.h>
29
29
#include <drizzled/sql_string.h>
30
30
#include <drizzled/session.h>
31
 
#include <algorithm>
32
 
 
33
 
using namespace std;
34
 
 
35
 
namespace drizzled
36
 
{
37
31
 
38
32
/**
39
33
  Create right type of Cached_item for an item.
40
34
*/
41
35
 
42
 
Cached_item *new_Cached_item(Session *session, Item *item)
 
36
Cached_item *new_Cached_item(Session *session, Item *item,
 
37
                             bool use_result_field)
43
38
{
44
39
  if (item->real_item()->type() == Item::FIELD_ITEM &&
45
40
      !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
46
41
  {
47
42
    Item_field *real_item= (Item_field *) item->real_item();
48
 
    Field *cached_field= real_item->field;
 
43
    Field *cached_field= use_result_field ? real_item->result_field :
 
44
                                            real_item->field;
49
45
    return new Cached_item_field(cached_field);
50
46
  }
51
 
 
52
47
  switch (item->result_type()) {
53
48
  case STRING_RESULT:
54
49
    return new Cached_item_str(session, (Item_field *) item);
59
54
  case DECIMAL_RESULT:
60
55
    return new Cached_item_decimal(item);
61
56
  case ROW_RESULT:
 
57
  default:
62
58
    assert(0);
63
59
    return 0;
64
60
  }
65
 
 
66
 
  abort();
67
61
}
68
62
 
69
63
Cached_item::~Cached_item() {}
76
70
*/
77
71
 
78
72
Cached_item_str::Cached_item_str(Session *session, Item *arg)
79
 
  :item(arg), value(min(arg->max_length,
80
 
                        (uint32_t)session->variables.max_sort_length))
 
73
  :item(arg), value(cmin(arg->max_length,
 
74
                         (uint32_t)session->variables.max_sort_length))
81
75
{}
82
76
 
83
77
bool Cached_item_str::cmp(void)
86
80
  bool tmp;
87
81
 
88
82
  if ((res=item->val_str(&tmp_value)))
89
 
    res->length(min(res->length(), value.alloced_length()));
 
83
    res->length(cmin(res->length(), value.alloced_length()));
90
84
 
91
85
  if (null_value != item->null_value)
92
86
  {
137
131
}
138
132
 
139
133
 
140
 
Cached_item_field::Cached_item_field(Field *arg_field) 
141
 
  : 
142
 
    field(arg_field)
143
 
{
144
 
  /* TODO: take the memory allocation below out of the constructor. */
145
 
  buff= (unsigned char*) memory::sql_calloc(length= field->pack_length());
146
 
}
147
 
 
148
134
bool Cached_item_field::cmp(void)
149
135
{
150
136
  // This is not a blob!
151
 
  bool tmp= field->cmp_internal(buff) != 0;
 
137
  bool tmp= field->cmp(buff) != 0;
152
138
 
153
139
  if (tmp)
154
140
    field->get_image(buff,length,field->charset());
187
173
  return false;
188
174
}
189
175
 
190
 
} /* namespace drizzled */
 
176