]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#828] Added checked_*sql_version functions
authorFrancis Dupont <fdupont@isc.org>
Sun, 6 Sep 2020 12:20:49 +0000 (14:20 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 10 Sep 2020 10:41:35 +0000 (12:41 +0200)
ChangeLog
src/bin/admin/kea-admin.in

index 69634ba91517413a667e8696cc3d7ad857b4ed34..3a1dd1658b9a8df6336116350a8cbb0a24c0611b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,14 @@
+1799.  [bug]           fdupont
+       Checked execution of queries to get schema versions of MySQL
+       and PostgreSQL database in kea-admin.
+       (Gitlab #828)
+
 1798.  [bug]           tmark
        kea-dhcp4 now correctly updates DNS when a client
        returns for lease after the lease has expired.  Prior
        to this, the server would remove the entries but then
        fail to add them unless the hostname (or FQDN) changed.
-       This change also eliminates redundant DNS removes when 
+       This change also eliminates redundant DNS removes when
        expired leases are reclaimed and given to different clients.
        (Gitlab #1409)
 
index 58cba6d1c17485dc6a5bb907808ac9deba238c82..1a77656f65dfa5243183003e95eb845131e02698 100644 (file)
@@ -247,7 +247,7 @@ mysql_init() {
 
     if [ "$ERRCODE" -eq 0 ]; then
         printf "Database version reported after initialization: "
-        mysql_version
+        checked_mysql_version
         printf "\n"
     fi
 
@@ -282,7 +282,7 @@ pgsql_init() {
         exit 1
     fi
 
-    version=$(pgsql_version)
+    version=$(checked_pgsql_version)
     printf "Database version reported after initialization: %s\n" "$version"
     exit 0
 }
@@ -315,6 +315,26 @@ memfile_version() {
     exit 1
 }
 
+checked_mysql_version() {
+    mysql_version
+    ERRCODE=$?
+    if [ $ERRCODE -ne 0 ]
+    then
+        log_error "Failed to get schema version, mysql status = $ERRCODE"
+        exit 1
+    fi
+}
+
+checked_pgsql_version() {
+    pgsql_version
+    ERRCODE=$?
+    if [ $ERRCODE -ne 0 ]
+    then
+        log_error "Failed to get schema version, pgsql status = $ERRCODE"
+        exit 1
+    fi
+}
+
 ### Functions used for upgrade
 memfile_upgrade() {
     # Useless as Kea converts CSV versions at startup.
@@ -331,7 +351,7 @@ memfile_upgrade() {
 mysql_upgrade() {
 
     printf "Database version reported before upgrade: "
-    mysql_version
+    checked_mysql_version
     printf "\n"
 
     # Check if the scripts directory exists at all.
@@ -360,12 +380,12 @@ mysql_upgrade() {
     done
 
     printf "Database version reported after upgrade: "
-    mysql_version
+    checked_mysql_version
     printf "\n"
 }
 
 pgsql_upgrade() {
-    version=$(pgsql_version)
+    version=$(checked_pgsql_version)
     printf "Database version reported before upgrade: %s\n" "$version"
 
     # Check if the scripts directory exists at all.
@@ -391,7 +411,7 @@ pgsql_upgrade() {
         sh "${script}" -U "${db_user}" -h "${db_host}" -d "${db_name}"
     done
 
-    version=$(pgsql_version)
+    version=$(checked_pgsql_version)
     printf "Database version reported after upgrade: %s\n" "$version"
     exit 0
 }
@@ -817,11 +837,11 @@ case ${command} in
                 memfile_version
                 ;;
             mysql)
-                mysql_version
+                checked_mysql_version
                 printf "\n"
                 ;;
             pgsql)
-                pgsql_version
+                checked_pgsql_version
                 ;;
             cql)
                 cql_version