1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2011 Brian Aker
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef DRIZZLED_PLUGIN_CLIENT_CACHED_H
23
#define DRIZZLED_PLUGIN_CLIENT_CACHED_H
26
#include <drizzled/plugin/client/concurrent.h>
27
#include <drizzled/sql/result_set.h>
29
#include <boost/scoped_ptr.hpp>
40
class Cached : public Concurrent
44
boost::scoped_ptr<sql::ResultSet> _result_set;
54
virtual bool sendFields(List<Item> *list)
56
List_iterator_fast<Item> it(*list);
65
item->make_field(&field);
68
_result_set.reset(new sql::ResultSet(max_column +1));
69
_result_set->createRow();
74
virtual void sendError(uint32_t error_code, const char *error_message)
76
sql::Exception tmp(error_message, static_cast<drizzled::error_t>(error_code));
77
std::cerr << tmp << std::endl;
78
_result_set->pushException(tmp);
81
virtual void checkRowEnd(void)
83
if (++column % max_column == 0)
85
_result_set->createRow();
91
virtual bool store(Field *from)
96
char buff[MAX_FIELD_WIDTH];
97
String str(buff, sizeof(buff), &my_charset_bin);
98
from->val_str_internal(&str);
100
return store(str.ptr(), str.length());
103
virtual bool store(void)
105
_result_set->setColumnNull(currentColumn());
112
virtual bool store(int32_t from)
116
tmp= boost::lexical_cast<std::string>(from);
117
_result_set->setColumn(currentColumn(), tmp);
123
virtual bool store(uint32_t from)
127
tmp= boost::lexical_cast<std::string>(from);
128
_result_set->setColumn(currentColumn(), tmp);
134
virtual bool store(int64_t from)
138
tmp= boost::lexical_cast<std::string>(from);
139
_result_set->setColumn(currentColumn(), tmp);
145
virtual bool store(uint64_t from)
149
tmp= boost::lexical_cast<std::string>(from);
150
_result_set->setColumn(currentColumn(), tmp);
156
virtual bool store(double from, uint32_t decimals, String *buffer)
158
buffer->set_real(from, decimals, &my_charset_bin);
159
return store(buffer->ptr(), buffer->length());
162
virtual bool store(const char *from, size_t length)
164
_result_set->setColumn(currentColumn(), std::string(from, length));
170
inline uint32_t currentColumn() const
172
return column % max_column;
176
} /* namespace client */
177
} /* namespace plugin */
178
} /* namespace drizzled */
180
#endif /* DRIZZLED_PLUGIN_CLIENT_CACHED_H */