Resultset
You are viewing an old version of this article. View
the current version here.
Resultset
A resultset consists of different packets:
- Resultset metadata
- 1 Column count packet
- for each column (i.e column_count times)
- if not (CLIENT_DEPRECATE_EOF capability set) EOF_Packet
- n resultset row
- if error
- else
- if CLIENT_DEPRECATE_EOF capability
- OK_Packet with a 0xFE header
- else EOF_Packet
- if CLIENT_DEPRECATE_EOF capability
Resultset row can begin with 0xfe byte (when using text protocol with a field length > 0xffffff)
Too ensure that packet beginning with 0xfe correspond to the ending packet (EOF_Packet or OK_Packet with a 0xFE header), packet length must be checked : packet length must be less than 0xffffff length.
ResultSet metadata
Column count packet
- int<lenenc> column count
Column definition packet
- string<lenenc> catalog (always 'def')
- string<lenenc> schema
- string<lenenc> table alias
- string<lenenc> table
- string<lenenc> column alias
- string<lenenc> column
- int<lenenc> length of fixed fields (=0xC)
- int<2> character set number
- int<4> max. column size
- int<1> Field types
- int<2> Field detail flag
- int<1> decimals
- int<2> - unused -
Field types
0 | MYSQL_TYPE_DECIMAL |
1 | MYSQL_TYPE_TINY |
2 | MYSQL_TYPE_SHORT |
3 | MYSQL_TYPE_LONG, |
4 | MYSQL_TYPE_FLOAT |
5 | MYSQL_TYPE_DOUBLE, |
6 | MYSQL_TYPE_NULL |
7 | MYSQL_TYPE_TIMESTAMP |
8 | MYSQL_TYPE_LONGLONG, |
9 | MYSQL_TYPE_INT24 |
10 | MYSQL_TYPE_DATE |
11 | MYSQL_TYPE_TIME |
12 | MYSQL_TYPE_DATETIME |
13 | MYSQL_TYPE_YEAR |
14 | MYSQL_TYPE_NEWDATE |
15 | MYSQL_TYPE_VARCHAR |
16 | MYSQL_TYPE_BIT |
17 | MYSQL_TYPE_TIMESTAMP2 |
18 | MYSQL_TYPE_DATETIME2 |
19 | MYSQL_TYPE_TIME2 |
246 | MYSQL_TYPE_NEWDECIMAL |
247 | MYSQL_TYPE_ENUM |
248 | MYSQL_TYPE_SET |
249 | MYSQL_TYPE_TINY_BLOB |
250 | MYSQL_TYPE_MEDIUM_BLOB |
251 | MYSQL_TYPE_LONG_BLOB |
252 | MYSQL_TYPE_BLOB |
253 | MYSQL_TYPE_VAR_STRING |
254 | MYSQL_TYPE_STRING |
255 | MYSQL_TYPE_GEOMETRY |
Field detail flag
The field details flag will permit having an indication, like is this field signed ?
The blob flag is not enough to permit identifying if the field is a binary flag: char binary and varchar binary are not binary (they are handled like strings), but have the binary flag!
1 | NOT_NULL | field cannot be null |
2 | PRIMARY_KEY | field is a primary key |
4 | UNIQUE_KEY | field is unique |
8 | MULTIPLE_KEY | field is in a multiple key |
16 | BLOB | is this field a Blob |
32 | UNSIGNED | is this field unsigned |
64 | DECIMAL | is this field a decimal |
128 | BINARY_COLLATION | whether this field has a binary collation |
256 | ENUM | Field is an enumeration |
512 | AUTO_INCREMENT | field auto-increment |
1024 | TIMESTAMP | field is a timestamp value |
2048 | SET | field is a SET |
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.