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

parse error when selecting on views using dynamic column

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.1, 5.5.29, 5.5.30, 5.3.12
    • 10.0.2, 5.5.31, 5.3.13
    • None
    • None

    Description

      The following query is fine :

      SELECT 
        R.splitlot_id,
        R.run_id, 
        I.ptest_info_id,
        COLUMN_GET(R.dynamic_flags,I.ptest_info_id as CHAR(1)),
        COLUMN_GET(R.dynamic_value,I.ptest_info_id as DECIMAL ) 
      FROM  
        wt_ptest_results_rows R INNER JOIN
        wt_ptest_info I on R.splitlot_id=I.splitlot_id
      where 
        COLUMN_GET(R.dynamic_value,I.ptest_info_id as DECIMAL) IS NOT NULL;

      but

      CREATE VIEW `wt_ptest_results_view`
      (splitlot_id,run_id,ptest_info_id,flags,value) AS 
      SELECT 
        R.splitlot_id,
        R.run_id, 
        I.ptest_info_id,
        COLUMN_GET(R.dynamic_flags,I.ptest_info_id as CHAR(1)),
        COLUMN_GET(R.dynamic_value,I.ptest_info_id as DECIMAL ) 
      FROM  
        wt_ptest_results_rows R INNER JOIN
        wt_ptest_info I on R.splitlot_id=I.splitlot_id
      where 
        COLUMN_GET(R.dynamic_value,I.ptest_info_id as DECIMAL) IS NOT NULL;
       
      select * from wt_ptest_results_view limit 1;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
      corresponds to your MariaDB server version for the right syntax to use near ') a
      s char(1) charset utf8) AS `flags`,cast(column_get(`r`.`dynamic_value`,`i`.`p' a
      t line 1
       
      show create view wt_ptest_results_view;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
      corresponds to your MariaDB server version for the right syntax to use near ') a
      s char(1) charset utf8) AS `flags`,cast(column_get(`r`.`dynamic_value`,`i`.`p' a
      t line 1

      Here is an simplified version of the tables in the test :

      CREATE TABLE `wt_ptest_info` (
        `splitlot_id` int(10) unsigned NOT NULL DEFAULT '0',
        `ptest_info_id` smallint(5) unsigned NOT NULL DEFAULT '0',
        KEY `wtptestinfo_splitlot_ptest` (`splitlot_id`,`ptest_info_id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 PACK_KEYS=1
       
       
      CREATE TABLE `wt_ptest_results_rows` (
        `splitlot_id` int(10) unsigned NOT NULL DEFAULT '0',
        `run_id` mediumint(7) unsigned NOT NULL DEFAULT '0',
        `dynamic_flags` blob,
        `dynamic_value` blob,
        PRIMARY KEY (`splitlot_id`,`run_id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1

      Attachments

        Activity

          sample data to insert into Dynamic column table schema

          stephane@skysql.com VAROQUI Stephane added a comment - sample data to insert into Dynamic column table schema

          problem is in incorrect column_get print method.

          sanja Oleksandr Byelkin added a comment - problem is in incorrect column_get print method.

          New test suite:
          create table t1 (i int, d blob);

          create view v1 as select i, column_get(d, 1 as binary) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as int) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as unsigned int) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as date) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as time) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as datetime) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as decimal) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as double) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          create view v1 as select i, column_get(d, 1 as char) as a from t1;
          select * from v1;
          show create view v1;
          drop view v1;

          drop table t1;

          sanja Oleksandr Byelkin added a comment - New test suite: create table t1 (i int, d blob); create view v1 as select i, column_get(d, 1 as binary) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as int) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as unsigned int) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as date) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as time) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as datetime) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as decimal) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as double) as a from t1; select * from v1; show create view v1; drop view v1; create view v1 as select i, column_get(d, 1 as char) as a from t1; select * from v1; show create view v1; drop view v1; drop table t1;

          Committed for review.

          sanja Oleksandr Byelkin added a comment - Committed for review.

          pushed

          sanja Oleksandr Byelkin added a comment - pushed

          People

            sanja Oleksandr Byelkin
            stephane@skysql.com VAROQUI Stephane
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.