Commit 95feb639 authored by Leigh Stoller's avatar Leigh Stoller

Add a limit option to help with debugging. The limit is the number of

rows pushed across to the DP.
parent 07c580de
......@@ -17,8 +17,9 @@ sub usage() {
print STDOUT "Usage: pelab_dbpush [-d]\n";
exit(-1);
}
my $optlist = "d";
my $optlist = "dl:";
my $debug = 0;
my $limit;
#
# Configure variables
......@@ -88,6 +89,9 @@ if (@ARGV) {
if (defined($options{"d"})) {
$debug++;
}
if (defined($options{"l"})) {
$limit = $options{"l"};
}
#
# Reopen both stdout and stderr so that we can record all the output for
......@@ -161,29 +165,39 @@ my $cutoffage = (time() - $CUTAGE) * 1.0;
DBQueryFatal("lock tables pair_data write");
#
# Grab all of the new entries and store to the file
# See what the max IDX we want to get is.
#
DBQueryFatal("select * from pair_data ".
"where idx > $lastidx ".
"into outfile '${tempfile}.pair_data' ".
"fields terminated by ' '");
if (defined($limit)) {
$query_result =
DBQueryFatal("select idx from pair_data ".
"where idx > $lastidx ".
"order by idx asc limit $limit,1");
}
else {
$query_result =
DBQueryFatal("select MAX(idx) from pair_data");
}
my ($maxidx) = $query_result->fetchrow_array();
#
# Now we need to find out what the last index really was.
#
$query_result =
DBQueryFatal("select idx from pair_data ".
"where idx > $lastidx " .
"order by idx desc limit 1");
# Save for later.
($lastidx) = $query_result->fetchrow_array();
# Grab all of the new entries and store to the file
#
if ($maxidx > $lastidx) {
DBQueryFatal("select * from pair_data ".
"where idx > $lastidx and idx <= $maxidx ".
"into outfile '${tempfile}.pair_data' ".
" fields terminated by ' '");
}
DBQueryFatal("unlock tables");
#
# Might not be any new entries ...
#
if (defined($lastidx)) {
if ($maxidx > $lastidx) {
# New last, used below.
$lastidx = $maxidx;
#
# Does not return if any error!
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment