From: Marco van Wieringen Date: Mon, 5 Apr 2010 08:35:23 +0000 (+0200) Subject: First version of Ingres Batch Insert code. X-Git-Tag: Release-5.0.2~105 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=65e9ccf4e2ede3aed10c5f769e3f86544143a8d2;p=bacula%2Fbacula First version of Ingres Batch Insert code. --- diff --git a/bacula/src/cats/ingres.c b/bacula/src/cats/ingres.c index 1d307167a3..3f82cc32c2 100755 --- a/bacula/src/cats/ingres.c +++ b/bacula/src/cats/ingres.c @@ -656,26 +656,56 @@ bail_out: } #ifdef HAVE_BATCH_FILE_INSERT - int my_ingres_batch_start(JCR *jcr, B_DB *mdb) { - //TODO! - return ING_ERROR; + bool ok; + + db_lock(mdb); + ok = db_sql_query(mdb, + "DECLARE GLOBAL TEMPORARY TABLE batch (" + "FileIndex integer," + "JobId integer," + "Path varchar(256)," + "Name varchar(256)," + "LStat varchar(256)," + "MD5 varchar(256))" + " ON COMMIT PRESERVE ROWS WITH NORECOVERY",NULL, NULL); + db_unlock(mdb); + return ok; } -/* set error to something to abort operation */ int my_ingres_batch_end(JCR *jcr, B_DB *mdb, const char *error) { - //TODO! - return ING_ERROR; + if (mdb) { + mdb->status = 0; + } + return true; } int my_ingres_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) { - //TODO! - return ING_ERROR; -} + size_t len; + const char *digest; + char ed1[50]; + mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1); + db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl); + + mdb->esc_path = check_pool_memory_size(mdb->esc_path, mdb->pnl*2+1); + db_escape_string(jcr, mdb, mdb->esc_path, mdb->path, mdb->pnl); + + if (ar->Digest == NULL || ar->Digest[0] == 0) { + digest = "0"; + } else { + digest = ar->Digest; + } + + len = Mmsg(mdb->cmd, "INSERT INTO batch VALUES (%u,%s,'%s','%s','%s','%s')", + ar->FileIndex, edit_int64(ar->JobId,ed1), mdb->esc_path, + mdb->esc_name, ar->attr, digest); + + return INSERT_DB(jcr, mdb, mdb->cmd); +} #endif /* HAVE_BATCH_FILE_INSERT */ /*