Skip to content

Commit

Permalink
Merge pull request #1721
Browse files Browse the repository at this point in the history
Fix warning about missing delcandidates table in director
  • Loading branch information
BareosBot committed Mar 20, 2024
2 parents 61febc7 + 800dec0 commit 5803427
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 28 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -179,6 +179,7 @@ Sam Verstraete
Samuel Börlin
Scott Bailey
Sebastian Lederer
Sebastian Marsching
Sebastian Sura
Serefhan Yeter
Sergey Svishchev
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix bareos_tasks plugin for pgsql [PR #1659]
- core: Fix compile errors on GCC 14 [PR #1687]
- stored: fix authentication race condition / deadlock [PR #1732]
- Fix warning about missing delcandidates table in director [PR #1721]

[PR #1538]: https://github.com/bareos/bareos/pull/1538
[PR #1581]: https://github.com/bareos/bareos/pull/1581
Expand Down Expand Up @@ -119,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[PR #1717]: https://github.com/bareos/bareos/pull/1717
[PR #1718]: https://github.com/bareos/bareos/pull/1718
[PR #1719]: https://github.com/bareos/bareos/pull/1719
[PR #1721]: https://github.com/bareos/bareos/pull/1721
[PR #1728]: https://github.com/bareos/bareos/pull/1728
[PR #1732]: https://github.com/bareos/bareos/pull/1732
[unreleased]: https://github.com/bareos/bareos/tree/master
3 changes: 1 addition & 2 deletions core/src/cats/cats.h
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
Copyright (C) 2013-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -952,7 +952,6 @@ class BareosDb : public BareosDbQueryEnum {
/* Pure virtual low level methods */
virtual bool OpenDatabase(JobControlRecord* jcr) = 0;
virtual void CloseDatabase(JobControlRecord* jcr) = 0;
virtual bool ValidateConnection(void) = 0;
virtual void StartTransaction(JobControlRecord* jcr) = 0;
virtual void EndTransaction(JobControlRecord* jcr) = 0;

Expand Down
26 changes: 3 additions & 23 deletions core/src/cats/postgresql.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
Copyright (C) 2013-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -238,6 +238,7 @@ bool BareosDbPostgresql::OpenDatabase(JobControlRecord* jcr)

SqlQueryWithoutHandler("SET datestyle TO 'ISO, YMD'");
SqlQueryWithoutHandler("SET cursor_tuple_fraction=1");
SqlQueryWithoutHandler("SET client_min_messages TO WARNING");

/* Tell PostgreSQL we are using standard conforming strings
* and avoid warnings such as:
Expand Down Expand Up @@ -288,28 +289,6 @@ void BareosDbPostgresql::CloseDatabase(JobControlRecord* jcr)
unlock_mutex(mutex);
}

bool BareosDbPostgresql::ValidateConnection(void)
{
// Perform a null query to see if the connection is still valid.
DbLocker _{this};
if (!SqlQueryWithoutHandler("SELECT 1", true)) {
// Try resetting the connection.
PQreset(db_handle_);
if (PQstatus(db_handle_) != CONNECTION_OK) { return false; }

SqlQueryWithoutHandler("SET datestyle TO 'ISO, YMD'");
SqlQueryWithoutHandler("SET cursor_tuple_fraction=1");
SqlQueryWithoutHandler("SET standard_conforming_strings=on");

// Retry the null query.
if (!SqlQueryWithoutHandler("SELECT 1", true)) { return false; }
}

SqlFreeResult();

return true;
}

/**
* Escape strings so that PostgreSQL is happy
*
Expand Down Expand Up @@ -630,6 +609,7 @@ bool BareosDbPostgresql::SqlQueryWithoutHandler(const char* query, int)
// Reset the connection settings.
PQexec(db_handle_, "SET datestyle TO 'ISO, YMD'");
PQexec(db_handle_, "SET cursor_tuple_fraction=1");
PQexec(db_handle_, "SET client_min_messages TO WARNING");
result_ = PQexec(db_handle_, "SET standard_conforming_strings=on");

switch (PQresultStatus(result_)) {
Expand Down
3 changes: 1 addition & 2 deletions core/src/cats/postgresql.h
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2009-2011 Free Software Foundation Europe e.V.
Copyright (C) 2016-2016 Planets Communications B.V.
Copyright (C) 2016-2023 Bareos GmbH & Co. KG
Copyright (C) 2016-2024 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -62,7 +62,6 @@ class BareosDbPostgresql : public BareosDb {
int SqlNumFields(void) override { return num_fields_; }
bool OpenDatabase(JobControlRecord* jcr) override;
void CloseDatabase(JobControlRecord* jcr) override;
bool ValidateConnection(void) override;
void EscapeString(JobControlRecord* jcr,
char* snew,
const char* old,
Expand Down
1 change: 0 additions & 1 deletion core/src/tests/run_on_incoming_connect_interval.cc
Expand Up @@ -198,7 +198,6 @@ class MockDatabase : public BareosDb {

bool OpenDatabase(JobControlRecord* /*jcr*/) override { return false; }
void CloseDatabase(JobControlRecord* /*jcr*/) override {}
bool ValidateConnection() override { return false; }
void StartTransaction(JobControlRecord* /*jcr*/) override {}
void EndTransaction(JobControlRecord* /*jcr*/) override {}
bool SqlCopyStart(const std::string&,
Expand Down

0 comments on commit 5803427

Please sign in to comment.