MySQL 8.4.0
Source Code Documentation
sql_cursor.h File Reference

Declarations for implementation of server side cursors. More...

#include <stddef.h>
#include <sys/types.h>
#include <new>
#include "sql/sql_class.h"

Go to the source code of this file.

Classes

class  Server_side_cursor
 Server_side_cursor – an interface for materialized implementation of cursors. 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 **res)
 Attempt to open a materialized cursor. More...
 

Detailed Description

Declarations for implementation of server side cursors.

Only read-only non-scrollable cursors are currently implemented.

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 
)