~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/que/que0que.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#define QUE_ROUND_ROBIN_LIMIT   (64 * 256 * 256 * 256)
32
32
#define QUE_MAX_LOOPS_WITHOUT_CHECK     16
33
33
 
34
 
#ifdef UNIV_DEBUG
35
34
/* If the following flag is set TRUE, the module will print trace info
36
35
of SQL execution in the UNIV_SQL_DEBUG version */
37
 
UNIV_INTERN ibool       que_trace_on            = FALSE;
38
 
#endif /* UNIV_DEBUG */
 
36
ibool   que_trace_on            = FALSE;
 
37
 
 
38
ibool   que_always_false        = FALSE;
39
39
 
40
40
/* Short introduction to query graphs
41
41
   ==================================
120
120
 
121
121
/***************************************************************************
122
122
Adds a query graph to the session's list of graphs. */
123
 
UNIV_INTERN
 
123
 
124
124
void
125
125
que_graph_publish(
126
126
/*==============*/
134
134
 
135
135
/***************************************************************************
136
136
Creates a query graph fork node. */
137
 
UNIV_INTERN
 
137
 
138
138
que_fork_t*
139
139
que_fork_create(
140
140
/*============*/
180
180
 
181
181
/***************************************************************************
182
182
Creates a query graph thread node. */
183
 
UNIV_INTERN
 
183
 
184
184
que_thr_t*
185
185
que_thr_create(
186
186
/*===========*/
219
219
a single worker thread to execute it. This function should be used to end
220
220
the wait state of a query thread waiting for a lock or a stored procedure
221
221
completion. */
222
 
UNIV_INTERN
 
222
 
223
223
void
224
224
que_thr_end_wait(
225
225
/*=============*/
264
264
 
265
265
/**************************************************************************
266
266
Same as que_thr_end_wait, but no parameter next_thr available. */
267
 
UNIV_INTERN
 
267
 
268
268
void
269
269
que_thr_end_wait_no_next_thr(
270
270
/*=========================*/
318
318
is not in the QUE_THR_RUNNING state and moves it to that state. If none
319
319
can be chosen, a situation which may arise in parallelized fetches, NULL
320
320
is returned. */
321
 
UNIV_INTERN
 
321
 
322
322
que_thr_t*
323
323
que_fork_start_command(
324
324
/*===================*/
336
336
 
337
337
        fork->last_sel_node = NULL;
338
338
 
339
 
        suspended_thr = NULL;
340
 
        completed_thr = NULL;
341
 
 
342
339
        /* Choose the query thread to run: usually there is just one thread,
343
340
        but in a parallelized select, which necessarily is non-scrollable,
344
341
        there may be several to choose from */
406
403
After signal handling is finished, returns control to a query graph error
407
404
handling routine. (Currently, just returns the control to the root of the
408
405
graph so that the graph can communicate an error message to the client.) */
409
 
UNIV_INTERN
 
406
 
410
407
void
411
408
que_fork_error_handle(
412
409
/*==================*/
488
485
/**************************************************************************
489
486
Frees a query graph, but not the heap where it was created. Does not free
490
487
explicit cursor declarations, they are freed in que_graph_free. */
491
 
UNIV_INTERN
 
488
 
492
489
void
493
490
que_graph_free_recursive(
494
491
/*=====================*/
651
648
 
652
649
/**************************************************************************
653
650
Frees a query graph. */
654
 
UNIV_INTERN
 
651
 
655
652
void
656
653
que_graph_free(
657
654
/*===========*/
684
681
Checks if the query graph is in a state where it should be freed, and
685
682
frees it in that case. If the session is in a state where it should be
686
683
closed, also this is done. */
687
 
UNIV_INTERN
 
684
 
688
685
ibool
689
686
que_graph_try_free(
690
687
/*===============*/
805
802
{
806
803
        que_fork_t*     fork;
807
804
        trx_t*          trx;
 
805
        sess_t*         sess;
808
806
        ulint           fork_type;
809
807
        ibool           stopped;
810
808
 
811
809
        fork = thr->common.parent;
812
810
        trx = thr_get_trx(thr);
 
811
        sess = trx->sess;
813
812
 
814
813
        mutex_enter(&kernel_mutex);
815
814
 
836
835
 
837
836
                                *next_thr = thr;
838
837
                        } else {
839
 
                                ut_error;
 
838
                                ut_a(0);
840
839
                                srv_que_task_enqueue_low(thr);
841
840
                        }
842
841
 
867
866
 
868
867
        if (que_fork_all_thrs_in_state(fork, QUE_THR_COMPLETED)) {
869
868
 
870
 
                switch (fork_type) {
871
 
                case QUE_FORK_ROLLBACK:
 
869
                if (fork_type == QUE_FORK_ROLLBACK) {
872
870
                        /* This is really the undo graph used in rollback,
873
871
                        no roll_node in this graph */
874
872
 
876
874
                        ut_ad(trx->handling_signals == TRUE);
877
875
 
878
876
                        trx_finish_rollback_off_kernel(fork, trx, next_thr);
879
 
                        break;
880
 
 
881
 
                case QUE_FORK_PURGE:
882
 
                case QUE_FORK_RECOVERY:
883
 
                case QUE_FORK_MYSQL_INTERFACE:
884
 
 
885
 
                        /* Do nothing */
886
 
                        break;
887
 
 
888
 
                default:
 
877
 
 
878
                } else if (fork_type == QUE_FORK_PURGE) {
 
879
 
 
880
                        /* Do nothing */
 
881
                } else if (fork_type == QUE_FORK_RECOVERY) {
 
882
 
 
883
                        /* Do nothing */
 
884
                } else if (fork_type == QUE_FORK_DRIZZLE_INTERFACE) {
 
885
 
 
886
                        /* Do nothing */
 
887
                } else {
889
888
                        ut_error;       /* not used in MySQL */
890
889
                }
891
890
        }
911
910
Stops a query thread if graph or trx is in a state requiring it. The
912
911
conditions are tested in the order (1) graph, (2) trx. The kernel mutex has
913
912
to be reserved. */
914
 
UNIV_INTERN
 
913
 
915
914
ibool
916
915
que_thr_stop(
917
916
/*=========*/
959
958
query thread is stopped and made inactive, except in the case where
960
959
it was put to the lock wait state in lock0lock.c, but the lock has already
961
960
been granted or the transaction chosen as a victim in deadlock resolution. */
962
 
UNIV_INTERN
 
961
 
963
962
void
964
963
que_thr_stop_for_mysql(
965
964
/*===================*/
1005
1004
Moves a thread from another state to the QUE_THR_RUNNING state. Increments
1006
1005
the n_active_thrs counters of the query graph and transaction if thr was
1007
1006
not active. */
1008
 
UNIV_INTERN
 
1007
 
1009
1008
void
1010
1009
que_thr_move_to_run_state_for_mysql(
1011
1010
/*================================*/
1037
1036
/**************************************************************************
1038
1037
A patch for MySQL used to 'stop' a dummy query thread used in MySQL
1039
1038
select, when there is no error or lock wait. */
1040
 
UNIV_INTERN
 
1039
 
1041
1040
void
1042
1041
que_thr_stop_for_mysql_no_error(
1043
1042
/*============================*/
1070
1069
/********************************************************************
1071
1070
Get the first containing loop node (e.g. while_node_t or for_node_t) for the
1072
1071
given node, or NULL if the node is not within a loop. */
1073
 
UNIV_INTERN
 
1072
 
1074
1073
que_node_t*
1075
1074
que_node_get_containing_loop_node(
1076
1075
/*==============================*/
1100
1099
 
1101
1100
/**************************************************************************
1102
1101
Prints info of an SQL query graph node. */
1103
 
UNIV_INTERN
 
1102
 
1104
1103
void
1105
1104
que_node_print_info(
1106
1105
/*================*/
1346
1345
 
1347
1346
/**************************************************************************
1348
1347
Run a query thread. Handles lock waits. */
1349
 
UNIV_INTERN
1350
1348
void
1351
1349
que_run_threads(
1352
1350
/*============*/
1401
1399
 
1402
1400
/*************************************************************************
1403
1401
Evaluate the given SQL. */
1404
 
UNIV_INTERN
 
1402
 
1405
1403
ulint
1406
1404
que_eval_sql(
1407
1405
/*=========*/
1433
1431
        graph->trx = trx;
1434
1432
        trx->graph = NULL;
1435
1433
 
1436
 
        graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
 
1434
        graph->fork_type = QUE_FORK_DRIZZLE_INTERFACE;
1437
1435
 
1438
1436
        ut_a(thr = que_fork_start_command(graph));
1439
1437