Skip to content

lib/pq handling of 24:00:00 is broken #44548

@otan

Description

@otan

lib/pq prints 24:00 time as 0001-01-01 00:00:00, which is indistinguishable from '00:00'. This is because time is represented as a time.Time in lib/pq.


root@127.0.0.1:51083/movr> select '24:00'::timetz;
            time
-----------------------------
  0000-01-01 00:00:00+00:00
(1 row)

Time: 320µs

root@127.0.0.1:51083/movr> select '24:00'::timetz::string;
    text
------------
  24:00:00
(1 row)

root@127.0.0.1:51083/movr> select '00:00'::timetz;
            time
-----------------------------
  0000-01-01 00:00:00+00:00
(1 row)

Time: 263µs

This breaks anything requiring a switch on time.Time to parse back into DTimeTZ (and DTime).

I think as a result, backups for time/timetz columns are broken if someone encoded 24:00 time in the database, since backups use lib/pq formatting.

Furthermore, this prevents us from using TestCopyRandom for 24:00 values for Time/TimeTZ.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-encodingRelating to the SQL/KV encoding.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions