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

Wrong result on query with BIGINT column, it works with CAST

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • 11.1.2
    • N/A
    • None
    • None
    • Debian-based custom distro
      Linux version 6.1.34-gen
      Virtualized x86_64 CPU on proxmox (GenuineIntel Common KVM processor pc-i440fx-8.1 CPU @ 2.0GHz)
      Nextcloud 30.0.5.1

    Description

      Currently my employer uses a Nextcloud based solution for groupware.
      We found a bug on the files app, when after an upload, the previously updated files wouldn't show anymore. After a hard debugging time, we watered down the problem to a malfunctioning query.
      The original query, as extracted from MariaDB file log, looks like this, granted the parent and storage columns change values:

      SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `oc_filecache` `filecache` LEFT JOIN `oc_filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `oc_files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`filecache`.`parent` = 26) AND (`storage` = 4) ORDER BY `name` ASC
      

      In order to investigate this, I simplified the original query to this one:

      SELECT `filecache`.`fileid`,`storage`,`filecache`.`parent` FROM `oc_filecache` `filecache` WHERE (`filecache`.`parent` = 26) AND (`storage` = 4);
      

      For both queries, MariaDB returns empty set. However, the data IS there. When I filter either using only the parent or the storage column, the results are shown, as in the attached screenshot.

      After searching a bit on the internet, I came up with the idea of doing a cast. So I've validated the following query returns the desired results:

      SELECT `filecache`.`fileid`,`storage`,`filecache`.`parent` FROM `oc_filecache` `filecache` WHERE (CAST(`filecache`.`parent` AS SIGNED) = 26) AND (`storage` = 4);
      

      The table definition has also been attached. Both parent and storage columns are BIGINTs.

      I've noticed that there are rows with the value -1 for the parent. This and the cast working makes me think there's some issue about internal type conversion.

      Attachments

        1. 2025-01-22_14-54.png
          2025-01-22_14-54.png
          107 kB
        2. 2025-01-22_14-59.png
          2025-01-22_14-59.png
          75 kB
        3. 2025-02-03_12-23_1.png
          2025-02-03_12-23_1.png
          38 kB
        4. 2025-02-03_12-23.png
          2025-02-03_12-23.png
          60 kB
        5. 2025-02-03_12-31.png
          2025-02-03_12-31.png
          9 kB
        6. 2025-02-03_12-42.png
          2025-02-03_12-42.png
          88 kB
        7. 2025-02-04_17-39_1.png
          2025-02-04_17-39_1.png
          44 kB
        8. 2025-02-04_17-39.png
          2025-02-04_17-39.png
          78 kB
        9. 2025-02-04_17-51.png
          2025-02-04_17-51.png
          62 kB
        10. 2025-02-04_17-52.png
          2025-02-04_17-52.png
          40 kB
        11. screenshot-1.png
          screenshot-1.png
          16 kB

        Activity

          People

            alice Alice Sherepa
            edgarlemkeseti Edgar Roberto Lemke
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.