TextResultSetParser

TextResultSetParser converts a text result set to a data struct like DBI::selectall_arrayref().  Text result sets are like what SHOW PROCESSLIST and EXPLAIN print, like:

+----+------+

Id | User |

+----+------+

1  | bob  |

+----+------+

That converts to

[
   {
      Id   => '1',
      User => 'bob',
   },
]

Both horizontal and vertical (\G) text outputs are supported.

Summary
TextResultSetParserTextResultSetParser converts a text result set to a data struct like DBI::selectall_arrayref().
Functions
new
_pasre_tabularParse a line from tabular horizontal output.
_parse_tabular
_pasre_tabularParse a line from tab-separated horizontal output.
_parse_tab_sep
parse_vertical_rowParse records split from vertical output by split_vertical_rows().
parseParse a text result set.
parse_horizontal_rowParse rows from horizontal output (regular MySQL style output).
parse_horizontal_rowSplit records in vertical output (\G style output).
split_vertical_rows
_d

Functions

new

sub new

Parameters

%argsArguments

Optional Arguments

value_forHashref of original_val => new_val, used to alter values
NAME_lcLowercase key names, like $dbh->{FetchHashKeyName} = ‘NAME_lc’

Returns

TextResultSetParser object

_pasre_tabular

Parse a line from tabular horizontal output.

Parameters

$textText row from horizontal output, split in parse_horizontal_rows()
@colsColumn names that text rows are organized by

Returns

A record hashref

_parse_tabular

sub _parse_tabular

_pasre_tabular

Parse a line from tab-separated horizontal output.

Parameters

$textText row from horizontal output, split in parse_horizontal_rows()
@colsColumn names that text rows are organized by

Returns

A record hashref

_parse_tab_sep

sub _parse_tab_sep

parse_vertical_row

sub parse_vertical_row

Parse records split from vertical output by split_vertical_rows().

Parameters

$textText record

Returns

A record hashref

parse

sub parse

Parse a text result set.

Parameters

$textText result set

Returns

Arrayref like:

[
  {
    Time     => '5',
    Command  => 'Query',
    db       => 'foo',
  },
]

parse_horizontal_row

sub parse_horizontal_row

Parse rows from horizontal output (regular MySQL style output).

Parameters

$textText result set
$line_patternCompiled regex pattern that matches one line
$subCoderef to parse a line (tabular or tab-separated lines)

Returns

Arrayref of records as hashrefs

parse_horizontal_row

Split records in vertical output (\G style output).

Parameters

$textText result set

Returns

Array of text records, parsed by parse_vertical_row().

split_vertical_rows

sub split_vertical_rows

_d

sub _d
sub new
sub _parse_tabular
sub _parse_tab_sep
sub parse_vertical_row
Parse records split from vertical output by split_vertical_rows().
sub split_vertical_rows
sub parse
Parse a text result set.
sub parse_horizontal_row
Parse rows from horizontal output (regular MySQL style output).
sub _d
Close