Skip to content

Commit f542949

Browse files
rustyrussellmadelinevibes
authored andcommitted
db: drop support for sqlite3 < 3.14.
Signed-off-by: Rusty Russell <[email protected]>
1 parent e051ba6 commit f542949

File tree

2 files changed

+4
-56
lines changed

2 files changed

+4
-56
lines changed

configure

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,6 @@ int main(void)
429429
return 0;
430430
}
431431
/*END*/
432-
var=HAVE_SQLITE3_EXPANDED_SQL
433-
desc=sqlite3_expanded_sql
434-
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
435-
link=$SQLITE3_LDLIBS
436-
code=
437-
#include <sqlite3.h>
438-
#include <stdio.h>
439-
440-
int main(void)
441-
{
442-
printf("%p\n", sqlite3_expanded_sql);
443-
return 0;
444-
}
445-
/*END*/
446432
var=HAVE_SQLITE3
447433
desc=sqlite3
448434
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE

db/db_sqlite3.c

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,6 @@ static bool have_same_data_version(sqlite3 *a, sqlite3 *b)
9292
return version_a == version_b;
9393
}
9494

95-
#if !HAVE_SQLITE3_EXPANDED_SQL
96-
/* Prior to sqlite3 v3.14, we have to use tracing to dump statements */
97-
struct db_sqlite3_trace {
98-
struct db_sqlite3 *wrapper;
99-
struct db_stmt *stmt;
100-
};
101-
102-
static void trace_sqlite3(void *stmtv, const char *stmt)
103-
{
104-
struct db_sqlite3_trace *trace = (struct db_sqlite3_trace *)stmtv;
105-
struct db_sqlite3 *wrapper = trace->wrapper;
106-
struct db_stmt *s = trace->stmt;
107-
db_sqlite3_changes_add(wrapper, s, stmt);
108-
}
109-
#endif
110-
11195
static const char *db_sqlite3_fmt_error(struct db_stmt *stmt)
11296
{
11397
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)
269253
static bool db_sqlite3_exec(struct db_stmt *stmt)
270254
{
271255
int err;
272-
bool success;
256+
char *expanded_sql;
273257
struct db_sqlite3 *wrapper = (struct db_sqlite3 *) stmt->db->conn;
274258

275-
#if !HAVE_SQLITE3_EXPANDED_SQL
276-
/* Register the tracing function if we don't have an explicit way of
277-
* expanding the statement. */
278-
struct db_sqlite3_trace trace;
279-
trace.wrapper = wrapper;
280-
trace.stmt = stmt;
281-
sqlite3_trace(conn2sql(stmt->db->conn), trace_sqlite3, &trace);
282-
#endif
283-
284259
if (!db_sqlite3_query(stmt)) {
285260
/* If the prepare step caused an error we hand it up. */
286-
success = false;
287-
goto done;
261+
return false;
288262
}
289263

290264
err = sqlite3_step(stmt->inner_stmt);
291265
if (err != SQLITE_DONE) {
292266
tal_free(stmt->error);
293267
stmt->error = db_sqlite3_fmt_error(stmt);
294-
success = false;
295-
goto done;
268+
return false;
296269
}
297270

298-
#if HAVE_SQLITE3_EXPANDED_SQL
299271
/* Manually expand and call the callback */
300-
char *expanded_sql;
301272
expanded_sql = sqlite3_expanded_sql(stmt->inner_stmt);
302273
db_sqlite3_changes_add(wrapper, stmt, expanded_sql);
303274
sqlite3_free(expanded_sql);
304-
#endif
305-
success = true;
306-
307-
done:
308-
#if !HAVE_SQLITE3_EXPANDED_SQL
309-
/* Unregister the trace callback to avoid it accessing the potentially
310-
* stale pointer to stmt */
311-
sqlite3_trace(conn2sql(stmt->db->conn), NULL, NULL);
312-
#endif
313275

314-
return success;
276+
return true;
315277
}
316278

317279
static bool db_sqlite3_step(struct db_stmt *stmt)

0 commit comments

Comments
 (0)