Skip to content

fix: BY DEFAULT identity columns must not be is_generated (#224) - #226

Merged
aesslinger merged 2 commits into
mainfrom
fix/issue-224-by-default-identity-is-generated
Dec 3, 2026
Merged

aesslinger merged 2 commits into
mainfrom
fix/issue-224-by-default-identity-is-generated

Conversation

@aesslinger

Copy link
Copy Markdown
Collaborator

Summary

#223 added a.attidentity IN ('a', 'd') to the is_generated check in all four get_columns queries. attidentity = 'd' is GENERATED BY DEFAULT AS IDENTITY, which accepts explicit values — only 'a' (ALWAYS) rejects them. Marking BY-DEFAULT identity columns as is_generated blocked table copy for the common case of a BY-DEFAULT identity primary key.

Regression from #223, found by retesting merged main against PostgreSQL 16. Should be fixed before rc.16.

Fix

Changed IN ('a', 'd') → = 'a' in all four is_generated queries in metadata.rs (lines 167, 241, 772, 1404). is_auto_increment stays true for both identity kinds.

column attidentity accepts explicit value? is_generated (before) is_generated (after)
BY DEFAULT identity 'd' yes true ❌ false ✅
ALWAYS identity 'a' no true ✅ true ✅
stored generated '' (attgenerated <> '') no true ✅ true ✅
plain column '' yes false ✅ false ✅

Test

Live test (get_columns_by_default_identity_is_not_generated) creates a table with all four shapes and asserts is_generated is present only for ALWAYS identity and stored generated — absent for BY DEFAULT and plain. Verified passing against PostgreSQL 16.

Closes #224

#223 added `a.attidentity IN ('a', 'd')` to the is_generated check in all
four get_columns queries. `attidentity = 'd'` is GENERATED BY DEFAULT AS
IDENTITY, which accepts explicit values — only `'a'` (ALWAYS) rejects
them. Marking BY-DEFAULT identity columns as is_generated blocked table
copy for the common case of a BY-DEFAULT identity primary key.

Fix: change `IN ('a', 'd')` to `= 'a'` in all four queries (metadata.rs
lines 167, 241, 772, 1404). is_auto_increment stays true for both.

Live test: creates a table with all four identity/generated shapes (BY
DEFAULT identity PK, ALWAYS identity, stored generated, plain column)
and asserts is_generated is present only for ALWAYS identity and stored
generated — absent for BY DEFAULT and plain.

Co-Authored-By: Adam J Esslinger <esslinger@gmail.com>
#224)

The ensemble review found 3 of 4 is_generated SQL query sites had zero
test coverage for the = 'a' change. Add 3 live tests:

1. get_schema_snapshot_by_default_identity_is_not_generated — exercises
   fetch_all_columns (line 1404) via get_schema_snapshot; asserts the
   same 4 identity/generated shapes as the get_columns test.

2. get_view_columns_never_reports_is_generated — exercises get_view_columns
   (line 772, the COALESCE/LEFT JOIN path); verifies no view column is
   marked is_generated (views can't have identity/generated columns).

3. get_materialized_view_columns_never_reports_is_generated — exercises
   fetch_materialized_view_columns (line 241); same assertion for
   materialized views.

All 4 paths now have dedicated live tests. Verified passing against
PostgreSQL 16.

Co-Authored-By: Adam J Esslinger <esslinger@gmail.com>
@aesslinger
aesslinger merged commit da5849a into main Dec 3, 2026
7 checks passed
@aesslinger
aesslinger deleted the fix/issue-224-by-default-identity-is-generated branch December 3, 2026 13:48
aesslinger added a commit that referenced this pull request Dec 3, 2026
Bumps version to 1.0.0-rc.16 in .tabularium, Cargo.toml, Cargo.lock, and
the CHANGELOG. This release includes manual commit mode (#219), the
read_rows server-text read path (#225, #227), and the copy fixes from
#220/#221, #222/#223 and #224/#226. Known limitations: money[] locale text
form and composite types named like built-ins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request prerelease:rc Version suggestion targets a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in #223: GENERATED BY DEFAULT identity columns reported is_generated, blocking table copy (fix before rc.16)

1 participant