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

HandleBinaryLiteral should ignore TypeNull #49526

Closed
YangKeao opened this issue Dec 17, 2023 · 8 comments · Fixed by #49527
Closed

HandleBinaryLiteral should ignore TypeNull #49526

YangKeao opened this issue Dec 17, 2023 · 8 comments · Fixed by #49527

Comments

@YangKeao
Copy link
Member

Enhancement

from_binary(<nil>) actually does nothing, but TiDB regards the NULL as binary string, so it may avoid some expressions to be pushed down to TiFlash. We can manually ignore this case.

(Though I don't know why this constant is not folded.)

@Ivy-YinSu Ivy-YinSu added the sig/sql-infra SIG: SQL Infra label Dec 17, 2023
@YangKeao YangKeao added affects-7.5 and removed sig/sql-infra SIG: SQL Infra labels Dec 17, 2023
ti-chi-bot bot pushed a commit that referenced this issue Dec 17, 2023
@YangKeao YangKeao added sig/sql-infra SIG: SQL Infra sig/execution SIG execution and removed sig/sql-infra SIG: SQL Infra labels Dec 28, 2023
@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

v5.4.0 seems to be the first release using "cast(from_binary()".
image

@kennedy8312
Copy link

v5.3.0 seems to be fine.
image

@kennedy8312
Copy link

Regression Analysis
PR caused this regression: #30706

@kennedy8312
Copy link

+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.4.0-alpha-458-geb6c89d6d4-dirty
Edition: Community
Git Commit Hash: eb6c89d
Git Branch: HEAD
UTC Build Time: 2024-02-01 10:04:22
GoVersion: go1.21.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> explain select null as a union all select 'a' as a order by a;
+--------------------------+---------+------+---------------+-----------------+
| id | estRows | task | access object | operator info |
+--------------------------+---------+------+---------------+-----------------+
| Sort_9 | 2.00 | root | | Column#3 |
| └─Union_11 | 2.00 | root | | |
| ├─Projection_13 | 1.00 | root | | ->Column#3 |
| │ └─TableDual_14 | 1.00 | root | | rows:1 |
| └─Projection_15 | 1.00 | root | | a->Column#3 |
| └─TableDual_16 | 1.00 | root | | rows:1 |
+--------------------------+---------+------+---------------+-----------------+
6 rows in set (0.00 sec)

mysql> select null as a union all select 'a' as a order by a;
+---+
| a |
+---+
| NULL |
| a |
+---+
2 rows in set (0.01 sec)

@kennedy8312
Copy link

mysql> explain select null as a union all select 'a' as a order by a;
+--------------------------+---------+------+---------------+---------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------+---------+------+---------------+---------------------------------------------------+
| Sort_9 | 2.00 | root | | Column#3 |
| └─Union_11 | 2.00 | root | | |
| ├─Projection_13 | 1.00 | root | | cast(from_binary(), var_string(1))->Column#3 |
| │ └─TableDual_14 | 1.00 | root | | rows:1 |
| └─Projection_15 | 1.00 | root | | a->Column#3 |
| └─TableDual_16 | 1.00 | root | | rows:1 |
+--------------------------+---------+------+---------------+---------------------------------------------------+
6 rows in set (0.00 sec)

mysql> select null as a union all select 'a' as a order by a;
+---+
| a |
+---+
| NULL |
| a |
+---+
2 rows in set (0.01 sec)

mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.4.0-alpha-459-g87ab28ebb2-dirty
Edition: Community
Git Commit Hash: 87ab28e
Git Branch: HEAD
UTC Build Time: 2024-02-01 10:09:06
GoVersion: go1.21.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |

@YangKeao YangKeao added the affects-5.4 This bug affects 5.4.x versions. label Feb 2, 2024
@kennedy8312
Copy link

/type performance

@windtalker windtalker mentioned this issue Feb 23, 2024
18 tasks
guoshouyan pushed a commit to guoshouyan/tidb that referenced this issue Mar 5, 2024
@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the found/customer Customers have encountered this bug. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants