fix(s3vectors): use correct exception condition for duplicate function on upgrade #581
fix(s3vectors): use correct exception condition for duplicate function on upgrade #581
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Disabled knowledge base sources:
📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbitBug Fixes
WalkthroughThe change modifies SQL exception handling in the build script responsible for generating wrapper functions. Specifically, it updates the exception handlers for Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes extension upgrade failures for existing installations by catching the correct PostgreSQL exception when s3vec_in/s3vec_out already exist with the same signature.
Changes:
- Update PL/pgSQL exception handlers for
CREATE FUNCTION s3vec_inandCREATE FUNCTION s3vec_outto catchduplicate_function(SQLSTATE 42723) instead ofduplicate_object(42710).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
building this locally as a tmp patch in the package to see if it works first |
When upgrading wrappers on an existing installation that already has the S3Vec type (introduced in 0.5.5), ALTER
EXTENSION wrappers UPDATE TO '0.6.0' fails with:
ERROR: function "s3vec_in" already exists with same argument types
The previous fix (#580) wrapped each CREATE statement in a nested BEGIN/EXCEPTION block to handle the case where
S3Vec objects already exist. However, the exception handlers for the CREATE FUNCTION sub-blocks used EXCEPTION WHEN
duplicate_object THEN NULL, which catches SQLSTATE 42710.
PostgreSQL raises SQLSTATE 42723 (duplicate_function) when a function already exists with the same argument types,
not duplicate_object (42710). These are sibling conditions in class 42 and neither subsumes the other. As a result,
the exception handler for the s3vec_in and s3vec_out sub-blocks never fired and the error propagated up, failing the
upgrade.
This fix changes the exception condition for the two CREATE FUNCTION sub-blocks (s3vec_in and s3vec_out) from
duplicate_object to duplicate_function. The CREATE TYPE sub-blocks (shell type and full type definition) correctly
use duplicate_object and are unchanged.