~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/select_send.h

  • Committer: Brian Aker
  • Date: 2009-08-18 07:20:29 UTC
  • mfrom: (1117.1.9 merge)
  • Revision ID: brian@gaz-20090818072029-s9ch5lcmltxwidn7
Merge of Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#ifndef DRIZZLED_SELECT_SEND_H
22
22
#define DRIZZLED_SELECT_SEND_H
23
23
 
24
 
#include <drizzled/plugin/client.h>
25
 
#include <drizzled/plugin/query_cache.h>
26
 
#include <drizzled/plugin/transactional_storage_engine.h>
27
 
#include <drizzled/select_result.h>
28
 
 
29
 
namespace drizzled
30
 
{
31
 
 
32
24
class select_send :public select_result {
33
25
  /**
34
26
    True if we have sent result set metadata to the client.
45
37
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
46
38
      by session
47
39
    */
48
 
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
 
40
    ha_release_temporary_latches(session);
49
41
 
50
42
    /* Unlock tables before sending packet to gain some speed */
51
43
    if (session->lock)
52
44
    {
53
 
      session->unlockTables(session->lock);
 
45
      mysql_unlock_tables(session, session->lock);
54
46
      session->lock= 0;
55
47
    }
56
48
    session->my_eof();
61
53
  bool send_fields(List<Item> &list)
62
54
  {
63
55
    bool res;
64
 
    if (! (res= session->getClient()->sendFields(&list)))
 
56
    if (! (res= session->protocol->sendFields(&list)))
65
57
      is_result_set_started= 1;
66
58
    return res;
67
59
  }
98
90
      InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
99
91
      by session
100
92
    */
101
 
    plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
 
93
    ha_release_temporary_latches(session);
102
94
 
103
 
    List<Item>::iterator li(items.begin());
 
95
    List_iterator_fast<Item> li(items);
104
96
    char buff[MAX_FIELD_WIDTH];
105
97
    String buffer(buff, sizeof(buff), &my_charset_bin);
106
98
 
 
99
    session->protocol->prepareForResend();
107
100
    Item *item;
108
101
    while ((item=li++))
109
102
    {
110
 
      if (item->send(session->getClient(), &buffer))
 
103
      if (item->send(session->protocol, &buffer))
111
104
      {
 
105
        session->protocol->free();
112
106
        my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
113
107
        break;
114
108
      }
115
109
    }
116
 
    /* Insert this record to the Resultset into the cache */
117
 
    if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
118
 
      plugin::QueryCache::insertRecord(session, items);
119
 
 
120
110
    session->sent_row_count++;
121
111
    if (session->is_error())
122
112
      return true;
123
 
    return session->getClient()->flush();
 
113
    if (session->protocol->isConnected())
 
114
      return(session->protocol->write());
 
115
    return false;
124
116
  }
125
117
};
126
118
 
127
 
} /* namespace drizzled */
128
 
 
129
119
#endif /* DRIZZLED_SELECT_SEND_H */