sqldb: demonstrate the use of ExecutePagedQuery

Here, a new query (GetChannelsByOutpoints) is added which makes use of
the /*SLICE:outpoints*/ directive & added workaround. This is then used
in a test to demonstrate how the ExecutePagedQuery helper can be used to
wrap a query like this such that calls are done in pages.

The query that has been added will also be used by live code paths in an
upcoming commit.
This commit is contained in:
Elle Mouton
2025-07-16 08:29:40 +02:00
parent 006905d57f
commit f0d2d1fd0a
6 changed files with 175 additions and 0 deletions

View File

@@ -231,6 +231,17 @@ WHERE scid >= @start_scid
SELECT * FROM graph_channels
WHERE scid = $1 AND version = $2;
-- name: GetChannelsByOutpoints :many
SELECT
sqlc.embed(c),
n1.pub_key AS node1_pubkey,
n2.pub_key AS node2_pubkey
FROM graph_channels c
JOIN graph_nodes n1 ON c.node_id_1 = n1.id
JOIN graph_nodes n2 ON c.node_id_2 = n2.id
WHERE c.outpoint IN
(sqlc.slice('outpoints')/*SLICE:outpoints*/);
-- name: GetChannelByOutpoint :one
SELECT
sqlc.embed(c),