int count;
db_lock(mdb);
+#ifdef not_used_in_new_code
Mmsg(&mdb->cmd, "SELECT JobId, MediaId FROM JobMedia WHERE \
JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId);
}
sql_free_result(mdb);
}
+#endif
/* Now get count for VolIndex */
Mmsg(&mdb->cmd, "SELECT count(*) from JobMedia");
}
+/*
+ * Create a Unique record for the counter -- no duplicates
+ * Returns: 0 on failure
+ * 1 on success with counter filled in
+ */
+int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
+{
+ COUNTER_DBR mcr;
+ int stat;
+
+ db_lock(mdb);
+ memset(&mcr, 0, sizeof(mcr));
+ bstrncpy(mcr.Counter, cr->Counter, sizeof(mcr.Counter));
+ if (db_get_counter_record(jcr, mdb, &mcr)) {
+ memcpy(cr, &mcr, sizeof(COUNTER_DBR));
+ db_unlock(mdb);
+ return 1;
+ }
+
+ /* Must create it */
+ Mmsg(&mdb->cmd, "INSERT INTO Counters (Counter,MinValue,MaxValue,CurrentValue,"
+ "WrapCounter) VALUES ('%s','%d','%d','%d','%s')",
+ cr->Counter, cr->MinValue, cr->MaxValue, cr->CurrentValue,
+ cr->WrapCounter);
+
+ if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
+ Mmsg2(&mdb->errmsg, _("Create DB Counters record %s failed. ERR=%s\n"),
+ mdb->cmd, sql_strerror(mdb));
+ Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+ stat = 0;
+ } else {
+ stat = 1;
+ }
+ db_unlock(mdb);
+ return stat;
+}
+
+
/*
* Create a FileSet record. This record is unique in the
* name and the MD5 signature of the include/exclude sets.
/*
* Make sure we have an acceptable attributes record.
*/
- if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES || ar->Stream == STREAM_WIN32_ATTRIBUTES)) {
+ if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES ||
+ ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) {
Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n"));
Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
return 0;
/* Must create it */
Mmsg(&mdb->cmd,
-"INSERT INTO File (FileIndex, JobId, PathId, FilenameId, \
-LStat, MD5) VALUES (%u, %u, %u, %u, '%s', '0')",
+"INSERT INTO File (FileIndex,JobId,PathId,FilenameId,"
+"LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')",
ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId,
ar->attr);
sql_free_result(mdb);
}
- Mmsg(&mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name);
+ Mmsg(&mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name);
if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"),