Re: [HACKERS] Add Roman numeral conversion to to_number - Mailing list pgsql-hackers

From David Fetter
Subject Re: [HACKERS] Add Roman numeral conversion to to_number
Date
Msg-id 20170803183818.GB22919@fetter.org
Whole thread Raw
In response to Re: [HACKERS] Add Roman numeral conversion to to_number  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Thu, Aug 03, 2017 at 01:45:02PM -0400, Robert Haas wrote:
> On Thu, Aug 3, 2017 at 9:25 AM, Oliver Ford <ojford@gmail.com> wrote:
> > Adds to the to_number() function the ability to convert Roman numerals
> > to a number. This feature is on the formatting.c TODO list. It is not
> > currently implemented in either Oracle, MSSQL or MySQL so gives
> > PostgreSQL an edge :-)
> 
> I kind of put my head in my hands when I saw this.  I'm not really
> sure it's worth complicating the code for something that has so little
> practical utility, but maybe other people will feel differently.  I
> can't deny the profound advantages associated with having a leg up on
> Oracle.
> 
> The error reporting is a little wonky, although maybe no wonkier than
> anything else about these conversion routines.
> 
> rhaas=# select to_number('q', 'rn');
> ERROR:  invalid character "q"
> 
> (hmm, no position)
> 
> rhaas=# select to_number('dd', 'rn');
> ERROR:  invalid character "D" at position 1
> 
> (now i get a position, but it's not really the right position; and the
> problem isn't really that the character is invalid but that you don't
> like me including it twice, and I said 'd' not 'D')
> 
> rhaas=# select to_number('à', 'rn');
> ERROR:  invalid character "?"
> 
> (eh?)
> 
> How much call is there for a format that can only represent values up to 3999?

There are ways to represent much larger numbers, possibly bigger than
INT_MAX.  https://en.wikipedia.org/wiki/Roman_numerals#Large_numbers
https://en.wikipedia.org/wiki/Numerals_in_Unicode#Roman_numerals

As nearly as I can tell, this patch is late by 124 days.

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] A bug in mapping attributes in ATExecAttachPartition()
Next
From: Oliver Ford
Date:
Subject: Re: [HACKERS] Add Roman numeral conversion to to_number