tiup sql client corrupts SQL column names
Open
Nobody has claimed this yet.
type/bug
- Dominant language
- Go
- Stars
- 466
- Forks
- 338
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 8
Description
Bug Report
Credit for this bug report goes to @Alkaagr81
- What did you do?
create table t1 (c1 int, c2 char(6), c3 int);
create table t2 (c1 int, c2 char(6));
insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2;
- What did you expect to see?
Using mysql client, no error:
tidb> create table t1 (c1 int, c2 char(6), c3 int);
Query OK, 0 rows affected (0.06 sec)
tidb> create table t2 (c1 int, c2 char(6));
Query OK, 0 rows affected (0.07 sec)
tidb> insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
tidb> update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
tidb> update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
tidb> drop table t1, t2;
- What did you see instead?
Using Tiup SQL client:
my:root@127.0.0.1:4000=> use test;
USE
my:root@127.0.0.1:4000=> create table t1 (c1 int, c2 char(6), c3 int);
CREATE TABLE
my:root@127.0.0.1:4000=> create table t2 (c1 int, c2 char(6));
CREATE TABLE
my:root@127.0.0.1:4000=> insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
error: mysql: 1054: Unknown column 't1c2-1' in 'field list'
my:root@127.0.0.1:4000=> update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
error: mysql: 1054: Unknown column 't2c2-1' in 'field list'
my:root@127.0.0.1:4000=> update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
error: mysql: 1054: Unknown column 't2c2-1' in 'field list'
my:root@127.0.0.1:4000=> drop table t1, t2;
- What version of TiUP are you using (
tiup --version)?
morgo@ubuntu:~/go/src/github.com/mysql/mysql-server$ tiup --version
1.4.0 tiup
Go Version: go1.16.2
Git Ref: v1.4.0
GitHash: eb335e6ad9d0dc19d1c43db422cd409d62bc3cea
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported INSERT and UPDATE statements through the TiUP SQL client, then compare their handling with the mysql client behavior shown in the issue. Trace the SQL client’s processing of double-quoted string values; done means those statements no longer produce Unknown column errors and match the expected client behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100