Re: [PATCH] Add roman support for to_number function

From: Hunaid Sohail <hunaidpgml(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: [PATCH] Add roman support for to_number function
Date: 2024-12-13 05:29:28
Message-ID: CAMWA6ybQ498tDOSqXLqFgU1hGbbMy=UJDuY5zD16_w5WLB_JWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> On Mon, Dec 9, 2024 at 3:07 AM Tomas Vondra <tomas(at)vondra(dot)me> wrote:
>
>> Thanks for a nice patch. I did a quick review today, seems almost there,
>> I only have a couple minor comments:
>>
>> 1) Template Patterns for Numeric Formatting
>>
>> Why the wording change? "input between 1 and 3999" sounds fine to me.
>>
> input... seemed to refer to numeric input for to_char roman format. But,
> after roman support in to_number function shouldn't we modify it? It is the
> reason I changed it to "valid for numbers 1 to 3999".
>
> 2) The docs say "standard numbers" but I'm not sure what that is? We
>> don't use that term anywhere else, I think. Same for "standard roman
>> numeral".
>>
> I will change "standard numbers" to "numbers".
> Note that we are following the standard form. There are other forms too.
> For example, 4 can be represented as IV (standard) or IIII (non standard).
> https://en.wikipedia.org/wiki/Roman_numerals#Standard_form
>
>
>> 3) A couple comments need a bit of formatting. Multi-line comments
>> should start with an empty line, some lines are a bit too long.
>>
> I will fix the multi-line formatting.
>
>
>> 4) I was wondering if the regression tests check all interesting cases,
>> and it seems none of the tests hit these two cases:
>>
>> if (vCount > 1 || lCount > 1 || dCount > 1)
>> return -1;
>>
> SELECT to_number('viv', 'RN') test covers this if statement for the
> subtraction part. But, I noticed that no test covers simple counts of V, L,
> D.
> I will add SELECT to_number('VV', 'RN') for that.
>
>
>> and
>>
>> if (!IS_VALID_SUB_COMB(currChar, nextChar))
>> return -1;
>>
> Noted. SELECT to_number('IL', 'RN') test can be added.
>

I’ve attached a new patch that addresses comments 2, 3, and 4 from Tomas.

Looking forward to your feedback.

Regards,
Hunaid Sohail

Attachment Content-Type Size
v6-0001-Add-roman-support-for-to_number-function.patch application/x-patch 10.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shubham Khanna 2024-12-13 05:32:33 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.
Previous Message Peter Smith 2024-12-13 05:27:38 DOCS: pg_createsubscriber wrong link?