Fix collation/ctype query error for non-default LC_COLLATE (#9798)#10040
Fix collation/ctype query error for non-default LC_COLLATE (#9798)#10040dpage wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 7 minutes and 24 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR introduces pgAdmin 4 version 9.16 release documentation and fixes a critical SQL bug affecting database collation field handling. A nested ChangespgAdmin 9.16 Release with Collation Provider Fix
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
bb8fa3d to
4025de4
Compare
…rg#9798 get_ctypes.sql for PG 16+/17+ wrapped a multi-row UNION inside a scalar subquery in a CASE ELSE branch. When the database is not ICU-based and datcollate != datctype (e.g. LC_COLLATE=C with a different ctype), the scalar subquery returned two rows -> "more than one row returned by a subquery used as an expression", which locked the collation input. Rewrite as a flat UNION of guarded SELECTs returning cname rows, matching how the handler already consumes the result (a list of rows). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4025de4 to
f1a2cf2
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a PostgreSQL 16+ / 17+ SQL-template bug that could raise “more than one row returned by a subquery used as an expression” when a database has non-default LC_COLLATE/LC_CTYPE, preventing pgAdmin from populating/unlocking the collation/ctype fields in the database create/edit UI.
Changes:
- Rewrote
get_ctypes.sqlfor PG 16+ and 17+ to return rows via guardedUNIONselects (instead of a scalar subquery in aCASEexpression). - Added a 9.16 release note entry referencing Issue #9798.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/16_plus/get_ctypes.sql | Avoids scalar-subquery multi-row errors by returning locale/ctype values as a simple row set. |
| web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/get_ctypes.sql | Same fix as 16+, using the PG 17+ column layout. |
| docs/en_US/release_notes_9_16.rst | Documents the bug fix in the 9.16 release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes #9798.
Creating/editing a database with a non-default
LC_COLLATE/LC_CTYPE(e.g.LC_COLLATE=C) failed withmore than one row returned by a subquery used as an expression, which locked the collation input.Root cause:
get_ctypes.sql(PG 16+ and 17+) wrapped a multi-rowUNIONinside a scalar subquery in aCASE ... ELSEbranch. For a non-ICU database wheredatcollate != datctype, that branch returns two rows → scalar-subquery error.Fix: rewrite as a flat
UNIONof guardedSELECTs returningcnamerows (keyed ondatlocprovider), which is exactly what theget_ctypeshandler already expects (it iteratesrset['rows']). This mirrors the pre-16defaulttemplate's flat shape.Changes
databases/sql/16_plus/get_ctypes.sql,databases/sql/17_plus/get_ctypes.sql🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Bug Fixes