Drizzled Public API Documentation

select_send.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
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 
20 
21 #pragma once
22 
23 #include <drizzled/plugin/client.h>
24 #include <drizzled/plugin/query_cache.h>
25 #include <drizzled/plugin/transactional_storage_engine.h>
26 #include <drizzled/select_result.h>
27 #include <drizzled/sql_lex.h>
28 #include <drizzled/open_tables_state.h>
29 
30 namespace drizzled {
31 
32 class select_send : public select_result
33 {
34 public:
35  bool send_eof()
36  {
37  /*
38  We may be passing the control from mysqld to the client: release the
39  InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
40  by session
41  */
43 
44  /* Unlock tables before sending packet to gain some speed */
45  if (session->open_tables.lock)
46  {
47  session->unlockTables(session->open_tables.lock);
48  session->open_tables.lock= 0;
49  }
50  session->my_eof();
51  return false;
52  }
53 
54  void send_fields(List<Item>& list)
55  {
56  session->getClient()->sendFields(list);
57  }
58 
59  /* Send data to client. Returns 0 if ok */
60 
61  bool send_data(List<Item>& items)
62  {
63  if (unit->offset_limit_cnt)
64  { // using limit offset,count
65  unit->offset_limit_cnt--;
66  return false;
67  }
68 
69  /*
70  We may be passing the control from mysqld to the client: release the
71  InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
72  by session
73  */
75 
76  List<Item>::iterator li(items.begin());
77  char buff[MAX_FIELD_WIDTH];
78  String buffer(buff, sizeof(buff), &my_charset_bin);
79 
80  while (Item* item= li++)
81  {
82  item->send(session->getClient(), &buffer);
83  }
84  /* Insert this record to the Resultset into the cache */
85  /*
86  if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
87  plugin::QueryCache::insertRecord(session, items);
88  */
89 
90  session->sent_row_count++;
91  if (session->is_error())
92  return true;
93  return session->getClient()->flush();
94  }
95 };
96 
97 } /* namespace drizzled */
98 
virtual void sendFields(List< Item > &)=0
TODO: Rename this file - func.h is stupid.
ha_rows sent_row_count
Definition: session.h:414
virtual bool flush()=0
bool is_error() const
Definition: session.cc:1871