Difference between revisions of "AttachmentsSizeSQL"

From Request Tracker Wiki
Jump to navigation Jump to search
m (1 revision: Import (2/2) from Kwiki on wiki.bestpractical.com)
m (2 revisions imported)
 
(No difference)

Latest revision as of 16:03, 6 April 2016

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;