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
25
#include <drizzled/plugin/client/concurrent.h>
26
#include <drizzled/sql/result_set.h>
28
#include <boost/scoped_ptr.hpp>
39
class Cached : public Concurrent
43
sql::ResultSet *_result_set;
46
Cached(sql::ResultSet &rs) :
54
virtual bool sendFields(List<Item> *list)
56
List<Item>::iterator it(list->begin());
65
item->make_field(&field);
68
_result_set->createRow();
73
virtual void sendError(drizzled::error_t error_code, const char *error_message)
75
sql::Exception tmp(error_message, error_code);
76
_result_set->pushException(tmp);
79
virtual void checkRowEnd(void)
81
if (++column % max_column == 0)
83
_result_set->createRow();
89
virtual bool store(Field *from)
94
char buff[MAX_FIELD_WIDTH];
95
String str(buff, sizeof(buff), &my_charset_bin);
96
from->val_str_internal(&str);
98
return store(str.ptr(), str.length());
101
virtual bool store(void)
103
_result_set->setColumnNull(currentColumn());
110
virtual bool store(int32_t from)
114
tmp= boost::lexical_cast<std::string>(from);
115
_result_set->setColumn(currentColumn(), tmp);
121
virtual bool store(uint32_t from)
125
tmp= boost::lexical_cast<std::string>(from);
126
_result_set->setColumn(currentColumn(), tmp);
132
virtual bool store(int64_t from)
136
tmp= boost::lexical_cast<std::string>(from);
137
_result_set->setColumn(currentColumn(), tmp);
143
virtual bool store(uint64_t from)
147
tmp= boost::lexical_cast<std::string>(from);
148
_result_set->setColumn(currentColumn(), tmp);
154
virtual bool store(double from, uint32_t decimals, String *buffer)
156
buffer->set_real(from, decimals, &my_charset_bin);
157
return store(buffer->ptr(), buffer->length());
160
virtual bool store(const char *from, size_t length)
162
_result_set->setColumn(currentColumn(), std::string(from, length));
168
inline uint32_t currentColumn() const
170
return column % max_column;
174
} /* namespace client */
175
} /* namespace plugin */
176
} /* namespace drizzled */