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

The untested ha_spider::index_first_internal constructs broken queries

Details

    Description

      The easiest way to trigger this is by disabling the GBH in 10.11+:

      # ... (setup)
      set spider_same_server_link= 1;
      set global spider_same_server_link= 1;
      set spider_select_column_mode= 0;
      set spider_disable_group_by_handler= 1;
      evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
      OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
      CREATE TABLE t1 (c int);
      CREATE TABLE t1_s (c int)
      ENGINE=SPIDER COMMENT='wrapper "mariadb", srv "srv", table "t1"' ;
      SELECT MAX(c) FROM t1_s;
      drop table t1_s, t1;
      drop server srv;
      # ... (cleanup)
      

      Running this test results in

      mysqltest: At line 16: query 'SELECT MAX(c) FROM t1_s' failed: ER_BAD_FIELD_ERROR (1054): Unknown column 'c' in 'SELECT'
      

      The log shows that the SELECT query is translated to select max(`c`),min(`c`), missing the FROM part.

      The problem lies in ha_spider::index_first_internal, which is untested in the current spider regression test suites. That is, the following change causes no regression:

      modified   storage/spider/ha_spider.cc
      @@ -1911,6 +1911,7 @@ int ha_spider::index_prev(
       int ha_spider::index_first_internal(
         uchar *buf
       ) {
      +  abort();
         int error_num;
         backup_error_status();
         DBUG_ENTER("ha_spider::index_first_internal");
      

      The bug is the same as the failure of spider/bugfix.mdev_35874 with --view-protocol and the current draft patch of MDEV-36307 applied (bb-10.5-mdev-35452 d9d2fb9d07e47296faee79d230a38f7f9a0b3ef6)

      Attachments

        Issue Links

          Activity

            ycp Yuchen Pei added a comment - - edited

            Hi holyfoot, ptal thanks

            2b10581b143 bb-10.5-mdev-36324 MDEV-36324 MDEV-35452 Missing appending FROM ... in spider_mbase_handler::append_key_select

            ycp Yuchen Pei added a comment - - edited Hi holyfoot , ptal thanks 2b10581b143 bb-10.5-mdev-36324 MDEV-36324 MDEV-35452 Missing appending FROM ... in spider_mbase_handler::append_key_select

            looks ok to push.

            holyfoot Alexey Botchkov added a comment - looks ok to push.
            ycp Yuchen Pei added a comment -

            Pushed d3c5c47e0e8ba4cbca2b47e80a874841f7ba6108 to 10.5

            ycp Yuchen Pei added a comment - Pushed d3c5c47e0e8ba4cbca2b47e80a874841f7ba6108 to 10.5
            ycp Yuchen Pei added a comment -

            it actually missed the 10.5 release, so i merged to 10.6 and removed the 10.5.x fixversion. I am not sure whether the 10.6+ versions are correct or off by 1.

            ycp Yuchen Pei added a comment - it actually missed the 10.5 release, so i merged to 10.6 and removed the 10.5.x fixversion. I am not sure whether the 10.6+ versions are correct or off by 1.

            People

              ycp Yuchen Pei
              ycp Yuchen Pei
              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.