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

Union with bound variable silently trims result

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • Server
    • None

    Description

      The following query:

      select v
      from (
        select ? v
        union all
        select ? v
      ) t
      

      silently trims the `v` column when the column is longer than 65536 bytes.

      This is highly dangerous as UNION and bind value is basic SQL functionality frequently used.

      In our usecase, such query was built by ORM and MySQL silently corrupted our data.

      Full repro attached.

      Please reproduce on your side and fix. There should be no artificial limit of the string length.

      The current/wrong repro output:

      expected:
      Array
      (
          [0] => Array
              (
                  [v] => xxx...65540*...xxx
              )
       
          [1] => Array
              (
                  [v] => yxxx...65540*...xxx
              )
       
      )
       
      actual using mysqli driver:
      Array
      (
          [0] => Array
              (
                  [v] => xxxx
              )
       
          [1] => Array
              (
                  [v] => yxxxx
              )
       
      )
      bool(false)
       
      actual using PDO driver:
      Array
      (
          [0] => Array
              (
                  [v] => xxxx
              )
       
          [1] => Array
              (
                  [v] => yxxxx
              )
       
      )
      bool(false)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            mv Michael Voříšek
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.