From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Andrey Borodin <amborodin86(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Kirk Wolak <wolakk(at)gmail(dot)com> |
Subject: | [PoC] XMLCast (SQL/XML X025) |
Date: | 2024-07-02 16:02:38 |
Message-ID: | 7b99d466-985f-4d27-8c93-9b98c6945ebb@uni-muenster.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
This is a PoC that implements XMLCast (SQL/XML X025), which enables
conversions between SQL and XML data type.
It basically does the following:
* When casting an XML value to a SQL data type, XML values containing
XSD literals will be converted to their equivalent SQL data type.
* When casting from a SQL data type to XML, the cast operand will be
translated to its corresponding XSD data type.
SELECT xmlcast(now() AS xml);
xmlcast
----------------------------------
2024-07-02T17:03:11.189073+02:00
(1 row)
SELECT xmlcast('2024-07-02T17:03:11.189073+02:00'::xml AS timestamp with
time zone);
xmlcast
-------------------------------
2024-07-02 17:03:11.189073+02
(1 row)
SELECT xmlcast('P1Y2M3DT4H5M6S'::xml AS interval);
xmlcast
-------------------------------
1 year 2 mons 3 days 04:05:06
(1 row)
SELECT xmlcast('<foo&bar>'::xml AS text);
xmlcast
-----------
<foo&bar>
(1 row)
SELECT xmlcast('1 year 2 months 3 days 4 hours 5 minutes 6
seconds'::interval AS xml) ;
xmlcast
----------------
P1Y2M3DT4H5M6S
(1 row)
SELECT xmlcast('42.73'::xml AS numeric);
xmlcast
---------
42.73
(1 row)
SELECT xmlcast(42730102030405 AS xml);
xmlcast
----------------
42730102030405
(1 row)
Is it starting in the right direction? Any feedback would be much
appreciated.
Best,
Jim
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Add-XMLCast-function-SQL-XML-X025.patch | text/x-patch | 72.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2024-07-02 16:20:35 | Re: Optimize numeric multiplication for one and two base-NBASE digit multiplicands. |
Previous Message | Dagfinn Ilmari Mannsåker | 2024-07-02 15:38:01 | Re: Cleaning up perl code |