query_script_report
report: generate formatted report at end of script execution
SYNOPSIS
report h1 'My title'; report 'concatenated ', 'text, numbers, ', @user_variables, ' and ', $local_variables; report p 'Starting paragraph, ', @name, ' review'; report li $x, ' is validated, bullet'; report code 'SET $x := 5'; report hr;
DESCRIPTION
report builds a fancy report throughout execution of the script. The report itself is only presented as the script terminates gracefully (without error). Thus, invocation of report statements aggregate report messages in the background, and do not immediately prompt or otherwise affect execution and output of script.
report concatenates its arguments into a single string. Anything that is valid within a CONCAT() function is accepted by report. This includes user defined variables, local variables and expanded variables.
Line breaks (\n) will make for distinct rows in the resulting report.
report accepts formatting hints, in an HTML-like format. These are:
- h1: title (prettified by underline)
- p: begin paragraph
- li: bullet (prefix with "- ")
- code: source code (prefixed with "> ")
- hr: horizontal line
EXAMPLES
A built-in report in common_schema is security_audit.
Analyze and report some common_schema objects:
report h1 'common_schema overview'; report p 'common_schema offers:'; var $num_public_prodecures, $num_public_functions; select SUM(routine_type = 'PROCEDURE'), SUM(routine_type = 'FUNCTION') FROM information_schema.ROUTINES WHERE routine_schema='common_schema' AND routine_name NOT LIKE '\_%' INTO $num_public_prodecures, $num_public_functions; report li $num_public_prodecures, ' public procedures'; report li $num_public_functions, ' public functions'; var $num_public_tables, $num_public_views; select SUM(table_type='base table'), SUM(table_type='view') FROM information_schema.TABLES WHERE table_schema='common_schema' AND table_name NOT LIKE '\_%' INTO $num_public_tables, $num_public_views; report li $num_public_tables, ' public tables'; report li $num_public_views, ' public views'; report li (select count(*) from help_content), ' help pages'; +------------------------------------------+ | report | +------------------------------------------+ | | | common_schema overview | | ====================== | | | | common_schema offers: | | - 19 public procedures | | - 32 public functions | | - 3 public tables | | - 34 public views | | - 131 help pages | | --- | | Report generated on '2012-09-29 13:42:11 | +------------------------------------------+