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

ALTER performs vector truncation without WARN_DATA_TRUNCATED or similar warnings/errors

    XMLWordPrintable

Details

    Description

      ALTER TABLE is able to modify a vector column to a shorter length (which is good). However it does so without the usual warnings/errors produced in a similar situation for other data types.

      create table t (v vector(2));
      insert into t values (0x3131313132323232);
      select * from t;
      alter table t modify v vector(1);
      select * from t;
       
      # Cleanup
      drop table t;
      

      7aab5e35d714fc3b6de68f5158072d5ecdf62faa

      create table t (v vector(2));
      insert into t values (0x3131313132323232);
      select * from t;
      v
      11112222
      alter table t modify v vector(1);
      select * from t;
      v
      1111
      

      In the same situation, modification binary(8) => binary(4) produces WARN_DATA_TRUNCATED (error or warning, depending on the strict mode / ignore clause).

      create table t (v binary(8));
      insert into t values (0x3131313132323232);
      select * from t;
      v
      11112222
      alter table t modify v binary(4);
      bug.t                                    [ fail ]
              Test ended at 2024-10-31 23:41:15
       
      CURRENT_TEST: bug.t
      mysqltest: At line 4: query 'alter table t modify v binary(4)' failed: WARN_DATA_TRUNCATED (1265): Data truncated for column 'v' at row 1
      

      set sql_mode='';
      alter table t modify v binary(4);
      Warnings:
      Warning	1265	Data truncated for column 'v' at row 1
      select * from t;
      v
      1111
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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