MySQL 9.0.0
Source Code Documentation
sql_cursor.cc File Reference
#include "sql/sql_cursor.h"
#include <assert.h>
#include <sys/types.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "memory_debugging.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "mysql/components/services/bits/psi_statement_bits.h"
#include "mysql_com.h"
#include "sql/debug_sync.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/parse_tree_node_base.h"
#include "sql/protocol.h"
#include "sql/query_options.h"
#include "sql/query_result.h"
#include "sql/sql_cmd_dml.h"
#include "sql/sql_digest_stream.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_tmp_table.h"
#include "sql/sql_union.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"

Classes

class  Materialized_cursor
 Materialized_cursor – an insensitive materialized server-side cursor. More...
 
class  Query_result_materialize
 Query_result_materialize – a mediator between a cursor query and the protocol. More...
 

Functions

Query_resultnew_cursor_result (MEM_ROOT *mem_root, Query_result *result)
 
bool mysql_open_cursor (THD *thd, Query_result *result, Server_side_cursor **pcursor)
 Attempt to open a materialized cursor. More...
 

Function Documentation

◆ mysql_open_cursor()

bool mysql_open_cursor ( THD thd,
Query_result result,
Server_side_cursor **  pcursor 
)

Attempt to open a materialized cursor.

Parameters
thdthread handle
[in]resultresult class of the caller used as a destination for the rows fetched from the cursor
[in,out]pcursora pointer to store a pointer to cursor in. The cursor is usually created on first call. Notice that a cursor may be returned even though execution causes an error. Cursor is open when execution is successful, closed otherwise.
Returns
Error status
false on success, true on error
Note
Only used for cursors created by stored procedures. Cursors created for prepared statements are handled by simpler interfaces (new_cursor_result(), Materialized_cursor::open(), etc). On first invocation, mysql_open_cursor creates a query result object for management of the materialized result. When this cursor is prepared, it creates a materialized cursor object (Materialized_cursor) inside the cursor. In addition, an application specific result object supplied as argument is attached to the query result object. The query result object is also attached to the current prepared statement. A reference to the cursor object is returned in pcursor. The statement may or may not be prepared on first invocation, it is prepared if necessary.

On subsequent invocations, the query result object is located inside the preparable statement and the cursor object is located inside this. A reference to the cursor object is returned in pcursor.

On all invocations, the statement is executed and a temporary table managed by the cursor object is populated with the result set.

◆ new_cursor_result()

Query_result * new_cursor_result ( MEM_ROOT mem_root,
Query_result result 
)