642.1.11
by Lee
move functions from item.cc/item.h to item directory |
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.
|
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
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> |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
21 |
#include <drizzled/error.h> |
22 |
#include <drizzled/name_resolution_context.h> |
|
23 |
#include <drizzled/table.h> |
|
24 |
#include <drizzled/item/insert_value.h> |
|
642.1.24
by Lee
more header file cleanup |
25 |
#include <drizzled/item/ref.h> |
642.1.61
by Lee
more header file cleanup |
26 |
#include <drizzled/item/copy_string.h> |
1008.3.1
by Stewart Smith
move Item_default_value out into its own files under drizzled/item/ to make it easier to find and follow current convention |
27 |
#include <drizzled/item/default_value.h> |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
28 |
#include <drizzled/field/null.h> |
29 |
||
2318.7.18
by Olaf van der Spek
Refactor Items |
30 |
namespace drizzled { |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
31 |
|
32 |
bool Item_insert_value::eq(const Item *item, bool binary_cmp) const |
|
33 |
{
|
|
34 |
return item->type() == INSERT_VALUE_ITEM && |
|
35 |
((Item_default_value *)item)->arg->eq(arg, binary_cmp); |
|
36 |
}
|
|
37 |
||
38 |
bool Item_insert_value::fix_fields(Session *session, Item **) |
|
39 |
{
|
|
40 |
assert(fixed == 0); |
|
41 |
/* We should only check that arg is in first table */
|
|
42 |
if (!arg->fixed) |
|
43 |
{
|
|
44 |
TableList *orig_next_table= context->last_name_resolution_table; |
|
45 |
context->last_name_resolution_table= context->first_name_resolution_table; |
|
2318.7.19
by Olaf van der Spek
Refactor Items |
46 |
bool res= arg->fix_fields(session, &arg); |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
47 |
context->last_name_resolution_table= orig_next_table; |
48 |
if (res) |
|
49 |
return true; |
|
50 |
}
|
|
51 |
||
52 |
if (arg->type() == REF_ITEM) |
|
53 |
{
|
|
54 |
Item_ref *ref= (Item_ref *)arg; |
|
55 |
if (ref->ref[0]->type() != FIELD_ITEM) |
|
56 |
{
|
|
57 |
my_error(ER_BAD_FIELD_ERROR, MYF(0), "", "VALUES() function"); |
|
58 |
return true; |
|
59 |
}
|
|
60 |
arg= ref->ref[0]; |
|
61 |
}
|
|
62 |
/*
|
|
63 |
According to our SQL grammar, VALUES() function can reference
|
|
64 |
only to a column.
|
|
65 |
*/
|
|
66 |
assert(arg->type() == FIELD_ITEM); |
|
67 |
||
68 |
Item_field *field_arg= (Item_field *)arg; |
|
69 |
||
1672.3.5
by Brian Aker
This replaces the allocation we do for insert/update. |
70 |
if (field_arg->field->getTable()->insert_values.size()) |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
71 |
{
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
72 |
Field *def_field= (Field*) memory::sql_alloc(field_arg->field->size_of()); |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
73 |
memcpy(def_field, field_arg->field, field_arg->field->size_of()); |
1122.2.12
by Monty Taylor
Removed the silly my_ptrdiff_t typedef. |
74 |
def_field->move_field_offset((ptrdiff_t) |
1672.3.5
by Brian Aker
This replaces the allocation we do for insert/update. |
75 |
(&def_field->getTable()->insert_values[0] - def_field->getTable()->record[0])); |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
76 |
set_field(def_field); |
77 |
}
|
|
78 |
else
|
|
79 |
{
|
|
80 |
/* charset doesn't matter here, it's to avoid sigsegv only */
|
|
2318.7.18
by Olaf van der Spek
Refactor Items |
81 |
Field* tmp_field= new Field_null(0, 0, field_arg->field->field_name); |
82 |
tmp_field->init(field_arg->field->getTable()); |
|
83 |
set_field(tmp_field); |
|
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
84 |
}
|
85 |
return false; |
|
86 |
}
|
|
87 |
||
88 |
||
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
89 |
void Item_insert_value::print(String *str) |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
90 |
{
|
91 |
str->append(STRING_WITH_LEN("values(")); |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
92 |
arg->print(str); |
642.1.11
by Lee
move functions from item.cc/item.h to item directory |
93 |
str->append(')'); |
94 |
}
|
|
95 |
||
96 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
97 |
} /* namespace drizzled */ |