~drizzle-trunk/drizzle/development

2154.2.17 by Brian Aker
Additional removal of session
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, Inc.
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
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
2154.2.17 by Brian Aker
Additional removal of session
21
22
#include <drizzled/select_dumpvar.h>
23
#include <drizzled/sql_lex.h>
24
#include <drizzled/session.h>
25
26
namespace drizzled {
27
28
bool select_dumpvar::send_data(List<Item> &items)
29
{
30
  std::vector<var *>::const_iterator iter= var_list.begin();
31
2183.2.12 by Olaf van der Spek
Use List::begin()
32
  List<Item>::iterator it(items.begin());
2154.2.17 by Brian Aker
Additional removal of session
33
  Item *item= NULL;
34
  var *current_var;
35
36
  if (unit->offset_limit_cnt)
37
  {						// using limit offset,count
38
    unit->offset_limit_cnt--;
39
    return(0);
40
  }
41
  if (row_count++)
42
  {
43
    my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
44
    return(1);
45
  }
46
  while ((iter != var_list.end()) && (item= it++))
47
  {
48
    current_var= *iter;
49
    if (current_var->local == 0)
50
    {
51
      Item_func_set_user_var *suv= new Item_func_set_user_var(current_var->s, item);
52
      suv->fix_fields(session, 0);
53
      suv->check(0);
54
      suv->update();
55
    }
56
    ++iter;
57
  }
58
  return(session->is_error());
59
}
60
61
bool select_dumpvar::send_eof()
62
{
63
  if (! row_count)
64
    push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
65
		 ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
66
  /*
67
    In order to remember the value of affected rows for ROW_COUNT()
68
    function, SELECT INTO has to have an own SQLCOM.
69
    @TODO split from SQLCOM_SELECT
70
  */
71
  session->my_ok(row_count);
72
  return 0;
73
}
74
75
int select_dumpvar::prepare(List<Item> &list, Select_Lex_Unit *u)
76
{
77
  unit= u;
78
2183.2.19 by Olaf van der Spek
Use List::size()
79
  if (var_list.size() != list.size())
2154.2.17 by Brian Aker
Additional removal of session
80
  {
81
    my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
82
	       ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
83
    return 1;
84
  }
85
  return 0;
86
}
87
88
} // namespace drizzled