Skip to content

Commit

Permalink
Merge branch 'bareos-16.2-db2170'
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Apr 11, 2017
2 parents 248ae67 + 99db990 commit 513280b
Show file tree
Hide file tree
Showing 32 changed files with 288 additions and 312 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -6,6 +6,8 @@ policy at https://www.bareos.org/en/howto-contribute.html
This source code has the following changes (highlevel) compared with
Bacula 5.2.13 (original version forked.):

This is a special branch with denormalized filename table

Release 16.2.x
==============

Expand Down
4 changes: 2 additions & 2 deletions po/bareos.pot
Expand Up @@ -13005,12 +13005,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
6 changes: 3 additions & 3 deletions po/de.po
Expand Up @@ -13435,13 +13435,13 @@ msgstr "Fehler beim holen der Zeile: %s\n"

#: src/cats/sql_get.c:150
#, fuzzy, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr "get_file_record erwartet 1 erhalten rows=%d\n"

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgstr "File Eintrag für PathId=%s FilenameId=%s nicht gefunden.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr "File Eintrag für PathId=%s Filename=%s nicht gefunden.\n"

#: src/cats/sql_get.c:164
msgid "File record not found in Catalog.\n"
Expand Down
6 changes: 3 additions & 3 deletions po/es.po
Expand Up @@ -14118,13 +14118,13 @@ msgstr "Error obteniendo fila: %s\n"

#: src/cats/sql_get.c:150
#, fuzzy, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr "get_file_record falta 1 obtuvo filas=%d\n"

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgstr "Registro File para PathID=%s FilenameID=%s no encontrado.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr "Registro File para PathID=%s Filename=%s no encontrado.\n"

#: src/cats/sql_get.c:164
msgid "File record not found in Catalog.\n"
Expand Down
4 changes: 2 additions & 2 deletions po/fr.po
Expand Up @@ -13861,12 +13861,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
4 changes: 2 additions & 2 deletions po/it.po
Expand Up @@ -13005,12 +13005,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
4 changes: 2 additions & 2 deletions po/nl.po
Expand Up @@ -13088,12 +13088,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
4 changes: 2 additions & 2 deletions po/pl.po
Expand Up @@ -14037,12 +14037,12 @@ msgstr "Błąd pobierania rekordu: %s\n"

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
4 changes: 2 additions & 2 deletions po/sv.po
Expand Up @@ -13006,12 +13006,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
4 changes: 2 additions & 2 deletions po/uk.po
Expand Up @@ -13112,12 +13112,12 @@ msgstr ""

#: src/cats/sql_get.c:150
#, c-format
msgid "get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"
msgid "get_file_record want 1 got rows=%d PathId=%s Filename=%s\n"
msgstr ""

#: src/cats/sql_get.c:158
#, c-format
msgid "File record for PathId=%s FilenameId=%s not found.\n"
msgid "File record for PathId=%s Filename=%s not found.\n"
msgstr ""

#: src/cats/sql_get.c:164
Expand Down
41 changes: 20 additions & 21 deletions src/cats/bvfs.c
Expand Up @@ -3,7 +3,7 @@

Copyright (C) 2009-2010 Free Software Foundation Europe e.V.
Copyright (C) 2016-2016 Planets Communications B.V.
Copyright (C) 2016-2016 Bareos GmbH & Co. KG
Copyright (C) 2016-2017 Bareos GmbH & Co. KG

This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -554,8 +554,10 @@ bool Bvfs::ch_dir(const char *path)
* Get all file versions for a specified client
* TODO: Handle basejobs using different client
*/
void Bvfs::get_all_file_versions(DBId_t pathid, DBId_t fnid, const char *client)
void Bvfs::get_all_file_versions(DBId_t pathid, const char *fname, const char *client)
{
Dmsg3(dbglevel, "get_all_file_versions(%lld, %s, %s)\n", (uint64_t)pathid,
fname, client);
char ed1[50], ed2[50];
POOL_MEM query(PM_MESSAGE);
POOL_MEM filter(PM_MESSAGE);
Expand All @@ -569,13 +571,13 @@ void Bvfs::get_all_file_versions(DBId_t pathid, DBId_t fnid, const char *client)
}

Mmsg(query,// 1 2 3
"SELECT 'V', File.PathId, File.FilenameId, File.Md5, "
"SELECT 'V', File.PathId, File.Name, File.Md5, "
// 4 5 6
"File.JobId, File.LStat, File.FileId, "
// 7 8
"Media.VolumeName, Media.InChanger "
"FROM File, Job, Client, JobMedia, Media "
"WHERE File.FilenameId = %s "
"WHERE File.Name = %s "
"AND File.PathId=%s "
"AND File.JobId = Job.JobId "
"AND Job.JobId = JobMedia.JobId "
Expand All @@ -585,7 +587,7 @@ void Bvfs::get_all_file_versions(DBId_t pathid, DBId_t fnid, const char *client)
"AND Job.ClientId = Client.ClientId "
"AND Client.Name = '%s' "
"%s ORDER BY FileId LIMIT %d OFFSET %d"
,edit_uint64(fnid, ed1), edit_uint64(pathid, ed2), client, filter.c_str(),
,fname, edit_uint64(pathid, ed2), client, q.c_str(),
limit, offset);

Dmsg1(dbglevel_sql, "query=%s\n", query.c_str());
Expand Down Expand Up @@ -633,10 +635,6 @@ void Bvfs::ls_special_dirs()
return;
}

if (!dir_filenameid) {
get_dir_filenameid();
}

/* Will fetch directories */
*prev_dir = 0;

Expand All @@ -653,11 +651,11 @@ void Bvfs::ls_special_dirs()
"FROM %s AS tmp LEFT JOIN ( " // get attributes if any
"SELECT File1.PathId AS PathId, File1.JobId AS JobId, "
"File1.LStat AS LStat, File1.FileId AS FileId FROM File AS File1 "
"WHERE File1.FilenameId = %s "
"WHERE File1.Name = '' "
"AND File1.JobId IN (%s)) AS listfile1 "
"ON (tmp.PathId = listfile1.PathId) "
"ORDER BY tmp.Path, JobId DESC ",
query.c_str(), edit_uint64(dir_filenameid, ed2), jobids);
query.c_str(), jobids);

Dmsg1(dbglevel_sql, "q=%s\n", query2.c_str());
db->sql_query(query2.c_str(), path_handler, this);
Expand All @@ -679,9 +677,6 @@ bool Bvfs::ls_dirs()
db->fill_query(filter, B_DB::SQL_QUERY_match_query, pattern);
}

if (!dir_filenameid) {
get_dir_filenameid();
}

/*
* The sql query displays same directory multiple time, take the first one
Expand All @@ -696,7 +691,7 @@ bool Bvfs::ls_dirs()
*/
/* Then we get all the dir entries from File ... */
Mmsg(query,
// 0 1 2 3 4 5 6
// 0 1 2 3 4 5
"SELECT 'D', PathId, 0, Path, JobId, LStat, FileId FROM ( "
"SELECT Path1.PathId AS PathId, Path1.Path AS Path, "
"lower(Path1.Path) AS lpath, "
Expand All @@ -718,14 +713,13 @@ bool Bvfs::ls_dirs()
"LEFT JOIN ( " /* get attributes if any */
"SELECT File1.PathId AS PathId, File1.JobId AS JobId, "
"File1.LStat AS LStat, File1.FileId AS FileId FROM File AS File1 "
"WHERE File1.FilenameId = %s "
"WHERE File1.Name = '' "
"AND File1.JobId IN (%s)) AS listfile1 "
"ON (listpath1.PathId = listfile1.PathId) "
") AS A ORDER BY 2,3 DESC LIMIT %d OFFSET %d",
edit_uint64(pwd_id, ed1),
jobids,
filter.c_str(),
edit_uint64(dir_filenameid, ed2),
jobids,
limit, offset);

Expand Down Expand Up @@ -766,6 +760,11 @@ bool Bvfs::ls_files()
edit_uint64(pwd_id, pathid);
if (*pattern) {
db->fill_query(filter, B_DB::SQL_QUERY_match_query2, pattern);
#if 0
TODO: have to adapt this query!
Mmsg(filter, " AND File.Name %s '%s' ",
match_query[db_get_type_index(db)], pattern);
#endif
}

build_ls_files_query(jcr, db, query, jobids, pathid, filter.c_str(), limit, offset);
Expand Down Expand Up @@ -874,7 +873,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, char

if (*fileid) { /* Select files with their direct id */
init=true;
Mmsg(tmp,"SELECT Job.JobId, JobTDate, FileIndex, FilenameId, "
Mmsg(tmp,"SELECT Job.JobId, JobTDate, FileIndex, File.Name, "
"PathId, FileId "
"FROM File JOIN Job USING (JobId) WHERE FileId IN (%s)",
fileid);
Expand Down Expand Up @@ -917,7 +916,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, char
query.strcat(" UNION ");
}

Mmsg(tmp, "SELECT Job.JobId, JobTDate, File.FileIndex, File.FilenameId, "
Mmsg(tmp, "SELECT Job.JobId, JobTDate, File.FileIndex, File.Name, "
"File.PathId, FileId "
"FROM Path JOIN File USING (PathId) JOIN Job USING (JobId) "
"WHERE Path.Path LIKE '%s' AND File.JobId IN (%s) ",
Expand All @@ -929,7 +928,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, char

/* A directory can have files from a BaseJob */
Mmsg(tmp, "SELECT File.JobId, JobTDate, BaseFiles.FileIndex, "
"File.FilenameId, File.PathId, BaseFiles.FileId "
"File.Name, File.PathId, BaseFiles.FileId "
"FROM BaseFiles "
"JOIN File USING (FileId) "
"JOIN Job ON (BaseFiles.JobId = Job.JobId) "
Expand All @@ -955,7 +954,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, char
tmp.strcat(") UNION ");
query.strcat(tmp.c_str());
}
Mmsg(tmp, "SELECT Job.JobId, JobTDate, FileIndex, FilenameId, "
Mmsg(tmp, "SELECT Job.JobId, JobTDate, FileIndex, Name, "
"PathId, FileId "
"FROM File JOIN Job USING (JobId) WHERE JobId = %lld "
"AND FileIndex IN (%lld", jobid, id);
Expand Down
5 changes: 1 addition & 4 deletions src/cats/bvfs.h
Expand Up @@ -101,7 +101,7 @@ class Bvfs {
bool ls_files(); /* Returns true if we have more files to read */
bool ls_dirs(); /* Returns true if we have more dir to read */
void ls_special_dirs(); /* get . and .. */
void get_all_file_versions(DBId_t pathid, DBId_t fnid, const char *client);
void get_all_file_versions(DBId_t pathid, const char *fname, const char *client);

void update_cache();

Expand Down Expand Up @@ -163,15 +163,12 @@ class Bvfs {
uint32_t nb_record; /* number of records of the last query */
POOLMEM *pattern;
DBId_t pwd_id; /* Current pathid */
DBId_t dir_filenameid; /* special FilenameId where Name='' */
POOLMEM *prev_dir; /* ls_dirs query returns all versions, take the 1st one */
ATTR *attr; /* Can be use by handler to call decode_stat() */

bool see_all_versions;
bool see_copies;

DBId_t get_dir_filenameid();

DB_RESULT_HANDLER *list_entries;
void *user_data;
};
Expand Down
2 changes: 0 additions & 2 deletions src/cats/cats.h
Expand Up @@ -192,7 +192,6 @@ struct ATTR_DBR {
JobId_t JobId;
DBId_t ClientId;
DBId_t PathId;
DBId_t FilenameId;
FileId_t FileId;
char *Digest;
int DigestType;
Expand Down Expand Up @@ -223,7 +222,6 @@ struct FILE_DBR {
FileId_t FileId;
uint32_t FileIndex;
JobId_t JobId;
DBId_t FilenameId;
DBId_t PathId;
JobId_t MarkId;
uint32_t DeltaSeq;
Expand Down
14 changes: 2 additions & 12 deletions src/cats/ddl/creates/ingres.sql
Expand Up @@ -33,16 +33,6 @@

SET AUTOCOMMIT ON\g

CREATE SEQUENCE Filename_Seq;
CREATE TABLE Filename
(
FilenameId INTEGER NOT NULL DEFAULT Filename_Seq.nextval,
Name VARBYTE(32000) NOT NULL,
PRIMARY KEY (FilenameId)
);

CREATE UNIQUE INDEX (filename_name_idx ON filename (Name) WITH STRUCTURE=HASH,PAGE_SIZE=32768);

CREATE SEQUENCE Path_Seq;
CREATE TABLE path
(
Expand All @@ -60,15 +50,15 @@ CREATE TABLE file
FileIndex INTEGER NOT NULL DEFAULT 0,
JobId INTEGER NOT NULL,
PathId INTEGER NOT NULL,
FilenameId INTEGER NOT NULL,
Name VARBYTE(32000) NOT NULL,
DeltaSeq INTEGER NOT NULL DEFAULT 0,
MarkId INTEGER NOT NULL DEFAULT 0,
LStat VARBYTE(255) NOT NULL,
Md5 VARBYTE(255) NOT NULL,
PRIMARY KEY (fileid)
);

CREATE INDEX file_jpfid_idx ON File (jobid, pathid, filenameid);
CREATE INDEX file_jpfid_idx ON File (jobid, pathid, name);

-- If you need performances, you can remove this index
-- the database engine is able to use the composite index
Expand Down

0 comments on commit 513280b

Please sign in to comment.