Repository navigation
Schema change: tested on PostgreSQL 12 to 18, and a row count fix for 12 and 13 - #4
Merged
Merged
Conversation
… of 0 has an unknown row count PostgreSQL 14 stores -1 in pg_class.reltuples for a table nobody has analyzed; 12 and 13 store 0, which read as an empty table. The catalog, the facts and the health report now treat 0 on a table whose file is not empty as unknown on those versions, so a large never-analyzed table is no longer reported as empty and the 'never analyzed' finding appears.
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.
What changed
The schema change compiler says it is written for PostgreSQL 12 or newer, but had only been tested on 16. This runs the real-PostgreSQL checks (
scripts/schema-change-pg16.ts, 14 sections) against 12, 13, 14, 15, 16, 17 and 18 and fixes what that showed.One product bug. Before PostgreSQL 14,
pg_class.reltuplesis 0, not -1, for a table nobody has analyzed, so it read as an empty table. On 12 and 13 a large never-analyzed table was reported as 0 rows and the health report's "never analyzed" finding did not appear. On those versions, 0 on a table whose file is not empty is now treated as unknown (row-estimate.ts, used bycatalog.ts,facts.tsandhealth.ts). Behaviour on 14 and later is unchanged.Everything else that failed was the test script assuming PostgreSQL 16 (SQL-body functions need 14,
DROP DATABASE ... WITH (FORCE)needs 13,gen_random_uuid()is built in from 13, PostgreSQL 18 stores NOT NULL as a constraint of its own, the statistics views lag before 15). The script was made version-aware; those changes are in the local script, not in this diff.How it was checked
Reviewer notes
scripts/schema-change-pg16.tsandscripts/lib/are still not in the repository, so the version matrix itself is not reproducible from this branch yet.