SchemaIterator iterates schema objects.
SchemaIterator | SchemaIterator iterates schema objects. |
Variables | |
$open_comment | |
$tbl_name | |
Functions | |
new | Create a new SchemaIterator object with either a dbh or a file_itr. |
_make_filters | Create schema object filters from OptionParser options. |
next_schema_object | Return the next schema object or undef when no more schema objects. |
_iterate_files | |
_iterate_dbh | |
database_is_allowed | |
table_is_allowed | |
engine_is_allowed | |
_d |
sub new
Create a new SchemaIterator object with either a dbh or a file_itr.
%args | Arguments |
dbh | dbh to iterate. Mutually exclusive with file_itr. |
file_itr | FileIterator::get_file_itr() iterator for dump file. Mutually exclusive with dbh. |
OptionParser | OptionParser object. All filters are gotten from this obj: --databases, --tables, etc. |
Quoter | Quoter object. |
Schema | Schema object to initialize while iterating. |
MySQLDump | MySQLDump object to get CREATE TABLE when iterating dbh. |
TableParser | TableParser object to parse CREATE TABLE for tbl_struct. |
keep_ddl | Keep CREATE TABLE (default false) |
SchemaIterator object
sub _make_filters
Create schema object filters from OptionParser options. The OptionParser object passed to new() is checked for filter options like --database, --tables, --ignore-tables, etc. For all such options, a hash is built keyed off the same option name. So $filter{tables} represents --tables, etc. Regex filters are pre-compiled. It is very important to avoid auto-vivifying certain key-values; see below. The filter hash is used in sub like database_is_allowed().
This sub is called from new(). That’s the only place and time it needs to be called because options shouldn’t change between runs.
%args | Arguments |
OptionParser | OptionParser object. All filters are gotten from this obj: --databases, --tables, etc. |
Quoter | Quoter object. |
Hashref of filters keyed on corresponding option names.
sub next_schema_object
Return the next schema object or undef when no more schema objects. Only filtered schema objects are returned. If iterating dump files (i.e. the obj was created with a file_itr arg), then the returned schema object will always have a ddl (see below). But if iterating a dbh, then you must create the obj with a MySQLDump obj to get a ddl. If this object was created with a TableParser, then the ddl, if present, is parsed, too.
Hashref of schema object with at least a db and tbl keys, like
{ db => 'test', tbl => 'a', ddl => 'CREATE TABLE `a` ( ...', # if keep_ddl tbl_struct => <TableParser::parse()> hashref of parsed ddl, }
The ddl is suitable for TableParser::parse().
my $open_comment
my $tbl_name
Create a new SchemaIterator object with either a dbh or a file_itr.
sub new
Create schema object filters from OptionParser options.
sub _make_filters
Return the next schema object or undef when no more schema objects.
sub next_schema_object
sub _iterate_files
sub _iterate_dbh
sub database_is_allowed
sub table_is_allowed
sub engine_is_allowed
sub _d
sub get_file_itr
Parse SHOW CREATE TABLE.
sub parse