Skip to content

rename reserved-word aliases current/compact for openGauss compatibility - #753

Merged
brandond merged 2 commits into
k3s-io:masterfrom
asdfsx:v0.16.4-opengauss
Sep 8, 2026
Merged

brandond merged 2 commits into
k3s-io:masterfrom
asdfsx:v0.16.4-opengauss

Conversation

@asdfsx

@asdfsx asdfsx commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

openGauss is a PostgreSQL-forked database that speaks the PostgreSQL wire protocol, so it is directly accessible with standard Go PostgreSQL drivers such as pgx. However, two incompatibilities prevent kine from running on it:

  • Reserved keyword collision (this PR). openGauss treats COMPACT as a reserved keyword in FROM-clause table aliases, so the startup queries built from ListFmt/After* templates fail with ERROR: syntax error at or near "compact" (SQLSTATE 42601). This makes kine unable to start on openGauss at all.
  • Proprietary SHA-256 authentication (deployment prerequisite, no code change needed). Unlike PostgreSQL's standard SCRAM-SHA-256 (RFC 5802), openGauss implements its own SHA-256 challenge-response scheme and reuses the wire-protocol auth code 11 without the preceding SASL negotiation, which standard PG drivers reject (pq: unknown authentication response: 11). For PG-driver compatibility, the openGauss instance must set password_encryption_type = 1 (store both SHA-256 and MD5 hashes) before creating the kine user, so that PG clients can authenticate via the MD5 channel.

Changes

Rename the subquery aliases current/compact to kv_current/kv_compact (6 occurrences in pkg/drivers/generic/generic.go):

  • The new names are dialect-neutral: quoting is not a viable alternative, since double quotes (AS "compact") would break MySQL (parsed as a string literal in the default sql_mode), while backticks would break PostgreSQL/openGauss.
  • The aliases are table aliases only — the projected column names (current_rev, compact_rev, ...) and all row.Scan() call sites are untouched, and the aliases are never referenced via qualification elsewhere. The rename is purely semantic-preserving.

Verification

Full CRUD (create/get/update/list/watch/delete/compact, driven through the etcd v3 gRPC interface) against:

  • MySQL 8.0 — PASS
  • PostgreSQL 16 — PASS
  • openGauss 7.0.0-RC3 (password_encryption_type=1) — PASS, including on a dedicated instance at a remote host

Unpatched v0.16.4 fails to start on openGauss with the syntax error above; MySQL/PostgreSQL behavior is unchanged by this rename.

@asdfsx
asdfsx requested a review from a team as a code owner August 31, 2026 09:21
@asdfsx
asdfsx force-pushed the v0.16.4-opengauss branch from 5372131 to 3052181 Compare August 31, 2026 09:22
Comment thread pkg/drivers/generic/generic.go Outdated
ListFmt = `
SELECT current_rev, compact_rev, %s
FROM (%s) AS current, (%s) AS compact, kine
FROM (%s) AS kv_current, (%s) AS kv_compact, kine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just alias these subqueries using the name of the columns they will produce.

Suggested change
FROM (%s) AS kv_current, (%s) AS kv_compact, kine
FROM (%s) AS current_rev, (%s) AS compact_rev, kine

Same change for the remainder of the occurrences.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update these alias as you suggest

…ompatibility

openGauss treats COMPACT as a reserved keyword in FROM-clause table
aliases, which makes the startup queries fail with 'syntax error at or
near "compact"'. Rename the subquery aliases to kv_current/kv_compact;
the new names are dialect-neutral (double-quoting would break MySQL,
backticks would break PostgreSQL/openGauss) and are not referenced
elsewhere.

Verified: full CRUD (create/get/update/list/watch/delete/compact)
against MySQL 8.0, PostgreSQL 16 and openGauss 7.0.0-RC3.

Signed-off-by: samsun <asdfsx@gmail.com>
Signed-off-by: samsun <asdfsx@gmail.com>
@brandond
brandond merged commit 5531642 into k3s-io:master Sep 8, 2026
35 checks passed
brandond pushed a commit that referenced this pull request Sep 14, 2026
…ity (#753)

(cherry picked from commit 5531642)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
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