From 5d80f9877d2d01fe7ea9808537c4d240444e25e0 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 12 Mar 2021 19:11:02 +0100 Subject: [PATCH] Fix running ALTER TABLE statements in Execute SQL tab This fixes a bug introduced in 73efa116807aa7171379a0c3f5bc479dda0810f8. Because SQLite reports ALTER TABLE statements to return one column worth of data, DB4S assumed they are close to a SELECT statement and therefore did not fully execute them. See issues #2563 and #2622. --- src/RunSql.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RunSql.cpp b/src/RunSql.cpp index ccaef591..e0aaf9c8 100644 --- a/src/RunSql.cpp +++ b/src/RunSql.cpp @@ -165,8 +165,8 @@ bool RunSql::executeNextStatement() // Get type StatementType query_part_type = getQueryType(queryPart.trimmed()); - // Check if this statement returned any data - if(sqlite3_column_count(vm)) + // Check if this statement returned any data. We skip this check if this is an ALTER TABLE statement which, for some reason, are reported to return one column. + if(query_part_type != AlterStatement && sqlite3_column_count(vm)) { // It did. So it is definitely some SELECT statement or similar and we don't need to actually execute it here sql3status = SQLITE_ROW;