Skip to content

Commit

Permalink
Post-merge fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Apr 11, 2017
1 parent 513280b commit 85b2a69
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 51 deletions.
33 changes: 7 additions & 26 deletions src/cats/bvfs.c
Expand Up @@ -423,7 +423,7 @@ Bvfs::Bvfs(JCR *j, B_DB *mdb) {
prev_dir = get_pool_memory(PM_NAME);
pattern = get_pool_memory(PM_NAME);
*jobids = *prev_dir = *pattern = 0;
dir_filenameid = pwd_id = offset = 0;
pwd_id = offset = 0;
see_copies = see_all_versions = false;
limit = 1000;
attr = new_attr(jcr);
Expand Down Expand Up @@ -513,24 +513,6 @@ char *bvfs_basename_dir(char *path)
return p;
}

/**
* Find an store the filename descriptor for empty directories Filename.Name=''
*/
DBId_t Bvfs::get_dir_filenameid()
{
uint32_t id;
POOL_MEM query(PM_MESSAGE);

if (dir_filenameid) {
return dir_filenameid;
}

Mmsg(query, "SELECT FilenameId FROM Filename WHERE Name = ''");
db->sql_query(query.c_str(), db_int_handler, &id);
dir_filenameid = id;

return dir_filenameid;
}

/**
* Update the bvfs cache for current jobids
Expand All @@ -556,13 +538,12 @@ bool Bvfs::ch_dir(const char *path)
*/
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];
char ed1[50];
POOL_MEM query(PM_MESSAGE);
POOL_MEM filter(PM_MESSAGE);

Dmsg3(dbglevel, "get_all_file_versions(%lld, %lld, %s)\n", (uint64_t)pathid, (uint64_t)fnid, client);
Dmsg3(dbglevel, "get_all_file_versions(%lld, %s, %s)\n",
(uint64_t)pathid, fname, client);

if (see_copies) {
Mmsg(filter, " AND Job.Type IN ('C', 'B') ");
Expand All @@ -587,7 +568,7 @@ void Bvfs::get_all_file_versions(DBId_t pathid, const char *fname, const char *c
"AND Job.ClientId = Client.ClientId "
"AND Client.Name = '%s' "
"%s ORDER BY FileId LIMIT %d OFFSET %d"
,fname, edit_uint64(pathid, ed2), client, q.c_str(),
,fname, edit_uint64(pathid, ed1), client, query.c_str(),
limit, offset);

Dmsg1(dbglevel_sql, "query=%s\n", query.c_str());
Expand Down Expand Up @@ -625,7 +606,7 @@ int Bvfs::_handle_path(void *ctx, int fields, char **row)
*/
void Bvfs::ls_special_dirs()
{
char ed1[50], ed2[50];
char ed1[50];
POOL_MEM query(PM_MESSAGE);
POOL_MEM query2(PM_MESSAGE);

Expand Down Expand Up @@ -664,7 +645,7 @@ void Bvfs::ls_special_dirs()
/* Returns true if we have dirs to read */
bool Bvfs::ls_dirs()
{
char ed1[50], ed2[50];
char ed1[50];
POOL_MEM filter(PM_MESSAGE);
POOL_MEM query(PM_MESSAGE);

Expand Down
11 changes: 6 additions & 5 deletions src/cats/sql_create.c
Expand Up @@ -864,6 +864,7 @@ bool B_DB::write_batch_file_records(JCR *jcr)
Jmsg1(jcr, M_FATAL, 0, "Lock Filename table %s\n", jcr->db_batch->errmsg);
>>>>>>> bareos-16.2-db2170
goto bail_out;
*/
}
#endif

Expand Down Expand Up @@ -967,7 +968,7 @@ bool B_DB::create_file_attributes_record(JCR *jcr, ATTR_DBR *ar)

split_path_and_file(jcr, ar->fname);

if (!db_create_path_record(jcr, mdb, ar)) {
if (!create_path_record(jcr, ar)) {
goto bail_out;
}
Dmsg1(dbglevel, "create_path_record: %s\n", esc_name);
Expand All @@ -978,7 +979,7 @@ bool B_DB::create_file_attributes_record(JCR *jcr, ATTR_DBR *ar)
}
Dmsg0(dbglevel, "create_file_record OK\n");

Dmsg2(dbglevel, "CreateAttributes Path=%s File=%s\n", mdb->path, mdb->fname);
Dmsg2(dbglevel, "CreateAttributes Path=%s File=%s\n", path, fname);
retval = true;

bail_out:
Expand All @@ -1001,8 +1002,8 @@ bool B_DB::create_file_record(JCR *jcr, ATTR_DBR *ar)
ASSERT(ar->JobId);
ASSERT(ar->PathId);

mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
esc_name = check_pool_memory_size(esc_name, 2*fnl+2);
escape_string(jcr, esc_name, fname, fnl);

if (ar->Digest == NULL || ar->Digest[0] == 0) {
digest = no_digest;
Expand All @@ -1014,7 +1015,7 @@ bool B_DB::create_file_record(JCR *jcr, ATTR_DBR *ar)
Mmsg(cmd,
"INSERT INTO File (FileIndex,JobId,PathId,Name,"
"LStat,MD5,DeltaSeq) VALUES (%u,%u,%u,'%s','%s','%s',%u)",
ar->FileIndex, ar->JobId, ar->PathId, mdb->esc_name,
ar->FileIndex, ar->JobId, ar->PathId, esc_name,
ar->attr, digest, ar->DeltaSeq);

ar->FileId = sql_insert_autokey_record(cmd, NT_("File"));
Expand Down
38 changes: 21 additions & 17 deletions src/cats/sql_get.c
Expand Up @@ -56,14 +56,18 @@
*/
bool B_DB::get_file_attributes_record(JCR *jcr, char *filename, JOB_DBR *jr, FILE_DBR *fdbr)
{
bool retval;
Dmsg1(100, "get_file_attributes_record fname=%s \n", fname);
fdbr->FilenameId = get_filename_record(jcr);
bool retval;
Dmsg1(100, "db_get_file_attributes_record fname=%s \n", fname);

db_lock(this);

split_path_and_file(jcr, fname);
fdbr->PathId = get_path_record(jcr);
retval = get_file_record(jcr, jr, fdbr);


db_unlock(this);
return retval;

}

/**
Expand Down Expand Up @@ -96,8 +100,8 @@ bool B_DB::get_file_record(JCR *jcr, JOB_DBR *jr, FILE_DBR *fdbr)
char ed1[50], ed2[50], ed3[50];
int num_rows;

mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
esc_name = check_pool_memory_size(esc_name, 2*fnl+2);
escape_string(jcr, esc_name, fname, fnl);

if (jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG) {
Mmsg(cmd,
Expand All @@ -106,26 +110,26 @@ bool B_DB::get_file_record(JCR *jcr, JOB_DBR *jr, FILE_DBR *fdbr)
"File.Name='%s' AND Job.Type='B' AND Job.JobStatus IN ('T','W') AND "
"ClientId=%s ORDER BY StartTime DESC LIMIT 1",
edit_int64(fdbr->PathId, ed1),
mdb->esc_name,
esc_name,
edit_int64(jr->ClientId,ed3));
} else if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
Mmsg(cmd,
"SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%s AND File.PathId=%s AND "
"File.Name='%s' AND File.FileIndex=%u",
edit_int64(fdbr->JobId, ed1),
edit_int64(fdbr->PathId, ed2),
mdb->esc_name,
esc_name,
jr->FileIndex);
} else {
Mmsg(cmd,
"SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%s AND File.PathId=%s AND "
"File.Name='%s'",
edit_int64(fdbr->JobId, ed1),
edit_int64(fdbr->PathId, ed2),
mdb->esc_name);
esc_name);
}
Dmsg3(450, "Get_file_record JobId=%u Filename=%s PathId=%u\n",
fdbr->JobId, mdb->esc_name, fdbr->PathId);
fdbr->JobId, esc_name, fdbr->PathId);

Dmsg1(100, "Query=%s\n", cmd);

Expand All @@ -144,14 +148,14 @@ bool B_DB::get_file_record(JCR *jcr, JOB_DBR *jr, FILE_DBR *fdbr)
Mmsg3(errmsg, _("get_file_record want 1 got rows=%d PathId=%s FilenameId=%s\n"),
num_rows,
edit_int64(fdbr->PathId, ed1),
mdb->esc_name);
Dmsg1(000, "=== Problem! %s", mdb->errmsg);
esc_name);
Dmsg1(000, "=== Problem! %s", errmsg);
}
}
} else {
Mmsg2(mdb->errmsg, _("File record for PathId=%s Filename=%s not found.\n"),
Mmsg2(errmsg, _("File record for PathId=%s Filename=%s not found.\n"),
edit_int64(fdbr->PathId, ed1),
mdb->esc_name);
esc_name);
}
sql_free_result();
} else {
Expand All @@ -168,7 +172,7 @@ bool B_DB::get_file_record(JCR *jcr, JOB_DBR *jr, FILE_DBR *fdbr)
*
* DO NOT use Jmsg in this routine (see notes for get_file_record)
*/
int db_get_path_record(JCR *jcr, B_DB *mdb)
int B_DB::get_path_record(JCR *jcr)
{
SQL_ROW row;
DBId_t PathId = 0;
Expand Down Expand Up @@ -909,7 +913,7 @@ int B_DB::get_num_media_records(JCR *jcr)
}

/**
* This function creates a sql query string at mdb->cmd to return a list of all the Media records for
* This function creates a sql query string at cmd to return a list of all the Media records for
* the current Pool, the correct Media Type, Recyle, Enabled, StorageId, VolBytes and
* volumes or VolumeName if specified. Comma separated list of volumes takes precedence
* over VolumeName. The caller must free ids if non-NULL.
Expand Down Expand Up @@ -1669,7 +1673,7 @@ bool B_DB::get_ndmp_environment_string(JCR *jcr, JOB_DBR *jr, DB_RESULT_HANDLER
}

/**
* This function creates a sql query string at mdb->cmd to return a list of all the Media records for
* This function creates a sql query string at cmd to return a list of all the Media records for
* the current Pool, the correct Media Type, Recyle, Enabled, StorageId, VolBytes and
* volumes or VolumeName if specified. Comma separated list of volumes takes precedence
* over VolumeName. The caller must free ids if non-NULL.
Expand Down
4 changes: 2 additions & 2 deletions src/dird/ndmp_dma_restore.c
Expand Up @@ -661,8 +661,8 @@ static inline bool do_ndmp_restore_bootstrap(JCR *jcr)
bool next_fi = true;
int first_fi = jcr->bsr->FileIndex->findex;
int last_fi = jcr->bsr->FileIndex->findex2;
int current_sessionid = jcr->bsr->sessid->sessid;
int current_sessiontime = jcr->bsr->sesstime->sesstime;
uint32_t current_sessionid = jcr->bsr->sessid->sessid;
uint32_t current_sessiontime = jcr->bsr->sesstime->sesstime;
cnt = 0;

for (bsr = jcr->bsr; bsr; bsr = bsr->next) {
Expand Down
2 changes: 1 addition & 1 deletion src/dird/verify.c
Expand Up @@ -881,7 +881,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
"AND File.MarkId!=%d AND File.PathId=Path.PathId ",
JobId, jcr->JobId);
/* missing_handler is called for each file found */
db_sql_query(jcr->db, buf.c_str(), missing_handler, (void *)jcr);
jcr->db->sql_query(buf.c_str(), missing_handler, (void *)jcr);
if (jcr->fn_printed) {
jcr->setJobStatus(JS_Differences);
}
Expand Down

0 comments on commit 85b2a69

Please sign in to comment.