Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-32443

load data ignore check constraint applied not on every row

    XMLWordPrintable

Details

    Description

      Test:

      loaddata.test

      SET sql_mode='';
      CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
      LOAD DATA INFILE '../../std_data/loaddata7.dat' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',';
      SELECT * FROM t1;
      TRUNCATE TABLE t1;
      INSERT IGNORE INTO t1 VALUES (11,12),(33,33);
      SELECT * FROM t1;
      DROP TABLE t1;
      

      mysql-test/std_data/loaddata7.dat

      2,2
      3,3
      4,4
      5,5
      6,6
      

      Result:

      +SET sql_mode='';
      +CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
      +LOAD DATA INFILE '../../std_data/loaddata7.dat' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',';
      +Warnings:
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +SELECT * FROM t1;
      +v1	v2
      +2	2
      +3	3
      +4	4
      +5	5
      +TRUNCATE TABLE t1;
      +INSERT IGNORE INTO t1 VALUES (11,12),(33,33);
      +Warnings:
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +SELECT * FROM t1;
      +v1	v2
      +11	12
      +DROP TABLE t1;
      

      values 2,2 to 5,5 shouldn't have been inserted.

      Expected result:

      +LOAD DATA INFILE '../../std_data/loaddata7.dat' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',';
      +Warnings:
      +Note	1265	Data truncated for column 'v2' at row 1
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +Note	1265	Data truncated for column 'v2' at row 1
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +Note	1265	Data truncated for column 'v2' at row 1
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +Note	1265	Data truncated for column 'v2' at row 1
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +SELECT * FROM t1;
      +v1	v2
      +INSERT IGNORE INTO t1 VALUES (11,12),(33,33);
      +Warnings:
      +Warning	4025	CONSTRAINT `unequal` failed for `test`.`t1`
      +SELECT * FROM t1;
      +v1	v2
      +11	12
      +DROP TABLE t1;
      

      Which is the result if the v1,v2 where int rather than varchar or text

      Attachments

        Activity

          People

            serg Sergei Golubchik
            danblack Daniel Black
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.