Bug #98925 LOAD DATA INFILE fails if there is a functional index
Submitted: 12 Mar 2020 11:16 Modified: 21 May 2020 14:27
Reporter: Saverio Miroddi Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any

[12 Mar 2020 11:16] Saverio Miroddi
Description:
If a table has a functional key part (a functional index without an explicitly generated column), LOAD DATA INFILE will fail with an error.

How to repeat:
Sample script for Linux, to be run without, then with the KEY row uncommented.

The second version will raise `ERROR 1261 (01000): Row 1 doesn't contain data for all columns`.

####

echo '[]' > /tmp/test_data.csv

mysql <<'SQL'
  CREATE SCHEMA IF NOT EXISTS tmp;

  CREATE TEMPORARY TABLE tmp.issue_load_data_on_functional_index
  (
    json_col JSON
    -- , KEY json_col ( (CAST(json_col -> '$' AS UNSIGNED ARRAY)) )
  );

  LOAD DATA INFILE '/tmp/test_data.csv' INTO TABLE tmp.issue_load_data_on_functional_index;
SQL
[12 Mar 2020 11:24] Saverio Miroddi
For reference, explicitly specifying the column(s) work:

    LOAD DATA INFILE '/tmp/test_data.csv' INTO TABLE tmp.issue_load_data_on_functional_index (json_col);
[12 Mar 2020 12:50] MySQL Verification Team
Hello Saverio M,

Thank you for the report and feedback.
Observed this with 8.0.19 builds on OL7.

regards,
Umesh
[21 May 2020 14:27] Paul DuBois
Posted by developer:
 
Fixed in 8.0.21.

LOAD DATA did not ignore hidden generated columns when parsing input
file rows.