-
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
SQL Error 1105
TiDB and MySQL behave differently (With Left Join)
#9536
Comments
@HankWang95 Thanks for the report.
Thanks. |
create SQL CREATE TABLE `org_department` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ctx` int(11) DEFAULT '0' COMMENT 'organization id',
`name` varchar(128) DEFAULT NULL,
`left_value` int(11) DEFAULT NULL,
`right_value` int(11) DEFAULT NULL,
`depth` int(11) DEFAULT NULL,
`leader_id` bigint(20) DEFAULT NULL,
`status` int(11) DEFAULT '1000',
`created_on` datetime DEFAULT NULL,
`updated_on` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `org_department_id_uindex` (`id`),
KEY `org_department_leader_id_index` (`leader_id`),
KEY `org_department_ctx_index` (`ctx`)
)
CREATE TABLE `org_position` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ctx` int(11) DEFAULT NULL,
`name` varchar(128) DEFAULT NULL,
`left_value` int(11) DEFAULT NULL,
`right_value` int(11) DEFAULT NULL,
`depth` int(11) DEFAULT NULL,
`department_id` int(11) DEFAULT NULL,
`status` int(2) DEFAULT NULL,
`created_on` datetime DEFAULT NULL,
`updated_on` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `org_position_id_uindex` (`id`),
KEY `org_position_department_id_index` (`department_id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8
CREATE TABLE `org_employee_position` (
`hotel_id` int(11) DEFAULT NULL,
`user_id` bigint(20) DEFAULT NULL,
`position_id` int(11) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`created_on` datetime DEFAULT NULL,
`updated_on` datetime DEFAULT NULL,
UNIQUE KEY `org_employee_position_pk` (`hotel_id`,`user_id`,`position_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
@HankWang95 thanks, we will fix this later. Here is the minimal repro case:
Looks like we have problems in column pruning. |
Please tell me when the bug was fixed . Thanks bro. |
@erjiaqing Do you have interest to fix this issue? |
@HankWang95 sure. |
Okey, can you tell me which file should be fix? |
@HankWang95 I guess it should be in |
well, I'll try it, but I can't guarantee to fix it.😄 |
@HankWang95 that will be fine. |
I printed the tidb/planner/core/optimizer.go Lines 121 to 136 in 63b49c9
And get the following tree, After *core.outerJoinEliminator Logic Plan:
Seems we have done something wrong with outer join elimination. |
It looks like we should record all the columns of schema between the Agg node and join node rather than only record the Agg columns. |
@erjiaqing Are u still working on this? I just found one commit on u repo before 3 days. |
It is on my todo list but I found it is a bit difficult to solve and might took a few weeks. |
@erjiaqing thanks for you work, but I am blocked the bug. Maybe we can fix it this week? and what's thing I can help ? |
@imiskolee the code change is more extensive than the initial expectation, so it would take some time to fix this bug. You can use the workaround mentioned in the description of the issue to solve this problem temporarily. |
@eurekaka thanks your work! the temp solution is work for me also. |
This was fixed in #11160 Proof:
|
Wrong SQL content:
Error message content:
My Fixed SQL:
SELECT ep.user_id, d.id, d.ctx, d.name, d.left_value, d.right_value, d.depth, d.leader_id, d.status, d.created_on, d.updated_on
......
The text was updated successfully, but these errors were encountered: