| From: | Cary Huang <cary(dot)huang(at)highgo(dot)ca> |
|---|---|
| To: | "Tatsuro Yamada" <yamatattsu(at)gmail(dot)com> |
| Cc: | "Álvaro Herrera" <alvherre(at)kurilemu(dot)de>, "Chao Li" <li(dot)evan(dot)chao(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Jim Jones" <jim(dot)jones(at)uni-muenster(dot)de>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] psql: add \dcs to list all constraints |
| Date: | 2026-06-10 18:50:44 |
| Message-ID: | 19eb2df5fa0.43034f3c3151107.3042967838443745451@highgo.ca |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi
The newly added \dCN meta-command in psql does return all constraints correctly,
but it does not properly filter by table name. When a table name is provided as
an argument, the command returns empty results instead of matching constraints
on that table. For example:
-- Setup
CREATE TABLE con_test_table (
id INT PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
-- List all constraints (works correctly)
\dCN
-- List constraints on specific table (returns empty)
\dCN con_test_table
-- Match by constraint name (works correctly)
\dCN con_test_table_pkey
To fix, in "src/bin/psql/describe.c", in the `listConstraints()` function, change:
```
if (!validateSQLNamePattern(&buf, pattern,
true, false,
"n.nspname", "cns.conname", NULL,
NULL, NULL, 3))
```
To:
```
if (!validateSQLNamePattern(&buf, pattern,
true, false,
"n.nspname", "cns.conname", "c.relname",
NULL, NULL, 3))
```
to allow the pattern to match against table names as well.
thanks
Cary Huang
-------------
HighGo Software (Canada)
cary(dot)huang(at)highgo(dot)ca
www.highgo.ca
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-06-10 19:16:17 | fix prev link in docs |
| Previous Message | Andres Freund | 2026-06-10 18:03:37 | Re: [PATCH v5] pg_stat_statements: Add last_execution_start column |