AttachmentsSizeSQL

From Request Tracker Wiki
Revision as of 15:03, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Found on my disk SQL that fetches attachments sizes from RT DB. It's not that trivial as we store it in headers. May be someone would find this useful. Works with mysql 4.1.x --RuslanZakirov

SELECT id, IF(
      LOCATE('Content-Length:', Headers),
      CAST(TRIM(
        SUBSTRING_INDEX(
          SUBSTRING_INDEX(Headers, 'Content-Length:', -1),
          "\n",
          1
        )
      ) AS UNSIGNED INTEGER),
      BINARY LENGTH(Content)
    ) ContentLength
FROM Attachments;