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

Vector datatype returns in protocol as VAR_STRING without vector hints

    XMLWordPrintable

Details

    Description

      The failing unit.conc_ps(test_vector) on big-endian highlights, a prepared statement protocol expecting to decode a SELECT from a VECTOR type column will end up with raw little endian.

      MariaDB [test]> select * from my_vector;
      Field   1:  `a`
      Org_field:  `a`
      Catalog:    `def`
      Database:   `test`
      Table:      `my_vector`
      Org_table:  `my_vector`
      Type:       VAR_STRING
      Collation:  binary (63)
      Length:     16
      Max_length: 16
      Decimals:   0
      Flags:      BINARY 
       
       
      +------------------+
      | a                |
      +------------------+
      |   �?�̌?���?ff�?        |
      +------------------+
      1 row in set (0.001 sec)
      

      from: libmariadb/unittest/libmariadb/ps.c (test_vector)

          float f1[4] = {1.0f, 1.1f, 1.2f, 1.3f};
          float f2[4] = {0.0};
      ...
          rc= mysql_stmt_prepare(stmt, SL("SELECT a FROM my_vector"));
          check_stmt_rc(rc, stmt);
        
          rc= mysql_stmt_execute(stmt);
          check_stmt_rc(rc, stmt);
        
          memset(&bind, 0, sizeof(MYSQL_BIND));
          bind.buffer= &f2;
          bind.buffer_length= sizeof(float) * 4;
          rc= mysql_stmt_bind_result(stmt, &bind);
          check_stmt_rc(rc, stmt);
        
          rc= mysql_stmt_fetch(stmt);
          check_stmt_rc(rc, stmt);
        
          mysql_stmt_close(stmt);
        
          if (memcmp(f1, f2, sizeof(float) * 4))
      

      A client application can reasonable expect to get the same results back that it sent, as Georg's test does. Currently because of the protocol, there's no indication that the resulting vector type data is anything that needs special handling (like endian consideration), so its just copied a raw blob copied over the top of float arrays.

      Recommendations:

      • Add a extended metadata for vector so that C/C can endian unpack it

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              danblack Daniel Black
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.