Conversation
Fixed issue where CREATE EXTENSION pg_background WITH SCHEMA <schema> would fail because SQL scripts hardcoded 'public.' schema prefix. Changes: - Replace all hardcoded 'public.' with '@extschema@' which PostgreSQL substitutes with the actual target schema at installation time - Update grant/revoke helper functions to dynamically lookup the extension's schema from pg_extension catalog at runtime - Fixed in pg_background--1.7.sql, pg_background--1.8.sql, and pg_background--1.7--1.8.sql upgrade script The extension is marked relocatable=true in the control file, so it should support installation in any schema. This fix ensures that works correctly. Example that now works: CREATE SCHEMA contrib; CREATE EXTENSION pg_background WITH SCHEMA contrib; Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add "Custom Schema Installation" section in Installation guide - Document schema-qualified function calls - Add 6 test cases for custom schema functionality - Add troubleshooting entry for the fixed schema bug - Update migration guide for v1.7 with custom schema fix note - Update Key Features with relocatable extension support - Update Last Updated date Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PostgreSQL does not substitute @extschema@ for relocatable extensions. For relocatable=true extensions, objects should use unqualified names and PostgreSQL automatically places them in the target schema. Changes: - Remove @extschema@ prefix from CREATE TYPE statements - Remove @extschema@ prefix from RETURNS clauses - Remove @extschema@ prefix from SELECT and REVOKE statements - Add comprehensive relocatable schema test suite (16 test cases) - Add test-relocatable.sh for Docker-based testing The extension now properly supports: - CREATE EXTENSION pg_background WITH SCHEMA custom; - Schema-qualified function calls - Dynamic schema detection in privilege helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Updated the migration guide to accurately describe the fix for relocatable extensions - using unqualified names rather than @extschema@ substitution (which doesn't work for relocatable=true). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive support for relocatable schema installation to the pg_background extension, allowing it to be installed in custom schemas rather than only in the public schema. The changes remove hardcoded public. schema references and implement dynamic schema detection for privilege management functions.
Changes:
- Removed hardcoded
public.schema prefixes from type definitions and function return types in v1.7 and v1.8 SQL scripts - Added dynamic schema lookup to privilege helper functions (
grant_pg_background_privilegesandrevoke_pg_background_privileges) - Created comprehensive test suite for validating relocatable schema functionality with Docker-based testing infrastructure
- Updated README with custom schema installation documentation, examples, and troubleshooting guidance
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pg_background--1.8.sql | Removed public. prefixes from type definitions and added dynamic schema detection to privilege helpers for v1.8 base installation |
| pg_background--1.7.sql | Removed public. prefixes from type definitions and added dynamic schema detection to privilege helpers for v1.7 base installation |
| pg_background--1.7--1.8.sql | Updated upgrade script with schema-agnostic type definitions and dynamic schema detection in updated privilege helpers |
| test-relocatable.sh | New Docker-based test script that validates extension functionality when installed in custom schemas |
| sql/pg_background_relocatable.sql | Comprehensive test suite covering all v1/v2 API functions, types, and privilege helpers with schema qualification |
| README.md | Added custom schema installation guide, usage examples, test cases, and troubleshooting documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Clarify that custom schema support is only for fresh installs of v1.7+ - Document that upgrade scripts for v1.4, v1.5, v1.6 have hardcoded public. references - Add instructions for relocating existing installations to custom schema - Update troubleshooting section with upgrade limitations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The \gset command assigns column values to variables. When a query returns a composite type, it must be expanded before \gset to create individual variables for each field. Changed from: SELECT * FROM ... AS h \gset ... :'\''h.pid'\'', :'\''h.cookie'\'' To: SELECT (h).pid, (h).cookie FROM ... AS h \gset ... :pid, :cookie Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixes for relocatable schema