tada! the new worm
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Driver / Pg / storage.pm
index d4ecbd3..a066969 100644 (file)
 
                my $xact_id = $pg->current_xact_id;
 
+               my $success = 1;
                try {
                        $log->debug("Committing trasaction with Open-ILS XACT-ID [$xact_id]", INFO);
                        my $dbh = OpenILS::Application::Storage::CDBI->db_Main;
                } catch Error with {
                        my $e = shift;
                        $log->debug("Failed to commit trasaction with Open-ILS XACT-ID [$xact_id]: ".$e, INFO);
-                       return 0;
+                       $success = 0;
                };
                
                $pg->current_xact_session->unregister_callback( death => 
 
                $pg->unset_xact_session;
 
-               return 1;
+               return $success;
                
        }
        __PACKAGE__->register_method(
                my $self = shift;
 
                my $xact_id = $pg->current_xact_id;
+
+               my $success = 1;
                try {
                        my $dbh = OpenILS::Application::Storage::CDBI->db_Main;
                        $log->debug("Rolling back a trasaction with Open-ILS XACT-ID [$xact_id]", INFO);
                } catch Error with {
                        my $e = shift;
                        $log->debug("Failed to roll back trasaction with Open-ILS XACT-ID [$xact_id]: ".$e, INFO);
-                       return 0;
+                       $success = 0;
                };
        
                $pg->current_xact_session->unregister_callback( death =>
 
                $pg->unset_xact_session;
 
-               return 1;
+               return $success;
        }
        __PACKAGE__->register_method(
                method          => 'pg_rollback_xaction',
                argc            => 0,
        );
 
+       sub set_savepoint {
+               my $self = shift;
+               my $client = shift;
+               my $sp = shift || 'osrf_savepoint';
+               return OpenILS::Application::Storage::CDBI->db_Main->pg_savepoint($sp);
+       }
+       __PACKAGE__->register_method(
+               method          => 'set_savepoint',
+               api_name        => 'open-ils.storage.savepoint.set',
+               api_level       => 1,
+               argc            => 1,
+       );
+
+       sub release_savepoint {
+               my $self = shift;
+               my $client = shift;
+               my $sp = shift || 'osrf_savepoint';
+               return OpenILS::Application::Storage::CDBI->db_Main->pg_release($sp);
+       }
+       __PACKAGE__->register_method(
+               method          => 'release_savepoint',
+               api_name        => 'open-ils.storage.savepoint.release',
+               api_level       => 1,
+               argc            => 1,
+       );
+
+       sub rollback_to_savepoint {
+               my $self = shift;
+               my $client = shift;
+               my $sp = shift || 'osrf_savepoint';
+               return OpenILS::Application::Storage::CDBI->db_Main->pg_rollback_to($sp);
+       }
+       __PACKAGE__->register_method(
+               method          => 'rollback_to_savepoint',
+               api_name        => 'open-ils.storage.savepoint.rollback',
+               api_level       => 1,
+               argc            => 1,
+       );
+
+
        sub copy_create {
                my $self = shift;
                my $client = shift;
                        next unless ($node);
                        my $line = join("\t", map { defined($node->$_()) ? $node->$_() : '\N' } @cols);
                        $log->debug("COPY line: [$line]",DEBUG);
-                       $dbh->func($line."\n", 'putline');
+                       $dbh->pg_putline($line."\n");
                }
 
-               $dbh->func('endcopy');
+               $dbh->pg_endcopy || $log->debug("Could not end COPY with pg_endcopy", WARN);
+
+               $log->debug('COPY import for '.$cdbi->table." ($col_list) complete", DEBUG);
 
                return scalar(@fm_nodes);
        }