Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SQL statement expansion for plugin db_write hook #4090

Merged
merged 4 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

# All of the following will just run `make pytest`
- VALGRIND=0 ARCH=64 DEVELOPER=1 COMPILER=clang
- VALGRIND=0 ARCH=64 DEVELOPER=1 COMPILER=gcc
- VALGRIND=0 ARCH=64 DEVELOPER=1 COMPILER=gcc TEST_CHECK_DBSTMTS=1
- VALGRIND=0 ARCH=64 DEVELOPER=0 COMPILER=gcc COMPAT=0 TEST_GROUP=1 TEST_GROUP_COUNT=2
- VALGRIND=0 ARCH=64 DEVELOPER=0 COMPILER=gcc COMPAT=0 TEST_GROUP=2 TEST_GROUP_COUNT=2

Expand Down
11 changes: 11 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ class LightningNode(utils.LightningNode):
def __init__(self, *args, **kwargs):
utils.LightningNode.__init__(self, *args, **kwargs)

# If we opted into checking the DB statements we will attach the dblog
# plugin before starting the node
check_dblog = os.environ.get("TEST_CHECK_DBSTMTS", None) is not None
db = os.environ.get("TEST_DB_PROVIDER", "sqlite3")
if db == 'sqlite3' and check_dblog:
dblog = os.path.join(os.path.dirname(__file__), 'plugins', 'dblog.py')
has_dblog = len([o for o in self.daemon.cmd_line if 'dblog.py' in o]) > 0
if not has_dblog:
# Add as an expanded option so we don't clobber other options.
self.daemon.opts['plugin={}'.format(dblog)] = None

# Yes, we really want to test the local development version, not
# something in out path.
self.daemon.executable = 'lightningd/lightningd'
Expand Down
10 changes: 5 additions & 5 deletions wallet/db_postgres_sqlgen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions wallet/db_sqlite3_sqlgen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions wallet/statements_gettextgen.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static void db_set_utxo(struct db *db, const struct utxo *utxo)
assert(!utxo->reserved_til);

stmt = db_prepare_v2(
db, SQL("UPDATE outputs SET status=?, reserved_til=?"
db, SQL("UPDATE outputs SET status=?, reserved_til=? "
"WHERE prev_out_tx=? AND prev_out_index=?"));
m-schmoock marked this conversation as resolved.
Show resolved Hide resolved
db_bind_int(stmt, 0, output_status_in_db(utxo->status));
db_bind_int(stmt, 1, utxo->reserved_til);
Expand Down Expand Up @@ -1651,7 +1651,7 @@ void wallet_channel_close(struct wallet *w, u64 wallet_id)

/* Set the channel to closed and disassociate with peer */
stmt = db_prepare_v2(w->db, SQL("UPDATE channels "
"SET state=?, peer_id=?"
"SET state=?, peer_id=? "
"WHERE channels.id=?"));
db_bind_u64(stmt, 0, CLOSED);
db_bind_null(stmt, 1);
Expand Down