Very necessary as the trigger disabling code is about to be rewritten.
$t = q{Add table works for a single valid ending wildcard entry};
$res = $bct->ctl('bucardo add table drop%');
-is ($res, qq{$addtable_msg:\n public.droptest\n}, $t);
+is ($res, qq{$addtable_msg:\n public.droptest_bucardo\n}, $t);
$t = q{Add table works for a single valid middle wildcard entry};
$res = $bct->ctl('bucardo add table b%_test6');
\d+\.\s* Table: public.bucardo_test8 DB: A PK: id \(bytea\)\s+
\d+\.\s* Table: public.bucardo_test9 DB: A PK: id \(int_unsigned\)\s+
\d+\.\s* Table: public.bucardo_test10 DB: A PK: id \(timestamptz\)\s+
-\d+\.\s* Table: public.droptest DB: A PK: none\s+
+\d+\.\s* Table: public.droptest_bucardo DB: A PK: none\s+
\d+\.\s* Table: tschema.bucardo_test4 DB: A PK: none\s+
};
like ($res, $expected, $t);
## Remove them all, then try 'all tables' with exclude table
empty_goat_table();
$t = q{Add all tables with exclude table};
-$res = $bct->ctl('bucardo add all tables -T droptest -vv --debug');
+$res = $bct->ctl('bucardo add all tables -T droptest_bucardo -vv --debug');
like ($res, qr{New tables added: 12}, $t);
## Remove them all, then try 'all tables' with exclude schema
## The above runs one test for each passed in database x the number of test tables
my $numtables = keys %tabletype;
my $numsequences = keys %sequences;
-my $single_tests = 61;
+my $single_tests = 62;
my $check_for_row_1 = 1;
my $check_for_row_2 = 2;
my $check_for_row_3 = 3;
## Add a row to A, to make sure it does not go anywhere with inactive syncs
$bct->add_row_to_database('A', 1);
+## Clean out the droptest table for later testing
+$dbhA->do('TRUNCATE TABLE droptest_bucardo');
+$dbhA->commit();
+
sub d {
my $msg = shift || '?';
my $time = scalar localtime;
$res = $dbhA->selectall_arrayref($SQL);
is_deeply($res, [[1]], $t);
+## Make sure triggers and rules did not fire
+$SQL = 'SELECT * FROM droptest_bucardo';
+$sth = $dbhB->prepare($SQL);
+$count = $sth->execute();
+if ($count >= 1) {
+ diag Dumper $sth->fetchall_arrayref({});
+ BAIL_OUT "Found rows ($count) in the droptest table!";
+}
+$sth->finish();
+ok ('No rows found in the droptest table: triggers and rules were disabled');
+
## Switch to a 2 source sync
is $bct->ctl('bucardo update sync pgtest1 status=inactive'), '', 'Set pgtest1 status=inactive';
is $bct->ctl('bucardo update sync pgtest5 status=active'), '', 'Set pgtest5 status=active';
);
-our @tables2empty = (qw/droptest/);
+our @tables2empty = (qw/droptest_bucardo/);
our %sequences =
(
my ($tcount,$scount,$fcount) = (0,0,0);
## Empty out or create the droptest table
- if (table_exists($dbh => 'droptest')) {
- $dbh->do('TRUNCATE TABLE droptest');
+ if (table_exists($dbh => 'droptest_bucardo')) {
+ $dbh->do('TRUNCATE TABLE droptest_bucardo');
}
else {
$tcount++;
$dbh->do(q{
- CREATE TABLE droptest (
+ CREATE TABLE droptest_bucardo (
name TEXT NOT NULL,
type TEXT NOT NULL
)
RETURNS trigger
LANGUAGE plpgsql
AS $_$ BEGIN
- INSERT INTO droptest(name,type)
+ INSERT INTO droptest_bucardo(name,type)
VALUES (TG_RELNAME, 'trigger');
RETURN NULL;
END;
RETURNS trigger
LANGUAGE plpgsql
AS $_$ BEGIN
- INSERT INTO droptest(name,type)
+ INSERT INTO droptest_bucardo(name,type)
VALUES (TG_RELNAME, 'trigger');
RETURN NULL;
END;
$SQL = qq{
CREATE OR REPLACE RULE "bcrule_$table"
AS ON INSERT TO "$table"
- DO ALSO INSERT INTO droptest(name,type) VALUES ('$table','rule')
+ DO ALSO INSERT INTO droptest_bucardo(name,type) VALUES ('$table','rule')
};
$table =~ /0/ and $SQL =~ s/NEW.inty/0/;
$dbh->do($SQL);