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