Tie-Hash-DBD

 view release on metacpan or  search on metacpan

lib/Tie/Array/DBD.pm  view on Meta::CPAN


Note that changes inside deep structures do not work. See L</TODO>.

=head1 METHODS

=head2 drop ()

If a table was used with persistence, the table will not be dropped when
the C<untie> is called.  Dropping can be forced using the C<drop> method
at any moment while the array is tied:

  tied (@array)->drop;

=head2 readonly

You can inquire or set the readonly status of the bound array. Note that
setting read-only also forbids to delete generated temporary table.

  my $readonly = tied (@array)->readonly ();
  tied (@array)->readonly (1);

Setting read-only accepts 3 states:

=over 2

=item false (C<undef>, C<"">, C<0>)

This will (re)set the array to read-write.

=item C<1>

This will set read-only. When attempting to make changes, a warning is given.

=item C<2>

This will set read-only. When attempting to make changes, the process will die.

=back

=head1 PREREQUISITES

The only real prerequisite is DBI but of course that uses the DBD driver
of your choice. Some drivers are (very) actively maintained.  Be sure to
to use recent Modules.  DBD::SQLite for example seems to require version
1.29 or up.

=head1 RESTRICTIONS and LIMITATIONS

=over 2

=item *

C<DBD::Oracle> limits the size of BLOB-reads to 4kb by default, which is
too small for reasonable data structures. Tie::Array::DBD locally raises
this value to 4Mb, which is still an arbitrary limit.

=item *

C<Storable> does not support persistence of perl types C<IO>, C<REGEXP>,
C<CODE>, C<FORMAT>, and C<GLOB>.  Future extensions might implement some
alternative streaming modules, like C<Data::Dump::Streamer> or use mixin
approaches that enable you to fit in your own.

=item *

Note that neither DBD::CSV nor DBD::Unify support C<AutoCommit>.

=item *

For now, Firebird does not support C<TEXT> (or C<CLOB>) in DBD::Firebird
at a level required by Tie::Array::DBD.

Firebird support is stalled.

=back

=head1 TODO

=over 2

=item Update on deep changes

Currently,  nested structures do not get updated when it is an change in
a deeper part.

  tie my @array, "Tie::Array::DBD", $dbh, { str => "Storable" };

  @array = (
      [ 1, "foo" ],
      [ 2, "bar" ],
      );

  $array[1][0]++; # No effect :(

=item Documentation

Better document what the implications are of storing  I<data> content in
a database and restoring that. It will not be fool proof.

=item Mixins

Maybe: implement a feature that would enable plugins or mixins to do the
streaming or preservation of other data attributes.

=back

=head1 AUTHOR

H.Merijn Brand <h.m.brand@xs4all.nl>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010-2026 H.Merijn Brand

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. 

=head1 SEE ALSO

DBI, Tie::DBI, Tie::Array, Tie::Hash::DBD, DBM::Deep, Storable, Sereal,
JSON, JSON::MaybeXS, JSON::SIMD, JSON::Syck, JSON::XS, YAML, YAML::Syck,
XML::Dumper, Bencode, FreezeThaw

=cut

":ex:se gw=72";



( run in 0.480 second using v1.01-cache-2.11-cpan-d8267643d1d )