1/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16#ifndef _sql_cursor_h_
17#define _sql_cursor_h_
18
19#ifdef USE_PRAGMA_INTERFACE
20#pragma interface /* gcc class interface */
21#endif
22
23#include "sql_class.h" /* Query_arena */
24
25class JOIN;
26
27/**
28 @file
29
30 Declarations for implementation of server side cursors. Only
31 read-only non-scrollable cursors are currently implemented.
32*/
33
34/**
35 Server_side_cursor -- an interface for materialized
36 implementation of cursors. All cursors are self-contained
37 (created in their own memory root). For that reason they must
38 be deleted only using a pointer to Server_side_cursor, not to
39 its base class.
40*/
41
42class Server_side_cursor: protected Query_arena, public Sql_alloc
43{
44protected:
45 /** Row destination used for fetch */
46 select_result *result;
47public:
48 Server_side_cursor(MEM_ROOT *mem_root_arg, select_result *result_arg)
49 :Query_arena(mem_root_arg, STMT_INITIALIZED), result(result_arg)
50 {}
51
52 virtual bool is_open() const= 0;
53
54 virtual int open(JOIN *top_level_join)= 0;
55 virtual void fetch(ulong num_rows)= 0;
56 virtual void close()= 0;
57 virtual bool export_structure(THD *thd, Row_definition_list *defs)
58 {
59 DBUG_ASSERT(0);
60 return true;
61 }
62 virtual ~Server_side_cursor();
63
64 static void operator delete(void *ptr, size_t size);
65 static void operator delete(void *, MEM_ROOT *){}
66};
67
68
69int mysql_open_cursor(THD *thd, select_result *result,
70 Server_side_cursor **res);
71
72#endif /* _sql_cusor_h_ */
73