Re: [PATCH] Add roman support for to_number function

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Hunaid Sohail <hunaidpgml(at)gmail(dot)com>, Maciek Sakrejda <maciek(at)pganalyze(dot)com>, maciek(at)sakrejda(dot)org
Subject: Re: [PATCH] Add roman support for to_number function
Date: 2024-09-05 09:41:42
Message-ID: CAJ7c6TPf5wCB=xiBybGXYED3+jBqhMP2qtRWMMLgKgxn2KrYrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> I have attached a new patch v2 with following changes:
>
> - Handled invalid cases like 'viv', 'lxl', and 'dcd'.
> - Changed errcode to 22P07 because 22P06 was already taken.
> - Removed TODO.
> - Added a few positive & negative tests.
> - Updated documentation.
>
> Looking forward to your feedback.

While playing with the patch I noticed that to_char(..., 'RN') doesn't
seem to be test-covered. I suggest adding the following test:

```
WITH rows AS (
SELECT i, to_char(i, 'FMRN') AS roman
FROM generate_series(1, 3999) AS i
) SELECT bool_and(to_number(roman, 'RN') = i) FROM rows;

bool_and
----------
t
```

... in order to fix this while on it. The query takes ~12 ms on my laptop.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2024-09-05 09:55:47 Re: generic plans and "initial" pruning
Previous Message Nazir Bilal Yavuz 2024-09-05 09:24:51 Re: meson vs. llvm bitcode files