],
);
DBI()->do("alter table $DB_table add index (retries,id)");
+ DBI()->do("alter table $DB_table add index (time,retries)");
print "done.\n";
exit 0;
}
{
my($cond)=@_;
- my $sth=DBI()->prepare("select message from $DB_table $cond order by id");
+ my $sth=DBI()->prepare("select message from $DB_table $cond order by id"
+# ." limit 4001,999999" # FIXME
+ );
$sth->execute();
while (my $row=$sth->fetchrow_hashref()) {
print $row->{"message"},"\n";
}
}
+my $optwrap_err;
+sub optwrap
+{
+my($func,@args)=@_;
+
+ # Prevent successful return due to --forkoff in the case of failed --store when using:
+ # perlmail-submit --store --forkoff --submit
+ if (!eval { &{$func}(@args); 1; }) {
+ $optwrap_err||=$@||$!;
+ die "!FINISH";
+ die "NOTREACHED";
+ }
+}
$Getopt::Long::ignorecase=0;
-die if !GetOptions(
- "initdb" ,\&initdb,
- "store" ,\&store,
- "forkoff",\&forkoff,
- "submit" ,\&submit,
- "pending",\&pending,
- "dump" ,\&dump,
- "clean:s",\&clean,
+# &GetOptions will return success due to: die "!FINISH"
+# but our error detection is done by $optwrap_err.
+GetOptions(
+ "initdb" ,sub { optwrap \&initdb,@_; },
+ "store" ,sub { optwrap \&store,@_; },
+ "forkoff",sub { optwrap \&forkoff,@_; },
+ "submit" ,sub { optwrap \&submit,@_; },
+ "pending",sub { optwrap \&pending,@_; },
+ "dump" ,sub { optwrap \&dump,@_; },
+ "clean:s",sub { optwrap \&clean,@_; },
"V|version",sub { print "perlmail-submit: $VERSION\n"; exit 0; },
);
+die $optwrap_err if defined $optwrap_err;
exit 0;