Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0Wr5-001yx8-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 03:36:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0Wr3-00D85P-1n for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 03:36:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0Wr3-00D85H-0t for pgsql-hackers@lists.postgresql.org; Thu, 12 Mar 2026 03:36:57 +0000 Received: from mail-vs1-xe36.google.com ([2607:f8b0:4864:20::e36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0Wr1-00000001iB3-2US7 for pgsql-hackers@postgresql.org; Thu, 12 Mar 2026 03:36:56 +0000 Received: by mail-vs1-xe36.google.com with SMTP id ada2fe7eead31-5ffc879c1aeso372940137.2 for ; Wed, 11 Mar 2026 20:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773286615; cv=none; d=google.com; s=arc-20240605; b=KU5M9CqHHqNgneceNSUTZhidwSJX0JqTKeru1+I/YNLv+4YUeVxLomSl67viorEDqd hjDpqPp7Og276JZDPVA+l1EUTBa4BuNrHJuunYLkqN+/yybBTh3ML8NCDrnP57LBNKq1 ljwVabguyGUk9kTMnsqSZ1AxmA5VN0VLfROzMaMJ/lHqmv+9wbFn0tdp6KkYDYb1u4/0 20v+MP6ocajhI8idqdUUofM4PWBOvsP2IVzcHW+Fy4xgyl8PjMbsNsf2JUf1dk/nkxaY R4g/OZIyEayic42mD0Kxj0ugq6s5GPKIklYvhO3OT9/UZJ+Qp2pyVc6/2gxsvQ1cd5gU dZog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jpsej8lNfhRmmszvrB/T8yNapeYxbk2mXJ5WImDfVVo=; fh=ApMVyRQ+gnZY0C3xPb/38Qq7df1Kufv06EO3qEoWvmg=; b=d0zbZm/xDnu38nKDI1f8zBcYpY7zVeKynwNpUW45o315WCBTmBARHuYo5hXkm0iPL4 idtnUsSfnNNHLSOZLStVdP7kQm5LhS6UZwYTTsjWe3X9dV0HtvhDWH8704ScSKPuOq+o CU6AO4tvUZ2YV+JCvGucq1nJPOpNidYzSFt7GnZOGdlz/FIPenOVpF1Du23pzuUqH7Tw 22bWD8EBeno6rtAxRnt3SKdGjd7GjFDWrm8PE/yNWf0ph5edOr/i+EY3RuE7WA0hq13g JZl8tob35aOzJBFOytrscE//D3Z0rxa44G/pdV06HN2IfxDtOkfEmSOUMVcbsLwJJ99f VcYA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773286615; x=1773891415; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jpsej8lNfhRmmszvrB/T8yNapeYxbk2mXJ5WImDfVVo=; b=XLCBEYM8oGJV/VNdINBB9XdYrPmhPLduD2giv1JZ3jJf3pom4v17xHCsVhUlaDMKU5 V6vIEBPZ56NmVO89XJdnOL8zq7sTatpom4RShf5PnBNahu6F49xxrFw7v/f7nxseS91h EOUHH4pwZqbOYwOejD5st7kTCHaj5sRUeFQbP8fAmtkTnnAZUA7bxyZCdHuoGZblJZPW nVdCvbfqjS4fIxZRFP+cowhLFT8tSAXkFTC55ztoSVyGJECpASFv9+Dc27u5Kf3vm2zf 4bfYggl/VqdtGPC5jBMBrV6vcBTXzQapuTuXKOWDjWF1FrbAgmhEL173nu/cL3qY/cc8 MZFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773286615; x=1773891415; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jpsej8lNfhRmmszvrB/T8yNapeYxbk2mXJ5WImDfVVo=; b=sHM7WS3tEChIIqO1mZm9qgRucuSC9MoCcNDjYnsUZXjHgwxJoc7bmhHdWgs9Vo/ulo lf/Y0HNjGimHDYRRre035OMOi6T25SGlFQUMJ6boVmjWk4dEN3UJ1a2P2oXa8EafF1+C hR48oDITHAtc3ac6JzIEZTHsZXn62LA4oIBiRkC4gZBWQvRGP2qqOtMNtCy9uLGAHvYf k5FC2l7N65GqYcmQvANqLCM9iibahAagtM7qCXgVFnCQbaWw+2T2K1GIlmM5onon+jXS MeL2+/K8eN0cjM1Q3kxbkO1E2p1OwIF711ajIazgEMqItKbzMIqZ7izuUIhJG/QQ4if5 cXsA== X-Gm-Message-State: AOJu0Yxctj0WiU2fiQsteyEVwgIQkujHtFSrmO/r415gEM11vygBixeg P4kHUbEmRIOwTLQtIBDX+J5TaI0ex/UwH5qOTmuL4/YvBS6vU3zh1/QLFg4qdaT3qJ0atVxu3ZO e3YMEAJRI9s410Xomoy4STZKvdnJxA3q+oKnF5F3WVQ== X-Gm-Gg: ATEYQzyFktFAQpHOuh/Fhl8LbQxydOd1qPxx/mugdZaqMItJeJPHVBG0d79VwFpsYOe ME6JDhE4wUyjCtZtqZVtGsho4apGcOfgk7mKzw686B+aIoYk6C2QjYOO/3n7kwgMt46WO/sDt31 8mYjX35XMVoKUPwU+pn0eK3WywPyqzZ9MBhGUB9mfh/iHs8pb6GxnPfNIGRlsaG9P7+98Zl4Bq3 TczuehlmEpQwytVKZAzFjV3vY0K0dJvDZ+EvdjavFyfhbdqtWegIucRC5l8OqosKfXtX7x3UFo8 SXls8J/Wri154m/REsDLQ5gHkJiEzLZd5bT9KbPjKc1j63VBb2eZLBlLFzMO4oBOqV5Z0sot0Px QGMwracARWlgGAe3vtDQENDbQFbCGBqqwpc0l4Kq567ijjWfiwWPmi4P5HuBbdm0DJfAymlcu+W cRaQhchU9W8B3DXTrGExPCmg== X-Received: by 2002:a05:6102:3588:b0:5f8:e2eb:43d with SMTP id ada2fe7eead31-601ded2f067mr2297083137.10.1773286614838; Wed, 11 Mar 2026 20:36:54 -0700 (PDT) MIME-Version: 1.0 References: <229413.1741144420@sss.pgh.pa.us> <5a8c55ea-81d3-47f4-aff9-a89fabcc2304@Spark> <31d12caf-17d8-4ab7-af58-ec3c5a310a92@dunslane.net> In-Reply-To: <31d12caf-17d8-4ab7-af58-ec3c5a310a92@dunslane.net> From: jian he Date: Thu, 12 Mar 2026 11:36:19 +0800 X-Gm-Features: AaiRm51VmASPKyZmoRCRevHPoCcsbMYPnRIdLqJxqWZoxrjk4JllRLYh7txZiNs Message-ID: Subject: Re: support fast default for domain with constraints To: Andrew Dunstan , Viktor Holmberg Cc: PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 12, 2026 at 3:50=E2=80=AFAM Andrew Dunstan wrote: > Also added some tests. V11 looks good to me. On Wed, Mar 11, 2026 at 6:34=E2=80=AFPM Viktor Holmberg wro= te: > > I=E2=80=99ve been burned my this issue in the past so would be great if t= his could get in. > > + /* > + * If the domain has volatile constraints, we must do a table rewrite > + * since the constraint result could differ per row and cannot be > + * evaluated once and cached as a missing value. > + */ > + if (has_volatile) > + { > + Assert(has_domain_constraints); > + tab->rewrite |=3D AT_REWRITE_DEFAULT_VAL; > + } > > I'm not sure. But seems to me this makes the pre-existing guard for virtu= al columns > redundant? > I mean this code on line 7633: > if (colDef->generated !=3D ATTRIBUTE_GENERATED_VIRTUAL) > tab->rewrite |=3D AT_REWRITE_DEFAULT_VAL; > If the first `if (has_volatile)` is false, then > if (colDef->generated !=3D ATTRIBUTE_GENERATED_VIRTUAL) > tab->rewrite |=3D AT_REWRITE_DEFAULT_VAL; is still reachable. > Also, perhaps virtual generated columns could use a test? Virtual generated columns based on domain are not currently supported. I have a patch for it: https://commitfest.postgresql.org/patch/5725 but it's not doable now because of https://git.postgresql.org/cgit/postgresql.git/commit/?id=3D0cd69b3d7ef357f= 2b43258de5831c4de0bd51dec You may also be interested in https://commitfest.postgresql.org/patch/5907 -- jian https://www.enterprisedb.com/