mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
wallet: Add macro to annotate SQL statements
These two simple macros have a twofold use: 1) They serve as annotations for the query extraction tool to find them when extracting queries from the C source code. 2) They replace the actual queries with names that can be used to lookup the queries in a table again, once they have been rewritten into the target SQL dialect. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
57f91246cf
commit
5270c149e3
1 changed files with 22 additions and 0 deletions
22
wallet/db.h
22
wallet/db.h
|
@ -25,6 +25,28 @@ struct db {
|
|||
const char **changes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Macro to annotate a named SQL query.
|
||||
*
|
||||
* This macro is used to annotate SQL queries that might need rewriting for
|
||||
* different SQL dialects. It is used both as a marker for the query
|
||||
* extraction logic in devtools/sql-rewrite.py to identify queries, as well as
|
||||
* a way to swap out the query text with it's name so that the query execution
|
||||
* engine can then look up the rewritten query using its name.
|
||||
*
|
||||
*/
|
||||
#define NAMED_SQL(name,x) x
|
||||
|
||||
/**
|
||||
* Simple annotation macro that auto-generates names for NAMED_SQL
|
||||
*
|
||||
* If this macro is changed it is likely that the extraction logic in
|
||||
* devtools/sql-rewrite.py needs to change as well, since they need to
|
||||
* generate identical names to work correctly.
|
||||
*/
|
||||
#define SQL(x) NAMED_SQL( __FILE__ ":" stringify(__LINE__) ":" stringify(__COUNTER__), x)
|
||||
|
||||
|
||||
/**
|
||||
* db_setup - Open a the lightningd database and update the schema
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue