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

planner, executor: fix PREPARE FROM @var_name #8437

Merged
merged 4 commits into from
Nov 27, 2018

Conversation

AndrewDi
Copy link
Contributor

@AndrewDi AndrewDi commented Nov 24, 2018

What problem does this PR solve?

PlanBuilder: Fix prepare from session value issue #8074

What is changed and how it works?

When prepare from a user defined session name, replace session name with session value.
Improve mysql grammar compatibility.

Check List

Tests

  • Unit test

This change is Reviewable

@sre-bot
Copy link
Contributor

sre-bot commented Nov 24, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@AndrewDi AndrewDi force-pushed the fix_prepare_issue_8074 branch from cfb5ba7 to c0ae8c8 Compare November 25, 2018 03:50
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.

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @AndrewDi)


executor/prepared_test.go, line 221 at r1 (raw file):

		tk.MustExec("create table prepare1 (a decimal(1))")
		_, err = tk.Exec("prepare stmt FROM @sql1")
		c.Assert(err, NotNil)

please check the error message as well.

Copy link
Contributor Author

@AndrewDi AndrewDi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @zz-jason)


executor/prepared_test.go, line 221 at r1 (raw file):

Previously, zz-jason (Zhang Jian) wrote…

please check the error message as well.

Because @SQL is undefined,so “ERROR 1105 (HY000): line 1 column 4 near "" (total length 4)” message return。

@AndrewDi AndrewDi force-pushed the fix_prepare_issue_8074 branch from 864fb23 to c0ae8c8 Compare November 25, 2018 10:16
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.

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @zz-jason and @AndrewDi)


executor/prepared_test.go, line 221 at r1 (raw file):

Previously, AndrewDi (Andrew) wrote…

Because @SQL is undefined,so “ERROR 1105 (HY000): line 1 column 4 near "" (total length 4)” message return。

Uh.. I can't get your point. Except for c.Assert(err, NotNil), could you further test the error message that err contains, i.e. err.Error()?

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

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@zz-jason zz-jason dismissed their stale review November 25, 2018 11:26

addressed

@zz-jason zz-jason added contribution This PR is from a community contributor. type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Nov 25, 2018
@AndrewDi AndrewDi force-pushed the fix_prepare_issue_8074 branch from a5ade9d to 2e9d6c7 Compare November 25, 2018 11:28
@AndrewDi
Copy link
Contributor Author

Test case address...

@XuHuaiyu XuHuaiyu changed the title PlanBuilder: fix prepare from session value planner, executor: fix PREPARE FROM @var_name Nov 26, 2018
c.Assert(err.Error(), Equals, "line 1 column 4 near \"\" (total length 4)")
tk.MustExec("SET @sql = 'update prepare1 set a=5 where a=?';")
_, err = tk.Exec("prepare stmt FROM @sql")
c.Assert(err, IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we need to execute stmt to see whether the result is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fine, result check addressed.

} else {
p.SQLText = x.SQLText
}
return p
return p, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why adding one more return value error which is always nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we may address some errors in this function first thought; but found no such errors should be address here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I prefer removing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Address this comment makes an LGTM. @AndrewDi

@eurekaka eurekaka added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 26, 2018
Copy link
Contributor Author

@AndrewDi AndrewDi left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @zz-jason, @XuHuaiyu, and @eurekaka)


executor/prepared_test.go, line 224 at r3 (raw file):

Previously, AndrewDi (Andrew) wrote…

fine, result check addressed.

Done.


planner/core/planbuilder.go, line 412 at r3 (raw file):

Previously, eurekaka (Kenan Yao) wrote…

Then I prefer removing it.

I think both programming is fine。。。

@AndrewDi AndrewDi force-pushed the fix_prepare_issue_8074 branch from 01ac8d5 to 456015f Compare November 27, 2018 00:59
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, 1 of 1 files at r5.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @eurekaka)

@XuHuaiyu
Copy link
Contributor

/run-all-tests
PTAL @eurekaka

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@eurekaka eurekaka added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 27, 2018
@zz-jason zz-jason merged commit 0ac0e15 into pingcap:master Nov 27, 2018
@zz-jason
Copy link
Member

Hi, @AndrewDi , could you cherry pick this commit to the release-2.1 and release-2.0 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/planner SIG: Planner 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.

5 participants