From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Hunaid Sohail <hunaidpgml(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me> |
Subject: | Re: [PATCH] Add roman support for to_number function |
Date: | 2025-01-20 21:16:35 |
Message-ID: | 3178834.1737407795@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> However, when you poke at that a bit closer, it's not a license
> for unlimited whitespace:
> regression=# select to_number('123 456', '999999');
> to_number
> -----------
> 12345
> (1 row)
> I've not tracked down the exact cause of that, but I think it
> has to do with the fact that NUM_numpart_from_char() is willing
> to eat a single leading space per call, even if it's not the
> first call.
I tried simply removing that bit:
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 3960235e14..366430863f 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -5134,12 +5134,6 @@ NUM_numpart_from_char(NUMProc *Np, int id, int input_len)
(id == NUM_0 || id == NUM_9) ? "NUM_0/9" : id == NUM_DEC ? "NUM_DEC" : "???");
#endif
- if (OVERLOAD_TEST)
- return;
-
- if (*Np->inout_p == ' ')
- Np->inout_p++;
-
if (OVERLOAD_TEST)
return;
All our regression tests still pass, and this example seems to behave
more sanely:
regression=# select to_number('123 456', '999999');
to_number
-----------
12345
(1 row)
regression=# select to_number('123 456', '999999');
to_number
-----------
1234
(1 row)
That might or might not be a behavior you like, but it's at least
possible to see where it's coming from: it's eating the digits that
appear within a six-character window, and not any more.
Not sure if anyone would thank us for making this change though.
I can't avoid the suspicion that somebody somewhere is depending
on the current behavior.
Anyway, this is getting off-topic for the current thread.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Corey Huinker | 2025-01-20 21:26:02 | Re: Statistics Import and Export |
Previous Message | Dagfinn Ilmari Mannsåker | 2025-01-20 21:10:07 | Re: pg_createsubscriber TAP test wrapping makes command options hard to read. |