dolthub / go-mysql-server

A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.
Apache License 2.0
2.32k stars 199 forks source link

Bug fix: the `timestamp` function should convert to a `datetime` type #2625

Closed fulghum closed 1 month ago

fulghum commented 1 month ago

MySQL's timestamp function, despite its name, actually returns a datetime type and not a timestamp type.

MySQL example:

mysql -uroot --protocol TCP -e "select timestamp('1000-01-01 00:00:00');" --column-type-info
Field   1:  `timestamp('1000-01-01 00:00:00')`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DATETIME
Collation:  binary (63)
Length:     19
Max_length: 19
Decimals:   0
Flags:      BINARY 

+----------------------------------+
| timestamp('1000-01-01 00:00:00') |
+----------------------------------+
| 1000-01-01 00:00:00              |
+----------------------------------+

Note: We still need to add support for the second, optional parameter to timestamp().

Customer issue: https://github.com/dolthub/dolt/issues/8236

timsehn commented 1 month ago

This is some MySQL garbage.

fulghum commented 1 month ago

This is some MySQL garbage.

Yeah, MySQL has some wacky naming in several places 🤷‍♂️