1 module mysql.protocol;
2 
3 
4 enum CapabilityFlags : uint {
5     CLIENT_LONG_PASSWORD                = 0x00000001,  // Use the improved version of Old Password Authentication
6     CLIENT_FOUND_ROWS                   = 0x00000002,  // Send found rows instead of affected rows in EOF_Packet
7     CLIENT_LONG_FLAG                    = 0x00000004,  // Longer flags in Protocol::ColumnDefinition320
8     CLIENT_CONNECT_WITH_DB              = 0x00000008,  // One can specify db on connect in Handshake Response Packet
9     CLIENT_NO_SCHEMA                    = 0x00000010,  // Don't allow database.table.column
10     CLIENT_COMPRESS                     = 0x00000020,  // Compression protocol supported
11     CLIENT_ODBC                         = 0x00000040,  // Special handling of ODBC behaviour
12     CLIENT_LOCAL_FILES                  = 0x00000080,  // Can use LOAD DATA LOCAL
13     CLIENT_IGNORE_SPACE                 = 0x00000100,  // Parser can ignore spaces before '('
14     CLIENT_PROTOCOL_41                  = 0x00000200,  // Supports the 4.1 protocol
15     CLIENT_INTERACTIVE                  = 0x00000400,  // wait_timeout vs. wait_interactive_timeout
16     CLIENT_SSL                          = 0x00000800,  // Supports SSL
17     CLIENT_IGNORE_SIGPIPE               = 0x00001000,  // Don't issue SIGPIPE if network failures (libmysqlclient only)
18     CLIENT_TRANSACTIONS                 = 0x00002000,  // Can send status flags in EOF_Packet
19     CLIENT_RESERVED                     = 0x00004000,  // Unused
20     CLIENT_SECURE_CONNECTION            = 0x00008000,  // Supports Authentication::Native41
21     CLIENT_MULTI_STATEMENTS             = 0x00010000,  // Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE
22     CLIENT_MULTI_RESULTS                = 0x00020000,  // Can send multiple resultsets for COM_QUERY
23     CLIENT_PS_MULTI_RESULTS             = 0x00040000,  // Can send multiple resultsets for COM_STMT_EXECUTE
24     CLIENT_PLUGIN_AUTH                  = 0x00080000,  // Sends extra data in Initial Handshake Packet and supports the pluggable authentication protocol.
25     CLIENT_CONNECT_ATTRS                = 0x00100000,  // Allows connection attributes in Protocol::HandshakeResponse41
26     CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000,  // Understands length encoded integer for auth response data in Protocol::HandshakeResponse41
27     CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS = 0x00400000,  // Announces support for expired password extension
28     CLIENT_SESSION_TRACK                = 0x00800000,  // Can set SERVER_SESSION_STATE_CHANGED in the Status Flags and send session-state change data after a OK packet
29     CLIENT_DEPRECATE_EOF                = 0x01000000,  // Can send OK after a Text Resultset
30 }
31 
32 
33 enum StatusFlags : ushort {
34     SERVER_STATUS_IN_TRANS	            = 0x0001,  // A transaction is active
35     SERVER_STATUS_AUTOCOMMIT	        = 0x0002,  // auto-commit is enabled
36     SERVER_MORE_RESULTS_EXISTS	        = 0x0008,
37     SERVER_STATUS_NO_GOOD_INDEX_USED    = 0x0010,
38     SERVER_STATUS_NO_INDEX_USED	        = 0x0020,
39     SERVER_STATUS_CURSOR_EXISTS	        = 0x0040,  // Used by Binary Protocol Resultset to signal that COM_STMT_FETCH has to be used to fetch the row-data.
40     SERVER_STATUS_LAST_ROW_SENT	        = 0x0080,
41     SERVER_STATUS_DB_DROPPED	        = 0x0100,
42     SERVER_STATUS_NO_BACKSLASH_ESCAPES	= 0x0200,
43     SERVER_STATUS_METADATA_CHANGED	    = 0x0400,
44     SERVER_QUERY_WAS_SLOW	            = 0x0800,
45     SERVER_PS_OUT_PARAMS	            = 0x1000,
46     SERVER_STATUS_IN_TRANS_READONLY	    = 0x2000,  // In a read-only transaction
47     SERVER_SESSION_STATE_CHANGED	    = 0x4000,  // connection state information has changed
48 }
49 
50 
51 enum StatusPackets : ubyte {
52     OK_Packet   = 0,
53     ERR_Packet  = 0xff,
54     EOF_Packet  = 0xfe,
55 }
56 
57 
58 enum Commands : ubyte {
59     //COM_SLEEP           = 0x00,
60     COM_QUIT            = 0x01,
61     COM_INIT_DB         = 0x02,
62     COM_QUERY           = 0x03,
63     COM_FIELD_LIST      = 0x04,
64     COM_CREATE_DB       = 0x05,
65     COM_DROP_DB         = 0x06,
66     COM_REFRESH         = 0x07,
67     //COM_SHUTDOWN        = 0x08,
68     COM_STATISTICS      = 0x09,
69     COM_PROCESS_INFO    = 0x0a,
70     //COM_CONNECT         = 0x0b,
71     COM_PROCESS_KILL    = 0x0c,
72     COM_DEBUG           = 0x0d,
73     COM_PING            = 0x0e,
74     //COM_TIME            = 0x0f,
75     //COM_DELAYED_INSERT  = 0x10,
76     COM_CHANGE_USER     = 0x11,
77     COM_BINLOG_DUMP     = 0x12,
78     COM_TABLE_DUMP      = 0x13,
79     //COM_CONNECT_OUT     = 0x14,
80     COM_REGISTER_SLAVE  = 0x15,
81     COM_STMT_PREPARE    = 0x16,
82     COM_STMT_EXECUTE    = 0x17,
83     COM_STMT_SEND_LONG_DATA = 0x18,
84     COM_STMT_CLOSE      = 0x19,
85     COM_STMT_RESET      = 0x1a,
86     COM_SET_OPTION      = 0x1b,
87     COM_STMT_FETCH      = 0x1c,
88     //COM_DAEMON          = 0x1d,
89     COM_BINLOG_DUMP_GTID = 0x1e,
90     COM_RESET_CONNECTION = 0x1f,
91 }
92 
93 
94 enum Cursors : ubyte {
95     CURSOR_TYPE_NO_CURSOR   = 0x00,
96     CURSOR_TYPE_READ_ONLY   = 0x01,
97     CURSOR_TYPE_FOR_UPDATE  = 0x02,
98     CURSOR_TYPE_SCROLLABLE  = 0x04,
99 }
100 
101 
102 enum ColumnTypes : ubyte {
103     MYSQL_TYPE_DECIMAL      = 0x00,
104     MYSQL_TYPE_TINY         = 0x01,
105     MYSQL_TYPE_SHORT        = 0x02,
106     MYSQL_TYPE_LONG	        = 0x03,
107     MYSQL_TYPE_FLOAT	    = 0x04,
108     MYSQL_TYPE_DOUBLE	    = 0x05,
109     MYSQL_TYPE_NULL	        = 0x06,
110     MYSQL_TYPE_TIMESTAMP	= 0x07,
111     MYSQL_TYPE_LONGLONG	    = 0x08,
112     MYSQL_TYPE_INT24	    = 0x09,
113     MYSQL_TYPE_DATE	        = 0x0a,
114     MYSQL_TYPE_TIME	        = 0x0b,
115     MYSQL_TYPE_DATETIME	    = 0x0c,
116     MYSQL_TYPE_YEAR	        = 0x0d,
117     MYSQL_TYPE_NEWDATE  	= 0x0e,
118     MYSQL_TYPE_VARCHAR	    = 0x0f,
119     MYSQL_TYPE_BIT	        = 0x10,
120     MYSQL_TYPE_TIMESTAMP2   = 0x11,
121     MYSQL_TYPE_DATETIME2    = 0x12,
122     MYSQL_TYPE_TIME2        = 0x13,
123     MYSQL_TYPE_NEWDECIMAL   = 0xf6,
124     MYSQL_TYPE_ENUM         = 0xf7,
125     MYSQL_TYPE_SET	        = 0xf8,
126     MYSQL_TYPE_TINY_BLOB	= 0xf9,
127     MYSQL_TYPE_MEDIUM_BLOB	= 0xfa,
128     MYSQL_TYPE_LONG_BLOB	= 0xfb,
129     MYSQL_TYPE_BLOB	        = 0xfc,
130     MYSQL_TYPE_VAR_STRING	= 0xfd,
131     MYSQL_TYPE_STRING	    = 0xfe,
132     MYSQL_TYPE_GEOMETRY	    = 0xff,
133 }
134 
135 
136 enum FieldFlags : ushort {
137     NOT_NULL_FLAG           = 0x0001, //  Field cannot be NULL
138     PRI_KEY_FLAG	        = 0x0002, //  Field is part of a primary key
139     UNIQUE_KEY_FLAG	        = 0x0004, //  Field is part of a unique key
140     MULTIPLE_KEY_FLAG       = 0x0008, //  Field is part of a nonunique key
141     BLOB_FLAG	            = 0x0010, //  Field is a BLOB or TEXT (deprecated)
142     UNSIGNED_FLAG	        = 0x0020, //  Field has the UNSIGNED attribute
143     ZEROFILL_FLAG	        = 0x0040, //  Field has the ZEROFILL attribute
144     BINARY_FLAG	            = 0x0080, //  Field has the BINARY attribute
145     ENUM_FLAG	            = 0x0100, //  Field is an ENUM
146     AUTO_INCREMENT_FLAG	    = 0x0200, //  Field has the AUTO_INCREMENT attribute
147     TIMESTAMP_FLAG	        = 0x0400, //  Field is a TIMESTAMP (deprecated)
148     SET_FLAG	            = 0x0800, //  Field is a SET
149     NO_DEFAULT_VALUE_FLAG   = 0x1000, //  Field has no default value; see additional notes following table
150     ON_UPDATE_NOW_FLAG      = 0x2000, // Field is set to NOW on UPDATE
151 //    PART_KEY_FLAG           = 0x4000, //  Intern; Part of some key
152     NUM_FLAG	            = 0x8000, //  Field is numeric
153 }
154 
155 
156 enum ErrorCodes : ushort {
157     ER_DUP_KEYNAME                  = 1061,
158     ER_DUP_ENTRY                    = 1062,
159     ER_DUP_ENTRY_WITH_KEY_NAME      = 1586,
160 }