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

TYPE OF, ROW TYPE OF and Oracle-style db.seq.NEXTVAL accept a #mysql50# database in default old_mode

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.2
    • 13.2
    • Parser
    • None

    Description

      Anchored type declarations and the db.seq.NEXTVAL / db.seq.CURRVAL syntax build the Table_ident directly, not through LEX::make_table_ident(), so the database name is not checked. In default old_mode a routine can read column types from a table in a #mysql50# database, and NEXTVAL advances a sequence there. %TYPE and %ROWTYPE in sql_mode=ORACLE behave the same.

      --source include/have_sequence.inc
      let $D= `select @@datadir`;
      --mkdir $D/d-b
      set old_mode=MYSQL50_TABLE_NAMES;
      create table `#mysql50#d-b`.t1 (a varchar(7));
      create sequence `#mysql50#d-b`.s;
      set old_mode=default;
      --error ER_WRONG_DB_NAME
      select nextval(`#mysql50#d-b`.s);
      --echo # BUG if the statements below are accepted
      delimiter $$;
      create function f1() returns text begin declare v type of `#mysql50#d-b`.t1.a default 'abcdefghijkl'; return v; end $$
      create function f2() returns text begin declare r row type of `#mysql50#d-b`.t1; set r.a='abcdefghijkl'; return r.a; end $$
      delimiter ;$$
      --error ER_DATA_TOO_LONG
      select f1();
      --error ER_DATA_TOO_LONG
      select f2();
      set sql_mode=oracle;
      select "#mysql50#d-b".s.nextval;
      set sql_mode=default;
      drop function f1;
      drop function f2;
      set old_mode=MYSQL50_TABLE_NAMES;
      drop database `#mysql50#d-b`;

      13.2.0-MariaDB-asan-debug-log source revision: bd4d5680ca4e7d8fd3b953e9f9d342599ac5c07c
       
      select nextval(`#mysql50#d-b`.s);
      ERROR 42000: Incorrect database name '#mysql50#d-b'
      select f1();
      ERROR 22001: Data too long for column 'a' at row 0
      select f2();
      ERROR 22001: Data too long for column 'a' at row 0
      set sql_mode=oracle;
      select "#mysql50#d-b".s.nextval;
      "#mysql50#d-b".s.nextval
      1

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 0.25d
                  0.25d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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