yuqi1129 opened a new pull request, #13922:
URL: https://github.com/apache/gravitino/pull/13922

   ### What changes were proposed in this pull request?
   
   Fix deletion of PostgreSQL constraint-backed primary-key and unique indexes 
by issuing only `ALTER TABLE ... DROP CONSTRAINT`. [PostgreSQL automatically 
removes the backing index with the 
constraint](https://www.postgresql.org/docs/current/sql-altertable.html), so a 
second `DROP INDEX` incorrectly fails after the constraint has been dropped.
   
   Apply `IF EXISTS` to `DROP CONSTRAINT` when requested. Add non-Docker 
SQL-generation coverage for strict, optional, and defaulted requests; correct 
the existing SQL expectations; add catalog integration coverage for both index 
types with `ifExists` unset, false, and true, including repeated deletion.
   
   ### Why are the changes needed?
   
   Deleting a primary-key or unique constraint-backed index currently fails 
unless `ifExists=true`, because the generated SQL attempts to drop its backing 
index twice. A missing constraint also incorrectly fails with `ifExists=true`, 
because that flag is applied only to the second statement.
   
   This fixes indexes represented by PostgreSQL constraints, including those 
created by Gravitino. Support for native standalone `CREATE UNIQUE INDEX` 
objects is outside this change.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Deleting an existing constraint-backed index succeeds with the default 
`ifExists=false`, while `ifExists=true` correctly ignores an absent constraint. 
Strict requests still fail when the constraint is absent. No API or 
configuration changes.
   
   ### How was this patch tested?
   
   - All 50 PostgreSQL catalog non-Docker unit tests passed.
   - Spotless checks and `git diff --check` passed.
   - Five focused PostgreSQL 13 Docker tests passed: three new 
nullable/false/true request cases, the existing mixed-alter catalog test, and 
the updated legacy SQL expectations.
   - All 7 existing `TestTableUpdatesRequest` tests passed, including JSON 
deserialization with `ifExists` omitted.
   - Temporarily restoring the old production implementation made all three new 
catalog integration cases fail with the original missing-index/constraint 
errors; restored the fix and reran all 50 module unit tests successfully.
   


-- 
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