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, expression: fix current_timestamp/now not consistent in one stmt like MySQL (#11342) #11392

Merged
merged 4 commits into from
Jul 23, 2019

Conversation

cfzjywxk
Copy link
Contributor

@cfzjywxk cfzjywxk commented Jul 23, 2019

What problem does this PR solve?

cherry-pick for #11342.

MySQL will set time to “”time_cache“ structure before doing one command(COM_XXX)
later expresission calculation will use this timestamp as time value

TiDB logic different and default column calculation and now expr calculation will try to get timestamp twice.

more details see jira issue#4391
eg:
TiDB

CREATE TABLE `tt4` (
  `c1` timestamp DEFAULT CURRENT_TIMESTAMP,
  `c2` int(11) DEFAULT NULL,
  `c3` timestamp DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

insert into tt4 set c1 = current_timestamp, c2 = sleep(2);
mysql> select c1 = c3 from tt4;
+---------+
| c1 = c3 |
+---------+
|       0 |
+---------+
1 row in set (0.00 sec)

MySQL

insert into tt4 set c1 = current_timestamp, c2 = sleep(2);
select c1 = c3 from tt4;
+---------+
| c1 = c3 |
+---------+
|       1 |
+---------+
1 row in set (0.00 sec)

remove stmtCtx.sysTs unused variable
cache time value once in stmtCtx.nowTs
refactor nowTs usage, offer Unified function interface for get and reset nowTS. Generally, accessing variable directly is not a good way for further maintenance, refactor these usage code

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change

Side effects

@cfzjywxk cfzjywxk added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Jul 23, 2019
@cfzjywxk
Copy link
Contributor Author

/run-all-tests

@cfzjywxk
Copy link
Contributor Author

/run-all-tests

@cfzjywxk
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 23, 2019
@qw4990 qw4990 changed the title executor, expression: fix current_timestamp/now not consistent… (#11342) executor, expression: fix current_timestamp/now not consistent in one stmt like MySQL (#11342) Jul 23, 2019
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason merged commit ce2a7e9 into pingcap:release-2.1 Jul 23, 2019
@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution 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.

3 participants