AttachmentsSizeSQL

From Request Tracker Wiki
Revision as of 16: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
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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;