Comments (2)
MySQL's right shift supports two types: bigint
and binary
[1]. So no casting is applied to t2.a >> 8
and it evaluates to a binary
as well. Whereas TiDB so far only supports bigint
for right shift [2], this is why an implicit cast to bigint
is applied to t2.a
and this cast evaluates to 0
(with warning saying truncation). Then t2.a >> 8
still evaluates to a bigint
0
. Then it is compared with binary
(t3.a
), causing both sides being casted to double
, and the comparison is true
for 0
and 0
.
[1] https://dev.mysql.com/doc/refman/8.4/en/bit-functions.html#operator_right-shift
[2]
tidb/pkg/expression/builtin_op.go
Line 420 in 29fc940
from tidb.
We explain the execution plan. It seems that TiDB will cast blob into other types before right shift, which applies incorrect truncation.
explain select * from t2,t3 where (t2.a >> 8) = t3.a;
+------------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------+
| HashJoin_12 | 1.00 | root | | inner join, equal:[eq(Column#5, Column#6)] |
| ├─Projection_17(Build) | 1.00 | root | | test.t3.a, cast(test.t3.a, double BINARY)->Column#6 |
| │ └─TableReader_19 | 1.00 | root | | data:TableFullScan_18 |
| │ └─TableFullScan_18 | 1.00 | cop[tikv] | table:t3 | keep order:false, stats:pseudo |
| └─Projection_14(Probe) | 1.00 | root | | test.t2.a, cast(rightshift(cast(test.t2.a, bigint(65535) BINARY), 8), double UNSIGNED BINARY)->Column#5 |
| └─TableReader_16 | 1.00 | root | | data:TableFullScan_15 |
| └─TableFullScan_15 | 1.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
+------------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------+
from tidb.
Related Issues (20)
- Azure Identity Libraries and Microsoft Authentication Library Elevation of Privilege Vulnerability
- The partition prune result is not expected HOT 2
- If group by key contains constant columns, the constant columns should be removed from group by key
- Enforce Username Rules and Automatic Transformations
- stop loading stats when has too much stats in the memory during the init stats
- avoid use fmt.Sprintf in public path
- unexpected memory usage of memory tracker HOT 2
- TestMergeJoinInDisk test in ut is unstable HOT 1
- Decouple clean up ingest temp data from `BackendCtxMgr` HOT 3
- Invalid TABLESAMPLE: plan not supported
- br backup failed when kill pd leader or injection network partition between pd leader and pd followers HOT 1
- test HOT 1
- (*infoSchema).SchemaTables take too many time on growslics
- TiDB memory leak after meets the `fail to get stats version for this histogram` HOT 5
- Differences in JSON type for casting YEAR and binary
- Using JSON_TYPE on non-JSON values should return an error
- TiDB does not reject connection for mismatched user when using auth_socket plugin HOT 1
- tidb_schema_cache_size max support value is wrong
- Updating a column with another column is not compatible with MySQL 8.0 HOT 2
- Wrong user in error message when running SET PASSWORD FOR USER without sufficient privileges HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tidb.