Skip to content

Commit

Permalink
Merge pull request #1042
Browse files Browse the repository at this point in the history
sql_get.cc: fix error logging in GetJobRecord() for jobname
  • Loading branch information
pstorz committed Jan 13, 2022
2 parents 35011e5 + 7809794 commit 402cd16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- debian: Let dbconfig create the Bareos catalog also with LC_COLLATE='C' and LC_CTYPE='C'. The create_bareos_database script did always do so. Requires dbconfig >= 2.0.21 [PR #1031]
- fix wrong `packages_dir` in restapi workflow, so restapi packages will be released to PyPI [PR #1033]
- core cats: Add IF EXISTS in drop table statements fix for bug #1409 (Allow usage of ExitOnFatal) [PR #1035]
- sql_get.cc: fix error logging in GetJobRecord() for jobname #1042

### Added
- tests: simplify test coverage analysis [PR #1010]
Expand Down
14 changes: 10 additions & 4 deletions core/src/cats/sql_get.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2021 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 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 @@ -242,9 +242,9 @@ bool BareosDb::GetJobRecord(JobControlRecord* jcr, JobDbRecord* jr)
SQL_ROW row;
char ed1[50];
char esc[MAX_ESCAPE_NAME_LENGTH];

bool search_by_jobname = (jr->JobId == 0);
DbLock(this);
if (jr->JobId == 0) {
if (search_by_jobname) {
EscapeString(jcr, esc, jr->Job, strlen(jr->Job));
Mmsg(cmd,
"SELECT VolSessionId,VolSessionTime,"
Expand All @@ -264,8 +264,14 @@ bool BareosDb::GetJobRecord(JobControlRecord* jcr, JobDbRecord* jr)
}

if (!QUERY_DB(jcr, cmd)) { goto bail_out; }

if ((row = SqlFetchRow()) == NULL) {
Mmsg1(errmsg, _("No Job found for JobId %s\n"), edit_int64(jr->JobId, ed1));
if (search_by_jobname) {
Mmsg1(errmsg, _("No Job found for JobName %s\n"), esc);
} else {
Mmsg1(errmsg, _("No Job found for JobId %s\n"),
edit_int64(jr->JobId, ed1));
}
SqlFreeResult();
goto bail_out;
}
Expand Down

0 comments on commit 402cd16

Please sign in to comment.