Skip to content

Conversation

@fulghum
Copy link
Contributor

@fulghum fulghum commented Sep 13, 2022

MySQL's implementation of unix_timestamp(<expr>) returns 0 when the expression can't be converted to a date and logs a warning. This PR changes Dolt to have the same behavior. It also includes a bug fix for ctx.ClearWarnings to correctly clear warnings.

mysql> select unix_timestamp(1577995200);
+----------------------------+
| unix_timestamp(1577995200) |
+----------------------------+
|                          0 |
+----------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select unix_timestamp("jason");
+-------------------------+
| unix_timestamp("jason") |
+-------------------------+
|                0.000000 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-----------------------------------+
| Level   | Code | Message                           |
+---------+------+-----------------------------------+
| Warning | 1292 | Incorrect datetime value: 'jason' |
+---------+------+-----------------------------------+
1 row in set (0.00 sec)

@fulghum fulghum requested a review from zachmu September 13, 2022 21:25
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

…or depends on ClearWarnings being executed twice.
@fulghum fulghum merged commit b173ec2 into main Sep 13, 2022
@fulghum fulghum deleted the fulghum/unix_timestamp branch September 13, 2022 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants