Kenichi Ishigaki wrote:
Hi Toby, please write a test if you can.

As for the usage of install_method(), we need to do like this:

  DBD::SQLite::db->install_method('sqlite_your_function_name');

Best,

Kenichi

Thanks.
I've attached a test, which passes against my previous patch.

Within that, you can see I'm doing calls of:
$dbh->backup_from_file('foo');

Are you suggesting that it should be:
$dbh->sqlite_backup_from_file('foo');
instead?

I'll see if I can convert that over quickly.

-Toby
#!/usr/bin/perl

use strict;
use warnings;

use t::lib::Test;
use Test::More tests => 4;
use DBI;
# use Test::NoWarnings;

# Connect to the test db and add some stuff:
my $foo = connect_ok( RaiseError => 1 );
$foo->do(
    'CREATE TABLE online_backup_test( id INTEGER PRIMARY KEY, foo INTEGER )'
);
$foo->do("INSERT INTO online_backup_test (foo) VALUES ($$)");

# That should be in the "foo" database on disk now, so disconnect and try to
# back it up:

$foo->disconnect;

my $dbh = DBI->connect(
    'dbi:SQLite:dbname=:memory:',
    undef, undef,
    { RaiseError => 1 }
);

$dbh->backup_from_file('foo');

{
    my ($count) = $dbh->selectrow_array(
        "SELECT count(foo) FROM online_backup_test WHERE foo=$$"
    );
    is($count, 1, "Found our process ID in backed-up table");
}

# Add more data then attempt to copy it back to file:
$dbh->do(
    'CREATE TABLE online_backup_test2 ( id INTEGER PRIMARY KEY, foo INTEGER )'
);
$dbh->do("INSERT INTO online_backup_test2 (foo) VALUES ($$)");

# backup to file (foo):
$dbh->backup_to_file('foo');

$dbh->disconnect;

# Reconnect to foo db and check data made it over:
{
    my $foo = connect_ok( RaiseError => 1 );

    my ($count) = $foo->selectrow_array(
        "SELECT count(foo) FROM online_backup_test2 WHERE foo=$$"
    );
    is($count, 1, "Found our process ID in table back on disk");

    $foo->disconnect;
}
_______________________________________________
DBD-SQLite mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbd-sqlite

Reply via email to