diff --git a/core/src/cats/bdb_dbi.h b/core/src/cats/bdb_dbi.h index 22e8532476e..3826d6a115e 100644 --- a/core/src/cats/bdb_dbi.h +++ b/core/src/cats/bdb_dbi.h @@ -70,9 +70,9 @@ class BareosDbDBI : public BareosDbPrivateInterface { SQL_FIELD* SqlFetchField(void); bool SqlFieldIsNotNull(int field_type); bool SqlFieldIsNumeric(int field_type); - bool SqlBatchStart(JobControlRecord* jcr); - bool SqlBatchEnd(JobControlRecord* jcr, const char* error); - bool SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar); + bool SqlBatchStartFileTable(JobControlRecord* jcr); + bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error); + bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar); public: /* diff --git a/core/src/cats/bdb_mysql.h b/core/src/cats/bdb_mysql.h index 941370ffba2..74f3997de3c 100644 --- a/core/src/cats/bdb_mysql.h +++ b/core/src/cats/bdb_mysql.h @@ -75,9 +75,9 @@ class BareosDbMysql : public BareosDbPrivateInterface { SQL_FIELD* SqlFetchField(void) override; bool SqlFieldIsNotNull(int field_type) override; bool SqlFieldIsNumeric(int field_type) override; - bool SqlBatchStart(JobControlRecord* jcr) override; - bool SqlBatchEnd(JobControlRecord* jcr, const char* error) override; - bool SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) override; + bool SqlBatchStartFileTable(JobControlRecord* jcr) override; + bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) override; + bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) override; public: /* diff --git a/core/src/cats/bdb_postgresql.h b/core/src/cats/bdb_postgresql.h index 655fdafe4ce..139a4e330b4 100644 --- a/core/src/cats/bdb_postgresql.h +++ b/core/src/cats/bdb_postgresql.h @@ -74,9 +74,9 @@ class BareosDbPostgresql : public BareosDbPrivateInterface { SQL_FIELD* SqlFetchField(void) override; bool SqlFieldIsNotNull(int field_type) override; bool SqlFieldIsNumeric(int field_type) override; - bool SqlBatchStart(JobControlRecord* jcr) override; - bool SqlBatchEnd(JobControlRecord* jcr, const char* error) override; - bool SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) override; + bool SqlBatchStartFileTable(JobControlRecord* jcr) override; + bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) override; + bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) override; bool CheckDatabaseEncoding(JobControlRecord* jcr); diff --git a/core/src/cats/bdb_priv.h b/core/src/cats/bdb_priv.h index e37f768a649..91010de2541 100644 --- a/core/src/cats/bdb_priv.h +++ b/core/src/cats/bdb_priv.h @@ -64,10 +64,10 @@ class BareosDbPrivateInterface : public BareosDb { virtual SQL_FIELD* SqlFetchField(void) override = 0; virtual bool SqlFieldIsNotNull(int field_type) override = 0; virtual bool SqlFieldIsNumeric(int field_type) override = 0; - virtual bool SqlBatchStart(JobControlRecord* jcr) override = 0; - virtual bool SqlBatchEnd(JobControlRecord* jcr, + virtual bool SqlBatchStartFileTable(JobControlRecord* jcr) override = 0; + virtual bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) override = 0; - virtual bool SqlBatchInsert(JobControlRecord* jcr, + virtual bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) override = 0; public: diff --git a/core/src/cats/bdb_sqlite.h b/core/src/cats/bdb_sqlite.h index 15cf1a2e435..0474e3ac219 100644 --- a/core/src/cats/bdb_sqlite.h +++ b/core/src/cats/bdb_sqlite.h @@ -62,9 +62,9 @@ class BareosDbSqlite : public BareosDbPrivateInterface { SQL_FIELD* SqlFetchField(void) override; bool SqlFieldIsNotNull(int field_type) override; bool SqlFieldIsNumeric(int field_type) override; - bool SqlBatchStart(JobControlRecord* jcr) override; - bool SqlBatchEnd(JobControlRecord* jcr, const char* error) override; - bool SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) override; + bool SqlBatchStartFileTable(JobControlRecord* jcr) override; + bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) override; + bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) override; public: /* diff --git a/core/src/cats/cats.h b/core/src/cats/cats.h index c71d6c20689..26b23a2420c 100644 --- a/core/src/cats/cats.h +++ b/core/src/cats/cats.h @@ -1081,9 +1081,9 @@ class BareosDb : public BareosDbQueryEnum { virtual SQL_FIELD* SqlFetchField(void) = 0; virtual bool SqlFieldIsNotNull(int field_type) = 0; virtual bool SqlFieldIsNumeric(int field_type) = 0; - virtual bool SqlBatchStart(JobControlRecord* jcr) = 0; - virtual bool SqlBatchEnd(JobControlRecord* jcr, const char* error) = 0; - virtual bool SqlBatchInsert(JobControlRecord* jcr, + virtual bool SqlBatchStartFileTable(JobControlRecord* jcr) = 0; + virtual bool SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) = 0; + virtual bool SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) = 0; #endif }; diff --git a/core/src/cats/dbi.cc b/core/src/cats/dbi.cc index 925def10cb9..23d63693436 100644 --- a/core/src/cats/dbi.cc +++ b/core/src/cats/dbi.cc @@ -1144,12 +1144,12 @@ static char* postgresql_copy_escape(char* dest, char* src, size_t len) * Returns true if OK * false if failed */ -bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) +bool BareosDbDBI::SqlBatchStartFileTable(JobControlRecord* jcr) { bool retval = true; const char* query = "COPY batch FROM STDIN"; - Dmsg0(500, "SqlBatchStart started\n"); + Dmsg0(500, "SqlBatchStartFileTable started\n"); DbLock(this); switch (db_type_) { @@ -1162,10 +1162,10 @@ bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) "LStat tinyblob," "MD5 tinyblob," "DeltaSeq smallint)")) { - Dmsg0(500, "SqlBatchStart failed\n"); + Dmsg0(500, "SqlBatchStartFileTable failed\n"); goto bail_out; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); goto ok_out; case SQL_TYPE_POSTGRESQL: if (!SqlQueryWithoutHandler("CREATE TEMPORARY TABLE batch (" @@ -1176,7 +1176,7 @@ bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) "LStat varchar," "MD5 varchar," "DeltaSeq int)")) { - Dmsg0(500, "SqlBatchStart failed\n"); + Dmsg0(500, "SqlBatchStartFileTable failed\n"); goto bail_out; } @@ -1214,7 +1214,7 @@ bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) goto bail_out; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); goto ok_out; case SQL_TYPE_SQLITE3: if (!SqlQueryWithoutHandler("CREATE TEMPORARY TABLE batch (" @@ -1225,10 +1225,10 @@ bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) "LStat tinyblob," "MD5 tinyblob," "DeltaSeq smallint)")) { - Dmsg0(500, "SqlBatchStart failed\n"); + Dmsg0(500, "SqlBatchStartFileTable failed\n"); goto bail_out; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); goto ok_out; } @@ -1247,14 +1247,14 @@ bool BareosDbDBI::SqlBatchStart(JobControlRecord* jcr) /** * Set error to something to abort operation */ -bool BareosDbDBI::SqlBatchEnd(JobControlRecord* jcr, const char* error) +bool BareosDbDBI::SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) { int res = 0; int count = 30; int (*custom_function)(void*, const char*) = NULL; dbi_conn_t* myconn = (dbi_conn_t*)(db_handle_); - Dmsg0(500, "SqlBatchStart started\n"); + Dmsg0(500, "SqlBatchStartFileTable started\n"); switch (db_type_) { case SQL_TYPE_MYSQL: @@ -1285,7 +1285,7 @@ bool BareosDbDBI::SqlBatchEnd(JobControlRecord* jcr, const char* error) break; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); return true; } @@ -1295,7 +1295,7 @@ bool BareosDbDBI::SqlBatchEnd(JobControlRecord* jcr, const char* error) * In near future is better split in small functions * and refactory. */ -bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) +bool BareosDbDBI::SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) { int res; int count = 30; @@ -1306,7 +1306,7 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) char* digest; char ed1[50]; - Dmsg0(500, "SqlBatchStart started \n"); + Dmsg0(500, "SqlBatchStartFileTable started \n"); esc_name = CheckPoolMemorySize(esc_name, fnl * 2 + 1); esc_path = CheckPoolMemorySize(esc_path, pnl * 2 + 1); @@ -1328,11 +1328,11 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) ar->attr, digest, ar->DeltaSeq); if (!SqlQueryWithoutHandler(cmd)) { - Dmsg0(500, "SqlBatchStart failed\n"); + Dmsg0(500, "SqlBatchStartFileTable failed\n"); goto bail_out; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); return true; break; @@ -1347,7 +1347,7 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) * libdbi don't support CopyData and we need call a postgresql * specific function to do this work */ - Dmsg2(500, "SqlBatchInsert :\n %s \ncmd_size: %d", cmd, len); + Dmsg2(500, "SqlBatchInsertFileTable :\n %s \ncmd_size: %d", cmd, len); custom_function = (custom_function_insert_t)dbi_driver_specific_function( dbi_conn_get_driver(myconn), "PQputCopyData"); if (custom_function != NULL) { @@ -1362,11 +1362,11 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) } if (res <= 0) { - Dmsg0(500, "SqlBatchInsert failed\n"); + Dmsg0(500, "SqlBatchInsertFileTable failed\n"); goto bail_out; } - Dmsg0(500, "SqlBatchInsert finishing\n"); + Dmsg0(500, "SqlBatchInsertFileTable finishing\n"); return true; } else { /* @@ -1375,7 +1375,7 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) custom_function_error = (custom_function_error_t)dbi_driver_specific_function( dbi_conn_get_driver(myconn), "PQerrorMessage"); - Dmsg1(500, "SqlBatchInsert failed\n PQerrorMessage: %s", + Dmsg1(500, "SqlBatchInsertFileTable failed\n PQerrorMessage: %s", (*custom_function_error)(myconn->connection)); goto bail_out; } @@ -1390,11 +1390,11 @@ bool BareosDbDBI::SqlBatchInsert(JobControlRecord* jcr, AttributesDbRecord* ar) ar->attr, digest, ar->DeltaSeq); if (!SqlQueryWithoutHandler(cmd)) { - Dmsg0(500, "SqlBatchInsert failed\n"); + Dmsg0(500, "SqlBatchInsertFileTable failed\n"); goto bail_out; } - Dmsg0(500, "SqlBatchInsert finishing\n"); + Dmsg0(500, "SqlBatchInsertFileTable finishing\n"); return true; break; diff --git a/core/src/cats/mysql.cc b/core/src/cats/mysql.cc index 359fcf2ba8a..16985d6f8cb 100644 --- a/core/src/cats/mysql.cc +++ b/core/src/cats/mysql.cc @@ -691,7 +691,7 @@ bool BareosDbMysql::SqlFieldIsNumeric(int field_type) * Returns true if OK * false if failed */ -bool BareosDbMysql::SqlBatchStart(JobControlRecord* jcr) +bool BareosDbMysql::SqlBatchStartFileTable(JobControlRecord* jcr) { bool retval; @@ -722,7 +722,7 @@ bool BareosDbMysql::SqlBatchStart(JobControlRecord* jcr) * Returns true if OK * false if failed */ -bool BareosDbMysql::SqlBatchEnd(JobControlRecord* jcr, const char* error) +bool BareosDbMysql::SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) { status_ = 0; @@ -738,7 +738,7 @@ bool BareosDbMysql::SqlBatchEnd(JobControlRecord* jcr, const char* error) * Returns true if OK * false if failed */ -bool BareosDbMysql::SqlBatchInsert(JobControlRecord* jcr, +bool BareosDbMysql::SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) { const char* digest; diff --git a/core/src/cats/postgresql.cc b/core/src/cats/postgresql.cc index fdf57244adf..115dc40975c 100644 --- a/core/src/cats/postgresql.cc +++ b/core/src/cats/postgresql.cc @@ -1019,11 +1019,11 @@ static char* pgsql_copy_escape(char* dest, char* src, size_t len) return dest; } -bool BareosDbPostgresql::SqlBatchStart(JobControlRecord* jcr) +bool BareosDbPostgresql::SqlBatchStartFileTable(JobControlRecord* jcr) { const char* query = "COPY batch FROM STDIN"; - Dmsg0(500, "SqlBatchStart started\n"); + Dmsg0(500, "SqlBatchStartFileTable started\n"); if (!SqlQueryWithoutHandler("CREATE TEMPORARY TABLE batch (" "FileIndex int," @@ -1035,7 +1035,7 @@ bool BareosDbPostgresql::SqlBatchStart(JobControlRecord* jcr) "DeltaSeq smallint," "Fhinfo NUMERIC(20)," "Fhnode NUMERIC(20))")) { - Dmsg0(500, "SqlBatchStart failed\n"); + Dmsg0(500, "SqlBatchStartFileTable failed\n"); return false; } @@ -1071,7 +1071,7 @@ bool BareosDbPostgresql::SqlBatchStart(JobControlRecord* jcr) goto bail_out; } - Dmsg0(500, "SqlBatchStart finishing\n"); + Dmsg0(500, "SqlBatchStartFileTable finishing\n"); return true; @@ -1086,13 +1086,14 @@ bool BareosDbPostgresql::SqlBatchStart(JobControlRecord* jcr) /** * Set error to something to abort operation */ -bool BareosDbPostgresql::SqlBatchEnd(JobControlRecord* jcr, const char* error) +bool BareosDbPostgresql::SqlBatchEndFileTable(JobControlRecord* jcr, + const char* error) { int res; int count = 30; PGresult* pg_result; - Dmsg0(500, "SqlBatchEnd started\n"); + Dmsg0(500, "SqlBatchEndFileTable started\n"); do { res = PQputCopyEnd(db_handle_, error); @@ -1121,13 +1122,13 @@ bool BareosDbPostgresql::SqlBatchEnd(JobControlRecord* jcr, const char* error) PQclear(pg_result); - Dmsg0(500, "SqlBatchEnd finishing\n"); + Dmsg0(500, "SqlBatchEndFileTable finishing\n"); return true; } -bool BareosDbPostgresql::SqlBatchInsert(JobControlRecord* jcr, - AttributesDbRecord* ar) +bool BareosDbPostgresql::SqlBatchInsertFileTable(JobControlRecord* jcr, + AttributesDbRecord* ar) { int res; int count = 30; @@ -1170,7 +1171,7 @@ bool BareosDbPostgresql::SqlBatchInsert(JobControlRecord* jcr, Dmsg1(500, "failure %s\n", errmsg); } - Dmsg0(500, "SqlBatchInsert finishing\n"); + Dmsg0(500, "SqlBatchInsertFileTable finishing\n"); return true; } diff --git a/core/src/cats/sql_create.cc b/core/src/cats/sql_create.cc index 32aa4b38d0e..6faee928334 100644 --- a/core/src/cats/sql_create.cc +++ b/core/src/cats/sql_create.cc @@ -830,7 +830,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord* jcr) "Insert of attributes batch table with %u entries start\n", jcr->db_batch->changes); - if (!jcr->db_batch->SqlBatchEnd(jcr, NULL)) { + if (!jcr->db_batch->SqlBatchEndFileTable(jcr, NULL)) { Jmsg1(jcr, M_FATAL, 0, "Batch end %s\n", errmsg); goto bail_out; } @@ -911,7 +911,7 @@ bool BareosDb::CreateBatchFileAttributesRecord(JobControlRecord* jcr, */ if (!jcr->batch_started) { if (!OpenBatchConnection(jcr)) { return false; /* error already printed */ } - if (!jcr->db_batch->SqlBatchStart(jcr)) { + if (!jcr->db_batch->SqlBatchStartFileTable(jcr)) { Mmsg1(errmsg, "Can't start batch mode: ERR=%s", jcr->db_batch->strerror()); Jmsg(jcr, M_FATAL, 0, "%s", errmsg); @@ -922,7 +922,7 @@ bool BareosDb::CreateBatchFileAttributesRecord(JobControlRecord* jcr, jcr->db_batch->SplitPathAndFile(jcr, ar->fname); - return jcr->db_batch->SqlBatchInsert(jcr, ar); + return jcr->db_batch->SqlBatchInsertFileTable(jcr, ar); } /** diff --git a/core/src/cats/sqlite.cc b/core/src/cats/sqlite.cc index f3330fca6d9..e76616cc139 100644 --- a/core/src/cats/sqlite.cc +++ b/core/src/cats/sqlite.cc @@ -576,7 +576,7 @@ bool BareosDbSqlite::SqlFieldIsNumeric(int field_type) * Returns true if OK * false if failed */ -bool BareosDbSqlite::SqlBatchStart(JobControlRecord* jcr) +bool BareosDbSqlite::SqlBatchStartFileTable(JobControlRecord* jcr) { bool retval; @@ -603,7 +603,7 @@ bool BareosDbSqlite::SqlBatchStart(JobControlRecord* jcr) * Returns true if OK * false if failed */ -bool BareosDbSqlite::SqlBatchEnd(JobControlRecord* jcr, const char* error) +bool BareosDbSqlite::SqlBatchEndFileTable(JobControlRecord* jcr, const char* error) { status_ = 0; @@ -614,7 +614,7 @@ bool BareosDbSqlite::SqlBatchEnd(JobControlRecord* jcr, const char* error) * Returns true if OK * false if failed */ -bool BareosDbSqlite::SqlBatchInsert(JobControlRecord* jcr, +bool BareosDbSqlite::SqlBatchInsertFileTable(JobControlRecord* jcr, AttributesDbRecord* ar) { const char* digest;