9 Commits

Author SHA1 Message Date
Boris Nagaev
dee8ad3754 multi: context.Background() -> t.Context()
Use the new feature of Go 1.24, fix linter warnings.

This change was produced by:
 - running golangci-lint run --fix
 - sed 's/context.Background/t.Context/' -i `git grep -l context.Background | grep test.go`
 - manually fixing broken tests
 - itest, lntest: use ht.Context() where ht or hn is available
 - in HarnessNode.Stop() we keep using context.Background(), because it is
   called from a cleanup handler in which t.Context() is canceled already.
2025-08-30 14:13:44 -03:00
Elle Mouton
f560c4d95b sqldb: use uint32 for config values 2025-08-14 08:03:28 +02:00
Elle Mouton
b1deddec44 multi: remove DefaultQueryConfig
And always make use of either the new DefaultSQLiteConfig or
DefaultPostgresConfig.
2025-08-13 14:43:31 +02:00
Elle Mouton
185166b8d3 sqldb+config: validate maximum batch size config value
Now that the SQL query config values are configurable, we add some
validation to make sure that the user doesnt set a max batch size that
is larger than the limits for sqlite/postgres that have been determined
by the TestSQLSliceQueries test.
2025-08-13 14:43:31 +02:00
Elle Mouton
905941067e sqldb: add ExecuteCollectAndBatchWithSharedDataQuery helper
In this commit we add a new helper method in the sqldb package:
ExecuteCollectAndBatchWithSharedDataQuery. This can be used to paginate
through items in the database while at the same time performing batch
data collection for those items.
2025-08-05 06:34:38 +02:00
Elle Mouton
e276f1ec3e sqldb: add ExecutePaginatedQuery helper
In this commit we add the ExecutePaginatedQuery helper function which
can be used to execute cursor-based paginated queries.
2025-07-31 15:33:07 +02:00
Elle Mouton
a6248872cb sqldb: rename ExecutePagedQuery to ExecuteBatchQuery
We rename this helper along the config types & helper types for it
because the word "page" is used more often in the context of paging
through results using an offset and limit whereas this helper is
specifically used to split up the slice in queries of the form
"WHERE x in []slice". We do this rename so that there is mimimal
confusion in contexts where we use batching along with actual paging.

The config struct is also renamed to QueryConfig in preparation for it
holding more config options.
2025-07-31 15:32:53 +02:00
Elle Mouton
f0d2d1fd0a 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.
2025-07-22 17:16:38 +02:00
Elle Mouton
006905d57f sqldb: add ExecutePagedQuery helper
Along with a test for it. This helper will allow us to easily create a
pagination wrapper for queries that will make use of the new
/*SLICE:<field_name>*/ directive. The next commit will add a test
showing this.
2025-07-22 17:14:58 +02:00