Skip to content

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

@Oaktribe

Description

@Oaktribe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions