MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Runtime Environment
Collaboration diagram for Runtime Environment:

Modules

 Event Scheduler
 Stored Routines

Macros

#define SP_TYPE_STRING(LP)   ((LP)->sphead->m_type == SP_TYPE_FUNCTION ? "FUNCTION" : "PROCEDURE")
#define SP_COM_STRING(LP)
#define used_stack(A, B)   (long) (B - A)
#define MY_YACC_INIT   1000
#define MY_YACC_MAX   32000

Functions

Slow_log_throttle
log_throttle_qni & 
opt_log_throttle_queries_not_using_indexes (s) suppressed."
bool stmt_causes_implicit_commit (const THD *thd, uint mask)
void init_update_queries (void)
bool sqlcom_can_generate_row_events (const THD *thd)
bool is_update_query (enum enum_sql_command command)
bool is_explainable_query (enum enum_sql_command command)
bool is_log_table_write_query (enum enum_sql_command command)
void execute_init_command (THD *thd, LEX_STRING *init_command, mysql_rwlock_t *var_lock)
pthread_handler_t handle_bootstrap (void *arg)
void do_handle_bootstrap (THD *thd)
void free_items (Item *item)
void cleanup_items (Item *item)
bool do_command (THD *thd)
bool dispatch_command (enum enum_server_command command, THD *thd, char *packet, uint packet_length)
bool log_slow_applicable (THD *thd)
void log_slow_do (THD *thd)
void log_slow_statement (THD *thd)
int prepare_schema_table (THD *thd, LEX *lex, Table_ident *table_ident, enum enum_schema_tables schema_table_idx)
bool alloc_query (THD *thd, const char *packet, uint packet_length)
int mysql_execute_command (THD *thd)
bool check_single_table_access (THD *thd, ulong privilege, TABLE_LIST *all_tables, bool no_errors)
bool check_one_table_access (THD *thd, ulong privilege, TABLE_LIST *all_tables)
bool check_access (THD *thd, ulong want_access, const char *db, ulong *save_priv, GRANT_INTERNAL_INFO *grant_internal_info, bool dont_check_global_grants, bool no_errors)
 Compare requested privileges with the privileges acquired from the User- and Db-tables.
bool check_table_access (THD *thd, ulong requirements, TABLE_LIST *tables, bool any_combination_of_privileges_will_do, uint number, bool no_errors)
 Check if the requested privileges exists in either User-, Host- or Db-tables.
bool check_routine_access (THD *thd, ulong want_access, char *db, char *name, bool is_proc, bool no_errors)
bool check_some_routine_access (THD *thd, const char *db, const char *name, bool is_proc)
bool check_some_access (THD *thd, ulong want_access, TABLE_LIST *table)
bool check_global_access (THD *thd, ulong want_access)
bool check_stack_overrun (THD *thd, long margin, uchar *buf __attribute__((unused)))
bool my_yyoverflow (short **yyss, YYSTYPE **yyvs, ulong *yystacksize)
void mysql_reset_thd_for_next_command (THD *thd)
void mysql_init_select (LEX *lex)
bool mysql_new_select (LEX *lex, bool move_down)
void create_select_for_variable (const char *var_name)
void mysql_init_multi_delete (LEX *lex)
void mysql_parse (THD *thd, char *rawbuf, uint length, Parser_state *parser_state)
bool add_field_to_list (THD *thd, LEX_STRING *field_name, enum_field_types type, char *length, char *decimals, uint type_modifier, Item *default_value, Item *on_update_value, LEX_STRING *comment, char *change, List< String > *interval_list, const CHARSET_INFO *cs, uint uint_geom_type)
void store_position_for_column (const char *name)
bool add_to_list (THD *thd, SQL_I_List< ORDER > &list, Item *item, bool asc)
void add_join_natural (TABLE_LIST *a, TABLE_LIST *b, List< String > *using_fields, SELECT_LEX *lex)
uint kill_one_thread (THD *thd, ulong id, bool only_kill_query)
bool append_file_to_dir (THD *thd, const char **filename_ptr, const char *table_name)
bool check_simple_select ()
Comp_creatorcomp_eq_creator (bool invert)
Comp_creatorcomp_ge_creator (bool invert)
Comp_creatorcomp_gt_creator (bool invert)
Comp_creatorcomp_le_creator (bool invert)
Comp_creatorcomp_lt_creator (bool invert)
Comp_creatorcomp_ne_creator (bool invert)
Itemall_any_subquery_creator (Item *left_expr, chooser_compare_func_creator cmp, bool all, SELECT_LEX *select_lex)
bool select_precheck (THD *thd, LEX *lex, TABLE_LIST *tables, TABLE_LIST *first_table)
bool multi_update_precheck (THD *thd, TABLE_LIST *tables)
bool multi_delete_precheck (THD *thd, TABLE_LIST *tables)
bool multi_delete_set_locks_and_link_aux_tables (LEX *lex)
bool update_precheck (THD *thd, TABLE_LIST *tables)
bool delete_precheck (THD *thd, TABLE_LIST *tables)
bool insert_precheck (THD *thd, TABLE_LIST *tables)
void create_table_set_open_action_and_adjust_tables (LEX *lex)
bool create_table_precheck (THD *thd, TABLE_LIST *tables, TABLE_LIST *create_table)
Itemnegate_expression (THD *thd, Item *expr)
void get_default_definer (THD *thd, LEX_USER *definer)
LEX_USERcreate_default_definer (THD *thd)
LEX_USERcreate_definer (THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
LEX_USERget_current_user (THD *thd, LEX_USER *user)
bool check_string_byte_length (LEX_STRING *str, const char *err_msg, uint max_byte_length)
bool check_string_char_length (LEX_STRING *str, const char *err_msg, uint max_char_length, const CHARSET_INFO *cs, bool no_error)
C_MODE_START int test_if_data_home_dir (const char *dir)
C_MODE_END bool check_host_name (LEX_STRING *str)
int MYSQLparse (void *thd)
bool parse_sql (THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx)

Variables

const char * any_db = "*any*"
const LEX_STRING command_name []
const char * xa_state_names []
uint sql_command_flags [SQLCOM_END+1]
uint server_command_flags [COM_END+1]
long max_stack_used

Detailed Description

Macro Definition Documentation

#define SP_COM_STRING (   LP)
Value:
((LP)->sql_command == SQLCOM_CREATE_SPFUNCTION || \
(LP)->sql_command == SQLCOM_ALTER_FUNCTION || \
(LP)->sql_command == SQLCOM_SHOW_CREATE_FUNC || \
(LP)->sql_command == SQLCOM_DROP_FUNCTION ? \
"FUNCTION" : "PROCEDURE")

Definition at line 118 of file sql_parse.cc.

Function Documentation

bool add_field_to_list ( THD *  thd,
LEX_STRING field_name,
enum_field_types  type,
char *  length,
char *  decimals,
uint  type_modifier,
Item default_value,
Item on_update_value,
LEX_STRING comment,
char *  change,
List< String > *  interval_list,
const CHARSET_INFO cs,
uint  uint_geom_type 
)

Store field definition for create.

Returns
Return 0 if ok

Definition at line 6339 of file sql_parse.cc.

Here is the call graph for this function:

void add_join_natural ( TABLE_LIST a,
TABLE_LIST b,
List< String > *  using_fields,
SELECT_LEX *  lex 
)

Create a fake SELECT_LEX for a unit.

The method create a fake SELECT_LEX object for a unit. This object is created for any union construct containing a union operation and also for any single select union construct of the form

    (SELECT ... ORDER BY order_list [LIMIT n]) ORDER BY ... 
    @endvarbatim
    or of the form
    @varbatim
    (SELECT ... ORDER BY LIMIT n) ORDER BY ...
    @endvarbatim
  
  @param thd_arg                   thread handle

  @note
    The object is used to retrieve rows from the temporary table
    where the result on the union is obtained.

  @retval
    1     on failure to create the object
  @retval
    0     on success
*/

bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg)
{
  SELECT_LEX *first_sl= first_select();
  DBUG_ENTER("add_fake_select_lex");
  DBUG_ASSERT(!fake_select_lex);

  if (!(fake_select_lex= new (thd_arg->mem_root) SELECT_LEX()))
      DBUG_RETURN(1);
  fake_select_lex->include_standalone(this, 
                                      (SELECT_LEX_NODE**)&fake_select_lex);
  fake_select_lex->select_number= INT_MAX;
  fake_select_lex->parent_lex= thd_arg->lex; /* Used in init_query. */
  fake_select_lex->make_empty_select();
  fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE;
  fake_select_lex->select_limit= 0;

  fake_select_lex->context.outer_context=first_sl->context.outer_context;
  /* allow item list resolving in fake select for ORDER BY */
  fake_select_lex->context.resolve_in_select_list= TRUE;
  fake_select_lex->context.select_lex= fake_select_lex;

  if (!is_union())
  {
    /* 
      This works only for 
      (SELECT ... ORDER BY list [LIMIT n]) ORDER BY order_list [LIMIT m],
      (SELECT ... LIMIT n) ORDER BY order_list [LIMIT m]
      just before the parser starts processing order_list
    */ 
    global_parameters= fake_select_lex;
    fake_select_lex->no_table_names_allowed= 1;
    thd_arg->lex->current_select= fake_select_lex;
  }
  thd_arg->lex->pop_context();
  DBUG_RETURN(0);
}


/**
  Push a new name resolution context for a JOIN ... ON clause to the
  context stack of a query block.

    Create a new name resolution context for a JOIN ... ON clause,
    set the first and last leaves of the list of table references
    to be used for name resolution, and push the newly created
    context to the stack of contexts of the query.

  @param thd       pointer to current thread
  @param left_op   left  operand of the JOIN
  @param right_op  rigth operand of the JOIN

  @todo Research if we should set the "outer_context" member of the new ON
  context.

  @retval
    FALSE  if all is OK
  @retval
    TRUE   if a memory allocation error occured
*/

bool
push_new_name_resolution_context(THD *thd,
                                 TABLE_LIST *left_op, TABLE_LIST *right_op)
{
  Name_resolution_context *on_context;
  if (!(on_context= new (thd->mem_root) Name_resolution_context))
    return TRUE;
  on_context->init();
  on_context->first_name_resolution_table=
    left_op->first_leaf_for_name_resolution();
  on_context->last_name_resolution_table=
    right_op->last_leaf_for_name_resolution();
  on_context->select_lex= thd->lex->current_select;
  // Save join nest's context in right_op, to find it later in view merging.
  DBUG_ASSERT(right_op->context_of_embedding == NULL);
  right_op->context_of_embedding= on_context;
  return thd->lex->push_context(on_context);
}


/**
  Add an ON condition to the second operand of a JOIN ... ON.

    Add an ON condition to the right operand of a JOIN ... ON clause.

  @param b     the second operand of a JOIN ... ON
  @param expr  the condition to be added to the ON clause
*/

void add_join_on(TABLE_LIST *b, Item *expr)
{
  if (expr)
  {
    if (!b->join_cond())
      b->set_join_cond(expr);
    else
    {
      /*
        If called from the parser, this happens if you have both a
        right and left join. If called later, it happens if we add more
        than one condition to the ON clause.
      */
      b->set_join_cond(new Item_cond_and(b->join_cond(), expr));
    }
    b->join_cond()->top_level_item();
  }
}


/**
  Mark that there is a NATURAL JOIN or JOIN ... USING between two
  tables.

    This function marks that table b should be joined with a either via
    a NATURAL JOIN or via JOIN ... USING. Both join types are special
    cases of each other, so we treat them together. The function
    setup_conds() creates a list of equal condition between all fields
    of the same name for NATURAL JOIN or the fields in 'using_fields'
    for JOIN ... USING. The list of equality conditions is stored
    either in b->join_cond(), or in JOIN::conds, depending on whether there
    was an outer join.

  EXAMPLE
  @verbatim
    SELECT * FROM t1 NATURAL LEFT JOIN t2
     <=>
    SELECT * FROM t1 LEFT JOIN t2 ON (t1.i=t2.i and t1.j=t2.j ... )

    SELECT * FROM t1 NATURAL JOIN t2 WHERE <some_cond>
     <=>
    SELECT * FROM t1, t2 WHERE (t1.i=t2.i and t1.j=t2.j and <some_cond>)

    SELECT * FROM t1 JOIN t2 USING(j) WHERE <some_cond>
     <=>
    SELECT * FROM t1, t2 WHERE (t1.j=t2.j and <some_cond>)
Parameters
aLeft join argument
bRight join argument
using_fieldsField names from USING clause

Definition at line 7056 of file sql_parse.cc.

bool add_to_list ( THD *  thd,
SQL_I_List< ORDER > &  list,
Item item,
bool  asc 
)

save order by and tables in own lists.

Definition at line 6447 of file sql_parse.cc.

Item* all_any_subquery_creator ( Item left_expr,
chooser_compare_func_creator  cmp,
bool  all,
SELECT_LEX *  select_lex 
)

Construct ALL/ANY/SOME subquery Item.

Parameters
left_exprpointer to left expression
cmpcompare function creator
alltrue if we create ALL subquery
select_lexpointer on parsed subquery structure
Returns
constructed Item (or 0 if out of memory)

Definition at line 7262 of file sql_parse.cc.

bool alloc_query ( THD *  thd,
const char *  packet,
uint  packet_length 
)

Read query from packet and store in thd->query. Used in COM_QUERY and COM_STMT_PREPARE.

Sets the following THD variables:

  • query
  • query_length
Return values
FALSEok
TRUEerror; In this case thd->fatal_error is set

Definition at line 2052 of file sql_parse.cc.

Here is the caller graph for this function:

bool append_file_to_dir ( THD *  thd,
const char **  filename_ptr,
const char *  table_name 
)

If pointer is not a null pointer, append filename to it.

Definition at line 7164 of file sql_parse.cc.

Here is the caller graph for this function:

bool check_access ( THD *  thd,
ulong  want_access,
const char *  db,
ulong *  save_priv,
GRANT_INTERNAL_INFO grant_internal_info,
bool  dont_check_global_grants,
bool  no_errors 
)

Compare requested privileges with the privileges acquired from the User- and Db-tables.

Parameters
thdThread handler
want_accessThe requested access privileges.
dbA pointer to the Db name.
[out]save_privA pointer to the granted privileges will be stored.
grant_internal_infoA pointer to the internal grant cache.
dont_check_global_grantsTrue if no global grants are checked.
no_errorTrue if no errors should be sent to the client.

'save_priv' is used to save the User-table (global) and Db-table grants for the supplied db name. Note that we don't store db level grants if the global grants is enough to satisfy the request AND the global grants contains a SELECT grant.

For internal databases (INFORMATION_SCHEMA, PERFORMANCE_SCHEMA), additional rules apply, see ACL_internal_schema_access.

See Also
check_grant
Returns
Status of denial of access by exclusive ACLs.
Return values
FALSEAccess can't exclusively be denied by Db- and User-table access unless Column- and Table-grants are checked too.
TRUEAccess denied.

Definition at line 5226 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_global_access ( THD *  thd,
ulong  want_access 
)

check for global access and give descriptive error message if it fails.

Parameters
thdThread handler
want_accessUse should have any of these global rights
Warning
One gets access right if one has ANY of the rights in want_access. This is useful as one in most cases only need one global right, but in some case we want to check if the user has SUPER or REPL_CLIENT_ACL rights.
Return values
0ok
1Access denied. In this case an error is sent to the client

Definition at line 5729 of file sql_parse.cc.

Here is the caller graph for this function:

C_MODE_END bool check_host_name ( LEX_STRING str)

Check that host name string is valid.

Parameters
[in]strstring to be checked
Returns
Operation status
Return values
FALSEhost name is ok
TRUEhost name string is longer than max_length or has invalid symbols

Definition at line 8092 of file sql_parse.cc.

Here is the call graph for this function:

bool check_one_table_access ( THD *  thd,
ulong  privilege,
TABLE_LIST all_tables 
)

Check grants for commands which work only with one table and all other tables belonging to subselects or implicitly opened tables.

Parameters
thdThread handler
privilegerequested privilege
all_tablesglobal table list of query
Return values
0OK
1access denied, error is sent to client

Definition at line 5170 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool select_dumpvar::check_simple_select ( )

Check if the select is a simple select (not an union).

Return values
0ok
1error ; In this case the error messege is sent to the client

Definition at line 7198 of file sql_parse.cc.

bool check_single_table_access ( THD *  thd,
ulong  privilege,
TABLE_LIST all_tables,
bool  no_errors 
)

Check grants for commands which work only with one table.

Parameters
thdThread handler
privilegerequested privilege
all_tablesglobal table list of query
no_errorsFALSE/TRUE - report/don't report error to the client (using my_error() call).
Return values
0OK
1access denied, error is sent to client

Definition at line 5120 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_some_access ( THD *  thd,
ulong  want_access,
TABLE_LIST table 
)

Check if the given table has any of the asked privileges

Parameters
thdThread handler
want_accessBitmap of possible privileges to check for
Return values
0ok
1error

Definition at line 5679 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_some_routine_access ( THD *  thd,
const char *  db,
const char *  name,
bool  is_proc 
)

Check if the routine has any of the routine privileges.

Parameters
thdThread handler
dbDatabase name
nameRoutine name
Return values
0ok
1error

Definition at line 5645 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_stack_overrun ( THD *  thd,
long  margin,
uchar *buf   __attribute__(unused) 
)
Note
Note: The 'buf' parameter is necessary, even if it is unused here.
  • fix_fields functions has a "dummy" buffer large enough for the corresponding exec. (Thus we only have to check in fix_fields.)
  • Passing to check_stack_overrun() prevents the compiler from removing it.

Definition at line 5766 of file sql_parse.cc.

Here is the caller graph for this function:

bool check_string_byte_length ( LEX_STRING str,
const char *  err_msg,
uint  max_byte_length 
)

Check that byte length of a string does not exceed some limit.

Parameters
strstring to be checked
err_msgerror message to be displayed if the string is too long
max_lengthmax length
Return values
FALSEthe passed string is not longer than max_length
TRUEthe passed string is longer than max_length

NOTE The function is not used in existing code but can be useful later?

Definition at line 7983 of file sql_parse.cc.

Here is the caller graph for this function:

bool check_table_access ( THD *  thd,
ulong  requirements,
TABLE_LIST tables,
bool  any_combination_of_privileges_will_do,
uint  number,
bool  no_errors 
)

Check if the requested privileges exists in either User-, Host- or Db-tables.

Parameters
thdThread context
want_accessPrivileges requested
tablesList of tables to be compared against
no_errorsDon't report error to the client (using my_error() call).
any_combination_of_privileges_will_doTRUE if any privileges on any column combination is enough.
numberOnly the first 'number' tables in the linked list are relevant.

The suppled table list contains cached privileges. This functions calls the help functions check_access and check_grant to verify the first three steps in the privileges check queue:

  1. Global privileges
  2. OR (db privileges AND host privileges)
  3. OR table privileges
  4. OR column privileges (not checked by this function!)
  5. OR routine privileges (not checked by this function!)
See Also
check_access
check_grant
Note
This functions assumes that table list used and thd->lex->query_tables_own_last value correspond to each other (the latter should be either 0 or point to next_global member of one of elements of this table list).
Returns
Return values
FALSEOK
TRUEAccess denied; But column or routine privileges might need to be checked also.

Definition at line 5534 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void cleanup_items ( Item item)

This works because items are allocated with sql_alloc().

Note
The function also handles null pointers (empty list).

Definition at line 887 of file sql_parse.cc.

Here is the caller graph for this function:

LEX_USER* create_default_definer ( THD *  thd)

Create default definer for the specified THD.

Parameters
[in]thdthread handler
Returns
  • On success, return a valid pointer to the created and initialized LEX_USER, which contains definer information.
  • On error, return 0.

Definition at line 7875 of file sql_parse.cc.

Here is the caller graph for this function:

LEX_USER* create_definer ( THD *  thd,
LEX_STRING user_name,
LEX_STRING host_name 
)

Create definer with the given user and host names.

Parameters
[in]thdthread handler
[in]user_nameuser name
[in]host_namehost name
Returns
  • On success, return a valid pointer to the created and initialized LEX_USER, which contains definer information.
  • On error, return 0.

Definition at line 7901 of file sql_parse.cc.

void create_select_for_variable ( const char *  var_name)

Create a select to return the same output as 'SELECT @var_name'.

Used for SHOW COUNT(*) [ WARNINGS | ERROR].

This will crash with a core dump if the variable doesn't exists.

Parameters
var_nameVariable name

Definition at line 6051 of file sql_parse.cc.

Here is the call graph for this function:

bool create_table_precheck ( THD *  thd,
TABLE_LIST tables,
TABLE_LIST create_table 
)

CREATE TABLE query pre-check.

Parameters
thdThread handler
tablesGlobal table list
create_tableTable which will be created
Return values
FALSEOK
TRUEError

Definition at line 7683 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void create_table_set_open_action_and_adjust_tables ( LEX *  lex)

Set proper open mode and table type for element representing target table of CREATE TABLE statement, also adjust statement table list if necessary.

Definition at line 7647 of file sql_parse.cc.

Here is the call graph for this function:

bool delete_precheck ( THD *  thd,
TABLE_LIST tables 
)

simple DELETE query pre-check.

Parameters
thdThread handler
tablesGlobal table list
Return values
FALSEOK
TRUEerror

Definition at line 7594 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool dispatch_command ( enum enum_server_command  command,
THD *  thd,
char *  packet,
uint  packet_length 
)

Perform one connection-level (COM_XXXX) command.

Parameters
commandtype of command to perform
thdconnection handle
packetdata for the command, packet is always null-terminated
packet_lengthlength of packet + 1 (to show that data is null-terminated) except for COM_SLEEP, where it can be zero.
Todo:

set thd->lex->sql_command to SQLCOM_END here.

The following has to be changed to an 8 byte integer

Return values
0ok
1request of thread shutdown, i. e. if command is COM_QUIT/COM_SHUTDOWN

Clear the set of flags that are expected to be cleared at the beginning of each command.

Enforce password expiration for all RPC commands, except the following:

COM_QUERY does a more fine-grained check later. COM_STMT_CLOSE and COM_STMT_SEND_LONG_DATA don't return anything. COM_PING only discloses information that the server is running, and that's available through other means. COM_QUIT should work even for expired statements.

Definition at line 1134 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool do_command ( THD *  thd)

Read one command from connection and execute it (query or simple command). This function is called in loop from thread function.

For profiling to work, it must never be called recursively.

Return values
0success
1request of thread shutdown (see dispatch_command() description)

Definition at line 909 of file sql_parse.cc.

Here is the call graph for this function:

LEX_USER* get_current_user ( THD *  thd,
LEX_USER user 
)

Retuns information about user or current user.

Parameters
[in]thdthread handler
[in]useruser
Returns
  • On success, return a valid pointer to initialized LEX_USER, which contains user information.
  • On error, return 0.

Definition at line 7934 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void get_default_definer ( THD *  thd,
LEX_USER definer 
)

Set the specified definer to the default value, which is the current user in the thread.

Parameters
[in]thdthread handler
[out]definerdefiner

Definition at line 7844 of file sql_parse.cc.

pthread_handler_t handle_bootstrap ( void *  arg)

Execute commands from bootstrap_file.

Used when creating the initial grant tables.

Definition at line 808 of file sql_parse.cc.

bool insert_precheck ( THD *  thd,
TABLE_LIST tables 
)

simple INSERT query pre-check.

Parameters
thdThread handler
tablesGlobal table list
Return values
FALSEOK
TRUEerror

Definition at line 7617 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_log_table_write_query ( enum enum_sql_command  command)

Check if a sql command is allowed to write to log tables.

Parameters
commandThe SQL command
Returns
true if writing is allowed

Definition at line 624 of file sql_parse.cc.

uint kill_one_thread ( THD *  thd,
ulong  id,
bool  only_kill_query 
)

kill on thread.

Parameters
thdThread class
idThread id
only_kill_queryShould it kill the query or the connection
Note
This is written such that we have a short lock on LOCK_thread_count

Definition at line 7075 of file sql_parse.cc.

bool log_slow_applicable ( THD *  thd)

Check whether we need to write the current statement (or its rewritten version if it exists) to the slow query log. As a side-effect, a digest of suppressed statements may be written.

Parameters
thdthread handle
Return values
truestatement needs to be logged
falsestatement does not need to be logged

Definition at line 1821 of file sql_parse.cc.

Here is the caller graph for this function:

void log_slow_do ( THD *  thd)

Unconditionally the current statement (or its rewritten version if it exists) to the slow query log.

Parameters
thdthread handle

Definition at line 1865 of file sql_parse.cc.

Here is the caller graph for this function:

void log_slow_statement ( THD *  thd)

Check whether we need to write the current statement to the slow query log. If so, do so. This is a wrapper for the two functions above; most callers should use this wrapper. Only use the above functions directly if you have expensive rewriting that you only need to do if the query actually needs to be logged (e.g. SP variables / NAME_CONST substitution when executing a PROCEDURE). A digest of suppressed statements may be logged instead of the current statement.

Parameters
thdthread handle

Definition at line 1896 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool multi_delete_precheck ( THD *  thd,
TABLE_LIST tables 
)

Multi delete query pre-check.

Parameters
thdThread handler
tablesGlobal/local table list
Return values
FALSEOK
TRUEerror

Definition at line 7412 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool multi_delete_set_locks_and_link_aux_tables ( LEX *  lex)

Link tables in auxilary table list of multi-delete with corresponding elements in main table list, and set proper locks for them.

Parameters
lexpointer to LEX representing multi-delete
Return values
FALSEsuccess
TRUEerror

Definition at line 7529 of file sql_parse.cc.

Here is the call graph for this function:

bool multi_update_precheck ( THD *  thd,
TABLE_LIST tables 
)

Multi update query pre-check.

Parameters
thdThread handler
tablesGlobal/local table list (have to be the same)
Return values
FALSEOK
TRUEError

Definition at line 7333 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int mysql_execute_command ( THD *  thd)

Execute command saved in thd and lex->sql_command.

Parameters
thdThread handle
Todo:
  • Invalidate the table in the query cache if something changed after unlocking when changes become visible.

: this is workaround. right way will be move invalidating in the unlock procedure.

  • TODO: use check_change_password()
Return values
FALSEOK
TRUEError

NO_EMBEDDED_ACCESS_CHECKS

Definition at line 2281 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void mysql_init_select ( LEX *  lex)

Resets the lex->current_select object.

Note
It is assumed that lex->current_select != NULL

This function is a wrapper around select_lex->init_select() with an added check for the special situation when using INTO OUTFILE and LOAD DATA.

Definition at line 5928 of file sql_parse.cc.

Here is the caller graph for this function:

bool mysql_new_select ( LEX *  lex,
bool  move_down 
)

Used to allocate a new SELECT_LEX object on the current thd mem_root and link it into the relevant lists.

This function is always followed by mysql_init_select.

See Also
mysql_init_select
Return values
TRUEAn error occurred
FALSEThe new SELECT_LEX was successfully allocated.

Definition at line 5954 of file sql_parse.cc.

void mysql_parse ( THD *  thd,
char *  rawbuf,
uint  length,
Parser_state *  parser_state 
)

Parse a query.

Parameters
thdCurrent thread
rawbufBegining of the query text
lengthLength of the query text
[out]found_semicolonFor multi queries, position of the character of the next query in the query text.

Definition at line 6108 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void mysql_reset_thd_for_next_command ( THD *  thd)

Reset the part of THD responsible for the state of command processing.

This needs to be called before execution of every statement (prepared or conventional). It is not called by substatements of routines.

Todo:
Remove mysql_reset_thd_for_next_command and only use the member function.
Todo:
Call it after we use THD for queries, not before.

Definition at line 5845 of file sql_parse.cc.

Here is the caller graph for this function:

Item* negate_expression ( THD *  thd,
Item expr 
)

negate given expression.

Parameters
thdthread handler
exprexpression for negation
Returns
negated expression

Definition at line 7813 of file sql_parse.cc.

bool parse_sql ( THD *  thd,
Parser_state *  parser_state,
Object_creation_ctx creation_ctx 
)

This is a wrapper of MYSQLparse(). All the code should call parse_sql() instead of MYSQLparse().

Parameters
thdThread context.
parser_stateParser state.
creation_ctxObject creation context.
Returns
Error status.
Return values
FALSEon success.
TRUEon parsing error.

Definition at line 8130 of file sql_parse.cc.

Here is the caller graph for this function:

int prepare_schema_table ( THD *  thd,
LEX *  lex,
Table_ident *  table_ident,
enum enum_schema_tables  schema_table_idx 
)

Create a TABLE_LIST object for an INFORMATION_SCHEMA table.

This function is used in the parser to convert a SHOW or DESCRIBE table_name command to a SELECT from INFORMATION_SCHEMA. It prepares a SELECT_LEX and a TABLE_LIST object to represent the given command as a SELECT parse tree.

Parameters
thdthread handle
lexcurrent lex
table_identtable alias if it's used
schema_table_idxthe type of the INFORMATION_SCHEMA table to be created
Note
Due to the way this function works with memory and LEX it cannot be used outside the parser (parse tree transformations outside the parser break PS and SP).
Return values
0success
1out of memory or SHOW commands are not allowed in this version of the server.

Definition at line 1933 of file sql_parse.cc.

bool select_precheck ( THD *  thd,
LEX *  lex,
TABLE_LIST tables,
TABLE_LIST first_table 
)

Perform first stage of privilege checking for SELECT statement.

Parameters
thdThread context.
lexLEX for SELECT statement.
tablesList of tables used by statement.
first_tableFirst table in the main SELECT of the SELECT statement.
Return values
FALSE- Success (column-level privilege checks might be required).
TRUE- Failure, privileges are insufficient.

Definition at line 7295 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void store_position_for_column ( const char *  name)

Store position for column in ALTER TABLE .. ADD column.

Definition at line 6437 of file sql_parse.cc.

bool update_precheck ( THD *  thd,
TABLE_LIST tables 
)

simple UPDATE query pre-check.

Parameters
thdThread handler
tablesGlobal table list
Return values
FALSEOK
TRUEError

Definition at line 7570 of file sql_parse.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

uint sql_command_flags[SQLCOM_END+1]

Mark all commands that somehow changes a table.

This is used to check number of updates / hour.

sql_command is actually set to SQLCOM_END sometimes so we need the +1 to include it in the array.

See COMMAND_FLAG_xxx for different type of commands 2 - query that returns meaningful ROW_COUNT() - a number of modified rows

Definition at line 289 of file sql_parse.cc.

const char* xa_state_names[]
Initial value:
{
"NON-EXISTING", "ACTIVE", "IDLE", "PREPARED", "ROLLBACK ONLY"
}

Definition at line 167 of file sql_parse.cc.