-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: check view recursion when building source from view #20398
Conversation
/label sig/planner,/bug-fix |
These labels are not found |
/label sig/planner,type/bug-fix |
executor/ddl_test.go
Outdated
@@ -273,11 +273,24 @@ func (s *testSuite6) TestCreateView(c *C) { | |||
tk.MustExec("create definer='root'@'localhost' view v_nested as select * from test_v_nested") | |||
tk.MustExec("create definer='root'@'localhost' view v_nested2 as select * from v_nested") | |||
_, err = tk.Exec("create or replace definer='root'@'localhost' view v_nested as select * from v_nested2") | |||
c.Assert(terror.ErrorEqual(err, plannercore.ErrNoSuchTable), IsTrue) | |||
c.Assert(terror.ErrorEqual(err, plannercore.ErrViewRecursive), IsTrue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this error message is not compatible with MySQL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
planner/core/logical_plan_builder.go
Outdated
@@ -3237,6 +3236,20 @@ func (b *PlanBuilder) buildMemTable(_ context.Context, dbName model.CIStr, table | |||
|
|||
// BuildDataSourceFromView is used to build LogicalPlan from view | |||
func (b *PlanBuilder) BuildDataSourceFromView(ctx context.Context, dbName model.CIStr, tableInfo *model.TableInfo) (LogicalPlan, error) { | |||
viewFullName := dbName.L + "." + tableInfo.Name.L |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract these code block as in individual function like checkRecrusiveView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed, PTAL
0b53d72
to
571921b
Compare
…ested_view # Conflicts: # planner/core/errors.go
/run-all-tests |
The test failed due to #20596 |
/run-all-tests |
/run-unit-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PTAL @wshwsh12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-3.0 in PR #21000 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #21001 |
What problem does this PR solve?
Issue Number: close #20368
Problem Summary:
TiDB server crashed with stack overflow when building source from recursive view.
What is changed and how it works?
What's Changed:
ErrNoSuchTable
withErrViewRecursive
How it Works:
ErrViewRecursive
error.Related changes
Check List
Tests
Side effects
Release note