jrgemignani opened a new pull request, #2403:
URL: https://github.com/apache/age/pull/2403

   Fix upgrade test: replace data-integrity checks with catalog comparison
   
   The age_upgrade regression test (added in #2364, improved in #2377, #2397) 
was designed to validate the upgrade template (age--<VER>--y.y.y.sql) by 
creating graph data before the upgrade and verifying it survived afterward. 
This approach had two fundamental problems:
   
   1. It did not detect incomplete upgrade templates. The test verified that 
graph data (vertices, edges, checksums, GIN indexes) survived ALTER EXTENSION 
UPDATE, but never checked whether new SQL objects (functions, views, relations) 
were actually created by the template. A developer could add a new function to 
sql/ and sql_files, forget to add it to the upgrade template, and all tests 
would pass — the function existed via the fresh CREATE EXTENSION install that 
ran before the upgrade test, but would be missing for users who upgraded via 
ALTER EXTENSION UPDATE.
   
   2. The data-integrity checks relied on cypher queries (MATCH/RETURN) within 
the same backend session after DROP EXTENSION + CREATE EXTENSION. This caused 
intermittent failures on some PostgreSQL versions where AGE's internal type 
cache (agtype OID) was not properly refreshed after the extension was dropped 
and recreated, resulting in 'type with OID 0 does not exist' errors. The 
data-integrity aspect was also redundant — ALTER EXTENSION UPDATE runs DDL 
statements and does not touch heap data, so data survival is guaranteed by 
PostgreSQL and not a meaningful test.
   
   The fix replaces the entire test with a catalog comparison approach:
   
     1. Snapshot ag_catalog's functions (pg_proc) and relations (pg_class) from 
the fresh install (the --load-extension=age default version).
     2. DROP EXTENSION, CREATE EXTENSION at the synthetic initial version, then 
ALTER EXTENSION UPDATE to the current version via the stamped upgrade template.
     3. Snapshot the catalog again after upgrade.
     4. Compare: any function or relation present in the fresh snapshot but 
missing after upgrade means the template is incomplete. Any object present 
after upgrade but not in the fresh snapshot means the template creates 
something unexpected.
   
   This approach:
     - Catches the actual failure mode: incomplete upgrade templates.
     - Uses only plain SQL catalog queries — no cypher, no .so cache issues.
     - Works reliably across all PostgreSQL versions.
     - Reports the exact missing/extra object name in the diff output.
     - Is simpler: 130 lines of SQL vs 306, no graph data setup needed.
   
   Makefile: updated step 5 comment to reflect catalog comparison approach.
   
   All 33 regression tests pass.
   
   modified:   Makefile
   modified:   regress/expected/age_upgrade.out
   modified:   regress/sql/age_upgrade.sql


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to