| From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Henson Choi <assam258(at)gmail(dot)com>, Peter <peter(at)eisentraut(dot)org>, Vik Fearing <vik(at)postgresfriends(dot)org>, Amul Sul <sulamul(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |
| Date: | 2026-11-06 06:37:00 |
| Message-ID: | CADkLM=fUkbJzzFOvZyEKL9mJePU5EJe4=sb9FFD_CkMbeghTCA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
>
>
> I'm going to stop there for now.
>
Contrary to my previous statement, I wasn't able to leave things be, and I
started asking Claude about the compiler warnings, and then further asked
about the ability to enforce short-circuiting (i.e. must evaluate the
expression to be cast-ed and raise any errors found, must not evaluate the
default expression until the value expression has correctly evaluated and
the cast itself failed). This resulted into two patches that I've added to
the existing patchset.
Patches 0001-0003 are the v34 patches, unchanged.
Patch 0004 is about removing the unassigned variables warnings (and some
regressions tests that fail because of it). The LLM's solution was to move
the two new node type cases from the main switch into the default switch.
Patch 0005 address requiring errors in the value expression not be ignored,
but also to only evaluate the default expression if the cast operation
itself failed. I'm unsure that adding no_eval
to eval_const_expressions_context is the right way to go about it as there
might be a more established pattern for doing such things, but it does
appear to resolve all the issues I had with the behavior of the new feature.
Obviously we want to give this generated code a lot of scrutiny, but it at
least demonstrates that the desired behavior as I see it is at least
possible. Whether or not my idea of the expected behavior matches other's
expectations is still up for debate, obviously.
| Attachment | Content-Type | Size |
|---|---|---|
| v35-0005-WIP-Short-circuit-default-of-CAST-DEFAULT-ON-CON.patch | application/octet-stream | 12.8 KB |
| v35-0001-error-safe-for-casting-text-to-other-types-per-p.patch | application/octet-stream | 9.5 KB |
| v35-0003-CAST-expr-AS-newtype-DEFAULT-expr-ON-CONVERSION-.patch | application/octet-stream | 162.7 KB |
| v35-0002-introduce-pg_proc.proerrorsafe.patch | application/octet-stream | 67.0 KB |
| v35-0004-WIP-Reorganize-Safe-Cast-operations-to-avoid-uni.patch | application/octet-stream | 2.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Sharma | 2026-11-06 07:04:03 | Re: log XLogPrefetch stats at end of recovery |
| Previous Message | Xuneng Zhou | 2026-11-06 06:33:52 | Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring |