db: collapse the db_queries files into the generated ones

There's no reason to have these be independent of the generated files,
all the data contained within them is 'formulaic'
This commit is contained in:
niftynei 2022-03-01 12:24:18 -06:00 committed by Rusty Russell
parent 453ef7f0ce
commit ea36c3a938
5 changed files with 10 additions and 34 deletions

View file

@ -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()} */

View file

@ -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) \

View file

@ -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 */

View file

@ -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 */

View file

@ -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