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

executor, infoschema: fix display of default CURRENT_TIMESTAMP with decimal #11070

Merged
merged 4 commits into from Jul 4, 2019

Conversation

Projects
None yet
4 participants
@bb7133
Copy link
Contributor

commented Jul 4, 2019

What problem does this PR solve?

This PR fixes the following scenarios in which decimal fraction is missed for default CURRENT_TIMESTAMP in TiDB:

tidb> create table t(a datetime(3) default current_timestamp(3), b timestamp(4) default current_timestamp(4));
Query OK, 0 rows affected (0.01 sec)
  • For SHOW CREATE TABLE:
tidb> show create table t;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                   |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` datetime(3) DEFAULT CURRENT_TIMESTAMP,
  `b` timestamp(4) DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
  • For SHOW (FULL) COLUMNS:
tidb> show full columns from t;
+-------+--------------+-----------+------+------+-------------------+-------+---------------------------------+---------+
| Field | Type         | Collation | Null | Key  | Default           | Extra | Privileges                      | Comment |
+-------+--------------+-----------+------+------+-------------------+-------+---------------------------------+---------+
| a     | datetime(3)  | NULL      | YES  |      | CURRENT_TIMESTAMP |       | select,insert,update,references |         |
| b     | timestamp(4) | NULL      | YES  |      | CURRENT_TIMESTAMP |       | select,insert,update,references |         |
+-------+--------------+-----------+------+------+-------------------+-------+---------------------------------+---------+
2 rows in set (0.01 sec)
  • For the queries on information_schema:
tidb> select column_name, column_default from information_schema.COLUMNS where table_schema="test" and table_name = "t" order by column_name;
+-------------+-------------------+
| column_name | column_default    |
+-------------+-------------------+
| a           | CURRENT_TIMESTAMP |
| b           | CURRENT_TIMESTAMP |
+-------------+-------------------+
2 rows in set (0.00 sec)

Notice that for all displays of the default values of time-related columns, the decimal fraction part is missed. This would cause some errors when users try to use those pieces of information, for example, create a table from SHOW CREATE TABLE:

tidb> CREATE TABLE `t` (
  `a` datetime(3) DEFAULT CURRENT_TIMESTAMP,
  `b` timestamp(4) DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
ERROR 1067 (42000): Invalid default value for 'a'

What is changed and how it works?

Simply adding the missed parts.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has interface methods change

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

@bb7133 bb7133 changed the title executor, infoschema: fix display of default CURRENT_TIMESTAMP with d… executor, infoschema: fix display of default CURRENT_TIMESTAMP with decimal Jul 4, 2019

@winkyao
Copy link
Member

left a comment

LGTM

@winkyao

This comment has been minimized.

Copy link
Member

commented Jul 4, 2019

/rebuild

@tangenta
Copy link
Contributor

left a comment

LGTM

@tangenta tangenta added the status/LGT2 label Jul 4, 2019

@codecov

This comment has been minimized.

Copy link

commented Jul 4, 2019

Codecov Report

❗️ No coverage uploaded for pull request base (master@e1f2b37). Click here to learn what that means.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11070   +/-   ##
===========================================
  Coverage          ?   81.0658%           
===========================================
  Files             ?        419           
  Lines             ?      89848           
  Branches          ?          0           
===========================================
  Hits              ?      72836           
  Misses            ?      11772           
  Partials          ?       5240
@crazycs520
Copy link
Contributor

left a comment

LGTM

bb7133 added some commits Jul 4, 2019

@bb7133

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

/run-all-tests

@bb7133

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

/run-integration-common-test

@bb7133 bb7133 merged commit 53a1ce6 into pingcap:master Jul 4, 2019

14 checks passed

ci/circleci Your tests passed on CircleCI!
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

bb7133 added a commit to bb7133/tidb that referenced this pull request Jul 4, 2019

bb7133 added a commit to bb7133/tidb that referenced this pull request Jul 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.