1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-24 06:01:07 +03:00

Support RN (roman-numeral format) in to_number().

We've long had roman-numeral output support in to_char(),
but lacked the reverse conversion.  Here it is.

Author: Hunaid Sohail <hunaidpgml@gmail.com>
Reviewed-by: Maciek Sakrejda <m.sakrejda@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAMWA6ybh4M1VQqpmnu2tfSwO+3gAPeA8YKnMHVADeB=XDEvT_A@mail.gmail.com
This commit is contained in:
Tom Lane
2025-01-22 15:18:40 -05:00
parent f0ee648527
commit 172e6b3adb
4 changed files with 350 additions and 53 deletions

View File

@@ -8669,8 +8669,8 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
<entry>plus/minus sign in specified position</entry>
</row>
<row>
<entry><literal>RN</literal></entry>
<entry>Roman numeral (input between 1 and 3999)</entry>
<entry><literal>RN</literal> or <literal>rn</literal></entry>
<entry>Roman numeral (values between 1 and 3999)</entry>
</row>
<row>
<entry><literal>TH</literal> or <literal>th</literal></entry>
@@ -8798,6 +8798,19 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
(e.g., <literal>9.99EEEE</literal> is a valid pattern).
</para>
</listitem>
<listitem>
<para>
In <function>to_number()</function>, the <literal>RN</literal>
pattern converts Roman numerals (in standard form) to numbers.
Input is case-insensitive, so <literal>RN</literal>
and <literal>rn</literal> are equivalent. <literal>RN</literal>
cannot be used in combination with any other formatting patterns or
modifiers except <literal>FM</literal>, which is applicable only
in <function>to_char()</function> and is ignored
in <function>to_number()</function>.
</para>
</listitem>
</itemizedlist>
</para>