Skip to content

experimental postgres query: use pgconn directly - #7073

Closed
denik wants to merge 2 commits into
mainfrom
denis/postgres-pgconn
Closed

denik wants to merge 2 commits into
mainfrom
denis/postgres-pgconn

Conversation

@denik

@denik denik commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Changes

Switch from pgx.Conn to pgconn.PgConn and decode rows from the server's text format: ints, floats, bools, bytea and date/time types map to Go types as before; all other types are printed as Postgres' canonical text.

Why

Binary size: pgx's pgtype registry costs 2.8 MB (55.8 MB → 53.0 MB, stripped linux/amd64 release build). It also fixes output for types pgx decoded into internal structs: json/jsonb rendered as Go maps (a jsonb string broke --output json), and numeric, uuid, time, interval, arrays and point rendered as struct dumps.

Tests

Unit and acceptance tests, plus a throwaway differential test against a fake pgwire server: every value that rendered correctly before renders identically. Not yet tested against a real Lakebase instance.

This pull request and its description were written by Isaac.

denik and others added 2 commits October 15, 2026 15:05
The command only needs text-format results, so pgx.Conn and its pgtype
type registry are unnecessary. Rows are now decoded from the server's
text form: ints, floats, bools, bytea and date/time types map to Go
types as before; all other types keep the canonical Postgres text.

This also fixes output for types pgx decoded into internal structs:
json/jsonb rendered as Go maps (and a jsonb string broke JSON output),
numeric/uuid/time/interval/arrays/point rendered as struct dumps.

Stripped linux/amd64 release build: 55,840,928 -> 53,047,456 bytes (-2.79 MB).

Co-authored-by: Isaac <no-reply@databricks.com>
- Decode date/timestamp/timestamptz with pgtype's own text scanners so
  years above 9999, BC dates and the timestamptz location match the
  previous pgx.Conn behavior.
- Strip pgx-only options (statement_cache_capacity, ...) that a
  PGSERVICE file may set; pgconn would send them to the server.
- Decode non-UTF-8 JSON instead of passing raw bytes to the output.
- Decode bytea without an extra copy; defer ResultReader.Close.

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: d8a0fc9

Run: 38759095600

Env 🔄​flaky ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 276 15 5:15
✅​ aws-windows-latest-4core-16gb 278 13 3:10
✅​ azure linux-2core-8gb 275 15 5:41
✅​ azure-windows-latest-4core-16gb 277 13 3:17
✅​ gcp linux-2core-8gb 276 15 5:37
🔄​ gcp-windows-latest-4core-16gb 2 276 13 3:41
Test Name gcp-windows-latest-4core-16gb
🔄​ TestFsCpFileToDir 🔄​f
🔄​ TestFsCpFileToDir/uc-volumes_to_uc-volumes 🔄​f
Top 6 slowest tests (at least 2 minutes):
duration env testname
4:03 azure linux-2core-8gb TestAccept
3:53 gcp linux-2core-8gb TestAccept
3:32 aws linux-2core-8gb TestAccept
3:11 azure-windows-latest-4core-16gb TestAccept
3:05 aws-windows-latest-4core-16gb TestAccept
3:02 gcp-windows-latest-4core-16gb TestAccept

@denik denik closed this Oct 17, 2026
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