© Laurenz Albe 2025
Table of Contents
Recently, I wrote about the power of open source. Now, power is good and important, but open source software has other good sides as well. One of these aspects is fun. I will showcase that with the recently introduced support for converting Roman numerals to numbers.
Before we turn to the Roman numerals, let's take a step back. People with little knowledge about open source software sometimes believe that open source software is something that computer nerds write in their spare time. But developing open source software is not primarily a pastime for people with nothing better to do. The driving force behind most open source software development is actually money, directly or indirectly. Sometimes customers sponsor the development of a feature they need. Companies that live by selling PostgreSQL services or add-on products invest time and money into development so that the software is attractive to users.
But what drives the people who actually write the software? Well, certainly it is the money they get paid for it. But there is more to the picture:
psql
has so many features?)Reading the PostgreSQL documentation or using the software you probably don't see a lot of fun. Both speak to you in a technical, no-nonsense fashion. You have to look to the places where people communicate about PostgreSQL. This is primarily the mailing list pgsql-hackers. Sure enough, discussions there are fact-oriented and sometimes heated, but there is room for fun.
But most of the fun with PostgreSQL happens at conferences. Read my article about PostgreSQL conferences and you will know what I mean.
Honestly, I have no idea. I am sure there are some use cases. But if you are asking that question, you didn't understand what I wrote about fun above. Roman numerals are cool, that's why you want to have them!
Digging through the history of the source code, we find that PostrgreSQL has had support for rendering numbers with to_char()
as Roman numerals since commit b866d2e2d7 in 2000. Unfortunately, I cannot find any discussion on the mailing list about that patch. If I have to guess, I would say that the reason was feature compatibility with Oracle database. There was no support for the conversion in the other direction until commit 172e6b3adb almost 25 years later.
If you follow the discussion on the mailing list, you will find that nobody asked, “why do we need that?”. The patch fills a gap, and supporting Roman numerals is cool.
Try the following thought experiment: to_char()
was actually taken from Oracle database, which supports the conversion of numbers to Roman numerals. Now imagine submitting an enhancement request for conversion in the other direction to Oracle. Do you think Oracle would pay its developers for implementing that? I don't think so. Perhaps there was more room for fun at Oracle in the olden days...
Let's play!
1 2 3 4 5 |
SELECT to_number('MCMLXVIII', 'RN'); to_number ═══════════ 1968 |
Looks good!
1 2 |
SELECT to_number('MMMM', 'RN'); ERROR: invalid Roman numeral |
Like for the conversion in the other direction, the maximum allowed number is 3999.
1 2 3 4 5 |
SELECT to_number('iv', 'RN'); to_number ═══════════ 4 |
to_number()
supports lower case characters as well.
1 2 |
SELECT to_number('IIII', 'RN'); ERROR: invalid Roman numeral |
But to_number()
doesn't support the non-standard spelling of 4.
Have you missed the functionality of converting Roman numerals to numbers? I haven't. But the world has certainly become a little bit nicer because of that new feature!
Leave a Reply