MySQL Shell API 9.1.0
Unified development interface for MySQL Products
Methods | List of all members
Reports Class Reference

Gives access to built-in and user-defined reports. More...

Methods

Dict query (Session session, List argv)
 Executes the given SQL statement. More...
 
Dict threads (Session session, List argv, Dict options)
 Lists threads that belong to the user who owns the session object. More...
 
Dict thread (Session session, List argv, Dict options)
 Provides various information regarding the specified thread. More...
 

Detailed Description

Gives access to built-in and user-defined reports.

The 'reports' object provides access to built-in reports. All user-defined reports registered using the shell.registerReport() method are also available here. The reports are provided as methods of this object, with names corresponding to the names of the available reports.

All methods have the same signature: Dict report(Session session, List argv, Dict options), where:

Each report returns a dictionary with the following keys:

For more information on a report use: shell.reports.help('report_name').

Member Function Documentation

◆ query()

Dict query ( Session  session,
List  argv 
)

Executes the given SQL statement.

This is a 'list' type report.

Parameters
sessionSession object used to execute the given SQL statement.
argvList of strings constituting the SQL statement to be executed.
Returns
Dictionary containing a single key named 'report' with value being a list of lists.

◆ threads()

Dict threads ( Session  session,
List  argv,
Dict  options 
)

Lists threads that belong to the user who owns the session object.

This is a 'list' type report.

The 'options' dictionary may contain the following key-value pairs:

  • 'foreground' - Boolean, causes the report to list all foreground threads.
  • 'background' - Boolean, causes the report to list all background threads.
  • 'all' - Boolean, causes the report to list all threads.
  • 'format' - string, allows to specify order and number of columns returned by the report, optionally defining new column names. The expected format is: column[=alias][,column[=alias]]*. If column with the given name does not exist, all columns that match the given prefix are selected and alias is ignored.
  • 'where' - string, allows to filter the result. Expects a string in the following format: column OP value [LOGIC column OP value]*, where 'column' is a name of the column, value is an SQL value, OP is a relational operator (=, !=, <>, >, >=, <, <=, LIKE), LOGIC is a logical operator (AND, OR, NOT - case insensitive). The logical expressions can be grouped using parenthesis characters.
  • 'order_by' - string, a comma separated list which specifies the columns to be used to sort the output.
  • 'desc' - Boolean, causes the output to be sorted in descending order.
  • 'limit' - integer, limits the number of returned threads.

For more information on available columns, run: \show threads --help.

Parameters
sessionSession object.
argvEmpty list.
optionsConfiguration options of the report.
Returns
Dictionary containing a single key named 'report' with value being a list of lists.

◆ thread()

Dict thread ( Session  session,
List  argv,
Dict  options 
)

Provides various information regarding the specified thread.

By default lists information on the thread used by the session object.

The 'options' dictionary may contain the following key-value pairs:

  • 'tid' - integer, lists information for the specified thread ID.
  • 'cid' - integer, lists information for the specified connection ID.
  • 'brief' - Boolean, causes the report to list just a brief information on the given thread.
  • 'client' - Boolean, shows additional information about the client connection and the client session.
  • 'general' - Boolean, shows the basic information about the specified thread. This is the default if no other option is provided.
  • 'innodb' - Boolean, shows additional information about the current InnoDB transaction.
  • 'locks' - Boolean, shows additional information about locks blocking the thread and locks blocked by the thread.
  • 'prep_stmts' - Boolean, lists the prepared statements allocated for the thread.
  • 'status' - string, lists the session status variables for the thread. If value is empty, all variables are listed. Non-empty value should be in form: prefix[,prefix]*, only variables matching the given prefixes will be returned.
  • 'vars' - string, lists the session system variables for the thread. If value is empty, all variables are listed. Non-empty value should be in form: prefix[,prefix]*, only variables matching the given prefixes will be returned.
  • 'user_vars' - string, lists the user-defined variables for the thread. If value is empty, all variables are listed. Non-empty value should be in form: prefix[,prefix]*, only variables matching the given prefixes will be returned.
  • 'all' - Boolean, provides all available information for the thread.
Parameters
sessionSession object.
argvEmpty list.
optionsConfiguration options of the report.
Returns
Dictionary containing a single key named 'report' with value being a list of dictionaries.