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
23
#include <boost/lexical_cast.hpp>
24
#include <drizzled/field.h>
25
#include <drizzled/plugin/client/concurrent.h>
26
#include <drizzled/sql/result_set.h>
33
class Cached : public Concurrent
37
sql::ResultSet *_result_set;
40
Cached(sql::ResultSet &rs) :
47
virtual bool sendFields(List<Item> *list)
49
List<Item>::iterator it(list->begin());
54
while (Item* item= it++)
57
item->make_field(&field);
60
_result_set->createRow();
65
virtual void sendError(drizzled::error_t error_code, const char *error_message)
67
_result_set->pushException(sql::Exception(error_message, error_code));
70
virtual void checkRowEnd()
72
if (++column % max_column == 0)
74
_result_set->createRow();
80
virtual bool store(Field *from)
85
char buff[MAX_FIELD_WIDTH];
86
String str(buff, sizeof(buff), &my_charset_bin);
87
from->val_str_internal(&str);
89
return store(str.ptr(), str.length());
94
_result_set->setColumnNull(currentColumn());
101
virtual bool store(int32_t from)
103
_result_set->setColumn(currentColumn(), boost::lexical_cast<std::string>(from));
109
virtual bool store(uint32_t from)
111
_result_set->setColumn(currentColumn(), boost::lexical_cast<std::string>(from));
117
virtual bool store(int64_t from)
119
_result_set->setColumn(currentColumn(), boost::lexical_cast<std::string>(from));
125
virtual bool store(uint64_t from)
127
_result_set->setColumn(currentColumn(), boost::lexical_cast<std::string>(from));
133
virtual bool store(double from, uint32_t decimals, String *buffer)
135
buffer->set_real(from, decimals, &my_charset_bin);
136
return store(buffer->ptr(), buffer->length());
139
virtual bool store(const char *from, size_t length)
141
_result_set->setColumn(currentColumn(), std::string(from, length));
147
inline uint32_t currentColumn() const
149
return column % max_column;
153
} /* namespace client */
154
} /* namespace plugin */
155
} /* namespace drizzled */