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

user variables in LOAD DATA don't work as expected #11941

Closed
kolbe opened this issue Aug 30, 2019 · 3 comments
Closed

user variables in LOAD DATA don't work as expected #11941

kolbe opened this issue Aug 30, 2019 · 3 comments
Labels
sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@kolbe
Copy link
Contributor

kolbe commented Aug 30, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

data.csv:

1,c

table:

CREATE TABLE `t` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
);

statement:

load data local infile 'data.csv' into table t fields terminated by ',' (id, @c) set c=upper(@c);
  1. What did you expect to see?

This should load the data from the file into the table, setting the value of column c to the uppercased value of the 2nd column in the CSV file, as occurs in MariaDB:

MariaDB [test]> load data local infile 'data.csv' into table t fields terminated by ',' (id, @c) set c=upper(@c);
Query OK, 1 row affected (0.002 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

MariaDB [test]> select * from t;
+----+------+
| id | c    |
+----+------+
|  1 | C    |
+----+------+
1 row in set (0.001 sec)
  1. What did you see instead?
TiDB [test]> load data local infile 'data.csv' into table t fields terminated by ',' (id, @c) set c=upper(@c);
Query OK, 1 row affected (0.01 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

TiDB [test]> select * from t;
+----+------+
| id | c    |
+----+------+
|  1 | NULL |
+----+------+
1 row in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
tidb_version(): Release Version: v3.0.3
Git Commit Hash: 836982c617fbaa42d74616eb9ba9ed4cae46c46b
Git Branch: HEAD
UTC Build Time: 2019-08-29 04:59:41
GoVersion: go version go1.12 linux/amd64
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@kolbe kolbe added the type/bug The issue is confirmed as a bug. label Aug 30, 2019
@lysu
Copy link
Contributor

lysu commented Aug 30, 2019

@kolbe #7707 nearly fixes this, but it be paused due to the priority and go to do other things at that time 😞 I can restart it if we need it 😄

@ghost
Copy link

ghost commented Jul 15, 2020

Verified against master:

mysql> load data local infile '/tmp/data.csv' into table t fields terminated by ',' (id, @c) set c=upper(@c);
Query OK, 1 row affected (0.02 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from t;
+----+------+
| id | c    |
+----+------+
|  1 | NULL |
+----+------+
1 row in set (0.00 sec)

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-769-g2024e4463
Edition: Community
Git Commit Hash: 2024e44636f2fb9798982a1cc0ec22176e07f5c1
Git Branch: master
UTC Build Time: 2020-07-14 09:26:07
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@ghost
Copy link

ghost commented Aug 3, 2020

Fixed in #18753 (not closed due to issue in close syntax.)

@ghost ghost closed this as completed Aug 3, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants