| From: | Lakshmi N <lakshmin(dot)jhs(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org, dean(dot)a(dot)rasheed(at)gmail(dot)com, peter(at)eisentraut(dot)org |
| Subject: | Show VIRTUAL keyword for virtual generated columns in pg_dump and psql |
| Date: | 2026-04-13 08:22:07 |
| Message-ID: | CA+3i_M8Rj0yEA5rRbWjobNbcZsB0MExfZbKV-mkWwFeyRvanCw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Adding Peter and Dean based on the recent commit history for generated
columns.
pg_dump and psql's \d currently display stored and virtual generated
columns asymmetrically:
s_total integer GENERATED ALWAYS AS ((a + b)) STORED
v_total integer GENERATED ALWAYS AS ((a + b))
Since VIRTUAL is default most likely this was omitted but with this
puts the burden on the reader to identify whether it is STORED or
VIRTUAL since both kinds coexist in v19.
The attached patch adds the VIRTUAL keyword to the output of both
pg_dump and psql \d, so the display becomes:
s_total integer GENERATED ALWAYS AS ((a + b)) STORED
v_total integer GENERATED ALWAYS AS ((a + b)) VIRTUAL
The fix is three one-line changes:
- src/bin/pg_dump/pg_dump.c: append " VIRTUAL" instead of bare ")"
- src/bin/psql/describe.c: same for \d display
- src/bin/pg_dump/t/002_pg_dump.pl: update TAP test regex
The parser already accepts the VIRTUAL keyword, so pg_dump output
round-trips correctly (dump -> restore -> \d shows identical schema).
I verified this with a CTAS + dump + restore cycle.
Regards,
Lakshmi
| Attachment | Content-Type | Size |
|---|---|---|
| show-virtual-keyword.patch | application/octet-stream | 29.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-04-13 08:30:39 | Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value) |
| Previous Message | JoongHyuk Shin | 2026-04-13 08:21:39 | [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks |