Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sql_mode TIME_TRUNCATE_FRACTIONAL #29406

Open
Thearas opened this issue Nov 3, 2021 · 1 comment · May be fixed by #56442
Open

Support sql_mode TIME_TRUNCATE_FRACTIONAL #29406

Thearas opened this issue Nov 3, 2021 · 1 comment · May be fixed by #56442
Labels
type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@Thearas
Copy link

Thearas commented Nov 3, 2021

Feature Request

Is your feature request related to a problem? Please describe:
No.

Describe the feature you'd like:
Same as mysql TIME_TRUNCATE_FRACTIONAL. I don't want to round datetime, truncation is better in my scene.

Describe alternatives you've considered:
No.

Teachability, Documentation, Adoption, Migration Strategy:
See MySQL Doc: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_time_truncate_fractional

@Thearas Thearas added the type/feature-request Categorizes issue or PR as related to a new feature. label Nov 3, 2021
@morgo
Copy link
Contributor

morgo commented Jan 12, 2022

Currently, TiDB behaves as if TIME_TRUNCATE_FRACTIONAL is always enabled. If this SQL mode is implemented, it will actually change the default behavior of TiDB to round, and require this mode to restore the current behavior.

Consider the following testcase:

CREATE TABLE t1 (a INT, b TIME(6));
INSERT INTO t1 (b) VALUES ('-10:10:59.500000');
INSERT INTO t1 (b) VALUES ('-10:10:59.500000');
UPDATE t1 SET a=b;
SELECT * FROM t1; 

..

tidb> SELECT * FROM t1; 
+---------+------------------+
| a       | b                |
+---------+------------------+
| -101059 | -10:10:59.500000 |
| -101059 | -10:10:59.500000 |
+---------+------------------+
2 rows in set (0.00 sec)

mysql [localhost:5735] {msandbox} (test) > SELECT * FROM t1; 
+---------+------------------+
| a       | b                |
+---------+------------------+
| -101100 | -10:10:59.500000 |
| -101100 | -10:10:59.500000 |
+---------+------------------+
2 rows in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants