diff --git a/configure b/configure index c72981610b2a..dbef04b2a6ee 100755 --- a/configure +++ b/configure @@ -415,20 +415,6 @@ int main(void) return 0; } /*END*/ -var=HAVE_SQLITE3_EXPANDED_SQL -desc=sqlite3_expanded_sql -style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE -link=$SQLITE3_LDLIBS -code= -#include -#include - -int main(void) -{ - printf("%p\n", sqlite3_expanded_sql); - return 0; -} -/*END*/ var=HAVE_SQLITE3 desc=sqlite3 style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE diff --git a/db/db_sqlite3.c b/db/db_sqlite3.c index 876049ed304c..07ded41f6ea3 100644 --- a/db/db_sqlite3.c +++ b/db/db_sqlite3.c @@ -92,22 +92,6 @@ static bool have_same_data_version(sqlite3 *a, sqlite3 *b) return version_a == version_b; } -#if !HAVE_SQLITE3_EXPANDED_SQL -/* Prior to sqlite3 v3.14, we have to use tracing to dump statements */ -struct db_sqlite3_trace { - struct db_sqlite3 *wrapper; - struct db_stmt *stmt; -}; - -static void trace_sqlite3(void *stmtv, const char *stmt) -{ - struct db_sqlite3_trace *trace = (struct db_sqlite3_trace *)stmtv; - struct db_sqlite3 *wrapper = trace->wrapper; - struct db_stmt *s = trace->stmt; - db_sqlite3_changes_add(wrapper, s, stmt); -} -#endif - static const char *db_sqlite3_fmt_error(struct db_stmt *stmt) { return tal_fmt(stmt, "%s: %s: %s", stmt->location, stmt->query->query, @@ -269,49 +253,27 @@ static bool db_sqlite3_query(struct db_stmt *stmt) static bool db_sqlite3_exec(struct db_stmt *stmt) { int err; - bool success; + char *expanded_sql; struct db_sqlite3 *wrapper = (struct db_sqlite3 *) stmt->db->conn; -#if !HAVE_SQLITE3_EXPANDED_SQL - /* Register the tracing function if we don't have an explicit way of - * expanding the statement. */ - struct db_sqlite3_trace trace; - trace.wrapper = wrapper; - trace.stmt = stmt; - sqlite3_trace(conn2sql(stmt->db->conn), trace_sqlite3, &trace); -#endif - if (!db_sqlite3_query(stmt)) { /* If the prepare step caused an error we hand it up. */ - success = false; - goto done; + return false; } err = sqlite3_step(stmt->inner_stmt); if (err != SQLITE_DONE) { tal_free(stmt->error); stmt->error = db_sqlite3_fmt_error(stmt); - success = false; - goto done; + return false; } -#if HAVE_SQLITE3_EXPANDED_SQL /* Manually expand and call the callback */ - char *expanded_sql; expanded_sql = sqlite3_expanded_sql(stmt->inner_stmt); db_sqlite3_changes_add(wrapper, stmt, expanded_sql); sqlite3_free(expanded_sql); -#endif - success = true; - -done: -#if !HAVE_SQLITE3_EXPANDED_SQL - /* Unregister the trace callback to avoid it accessing the potentially - * stale pointer to stmt */ - sqlite3_trace(conn2sql(stmt->db->conn), NULL, NULL); -#endif - return success; + return true; } static bool db_sqlite3_step(struct db_stmt *stmt) @@ -570,6 +532,7 @@ static bool complete_table_manip(struct db *db, return true; } +/* FIXME: sqlite3 version 3.25.0 (2018-09-15) supports ALTER TABLE RENAME */ static bool db_sqlite3_rename_column(struct db *db, const char *tablename, const char *from, const char *to) diff --git a/plugins/sql.c b/plugins/sql.c index 1496d7e9cf82..9e4ca305b4b2 100644 --- a/plugins/sql.c +++ b/plugins/sql.c @@ -873,8 +873,8 @@ static struct command_result *channels_refresh(struct command *cmd, plugin_log(cmd->plugin, LOG_DBG, "Refreshing channel: %s", fmt_short_channel_id(tmpctx, scid)); - /* FIXME: sqlite 3.24.0 (2018-06-04) added UPSERT, but - * we don't require it. */ + /* FIXME: sqlite3 version 3.24.0 (2018-06-04) added + * UPSERT, but we don't require it. */ delete_channel_from_db(cmd, scid); req = jsonrpc_request_start(cmd, "listchannels", listchannels_one_done, diff --git a/tools/headerversions.c b/tools/headerversions.c index 4c798b43f8d5..15100bdef5f8 100644 --- a/tools/headerversions.c +++ b/tools/headerversions.c @@ -32,6 +32,10 @@ static const char template[] = " if (SQLITE_VERSION_NUMBER + 1000000 < sqlite3_libversion_number())\n" " errx(1, \"SQLITE major version mismatch: compiled %%u, now %%u\",\n" " SQLITE_VERSION_NUMBER, sqlite3_libversion_number());\n" + " /* Earliest supported sqlite3 version */\n" + " if (SQLITE_VERSION_NUMBER < 3026000)\n" + " errx(1, \"SQLITE version %%u too old (minimum 3.26)\",\n" + " SQLITE_VERSION_NUMBER);\n" ) "}\n"; diff --git a/wallet/db.c b/wallet/db.c index 569182d5e592..93707eb8f119 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -1631,8 +1631,8 @@ static void migrate_channels_scids_as_integers(struct lightningd *ld, /* FIXME: We cannot use ->delete_columns to remove * short_channel_id, as other tables reference the channels * (and sqlite3 has them referencing a now-deleted table!). - * When we can assume sqlite3 2021-04-19 (3.35.5), we can - * simply use DROP COLUMN (yay!) */ + * When we can assume sqlite3 version 3.35.5 (2021-04-19), + * we can simply use DROP COLUMN (yay!) */ /* So null-out the unused column, at least! */ stmt = db_prepare_v2(db, SQL("UPDATE channels"