~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/select_send.h

  • Committer: Monty Taylor
  • Date: 2009-03-04 02:16:28 UTC
  • mto: (917.1.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 912.
  • Revision ID: mordred@inaugust.com-20090304021628-rfq0b16uoi09g8tx
Fix to make VPATH builds work again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
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
#ifndef DRIZZLED_SELECT_SEND_H
 
22
#define DRIZZLED_SELECT_SEND_H
 
23
 
 
24
class select_send :public select_result {
 
25
  /**
 
26
    True if we have sent result set metadata to the client.
 
27
    In this case the client always expects us to end the result
 
28
    set with an eof or error packet
 
29
  */
 
30
  bool is_result_set_started;
 
31
public:
 
32
  select_send() :is_result_set_started(false) {}
 
33
  bool send_eof()
 
34
  {
 
35
    /*
 
36
      We may be passing the control from mysqld to the client: release the
 
37
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
 
38
      by session
 
39
    */
 
40
    ha_release_temporary_latches(session);
 
41
 
 
42
    /* Unlock tables before sending packet to gain some speed */
 
43
    if (session->lock)
 
44
    {
 
45
      mysql_unlock_tables(session, session->lock);
 
46
      session->lock= 0;
 
47
    }
 
48
    session->my_eof();
 
49
    is_result_set_started= 0;
 
50
    return false;
 
51
  }
 
52
 
 
53
  bool send_fields(List<Item> &list, uint32_t flags)
 
54
  {
 
55
    bool res;
 
56
    if (!(res= session->protocol->send_fields(&list, flags)))
 
57
      is_result_set_started= 1;
 
58
    return res;
 
59
  }
 
60
 
 
61
  void abort()
 
62
  {
 
63
    return;
 
64
  }
 
65
 
 
66
 
 
67
  /**
 
68
    Cleanup an instance of this class for re-use
 
69
    at next execution of a prepared statement/
 
70
    stored procedure statement.
 
71
  */
 
72
 
 
73
  virtual void cleanup()
 
74
  {
 
75
    is_result_set_started= false;
 
76
  }
 
77
 
 
78
  /* Send data to client. Returns 0 if ok */
 
79
 
 
80
  bool send_data(List<Item> &items)
 
81
  {
 
82
    if (unit->offset_limit_cnt)
 
83
    {                                           // using limit offset,count
 
84
      unit->offset_limit_cnt--;
 
85
      return false;
 
86
    }
 
87
 
 
88
    /*
 
89
      We may be passing the control from mysqld to the client: release the
 
90
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
 
91
      by session
 
92
    */
 
93
    ha_release_temporary_latches(session);
 
94
 
 
95
    List_iterator_fast<Item> li(items);
 
96
    Protocol *protocol= session->protocol;
 
97
    char buff[MAX_FIELD_WIDTH];
 
98
    String buffer(buff, sizeof(buff), &my_charset_bin);
 
99
 
 
100
    protocol->prepare_for_resend();
 
101
    Item *item;
 
102
    while ((item=li++))
 
103
    {
 
104
      if (item->send(protocol, &buffer))
 
105
      {
 
106
        protocol->free();                               // Free used buffer
 
107
        my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
 
108
        break;
 
109
      }
 
110
    }
 
111
    session->sent_row_count++;
 
112
    if (session->is_error())
 
113
    {
 
114
      protocol->remove_last_row();
 
115
      return true;
 
116
    }
 
117
    if (session->drizzleclient_vio_ok())
 
118
      return(protocol->write());
 
119
    return false;
 
120
  }
 
121
};
 
122
 
 
123
#endif /* DRIZZLED_SELECT_SEND_H */