-
-
Save cdecker/d2c0ade8ae5dd69938274ae459b6d8a6 to your computer and use it in GitHub Desktop.
Range-diff between ElementsProject/lightning#3057 as reviewed by @rustyrussell and its fixed up version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: 9d7560e63 = 1: 9d7560e63 make: Add configuration detection and linking of libpq | |
2: 71953a205 = 2: 71953a205 pytest: Add db_provider and db instances for configurable backends | |
3: 7d41cb30f ! 3: f0816fb50 cli: Add command line option to specify the wallet location | |
@@ -10,14 +10,6 @@ | |
diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 | |
--- a/doc/lightningd-config.5 | |
+++ b/doc/lightningd-config.5 | |
-@@ | |
- .TH "LIGHTNINGD-CONFIG" "5" "" "" "lightningd-config" | |
- .SH NAME | |
--lightningd-config - Lightning daemon configuration file | |
-+ | |
- .SH SYNOPSIS | |
- | |
- \fB~/\.lightning/config\fR | |
@@ | |
readable (we allow missing files in the default case)\. Using this inside | |
a configuration file is meaningless\. | |
@@ -31,24 +23,6 @@ | |
.SH Lightning node customization options | |
\fBalias\fR=\fIRRGGBB\fR | |
-@@ | |
- | |
- .SH AUTHOR | |
- | |
--Rusty Russell <\fIrusty@rustcorp.com.au\fR> wrote this man page, and | |
-+Rusty Russell <\fBNone\fR (\fIrusty@rustcorp.com.au\fR)> wrote this man page, and | |
- much of the configuration language, but many others did the hard work of | |
- actually implementing these options\. | |
- | |
-@@ | |
- | |
- .SH RESOURCES | |
- | |
--Main web site: \fIhttps://github.com/ElementsProject/lightning\fR | |
-+Main web site: \fBNone\fR (\fIhttps://github.com/ElementsProject/lightning\fR) | |
- | |
- .SH COPYING | |
- | |
diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md | |
--- a/doc/lightningd-config.5.md | |
4: 5a4382efa = 4: 25d29a16d postgres: Add postgres statement rewriting support | |
5: d3beaa601 = 5: 7f92a07ad db: Move remainder of the sqlite3 into the apropriate file | |
6: 003b7a5eb = 6: 524c8a010 db: Reorder migrations to reflect their relationship | |
7: 6032f1158 = 7: 8cb65ba36 db: Switch statement lookup to use the original query instead | |
8: 3520bc58d = 8: c8635a29e db: Adjust some db migrations to be compatible with postgres | |
9: 3fe5a88a0 ! 9: 55427326c db: Implement postgres driver primitives | |
@@ -41,7 +41,6 @@ | |
+ | |
+static bool db_postgres_setup(struct db *db) | |
+{ | |
-+ printf("Connecting to %s\n", db->filename); | |
+ db->conn = PQconnectdb(db->filename); | |
+ | |
+ if (PQstatus(db->conn) != CONNECTION_OK) { | |
10: f95261fb9 < -: --------- db: Allow some internal queries to fail | |
-: --------- > 10: 7dde498c9 db: Allow some internal queries to fail | |
11: 1986fb2c6 ! 11: c02078fdf db: Select driver by dsn prefix | |
@@ -18,12 +18,27 @@ | |
{ | |
size_t num_configs; | |
struct db_config **configs = autodata_get(db_backends, &num_configs); | |
- for (size_t i=0; i<num_configs; i++) | |
+- for (size_t i=0; i<num_configs; i++) | |
- if (streq(driver_name, configs[i]->name)) | |
-+ if (strstarts(dsn, configs[i]->name)) | |
++ const char *sep, *driver_name; | |
++ sep = strstr(dsn, "://"); | |
++ | |
++ if (!sep) | |
++ db_fatal("%s doesn't look like a valid data-source name (missing \"://\" separator.", dsn); | |
++ | |
++ driver_name = tal_strndup(tmpctx, dsn, sep - dsn); | |
++ | |
++ for (size_t i=0; i<num_configs; i++) { | |
++ if (streq(driver_name, configs[i]->name)) { | |
++ tal_free(driver_name); | |
return configs[i]; | |
++ } | |
++ } | |
++ | |
++ tal_free(driver_name); | |
return NULL; | |
} | |
+ | |
@@ | |
static struct db *db_open(const tal_t *ctx, char *filename) | |
{ | |
12: aec45a357 = 12: be77ae6f1 db: Split the vars table to have type-specific columns | |
13: 9f19aa3c4 = 13: 47bc85bc0 db: Implement SQL statement rewriting | |
14: fbd03072c = 14: c12fd9fe6 db: Change migrations to use types of the correct cardinality | |
15: 2423d8a63 ! 15: 5d183b02f db: Strengthen some null-checks on queries | |
@@ -25,17 +25,11 @@ | |
tal_free(stmt); | |
@@ | |
- res = db_step(stmt); | |
- assert(res); | |
+ bool res; | |
-- db_column_amount_msat(stmt, 0, &total); | |
-+ if (db_column_is_null(stmt, 0)) | |
-+ /* Some databases return a NULL result if there are no | |
-+ * operands for the SUM(). This is the case for example for | |
-+ * postgres. */ | |
-+ total = AMOUNT_MSAT(0); | |
-+ else | |
-+ db_column_amount_msat(stmt, 0, &total); | |
- tal_free(stmt); | |
- | |
- return total; | |
+ stmt = db_prepare_v2(w->db, SQL("SELECT" | |
+- " SUM(in_msatoshi - out_msatoshi) " | |
++ " CAST(COALESCE(SUM(in_msatoshi - out_msatoshi), 0) AS BIGINT)" | |
+ "FROM forwarded_payments " | |
+ "WHERE state = ?;")); | |
+ db_bind_int(stmt, 0, wallet_forward_status_in_db(FORWARD_SETTLED)); | |
16: d4cb64c3e = 16: 83bd8ff4d db: Check execution when accessing the result of a statement | |
17: a12c9914c = 17: 51b8fa0e4 db: Change table field types to be more specific | |
18: ab89d2abe ! 18: b9b28f71b db: Adjust queries to work with postgres | |
@@ -295,15 +295,6 @@ | |
notify_forward_event(w->ld, in, out, state, failcode, resolved_time); | |
} | |
-@@ | |
- bool res; | |
- | |
- stmt = db_prepare_v2(w->db, SQL("SELECT" | |
-- " SUM(in_msatoshi - out_msatoshi) " | |
-+ " CAST(SUM(in_msatoshi - out_msatoshi) AS BIGINT)" | |
- "FROM forwarded_payments " | |
- "WHERE state = ?;")); | |
- db_bind_int(stmt, 0, wallet_forward_status_in_db(FORWARD_SETTLED)); | |
@@ | |
", f.resolved_time" | |
", f.failcode " | |
19: 5803797ab = 19: 12e1a6448 pytest: Skip some tests that assume we have a sqlite3 db on postgres | |
20: 7490a4ebc = 20: 799b1c9e5 pytest: Consolidate fee-fetching in test_setchannelfee_usage | |
21: da8d7395a = 21: d66481ea3 pytest: Have the DB provider search for the postgres binary | |
22: 7c5d5de4f = 22: a9978886c pytest: Stabilize test_no_fee_estimate against UTXO selection issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment