47 #define QUE_MAX_LOOPS_WITHOUT_CHECK 16
52 UNIV_INTERN ibool que_trace_on = FALSE;
120 que_thr_move_to_run_state(
152 fork->
state = QUE_FORK_COMMAND_WAIT;
154 fork->
graph = (graph != NULL) ? graph : fork;
171 ut_ad(parent && heap);
179 thr->
magic_n = QUE_THR_MAGIC_N;
183 thr->
state = QUE_THR_COMMAND_WAIT;
221 que_thr_move_to_run_state(thr);
230 return((!was_active && thr != NULL) ? thr : NULL);
244 que_thr_move_to_run_state(thr);
270 fork->
state = QUE_FORK_ACTIVE;
274 switch (thr->
state) {
275 case QUE_THR_COMMAND_WAIT:
276 case QUE_THR_COMPLETED:
281 case QUE_THR_SUSPENDED:
282 case QUE_THR_LOCK_WAIT:
312 fork->
state = QUE_FORK_ACTIVE;
316 suspended_thr = NULL;
317 completed_thr = NULL;
334 switch (thr->
state) {
335 case QUE_THR_COMMAND_WAIT:
344 case QUE_THR_SUSPENDED:
348 if (!suspended_thr) {
354 case QUE_THR_COMPLETED:
355 if (!completed_thr) {
361 case QUE_THR_LOCK_WAIT:
370 que_thr_move_to_run_state(thr);
372 }
else if (completed_thr) {
400 if (thr_node->
state != state) {
413 que_graph_free_stat_list(
466 if (thr->
magic_n != QUE_THR_MAGIC_N) {
468 "que_thr struct appears corrupt;"
475 thr->
magic_n = QUE_THR_MAGIC_FREED;
487 case QUE_NODE_SELECT:
494 case QUE_NODE_INSERT:
510 case QUE_NODE_UPDATE:
514 if (upd->in_mysql_interface) {
521 if (upd->cascade_heap) {
530 case QUE_NODE_CREATE_TABLE:
540 case QUE_NODE_CREATE_INDEX:
551 que_graph_free_stat_list(((
proc_node_t*) node)->stat_list);
555 que_graph_free_stat_list(((
if_node_t*) node)->stat_list);
556 que_graph_free_stat_list(((
if_node_t*) node)->else_part);
557 que_graph_free_stat_list(((
if_node_t*) node)->elsif_list);
561 que_graph_free_stat_list(((
elsif_node_t*) node)->stat_list);
565 que_graph_free_stat_list(((
while_node_t*) node)->stat_list);
569 que_graph_free_stat_list(((
for_node_t*) node)->stat_list);
573 case QUE_NODE_ASSIGNMENT:
575 case QUE_NODE_RETURN:
576 case QUE_NODE_COMMIT:
577 case QUE_NODE_ROLLBACK:
581 case QUE_NODE_ROW_PRINTF:
589 "que_node struct appears corrupt; type %lu\n",
659 thr->
state = QUE_THR_COMPLETED;
674 que_thr_move_to_run_state(
692 thr->
state = QUE_THR_RUNNING;
712 if (graph->
state == QUE_FORK_COMMAND_WAIT) {
714 thr->
state = QUE_THR_SUSPENDED;
719 thr->
state = QUE_THR_LOCK_WAIT;
725 thr->
state = QUE_THR_COMPLETED;
727 }
else if (graph->
fork_type == QUE_FORK_ROLLBACK) {
729 thr->
state = QUE_THR_SUSPENDED;
749 que_thr_dec_refer_count(
766 if (thr->
state == QUE_THR_RUNNING) {
770 ut_a(next_thr != NULL && *next_thr == NULL);
825 if (thr->
state == QUE_THR_RUNNING) {
831 thr->
state = QUE_THR_COMPLETED;
866 if (thr->
magic_n != QUE_THR_MAGIC_N) {
868 "que_thr struct appears corrupt; magic n %lu\n",
885 thr->
state = QUE_THR_RUNNING;
904 if (thr->
magic_n != QUE_THR_MAGIC_N) {
906 "que_thr struct appears corrupt; magic n %lu\n",
914 thr->
state = QUE_THR_COMPLETED;
945 if ((type == QUE_NODE_FOR) || (type == QUE_NODE_WHILE)) {
966 if (type == QUE_NODE_SELECT) {
968 }
else if (type == QUE_NODE_INSERT) {
970 }
else if (type == QUE_NODE_UPDATE) {
972 }
else if (type == QUE_NODE_WHILE) {
974 }
else if (type == QUE_NODE_ASSIGNMENT) {
976 }
else if (type == QUE_NODE_IF) {
978 }
else if (type == QUE_NODE_FETCH) {
980 }
else if (type == QUE_NODE_OPEN) {
982 }
else if (type == QUE_NODE_PROC) {
983 str =
"STORED PROCEDURE";
984 }
else if (type == QUE_NODE_FUNC) {
986 }
else if (type == QUE_NODE_LOCK) {
988 }
else if (type == QUE_NODE_THR) {
989 str =
"QUERY THREAD";
990 }
else if (type == QUE_NODE_COMMIT) {
992 }
else if (type == QUE_NODE_UNDO) {
994 }
else if (type == QUE_NODE_PURGE) {
996 }
else if (type == QUE_NODE_ROLLBACK) {
998 }
else if (type == QUE_NODE_CREATE_TABLE) {
999 str =
"CREATE TABLE";
1000 }
else if (type == QUE_NODE_CREATE_INDEX) {
1001 str =
"CREATE INDEX";
1002 }
else if (type == QUE_NODE_FOR) {
1004 }
else if (type == QUE_NODE_RETURN) {
1006 }
else if (type == QUE_NODE_EXIT) {
1009 str =
"UNKNOWN NODE TYPE";
1012 fprintf(stderr,
"Node type %lu: %s, address %p\n",
1013 (ulong) type, str, (
void*) node);
1045 fputs(
"To execute: ", stderr);
1049 if (type & QUE_NODE_CONTROL_STAT) {
1059 }
else if (type == QUE_NODE_IF) {
1061 }
else if (type == QUE_NODE_FOR) {
1063 }
else if (type == QUE_NODE_PROC) {
1075 }
else if (type == QUE_NODE_WHILE) {
1080 }
else if (type == QUE_NODE_ASSIGNMENT) {
1082 }
else if (type == QUE_NODE_SELECT) {
1084 }
else if (type == QUE_NODE_INSERT) {
1086 }
else if (type == QUE_NODE_UPDATE) {
1088 }
else if (type == QUE_NODE_FETCH) {
1090 }
else if (type == QUE_NODE_OPEN) {
1092 }
else if (type == QUE_NODE_FUNC) {
1095 }
else if (type == QUE_NODE_LOCK) {
1098 }
else if (type == QUE_NODE_THR) {
1099 thr = que_thr_node_step(thr);
1100 }
else if (type == QUE_NODE_COMMIT) {
1102 }
else if (type == QUE_NODE_UNDO) {
1104 }
else if (type == QUE_NODE_PURGE) {
1106 }
else if (type == QUE_NODE_RETURN) {
1108 }
else if (type == QUE_NODE_EXIT) {
1110 }
else if (type == QUE_NODE_ROLLBACK) {
1112 }
else if (type == QUE_NODE_CREATE_TABLE) {
1114 }
else if (type == QUE_NODE_CREATE_INDEX) {
1116 }
else if (type == QUE_NODE_ROW_PRINTF) {
1122 if (type == QUE_NODE_EXIT) {
1139 que_run_threads_low(
1174 if (next_thr != thr) {
1175 ut_a(next_thr == NULL);
1180 que_thr_dec_refer_count(thr, &next_thr);
1182 if (next_thr != NULL) {
1192 }
while (next_thr != NULL);
1208 que_run_threads_low(thr);
1210 switch (thr->
state) {
1212 case QUE_THR_RUNNING:
1218 case QUE_THR_LOCK_WAIT:
1225 if (
thr_get_trx(thr)->error_state != DB_SUCCESS) {
1229 que_thr_dec_refer_count(thr, NULL);
1237 case QUE_THR_COMPLETED:
1238 case QUE_THR_COMMAND_WAIT:
1256 ibool reserve_dict_mutex,
1266 if (reserve_dict_mutex) {
1272 if (reserve_dict_mutex) {
1281 graph->
fork_type = QUE_FORK_MYSQL_INTERFACE;
1287 if (reserve_dict_mutex) {
1293 if (reserve_dict_mutex) {