pgadmin-org / pgadmin-org/pgadmin4

Using LC_COLLATE=C locks collaction input when creating/editing database due to SQL error

Open
#9,798 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Python
Stars
3.8k
Forks
891
Avg merge
4d 7h
Merged PRs (30d)
8

Description

Describe the bug
Using LC_COLLATE=C locks the collation fields when creating or editing a database, due to the error more than one row returned by a subquery used as an expression.

I use LC_COLLATE=C make it default when creating databases to get expected sorting behavior. (BÅ i want, not ÅB)

To Reproduce
Basically what I use, login to pgadmin and create a new database or view properties of the default database, and you should see same errors as above.

version: '3.8'

services:
  db:
    restart: unless-stopped
    image: postgres:18.3
    shm_size: 128m
    ports:
      - 5432:5432
    environment:
      - POSTGRES_PASSWORD=test
      - TZ=Europe/Stockholm
      - LC_COLLATE=C

  manager:
    restart: unless-stopped
    image: dpage/pgadmin4:9.13
    ports:
      - 8080:8080
    environment:
      - PGADMIN_LISTEN_PORT=8080
      - PGADMIN_DEFAULT_EMAIL=test@test.com
      - PGADMIN_DEFAULT_PASSWORD=test
      - PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True

Expected behavior
To be able to change collation.

Error message
What I can see in the container logs when I open the create database dialog

2026-03-27 19:15:51.397 CET [62] ERROR:  more than one row returned by a subquery used as an expression
2026-03-27 19:15:51.397 CET [62] STATEMENT:  SELECT CASE WHEN datlocprovider = 'i' THEN
		(SELECT datlocale as cname FROM pg_database WHERE datname = current_database())
	ELSE
	    (SELECT datcollate as cname FROM pg_database WHERE datname = current_database()
	    UNION
	    SELECT datctype as cname FROM pg_database WHERE datname = current_database())
	END
	FROM pg_database WHERE datname = current_database();

Screenshots

Image

Desktop (please complete the following information):

  • OS: Debian 12 bookworm
  • pgAdmin version: 9.13
  • Mode: Server
  • Browser (if running in server mode): Firefox 149
  • Package type: Container

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the problem from the database create/edit dialog using PostgreSQL with LC_COLLATE=C, then inspect the SQL statement shown in the report. Trace how the collation fields are populated; done means the query no longer errors and the fields remain usable when creating or editing a database.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.