1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Database version refactoring.

* Refactor db version constants into a separate module.
* Update synthetic backup tests to PostgreSQL 9.4.
This commit is contained in:
David Steele 2016-08-11 22:35:24 -04:00
parent bff262ac47
commit 17b79d6279
25 changed files with 2228 additions and 2197 deletions

View File

@ -117,6 +117,18 @@
</release-item>
</release-refactor-list>
</release-core-list>
<release-test-list>
<release-refactor-list>
<release-item>
<p>Refactor db version constants into a separate module.</p>
</release-item>
<release-item>
<p>Update synthetic backup tests to <postgres/> 9.4.</p>
</release-item>
</release-refactor-list>
</release-test-list>
</release>
<release date="2016-08-09" version="1.05" title="Bug Fix for Tablespace Link Checking">

View File

@ -22,6 +22,7 @@ use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;

View File

@ -27,6 +27,7 @@ use pgBackRest::BackupInfo;
use pgBackRest::Common::String;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;

View File

@ -15,6 +15,7 @@ use Fcntl qw(O_RDONLY);
use File::Basename qw(dirname);
use lib dirname($0);
use pgBackRest::DbVersion;
use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::Common::String;
@ -40,28 +41,6 @@ use constant OP_DB_INFO => OP_DB . '
use constant DB_BACKUP_ADVISORY_LOCK => '12340078987004321';
push @EXPORT, qw(DB_BACKUP_ADVISORY_LOCK);
####################################################################################################################################
# PostgreSQL version numbers
####################################################################################################################################
use constant PG_VERSION_83 => '8.3';
push @EXPORT, qw(PG_VERSION_83);
use constant PG_VERSION_84 => '8.4';
push @EXPORT, qw(PG_VERSION_84);
use constant PG_VERSION_90 => '9.0';
push @EXPORT, qw(PG_VERSION_90);
use constant PG_VERSION_91 => '9.1';
push @EXPORT, qw(PG_VERSION_91);
use constant PG_VERSION_92 => '9.2';
push @EXPORT, qw(PG_VERSION_92);
use constant PG_VERSION_93 => '9.3';
push @EXPORT, qw(PG_VERSION_93);
use constant PG_VERSION_94 => '9.4';
push @EXPORT, qw(PG_VERSION_94);
use constant PG_VERSION_95 => '9.5';
push @EXPORT, qw(PG_VERSION_95);
use constant PG_VERSION_96 => '9.6';
push @EXPORT, qw(PG_VERSION_96);
####################################################################################################################################
# Map the control and catalog versions to PostgreSQL version.
#
@ -134,29 +113,6 @@ sub DESTROY
return logDebugReturn($strOperation);
}
####################################################################################################################################
# versionSupport
#
# Returns an array of the supported Postgres versions.
####################################################################################################################################
sub versionSupport
{
# Assign function parameters, defaults, and log debug info
my ($strOperation) = logDebugParam(__PACKAGE__ . '->versionSupport');
my @strySupportVersion = (PG_VERSION_83, PG_VERSION_84, PG_VERSION_90, PG_VERSION_91, PG_VERSION_92, PG_VERSION_93,
PG_VERSION_94, PG_VERSION_95, PG_VERSION_96);
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'strySupportVersion', value => \@strySupportVersion}
);
}
push @EXPORT, qw(versionSupport);
####################################################################################################################################
# executeSql
####################################################################################################################################
@ -224,9 +180,9 @@ sub executeSql
if (!$self->{hDb})
{
confess &log(ERROR, $DBI::errstr, ERROR_DB_CONNECT);
}
}
confess &log(ERROR, $DBI::errstr, ERROR_DB_CONNECT);
}
}
# Prepare the query
my $hStatement = $self->{hDb}->prepare($strSql, {pg_async => PG_ASYNC})

View File

@ -0,0 +1,60 @@
####################################################################################################################################
# DB VERSION MODULE
####################################################################################################################################
package pgBackRest::DbVersion;
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use Exporter qw(import);
our @EXPORT = qw();
use pgBackRest::Common::Log;
####################################################################################################################################
# PostgreSQL version numbers
####################################################################################################################################
use constant PG_VERSION_83 => '8.3';
push @EXPORT, qw(PG_VERSION_83);
use constant PG_VERSION_84 => '8.4';
push @EXPORT, qw(PG_VERSION_84);
use constant PG_VERSION_90 => '9.0';
push @EXPORT, qw(PG_VERSION_90);
use constant PG_VERSION_91 => '9.1';
push @EXPORT, qw(PG_VERSION_91);
use constant PG_VERSION_92 => '9.2';
push @EXPORT, qw(PG_VERSION_92);
use constant PG_VERSION_93 => '9.3';
push @EXPORT, qw(PG_VERSION_93);
use constant PG_VERSION_94 => '9.4';
push @EXPORT, qw(PG_VERSION_94);
use constant PG_VERSION_95 => '9.5';
push @EXPORT, qw(PG_VERSION_95);
use constant PG_VERSION_96 => '9.6';
push @EXPORT, qw(PG_VERSION_96);
####################################################################################################################################
# versionSupport
#
# Returns an array of the supported Postgres versions.
####################################################################################################################################
sub versionSupport
{
# Assign function parameters, defaults, and log debug info
my ($strOperation) = logDebugParam(__PACKAGE__ . '->versionSupport');
my @strySupportVersion = (PG_VERSION_83, PG_VERSION_84, PG_VERSION_90, PG_VERSION_91, PG_VERSION_92, PG_VERSION_93,
PG_VERSION_94, PG_VERSION_95, PG_VERSION_96);
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'strySupportVersion', value => \@strySupportVersion}
);
}
push @EXPORT, qw(versionSupport);
1;

View File

@ -15,6 +15,7 @@ use Digest::SHA;
use Time::Local qw(timelocal);
use lib dirname($0);
use pgBackRest::DbVersion;
use pgBackRest::Common::Exception;
use pgBackRest::Common::Ini;
use pgBackRest::Common::Log;

View File

@ -19,7 +19,7 @@ use pgBackRest::BackupInfo;
use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;

BIN
test/data/pg_control_93 Normal file

Binary file not shown.

BIN
test/data/pg_control_94 Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,9 @@ use pgBackRest::Common::Exception;
use pgBackRest::Common::Ini;
use pgBackRest::Common::Log;
use pgBackRest::Common::Wait;
use pgBackRest::Db;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;
@ -473,7 +474,7 @@ sub backupTestRun
filePathCreate(($oHostDbMaster->dbBasePath() . '/' . DB_PATH_GLOBAL), undef, false, true);
# Copy pg_control
executeTest('cp ' . testDataPath() . '/pg_control ' . $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL);
executeTest('cp ' . testDataPath() . '/pg_control_93 ' . $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL);
my $strCommand =
$oHostDbMaster->backrestExe() .
@ -697,10 +698,10 @@ sub backupTestRun
$oManifest{&MANIFEST_SECTION_BACKUP_OPTION}{&MANIFEST_KEY_HARDLINK} = $bHardLink ? JSON::PP::true : JSON::PP::false;
$oManifest{&MANIFEST_SECTION_BACKUP_OPTION}{&MANIFEST_KEY_ONLINE} = JSON::PP::false;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_CATALOG} = 201306121;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_CONTROL} = 937;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_SYSTEM_ID} = 6156904820763115222;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_DB_VERSION} = PG_VERSION_93;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_CATALOG} = 201409291;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_CONTROL} = 942;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_SYSTEM_ID} = 6317709442043514973;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_DB_VERSION} = PG_VERSION_94;
$oManifest{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_DB_ID} = 1;
$oManifest{&MANIFEST_SECTION_BACKUP_TARGET}{&MANIFEST_TARGET_PGDATA}{&MANIFEST_SUBKEY_PATH} =
@ -709,8 +710,8 @@ sub backupTestRun
$oHostDbMaster->manifestPathCreate(\%oManifest, MANIFEST_TARGET_PGDATA);
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, DB_FILE_PGVERSION, PG_VERSION_93,
'e1f7a3a299f62225cba076fc6d3d6e677f303482', $lTime);
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, DB_FILE_PGVERSION, PG_VERSION_94,
'184473f470864e067ee3a22e64b47b0a1c356f29', $lTime);
# Create base path
$oHostDbMaster->manifestPathCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base');
@ -719,7 +720,7 @@ sub backupTestRun
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/1/12000', 'BASE',
'a3b357a3e395e43fcfb19bb13f3c1b5179279593', $lTime);
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/1/' . DB_FILE_PGVERSION,
PG_VERSION_93, 'e1f7a3a299f62225cba076fc6d3d6e677f303482', $lTime, '660');
PG_VERSION_94, '184473f470864e067ee3a22e64b47b0a1c356f29', $lTime, '660');
if ($bNeutralTest && !$bRemote)
{
@ -733,7 +734,7 @@ sub backupTestRun
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/16384/17000', 'BASE',
'a3b357a3e395e43fcfb19bb13f3c1b5179279593', $lTime);
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/16384/' . DB_FILE_PGVERSION,
PG_VERSION_93, 'e1f7a3a299f62225cba076fc6d3d6e677f303482', $lTime);
PG_VERSION_94, '184473f470864e067ee3a22e64b47b0a1c356f29', $lTime);
if ($bNeutralTest && !$bRemote)
{
@ -747,16 +748,16 @@ sub backupTestRun
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768/33000', '33000',
'7f4c74dc10f61eef43e6ae642606627df1999b34', $lTime);
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768/' . DB_FILE_PGVERSION,
PG_VERSION_93, 'e1f7a3a299f62225cba076fc6d3d6e677f303482', $lTime);
PG_VERSION_94, '184473f470864e067ee3a22e64b47b0a1c356f29', $lTime);
# Create global path
$oHostDbMaster->manifestPathCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'global');
$oHostDbMaster->manifestFileCreate(\%oManifest, MANIFEST_TARGET_PGDATA, DB_FILE_PGCONTROL, '[replaceme]',
'56fe5780b8dca9705e0c22032a83828860a21235', $lTime - 100);
'2ee0de0a5fb5cf15f4a24e72b368c41f7e187003', $lTime - 100);
# Copy pg_control
executeTest('cp ' . testDataPath() . '/pg_control ' . $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL);
executeTest('cp ' . testDataPath() . '/pg_control_94 ' . $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL);
utime($lTime - 100, $lTime - 100, $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL)
or confess &log(ERROR, "unable to set time");
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{MANIFEST_TARGET_PGDATA . '/' . DB_FILE_PGCONTROL}
@ -1476,9 +1477,9 @@ sub backupTestRun
# Remove checksum to match zeroed files
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/base/32768/33000'}{&MANIFEST_SUBKEY_CHECKSUM});
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.3_201306121/32768/tablespace2.txt'}
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.4_201409291/32768/tablespace2.txt'}
{&MANIFEST_SUBKEY_CHECKSUM});
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.3_201306121/32768/tablespace2c.txt'}
delete($oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.4_201409291/32768/tablespace2c.txt'}
{&MANIFEST_SUBKEY_CHECKSUM});
$oHostDbMaster->restore(
@ -1488,9 +1489,9 @@ sub backupTestRun
# Restore checksum values for next test
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_data/base/32768/33000'}{&MANIFEST_SUBKEY_CHECKSUM} =
'7f4c74dc10f61eef43e6ae642606627df1999b34';
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.3_201306121/32768/tablespace2.txt'}
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.4_201409291/32768/tablespace2.txt'}
{&MANIFEST_SUBKEY_CHECKSUM} = 'dc7f76e43c46101b47acc55ae4d593a9e6983578';
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.3_201306121/32768/tablespace2c.txt'}
$oManifest{&MANIFEST_SECTION_TARGET_FILE}{'pg_tblspc/2/PG_9.4_201409291/32768/tablespace2c.txt'}
{&MANIFEST_SUBKEY_CHECKSUM} = 'dfcb8679956b734706cf87259d50c88f83e80e66';
# Remove chacksum to match zeroed file

View File

@ -15,7 +15,7 @@ use pgBackRest::BackupInfo;
use pgBackRest::Common::Ini;
use pgBackRest::Common::Log;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;

View File

@ -22,7 +22,7 @@ use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::File;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;

View File

@ -22,7 +22,7 @@ use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;
use pgBackRest::Version;

View File

@ -19,7 +19,7 @@ use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::FileCommon;
use pgBackRest::Manifest;
use pgBackRest::Version;

View File

@ -26,7 +26,6 @@ use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Config::Config;
use pgBackRest::Db;
use pgBackRest::File;
use pgBackRest::Manifest;

View File

@ -14,7 +14,7 @@ use Exporter qw(import);
our @EXPORT = qw();
use pgBackRest::Common::Log;
use pgBackRest::Db;
use pgBackRest::DbVersion;
####################################################################################################################################
# VM hash keywords

View File

@ -26,7 +26,7 @@ use pgBackRest::Common::Ini;
use pgBackRest::Common::Log;
use pgBackRest::Common::String;
use pgBackRest::Common::Wait;
use pgBackRest::Db;
use pgBackRest::DbVersion;
use pgBackRest::FileCommon;
use pgBackRest::Version;