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

bit column union Numeric literals select got the wrong results #23832

Closed
aytrack opened this issue Apr 2, 2021 · 2 comments · Fixed by #23857
Closed

bit column union Numeric literals select got the wrong results #23832

aytrack opened this issue Apr 2, 2021 · 2 comments · Fixed by #23857
Assignees
Labels
severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Apr 2, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t(a bit(20), b float, c double, d int);
insert into t values(10, 10, 10, 10), (1, -1, 2, -2), (2, -2, 1, 1), (2, 1.1, 2.1, 10.1);
select a from t union select 10;

2. What did you expect to see? (Required)

mysql> drop table if exists t;
Query OK, 0 rows affected (0.04 sec)

mysql> create table t(a bit(20), b float, c double, d int);
Query OK, 0 rows affected (0.07 sec)

mysql> insert into t values(10, 10, 10, 10), (1, -1, 2, -2), (2, -2, 1, 1), (2, 1.1, 2.1, 10.1);
Query OK, 4 rows affected (0.04 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select a from t union select 10;
+------+
| a    |
+------+
|   10 |
|    1 |
|    2 |
+------+
3 rows in set (0.23 sec)

3. What did you see instead (Required)

mysql> select a from t union select 10;
+----------+
| a        |
+----------+
| 0x00000A |
| 0x3130   |
| 0x000001 |
| 0x000002 |
+----------+
4 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

master: 096281e
release-4.0: 11a9254
release-5.0: e2740f5

@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/critical labels Apr 2, 2021
@dveeden
Copy link
Contributor

dveeden commented Apr 2, 2021

The --column-type-info and --skip-binary-as-hex options of the MySQL client may be useful here.

With MySQL 8.0.22:

mysql> select a from t union select 10;
Field   1:  `a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     21
Max_length: 2
Decimals:   0
Flags:      NUM 


+------+
| a    |
+------+
|   10 |
|    1 |
|    2 |
+------+
3 rows in set (0.00 sec)

And with TiDB:

mysql> select a from t union select 10;
Field   1:  `a`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     20
Max_length: 3
Decimals:   0
Flags:      NOT_NULL UNSIGNED BINARY 


+----------+
| a        |
+----------+
| 0x00000A |
| 0x3130   |
| 0x000001 |
| 0x000002 |
+----------+
4 rows in set (0.00 sec)

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants