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

Unexpected data from server for specific scenario of statement execution with mysql_stmt_send_long_data

    XMLWordPrintable

Details

    Description

      Steps to reproduce:

      • Prepare statement SELECT ?
      • Execute with MYSQL_TYPE_LONGLONG parameter (e.g. 42)
      • Read result (will be 42 as expected)
      • Execute with MYSQL_TYPE_VAR_STRING using mysql_stmt_send_long_data (e.g. 'AAAAAAAA')
      • Read incorrect result (will be '94624714364288' instead of expected 'AAAAAAAA')

      At the protocol level (without packet headers):

      Prepare:
      1653 454c 4543 5420 3f
      Response:
      0002 0000 0001 0001 0000 0000 <-- OK
      0364 6566 0000 0001 3f00 0c3f 0000 0000 0006 8000 0000 00 <-- param definition
      fe00 0002 00 <-- EOF
      0364 6566 0000 0001 3f00 0c3f 0000 0000 0006 8000 0000 00 <-- column definition
      fe00 0002 00 <-- EOF
       
      Execute with LONGLONG 0x44332211223344:
      1702 0000 0000 0100 0000 0001 0800 4433 2211 1122 3344
      Response:
      01 <-- columns count
      0364 6566 0000 0001 3f00 0c3f 0015 0000 0008 8100 0000 00 <-- column definition
      fe00 0002 00 <-- EOF
      0000 4433 2211 1122 3344 <- row
      fe00 0002 00 <-- EOF
       
      Execute with VAR_STRING 'AAAAAAAA':
      1802 0000 0000 0041 4141 4141 4141 41 <-- send long data
      1702 0000 0000 0100 0000 0101 fd00 <-- execute
      Response:
      01 <-- columns count
      03 6465 6600 0000 013f 000c 3f00 1500 0000 fd81 0000 0000 <-- column definition
      fe00 0002 00 <-- EOF
      00 000e 3934 3632 3437 3134 3336 3432 3838 <-- row with unexpected bytes
      fe00 0002 00 <-- EOF
      

      Code:

      The code to reproduce the issue is in attachement (test.c).
      It's quite messy but do the job. Originally this behavior was revealed during tests of the native rust driver against latest 10.3 and latest 10.4 (on circleci).

      Info

      MariaDb 5.5 is not affected.
      Unexpected string ('94624714364288') is always the same, i.e something like this:
      PREPARE SELECT ?, ?, ?
      EXECUTE WITH 42, 42, 42 -> (42, 42, 42)
      EXECUTE WITH 'AAAA', 'AAAA', 42 -> ('94624714364288', '94624714364288', 42)

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            blackbeam Anatoly Ikorsky
            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.