robozmey opened a new pull request, #901:
URL: https://github.com/apache/cloudberry/pull/901

   # Extension TRY_CONVERT adds function TRY_CONVERT
   
   TRY_CONVERT was made to use like [TRY_CAST from 
SQL-Server](https://learn.microsoft.com/ru-ru/sql/t-sql/functions/try-cast-transact-sql?view=sql-server-ver16)
   
   
   Due polymorphism have strange signature (some_type, anyelement) -> anyelement
   
   First parament is SOURCE_VALUE
   
   Second parameter is DEFAULT_VALUE::TARGET_TYPE
   
   ```
   TRY_CONVERT('42'::text, NULL::int2) -- returns 42::int2
   TRY_CONVERT('42d'::text, NULL::int2) -- returns NULL::int2
   TRY_CONVERT('42d'::text, 1234::int2) -- returns 1234::int2
   ```
   
   We cannot have (any1, any2) -> any2 signature with different anyelement 
types, but we can create multiple (_, any) -> any functions in 
`contrib/try_convert/try_convert--1.0.sql` or use `select 
add_type_for_try_convert('date'::regtype);` to add types.
   
   In init we can add all supported types, but with `add_type_for_try_convert` 
user can add whatever type he wants
   
   ## ERROR HANDLING
   
   Error handles by PG_TRY() PG_CATCH()
   
   But better way is use "soft" error handling from Postgres 17 
(https://github.com/postgres/postgres/commit/ccff2d20ed9622815df2a7deffce8a7b14830965)
 it also realising OPENGPDB 
(https://github.com/open-gpdb/gpdb/commit/21be3688729ec4468ffd083da197721860fa2cbd).
 Of course it needs to convert datatype function to support "soft" error 
handling
   
   
   <!-- Thank you for your contribution to Apache Cloudberry (Incubating)! -->
   
   Fixes #ISSUE_Number
   
   ### What does this PR do?
   <!-- Brief overview of the changes, including any major features or fixes -->
   
   ### Type of Change
   - [ ] Bug fix (non-breaking change)
   - [ ] New feature (non-breaking change)
   - [ ] Breaking change (fix or feature with breaking changes)
   - [ ] Documentation update
   
   ### Breaking Changes
   <!-- Remove if not applicable. If yes, explain impact and migration path -->
   
   ### Test Plan
   <!-- How did you test these changes? -->
   - [ ] Unit tests added/updated
   - [ ] Integration tests added/updated
   - [ ] Passed `make installcheck`
   - [ ] Passed `make -C src/test installcheck-cbdb-parallel`
   
   ### Impact
   <!-- Remove sections that don't apply -->
   **Performance:**
   <!-- Any performance implications? -->
   
   **User-facing changes:**
   <!-- Any changes visible to users? -->
   
   **Dependencies:**
   <!-- New dependencies or version changes? -->
   
   ### Checklist
   - [ ] Followed [contribution 
guide](https://cloudberry.apache.org/contribute/code)
   - [ ] Added/updated documentation
   - [ ] Reviewed code for security implications
   - [ ] Requested review from [cloudberry 
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
   
   ### Additional Context
   <!-- Any other information that would help reviewers? Remove if none -->
   
   ### CI Skip Instructions
   <!--
   To skip CI builds, add the appropriate CI skip identifier to your PR title.
   The identifier must:
   - Be in square brackets []
   - Include the word "ci" and either "skip" or "no"
   - Only use for documentation-only changes or when absolutely necessary
   -->
   
   ---
   <!-- Join our community:
   - Mailing list: 
[[email protected]](https://lists.apache.org/[email protected])
 (subscribe: [email protected])
   - Discussions: https://github.com/apache/cloudberry/discussions -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to