![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It appears that any string representation of an interval of length greater than 76 is rejected. (76 = 51 + 25 = MAXDATELEN + MAXDATEFIELDS). This appears to be a limitation enforced within function interval_in() in the file src/backend/utils/adt/timestamp.c |
#3
| |||
| |||
|
|
Yeah, this seems bogus. It's not even clear to me why MAXDATELEN + MAXDATEFIELDS is used as the size of that buffer in the first place. I don't know the datetime code particularly well; perhaps someone who does can shed some light on this? |
#4
| |||
| |||
|
|
There are a lot of fixed-size local buffers in that code. The ones used in output routines seem defensible since the string to be generated is predictable. The ones that are used for processing input are likely wrong. OTOH I'm not eager to throw a palloc into each of those code paths ... can we avoid that? |
#5
| |||
| |||
|
|
Tom Lane wrote: There are a lot of fixed-size local buffers in that code. The ones used in output routines seem defensible since the string to be generated is predictable. The ones that are used for processing input are likely wrong. I'm not sure offhand what the upper bounds on legal input for each of the datetime types is. |
#6
| |||
| |||
|
|
Well, if you allow for whitespace between tokens then it's immediately clear that there is no fixed upper bound. |
|
Perhaps it would work to downcase just one token at a time, so that the max buffer length equals the max acceptable token? |
#7
| |||
| |||
|
|
Perhaps it would work to downcase just one token at a time, so that the max buffer length equals the max acceptable token? Not sure I follow you. |
#8
| |||
| |||
|
|
I believe that the reason for the local buffer is to hold a downcased version of the input, which we can compare to the all-lower-case tables of relevant keywords. |
#9
| |||
| |||
|
|
Tom Lane wrote: I believe that the reason for the local buffer is to hold a downcased version of the input, which we can compare to the all-lower-case tables of relevant keywords. Well, that's one of the reasons, but not the only one. For example, how do you parse '17 minutes31 seconds'::interval without either a working buffer or the ability to resize the input buffer? |
|
On closer inspection, the current code seems to get this wrong as well :-( |
#10
| |||
| |||
|
|
Sorry, s/downcased/downcased and null-terminated/. I have not read the parsing code in question lately, but offhand it seems like transferring one token at a time into a work buffer isn't a completely broken idea... |
The gist of the current code is:![]() |
| Thread Tools | |
| Display Modes | |
| |