sql 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. #------------------------------------------------------------------------------
  2. # $File: sql,v 1.26 2023/04/29 17:26:58 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. # Update: Joerg Jenderek
  89. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/s/sqlite-2x.trid.xml
  90. # Note: called "SQLite 2.x database" by TrID and "SQLite Database File Format" version 2 by DROID via PUID fmt/1135
  91. # Version 2 used this format:
  92. 0 string **\ This\ file\ contains\ an\ SQLite SQLite 2.x database
  93. !:mime application/x-sqlite2
  94. # FileAttributesStore.db test.sqlite2
  95. !:ext sqlite/sqlite2/db
  96. # URL: https://en.wikipedia.org/wiki/SQLite
  97. # Reference: https://www.sqlite.org/fileformat.html
  98. # Update: Joerg Jenderek
  99. # Version 3 of SQLite allows applications to embed their own "user version"
  100. # number in the database at offset 60. Later, SQLite added an "application id"
  101. # at offset 68 that is preferred over "user version" for indicating the
  102. # associated application.
  103. #
  104. 0 string SQLite\ format\ 3
  105. # skip DROID fmt-729-signature-id-1053.sqlite by checking for valid page size
  106. >16 ubeshort >0 SQLite 3.x
  107. # deprecated
  108. #!:mime application/x-sqlite3
  109. !:mime application/vnd.sqlite3
  110. # seldom found extension sqlite3 like in SyncData.sqlite3
  111. # db
  112. # db3 like: AddrBook.db3 cgipcrvp.db3
  113. # https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2freference%2fhelpdatabase
  114. # help is used for newer Maple help database
  115. # SQLite database weewx.sdb used by weather software weewx
  116. # https://www.weewx.com/docs/usersguide.htm
  117. # Avira Antivir use extension "dbe" like in avevtdb.dbe, avguard_tchk.dbe
  118. # Unfortunately extension sqlite also used for other databases starting with string
  119. # "TTCONTAINER" like in tracks.sqlite contentconsumer.sqlite contentproducerrepository.sqlite
  120. # and with string "ZV-zlib" in like extra.sqlite
  121. >>68 belong !0x5CDE09EF database
  122. !:ext sqlite/sqlite3/db/db3/dbe/sdb/help
  123. >>68 belong =0x5CDE09EF database
  124. # maple is used for Maple Workbook
  125. !:ext maple
  126. >>60 belong =0x5f4d544e (Monotone source repository)
  127. # if no known user version then check for Application IDs with default clause
  128. >>60 belong !0x5f4d544e
  129. # The "Application ID" set by PRAGMA application_id
  130. >>>68 belong =0x0f055112 (Fossil checkout)
  131. >>>68 belong =0x0f055113 (Fossil global configuration)
  132. >>>68 belong =0x0f055111 (Fossil repository)
  133. >>>68 belong =0x42654462 (Bentley Systems BeSQLite Database)
  134. >>>68 belong =0x42654c6e (Bentley Systems Localization File)
  135. >>>68 belong =0x47504b47 (OGC GeoPackage file)
  136. # https://www.sqlite.org/src/artifact?ci=trunk&filename=magic.txt
  137. >>>68 belong =0x47503130 (OGC GeoPackage version 1.0 file)
  138. >>>68 belong =0x45737269 (Esri Spatially-Enabled Database)
  139. >>>68 belong =0x4d504258 (MBTiles tileset)
  140. # https://www.maplesoft.com/support/help/errors/view.aspx?path=Formats/Maple
  141. >>>68 belong =0x5CDE09EF (Maple Workbook)
  142. # unknown application ID
  143. >>>68 default x
  144. >>>>68 belong !0 \b, application id %u
  145. # The "user version" as read and set by the user_version pragma like:
  146. # 1 2 4 5 7 9 10 25 36 43 53 400 416 131073 131074 131075
  147. >>60 belong !0 \b, user version %d
  148. # SQLITE_VERSION_NUMBER like: 0 3008011 3016002 3007014 3017000 3022000 3028000 3031001
  149. >>96 belong x \b, last written using SQLite version %d
  150. # database page size in bytes; a power of two between 512 and 32768, or 1 for 65536
  151. # like: 512 1024 often 4096 32768
  152. >>16 ubeshort !4096 \b, page size %u
  153. # File format write version. 1 for legacy; 2 for WAL; 0 for corruptDB.sqlite
  154. >>18 ubyte !1 \b, writer version %u
  155. # File format read version. 1 for legacy; 2 for WAL; 4 for corruptDB.sqlite
  156. >>19 ubyte !1 \b, read version %u
  157. # Bytes of unused "reserved" space at the end of each page. Usually 0
  158. >>20 ubyte !0 \b, unused bytes %u
  159. # maximum embedded payload fraction. Must be 64; 1 for corruptDB.sqlite
  160. >>21 ubyte !64 \b, maximum payload %u
  161. # Minimum embedded payload fraction. Must be 32; 1 for corruptDB.sqlite
  162. >>22 ubyte !32 \b, minimum payload %u
  163. # Leaf payload fraction. Must be 32; 0 for corruptDB.sqlite
  164. >>23 ubyte !32 \b, leaf payload %u
  165. # file change counter
  166. >>24 ubelong x \b, file counter %u
  167. # Size of the database file in pages
  168. >>28 ubelong x \b, database pages %u
  169. # page number of the first freelist trunk page like: 0 2 3 4 5 9
  170. # 10 13 14 15 16 17 18 19 23 36 39 46 50 136 190 217 307 505 516 561 883 1659
  171. >>32 ubelong !0 \b, 1st free page %u
  172. # total number of freelist pages
  173. >>36 ubelong !0 \b, free pages %u
  174. # 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
  175. >>40 ubelong x \b, cookie %#x
  176. # the schema format number. Supported formats are 1 2 3 and often 4
  177. # 3328 for corruptDB.sqlite and 0 for 512 byte storage.sqlite (TorBrowser Firefox Thunderbird)
  178. >>44 ubelong x \b, schema %u
  179. # Suggested cache size like: 0 2000
  180. >>48 ubelong !0 \b, cache page size %u
  181. # The page number of the largest root b-tree page when in auto-vacuum or incremental-vacuum modes, or zero otherwise.
  182. >>52 ubelong !0 \b, largest root page %u
  183. # The database text encoding; a value of 1 means UTF-8; 2 means UTF-16le; 3 means UTF-16be
  184. #>>56 ubelong x \b, encoding %u
  185. >>56 ubelong x
  186. >>>56 ubelong =1 \b, UTF-8
  187. >>>56 ubelong =2 \b, UTF-16 little endian
  188. >>>56 ubelong =3 \b, UTF-16 big endian
  189. # 0 for corruptDB.sqlite and for storage.sqlite with database pages 1 (TorBrowser Firefox Thunderbird)
  190. # https://mozilla.github.io/firefox-browser-architecture/text/0010-firefox-data-stores.html
  191. >>>56 default x
  192. >>>>56 ubelong x \b, unknown %#x encoding
  193. # True (non-zero) for incremental-vacuum mode; false (zero) otherwiseqy
  194. >>64 ubelong !0 \b, vacuum mode %u
  195. # Reserved for expansion. Must be zero
  196. >>72 uquad !0 \b, reserved %#llx
  197. # The version-valid-for number like:
  198. # 1 2 3 4 C F 68h 95h 266h A99h 3DCDh B7CEh
  199. >>92 ubelong x \b, version-valid-for %u
  200. # SQLite Write-Ahead Log from SQLite version >= 3.7.0
  201. # https://www.sqlite.org/fileformat.html#walformat
  202. 0 belong&0xfffffffe 0x377f0682 SQLite Write-Ahead Log,
  203. !:ext sqlite-wal/db-wal
  204. >4 belong x version %d
  205. # Summary: SQLite Write-Ahead-Log index (shared memory)
  206. # From: Joerg Jenderek
  207. # URL: http://fileformats.archiveteam.org/wiki/SQLite
  208. # Reference: http://www.sqlite.org/draft/walformat.html#walidxfmt
  209. # iVersion; WAL-index format version number; always 3007000=2DE218h
  210. 0 ulelong 0x002DE218
  211. >0 use shm-le
  212. # big endian variant not tested
  213. 0 ubelong 0x002DE218
  214. >0 use \^shm-le
  215. # show information about SQLite Write-Ahead-Log shared memory
  216. 0 name shm-le
  217. >0 ulelong x SQLite Write-Ahead Log shared memory
  218. #!:mime application/octet-stream
  219. !:mime application/vnd.sqlite3
  220. # db3-shm Acronis BackupAndRecovery F4CEEE47-042C-4828-95A0-DE44EC267A28.db3-shm
  221. # dbx-shm probably Dropbox filecache.dbx-shm
  222. # aup3-shm Audacity project tada.aup3-shm
  223. # srd-shm Microsoft Windows StateRepository service StateRepository-Deployment.srd-shm StateRepository-Machine.srd-shm:
  224. !:ext sqlite-shm/db-shm/db3-shm/dbx-shm/aup3-shm/srd-shm
  225. # unused padding space; must be zero
  226. >4 ulelong !0 \b, unused %x
  227. # iChange; unsigned integer counter, incremented with each transaction
  228. >8 ulelong x \b, counter %u
  229. # isInit; the "isInit" flag; 1 when the shm file has been initialized
  230. >12 ubyte !1 \b, not initialized %u
  231. # bigEndCksum; true if the WAL file uses big-ending checksums; 0 if the WAL uses little-endian checksums
  232. >13 ubyte !0 \b, checksum type %u
  233. # szPage; database page size in bytes, or 1 if the page size is 65536
  234. >14 uleshort !1 \b, page size %u
  235. >14 uleshort =1 \b, page size 65536
  236. # mxFrame; number of valid and committed frames in the WAL file
  237. >16 ulelong x \b, %u frames
  238. # nPage; size of the database file in pages
  239. >20 ulelong x \b, %u pages
  240. # aFrameCksum; checksum of the last frame in the WAL file
  241. >24 ulelong x \b, frame checksum %#x
  242. # aSalt; two salt value copied from the WAL file header in the byte-order of the WAL file; might be different from machine byte-order
  243. >32 ulequad x \b, salt %#llx
  244. # aCksum; checksum over bytes 0 through 39 of this header
  245. >40 ulelong x \b, header checksum %#x
  246. # a copy of bytes 0 through 47 of header
  247. >48 ulelong !3007000 \b, iversion %u
  248. # nBackfill; number of WAL frames that have already been backfilled into the database by prior checkpoints
  249. >96 ulelong !0 \b, %u backfilled
  250. # nBackfillAttempted; number of WAL frames that have attempted to be backfilled
  251. >>128 ulelong x (%u attempts)
  252. # read-mark[0..4]; five "read marks"; each read mark is a 32-bit unsigned integer
  253. >100 ulelong !0 \b, read-mark[0] %#x
  254. >104 ulelong x \b, read-mark[1] %#x
  255. >108 ulelong !0xffffffff \b, read-mark[2] %#x
  256. >112 ulelong !0xffffffff \b, read-mark[3] %#x
  257. >116 ulelong !0xffffffff \b, read-mark[4] %#x
  258. # unused space set aside for 8 file locks
  259. >120 ulequad !0 \b, space %#llx
  260. # unused space reserved for further expansion
  261. >132 ulelong !0 \b, reserved %#x
  262. # SQLite Rollback Journal
  263. # https://www.sqlite.org/fileformat.html#rollbackjournal
  264. 0 string \xd9\xd5\x05\xf9\x20\xa1\x63\xd7 SQLite Rollback Journal
  265. # Panasonic channel list database svl.bin or svl.db added by Joerg Jenderek
  266. # https://github.com/PredatH0r/ChanSort
  267. 0 string PSDB\0 Panasonic channel list DataBase
  268. !:ext db/bin
  269. #!:mime application/x-db-svl-panasonic
  270. >126 string SQLite\ format\ 3
  271. #!:mime application/x-panasonic-sqlite3
  272. >>&-15 indirect x \b; contains
  273. # H2 Database from https://www.h2database.com/
  274. 0 string --\ H2\ 0.5/B\ --\ \n H2 Database file
  275. # DuckDB database file from https://duckdb.org
  276. 8 string DUCK DuckDB database file
  277. >12 lequad x \b, version %lld
  278. #>20 lequad x \b, flags %#llx
  279. #>28 lequad x \b, flags %#llx