TableUsage determines how tables in a query are used.
For best results, queries should be from EXPLAIN EXTENDED so all identifiers are fully qualified. Else, some table references may be missed because no effort is made to table-qualify unqualified columns.
This package uses both QueryParser and SQLParser. The former is used for simple queries, and the latter is used for more complex queries where table usage may be hidden in who-knows-which clause of the SQL statement.
TableUsage | TableUsage determines how tables in a query are used. |
Functions | |
new | |
get_table_usage | Get table usage for each table in the given query. |
_get_tables_used_from_query_parser | |
_get_tables_used_from_query_struct | |
_get_tables_used_in_columns | |
_get_tables_used_in_where | |
_get_tables_used_in_set | |
_get_real_table_name | |
_qualify_table_name | |
_change_context | |
_d |
sub new
%args | Arguments |
QueryParser | QueryParser object |
SQLParser | SQLParser object |
constant_data_value | Value for constants, default “DUAL”. |
TableUsage object
sub get_table_usage
Get table usage for each table in the given query.
%args | Arguments |
query | Query string |
Arrayref of hashrefs, one for each CAT, like: (code start) [ { context => ‘DELETE’, table => ‘d.t’, }, { context => ‘DELETE’, table => ‘d.t’, }, ], (code stop)
sub new
Get table usage for each table in the given query.
sub get_table_usage
sub _get_tables_used_from_query_parser
sub _get_tables_used_from_query_struct
sub _get_tables_used_in_columns
sub _get_tables_used_in_where
sub _get_tables_used_in_set
sub _get_real_table_name
sub _qualify_table_name
sub _change_context
sub _d