MySQL 8.0.39
Source Code Documentation
|
Query graph. More...
#include <stddef.h>
#include "dict0crea.h"
#include "eval0eval.h"
#include "eval0proc.h"
#include "ha_prototypes.h"
#include "lock0lock.h"
#include "log0chkp.h"
#include "pars0types.h"
#include "que0que.h"
#include "row0ins.h"
#include "row0purge.h"
#include "row0sel.h"
#include "row0undo.h"
#include "row0upd.h"
#include "trx0roll.h"
#include "trx0trx.h"
#include "usr0sess.h"
#include "my_dbug.h"
Functions | |
static void | que_thr_move_to_run_state (que_thr_t *thr) |
Moves a thread from another state to the QUE_THR_RUNNING state. More... | |
que_fork_t * | que_fork_create (que_t *graph, que_node_t *parent, ulint fork_type, mem_heap_t *heap) |
Creates a query graph fork node. More... | |
que_thr_t * | que_thr_create (que_fork_t *parent, mem_heap_t *heap, row_prebuilt_t *prebuilt) |
Creates a query graph thread node. More... | |
que_thr_t * | que_thr_end_lock_wait (trx_t *trx) |
Moves a suspended query thread to the QUE_THR_RUNNING state and may release a worker thread to execute it. More... | |
static void | que_thr_init_command (que_thr_t *thr) |
Inits a query thread for a command. More... | |
que_thr_t * | que_fork_scheduler_round_robin (que_fork_t *fork, que_thr_t *thr) |
Round robin scheduler. More... | |
que_thr_t * | que_fork_start_command (que_fork_t *fork) |
Starts execution of a command in a query fork. More... | |
static void | que_graph_free_stat_list (que_node_t *node) |
Calls que_graph_free_recursive for statements in a statement list. More... | |
void | que_graph_free_recursive (que_node_t *node) |
Frees a query graph, but not the heap where it was created. More... | |
void | que_graph_free (que_t *graph) |
Frees a query graph. More... | |
static que_thr_t * | que_thr_node_step (que_thr_t *thr) |
Performs an execution step on a thr node. More... | |
bool | que_thr_stop (que_thr_t *thr) |
Stops a query thread if graph or trx is in a state requiring it. More... | |
static void | que_thr_dec_refer_count (que_thr_t *thr, que_thr_t **next_thr) |
Decrements the query thread reference counts in the query graph and the transaction. More... | |
void | que_thr_stop_for_mysql (que_thr_t *thr) |
A patch for MySQL used to 'stop' a dummy query thread used in MySQL. More... | |
void | que_thr_move_to_run_state_for_mysql (que_thr_t *thr, trx_t *trx) |
Moves a thread from another state to the QUE_THR_RUNNING state. More... | |
void | que_thr_stop_for_mysql_no_error (que_thr_t *thr, trx_t *trx) |
A patch for MySQL used to 'stop' a dummy query thread used in MySQL select, when there is no error or lock wait. More... | |
que_node_t * | que_node_get_containing_loop_node (que_node_t *node) |
Get the first containing loop node (e.g. More... | |
static const char * | que_node_type_string (const que_node_t *node) |
Gets information of an SQL query graph node. More... | |
static que_thr_t * | que_thr_step (que_thr_t *thr) |
Performs an execution step on a query thread. More... | |
static void | que_run_threads_low (que_thr_t *thr) |
Run a query thread until it finishes or encounters e.g. More... | |
void | que_run_threads (que_thr_t *thr) |
Run a query thread. More... | |
dberr_t | que_eval_sql (pars_info_t *info, const char *sql, trx_t *trx) |
Evaluate the given SQL. More... | |
void | que_init (void) |
Initialise the query sub-system. More... | |
void | que_close (void) |
Close the query sub-system. More... | |
Query graph.
Created 5/27/1996 Heikki Tuuri
void que_close | ( | void | ) |
Close the query sub-system.
dberr_t que_eval_sql | ( | pars_info_t * | info, |
const char * | sql, | ||
trx_t * | trx | ||
) |
Evaluate the given SQL.
[in] | info | Info struct, or nullptr. |
[in] | sql | SQL string. |
[in] | trx | Transaction. |
que_fork_t * que_fork_create | ( | que_t * | graph, |
que_node_t * | parent, | ||
ulint | fork_type, | ||
mem_heap_t * | heap | ||
) |
Creates a query graph fork node.
graph | in: graph, if NULL then this fork node is assumed to be the graph root |
parent | in: parent node |
fork_type | in: fork type |
heap | in: memory heap where created |
que_thr_t * que_fork_scheduler_round_robin | ( | que_fork_t * | fork, |
que_thr_t * | thr | ||
) |
Round robin scheduler.
fork | in: a query fork |
thr | in: current pos |
que_thr_t * que_fork_start_command | ( | que_fork_t * | fork | ) |
Starts execution of a command in a query fork.
Picks a query thread which is not in the QUE_THR_RUNNING state and moves it to that state. If none can be chosen, a situation which may arise in parallelized fetches, NULL is returned.
fork | in: a query fork |
void que_graph_free | ( | que_t * | graph | ) |
Frees a query graph.
in: query graph; we assume that the memory heap where this graph was created is private to this graph: if not, then use que_graph_free_recursive and free the heap afterwards!
graph | in: query graph; we assume that the memory heap where this graph was created is private to this graph: if not, then use que_graph_free_recursive and free the heap afterwards! |
void que_graph_free_recursive | ( | que_node_t * | node | ) |
Frees a query graph, but not the heap where it was created.
Does not free explicit cursor declarations, they are freed in que_graph_free.
node | in: query graph node |
|
static |
Calls que_graph_free_recursive for statements in a statement list.
node | in: first query graph node in the list |
void que_init | ( | void | ) |
Initialise the query sub-system.
que_node_t * que_node_get_containing_loop_node | ( | que_node_t * | node | ) |
Get the first containing loop node (e.g.
while_node_t or for_node_t) for the given node, or NULL if the node is not within a loop.
node | in: node |
|
static |
Gets information of an SQL query graph node.
node | in: query graph node |
void que_run_threads | ( | que_thr_t * | thr | ) |
Run a query thread.
Handles lock waits.
thr | in: query thread |
|
static |
Run a query thread until it finishes or encounters e.g.
a lock wait.
thr | in: query thread |
que_thr_t * que_thr_create | ( | que_fork_t * | parent, |
mem_heap_t * | heap, | ||
row_prebuilt_t * | prebuilt | ||
) |
Creates a query graph thread node.
[in] | parent | parent node, i.e., a fork node |
[in] | heap | memory heap where created |
[in] | prebuilt | row prebuilt structure |
Decrements the query thread reference counts in the query graph and the transaction.
NOTE ***: This and que_thr_stop_for_mysql are the only functions where the reference count can be decremented and this function may only be called from inside que_run_threads! These restrictions exist to make the rollback code easier to maintain.
thr | in: query thread |
next_thr | in/out: next query thread to run; if the value which is passed in is a pointer to a NULL pointer, then the calling function can start running a new query thread |
Moves a suspended query thread to the QUE_THR_RUNNING state and may release a worker thread to execute it.
Moves a suspended query thread to the QUE_THR_RUNNING state and release a worker thread to execute it.
This function should be used to end the wait state of a query thread waiting for a lock or a stored procedure completion.
trx | in: transaction with que_state in QUE_THR_LOCK_WAIT |
|
inlinestatic |
Inits a query thread for a command.
thr | in: query thread |
|
static |
Moves a thread from another state to the QUE_THR_RUNNING state.
Increments the n_active_thrs counters of the query graph and transaction. NOTE***: This is the only function in which such a transition is allowed to happen! in: an query thread
Increments the n_active_thrs counters of the query graph and transaction if thr was not active. NOTE***: This and ..._mysql are the only functions in which such a transition is allowed to happen!
thr | in: an query thread |
Moves a thread from another state to the QUE_THR_RUNNING state.
Increments the n_active_thrs counters of the query graph and transaction if thr was not active.
thr | in: an query thread |
trx | in: transaction |
Performs an execution step on a thr node.
thr | in: query thread where run_node must be the thread node itself |
Performs an execution step on a query thread.
thr | in: query thread |
bool que_thr_stop | ( | que_thr_t * | thr | ) |
Stops a query thread if graph or trx is in a state requiring it.
The conditions are tested in the order (1) graph, (2) trx. Caller must hold the trx mutex.
[in,out] | thr | query thread |
void que_thr_stop_for_mysql | ( | que_thr_t * | thr | ) |
A patch for MySQL used to 'stop' a dummy query thread used in MySQL.
The query thread is stopped and made inactive, except in the case where it was put to the lock wait state in lock0lock.cc, but the lock has already been granted or the transaction chosen as a victim in deadlock resolution.
thr | in: query thread |