~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>
2263.3.11 by Olaf van der Spek
Open Tables
28
#include <drizzled/open_tables_state.h>
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
29
2263.3.11 by Olaf van der Spek
Open Tables
30
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
31
2318.3.9 by Olaf van der Spek
Refactor
32
class select_send : public select_result 
33
{
837 by Brian Aker
Reworked some classes out of session.h
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
    */
1273.1.15 by Jay Pipes
This patch completes the first step in the splitting of
42
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
837 by Brian Aker
Reworked some classes out of session.h
43
44
    /* Unlock tables before sending packet to gain some speed */
2263.3.3 by Olaf van der Spek
Use open_tables
45
    if (session->open_tables.lock)
837 by Brian Aker
Reworked some classes out of session.h
46
    {
2263.3.3 by Olaf van der Spek
Use open_tables
47
      session->unlockTables(session->open_tables.lock);
48
      session->open_tables.lock= 0;
837 by Brian Aker
Reworked some classes out of session.h
49
    }
50
    session->my_eof();
51
    return false;
52
  }
53
2318.3.10 by Olaf van der Spek
Return void
54
  void send_fields(List<Item>& list)
837 by Brian Aker
Reworked some classes out of session.h
55
  {
2318.3.8 by Olaf van der Spek
Refactor
56
    session->getClient()->sendFields(list);
837 by Brian Aker
Reworked some classes out of session.h
57
  }
58
59
  /* Send data to client. Returns 0 if ok */
60
2318.3.9 by Olaf van der Spek
Refactor
61
  bool send_data(List<Item>& items)
837 by Brian Aker
Reworked some classes out of session.h
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
    */
1273.1.15 by Jay Pipes
This patch completes the first step in the splitting of
74
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
837 by Brian Aker
Reworked some classes out of session.h
75
2183.2.12 by Olaf van der Spek
Use List::begin()
76
    List<Item>::iterator li(items.begin());
837 by Brian Aker
Reworked some classes out of session.h
77
    char buff[MAX_FIELD_WIDTH];
78
    String buffer(buff, sizeof(buff), &my_charset_bin);
79
2313.3.7 by Olaf van der Spek
Return void
80
    while (Item* item= li++)
837 by Brian Aker
Reworked some classes out of session.h
81
    {
2313.3.7 by Olaf van der Spek
Return void
82
      item->send(session->getClient(), &buffer);
837 by Brian Aker
Reworked some classes out of session.h
83
    }
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
84
    /* Insert this record to the Resultset into the cache */
2385.3.14 by Olaf van der Spek
Remove unused Session::query_cache_key var
85
    /*
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
86
    if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
87
      plugin::QueryCache::insertRecord(session, items);
2385.3.14 by Olaf van der Spek
Remove unused Session::query_cache_key var
88
    */
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
89
837 by Brian Aker
Reworked some classes out of session.h
90
    session->sent_row_count++;
91
    if (session->is_error())
92
      return true;
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
93
    return session->getClient()->flush();
837 by Brian Aker
Reworked some classes out of session.h
94
  }
95
};
96
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
97
} /* namespace drizzled */
98