Skip to content

Commit

Permalink
core cats: Add IF EXISTS in drop table statements
Browse files Browse the repository at this point in the history
- Using if exists avoid return of fatal error from database
  Allow the use of parameter ExitOnFatal = true on normal workflow
- Fixes #1409: DB error on restore with ExitOnFatal=true

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
  • Loading branch information
bruno-at-bareos authored and pstorz committed Jan 13, 2022
1 parent 37d2fca commit aa1d472
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/src/cats/dml/0018_uar_del_temp
@@ -1 +1 @@
DROP TABLE temp
DROP TABLE IF EXISTS temp
2 changes: 1 addition & 1 deletion core/src/cats/dml/0019_uar_del_temp1
@@ -1 +1 @@
DROP TABLE temp1
DROP TABLE IF EXISTS temp1
4 changes: 2 additions & 2 deletions core/src/cats/mysql_queries.inc
Expand Up @@ -214,11 +214,11 @@ const char *BareosDbMysql::query_definitions[] = {
,

/* 0018_uar_del_temp */
"DROP TABLE temp "
"DROP TABLE IF EXISTS temp "
,

/* 0019_uar_del_temp1 */
"DROP TABLE temp1 "
"DROP TABLE IF EXISTS temp1 "
,

/* 0020_uar_last_full */
Expand Down
4 changes: 2 additions & 2 deletions core/src/cats/postgresql_queries.inc
Expand Up @@ -211,11 +211,11 @@ const char *BareosDbPostgresql::query_definitions[] = {
,

/* 0018_uar_del_temp */
"DROP TABLE temp "
"DROP TABLE IF EXISTS temp "
,

/* 0019_uar_del_temp1 */
"DROP TABLE temp1 "
"DROP TABLE IF EXISTS temp1 "
,

/* 0020_uar_last_full */
Expand Down
4 changes: 2 additions & 2 deletions core/src/cats/sqlite_queries.inc
Expand Up @@ -214,11 +214,11 @@ const char *BareosDbSqlite::query_definitions[] = {
,

/* 0018_uar_del_temp */
"DROP TABLE temp "
"DROP TABLE IF EXISTS temp "
,

/* 0019_uar_del_temp1 */
"DROP TABLE temp1 "
"DROP TABLE IF EXISTS temp1 "
,

/* 0020_uar_last_full */
Expand Down
8 changes: 4 additions & 4 deletions core/src/dird/query.sql
Expand Up @@ -90,8 +90,8 @@ SELECT DISTINCT Job.JobId,VolumeName
# 8
:List Volumes to Restore All Files
*Enter Client Name:
!DROP TABLE temp;
!DROP TABLE temp2;
!DROP TABLE IF EXISTS temp;
!DROP TABLE IF EXISTS temp2;
CREATE TABLE temp (JobId BIGINT NOT NULL,
JobTDate BIGINT,
ClientId BIGINT,
Expand Down Expand Up @@ -135,8 +135,8 @@ INSERT INTO temp2 SELECT DISTINCT Job.JobId,Job.StartTime,Media.VolumeName,
AND JobMedia.MediaId=Media.MediaId;
# list results
SELECT DISTINCT VolumeName from temp2;
!DROP TABLE temp;
!DROP TABLE temp2;
!DROP TABLE IF EXISTS temp;
!DROP TABLE IF EXISTS temp2;

# 9
:List Pool Attributes for a selected Pool
Expand Down

0 comments on commit aa1d472

Please sign in to comment.