>>>>> On Tue, 11 May 2010 17:10:37 +0200, Eric Bollengier said:
>
> Hello Martin,
>
> > - db_add_digest_to_file_record and db_mark_file_record were very slow
> > because the query optimizer failed to use the file_pkey index due to
> > datatype mismatch. I hacked around that but the patch is not clean.
>
> Can you be more specific for this issue ? The code looks to use integer and
> no
> quotes around FileId, it should work.
I think it was a limitation of older PostgreSQL servers, but I don't know
which versions exactly. The problem is that integer literals are of type int,
which doesn't match the type of the fileid column (bigserial, aka bigint).
My hack was to add ::bigint to the end of the fileid literals in these
functions.
--- orig/bacula-5.0.1/src/cats/sql_update.c 2010-02-24 15:33:48.000000000
+0000
+++ ../bacula-5.0.1/src/cats/sql_update.c 2010-04-11 17:30:08.000000000
+0100
@@ -56,6 +56,15 @@
*
* -----------------------------------------------------------------------
*/
+static char *edit_fileid(FileId_t FileId, char *buf)
+{
+ edit_int64(FileId, buf);
+#ifdef HAVE_POSTGRESQL
+ bstrncat(buf, "::bigint", 50);
+#endif
+ return buf;
+}
+
/* Update the attributes record by adding the file digest */
int
db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char
*digest,
@@ -66,7 +75,7 @@
db_lock(mdb);
Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", digest,
- edit_int64(FileId, ed1));
+ edit_fileid(FileId, ed1));
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return stat;
@@ -82,7 +91,7 @@
db_lock(mdb);
Mmsg(mdb->cmd, "UPDATE File SET MarkId=%s WHERE FileId=%s",
- edit_int64(JobId, ed1), edit_int64(FileId, ed2));
+ edit_int64(JobId, ed1), edit_fileid(FileId, ed2));
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return stat;
> AFAIK, the db_add_digest_to_file_record function is used only in non-batch
> mode session.
I don't know when db_add_digest_to_file_record is used, but I found the
problem when doing a verify, which uses db_mark_file_record.
__Martin
------------------------------------------------------------------------------
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel