mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
db: Switch statement lookup to use the original query instead
Using a generated identifier with filename and line proved to be brittle since compilers assign the __LINE__ macro differently on multi-line macro invocations. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
3df8ccd3e0
commit
640e64cb73
@@ -77,7 +77,7 @@ def extract_queries(pofile):
|
|||||||
query = c[i][7:][:-1]
|
query = c[i][7:][:-1]
|
||||||
|
|
||||||
queries.append({
|
queries.append({
|
||||||
'name': name,
|
'name': query,
|
||||||
'query': query,
|
'query': query,
|
||||||
'placeholders': query.count('?'),
|
'placeholders': query.count('?'),
|
||||||
'readonly': "true" if query.upper().startswith("SELECT") else "false",
|
'readonly': "true" if query.upper().startswith("SELECT") else "false",
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ struct db_stmt *db_prepare_v2_(const char *location, struct db *db,
|
|||||||
|
|
||||||
/* Look up the query by its ID */
|
/* Look up the query by its ID */
|
||||||
for (size_t i = 0; i < db->config->num_queries; i++) {
|
for (size_t i = 0; i < db->config->num_queries; i++) {
|
||||||
if (streq(query_id, db->config->queries[i].query)) {
|
if (streq(query_id, db->config->queries[i].name)) {
|
||||||
stmt->query = &db->config->queries[i];
|
stmt->query = &db->config->queries[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ struct db;
|
|||||||
* devtools/sql-rewrite.py needs to change as well, since they need to
|
* devtools/sql-rewrite.py needs to change as well, since they need to
|
||||||
* generate identical names to work correctly.
|
* generate identical names to work correctly.
|
||||||
*/
|
*/
|
||||||
#define SQL(x) NAMED_SQL( __FILE__ ":" stringify(__LINE__) ":" stringify(__COUNTER__), x)
|
#define SQL(x) NAMED_SQL( __FILE__ ":" stringify(__COUNTER__), x)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ enum db_binding_type {
|
|||||||
struct db_binding {
|
struct db_binding {
|
||||||
enum db_binding_type type;
|
enum db_binding_type type;
|
||||||
union {
|
union {
|
||||||
int i;
|
s32 i;
|
||||||
u64 u64;
|
u64 u64;
|
||||||
const char* text;
|
const char* text;
|
||||||
const u8 *blob;
|
const u8 *blob;
|
||||||
|
|||||||
Reference in New Issue
Block a user