cockroachdb / cockroachdb/cockroach
sql: 'infinity'::time should be greater than any other time
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
In the current implementation, `'infinity'::time` is equal to `'23:59:59.999999'` and smaller than `'24:00:00'`.
We should make it greater than any other time to fit the semantics of 'infinity', and the updated behaviour will also aligne with pr https://github.com/cockroachdb/cockroach/pull/127141
```
demo@127.0.0.1:26257/demoapp/movr> SELECT 'infinity'::time = '23:59:59.999999'::time;
?column?
------------
t
demo@127.0.0.1:26257/demoapp/movr> SELECT 'infinity'::time < '24:00:00'::time;
?column?
------------
t
```
Alternatively, we can align it's behaviour with postgres, which prohibits `'infinity'::time`:
```
postgres=# SELECT 'infinity'::time;
ERROR: invalid input syntax for type time: "infinity"
LINE 1: SELECT 'infinity'::time;
^
postgres=# SELECT 'infinity'::time > '23:59:59.999999'::time;
ERROR: invalid input syntax for type time: "infinity"
LINE 1: SELECT 'infinity'::time > '23:59:59.999999'::time;
```
This issue complements issue https://github.com/cockroachdb/cockroach/issues/41564
Jira issue: CRDB-41399
Epic CRDB-60811
Contributor guide
Research direction
Reproduce the issue with the shown SQL comparisons for `'infinity'::time`, then review issue 41564 and PR 127141 for related behavior and context. Identify the time parsing and comparison entry points and existing regression tests; done means the chosen infinity semantics are documented by tests and no longer contradict the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100