Better SQL for gathering latest changes across all tables for conflict resolution.
authorGreg Sabino Mullane <greg@endpoint.com>
Wed, 29 Apr 2015 03:15:59 +0000 (23:15 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Wed, 29 Apr 2015 03:15:59 +0000 (23:15 -0400)
Bucardo.pm

index 4dba0776f32c3cbba22f1dc3853f35df2132313e..6fbe3482aab587145438212c378c140b4f85f608 100644 (file)
@@ -3920,7 +3920,7 @@ sub start_kid {
                             $self->glog("Using previous conflict winner $self->{conflictinfo}{syncwinner}", LOG_DEBUG);
                         }
                         else {
-                            my $maxsql = 'SELECT extract(epoch FROM MAX(txntime)) FROM';
+                            my $maxsql = 'SELECT COALESCE(extract(epoch FROM MAX(txntime)),0) FROM';
 
                             ## Find the maximum txntime across all databases for this table
                             if ($g->{conflict_strategy} eq 'bucardo_latest') {
@@ -3938,7 +3938,7 @@ sub start_kid {
                                 $self->pause_and_exit(qq{Unknown conflict_strategy $g->{conflict_strategy}!});
                             }
 
-                            $SQL .= ' ORDER BY txntime IS NULL, 1 DESC LIMIT 1';
+                            $SQL .= ' ORDER BY 1 DESC LIMIT 1';
 
                             ## Check every database that generates deltas
                             for my $dbname (@dbs_delta) {