408
408
LEX *lex; /**< parse tree descriptor */
410
Points to the query associated with this statement. It's const, but
411
we need to declare it char * because all table handlers are written
412
in C and need to point to it.
414
Note that (A) if we set query = NULL, we must at the same time set
415
query_length = 0, and protect the whole operation with the
416
LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a
417
non-NULL value if its previous value is NULL. We do not need to protect
418
operation (B) with any mutex. To avoid crashes in races, if we do not
419
know that session->query cannot change at the moment, one should print
420
session->query like this:
421
(1) reserve the LOCK_thread_count mutex;
422
(2) check if session->query is NULL;
423
(3) if not NULL, then print at most session->query_length characters from
424
it. We will see the query_length field as either 0, or the right value
426
Assuming that the write and read of an n-bit memory field in an n-bit
427
computer is atomic, we can avoid races in the above way.
428
This printing is needed at least in SHOW PROCESSLIST and SHOW INNODB
432
uint32_t query_length; /**< current query length */
409
/** query associated with this statement */
435
413
Name of the current (default) database.