#include "cats.h"
+#define dbglevel1 100
+#define dbglevel2 400
+
/* -----------------------------------------------------------------------
*
* Generic Routines (or almost generic)
bdb_escape_string(jcr, esc_name, digest, len);
Mmsg(cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", esc_name,
edit_int64(FileId, ed1));
- ret = UpdateDB(jcr, cmd);
+ ret = UpdateDB(jcr, cmd, false);
bdb_unlock();
return ret;
}
bdb_lock();
Mmsg(cmd, "UPDATE File SET MarkId=%s WHERE FileId=%s",
edit_int64(JobId, ed1), edit_int64(FileId, ed2));
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}
edit_int64(jr->FileSetId, ed4),
edit_int64(jr->JobId, ed5));
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
changes = 0;
bdb_unlock();
return stat;
rdt, PriorJobId, jr->HasBase, jr->PurgedFiles,
edit_int64(jr->JobId, ed3));
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
edit_uint64(cr->JobRetention, ed2),
esc_uname, esc_name);
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}
cr->MinValue, cr->MaxValue, cr->CurrentValue,
cr->WrapCounter, esc);
- int stat = UpdateDB(jcr, cmd);
+ int stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}
Mmsg(cmd, "SELECT count(*) from Media WHERE PoolId=%s",
edit_int64(pr->PoolId, ed4));
pr->NumVols = get_sql_record_max(jcr, this);
- Dmsg1(400, "NumVols=%d\n", pr->NumVols);
+ Dmsg1(dbglevel2, "NumVols=%d\n", pr->NumVols);
Mmsg(cmd,
"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d,"
edit_int64(pr->ScratchPoolId,ed6),
pr->ActionOnPurge,
ed4);
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}
Mmsg(cmd, "UPDATE Storage SET AutoChanger=%d WHERE StorageId=%s",
sr->AutoChanger, edit_int64(sr->StorageId, ed1));
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}
char esc_name[MAX_ESCAPE_NAME_LENGTH];
char esc_status[MAX_ESCAPE_NAME_LENGTH];
- Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
+ Dmsg1(dbglevel1, "update_media: FirstWritten=%d\n", mr->FirstWritten);
bdb_lock();
bdb_escape_string(jcr, esc_name, mr->VolumeName, strlen(mr->VolumeName));
bdb_escape_string(jcr, esc_status, mr->VolStatus, strlen(mr->VolStatus));
if (mr->set_first_written) {
- Dmsg1(400, "Set FirstWritten Vol=%s\n", mr->VolumeName);
+ Dmsg1(dbglevel2, "Set FirstWritten Vol=%s\n", mr->VolumeName);
ttime = mr->FirstWritten;
(void)localtime_r(&ttime, &tm);
strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
Mmsg(cmd, "UPDATE Media SET FirstWritten='%s'"
" WHERE VolumeName='%s'", dt, esc_name);
- stat = UpdateDB(jcr, cmd);
- Dmsg1(400, "Firstwritten=%d\n", mr->FirstWritten);
+ stat = UpdateDB(jcr, cmd, false);
+ Dmsg1(dbglevel2, "Firstwritten=%d\n", mr->FirstWritten);
}
/* Label just done? */
strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
Mmsg(cmd, "UPDATE Media SET LabelDate='%s' "
"WHERE VolumeName='%s'", dt, esc_name);
- UpdateDB(jcr, cmd);
+ UpdateDB(jcr, cmd, false);
}
if (mr->LastWritten != 0) {
strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
Mmsg(cmd, "UPDATE Media Set LastWritten='%s' "
"WHERE VolumeName='%s'", dt, esc_name);
- UpdateDB(jcr, cmd);
+ UpdateDB(jcr, cmd, false);
}
/* sanity checks for #1066 */
mr->RecycleCount,mr->Recycle, mr->ActionOnPurge,
esc_name);
- Dmsg1(400, "%s\n", cmd);
+ Dmsg1(dbglevel1, "%s\n", cmd);
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
/* Make sure InChanger is 0 for any record having the same Slot */
db_make_inchanger_unique(jcr, this, mr);
int stat;
char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
char esc[MAX_ESCAPE_NAME_LENGTH];
+ bool can_be_empty;
bdb_lock();
if (mr->VolumeName[0]) {
edit_uint64(mr->MaxVolBytes, ed3),
edit_uint64(mr->RecyclePoolId, ed4),
esc);
+ can_be_empty = false;
+
} else {
Mmsg(cmd, "UPDATE Media SET "
"ActionOnPurge=%d, Recycle=%d,VolRetention=%s,VolUseDuration=%s,"
edit_uint64(mr->MaxVolBytes, ed3),
edit_int64(mr->RecyclePoolId, ed4),
edit_int64(mr->PoolId, ed5));
+ can_be_empty = true;
}
- Dmsg1(400, "%s\n", cmd);
+ Dmsg1(dbglevel1, "%s\n", cmd);
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, can_be_empty);
bdb_unlock();
return stat;
mr->Slot,
edit_int64(mr->StorageId, ed1), mr->VolumeName);
}
- Dmsg1(100, "%s\n", cmd);
- UpdateDB(jcr, cmd);
+ Dmsg1(dbglevel1, "%s\n", cmd);
+ UpdateDB(jcr, cmd, true);
}
}
Mmsg(cmd, "UPDATE Snapshot SET Retention=%s, Comment='%s' WHERE SnapshotId=%s",
edit_int64(sr->Retention, ed2), sr->Comment, edit_int64(sr->SnapshotId, ed1));
- stat = UpdateDB(jcr, cmd);
+ stat = UpdateDB(jcr, cmd, false);
bdb_unlock();
return stat;
}