diff --git a/devtools/sql-rewrite.py b/devtools/sql-rewrite.py index 1aa9c4469..476cdc147 100755 --- a/devtools/sql-rewrite.py +++ b/devtools/sql-rewrite.py @@ -157,6 +157,13 @@ const struct db_query db_${f}_queries[] = { % endfor }; +struct db_query_set ${f}_query_set = { + .name = "${f}", + .query_table = db_${f}_queries, + .query_table_size = ARRAY_SIZE(db_${f}_queries), +}; + +AUTODATA(db_queries, &${f}_query_set); #endif /* HAVE_${f.upper()} */ #endif /* LIGHTNINGD_WALLET_GEN_DB_${f.upper()} */ diff --git a/wallet/Makefile b/wallet/Makefile index 91b10246b..05ce68de4 100644 --- a/wallet/Makefile +++ b/wallet/Makefile @@ -8,15 +8,13 @@ WALLET_LIB_SRC := \ wallet/walletrpc.c WALLET_LIB_SRC_NOHDR := \ - wallet/reservation.c \ - wallet/db_queries_postgres.c \ - wallet/db_queries_sqlite3.c + wallet/reservation.c WALLET_DB_QUERIES := \ wallet/db_sqlite3_sqlgen.c \ wallet/db_postgres_sqlgen.c -WALLET_SRC := $(WALLET_LIB_SRC) $(WALLET_LIB_SRC_NOHDR) +WALLET_SRC := $(WALLET_LIB_SRC) $(WALLET_LIB_SRC_NOHDR) $(WALLET_DB_QUERIES) WALLET_HDRS := $(WALLET_LIB_SRC:.c=.h) WALLET_OBJS := $(WALLET_SRC:.c=.o) @@ -25,10 +23,6 @@ WALLET_OBJS := $(WALLET_SRC:.c=.o) ALL_C_SOURCES += $(WALLET_SRC) $(WALLET_DB_QUERIES) ALL_C_HEADERS += $(WALLET_HDRS) -# Query sets depend on the rewritten queries -wallet/db_queries_sqlite3.o: $(WALLET_DB_QUERIES) -wallet/db_queries_postgres.o: $(WALLET_DB_QUERIES) - # The following files contain SQL-annotated statements that we need to extact WALLET_SQL_FILES := \ $(DB_SQL_FILES) \ diff --git a/wallet/db_queries_postgres.c b/wallet/db_queries_postgres.c deleted file mode 100644 index 687f9e4d5..000000000 --- a/wallet/db_queries_postgres.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "config.h" -#include "db_postgres_sqlgen.c" - -#if HAVE_POSTGRES - -struct db_query_set postgres_query_set = { - .name = "postgres", - .query_table = db_postgres_queries, - .query_table_size = ARRAY_SIZE(db_postgres_queries), -}; - -AUTODATA(db_queries, &postgres_query_set); -#endif /* HAVE_POSTGRES */ diff --git a/wallet/db_queries_sqlite3.c b/wallet/db_queries_sqlite3.c deleted file mode 100644 index 9411170fd..000000000 --- a/wallet/db_queries_sqlite3.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "config.h" -#include "db_sqlite3_sqlgen.c" - -#if HAVE_SQLITE3 -struct db_query_set sqlite3_query_set = { - .name = "sqlite3", - .query_table = db_sqlite3_queries, - .query_table_size = ARRAY_SIZE(db_sqlite3_queries), -}; - -AUTODATA(db_queries, &sqlite3_query_set); -#endif /* HAVE_SQLITE3 */ diff --git a/wallet/test/Makefile b/wallet/test/Makefile index b8406b16c..278287cfb 100644 --- a/wallet/test/Makefile +++ b/wallet/test/Makefile @@ -27,7 +27,7 @@ WALLET_TEST_COMMON_OBJS := \ common/utils.o \ common/wireaddr.o \ common/version.o \ - wallet/db_queries_sqlite3.o \ + wallet/db_sqlite3_sqlgen.o \ wire/towire.o \ wire/fromwire.o