~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_item.cc

  • Committer: Monty Taylor
  • Date: 2009-05-09 22:13:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1009.
  • Revision ID: mordred@inaugust.com-20090509221347-l712szviusbobro0
Re-added bitset<> as a replacement for Bitmap<>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
16
19
 
17
20
/**
18
21
  @file
22
25
*/
23
26
 
24
27
#include <drizzled/server_includes.h>
 
28
#include <drizzled/cached_item.h>
 
29
#include <drizzled/sql_string.h>
 
30
#include <drizzled/session.h>
25
31
 
26
32
/**
27
33
  Create right type of Cached_item for an item.
28
34
*/
29
35
 
30
 
Cached_item *new_Cached_item(THD *thd, Item *item, bool use_result_field)
 
36
Cached_item *new_Cached_item(Session *session, Item *item,
 
37
                             bool use_result_field)
31
38
{
32
39
  if (item->real_item()->type() == Item::FIELD_ITEM &&
33
40
      !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
39
46
  }
40
47
  switch (item->result_type()) {
41
48
  case STRING_RESULT:
42
 
    return new Cached_item_str(thd, (Item_field *) item);
 
49
    return new Cached_item_str(session, (Item_field *) item);
43
50
  case INT_RESULT:
44
51
    return new Cached_item_int((Item_field *) item);
45
52
  case REAL_RESULT:
62
69
    Return true if values have changed
63
70
*/
64
71
 
65
 
Cached_item_str::Cached_item_str(THD *thd, Item *arg)
66
 
  :item(arg), value(cmin(arg->max_length, (uint32_t)thd->variables.max_sort_length))
 
72
Cached_item_str::Cached_item_str(Session *session, Item *arg)
 
73
  :item(arg), value(cmin(arg->max_length,
 
74
                         (uint32_t)session->variables.max_sort_length))
67
75
{}
68
76
 
69
77
bool Cached_item_str::cmp(void)
77
85
  if (null_value != item->null_value)
78
86
  {
79
87
    if ((null_value= item->null_value))
80
 
      return(true);                     // New value was null
 
88
      // New value was null
 
89
      return(true);
81
90
    tmp=true;
82
91
  }
83
92
  else if (null_value)
84
 
    return(0);                          // new and old value was null
 
93
    // new and old value was null
 
94
    return(0);
85
95
  else
86
96
    tmp= sortcmp(&value,res,item->collation.collation) != 0;
87
97
  if (tmp)
88
 
    value.copy(*res);                           // Remember for next cmp
 
98
    // Remember for next cmp
 
99
    value.copy(*res);
89
100
  return(tmp);
90
101
}
91
102
 
92
103
Cached_item_str::~Cached_item_str()
93
104
{
94
 
  item=0;                                       // Safety
 
105
  // Safety
 
106
  item=0;
95
107
}
96
108
 
97
109
bool Cached_item_real::cmp(void)
121
133
 
122
134
bool Cached_item_field::cmp(void)
123
135
{
124
 
  bool tmp= field->cmp(buff) != 0;              // This is not a blob!
 
136
  // This is not a blob!
 
137
  bool tmp= field->cmp(buff) != 0;
 
138
 
125
139
  if (tmp)
126
140
    field->get_image(buff,length,field->charset());
127
141
  if (null_value != field->is_null())
160
174
}
161
175
 
162
176
 
163
 
/*****************************************************************************
164
 
** Instansiate templates
165
 
*****************************************************************************/
166
 
 
167
 
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
168
 
template class List<Cached_item>;
169
 
template class List_iterator<Cached_item>;
170
 
#endif