Skip to content

[compatibility] SYSDATE() is different from mysql #4245

@tshqin

Description

@tshqin
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    SELECT SYSDATE(), SLEEP(1), SYSDATE(), SLEEP(2), SYSDATE();

  2. What did you expect to see?

mysql> SELECT SYSDATE(), SLEEP(1), SYSDATE(), SLEEP(2), SYSDATE();
+---------------------+----------+---------------------+----------+---------------------+
| SYSDATE()           | SLEEP(1) | SYSDATE()           | SLEEP(2) | SYSDATE()           |
+---------------------+----------+---------------------+----------+---------------------+
| 2017-08-18 22:33:51 |        0 | 2017-08-18 22:33:52 |        0 | 2017-08-18 22:33:54 |
+---------------------+----------+---------------------+----------+---------------------+
1 row in set (3.01 sec)
  1. What did you see instead?

in TiDB SYSDATE() behaves the same as now(), it returns statement begin time but not execute time

MySQL [(none)]> SELECT SYSDATE(), SLEEP(1), SYSDATE(), SLEEP(2), SYSDATE();
+---------------------+----------+---------------------+----------+---------------------+
| SYSDATE()           | SLEEP(1) | SYSDATE()           | SLEEP(2) | SYSDATE()           |
+---------------------+----------+---------------------+----------+---------------------+
| 2017-08-18 22:33:44 |        0 | 2017-08-18 22:33:44 |        0 | 2017-08-18 22:33:44 |
+---------------------+----------+---------------------+----------+---------------------+
1 row in set (3.00 sec)
  1. What version of TiDB are you using (tidb-server -V)?
    Git Commit Hash: 365e4ab
    Git Commit Branch: master
    UTC Build Time: 2017-08-16 01:24:27

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions