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

didn't output good width for timestamp column sometimes #21307

Closed
lance6716 opened this issue Nov 26, 2020 · 4 comments
Closed

didn't output good width for timestamp column sometimes #21307

lance6716 opened this issue Nov 26, 2020 · 4 comments
Labels
severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@lance6716
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

in mysql client

set @@explicit_defaults_for_timestamp = 1;
create table t(c timestamp);
insert into t values (null);
select * from t;

2. What did you expect to see? (Required)

mysql> select * from t;
+------+
| c    |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select * from t;
+---+
| c |
+---+
| NULL |
+---+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v4.0.0-beta.2-1552-ga81c89f89
Edition: Community
Git Commit Hash: a81c89f89b6fbc81c23f1bd341b3bc6c0cb4475f
Git Branch: HEAD
UTC Build Time: 2020-11-12 20:00:53
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@lance6716 lance6716 added the type/bug The issue is confirmed as a bug. label Nov 26, 2020
@ichn-hu
Copy link
Contributor

ichn-hu commented Nov 26, 2020

This is an interesting bug, after investigation, it might be that TiDB wrongly calculated the Flag column information, and a simplest reproduce is to

╰─$ mysql -u root -p -h 0.0.0.0 -P 4000 -D test --column-type-info                                                         
mysql> select NULL as a;
Field   1:  `a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NULL
Collation:  binary (63)
Length:     0
Max_length: 0
Decimals:   0
Flags:      NOT_NULL BINARY NUM


+---+
| a |
+---+
| NULL |
+---+
1 row in set (0.00 sec)

While in mysql

mysql>  select NULL as a;
Field   1:  `a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NULL
Collation:  binary (63)
Length:     0
Max_length: 0
Decimals:   0
Flags:      BINARY NUM


+------+
| a    |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

@xuyifangreeneyes
Copy link
Contributor

/assign

@xuyifangreeneyes
Copy link
Contributor

#19029 can fix this issue.

@lance6716
Copy link
Contributor Author

fixed somehow

MySQL [(none)]>  select NULL as a;
Field   1:  `a`
Org_field:  `a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NULL
Collation:  binary (63)
Length:     0
Max_length: 0
Decimals:   0
Flags:      BINARY NUM 


+------+
| a    |
+------+
| NULL |
+------+
1 row in set (0.001 sec)

MySQL [(none)]> select tidb_version();
Field   1:  `tidb_version()`
Org_field:  `tidb_version()`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb3_bin (83)
Length:     1136
Max_length: 284
Decimals:   31
Flags:      NOT_NULL 


+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants