]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/postgresql.c
bvfs: Restore should be ok with MySQL
[bacula/bacula] / bacula / src / cats / postgresql.c
index 63fab725cb89df5f06e498f913b4fb5f30436af8..959baf75ed239ab91f2c73307b47754834db3f9e 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -650,7 +650,7 @@ void my_postgresql_free_result(B_DB *mdb)
    db_unlock(mdb);
 }
 
-static int my_postgresql_currval(B_DB *mdb, const char *table_name)
+static uint64_t my_postgresql_currval(B_DB *mdb, const char *table_name)
 {
    // Obtain the current value of the sequence that
    // provides the serial value for primary key of the table.
@@ -671,7 +671,7 @@ static int my_postgresql_currval(B_DB *mdb, const char *table_name)
    char      sequence[NAMEDATALEN-1];
    char      query   [NAMEDATALEN+50];
    PGresult *result;
-   int       id = 0;
+   uint64_t  id = 0;
 
    if (strcasecmp(table_name, "basefiles") == 0) {
       bstrncpy(sequence, "basefiles_baseid", sizeof(sequence));
@@ -702,7 +702,7 @@ static int my_postgresql_currval(B_DB *mdb, const char *table_name)
 
    if (PQresultStatus(result) == PGRES_TUPLES_OK) {
       Dmsg0(500, "getting value");
-      id = atoi(PQgetvalue(result, 0, 0));
+      id = str_to_uint64(PQgetvalue(result, 0, 0));
       Dmsg2(500, "got value '%s' which became %d\n", PQgetvalue(result, 0, 0), id);
    } else {
       Dmsg1(50, "Result status failed: %s\n", query);
@@ -715,7 +715,7 @@ bail_out:
    return id;
 }
 
-int my_postgresql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name)
+uint64_t my_postgresql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name)
 {
    /*
     * First execute the insert query and then retrieve the currval.