~drizzle-trunk/drizzle/development

837 by Brian Aker
Reworked some classes out of session.h
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.
837 by Brian Aker
Reworked some classes out of session.h
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
837 by Brian Aker
Reworked some classes out of session.h
22
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
23
#include <drizzled/plugin/client.h>
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
24
#include <drizzled/plugin/query_cache.h>
1273.1.15 by Jay Pipes
This patch completes the first step in the splitting of
25
#include <drizzled/plugin/transactional_storage_engine.h>
2154.2.24 by Brian Aker
Merge in all changes for current_session, etc.
26
#include <drizzled/select_result.h>
2234.1.4 by Olaf van der Spek
Refactor includes
27
#include <drizzled/sql_lex.h>
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
28
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
29
namespace drizzled
30
{
31
837 by Brian Aker
Reworked some classes out of session.h
32
class select_send :public select_result {
33
  /**
34
    True if we have sent result set metadata to the client.
35
    In this case the client always expects us to end the result
36
    set with an eof or error packet
37
  */
38
  bool is_result_set_started;
39
public:
40
  select_send() :is_result_set_started(false) {}
41
  bool send_eof()
42
  {
43
    /*
44
      We may be passing the control from mysqld to the client: release the
45
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
46
      by session
47
    */
1273.1.15 by Jay Pipes
This patch completes the first step in the splitting of
48
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
837 by Brian Aker
Reworked some classes out of session.h
49
50
    /* Unlock tables before sending packet to gain some speed */
51
    if (session->lock)
52
    {
1910.2.7 by Brian Aker
Rename lock methods to be style + well make sense.
53
      session->unlockTables(session->lock);
837 by Brian Aker
Reworked some classes out of session.h
54
      session->lock= 0;
55
    }
56
    session->my_eof();
57
    is_result_set_started= 0;
58
    return false;
59
  }
60
971.3.63 by Eric Day
Removed protocol field flags.
61
  bool send_fields(List<Item> &list)
837 by Brian Aker
Reworked some classes out of session.h
62
  {
63
    bool res;
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
64
    if (! (res= session->getClient()->sendFields(&list)))
837 by Brian Aker
Reworked some classes out of session.h
65
      is_result_set_started= 1;
66
    return res;
67
  }
68
69
  void abort()
70
  {
71
    return;
72
  }
73
74
75
  /**
76
    Cleanup an instance of this class for re-use
77
    at next execution of a prepared statement/
78
    stored procedure statement.
79
  */
80
81
  virtual void cleanup()
82
  {
83
    is_result_set_started= false;
84
  }
85
86
  /* Send data to client. Returns 0 if ok */
87
88
  bool send_data(List<Item> &items)
89
  {
90
    if (unit->offset_limit_cnt)
91
    {						// using limit offset,count
92
      unit->offset_limit_cnt--;
93
      return false;
94
    }
95
96
    /*
97
      We may be passing the control from mysqld to the client: release the
98
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
99
      by session
100
    */
1273.1.15 by Jay Pipes
This patch completes the first step in the splitting of
101
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
837 by Brian Aker
Reworked some classes out of session.h
102
2183.2.12 by Olaf van der Spek
Use List::begin()
103
    List<Item>::iterator li(items.begin());
837 by Brian Aker
Reworked some classes out of session.h
104
    char buff[MAX_FIELD_WIDTH];
105
    String buffer(buff, sizeof(buff), &my_charset_bin);
106
107
    Item *item;
108
    while ((item=li++))
109
    {
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
110
      if (item->send(session->getClient(), &buffer))
837 by Brian Aker
Reworked some classes out of session.h
111
      {
112
        my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
113
        break;
114
      }
115
    }
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
116
    /* Insert this record to the Resultset into the cache */
1643.6.3 by Djellel E. Difallah
Refactoring of the QC Plugin's interface methods, adding mutual exclusion mechanism between sessions to cache a query, Store Meta inoformation of all the tables and select fields of the query
117
    if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
118
      plugin::QueryCache::insertRecord(session, items);
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
119
837 by Brian Aker
Reworked some classes out of session.h
120
    session->sent_row_count++;
121
    if (session->is_error())
122
      return true;
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
123
    return session->getClient()->flush();
837 by Brian Aker
Reworked some classes out of session.h
124
  }
125
};
126
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
127
} /* namespace drizzled */
128