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)
[email protected]
www.highgo.ca



Reply via email to