~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_item.cc

  • Committer: Monty Taylor
  • Date: 2008-11-16 23:47:43 UTC
  • mto: (584.1.10 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116234743-c38gmv0pa2kdefaj
BrokeĀ outĀ cached_item.

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>
25
29
 
26
30
/**
27
31
  Create right type of Cached_item for an item.
28
32
*/
29
33
 
30
 
Cached_item *new_Cached_item(Session *session, Item *item, bool use_result_field)
 
34
Cached_item *new_Cached_item(Session *session, Item *item,
 
35
                             bool use_result_field)
31
36
{
32
37
  if (item->real_item()->type() == Item::FIELD_ITEM &&
33
38
      !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
63
68
*/
64
69
 
65
70
Cached_item_str::Cached_item_str(Session *session, Item *arg)
66
 
  :item(arg), value(cmin(arg->max_length, (uint32_t)session->variables.max_sort_length))
 
71
  :item(arg), value(cmin(arg->max_length,
 
72
                         (uint32_t)session->variables.max_sort_length))
67
73
{}
68
74
 
69
75
bool Cached_item_str::cmp(void)
77
83
  if (null_value != item->null_value)
78
84
  {
79
85
    if ((null_value= item->null_value))
80
 
      return(true);                     // New value was null
 
86
      // New value was null
 
87
      return(true);
81
88
    tmp=true;
82
89
  }
83
90
  else if (null_value)
84
 
    return(0);                          // new and old value was null
 
91
    // new and old value was null
 
92
    return(0);
85
93
  else
86
94
    tmp= sortcmp(&value,res,item->collation.collation) != 0;
87
95
  if (tmp)
88
 
    value.copy(*res);                           // Remember for next cmp
 
96
    // Remember for next cmp
 
97
    value.copy(*res);
89
98
  return(tmp);
90
99
}
91
100
 
92
101
Cached_item_str::~Cached_item_str()
93
102
{
94
 
  item=0;                                       // Safety
 
103
  // Safety
 
104
  item=0;
95
105
}
96
106
 
97
107
bool Cached_item_real::cmp(void)
121
131
 
122
132
bool Cached_item_field::cmp(void)
123
133
{
124
 
  bool tmp= field->cmp(buff) != 0;              // This is not a blob!
 
134
  // This is not a blob!
 
135
  bool tmp= field->cmp(buff) != 0;
 
136
 
125
137
  if (tmp)
126
138
    field->get_image(buff,length,field->charset());
127
139
  if (null_value != field->is_null())
160
172
}
161
173
 
162
174
 
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