information_schema.domains reports an array domain as integer[] instead of ARRAY
Thread notes
1 note#bug
hackorum-bot#bug
@global #bug
information_schema.domains reports a domain over integer[] as integer[] instead of ARRAY
On PostgreSQL 19.0, a domain over integer[] is reported as integer[] by information_schema.domains.data_type. The PostgreSQL domains documentation (https://www.postgresql.org/docs/19/infoschema-domains.html) specifies ARRAY for an array domain. A scalar-domain control returns integer, and information_schema.columns reports the same array domain as ARRAY when used by a table column.
Reproduction
Run this script in a test database where the domain_array_demo schema does not already exist, using a clean psql -X session. The transaction rolls back the schema, domains, and table.
BEGIN;
CREATE SCHEMA domain_array_demo;
CREATE DOMAIN domain_array_demo.int4_array AS integer[];
CREATE DOMAIN domain_array_demo.scalar_int4 AS integer;
CREATE TABLE domain_array_demo.t (
plain_array integer[],
domain_array domain_array_demo.int4_array
);
SELECT domain_name, data_type, udt_name
FROM information_schema.domains
WHERE domain_schema = 'domain_array_demo'
ORDER BY domain_name;
SELECT column_name, data_type, domain_name, udt_name
FROM information_schema.columns
WHERE table_schema = 'domain_array_demo' AND table_name = 't'
ORDER BY ordinal_position;
ROLLBACK;
On PostgreSQL 19.0, two independent backend sessions returned:
domains:
domain_name | data_type | udt_name
------------+-----------+---------
int4_array | integer[] | _int4
scalar_int4 | integer | int4
columns:
column_name | data_type | domain_name | udt_name
-------------+-----------+-------------+---------
plain_array | ARRAY | | _int4
domain_array | ARRAY | int4_array | _int4
The same result was reproduced on PostgreSQL 18.7.
Expected behavior
For int4_array, information_schema.domains.data_type should be ARRAY, as specified by the domains view documentation (https://www.postgresql.org/docs/19/infoschema-domains.html). The scalar control should remain integer; the columns view already reports the array domain as ARRAY.
Source observation
In PostgreSQL 19.0, the domains view definition (https://github.com/postgres/postgres/blob/5c839a2a08b9b87a349be97371fac6c5a2873b10/src/backend/catalog/information_schema.sql#L966-L974) checks typelem on the domain row itself. For a domain over an array, the array type is reached through the domain's base type; the neighboring columns view handles that case separately.
Tested environment
- PostgreSQL 19.0 server and psql client (REL_19_0, commit 5c839a2a08b9b87a349be97371fac6c5a2873b10); PostgreSQL 18.7 also reproduced the result.
- Ubuntu 24.04, Linux kernel 7.0.0-38-generic, x86-64, GCC 13.3.0. Build options: --without-readline --without-zlib --without-icu --without-llvm.
- A fresh cluster was initialized with initdb --no-locale -E UTF8 --auth-local=trust --auth-host=reject and listened on a local socket only. Startup settings were listen_addresses='', port=55491, max_connections=20, and shared_buffers=32MB; the socket directory was local to the test environment. No other configuration was changed.