Skip to content

pg: use native pgx for PostgreSQL storage - #1321

Draft
yyforyongyu wants to merge 9 commits into
btcsuite:sql-walletfrom
yyforyongyu:task-native-pgx
Draft

pg: use native pgx for PostgreSQL storage#1321
yyforyongyu wants to merge 9 commits into
btcsuite:sql-walletfrom
yyforyongyu:task-native-pgx

Conversation

@yyforyongyu

@yyforyongyu yyforyongyu commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Use native pgx for normal PostgreSQL store reads, writes, and transactions
while keeping SQLite and migration tooling on database/sql.

Change Description

Implements roadmap Task 350

  • generate PostgreSQL queries for pgx/v5 and adapt PostgreSQL values at the
    backend boundary
  • make the shared transaction runtime driver-neutral while preserving retry,
    health, fatal-error, rollback, and ambiguous-commit behavior
  • retain migration and test-administration compatibility through the pgx
    pool's database/sql adapter

Status

This PR is deprioritized and is not currently being pursued. Please do not
review it.

Comment thread wallet/internal/db/pg/backend_rows_test.go Outdated
Comment thread wallet/internal/db/pg/itest_admin.go Outdated
Comment thread wallet/internal/db/pg/itest.go Outdated
Comment thread wallet/internal/db/pg/store.go Outdated
Comment thread wallet/internal/db/pg/store.go
Comment thread wallet/internal/db/runtime/runtime.go Outdated
Comment thread wallet/internal/db/runtime/runtime.go Outdated
Comment thread wallet/internal/db/itest/pg_test.go Outdated
Comment thread wallet/internal/db/pg/backend_rows_test.go Outdated
Comment thread wallet/internal/db/pg/store.go
Comment thread wallet/internal/db/accountstore_common.go Outdated
Comment thread wallet/internal/db/addressstore_newderived.go Outdated
Comment thread wallet/internal/sql/pg/migrations.go
@yyforyongyu
yyforyongyu force-pushed the task-native-pgx branch 2 times, most recently from bfe3fef to acb5fd5 Compare August 13, 2026 15:46
Add a driver-neutral nullable value for shared account rows and move
SQL nullable conversions into each backend adapter. Preserve account
creation and lookup behavior with focused tests.
Replace database/sql values in shared address rows with driver-neutral
nullable values and timestamps. Convert PostgreSQL and SQLite rows at
their adapter boundaries and retain address derivation coverage.
Replace shared UTXO nullable values with driver-neutral representations.
Convert backend row types at the PostgreSQL and SQLite boundaries and
cover invalid and absent block heights.
Move SQL query parameter construction into the PostgreSQL and SQLite
adapters. Keep shared casting helpers driver-neutral while preserving
range checks and nullable filter behavior.
Move no-row and connection sentinel handling into each SQL backend.
Keep shared error normalization driver-neutral and retain domain-error,
health, and classification behavior.
Define backend-neutral transaction operation and commit-result types.

Keep ambiguity classification inside each backend so the shared runtime
stays independent of driver transport errors.
Parameterize shared transaction execution over backend transaction and
query types. Preserve begin, bind, commit, rollback, health, retry, and
ambiguous-commit accounting for both SQL backends.
Name btcd v2 imports explicitly in changed PostgreSQL and SQLite files.
This keeps tagged Docker lint deterministic without changing runtime
behavior.
Generate PostgreSQL queries for pgx/v5, then run normal reads through
pgxpool and writes through pgx.Tx. Adapt generated query values and row
tests while retaining database/sql solely for migrations and tagged test
administration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants