| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: refactor AlterDomainAddConstraint (alter domain add constraint) |
| Date: | 2025-11-26 05:07:50 |
| Message-ID: | CACJufxEjHnT9S22nXXqiC1JSJiJF8K7oHUbtBETviBBOBDL4Pw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Nov 24, 2025 at 10:45 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 10.03.25 19:37, Alvaro Herrera wrote:
> >
> > I had forgotten this thread, and I ended up implementing a different
> > solution for this issue, which I just posted at
> > https://postgr.es/m/202503101758.ipn3g64twfye@alvherre.pgsql
> >
> > I like my patch better than this approach because it allows us to solve
> > the same problem as it appears in other parts of the grammar, and also
> > because it avoids the bit fiddling which is harder to maintain later on.
> > If you'd care to have a look at it, I'd appreciate it.
>
> Where are we on this? Which of the two patches should we pursue?
>
hi.
if you go to this link
https://postgr.es/m/202503101758.ipn3g64twfye@alvherre.pgsql
check v2-0001-Improve-processCASbits-API-with-a-seen-struct.patch
you will find that it added a struct CAS_flags to processCASbits.
+typedef struct CAS_flags
+{
+ bool seen_deferrability;
+ bool seen_enforced;
+ bool seen_valid;
+ bool seen_inherit;
+} CAS_flags;
In v2-0001, most of the case processCASbits just pass a NULL CAS_flags(seen).
CAS_flags are not used in table constraints at all.
but CAS_flags indeed used for error message handling in ALTER DOMAIN
ADD CONSTRAINT.
(IMHO, it looks like big efforts to solve the same problem, also these bit
fiddling for domain constraint unlikely to change in the future, e.g. we are
unlike to add DEFERRABLE, INITIALLY DEFERRED, NO INHERIT constraints to domain.)
anyway, both patches are attached.
this thread: v5-0001-ALTER-DOMAIN-ADD-CONSTRAINT-error-message-enhance.patch
thread: https://postgr.es/m/202503101758.ipn3g64twfye@alvherre.pgsql
v5-0001-Improve-processCASbits-API-with-a-seen-struct.no-cfbot
v5-0002-handle-constraints-on-domains-too.no-cfbot
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-ALTER-DOMAIN-ADD-CONSTRAINT-error-message-enhance.patch | text/x-patch | 9.1 KB |
| v5-0001-Improve-processCASbits-API-with-a-seen-struct.no-cfbot | application/octet-stream | 10.5 KB |
| v5-0002-handle-constraints-on-domains-too.no-cfbot | application/octet-stream | 7.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Corey Huinker | 2025-11-26 05:14:26 | Re: Extended Statistics set/restore/clear functions. |
| Previous Message | shveta malik | 2025-11-26 05:01:21 | Re: Improve pg_sync_replication_slots() to wait for primary to advance |