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

Spider wrapper name is case sensitive

Details

    Description

      MariaDB [(none)]> CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '/tmp/build.sock',DATABASE 'test',user 'buildbot',PASSWORD '');
      Query OK, 0 rows affected (0.001 sec)
       
      MariaDB [(none)]> SELECT spider_direct_sql ('SELECT 1','','SRV "srv"');
      ERROR 12521 (HY000): Can't use wrapper 'MYSQL' for SQL connection
      

      But if the wrapper is defined in lower case it is accepted.

      MariaDB [(none)]> CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET '/tmp/build.sock',DATABASE 'test',user 'buildbot',PASSWORD '');
      Query OK, 0 rows affected (0.001 sec)
       
      MariaDB [(none)]> SELECT spider_bg_direct_sql ('SET SESSION _offset=2','','SRV "srv"');
      ERROR 12720 (HY000): Host: and Socket:/tmp/build.sock aim self server. Please change spider_same_server_link parameter if this link is required.
      MariaDB [(none)]> set spider_same_server_link=1;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [(none)]> SELECT spider_bg_direct_sql ('SET @offset=2','','SRV "srv"');
      +-------------------------------------------------------+
      | spider_bg_direct_sql ('SET @offset=2','','SRV "srv"') |
      +-------------------------------------------------------+
      |                                                     1 |
      +-------------------------------------------------------+
      1 row in set (0.001 sec)
      

      Desired behaviour - accept any case variant of MySQL (and possibly MariaDB too).

      Attachments

        Activity

          ycp Yuchen Pei added a comment -

          Hi holyfoot,

          ptal thanks:

          e4815ad5518 upstream/bb-10.5-mdev-35807 MDEV-35807 Case-insensitive wrappers in spider
          b9acf4f4760 MDEV-35807 Removed an unused function spider_cmp_trx_alter_table
          

          ycp Yuchen Pei added a comment - Hi holyfoot , ptal thanks: e4815ad5518 upstream/bb-10.5-mdev-35807 MDEV-35807 Case-insensitive wrappers in spider b9acf4f4760 MDEV-35807 Removed an unused function spider_cmp_trx_alter_table

          ok to push.

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

          I think this should be pushed to 10.5 because it is a follow up to MDEV-32157 which was pushed in 2023-09

          ycp Yuchen Pei added a comment - I think this should be pushed to 10.5 because it is a follow up to MDEV-32157 which was pushed in 2023-09
          ycp Yuchen Pei added a comment - - edited

          To expand on the previous comment, note that without the patch for this issue, the following test fails at spider_direct_sql as expected:

          --disable_query_log
          --disable_result_log
          --source ../../t/test_init.inc
          --enable_result_log
          --enable_query_log
          set spider_same_server_link= 1;
          evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL
          OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
           
          create table t2 (c int);
           
          create table t1 (c int) ENGINE=Spider COMMENT='srv "srv",TABLE "t2"';
          select spider_direct_sql('select 1', '', 'srv "srv"');
           
          drop table t1, t2;
          drop server srv;
          --disable_query_log
          --disable_result_log
          --source ../../t/test_deinit.inc
          --enable_result_log
          --enable_query_log
          

          However, it succeeded at creating the table t1, despite using the same foreign server. If we revert the following changes in the MDEV-32157 patch 18990f007366863e2066c2905993358ceb941ce3, then the testcase fails at creating the t1 table in the same way:

          @@ -3140,7 +3143,7 @@ int spider_parse_connect_info(
                 {
                   if (
                     spider_dbton[roop_count2].wrapper &&
          -          !strcmp(share->tgt_wrappers[roop_count],
          +          !strcasecmp(share->tgt_wrappers[roop_count],
                       spider_dbton[roop_count2].wrapper)
                   ) {
                     break;
          @@ -4080,7 +4083,7 @@ int spider_create_conn_keys(
                     spider_dbton[roop_count2].wrapper : "NULL"));
                 if (
                   spider_dbton[roop_count2].wrapper &&
          -        !strcmp(share->tgt_wrappers[roop_count],
          +        !strcasecmp(share->tgt_wrappers[roop_count],
                     spider_dbton[roop_count2].wrapper)
                 ) {
                   spider_set_bit(share->dbton_bitmap, roop_count2);
          

          So for consistency the patch for this issue should be applied to 10.5.

          ycp Yuchen Pei added a comment - - edited To expand on the previous comment, note that without the patch for this issue, the following test fails at spider_direct_sql as expected: --disable_query_log --disable_result_log --source ../../t/test_init.inc --enable_result_log --enable_query_log set spider_same_server_link= 1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK" , DATABASE 'test' , user 'root' );   create table t2 (c int );   create table t1 (c int ) ENGINE=Spider COMMENT= 'srv "srv",TABLE "t2"' ; select spider_direct_sql( 'select 1' , '' , 'srv "srv"' );   drop table t1, t2; drop server srv; --disable_query_log --disable_result_log --source ../../t/test_deinit.inc --enable_result_log --enable_query_log However, it succeeded at creating the table t1, despite using the same foreign server. If we revert the following changes in the MDEV-32157 patch 18990f007366863e2066c2905993358ceb941ce3, then the testcase fails at creating the t1 table in the same way: @@ -3140,7 +3143,7 @@ int spider_parse_connect_info( { if ( spider_dbton[roop_count2].wrapper && - !strcmp(share->tgt_wrappers[roop_count], + !strcasecmp(share->tgt_wrappers[roop_count], spider_dbton[roop_count2].wrapper) ) { break; @@ -4080,7 +4083,7 @@ int spider_create_conn_keys( spider_dbton[roop_count2].wrapper : "NULL")); if ( spider_dbton[roop_count2].wrapper && - !strcmp(share->tgt_wrappers[roop_count], + !strcasecmp(share->tgt_wrappers[roop_count], spider_dbton[roop_count2].wrapper) ) { spider_set_bit(share->dbton_bitmap, roop_count2); So for consistency the patch for this issue should be applied to 10.5.
          ycp Yuchen Pei added a comment -

          pushed the following to 10.5

          92d5882ffd5 upstream/bb-10.5-ycp-push upstream/10.5 MDEV-35807 Case-insensitive wrappers in spider
          71244c30a11 MDEV-35807 Removed an unused function spider_cmp_trx_alter_table
          

          ycp Yuchen Pei added a comment - pushed the following to 10.5 92d5882ffd5 upstream/bb-10.5-ycp-push upstream/10.5 MDEV-35807 Case-insensitive wrappers in spider 71244c30a11 MDEV-35807 Removed an unused function spider_cmp_trx_alter_table

          People

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