Changeset 1318

Show
Ignore:
Timestamp:
10/16/09 22:30:22 (6 weeks ago)
Author:
robbat2
Message:

Support fid_type for Postgres, moving to 64-bit FIDs.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/server/lib/MogileFS/Store/Postgres.pm

    r1274 r1318  
    372372} 
    373373 
     374sub fid_type { 
     375    my $self = shift; 
     376    return $self->{_fid_type} if $self->{_fid_type}; 
     377 
     378    # let people force bigint mode with environment. 
     379    if ($ENV{MOG_FIDSIZE} && $ENV{MOG_FIDSIZE} eq "big") { 
     380        return $self->{_fid_type} = "BIGINT"; 
     381    } 
     382 
     383    # else, check a maybe-existing table and see if we're in bigint 
     384    # mode already. 
     385    my $dbh = $self->dbh; 
     386    my $file_fid_type = $self->column_type("file", "fid"); 
     387    if($file_fid_type) { 
     388        if ($file_fid_type =~ /bigint/i) { 
     389            return $self->{_fid_type} = "BIGINT"; 
     390        } elsif($file_fid_type =~ /int/i) { 
     391            # Old installs might not have raised the fid type size yet. 
     392            return $self->{_fid_type} = "INT"; 
     393        } 
     394    } 
     395 
     396    # Used to default to 32bit ints, but this always bites people 
     397    # a few years down the road. So default to 64bit. 
     398    return $self->{_fid_type} = "BIGINT"; 
     399} 
     400 
    374401# -------------------------------------------------------------------------- 
    375402# Test suite things we override