|
1 | | -use std::collections::HashMap; |
2 | | - |
3 | 1 | use crate::compile::{DatabaseVariable, DatabaseVariables}; |
4 | 2 | use datafusion::scalar::ScalarValue; |
5 | 3 |
|
6 | 4 | pub fn defaults() -> DatabaseVariables { |
7 | | - let mut variables: DatabaseVariables = HashMap::new(); |
8 | | - |
9 | | - variables.insert( |
10 | | - "max_allowed_packet".to_string(), |
| 5 | + let variables = [ |
11 | 6 | DatabaseVariable::system( |
12 | 7 | "max_allowed_packet".to_string(), |
13 | 8 | ScalarValue::UInt32(Some(67108864)), |
14 | 9 | None, |
15 | 10 | ), |
16 | | - ); |
17 | | - variables.insert( |
18 | | - "auto_increment_increment".to_string(), |
19 | 11 | DatabaseVariable::system( |
20 | 12 | "auto_increment_increment".to_string(), |
21 | 13 | ScalarValue::UInt32(Some(1)), |
22 | 14 | None, |
23 | 15 | ), |
24 | | - ); |
25 | | - variables.insert( |
26 | | - "version_comment".to_string(), |
27 | 16 | DatabaseVariable::system( |
28 | 17 | "version_comment".to_string(), |
29 | 18 | ScalarValue::Utf8(Some("mysql".to_string())), |
30 | 19 | None, |
31 | 20 | ), |
32 | | - ); |
33 | | - variables.insert( |
34 | | - "system_time_zone".to_string(), |
35 | 21 | DatabaseVariable::system( |
36 | 22 | "system_time_zone".to_string(), |
37 | 23 | ScalarValue::Utf8(Some("UTC".to_string())), |
38 | 24 | None, |
39 | 25 | ), |
40 | | - ); |
41 | | - variables.insert( |
42 | | - "time_zone".to_string(), |
43 | 26 | DatabaseVariable::system( |
44 | 27 | "time_zone".to_string(), |
45 | 28 | ScalarValue::Utf8(Some("SYSTEM".to_string())), |
46 | 29 | None, |
47 | 30 | ), |
48 | | - ); |
49 | | - |
50 | | - variables.insert( |
51 | | - "tx_isolation".to_string(), |
52 | 31 | DatabaseVariable::system( |
53 | 32 | "tx_isolation".to_string(), |
54 | 33 | ScalarValue::Utf8(Some("REPEATABLE-READ".to_string())), |
55 | 34 | None, |
56 | 35 | ), |
57 | | - ); |
58 | | - variables.insert( |
59 | | - "tx_read_only".to_string(), |
60 | 36 | DatabaseVariable::system( |
61 | 37 | "tx_read_only".to_string(), |
62 | 38 | ScalarValue::Boolean(Some(false)), |
63 | 39 | None, |
64 | 40 | ), |
65 | | - ); |
66 | | - variables.insert( |
67 | | - "transaction_isolation".to_string(), |
68 | 41 | DatabaseVariable::system( |
69 | 42 | "transaction_isolation".to_string(), |
70 | 43 | ScalarValue::Utf8(Some("REPEATABLE-READ".to_string())), |
71 | 44 | None, |
72 | 45 | ), |
73 | | - ); |
74 | | - variables.insert( |
75 | | - "transaction_read_only".to_string(), |
76 | 46 | DatabaseVariable::system( |
77 | 47 | "transaction_read_only".to_string(), |
78 | 48 | ScalarValue::Boolean(Some(false)), |
79 | 49 | None, |
80 | 50 | ), |
81 | | - ); |
82 | | - variables.insert( |
83 | | - "sessiontransaction_isolation".to_string(), |
84 | 51 | DatabaseVariable::system( |
85 | 52 | "sessiontransaction_isolation".to_string(), |
86 | 53 | ScalarValue::Utf8(Some("REPEATABLE-READ".to_string())), |
87 | 54 | None, |
88 | 55 | ), |
89 | | - ); |
90 | | - variables.insert( |
91 | | - "sessionauto_increment_increment".to_string(), |
92 | 56 | DatabaseVariable::system( |
93 | 57 | "sessionauto_increment_increment".to_string(), |
94 | 58 | ScalarValue::Int64(Some(1)), |
95 | 59 | None, |
96 | 60 | ), |
97 | | - ); |
98 | | - variables.insert( |
99 | | - "character_set_client".to_string(), |
100 | 61 | DatabaseVariable::system( |
101 | 62 | "character_set_client".to_string(), |
102 | 63 | ScalarValue::Utf8(Some("utf8mb4".to_string())), |
103 | 64 | None, |
104 | 65 | ), |
105 | | - ); |
106 | | - variables.insert( |
107 | | - "character_set_connection".to_string(), |
108 | 66 | DatabaseVariable::system( |
109 | 67 | "character_set_connection".to_string(), |
110 | 68 | ScalarValue::Utf8(Some("utf8mb4".to_string())), |
111 | 69 | None, |
112 | 70 | ), |
113 | | - ); |
114 | | - variables.insert( |
115 | | - "character_set_results".to_string(), |
116 | 71 | DatabaseVariable::system( |
117 | 72 | "character_set_results".to_string(), |
118 | 73 | ScalarValue::Utf8(Some("utf8mb4".to_string())), |
119 | 74 | None, |
120 | 75 | ), |
121 | | - ); |
122 | | - variables.insert( |
123 | | - "character_set_server".to_string(), |
124 | 76 | DatabaseVariable::system( |
125 | 77 | "character_set_server".to_string(), |
126 | 78 | ScalarValue::Utf8(Some("utf8mb4".to_string())), |
127 | 79 | None, |
128 | 80 | ), |
129 | | - ); |
130 | | - variables.insert( |
131 | | - "collation_connection".to_string(), |
132 | 81 | DatabaseVariable::system( |
133 | 82 | "collation_connection".to_string(), |
134 | 83 | ScalarValue::Utf8(Some("utf8mb4_general_ci".to_string())), |
135 | 84 | None, |
136 | 85 | ), |
137 | | - ); |
138 | | - variables.insert( |
139 | | - "collation_server".to_string(), |
140 | 86 | DatabaseVariable::system( |
141 | 87 | "collation_server".to_string(), |
142 | 88 | ScalarValue::Utf8(Some("utf8mb4_0900_ai_ci".to_string())), |
143 | 89 | None, |
144 | 90 | ), |
145 | | - ); |
146 | | - variables.insert( |
147 | | - "init_connect".to_string(), |
148 | 91 | DatabaseVariable::system( |
149 | 92 | "init_connect".to_string(), |
150 | 93 | ScalarValue::Utf8(Some("".to_string())), |
151 | 94 | None, |
152 | 95 | ), |
153 | | - ); |
154 | | - variables.insert( |
155 | | - "interactive_timeout".to_string(), |
156 | 96 | DatabaseVariable::system( |
157 | 97 | "interactive_timeout".to_string(), |
158 | 98 | ScalarValue::Int32(Some(28800)), |
159 | 99 | None, |
160 | 100 | ), |
161 | | - ); |
162 | | - variables.insert( |
163 | | - "license".to_string(), |
164 | 101 | DatabaseVariable::system( |
165 | 102 | "license".to_string(), |
166 | 103 | ScalarValue::Utf8(Some("Apache 2".to_string())), |
167 | 104 | None, |
168 | 105 | ), |
169 | | - ); |
170 | | - variables.insert( |
171 | | - "lower_case_table_names".to_string(), |
172 | 106 | DatabaseVariable::system( |
173 | 107 | "lower_case_table_names".to_string(), |
174 | 108 | ScalarValue::Int32(Some(0)), |
175 | 109 | None, |
176 | 110 | ), |
177 | | - ); |
178 | | - variables.insert( |
179 | | - "net_buffer_length".to_string(), |
180 | 111 | DatabaseVariable::system( |
181 | 112 | "net_buffer_length".to_string(), |
182 | 113 | ScalarValue::Int32(Some(16384)), |
183 | 114 | None, |
184 | 115 | ), |
185 | | - ); |
186 | | - variables.insert( |
187 | | - "net_write_timeout".to_string(), |
188 | 116 | DatabaseVariable::system( |
189 | 117 | "net_write_timeout".to_string(), |
190 | 118 | ScalarValue::Int32(Some(600)), |
191 | 119 | None, |
192 | 120 | ), |
193 | | - ); |
194 | | - variables.insert( |
195 | | - "wait_timeout".to_string(), |
196 | 121 | DatabaseVariable::system( |
197 | 122 | "wait_timeout".to_string(), |
198 | 123 | ScalarValue::Int32(Some(28800)), |
199 | 124 | None, |
200 | 125 | ), |
201 | | - ); |
202 | | - variables.insert( |
203 | | - "sql_mode".to_string(), |
204 | | - DatabaseVariable::system( |
205 | | - "sql_mode".to_string(), |
206 | | - ScalarValue::Utf8(Some("ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION".to_string())), |
207 | | - None, |
208 | | - ), |
209 | | -); |
| 126 | + DatabaseVariable::system( |
| 127 | + "sql_mode".to_string(), |
| 128 | + ScalarValue::Utf8(Some("ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION".to_string())), |
| 129 | + None, |
| 130 | + ), |
| 131 | + ]; |
| 132 | + |
| 133 | + let variables = IntoIterator::into_iter(variables) |
| 134 | + .map(|v| (v.name.clone(), v)) |
| 135 | + .collect::<DatabaseVariables>(); |
| 136 | + |
210 | 137 | variables |
211 | 138 | } |
0 commit comments