MySQL 8.0.29
Source Code Documentation
sql_cursor.h
Go to the documentation of this file.
1/* Copyright (c) 2005, 2022, Oracle and/or its affiliates.
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, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef _sql_cursor_h_
24#define _sql_cursor_h_
25
26#include <stddef.h>
27#include <sys/types.h>
28#include <new>
29
30#include "sql/sql_class.h" /* Query_arena */
31
32class Query_result;
33struct MEM_ROOT;
34
35/**
36 @file
37
38 Declarations for implementation of server side cursors. Only
39 read-only non-scrollable cursors are currently implemented.
40*/
41
42/**
43 Server_side_cursor -- an interface for materialized
44 implementation of cursors. All cursors are self-contained
45 (created in their own memory root). For that reason they must
46 be deleted only using a pointer to Server_side_cursor, not to
47 its base class.
48*/
49
51 public:
52 /**
53 For allocation of Handler objects for the temporary table. The prepared
54 statement's mem_root cannot be used, since the handler may be created and
55 deleted several times. The execution mem_root cannot be used since
56 creation of and retrieval from a cursor are in different executions.
57 */
59
60 protected:
62 /** Row destination used for fetch */
64
65 public:
67 : m_arena(&mem_root, Query_arena::STMT_INITIALIZED), result(result_arg) {}
68 virtual bool is_open() const = 0;
69
70 virtual bool open(THD *thd) = 0;
71 virtual bool fetch(ulong num_rows) = 0;
72 virtual void close() = 0;
74 static void *operator new(size_t size, MEM_ROOT *mem_root,
75 const std::nothrow_t & = std::nothrow) noexcept {
76 return mem_root->Alloc(size);
77 }
78 static void operator delete(void *, size_t) {}
79 static void operator delete(
80 void *, MEM_ROOT *, const std::nothrow_t &) noexcept { /* never called */
81 }
82};
83
85 Server_side_cursor **res);
86
87#endif /* _sql_cusor_h_ */
Definition: sql_class.h:358
Definition: query_result.h:55
Server_side_cursor – an interface for materialized implementation of cursors.
Definition: sql_cursor.h:50
Query_arena m_arena
Definition: sql_cursor.h:61
virtual bool fetch(ulong num_rows)=0
virtual void close()=0
MEM_ROOT mem_root
For allocation of Handler objects for the temporary table.
Definition: sql_cursor.h:58
virtual bool is_open() const =0
Query_result * result
Row destination used for fetch.
Definition: sql_cursor.h:63
virtual ~Server_side_cursor()
Definition: sql_cursor.h:73
virtual bool open(THD *thd)=0
Server_side_cursor(Query_result *result_arg)
Definition: sql_cursor.h:66
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
PSI_memory_key key_memory_TABLE
Definition: psi_memory_key.cc:80
bool mysql_open_cursor(THD *thd, Query_result *result, Server_side_cursor **res)
Attempt to open a materialized cursor.
Definition: sql_cursor.cc:171
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
void Clear()
Deallocate all the RAM used.
Definition: my_alloc.cc:163
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:144
Definition: result.h:29