1 /// Internal - Misc protocol constants.
2 module mysql.protocol.constants;
3 
4 /++
5 Server capability flags.
6 
7 During the connection handshake process, the server sends a uint of flags
8 describing its capabilities.
9 
10 See_Also: $(LINK https://dev.mysql.com/doc/internals/en/capability-flags.html)
11 +/
12 enum SvrCapFlags: uint
13 {
14 	OLD_LONG_PASSWORD   = 0x0_0001, /// Long old-style passwords (Not 4.1+ passwords)
15 	FOUND_NOT_AFFECTED  = 0x0_0002, /// Report rows found rather than rows affected
16 	ALL_COLUMN_FLAGS    = 0x0_0004, /// Send all column flags
17 	WITH_DB             = 0x0_0008, /// Can take database as part of login
18 	NO_SCHEMA           = 0x0_0010, /// Can disallow database name as part of column name database.table.column
19 	CAN_COMPRESS        = 0x0_0020, /// Can compress packets
20 	ODBC                = 0x0_0040, /// Can handle ODBC
21 	LOCAL_FILES         = 0x0_0080, /// Can use LOAD DATA LOCAL
22 	IGNORE_SPACE        = 0x0_0100, /// Can ignore spaces before '$(LPAREN)'
23 	PROTOCOL41          = 0x0_0200, /// Can use 4.1+ protocol
24 	INTERACTIVE         = 0x0_0400, /// Interactive client?
25 	SSL                 = 0x0_0800, /// Can switch to SSL after handshake
26 	IGNORE_SIGPIPE      = 0x0_1000, /// Ignore sigpipes?
27 	TRANSACTIONS        = 0x0_2000, /// Transaction support
28 	RESERVED            = 0x0_4000, ///  Old flag for 4.1 protocol
29 	SECURE_CONNECTION   = 0x0_8000, /// 4.1+ authentication
30 	MULTI_STATEMENTS    = 0x1_0000, /// Multiple statement support
31 	MULTI_RESULTS       = 0x2_0000, /// Multiple result set support
32 }
33 
34 /++
35 Column type codes
36 
37 $(LINK2 https://dev.mysql.com/doc/internals/en/com-query-response.html#column-type, Reference)
38 +/
39 enum SQLType : short
40 {
41 	INFER_FROM_D_TYPE = -1,
42 	DECIMAL      = 0x00,
43 	TINY         = 0x01,
44 	SHORT        = 0x02,
45 	INT          = 0x03,
46 	FLOAT        = 0x04,
47 	DOUBLE       = 0x05,
48 	NULL         = 0x06,
49 	TIMESTAMP    = 0x07,
50 	LONGLONG     = 0x08,
51 	INT24        = 0x09,
52 	DATE         = 0x0a,
53 	TIME         = 0x0b,
54 	DATETIME     = 0x0c,
55 	YEAR         = 0x0d,
56 	NEWDATE      = 0x0e,
57 	VARCHAR      = 0x0f, // new in MySQL 5.0
58 	BIT          = 0x10, // new in MySQL 5.0
59 	NEWDECIMAL   = 0xf6, // new in MYSQL 5.0
60 	ENUM         = 0xf7,
61 	SET          = 0xf8,
62 	TINYBLOB     = 0xf9,
63 	MEDIUMBLOB   = 0xfa,
64 	LONGBLOB     = 0xfb,
65 	BLOB         = 0xfc,
66 	VARSTRING    = 0xfd,
67 	STRING       = 0xfe,
68 	GEOMETRY     = 0xff
69 }
70 
71 /++
72 Server refresh flags
73 +/
74 enum RefreshFlags : ubyte
75 {
76 	GRANT    =   1,
77 	LOG      =   2,
78 	TABLES   =   4,
79 	HOSTS    =   8,
80 	STATUS   =  16,
81 	THREADS  =  32,
82 	SLAVE    =  64,
83 	MASTER   = 128
84 }
85 
86 /++
87 Type of Command Packet (COM_XXX)
88 See_Also: $(LINK https://dev.mysql.com/doc/internals/en/command-phase.html)
89 +/
90 enum CommandType : ubyte
91 {
92 	SLEEP               = 0x00,
93 	QUIT                = 0x01,
94 	INIT_DB             = 0x02,
95 	QUERY               = 0x03,
96 	FIELD_LIST          = 0x04,
97 	CREATE_DB           = 0x05,
98 	DROP_DB             = 0x06,
99 	REFRESH             = 0x07,
100 	SHUTDOWN            = 0x08,
101 	STATISTICS          = 0x09,
102 	PROCESS_INFO        = 0x0a,
103 	CONNECT             = 0x0b,
104 	PROCESS_KILL        = 0x0c,
105 	DEBUG               = 0x0d,
106 	PING                = 0x0e,
107 	TIME                = 0x0f,
108 	DELAYED_INSERT      = 0x10,
109 	CHANGE_USER         = 0x11,
110 	BINLOG_DUBP         = 0x12,
111 	TABLE_DUMP          = 0x13,
112 	CONNECT_OUT         = 0x14,
113 	REGISTER_SLAVE      = 0x15,
114 	STMT_PREPARE        = 0x16,
115 	STMT_EXECUTE        = 0x17,
116 	STMT_SEND_LONG_DATA = 0x18,
117 	STMT_CLOSE          = 0x19,
118 	STMT_RESET          = 0x1a,
119 	STMT_OPTION         = 0x1b,
120 	STMT_FETCH          = 0x1c,
121 }
122 
123 /// Magic marker sent in the first byte of mysql results in response to auth or command packets.
124 enum ResultPacketMarker : ubyte
125 {
126 	/++
127 	Server reports an error
128 	See_Also: $(LINK https://dev.mysql.com/doc/internals/en/packet-ERR_Packet.html)
129 	+/
130 	error   = 0xff,
131 
132 	/++
133 	No error, no result set.
134 	See_Also: $(LINK https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html)
135 	+/
136 	ok      = 0x00,
137 
138 	/++
139 	Server reports end of data
140 	See_Also: $(LINK https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html)
141 	+/
142 	eof     = 0xfe,
143 }
144 
145 /++
146 Field Flags
147 See_Also: $(LINK https://dev.mysql.com/doc/dev/mysql-server/8.0.26/group__group__cs__column__definition__flags.html)
148 +/
149 enum FieldFlags : ushort
150 {
151 	NOT_NULL        = 0x0001,
152 	PRI_KEY         = 0x0002,
153 	UNIQUE_KEY      = 0x0004,
154 	MULTIPLE_KEY    = 0x0008,
155 	BLOB            = 0x0010,
156 	UNSIGNED        = 0x0020,
157 	ZEROFILL        = 0x0040,
158 	BINARY          = 0x0080,
159 	ENUM            = 0x0100,
160 	AUTO_INCREMENT  = 0x0200,
161 	TIMESTAMP       = 0x0400,
162 	SET             = 0x0800
163 }