Re: [PATCH] Add roman support for to_number function
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hunaid Sohail <hunaidpgml@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org,
Maciek Sakrejda <m.sakrejda@gmail.com>,
Tomas Vondra <tomas@vondra.me>
Date: 2025-01-22T20:29:04Z
Lists: pgsql-hackers
Hunaid Sohail <hunaidpgml@gmail.com> writes:
> I have attached a new patch v8 with the following changes:
> 1. Fixed cases reported by Maciek.
> 2. Handles leading spaces in input string.
I pushed this after fooling with it a bit more:
* The way you did the leading-space skip would actually skip
anything whatsoever until it found a valid roman character.
I don't think that's what's wanted here. We just want to
skip whitespace --- the idea more or less is to consume
leading whitespace that to_char('RN') might have emitted.
* You'd also re-introduced failure on trailing whitespace
(or indeed trailing anything), which I still don't agree with.
It's not appropriate for RN to dictate that nothing can follow it.
There's a separate discussion to be had about whether to_number
is too lax about trailing garbage, but the policy should not be
different for RN than it is for other format codes.
* I made some other cosmetic changes such as rearranging the
error checks into an order that made more sense to me.
Thanks for submitting this patch!
regards, tom lane
Commits
-
Support RN (roman-numeral format) in to_number().
- 172e6b3adb2e 18.0 landed