sql 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #------------------------------------------------------------------------------
  2. # $File: sql,v 1.23 2021/07/30 14:53:38 christos Exp $
  3. # sql: file(1) magic for SQL files
  4. #
  5. # From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
  6. # Recognize some MySQL files.
  7. # Elan Ruusamae <glen@delfi.ee>, added MariaDB signatures
  8. # from https://bazaar.launchpad.net/~maria-captains/maria/5.5/view/head:/support-files/magic
  9. #
  10. 0 beshort 0xfe01 MySQL table definition file
  11. >2 byte x Version %d
  12. >3 byte 0 \b, type UNKNOWN
  13. >3 byte 1 \b, type DIAM_ISAM
  14. >3 byte 2 \b, type HASH
  15. >3 byte 3 \b, type MISAM
  16. >3 byte 4 \b, type PISAM
  17. >3 byte 5 \b, type RMS_ISAM
  18. >3 byte 6 \b, type HEAP
  19. >3 byte 7 \b, type ISAM
  20. >3 byte 8 \b, type MRG_ISAM
  21. >3 byte 9 \b, type MYISAM
  22. >3 byte 10 \b, type MRG_MYISAM
  23. >3 byte 11 \b, type BERKELEY_DB
  24. >3 byte 12 \b, type INNODB
  25. >3 byte 13 \b, type GEMINI
  26. >3 byte 14 \b, type NDBCLUSTER
  27. >3 byte 15 \b, type EXAMPLE_DB
  28. >3 byte 16 \b, type CSV_DB
  29. >3 byte 17 \b, type FEDERATED_DB
  30. >3 byte 18 \b, type BLACKHOLE_DB
  31. >3 byte 19 \b, type PARTITION_DB
  32. >3 byte 20 \b, type BINLOG
  33. >3 byte 21 \b, type SOLID
  34. >3 byte 22 \b, type PBXT
  35. >3 byte 23 \b, type TABLE_FUNCTION
  36. >3 byte 24 \b, type MEMCACHE
  37. >3 byte 25 \b, type FALCON
  38. >3 byte 26 \b, type MARIA
  39. >3 byte 27 \b, type PERFORMANCE_SCHEMA
  40. >3 byte 127 \b, type DEFAULT
  41. >0x0033 ulong x \b, MySQL version %d
  42. 0 belong&0xffffff00 0xfefe0500 MySQL ISAM index file
  43. >3 byte x Version %d
  44. 0 belong&0xffffff00 0xfefe0600 MySQL ISAM compressed data file
  45. >3 byte x Version %d
  46. 0 belong&0xffffff00 0xfefe0700 MySQL MyISAM index file
  47. >3 byte x Version %d
  48. >14 beshort x \b, %d key parts
  49. >16 beshort x \b, %d unique key parts
  50. >18 byte x \b, %d keys
  51. >28 bequad x \b, %lld records
  52. >36 bequad x \b, %lld deleted records
  53. 0 belong&0xffffff00 0xfefe0800 MySQL MyISAM compressed data file
  54. >3 byte x Version %d
  55. 0 belong&0xffffff00 0xfefe0900 MySQL Maria index file
  56. >3 byte x Version %d
  57. 0 belong&0xffffff00 0xfefe0a00 MySQL Maria compressed data file
  58. >3 byte x Version %d
  59. 0 belong&0xffffff00 0xfefe0c00
  60. >4 string MACF MySQL Maria control file
  61. >>3 byte x Version %d
  62. 0 string \376bin MySQL replication log,
  63. >9 long x server id %d
  64. >8 byte 1
  65. >>13 long 69 \b, MySQL V3.2.3
  66. >>>19 string x \b, server version %s
  67. >>13 long 75 \b, MySQL V4.0.2-V4.1
  68. >>>25 string x \b, server version %s
  69. >8 byte 15 MySQL V5+,
  70. >>25 string x server version %s
  71. >4 string MARIALOG MySQL Maria transaction log file
  72. >>3 byte x Version %d
  73. #------------------------------------------------------------------------------
  74. # iRiver H Series database file
  75. # From Ken Guest <ken@linux.ie>
  76. # As observed from iRivNavi.iDB and unencoded firmware
  77. #
  78. 0 string iRivDB iRiver Database file
  79. >11 string >\0 Version %s
  80. >39 string iHP-100 [H Series]
  81. #------------------------------------------------------------------------------
  82. # SQLite database files
  83. # Ken Guest <ken@linux.ie>, Ty Sarna, Zack Weinberg
  84. #
  85. # Version 1 used GDBM internally; its files cannot be distinguished
  86. # from other GDBM files.
  87. #
  88. # Version 2 used this format:
  89. 0 string **\ This\ file\ contains\ an\ SQLite SQLite 2.x database
  90. # URL: https://en.wikipedia.org/wiki/SQLite
  91. # Reference: https://www.sqlite.org/fileformat.html
  92. # Update: Joerg Jenderek
  93. # Version 3 of SQLite allows applications to embed their own "user version"
  94. # number in the database at offset 60. Later, SQLite added an "application id"
  95. # at offset 68 that is preferred over "user version" for indicating the
  96. # associated application.
  97. #
  98. 0 string SQLite\ format\ 3
  99. # skip DROID fmt-729-signature-id-1053.sqlite by checking for valid page size
  100. >16 ubeshort >0 SQLite 3.x
  101. # deprecated
  102. #!:mime application/x-sqlite3
  103. !:mime application/vnd.sqlite3
  104. # seldom found extension sqlite3 like in SyncData.sqlite3
  105. # db
  106. # db3 like: AddrBook.db3 cgipcrvp.db3
  107. # https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2freference%2fhelpdatabase
  108. # help is used for newer Maple help database
  109. # SQLite database weewx.sdb used by weather software weewx
  110. # https://www.weewx.com/docs/usersguide.htm
  111. # Avira Antivir use extension "dbe" like in avevtdb.dbe, avguard_tchk.dbe
  112. # Unfortunately extension sqlite also used for other databases starting with string
  113. # "TTCONTAINER" like in tracks.sqlite contentconsumer.sqlite contentproducerrepository.sqlite
  114. # and with string "ZV-zlib" in like extra.sqlite
  115. >>68 belong !0x5CDE09EF database
  116. !:ext sqlite/sqlite3/db/db3/dbe/sdb/help
  117. >>68 belong =0x5CDE09EF database
  118. # maple is used for Maple Workbook
  119. !:ext maple
  120. >>60 belong =0x5f4d544e (Monotone source repository)
  121. # if no known user version then check for Application IDs with default clause
  122. >>60 belong !0x5f4d544e
  123. # The "Application ID" set by PRAGMA application_id
  124. >>>68 belong =0x0f055112 (Fossil checkout)
  125. >>>68 belong =0x0f055113 (Fossil global configuration)
  126. >>>68 belong =0x0f055111 (Fossil repository)
  127. >>>68 belong =0x42654462 (Bentley Systems BeSQLite Database)
  128. >>>68 belong =0x42654c6e (Bentley Systems Localization File)
  129. >>>68 belong =0x47504b47 (OGC GeoPackage file)
  130. # https://www.sqlite.org/src/artifact?ci=trunk&filename=magic.txt
  131. >>>68 belong =0x47503130 (OGC GeoPackage version 1.0 file)
  132. >>>68 belong =0x45737269 (Esri Spatially-Enabled Database)
  133. >>>68 belong =0x4d504258 (MBTiles tileset)
  134. # https://www.maplesoft.com/support/help/errors/view.aspx?path=Formats/Maple
  135. >>>68 belong =0x5CDE09EF (Maple Workbook)
  136. # unknown application ID
  137. >>>68 default x
  138. >>>>68 belong !0 \b, application id %u
  139. # The "user version" as read and set by the user_version pragma like:
  140. # 1 2 4 5 7 9 10 25 36 43 53 400 416 131073 131074 131075
  141. >>60 belong !0 \b, user version %d
  142. # SQLITE_VERSION_NUMBER like: 0 3008011 3016002 3007014 3017000 3022000 3028000 3031001
  143. >>96 belong x \b, last written using SQLite version %d
  144. # database page size in bytes; a power of two between 512 and 32768, or 1 for 65536
  145. # like: 512 1024 often 4096 32768
  146. >>16 ubeshort !4096 \b, page size %u
  147. # File format write version. 1 for legacy; 2 for WAL; 0 for corruptDB.sqlite
  148. >>18 ubyte !1 \b, writer version %u
  149. # File format read version. 1 for legacy; 2 for WAL; 4 for corruptDB.sqlite
  150. >>19 ubyte !1 \b, read version %u
  151. # Bytes of unused "reserved" space at the end of each page. Usually 0
  152. >>20 ubyte !0 \b, unused bytes %u
  153. # maximum embedded payload fraction. Must be 64; 1 for corruptDB.sqlite
  154. >>21 ubyte !64 \b, maximum payload %u
  155. # Minimum embedded payload fraction. Must be 32; 1 for corruptDB.sqlite
  156. >>22 ubyte !32 \b, minimum payload %u
  157. # Leaf payload fraction. Must be 32; 0 for corruptDB.sqlite
  158. >>23 ubyte !32 \b, leaf payload %u
  159. # file change counter
  160. >>24 ubelong x \b, file counter %u
  161. # Size of the database file in pages
  162. >>28 ubelong x \b, database pages %u
  163. # page number of the first freelist trunk page like: 0 2 3 4 5 9
  164. # 10 13 14 15 16 17 18 19 23 36 39 46 50 136 190 217 307 505 516 561 883 1659
  165. >>32 ubelong !0 \b, 1st free page %u
  166. # total number of freelist pages
  167. >>36 ubelong !0 \b, free pages %u
  168. # The schema cookie like: 2 3 4 6 7 9 A D E F 13 14 1C 25 2A 2F 33 44 4B 53 5A 5F 62 86 87 8F 91 A8
  169. >>40 ubelong x \b, cookie %#x
  170. # the schema format number. Supported formats are 1 2 3 and often 4
  171. # 3328 for corruptDB.sqlite and 0 for 512 byte storage.sqlite (TorBrowser Firefox Thunderbird)
  172. >>44 ubelong x \b, schema %u
  173. # Suggested cache size like: 0 2000
  174. >>48 ubelong !0 \b, cache page size %u
  175. # The page number of the largest root b-tree page when in auto-vacuum or incremental-vacuum modes, or zero otherwise.
  176. >>52 ubelong !0 \b, largest root page %u
  177. # The database text encoding; a value of 1 means UTF-8; 2 means UTF-16le; 3 means UTF-16be
  178. #>>56 ubelong x \b, encoding %u
  179. >>56 ubelong x
  180. >>>56 ubelong =1 \b, UTF-8
  181. >>>56 ubelong =2 \b, UTF-16 little endian
  182. >>>56 ubelong =3 \b, UTF-16 big endian
  183. # 0 for corruptDB.sqlite and for storage.sqlite with database pages 1 (TorBrowser Firefox Thunderbird)
  184. # https://mozilla.github.io/firefox-browser-architecture/text/0010-firefox-data-stores.html
  185. >>>56 default x
  186. >>>>56 ubelong x \b, unknown %#x encoding
  187. # True (non-zero) for incremental-vacuum mode; false (zero) otherwiseqy
  188. >>64 ubelong !0 \b, vacuum mode %u
  189. # Reserved for expansion. Must be zero
  190. >>72 uquad !0 \b, reserved %#llx
  191. # The version-valid-for number like:
  192. # 1 2 3 4 C F 68h 95h 266h A99h 3DCDh B7CEh
  193. >>92 ubelong x \b, version-valid-for %u
  194. # SQLite Write-Ahead Log from SQLite version >= 3.7.0
  195. # https://www.sqlite.org/fileformat.html#walformat
  196. 0 belong&0xfffffffe 0x377f0682 SQLite Write-Ahead Log,
  197. !:ext sqlite-wal/db-wal
  198. >4 belong x version %d
  199. # SQLite Rollback Journal
  200. # https://www.sqlite.org/fileformat.html#rollbackjournal
  201. 0 string \xd9\xd5\x05\xf9\x20\xa1\x63\xd7 SQLite Rollback Journal
  202. # Panasonic channel list database svl.bin or svl.db added by Joerg Jenderek
  203. # https://github.com/PredatH0r/ChanSort
  204. 0 string PSDB\0 Panasonic channel list DataBase
  205. !:ext db/bin
  206. #!:mime application/x-db-svl-panasonic
  207. >126 string SQLite\ format\ 3
  208. #!:mime application/x-panasonic-sqlite3
  209. >>&-15 indirect x \b; contains
  210. # H2 Database from https://www.h2database.com/
  211. 0 string --\ H2\ 0.5/B\ --\ \n H2 Database file