📄 que0que.h
字号:
/******************************************************Query graph(c) 1996 Innobase OyCreated 5/27/1996 Heikki Tuuri*******************************************************/#ifndef que0que_h#define que0que_h#include "univ.i"#include "data0data.h"#include "dict0types.h"#include "trx0trx.h"#include "srv0srv.h"#include "usr0types.h"#include "que0types.h"#include "row0types.h"#include "pars0types.h"/* If the following flag is set TRUE, the module will print trace infoof SQL execution in the UNIV_SQL_DEBUG version */extern ibool que_trace_on;/***************************************************************************Adds a query graph to the session's list of graphs. */voidque_graph_publish(/*==============*/ que_t* graph, /* in: graph */ sess_t* sess); /* in: session *//***************************************************************************Creates a query graph fork node. */que_fork_t*que_fork_create(/*============*/ /* out, own: fork node */ que_t* graph, /* in: graph, if NULL then this fork node is assumed to be the graph root */ que_node_t* parent, /* in: parent node */ ulint fork_type, /* in: fork type */ mem_heap_t* heap); /* in: memory heap where created *//***************************************************************************Gets the first thr in a fork. */UNIV_INLINEque_thr_t*que_fork_get_first_thr(/*===================*/ que_fork_t* fork); /* in: query fork *//***************************************************************************Gets the child node of the first thr in a fork. */UNIV_INLINEque_node_t*que_fork_get_child(/*===============*/ que_fork_t* fork); /* in: query fork *//***************************************************************************Sets the parent of a graph node. */UNIV_INLINEvoidque_node_set_parent(/*================*/ que_node_t* node, /* in: graph node */ que_node_t* parent);/* in: parent *//***************************************************************************Creates a query graph thread node. */que_thr_t*que_thr_create(/*===========*/ /* out, own: query thread node */ que_fork_t* parent, /* in: parent node, i.e., a fork node */ mem_heap_t* heap); /* in: memory heap where created *//**************************************************************************Checks if the query graph is in a state where it should be freed, andfrees it in that case. If the session is in a state where it should beclosed, also this is done. */iboolque_graph_try_free(/*===============*/ /* out: TRUE if freed */ que_t* graph); /* in: query graph *//**************************************************************************Frees a query graph, but not the heap where it was created. Does not freeexplicit cursor declarations, they are freed in que_graph_free. */voidque_graph_free_recursive(/*=====================*/ que_node_t* node); /* in: query graph node *//**************************************************************************Frees a query graph. */voidque_graph_free(/*===========*/ que_t* 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! *//**************************************************************************Stops a query thread if graph or trx is in a state requiring it. Theconditions are tested in the order (1) graph, (2) trx. The kernel mutex hasto be reserved. */iboolque_thr_stop(/*=========*/ /* out: TRUE if stopped */ que_thr_t* thr); /* in: query thread *//**************************************************************************Moves a thread from another state to the QUE_THR_RUNNING state. Incrementsthe n_active_thrs counters of the query graph and transaction. */voidque_thr_move_to_run_state_for_mysql(/*================================*/ que_thr_t* thr, /* in: an query thread */ trx_t* trx); /* in: transaction *//**************************************************************************A patch for MySQL used to 'stop' a dummy query thread used in MySQLselect, when there is no error or lock wait. */voidque_thr_stop_for_mysql_no_error(/*============================*/ que_thr_t* thr, /* in: query thread */ trx_t* trx); /* in: transaction *//**************************************************************************A patch for MySQL used to 'stop' a dummy query thread used in MySQL. Thequery thread is stopped and made inactive, except in the case whereit was put to the lock wait state in lock0lock.c, but the lock has alreadybeen granted or the transaction chosen as a victim in deadlock resolution. */voidque_thr_stop_for_mysql(/*===================*/ que_thr_t* thr); /* in: query thread *//**************************************************************************Runs query threads. Note that the individual query thread which is runwithin this function may change if, e.g., the OS thread executing thisfunction uses a threshold amount of resources. */voidque_run_threads(/*============*/ que_thr_t* thr); /* in: query thread which is run initially *//**************************************************************************After signal handling is finished, returns control to a query graph errorhandling routine. (Currently, just returns the control to the root of thegraph so that the graph can communicate an error message to the client.) */voidque_fork_error_handle(/*==================*/ trx_t* trx, /* in: trx */ que_t* fork); /* in: query graph which was run before signal handling started, NULL not allowed *//**************************************************************************Handles an SQL error noticed during query thread execution. At the moment,does nothing! */voidque_thr_handle_error(/*=================*/ que_thr_t* thr, /* in: query thread */ ulint err_no, /* in: error number */ byte* err_str,/* in, own: error string or NULL; NOTE: the function will take care of freeing of the string! */ ulint err_len);/* in: error string length */ /**************************************************************************Moves a suspended query thread to the QUE_THR_RUNNING state and releasesa single worker thread to execute it. This function should be used to endthe wait state of a query thread waiting for a lock or a stored procedurecompletion. */voidque_thr_end_wait(/*=============*/ que_thr_t* thr, /* in: query thread in the QUE_THR_LOCK_WAIT, or QUE_THR_PROCEDURE_WAIT, or QUE_THR_SIG_REPLY_WAIT state */ que_thr_t** 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 *//**************************************************************************Same as que_thr_end_wait, but no parameter next_thr available. */voidque_thr_end_wait_no_next_thr(/*=========================*/ que_thr_t* thr); /* in: query thread in the QUE_THR_LOCK_WAIT, or QUE_THR_PROCEDURE_WAIT, or QUE_THR_SIG_REPLY_WAIT state *//**************************************************************************Starts execution of a command in a query fork. Picks a query thread whichis not in the QUE_THR_RUNNING state and moves it to that state. If nonecan be chosen, a situation which may arise in parallelized fetches, NULLis returned. */que_thr_t*que_fork_start_command(/*===================*/ /* out: a query thread of the graph moved to QUE_THR_RUNNING state, or NULL; the query thread should be executed by que_run_threads by the caller */ que_fork_t* fork); /* in: a query fork *//***************************************************************************Gets the trx of a query thread. */UNIV_INLINEtrx_t*thr_get_trx(/*========*/ que_thr_t* thr); /* in: query thread *//***************************************************************************Gets the type of a graph node. */UNIV_INLINEulintque_node_get_type(/*==============*/ que_node_t* node); /* in: graph node *//***************************************************************************Gets pointer to the value data type field of a graph node. */UNIV_INLINEdtype_t*que_node_get_data_type(/*===================*/ que_node_t* node); /* in: graph node *//***************************************************************************Gets pointer to the value dfield of a graph node. */UNIV_INLINEdfield_t*que_node_get_val(/*=============*/ que_node_t* node); /* in: graph node *//***************************************************************************Gets the value buffer size of a graph node. */UNIV_INLINEulintque_node_get_val_buf_size(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -