Skip to content

Commit

Permalink
sqlqueries: fix core/src/cats/dml/create_queryfiles.sh
Browse files Browse the repository at this point in the history
The name of the BareosDB class was changed but the query create
script was not adapted to that fact.

This is now fixed and the queries were created anew.

Also changed GetQuotaJobbytes and GetQuotaJobbytesNofailed back
to the old name because that is the same name as the query file has.
  • Loading branch information
pstorz committed Sep 18, 2018
1 parent a24b842 commit bc0f734
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions core/src/cats/bdb_query_names.inc
Expand Up @@ -59,8 +59,8 @@ const char *BareosDb::query_names[] = {
"insert_counter_values",
"select_counter_values",
"update_counter_values",
"GetQuotaJobbytes",
"GetQuotaJobbytesNofailed",
"get_quota_jobbytes",
"get_quota_jobbytes_nofailed",
"uar_sel_jobid_copies",
"get_jobstatus_details",
"bvfs_versions_6",
Expand Down
4 changes: 2 additions & 2 deletions core/src/cats/cats.h
Expand Up @@ -713,8 +713,8 @@ class CATS_IMP_EXP BareosDb: public SmartAlloc, public BareosDbQueryEnum {
bool AccurateGetJobids(JobControlRecord *jcr, JobDbRecord *jr, db_list_ctx *jobids);
bool GetUsedBaseJobids(JobControlRecord *jcr, POOLMEM *jobids, db_list_ctx *result);
bool GetQuotaRecord(JobControlRecord *jcr, ClientDbRecord *cr);
bool GetQuotaJobbytes(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention);
bool GetQuotaJobbytesNofailed(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention);
bool get_quota_jobbytes(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention);
bool get_quota_jobbytes_nofailed(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention);
int GetNdmpLevelMapping(JobControlRecord *jcr, JobDbRecord *jr, char *filesystem);
bool GetNdmpEnvironmentString(JobControlRecord *jcr, JobDbRecord *jr, DB_RESULT_HANDLER *ResultHandler, void *ctx);
bool GetNdmpEnvironmentString(JobControlRecord *jcr, JobId_t JobId, DB_RESULT_HANDLER *ResultHandler, void *ctx);
Expand Down
4 changes: 2 additions & 2 deletions core/src/cats/dml/create_queryfiles.sh
Expand Up @@ -54,11 +54,11 @@ EOF


for db in $DATABASES; do
DB=`upper $db`
DB=${db^}
queryincludefile=`get_query_include_filename $db`
> $queryincludefile
printf "%s\n\n" "$NOTE" >> $queryincludefile
printf "const char *B_DB_%s::query_definitions[] = {\n" "$DB" >> $queryincludefile
printf "const char *BareosDb%s::query_definitions[] = {\n" "$DB" >> $queryincludefile
done

#
Expand Down
10 changes: 4 additions & 6 deletions core/src/cats/mysql_queries.inc
Expand Up @@ -873,13 +873,11 @@ const char *BareosDbMysql::query_definitions[] = {
"WHERE Log.JobId=%s "
,

/* 0072_get_orphaned_paths_0 */
"SELECT DISTINCT Path.PathId, File.PathId, Path.Path "
"FROM Path "
"LEFT JOIN File USING (PathId) "
"LEFT JOIN PathHierarchy ON (Path.Pathid = PathHierarchy.PPathId) "
/* 0072_get_orphaned_paths_0.mysql */
"SELECT DISTINCT ParentPath.PathId,File.PathId,ParentPath.Path "
"FROM Path AS ParentPath LEFT OUTER JOIN File USING(PathId) "
"WHERE File.PathId IS NULL "
"AND PathHierarchy.PPathId IS NULL "
"AND NOT EXISTS (SELECT 1 FROM Path WHERE Path LIKE CONCAT(ParentPath.Path,'_%%')) "
"LIMIT 300000 "
,

Expand Down
4 changes: 2 additions & 2 deletions core/src/cats/sql_get.cc
Expand Up @@ -1451,7 +1451,7 @@ bool BareosDb::GetVolumeJobids(JobControlRecord *jcr, MediaDbRecord *mr, db_list
* Returns false: on failure
* true: on success
*/
bool BareosDb::GetQuotaJobbytes(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention)
bool BareosDb::get_quota_jobbytes(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention)
{
SQL_ROW row;
int num_rows;
Expand Down Expand Up @@ -1503,7 +1503,7 @@ bool BareosDb::GetQuotaJobbytes(JobControlRecord *jcr, JobDbRecord *jr, utime_t
* Returns false: on failure
* true: on success
*/
bool BareosDb::GetQuotaJobbytesNofailed(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention)
bool BareosDb::get_quota_jobbytes_nofailed(JobControlRecord *jcr, JobDbRecord *jr, utime_t JobRetention)
{
SQL_ROW row;
char ed1[50], ed2[50];
Expand Down
8 changes: 4 additions & 4 deletions core/src/dird/quota.cc
Expand Up @@ -115,12 +115,12 @@ bool CheckHardquotas(JobControlRecord *jcr)
Dmsg1(debuglevel, "Checking hard quotas for JobId %d\n", jcr->JobId);
if (!jcr->HasQuota) {
if (jcr->res.client->QuotaIncludeFailedJobs) {
if (!jcr->db->GetQuotaJobbytes(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
if (!jcr->db->get_quota_jobbytes(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror());
goto bail_out;
}
} else {
if (!jcr->db->GetQuotaJobbytesNofailed(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
if (!jcr->db->get_quota_jobbytes_nofailed(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror());
goto bail_out;
}
Expand Down Expand Up @@ -168,13 +168,13 @@ bool CheckSoftquotas(JobControlRecord *jcr)
Dmsg1(debuglevel, "Checking soft quotas for JobId %d\n", jcr->JobId);
if (!jcr->HasQuota) {
if (jcr->res.client->QuotaIncludeFailedJobs) {
if (!jcr->db->GetQuotaJobbytes(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
if (!jcr->db->get_quota_jobbytes(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror());
goto bail_out;
}
Dmsg0(debuglevel, "Quota Includes Failed Jobs\n");
} else {
if (!jcr->db->GetQuotaJobbytesNofailed(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
if (!jcr->db->get_quota_jobbytes_nofailed(jcr, &jcr->jr, jcr->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror());
goto bail_out;
}
Expand Down

0 comments on commit bc0f734

Please sign in to comment.