~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/select_dumpvar.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#pragma once
 
20
#ifndef DRIZZLED_SELECT_DUMPVAR_H
 
21
#define DRIZZLED_SELECT_DUMPVAR_H
21
22
 
22
 
#include <drizzled/error.h>
23
 
#include <drizzled/function/set_user_var.h>
24
 
#include <drizzled/select_result_interceptor.h>
25
 
#include <drizzled/base.h>
 
23
#include "drizzled/error.h"
 
24
#include "drizzled/function/set_user_var.h"
26
25
 
27
26
#include <vector>
28
27
 
29
 
namespace drizzled {
 
28
namespace drizzled
 
29
{
30
30
 
31
31
class select_dumpvar :public select_result_interceptor {
32
32
  ha_rows row_count;
33
 
 
34
33
public:
35
34
  std::vector<var *> var_list;
36
35
  select_dumpvar()  { var_list.clear(); row_count= 0;}
37
36
  ~select_dumpvar() {}
38
37
 
39
 
  int prepare(List<Item> &list, Select_Lex_Unit *u);
 
38
  int prepare(List<Item> &list, Select_Lex_Unit *u)
 
39
  {
 
40
    unit= u;
 
41
 
 
42
    if (var_list.size() != list.elements)
 
43
    {
 
44
      my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
 
45
                 ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
 
46
      return 1;
 
47
    }
 
48
    return 0;
 
49
  }
40
50
 
41
51
  void cleanup()
42
52
  {
44
54
  }
45
55
 
46
56
 
47
 
  bool send_data(List<Item> &items);
48
 
 
49
 
  bool send_eof();
 
57
  bool send_data(List<Item> &items)
 
58
  {
 
59
    
 
60
    std::vector<var *>::const_iterator iter= var_list.begin();
 
61
 
 
62
    List_iterator<Item> it(items);
 
63
    Item *item= NULL;
 
64
    var *current_var;
 
65
 
 
66
    if (unit->offset_limit_cnt)
 
67
    {                                           // using limit offset,count
 
68
      unit->offset_limit_cnt--;
 
69
      return(0);
 
70
    }
 
71
    if (row_count++)
 
72
    {
 
73
      my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
 
74
      return(1);
 
75
    }
 
76
    while ((iter != var_list.end()) && (item= it++))
 
77
    {
 
78
      current_var= *iter;
 
79
      if (current_var->local == 0)
 
80
      {
 
81
        Item_func_set_user_var *suv= new Item_func_set_user_var(current_var->s, item);
 
82
        suv->fix_fields(session, 0);
 
83
        suv->check(0);
 
84
        suv->update();
 
85
      }
 
86
      ++iter;
 
87
    }
 
88
    return(session->is_error());
 
89
  }
 
90
 
 
91
  bool send_eof()
 
92
  {
 
93
    if (! row_count)
 
94
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
95
                   ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
 
96
    /*
 
97
      In order to remember the value of affected rows for ROW_COUNT()
 
98
      function, SELECT INTO has to have an own SQLCOM.
 
99
TODO: split from SQLCOM_SELECT
 
100
  */
 
101
    session->my_ok(row_count);
 
102
    return 0;
 
103
  }
50
104
 
51
105
};
52
106
 
53
107
} /* namespace drizzled */
54
108
 
 
109
#endif /* DRIZZLED_SELECT_DUMPVAR_H */