summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2021-05-27 09:33:45 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-05-27 11:02:42 +0200
commita00eccc7676dea5238be0b2908f254aba1bf321e (patch)
tree9e5f7c0e922fa5f71eaa60393e8aece24230080c
parent12d8fff3efef35aa61777f82133e627030bc0b27 (diff)
#1037 Simplify database update v3 code
Simplify database update v3, no need for iteration. Fixes: 12d8fff (#1037 Add disk type)
-rw-r--r--src/schema.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/schema.c b/src/schema.c
index 68c481f..c1d9ffd 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -180,26 +180,19 @@ err_no_trans:
static int og_dbi_schema_v3(struct og_dbi *dbi)
{
- const char *msglog, *command;
- dbi_result result, result_alter;
+ const char *msglog;
+ dbi_result result;
+ syslog(LOG_DEBUG, "Adding disk type to ordenadores_particiones\n");
result = dbi_conn_query(dbi->conn,
"ALTER TABLE ordenadores_particiones "
"ADD disk_type VARCHAR(32) DEFAULT NULL "
"AFTER numdisk;");
-
- while (dbi_result_next_row(result)) {
- command = dbi_result_get_string(result, "cmd");
-
- syslog(LOG_DEBUG, "Adding disk type: %s\n", command);
- result_alter = dbi_conn_query(dbi->conn, command);
- if (!result_alter) {
- dbi_conn_error(dbi->conn, &msglog);
- syslog(LOG_INFO, "Error when adding disk type (%s:%d) %s\n",
- __func__, __LINE__, msglog);
- return -1;
- }
- dbi_result_free(result_alter);
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when adding disk type (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
}
dbi_result_free(result);