On Tue, Jan 21, 2025 at 1:35 PM Hunaid Sohail <hunaidp...@gmail.com> wrote:
> Agreed. Your changes in v7 consumes leading spaces if leading space > is present in format (' RN'). But we need it to work on cases like: > SELECT to_number(' XIV', 'RN'); > So, I can add this logic in my next patch. > So, I was playing with leading spaces in v7 and found something interesting. postgres=# --both input and format both 2 spaces postgres=# SELECT to_number(' XIV', ' RN'); to_number ----------- 14 (1 row) postgres=# --input 1 space, format 2 spaces postgres=# --Input is read from "IV" ignoring "X" postgres=# SELECT to_number(' XIV', ' RN'); to_number ----------- 4 (1 row) postgres=# --should work after leading spaces are handled postgres=# SELECT to_number(' XIV', ' RN'); ERROR: invalid Roman numeral postgres=# select to_number('123456', ' 999999'); to_number ----------- 23456 (1 row) postgres=# select to_number('123456', ' 999999'); to_number ----------- 3456 (1 row) The leading spaces are consumed in the RN (from the main loop in Num_processor), and this behavior seems consistent with how simple numbers are handled. The Roman numeral parsing appears to start from where "RN" is in the format after leading spaces are consumed. Please review the first two examples of Roman numerals. I'd appreciate your opinions on whether this behavior should be considered valid. Regards, Hunaid Sohail