~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/select_send.h

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
 
21
 
#ifndef DRIZZLED_SELECT_SEND_H
22
 
#define DRIZZLED_SELECT_SEND_H
 
21
#pragma once
23
22
 
24
23
#include <drizzled/plugin/client.h>
25
24
#include <drizzled/plugin/query_cache.h>
26
25
#include <drizzled/plugin/transactional_storage_engine.h>
27
 
 
28
 
namespace drizzled
 
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 
29
33
{
30
 
 
31
 
class select_send :public select_result {
32
 
  /**
33
 
    True if we have sent result set metadata to the client.
34
 
    In this case the client always expects us to end the result
35
 
    set with an eof or error packet
36
 
  */
37
 
  bool is_result_set_started;
38
34
public:
39
 
  select_send() :is_result_set_started(false) {}
40
35
  bool send_eof()
41
36
  {
42
37
    /*
47
42
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
48
43
 
49
44
    /* Unlock tables before sending packet to gain some speed */
50
 
    if (session->lock)
 
45
    if (session->open_tables.lock)
51
46
    {
52
 
      session->unlockTables(session->lock);
53
 
      session->lock= 0;
 
47
      session->unlockTables(session->open_tables.lock);
 
48
      session->open_tables.lock= 0;
54
49
    }
55
50
    session->my_eof();
56
 
    is_result_set_started= 0;
57
51
    return false;
58
52
  }
59
53
 
60
 
  bool send_fields(List<Item> &list)
61
 
  {
62
 
    bool res;
63
 
    if (! (res= session->getClient()->sendFields(&list)))
64
 
      is_result_set_started= 1;
65
 
    return res;
66
 
  }
67
 
 
68
 
  void abort()
69
 
  {
70
 
    return;
71
 
  }
72
 
 
73
 
 
74
 
  /**
75
 
    Cleanup an instance of this class for re-use
76
 
    at next execution of a prepared statement/
77
 
    stored procedure statement.
78
 
  */
79
 
 
80
 
  virtual void cleanup()
81
 
  {
82
 
    is_result_set_started= false;
 
54
  void send_fields(List<Item>& list)
 
55
  {
 
56
    session->getClient()->sendFields(list);
83
57
  }
84
58
 
85
59
  /* Send data to client. Returns 0 if ok */
86
60
 
87
 
  bool send_data(List<Item> &items)
 
61
  bool send_data(List<Item>& items)
88
62
  {
89
63
    if (unit->offset_limit_cnt)
90
64
    {                                           // using limit offset,count
99
73
    */
100
74
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
101
75
 
102
 
    List_iterator_fast<Item> li(items);
 
76
    List<Item>::iterator li(items.begin());
103
77
    char buff[MAX_FIELD_WIDTH];
104
78
    String buffer(buff, sizeof(buff), &my_charset_bin);
105
79
 
106
 
    Item *item;
107
 
    while ((item=li++))
 
80
    while (Item* item= li++)
108
81
    {
109
 
      if (item->send(session->getClient(), &buffer))
110
 
      {
111
 
        my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
112
 
        break;
113
 
      }
 
82
      item->send(session->getClient(), &buffer);
114
83
    }
115
84
    /* Insert this record to the Resultset into the cache */
116
85
    if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
125
94
 
126
95
} /* namespace drizzled */
127
96
 
128
 
#endif /* DRIZZLED_SELECT_SEND_H */