query graph

/* Query graph query thread node: the fields are protected by the kernel mutex with the exceptions named below */

struct que_thr_struct{  que_common_t common;  /*!< type: QUE_NODE_THR */  ulint  magic_n; /*!< magic number to catch memory      corruption */  que_node_t* child;  /*!< graph child node */  que_t*  graph;  /*!< graph where this node belongs */  ibool  is_active; /*!< TRUE if the thread has been set      to the run state in      que_thr_move_to_run_state, but not      deactivated in      que_thr_dec_reference_count */  ulint  state;  /*!< state of the query thread */  UT_LIST_NODE_T(que_thr_t)    thrs;  /*!< list of thread nodes of the fork      node */  UT_LIST_NODE_T(que_thr_t)    trx_thrs; /*!< lists of threads in wait list of      the trx */  UT_LIST_NODE_T(que_thr_t)    queue;  /*!< list of runnable thread nodes in      the server task queue */  /*------------------------------*/  /* The following fields are private to the OS thread executing the  query thread, and are not protected by the kernel mutex: */

 que_node_t* run_node; /*!< pointer to the node where the      subgraph down from this node is      currently executed */  que_node_t* prev_node; /*!< pointer to the node from which      the control came */  ulint  resource; /*!< resource usage of the query thread      thus far */  ulint  lock_state; /*!< lock state of thread (table or      row) */  ulint  fk_cascade_depth; /*!< maximum cascading call depth      supported for foreign key constraint      related delete/updates */ };

 

#define QUE_THR_MAGIC_N  8476583 #define QUE_THR_MAGIC_FREED 123461526

 

/* Query graph fork node: its fields are protected by the kernel mutex */ struct que_fork_struct{  que_common_t common;  /*!< type: QUE_NODE_FORK */  que_t*  graph;  /*!< query graph of this node */  ulint  fork_type; /*!< fork type */  ulint  n_active_thrs; /*!< if this is the root of a graph, the      number query threads that have been      started in que_thr_move_to_run_state      but for which que_thr_dec_refer_count      has not yet been called */  trx_t*  trx;  /*!< transaction: this is set only in      the root node */  ulint  state;  /*!< state of the fork node */  que_thr_t* caller;  /*!< pointer to a possible calling query      thread */  UT_LIST_BASE_NODE_T(que_thr_t)    thrs;  /*!< list of query threads */  /*------------------------------*/  /* The fields in this section are defined only in the root node */  sym_tab_t* sym_tab; /*!< symbol table of the query,      generated by the parser, or NULL      if the graph was created 'by hand' */  pars_info_t* info;  /*!< info struct, or NULL */  /* The following cur_... fields are relevant only in a select graph */

 ulint  cur_end; /*!< QUE_CUR_NOT_DEFINED, QUE_CUR_START,      QUE_CUR_END */  ulint  cur_pos; /*!< if there are n rows in the result      set, values 0 and n + 1 mean before      first row, or after last row, depending      on cur_end; values 1...n mean a row      index */  ibool  cur_on_row; /*!< TRUE if cursor is on a row, i.e.,      it is not before the first row or      after the last row */  sel_node_t* last_sel_node; /*!< last executed select node, or NULL      if none */  UT_LIST_NODE_T(que_fork_t)    graphs;  /*!< list of query graphs of a session      or a stored procedure */  /*------------------------------*/  mem_heap_t* heap;  /*!< memory heap where the fork was      created */

};

 

/* Query graph node types */ #define QUE_NODE_LOCK  1 #define QUE_NODE_INSERT  2 #define QUE_NODE_UPDATE  4 #define QUE_NODE_CURSOR  5 #define QUE_NODE_SELECT  6 #define QUE_NODE_AGGREGATE 7 #define QUE_NODE_FORK  8 #define QUE_NODE_THR  9 #define QUE_NODE_UNDO  10 #define QUE_NODE_COMMIT  11 #define QUE_NODE_ROLLBACK 12 #define QUE_NODE_PURGE  13 #define QUE_NODE_CREATE_TABLE 14 #define QUE_NODE_CREATE_INDEX 15 #define QUE_NODE_SYMBOL  16 #define QUE_NODE_RES_WORD 17 #define QUE_NODE_FUNC  18 #define QUE_NODE_ORDER  19 #define QUE_NODE_PROC  (20 + QUE_NODE_CONTROL_STAT) #define QUE_NODE_IF  (21 + QUE_NODE_CONTROL_STAT) #define QUE_NODE_WHILE  (22 + QUE_NODE_CONTROL_STAT) #define QUE_NODE_ASSIGNMENT 23 #define QUE_NODE_FETCH  24 #define QUE_NODE_OPEN  25 #define QUE_NODE_COL_ASSIGNMENT 26 #define QUE_NODE_FOR  (27 + QUE_NODE_CONTROL_STAT) #define QUE_NODE_RETURN  28 #define QUE_NODE_ROW_PRINTF 29 #define QUE_NODE_ELSIF  30 #define QUE_NODE_CALL  31 #define QUE_NODE_EXIT  32

 

 
  

/* Insert node structure */

struct ins_node_struct{  que_common_t common; /*!< node type: QUE_NODE_INSERT */  ulint  ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */  dtuple_t* row; /*!< row to insert */  dict_table_t* table; /*!< table where to insert */  sel_node_t* select; /*!< select in searched insert */  que_node_t* values_list;/* list of expressions to evaluate and insert in an INS_VALUES insert */  ulint  state; /*!< node execution state */  dict_index_t* index; /*!< NULL, or the next index where the index entry should be inserted */  dtuple_t* entry; /*!< NULL, or entry to insert in the index; after a successful insert of the entry, this should be reset to NULL */  UT_LIST_BASE_NODE_T(dtuple_t)    entry_list;/* list of entries, one for each index */  byte*  row_id_buf;/* buffer for the row id sys field in row */  trx_id_t trx_id; /*!< trx id or the last trx which executed the node */  byte*  trx_id_buf;/* buffer for the trx id sys field in row */  mem_heap_t* entry_sys_heap;     /* memory heap used as auxiliary storage;     entry_list and sys fields are stored here;     if this is NULL, entry list should be created     and buffers for sys fields in row allocated */  ulint  magic_n; };

 

 

 

/** Select statement node */ struct sel_node_struct{  que_common_t common;  /*!< node type: QUE_NODE_SELECT */  enum sel_node_state    state; /*!< node state */  que_node_t* select_list; /*!< select list */  sym_node_t* into_list; /*!< variables list or NULL */  sym_node_t* table_list; /*!< table list */  ibool  asc;  /*!< TRUE if the rows should be fetched      in an ascending order */  ibool  set_x_locks; /*!< TRUE if the cursor is for update or      delete, which means that a row x-lock      should be placed on the cursor row */  ulint  row_lock_mode; /*!< LOCK_X or LOCK_S */  ulint  n_tables; /*!< number of tables */  ulint  fetch_table; /*!< number of the next table to access      in the join */  plan_t*  plans;  /*!< array of n_tables many plan nodes      containing the search plan and the      search data structures */  que_node_t* search_cond; /*!< search condition */  read_view_t* read_view; /*!< if the query is a non-locking      consistent read, its read view is      placed here, otherwise NULL */  ibool  consistent_read;/*!< TRUE if the select is a consistent,      non-locking read */  order_node_t* order_by; /*!< order by column definition, or      NULL */  ibool  is_aggregate; /*!< TRUE if the select list consists of      aggregate functions */  ibool  aggregate_already_fetched;      /*!< TRUE if the aggregate row has      already been fetched for the current      cursor */  ibool  can_get_updated;/*!< this is TRUE if the select      is in a single-table explicit      cursor which can get updated      within the stored procedure,      or in a searched update or      delete; NOTE that to determine      of an explicit cursor if it      can get updated, the parser      checks from a stored procedure      if it contains positioned      update or delete statements */  sym_node_t* explicit_cursor;/*!< not NULL if an explicit cursor */  UT_LIST_BASE_NODE_T(sym_node_t)    copy_variables; /*!< variables whose values we have to      copy when an explicit cursor is opened,      so that they do not change between      fetches */ };

 

 

 
/** Commit command node in a query graph */
struct commit_node_struct{
	que_common_t	common;	/*!< node type: QUE_NODE_COMMIT */
	enum commit_node_state
			state;	/*!< node execution state */
};
 
 
 
  

/* Index create node struct */

struct ind_node_struct{  que_common_t common; /*!< node type: QUE_NODE_INDEX_CREATE */  dict_index_t* index; /*!< index to create, built as a memory data     structure with dict_mem_... functions */  ins_node_t* ind_def; /* child node which does the insert of     the index definition; the row to be inserted     is built by the parent node  */  ins_node_t* field_def; /* child node which does the inserts of     the field definitions; the row to be inserted     is built by the parent node  */  commit_node_t* commit_node;     /* child node which performs a commit after     a successful index creation */  /*----------------------*/  /* Local storage for this graph node */  ulint  state; /*!< node execution state */  ulint  page_no;/* root page number of the index */  dict_table_t* table; /*!< table which owns the index */  dtuple_t* ind_row;/* index definition row built */  ulint  field_no;/* next field definition to insert */  mem_heap_t* heap; /*!< memory heap used as auxiliary storage */ };


 Query graph fork node 可有多个 Query graph query thread node, 并行查询

(Query graph query thread node)->child = 具体要执行操作的node

你可能感兴趣的:(mysql)