| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com> |
| Subject: | Re: Fix domain fast defaults on empty tables |
| Date: | 2026-06-06 12:41:32 |
| Message-ID: | 203a49c2-52e4-49ab-b644-ef6044266145@dunslane.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-06-05 Fr 10:08 AM, Tom Lane wrote:
> Heikki Linnakangas<hlinnaka(at)iki(dot)fi> writes:
>> On 5 June 2026 10:48:00 EEST, Chao Li<li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>>> evantest=# create domain d_div as int check (1 / (value - 1) > 0);
>>> CREATE DOMAIN
>>> evantest=# create table t (a int);
>>> CREATE TABLE
>>> evantest=# alter table t add column b d_div default 1;
>>> ERROR: division by zero
>> It seems totally reasonable to get an error in that case. '1' is not a valid value for the datatype, whether or not there are any rows in the table.
> I think there's reason for concern here, which is that we do not throw
> an error for the apparently equivalent case
>
> regression=# create table t2 (a int, b d_div default 1);
> CREATE TABLE
>
> This will give you an error at INSERT, but not CREATE. So this
> is inconsistent, as well as different from the pre-v19 behavior.
>
> Concretely, I'm pretty sure it is a hazard for pg_dump, which thinks
> it can freely transform bits of CREATE operations into ALTERs.
> I didn't try to make an example case, but I suspect it is now possible
> to create a database that will fail dump/restore because of this
> inconsistency.
>
>
Seems reasonable. So which of Chao's solutions do you prefer? I think
both will meet the pg_dump issue, not sure how much we care about the
case where we have deleted all the rows but not truncated the table.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Xuneng Zhou | 2026-06-06 12:56:10 | Re: t/035_standby_logical_decoding.pl might fail on attempt to read wrong timeline |
| Previous Message | Erik Rijkers | 2026-06-06 12:36:24 | Re: pgsql: doc: Clarify OAuth validator authn_id logging |