Skip to content

Commit

Permalink
Adapted for DB schema upgrade to version 2170
Browse files Browse the repository at this point in the history
  • Loading branch information
sduehr authored and joergsteffens committed May 18, 2017
1 parent f5c26e3 commit 8c25b7e
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 213 deletions.
2 changes: 1 addition & 1 deletion src/cats/cats.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ class pathid_cache;
/**
* Current database version number for all drivers
*/
#define BDB_VERSION 2004
#define BDB_VERSION 2170

#ifdef _BDB_PRIV_INTERFACE_
/*
Expand Down
19 changes: 10 additions & 9 deletions src/cats/ddl/creates/ingres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,15 @@ CREATE TABLE BaseFiles

CREATE INDEX basefiles_jobid_idx ON BaseFiles (JobId);

CREATE TABLE UnsavedFiles
(
UnsavedId INTEGER NOT NULL,
JobId INTEGER NOT NULL,
PathId INTEGER NOT NULL,
FilenameId INTEGER NOT NULL,
PRIMARY KEY (UnsavedId)
);
-- This table seems to be obsolete
-- CREATE TABLE UnsavedFiles
-- (
-- UnsavedId INTEGER NOT NULL,
-- JobId INTEGER NOT NULL,
-- PathId INTEGER NOT NULL,
-- FilenameId INTEGER NOT NULL,
-- PRIMARY KEY (UnsavedId)
-- );

CREATE TABLE PathHierarchy
(
Expand Down Expand Up @@ -535,7 +536,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
('i', 'Doing batch insert file records',15);

INSERT INTO Version (VersionId) VALUES (2004);
INSERT INTO Version (VersionId) VALUES (2170);

-- Make sure we have appropriate permissions
\g
47 changes: 23 additions & 24 deletions src/cats/ddl/creates/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ CREATE TABLE Path (
-- In general, these will cause very significant performance
-- problems in other areas. A better approch is to carefully check
-- that all your memory configuation parameters are
-- suitable for the size of your installation. If you backup
-- suitable for the size of your installation. If you backup
-- millions of files, you need to adapt the database memory
-- configuration parameters concerning sorting, joining and global
-- memory. By default, sort and join parameters are very small
-- (sometimes 8Kb), and having sufficient memory specified by those
-- parameters is extremely important to run fast.

-- In File table
-- FileIndex can be 0 for FT_DELETED files
-- FileNameId can link to Filename.Name='' for directories
-- FileIndex is 0 for FT_DELETED files
-- Name is '' for directories
CREATE TABLE File (
FileId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
FileIndex INTEGER UNSIGNED DEFAULT 0,
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
Name BLOB NOT NULL,
DeltaSeq SMALLINT UNSIGNED DEFAULT 0,
MarkId INTEGER UNSIGNED DEFAULT 0,
LStat TINYBLOB NOT NULL,
MD5 TINYBLOB,
PRIMARY KEY(FileId),
FileId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
FileIndex INTEGER UNSIGNED DEFAULT 0,
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
Name BLOB NOT NULL,
DeltaSeq SMALLINT UNSIGNED DEFAULT 0,
MarkId INTEGER UNSIGNED DEFAULT 0,
LStat TINYBLOB NOT NULL,
MD5 TINYBLOB NOT NULL,
PRIMARY KEY (FileId),
INDEX (JobId),
INDEX (JobId, PathId, Name(255))
);
Expand All @@ -46,8 +46,6 @@ CREATE TABLE File (
-- too slow, but they can slow down backups.
--
-- INDEX (PathId),
-- INDEX (FilenameId),
--

CREATE TABLE RestoreObject (
RestoreObjectId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -322,13 +320,14 @@ CREATE TABLE BaseFiles (

CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId );

CREATE TABLE UnsavedFiles (
UnsavedId INTEGER UNSIGNED AUTO_INCREMENT,
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
PRIMARY KEY (UnsavedId)
);
-- This table seems to be obsolete
-- CREATE TABLE UnsavedFiles (
-- UnsavedId INTEGER UNSIGNED AUTO_INCREMENT,
-- JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
-- PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
-- FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
-- PRIMARY KEY (UnsavedId)
-- );

CREATE TABLE Counters (
Counter TINYBLOB NOT NULL,
Expand Down Expand Up @@ -455,5 +454,5 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
-- Initialize Version
-- DELETE should not be required,
-- but prevents errors if create script is called multiple times
DELETE FROM Version WHERE VersionId<=2004;
INSERT INTO Version (VersionId) VALUES (2004);
DELETE FROM Version WHERE VersionId<=2170;
INSERT INTO Version (VersionId) VALUES (2170);
43 changes: 20 additions & 23 deletions src/cats/ddl/creates/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ CREATE UNIQUE INDEX path_name_idx ON Path (Path);
-- In general, these will cause very significant performance
-- problems in other areas. A better approch is to carefully check
-- that all your memory configuation parameters are
-- suitable for the size of your installation. If you backup
-- suitable for the size of your installation. If you backup
-- millions of files, you need to adapt the database memory
-- configuration parameters concerning sorting, joining and global
-- memory. By DEFAULT, sort and join parameters are very small
-- memory. By default, sort and join parameters are very small
-- (sometimes 8Kb), and having sufficient memory specified by those
-- parameters is extremely important to run fast.

-- In File table
-- FileIndex can be 0 for FT_DELETED files
-- FileNameId can link to Filename.Name='' for directories
CREATE TABLE File
(
FileId BIGSERIAL NOT NULL,
FileIndex INTEGER NOT NULL DEFAULT 0,
JobId INTEGER NOT NULL,
PathId INTEGER NOT NULL,
Name TEXT DEFAULT '',
DeltaSeq SMALLINT NOT NULL DEFAULT 0,
MarkId INTEGER NOT NULL DEFAULT 0,
LStat TEXT NOT NULL,
Md5 TEXT NOT NULL,
PRIMARY KEY (FileId)
-- FileIndex is 0 for FT_DELETED files
-- Name is '' for directories
CREATE TABLE File (
FileId BIGSERIAL NOT NULL,
FileIndex INTEGER NOT NULL DEFAULT 0,
JobId INTEGER NOT NULL,
PathId INTEGER NOT NULL,
Name TEXT NOT NULL,
DeltaSeq SMALLINT NOT NULL DEFAULT 0,
MarkId INTEGER NOT NULL DEFAULT 0,
LStat TEXT NOT NULL,
Md5 TEXT NOT NULL,
PRIMARY KEY (FileId)
);

CREATE INDEX file_jpfid_idx ON File (JobId, PathId, Name);
CREATE INDEX file_jobid_idx ON File (JobId);
CREATE INDEX file_jpfid_idx ON File (JobId, PathId, Name);

--
-- Add this if you have a good number of job
Expand All @@ -46,11 +44,10 @@ CREATE INDEX file_jobid_idx ON File (JobId);

--
-- Possibly add one or more of the following indexes
-- if your Verifies are too slow, but they can slow down
-- backups.
-- to the above File table if your Verifies are
-- too slow, but they can slow down backups.
--
-- CREATE INDEX file_pathid_idx ON file(pathid);
-- CREATE INDEX file_filenameid_idx ON file(filenameid);

CREATE TABLE RestoreObject (
RestoreObjectId SERIAL NOT NULL,
Expand Down Expand Up @@ -478,7 +475,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
-- Initialize Version
-- DELETE should not be required,
-- but prevents errors if create script is called multiple times
DELETE FROM Version WHERE VersionId<=2004;
INSERT INTO Version (VersionId) VALUES (2004);
DELETE FROM Version WHERE VersionId<=2170;
INSERT INTO Version (VersionId) VALUES (2170);

-- Make sure we have appropriate permissions
62 changes: 32 additions & 30 deletions src/cats/ddl/creates/sqlite3.sql
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
--
-- Sqlite:
--
-- make this as close to MySQL as possible.
-- sqlite:
-- INTEGER PRIMARY KEY is autoincremental by default.
-- index name must be unique per database, so name it to table_column_column_...

CREATE TABLE Path (
PathId INTEGER,
Path TEXT DEFAULT '',
PRIMARY KEY(PathId)
);

CREATE INDEX inx2 ON Path (Path);

-- In File table
-- FileIndex can be 0 for FT_DELETED files
-- FileNameId can link to Filename.Name='' for directories
-- FileIndex is 0 for FT_DELETED files
-- Name is '' for directories
CREATE TABLE File (
FileId INTEGER,
FileIndex INTEGER UNSIGNED NOT NULL,
JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
PathId INTEGER UNSIGNED REFERENCES Path NOT NULL,
Name TEXT DEFAULT '',
DeltaSeq SMALLINT UNSIGNED DEFAULT 0,
MarkId INTEGER UNSIGNED DEFAULT 0,
LStat VARCHAR(255) NOT NULL,
MD5 VARCHAR(255) NOT NULL,
PRIMARY KEY(FileId)
FileId INTEGER NOT NULL,
FileIndex INTEGER UNSIGNED DEFAULT 0,
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
Name BLOB NOT NULL,
DeltaSeq SMALLINT UNSIGNED DEFAULT 0,
MarkId INTEGER UNSIGNED DEFAULT 0,
LStat TINYBLOB NOT NULL,
MD5 TINYBLOB NOT NULL,
PRIMARY KEY (FileId)
);
CREATE INDEX inx3 ON File (JobId);
CREATE INDEX file_jpf_idx ON File (JobId, PathId, Name);
--
-- Possibly add one or more of the following indexes
-- if your Verifies are too slow.
--
-- CREATE INDEX inx4 ON File (PathId);
-- CREATE INDEX inx5 ON File (FileNameId);
CREATE INDEX File_JobId ON File (JobId);
CREATE INDEX File_JobId_PathId_Name ON File (JobId, PathId, Name);


CREATE TABLE RestoreObject (
Expand Down Expand Up @@ -300,13 +301,14 @@ CREATE TABLE BaseFiles (

CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId );

CREATE TABLE UnsavedFiles (
UnsavedId INTEGER,
JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
PathId INTEGER UNSIGNED REFERENCES Path NOT NULL,
FilenameId INTEGER UNSIGNED REFERENCES Filename NOT NULL,
PRIMARY KEY (UnsavedId)
);
-- This table seems to be obsolete
-- CREATE TABLE UnsavedFiles (
-- UnsavedId INTEGER,
-- JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
-- PathId INTEGER UNSIGNED REFERENCES Path NOT NULL,
-- FilenameId INTEGER UNSIGNED REFERENCES Filename NOT NULL,
-- PRIMARY KEY (UnsavedId)
-- );

CREATE TABLE NextId (
id INTEGER UNSIGNED DEFAULT 0,
Expand Down Expand Up @@ -468,8 +470,8 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
-- Initialize Version
-- DELETE should not be required,
-- but prevents errors if create script is called multiple times
DELETE FROM Version WHERE VersionId<=2004;
INSERT INTO Version (VersionId) VALUES (2004);
DELETE FROM Version WHERE VersionId<=2170;
INSERT INTO Version (VersionId) VALUES (2170);

PRAGMA default_cache_size = 100000;
PRAGMA synchronous = NORMAL;

0 comments on commit 8c25b7e

Please sign in to comment.