Retire gp-common-go-libs and sqlx; inline replacements in-repo#29
Open
adam8157 wants to merge 1 commit into
Open
Retire gp-common-go-libs and sqlx; inline replacements in-repo#29adam8157 wants to merge 1 commit into
adam8157 wants to merge 1 commit into
Conversation
Contributor
Author
Replace the external gp-common-go-libs dependency (and its transitive sqlx
dep) with seven top-level packages copied/ported into the repo:
cluster/, dbconn/, gplog/, iohelper/, operating/, structmatcher/, testhelper/.
The bulk of the file churn is mechanical import-path rewrites; APIs were
preserved so call sites didn't need to change.
Zero new direct deps; the replace directive pointing at warehouse-pg/gp-
common-go-libs is gone. dbconn is rewritten on database/sql + pgx/v5 stdlib
driver with a small reflect-based scanner (db: tag mapping, embedded
structs, sql.Scanner passthrough so pq.StringArray still works) — sqlx is
out. gplog is reimplemented on stdlib log.Logger.
Internal behavior changes worth flagging:
- dbconn.Get is now strict: returns ErrMultipleRows on >1 row instead of
sqlx's silent first-row. Every production call site was audited and is
1-row by construction (scalar functions, SHOW <guc>, PK-unique catalog
lookups, cluster invariants).
- dbconn.handleConnectionError classifies pgx errors by SQLSTATE
(42704/3D000) instead of substring-matching lib/pq error prefixes.
- dbconn.Begin uses BeginTx(LevelSerializable); previously BEGIN + SET
TRANSACTION ISOLATION LEVEL SERIALIZABLE.
- DBConn.ConnPool[i] is *sql.DB (was *sqlx.DB); Tx[i] is *sql.Tx.
Version-string parsing (dbconn.ParseGPVersion) anchors only on the brand
marker and takes the first X.Y.Z token after it, so it handles both banner
shapes — version inside the "(Greenplum Database <ver>)" parens (GP6/GP7),
and the newer shape where the closing paren precedes the version
("... (Greenplum Database) <ver> build ...") — without mistaking the gcc
toolchain version for the product version, and returns an error instead of
panicking on an unrecognized banner.
pkg/errors is dropped in favor of stdlib: errors.Errorf/New/As/Is -> stdlib,
errors.Wrap -> fmt.Errorf("%s: %w", ...) so wrapping stays recoverable; the
gplog.Fatal stack capture uses runtime.Callers via an internal captureStack()
(stack still starts at Fatal's caller). pq.StringArray is replaced by an
in-repo sql.Scanner (dbconn/array.go) matching pq's strict NULL handling.
tools.go is gone; ginkgo/goimports run via `go tool` (x/tools now indirect,
needs Go 1.24+, we're on 1.25). Assorted altitude cleanups (SelectString
single-pass scan; ReplaceAll; reflect.PointerTo; stale sqlx comments).
In-repo unit tests accompany the inlined packages: ported from the upstream
suites for cluster/structmatcher/iohelper (iohelper minus the dropped
OpenFileForAppending variants), fresh tests for the stdlib-log gplog
reimplementation, and dbconn coverage for the reflect scanner, array
scanning, and version parsing (both banner shapes, the toolchain-version
trap, and the error paths).
adam8157
force-pushed
the
retire_gp-common-go-libs
branch
from
July 24, 2026 06:36
8d04f50 to
432ef05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Replace the external gp-common-go-libs dependency (and its transitive sqlx
dep) with seven top-level packages copied/ported into the repo:
cluster/, dbconn/, gplog/, iohelper/, operating/, structmatcher/, testhelper/.
The bulk of the file churn is mechanical import-path rewrites; APIs were
preserved so call sites didn't need to change.
Zero new direct deps; the replace directive pointing at gp-common-go-libs is
gone. dbconn is rewritten on database/sql + pgx/v5 stdlib driver with a small
reflect-based scanner (db: tag mapping, embedded structs, sql.Scanner
passthrough so pq.StringArray still works) — sqlx is out. gplog is
reimplemented on stdlib log.Logger.
Internal behavior changes worth flagging:
sqlx's silent first-row. Every production call site was audited and is
1-row by construction (scalar functions, SHOW <guc>, PK-unique catalog
lookups, cluster invariants).
(42704/3D000) instead of substring-matching lib/pq error prefixes.
TRANSACTION ISOLATION LEVEL SERIALIZABLE.
X.Y.Z token after it, handling both the "(Greenplum Database <ver>)" banner
shape and the newer shape where the closing paren precedes the version,
without mistaking the gcc toolchain version for the product version, and
returning an error instead of panicking on an unrecognized banner.
Cleanups: pkg/errors dropped for stdlib (errors.Wrap →
fmt.Errorf("%s: %w", …)so wrapping stays recoverable; gplog.Fatal stack capture via runtime.Callers).
pq.StringArray replaced by an in-repo sql.Scanner. tools.go removed —
ginkgo/goimports run via
go tool(x/tools now indirect, needs Go 1.24+).Tests: in-repo unit tests accompany the inlined packages — ported from the
upstream suites for cluster/structmatcher/iohelper, fresh tests for the
stdlib-log gplog, and dbconn coverage for the reflect scanner, array scanning,
and version parsing (both banner shapes + error paths).
Rebased on main; adapts cleanly to the features that landed since
(
--exclude-extension, gpbackup_history columns, the CVE/dep bumps).