1 //! The MySQL backend
2 
3 use byteorder::NativeEndian;
4 
5 use super::bind_collector::MysqlBindCollector;
6 use super::query_builder::MysqlQueryBuilder;
7 use backend::*;
8 use sql_types::TypeMetadata;
9 
10 /// The MySQL backend
11 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
12 pub struct Mysql;
13 
14 #[allow(missing_debug_implementations)]
15 /// Represents the possible forms a bind parameter can be transmitted as.
16 /// Each variant represents one of the forms documented at
17 /// <https://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statement-type-codes.html>
18 ///
19 /// The null variant is omitted, as we will never prepare a statement in which
20 /// one of the bind parameters can always be NULL
21 #[derive(Hash, PartialEq, Eq, Clone, Copy)]
22 pub enum MysqlType {
23     /// Sets `buffer_type` to `MYSQL_TYPE_TINY`
24     Tiny,
25     /// Sets `buffer_type` to `MYSQL_TYPE_SHORT`
26     Short,
27     /// Sets `buffer_type` to `MYSQL_TYPE_LONG`
28     Long,
29     /// Sets `buffer_type` to `MYSQL_TYPE_LONGLONG`
30     LongLong,
31     /// Sets `buffer_type` to `MYSQL_TYPE_FLOAT`
32     Float,
33     /// Sets `buffer_type` to `MYSQL_TYPE_DOUBLE`
34     Double,
35     /// Sets `buffer_type` to `MYSQL_TYPE_TIME`
36     Time,
37     /// Sets `buffer_type` to `MYSQL_TYPE_DATE`
38     Date,
39     /// Sets `buffer_type` to `MYSQL_TYPE_DATETIME`
40     DateTime,
41     /// Sets `buffer_type` to `MYSQL_TYPE_TIMESTAMP`
42     Timestamp,
43     /// Sets `buffer_type` to `MYSQL_TYPE_STRING`
44     String,
45     /// Sets `buffer_type` to `MYSQL_TYPE_BLOB`
46     Blob,
47 }
48 
49 impl Backend for Mysql {
50     type QueryBuilder = MysqlQueryBuilder;
51     type BindCollector = MysqlBindCollector;
52     type RawValue = [u8];
53     type ByteOrder = NativeEndian;
54 }
55 
56 impl TypeMetadata for Mysql {
57     type TypeMetadata = MysqlType;
58     type MetadataLookup = ();
59 }
60 
61 impl SupportsDefaultKeyword for Mysql {}
62 impl UsesAnsiSavepointSyntax for Mysql {}
63