Skip to content

fix(s3vectors): use correct exception condition for duplicate function on upgrade #581

Draft
samrose wants to merge 1 commit intomainfrom
s3vec-migration-fix
Draft

fix(s3vectors): use correct exception condition for duplicate function on upgrade #581
samrose wants to merge 1 commit intomainfrom
s3vec-migration-fix

Conversation

@samrose
Copy link

@samrose samrose commented Feb 28, 2026

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.

Copilot AI review requested due to automatic review settings February 28, 2026 12:52
@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7633d56 and cbaf7b6.

📒 Files selected for processing (1)
  • wrappers/build.rs

📝 Walkthrough

Summary by CodeRabbit

Bug Fixes

  • Improved error handling in SQL extension generation to correctly detect and manage duplicate functions, preventing failures during database extension operations.

Walkthrough

The change modifies SQL exception handling in the build script responsible for generating wrapper functions. Specifically, it updates the exception handlers for s3vec_in and s3vec_out function creation, replacing duplicate_object with duplicate_function in the EXCEPTION clauses. This correction ensures the generated SQL properly handles the scenario where these wrapper functions already exist during extension creation.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_in and CREATE FUNCTION s3vec_out to catch duplicate_function (SQLSTATE 42723) instead of duplicate_object (42710).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samrose samrose marked this pull request as draft February 28, 2026 12:58
@samrose
Copy link
Author

samrose commented Feb 28, 2026

building this locally as a tmp patch in the package to see if it works first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants