~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_item.cc

  • Committer: Brian Aker
  • Date: 2009-10-02 21:34:26 UTC
  • mfrom: (1134.1.4 bug426504)
  • Revision ID: brian@gaz-20091002213426-7ojknrpknoedaprl
Merge Monty

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>
32
32
 
33
33
using namespace std;
34
34
 
35
 
namespace drizzled
36
 
{
37
 
 
38
35
/**
39
36
  Create right type of Cached_item for an item.
40
37
*/
41
38
 
42
 
Cached_item *new_Cached_item(Session *session, Item *item)
 
39
Cached_item *new_Cached_item(Session *session, Item *item,
 
40
                             bool use_result_field)
43
41
{
44
42
  if (item->real_item()->type() == Item::FIELD_ITEM &&
45
43
      !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
46
44
  {
47
45
    Item_field *real_item= (Item_field *) item->real_item();
48
 
    Field *cached_field= real_item->field;
 
46
    Field *cached_field= use_result_field ? real_item->result_field :
 
47
                                            real_item->field;
49
48
    return new Cached_item_field(cached_field);
50
49
  }
51
 
 
52
50
  switch (item->result_type()) {
53
51
  case STRING_RESULT:
54
52
    return new Cached_item_str(session, (Item_field *) item);
59
57
  case DECIMAL_RESULT:
60
58
    return new Cached_item_decimal(item);
61
59
  case ROW_RESULT:
 
60
  default:
62
61
    assert(0);
63
62
    return 0;
64
63
  }
65
 
 
66
 
  abort();
67
64
}
68
65
 
69
66
Cached_item::~Cached_item() {}
137
134
}
138
135
 
139
136
 
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
137
bool Cached_item_field::cmp(void)
149
138
{
150
139
  // This is not a blob!
151
 
  bool tmp= field->cmp_internal(buff) != 0;
 
140
  bool tmp= field->cmp(buff) != 0;
152
141
 
153
142
  if (tmp)
154
143
    field->get_image(buff,length,field->charset());
187
176
  return false;
188
177
}
189
178
 
190
 
} /* namespace drizzled */
 
179