Skip to content

[Bug] upgrading from 2.1.2->2.1.7 causes query result error #44666

@nandy33up

Description

@nandy33up

Search before asking

  • I had searched in the issues and found no similar issues.

Version

  • 2.1.7 (upgrading from 2.1.2)

What's Wrong?

  • 2.1.2 SUBSTRING_INDEX
mysql> select * from
(
	select 
				 SUBSTRING_INDEX(name, 'A', 1) t1,
				 LEFT(name, LOCATE('A', name)-1) t2,
				 name,
				 age,
				 code
	from
			(
				SELECT 
							 name,
							 age,
							 code
				FROM (
							SELECT '哈哈哈AAA' name, 20 age, '1' code
							UNION
							SELECT '哈哈哈AA+' name, 21 age, '2' code
							UNION
							SELECT '哈哈哈AA' name, 22 age, '3' code
							UNION
							SELECT '哈哈哈AA(2)' name, 23 age, '4' code
							UNION
							SELECT '哈哈哈AA-' name, 24 age, '5' code
						) a
			) b
) c
where t1 = '哈哈哈';
+--------+--------+-------------+-----+------+
| t1     | t2     | name        | age | code |
+--------+--------+-------------+-----+------+
| 哈哈哈 | 哈哈哈 | 哈哈哈AA-   |  24 | 5    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AAA   |  20 | 1    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA+   |  21 | 2    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA    |  22 | 3    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA(2) |  23 | 4    |
+--------+--------+-------------+-----+------+
5 rows in set (0.17 sec)
  • 2.1.7 SUBSTRING_INDEX
mysql> select * from
(
	select 
				 SUBSTRING_INDEX(name, 'A', 1) t1,
				 LEFT(name, LOCATE('A', name)-1) t2,
				 name,
				 age,
				 code
	from
			(
				SELECT 
							 name,
							 age,
							 code
				FROM (
							SELECT '哈哈哈AAA' name, 20 age, '1' code
							UNION
							SELECT '哈哈哈AA+' name, 21 age, '2' code
							UNION
							SELECT '哈哈哈AA' name, 22 age, '3' code
							UNION
							SELECT '哈哈哈AA(2)' name, 23 age, '4' code
							UNION
							SELECT '哈哈哈AA-' name, 24 age, '5' code
						) a
			) b
) c
where t1 = '哈哈哈';
+--------+--------+-------------+-----+------+
| t1     | t2     | name        | age | code |
+--------+--------+-------------+-----+------+
| 哈哈哈 | 哈哈哈 | 哈哈哈AA-   |  24 | 5    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA(2) |  23 | 4    |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA+   |  21 | 2    |
+--------+--------+-------------+-----+------+
3 rows in set (0.10 sec)

we use SUBSTRING_INDEX in the production, now we have to use LEFT+LOCATE for replacement.

What You Expected?

fix the query result bug

How to Reproduce?

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions