Changeset 260 for trunk/tools

Show
Ignore:
Timestamp:
07/04/11 21:40:32 (3 years ago)
Author:
depesz
Message:

Add dump of sequence values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/fast.dump.and.restore/fast.dump

    r259 r260  
    440440    ); 
    441441 
     442    my $sequences = $self->psql( "select oid::regclass from pg_class where relkind = 'S'" ); 
     443    my @sequence_names = map { $_->[0] } @{ $sequences }; 
     444 
     445    my $sql = join "\n", map { 
     446        sprintf "SELECT 'SELECT setval( ''%s'', ' || last_value || ', ' || case when is_called then 'true' else 'false' end || ');' FROM %s;\n", 
     447        $_, 
     448        $_ 
     449        }  @sequence_names; 
     450 
     451    $self->psql( "\\o sequences.sql\n$sql\n" ); 
     452 
    442453    return; 
    443454}