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 on update CURRENT_TIMESTAMP with decimal #11480

Merged
merged 11 commits into from
Aug 2, 2019

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Jul 29, 2019

What problem does this PR solve?

Fix #11349.

What is changed and how it works?

  1. refactor IsCurrentTimestampExpr into IsValidCurrentTimestampExpr. Here "valid" means the fractional seconds precision in column type equals to the one in on update clause.
  2. print fractional seconds precision in on update clause when show create table and describe if necessary. For example, here is a table with the following schema:
create table t (
  a datetime not null default current_timestamp on update current_timestamp,
  b datetime(3) not null default current_timestamp(3) on update current_timestamp(3)
);

show create table t:

+-------+----------------------------------------------------------------------------------------+
| Table | Create Table                                                                           |
+-------+----------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (                                                                     |
|       |   `a` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,         |
|       |   `b` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin                            |
+-------+----------------------------------------------------------------------------------------+

desc t:

+-------+-------------+------+-----+----------------------+--------------------------------------------------+
| Field | Type        | Null | Key | Default              | Extra                                            |
+-------+-------------+------+-----+----------------------+--------------------------------------------------+
| a     | datetime    | NO   |     | CURRENT_TIMESTAMP    | DEFAULT_GENERATED on update CURRENT_TIMESTAMP    |
| b     | datetime(3) | NO   |     | CURRENT_TIMESTAMP(3) | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
+-------+-------------+------+-----+----------------------+--------------------------------------------------+

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch

@codecov
Copy link

codecov bot commented Jul 29, 2019

Codecov Report

Merging #11480 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master    #11480   +/-   ##
=========================================
  Coverage   81.486%   81.486%           
=========================================
  Files          426       426           
  Lines        93103     93103           
=========================================
  Hits         75866     75866           
  Misses       11853     11853           
  Partials      5384      5384

expression/helper.go Outdated Show resolved Hide resolved
expression/helper.go Outdated Show resolved Hide resolved
@AilinKid
Copy link
Contributor

/LGTM

@tangenta tangenta added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 29, 2019
Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

ddl/db_integration_test.go Outdated Show resolved Hide resolved
ddl/db_integration_test.go Outdated Show resolved Hide resolved
@bb7133
Copy link
Member

bb7133 commented Aug 2, 2019

/run-all-tests

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133
Copy link
Member

bb7133 commented Aug 2, 2019

/run-unit-test

@sre-bot
Copy link
Contributor

sre-bot commented Aug 2, 2019

cherry pick to release-3.0 in PR #11591

@sre-bot
Copy link
Contributor

sre-bot commented Aug 2, 2019

cherry pick to release-2.1 failed

tangenta added a commit to tangenta/tidb that referenced this pull request Nov 6, 2019
@you06 you06 added the sig/sql-infra SIG: SQL Infra label Mar 4, 2020
@jackysp jackysp added the compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. sig/sql-infra SIG: SQL Infra status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dump of on update missing fraction
7 participants