584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
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 |
*/
|
|
19 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
21 |
|
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
22 |
#include <drizzled/error.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
23 |
#include <drizzled/table.h> |
24 |
#include <drizzled/session.h> |
|
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
25 |
|
26 |
#include <drizzled/item/cache_row.h> |
|
27 |
||
2318.7.17
by Olaf van der Spek
Refactor Items |
28 |
namespace drizzled { |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
29 |
|
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
30 |
void Item_cache_row::make_field(SendField *) |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
31 |
{
|
2318.7.17
by Olaf van der Spek
Refactor Items |
32 |
illegal_method_call("make_field"); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
33 |
}
|
34 |
||
35 |
double Item_cache_row::val_real() |
|
36 |
{
|
|
2318.7.17
by Olaf van der Spek
Refactor Items |
37 |
illegal_method_call("val"); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
38 |
return 0; |
39 |
}
|
|
40 |
||
41 |
int64_t Item_cache_row::val_int() |
|
42 |
{
|
|
2318.7.17
by Olaf van der Spek
Refactor Items |
43 |
illegal_method_call("val_int"); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
44 |
return 0; |
45 |
}
|
|
46 |
||
47 |
String *Item_cache_row::val_str(String *) |
|
48 |
{
|
|
2318.7.17
by Olaf van der Spek
Refactor Items |
49 |
illegal_method_call("val_str"); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
50 |
return 0; |
51 |
}
|
|
52 |
||
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
53 |
type::Decimal *Item_cache_row::val_decimal(type::Decimal *) |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
54 |
{
|
2318.7.17
by Olaf van der Spek
Refactor Items |
55 |
illegal_method_call("val_decimal"); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
56 |
return 0; |
57 |
}
|
|
58 |
||
59 |
enum Item_result Item_cache_row::result_type() const |
|
60 |
{
|
|
61 |
return ROW_RESULT; |
|
62 |
}
|
|
63 |
||
64 |
uint32_t Item_cache_row::cols() |
|
65 |
{
|
|
66 |
return item_count; |
|
67 |
}
|
|
68 |
||
69 |
Item *Item_cache_row::element_index(uint32_t i) |
|
70 |
{
|
|
71 |
return values[i]; |
|
72 |
}
|
|
73 |
||
74 |
Item **Item_cache_row::addr(uint32_t i) |
|
75 |
{
|
|
76 |
return (Item **) (values + i); |
|
77 |
}
|
|
78 |
||
2318.6.27
by Olaf van der Spek
Refactor |
79 |
void Item_cache_row::allocate(uint32_t num) |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
80 |
{
|
81 |
item_count= num; |
|
2318.6.20
by Olaf van der Spek
Refactor |
82 |
values= (Item_cache **) getSession().mem.calloc(sizeof(Item_cache *)*item_count); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
83 |
}
|
84 |
||
85 |
bool Item_cache_row::setup(Item * item) |
|
86 |
{
|
|
87 |
example= item; |
|
2318.6.27
by Olaf van der Spek
Refactor |
88 |
if (!values) |
89 |
allocate(item->cols()); |
|
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
90 |
for (uint32_t i= 0; i < item_count; i++) |
91 |
{
|
|
92 |
Item *el= item->element_index(i); |
|
2318.6.20
by Olaf van der Spek
Refactor |
93 |
Item_cache *tmp= values[i]= Item_cache::get_cache(el); |
94 |
if (!tmp) |
|
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
95 |
return 1; |
96 |
tmp->setup(el); |
|
97 |
}
|
|
98 |
return 0; |
|
99 |
}
|
|
100 |
||
101 |
void Item_cache_row::store(Item * item) |
|
102 |
{
|
|
103 |
null_value= 0; |
|
104 |
item->bring_value(); |
|
105 |
for (uint32_t i= 0; i < item_count; i++) |
|
106 |
{
|
|
107 |
values[i]->store(item->element_index(i)); |
|
108 |
null_value|= values[i]->null_value; |
|
109 |
}
|
|
110 |
}
|
|
111 |
||
2318.7.17
by Olaf van der Spek
Refactor Items |
112 |
void Item_cache_row::illegal_method_call(const char*) |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
113 |
{
|
2318.7.17
by Olaf van der Spek
Refactor Items |
114 |
assert(false); |
584.4.5
by Monty Taylor
Split out cache_row and type_holder. |
115 |
my_error(ER_OPERAND_COLUMNS, MYF(0), 1); |
116 |
}
|
|
117 |
||
118 |
bool Item_cache_row::check_cols(uint32_t c) |
|
119 |
{
|
|
120 |
if (c != item_count) |
|
121 |
{
|
|
122 |
my_error(ER_OPERAND_COLUMNS, MYF(0), c); |
|
123 |
return 1; |
|
124 |
}
|
|
125 |
return 0; |
|
126 |
}
|
|
127 |
||
128 |
bool Item_cache_row::null_inside() |
|
129 |
{
|
|
130 |
for (uint32_t i= 0; i < item_count; i++) |
|
131 |
{
|
|
132 |
if (values[i]->cols() > 1) |
|
133 |
{
|
|
134 |
if (values[i]->null_inside()) |
|
135 |
return 1; |
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
values[i]->update_null_value(); |
|
140 |
if (values[i]->null_value) |
|
141 |
return 1; |
|
142 |
}
|
|
143 |
}
|
|
144 |
return 0; |
|
145 |
}
|
|
146 |
||
147 |
void Item_cache_row::bring_value() |
|
148 |
{
|
|
149 |
for (uint32_t i= 0; i < item_count; i++) |
|
150 |
values[i]->bring_value(); |
|
151 |
return; |
|
152 |
}
|
|
153 |
||
154 |
void Item_cache_row::keep_array() |
|
155 |
{
|
|
156 |
save_array= 1; |
|
157 |
}
|
|
158 |
||
159 |
void Item_cache_row::cleanup() |
|
160 |
{
|
|
161 |
Item_cache::cleanup(); |
|
162 |
if (save_array) |
|
163 |
memset(values, 0, item_count*sizeof(Item**)); |
|
164 |
else
|
|
165 |
values= 0; |
|
166 |
return; |
|
167 |
}
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
168 |
|
169 |
} /* namespace drizzled */ |