1 /* Copyright (C) 2008-2020 Kentoku Shiba
2    Copyright (C) 2019-2020 MariaDB corp
3 
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; version 2 of the License.
7 
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12 
13   You should have received a copy of the GNU General Public License
14   along with this program; if not, write to the Free Software
15   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
16 
17 #define SPIDER_DB_WRAPPER_STR "mysql"
18 #define SPIDER_DB_WRAPPER_LEN (sizeof(SPIDER_DB_WRAPPER_STR) - 1)
19 #define SPIDER_DB_PK_NAME_STR "PRIMARY"
20 #define SPIDER_DB_PK_NAME_LEN (sizeof(SPIDER_DB_PK_NAME_STR) - 1)
21 #define SPIDER_DB_UNIQUE_NAME_STR "UNIQUE"
22 #define SPIDER_DB_UNIQUE_NAME_LEN (sizeof(SPIDER_DB_UNIQUE_NAME_STR) - 1)
23 #define SPIDER_DB_KEY_NAME_STR "KEY"
24 #define SPIDER_DB_KEY_NAME_LEN (sizeof(SPIDER_DB_KEY_NAME_STR) - 1)
25 #define SPIDER_DB_SEQUENCE_NAME_STR ""
26 #define SPIDER_DB_SEQUENCE_NAME_LEN (sizeof(SPIDER_DB_SEQUENCE_NAME_STR) - 1)
27 
28 #define SPIDER_DB_TABLE_LOCK_READ_LOCAL         0
29 #define SPIDER_DB_TABLE_LOCK_READ               1
30 #define SPIDER_DB_TABLE_LOCK_LOW_PRIORITY_WRITE 2
31 #define SPIDER_DB_TABLE_LOCK_WRITE              3
32 
33 #define SPIDER_DB_INSERT_REPLACE       (1 << 0)
34 #define SPIDER_DB_INSERT_IGNORE        (1 << 1)
35 #define SPIDER_DB_INSERT_LOW_PRIORITY  (1 << 2)
36 #define SPIDER_DB_INSERT_HIGH_PRIORITY (1 << 3)
37 #define SPIDER_DB_INSERT_DELAYED       (1 << 4)
38 
39 #define SPIDER_SQL_OPEN_PAREN_STR "("
40 #define SPIDER_SQL_OPEN_PAREN_LEN (sizeof(SPIDER_SQL_OPEN_PAREN_STR) - 1)
41 #define SPIDER_SQL_CLOSE_PAREN_STR ")"
42 #define SPIDER_SQL_CLOSE_PAREN_LEN (sizeof(SPIDER_SQL_CLOSE_PAREN_STR) - 1)
43 #define SPIDER_SQL_OPEN_BRACE_STR "{"
44 #define SPIDER_SQL_OPEN_BRACE_LEN (sizeof(SPIDER_SQL_OPEN_BRACE_STR) - 1)
45 #define SPIDER_SQL_CLOSE_BRACE_STR "}"
46 #define SPIDER_SQL_CLOSE_BRACE_LEN (sizeof(SPIDER_SQL_CLOSE_BRACE_STR) - 1)
47 #define SPIDER_SQL_COMMA_STR ","
48 #define SPIDER_SQL_COMMA_LEN (sizeof(SPIDER_SQL_COMMA_STR) - 1)
49 #define SPIDER_SQL_UNION_ALL_STR ")union all("
50 #define SPIDER_SQL_UNION_ALL_LEN (sizeof(SPIDER_SQL_UNION_ALL_STR) - 1)
51 #define SPIDER_SQL_NULL_STR "null"
52 #define SPIDER_SQL_NULL_LEN (sizeof(SPIDER_SQL_NULL_STR) - 1)
53 #define SPIDER_SQL_GT_STR " > "
54 #define SPIDER_SQL_GT_LEN (sizeof(SPIDER_SQL_GT_STR) - 1)
55 #define SPIDER_SQL_GTEQUAL_STR " >= "
56 #define SPIDER_SQL_GTEQUAL_LEN (sizeof(SPIDER_SQL_GTEQUAL_STR) - 1)
57 #define SPIDER_SQL_LT_STR " < "
58 #define SPIDER_SQL_LT_LEN (sizeof(SPIDER_SQL_LT_STR) - 1)
59 #define SPIDER_SQL_LTEQUAL_STR " <= "
60 #define SPIDER_SQL_LTEQUAL_LEN (sizeof(SPIDER_SQL_LTEQUAL_STR) - 1)
61 
62 #define SPIDER_SQL_ID_STR "id"
63 #define SPIDER_SQL_ID_LEN (sizeof(SPIDER_SQL_ID_STR) - 1)
64 #define SPIDER_SQL_TMP_BKA_ENGINE_STR "memory"
65 #define SPIDER_SQL_TMP_BKA_ENGINE_LEN (sizeof(SPIDER_SQL_TMP_BKA_ENGINE_STR) - 1)
66 
67 #define SPIDER_SQL_INSERT_STR "insert "
68 #define SPIDER_SQL_INSERT_LEN (sizeof(SPIDER_SQL_INSERT_STR) - 1)
69 #define SPIDER_SQL_REPLACE_STR "replace "
70 #define SPIDER_SQL_REPLACE_LEN (sizeof(SPIDER_SQL_REPLACE_STR) - 1)
71 #define SPIDER_SQL_SELECT_STR "select "
72 #define SPIDER_SQL_SELECT_LEN (sizeof(SPIDER_SQL_SELECT_STR) - 1)
73 #define SPIDER_SQL_UPDATE_STR "update "
74 #define SPIDER_SQL_UPDATE_LEN (sizeof(SPIDER_SQL_UPDATE_STR) - 1)
75 #define SPIDER_SQL_DELETE_STR "delete "
76 #define SPIDER_SQL_DELETE_LEN (sizeof(SPIDER_SQL_DELETE_STR) - 1)
77 #define SPIDER_SQL_DISTINCT_STR "distinct "
78 #define SPIDER_SQL_DISTINCT_LEN (sizeof(SPIDER_SQL_DISTINCT_STR) - 1)
79 #define SPIDER_SQL_HIGH_PRIORITY_STR "high_priority "
80 #define SPIDER_SQL_HIGH_PRIORITY_LEN (sizeof(SPIDER_SQL_HIGH_PRIORITY_STR) - 1)
81 #define SPIDER_SQL_LOW_PRIORITY_STR "low_priority "
82 #define SPIDER_SQL_LOW_PRIORITY_LEN (sizeof(SPIDER_SQL_LOW_PRIORITY_STR) - 1)
83 #define SPIDER_SQL_SQL_DELAYED_STR "delayed "
84 #define SPIDER_SQL_SQL_DELAYED_LEN (sizeof(SPIDER_SQL_SQL_DELAYED_STR) - 1)
85 #define SPIDER_SQL_SQL_IGNORE_STR "ignore "
86 #define SPIDER_SQL_SQL_IGNORE_LEN (sizeof(SPIDER_SQL_SQL_IGNORE_STR) - 1)
87 #define SPIDER_SQL_FROM_STR " from "
88 #define SPIDER_SQL_FROM_LEN (sizeof(SPIDER_SQL_FROM_STR) - 1)
89 #define SPIDER_SQL_WHERE_STR " where "
90 #define SPIDER_SQL_WHERE_LEN (sizeof(SPIDER_SQL_WHERE_STR) - 1)
91 #define SPIDER_SQL_OR_STR " or "
92 #define SPIDER_SQL_OR_LEN (sizeof(SPIDER_SQL_OR_STR) - 1)
93 #define SPIDER_SQL_ORDER_STR " order by "
94 #define SPIDER_SQL_ORDER_LEN (sizeof(SPIDER_SQL_ORDER_STR) - 1)
95 #define SPIDER_SQL_DESC_STR " desc"
96 #define SPIDER_SQL_DESC_LEN (sizeof(SPIDER_SQL_DESC_STR) - 1)
97 #define SPIDER_SQL_LIMIT_STR " limit "
98 #define SPIDER_SQL_LIMIT_LEN (sizeof(SPIDER_SQL_LIMIT_STR) - 1)
99 #define SPIDER_SQL_INTO_STR "into "
100 #define SPIDER_SQL_INTO_LEN (sizeof(SPIDER_SQL_INTO_STR) - 1)
101 #define SPIDER_SQL_VALUES_STR "values"
102 #define SPIDER_SQL_VALUES_LEN (sizeof(SPIDER_SQL_VALUES_STR) - 1)
103 #define SPIDER_SQL_SHARED_LOCK_STR " lock in share mode"
104 #define SPIDER_SQL_SHARED_LOCK_LEN (sizeof(SPIDER_SQL_SHARED_LOCK_STR) - 1)
105 #define SPIDER_SQL_FOR_UPDATE_STR " for update"
106 #define SPIDER_SQL_FOR_UPDATE_LEN (sizeof(SPIDER_SQL_FOR_UPDATE_STR) - 1)
107 
108 #define SPIDER_SQL_SQL_ALTER_TABLE_STR "alter table "
109 #define SPIDER_SQL_SQL_ALTER_TABLE_LEN (sizeof(SPIDER_SQL_SQL_ALTER_TABLE_STR) - 1)
110 #define SPIDER_SQL_SQL_DISABLE_KEYS_STR " disable keys"
111 #define SPIDER_SQL_SQL_DISABLE_KEYS_LEN (sizeof(SPIDER_SQL_SQL_DISABLE_KEYS_STR) - 1)
112 #define SPIDER_SQL_SQL_ENABLE_KEYS_STR " enable keys"
113 #define SPIDER_SQL_SQL_ENABLE_KEYS_LEN (sizeof(SPIDER_SQL_SQL_ENABLE_KEYS_STR) - 1)
114 #define SPIDER_SQL_SQL_CHECK_TABLE_STR "check table "
115 #define SPIDER_SQL_SQL_CHECK_TABLE_LEN (sizeof(SPIDER_SQL_SQL_CHECK_TABLE_STR) - 1)
116 #define SPIDER_SQL_SQL_ANALYZE_STR "analyze "
117 #define SPIDER_SQL_SQL_ANALYZE_LEN (sizeof(SPIDER_SQL_SQL_ANALYZE_STR) - 1)
118 #define SPIDER_SQL_SQL_OPTIMIZE_STR "optimize "
119 #define SPIDER_SQL_SQL_OPTIMIZE_LEN (sizeof(SPIDER_SQL_SQL_OPTIMIZE_STR) - 1)
120 #define SPIDER_SQL_SQL_REPAIR_STR "repair "
121 #define SPIDER_SQL_SQL_REPAIR_LEN (sizeof(SPIDER_SQL_SQL_REPAIR_STR) - 1)
122 #define SPIDER_SQL_SQL_TABLE_STR "table "
123 #define SPIDER_SQL_SQL_TABLE_LEN (sizeof(SPIDER_SQL_SQL_TABLE_STR) - 1)
124 #define SPIDER_SQL_SQL_QUICK_STR " quick"
125 #define SPIDER_SQL_SQL_QUICK_LEN (sizeof(SPIDER_SQL_SQL_QUICK_STR) - 1)
126 #define SPIDER_SQL_SQL_FAST_STR " fast"
127 #define SPIDER_SQL_SQL_FAST_LEN (sizeof(SPIDER_SQL_SQL_FAST_STR) - 1)
128 #define SPIDER_SQL_SQL_MEDIUM_STR " medium"
129 #define SPIDER_SQL_SQL_MEDIUM_LEN (sizeof(SPIDER_SQL_SQL_MEDIUM_STR) - 1)
130 #define SPIDER_SQL_SQL_EXTENDED_STR " extended"
131 #define SPIDER_SQL_SQL_EXTENDED_LEN (sizeof(SPIDER_SQL_SQL_EXTENDED_STR) - 1)
132 #define SPIDER_SQL_SQL_LOCAL_STR "local "
133 #define SPIDER_SQL_SQL_LOCAL_LEN (sizeof(SPIDER_SQL_SQL_LOCAL_STR) - 1)
134 #define SPIDER_SQL_SQL_USE_FRM_STR " use_frm"
135 #define SPIDER_SQL_SQL_USE_FRM_LEN (sizeof(SPIDER_SQL_SQL_USE_FRM_STR) - 1)
136 #define SPIDER_SQL_TRUNCATE_TABLE_STR "truncate table "
137 #define SPIDER_SQL_TRUNCATE_TABLE_LEN (sizeof(SPIDER_SQL_TRUNCATE_TABLE_STR) - 1)
138 #define SPIDER_SQL_EXPLAIN_SELECT_STR "explain select 1 "
139 #define SPIDER_SQL_EXPLAIN_SELECT_LEN sizeof(SPIDER_SQL_EXPLAIN_SELECT_STR) - 1
140 #define SPIDER_SQL_FLUSH_LOGS_STR "flush logs"
141 #define SPIDER_SQL_FLUSH_LOGS_LEN sizeof(SPIDER_SQL_FLUSH_LOGS_STR) - 1
142 #define SPIDER_SQL_FLUSH_TABLES_STR "flush tables"
143 #define SPIDER_SQL_FLUSH_TABLES_LEN sizeof(SPIDER_SQL_FLUSH_TABLES_STR) - 1
144 #define SPIDER_SQL_WITH_READ_LOCK_STR " with read lock"
145 #define SPIDER_SQL_WITH_READ_LOCK_LEN sizeof(SPIDER_SQL_WITH_READ_LOCK_STR) - 1
146 #define SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR " on duplicate key update "
147 #define SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN (sizeof(SPIDER_SQL_DUPLICATE_KEY_UPDATE_STR) - 1)
148 #define SPIDER_SQL_HANDLER_STR "handler "
149 #define SPIDER_SQL_HANDLER_LEN (sizeof(SPIDER_SQL_HANDLER_STR) - 1)
150 #define SPIDER_SQL_OPEN_STR " open "
151 #define SPIDER_SQL_OPEN_LEN (sizeof(SPIDER_SQL_OPEN_STR) - 1)
152 #define SPIDER_SQL_CLOSE_STR " close "
153 #define SPIDER_SQL_CLOSE_LEN (sizeof(SPIDER_SQL_CLOSE_STR) - 1)
154 #define SPIDER_SQL_READ_STR " read "
155 #define SPIDER_SQL_READ_LEN (sizeof(SPIDER_SQL_READ_STR) - 1)
156 #define SPIDER_SQL_FIRST_STR " first "
157 #define SPIDER_SQL_FIRST_LEN (sizeof(SPIDER_SQL_FIRST_STR) - 1)
158 #define SPIDER_SQL_NEXT_STR " next  "
159 #define SPIDER_SQL_NEXT_LEN (sizeof(SPIDER_SQL_NEXT_STR) - 1)
160 #define SPIDER_SQL_PREV_STR " prev  "
161 #define SPIDER_SQL_PREV_LEN (sizeof(SPIDER_SQL_PREV_STR) - 1)
162 #define SPIDER_SQL_LAST_STR " last  "
163 #define SPIDER_SQL_LAST_LEN (sizeof(SPIDER_SQL_LAST_STR) - 1)
164 #define SPIDER_SQL_AS_STR "as "
165 #define SPIDER_SQL_AS_LEN (sizeof(SPIDER_SQL_AS_STR) - 1)
166 #define SPIDER_SQL_WITH_QUERY_EXPANSION_STR " with query expansion"
167 #define SPIDER_SQL_WITH_QUERY_EXPANSION_LEN (sizeof(SPIDER_SQL_WITH_QUERY_EXPANSION_STR) - 1)
168 #define SPIDER_SQL_IN_BOOLEAN_MODE_STR " in boolean mode"
169 #define SPIDER_SQL_IN_BOOLEAN_MODE_LEN (sizeof(SPIDER_SQL_IN_BOOLEAN_MODE_STR) - 1)
170 #define SPIDER_SQL_MATCH_STR "match("
171 #define SPIDER_SQL_MATCH_LEN (sizeof(SPIDER_SQL_MATCH_STR) - 1)
172 #define SPIDER_SQL_AGAINST_STR ")against("
173 #define SPIDER_SQL_AGAINST_LEN (sizeof(SPIDER_SQL_AGAINST_STR) - 1)
174 #define SPIDER_SQL_IS_NULL_STR " is null"
175 #define SPIDER_SQL_IS_NULL_LEN (sizeof(SPIDER_SQL_IS_NULL_STR) - 1)
176 #define SPIDER_SQL_IS_NOT_NULL_STR " is not null"
177 #define SPIDER_SQL_IS_NOT_NULL_LEN (sizeof(SPIDER_SQL_IS_NOT_NULL_STR) - 1)
178 #define SPIDER_SQL_NOT_NULL_STR " not null"
179 #define SPIDER_SQL_NOT_NULL_LEN (sizeof(SPIDER_SQL_NOT_NULL_STR) - 1)
180 #define SPIDER_SQL_DEFAULT_STR " default "
181 #define SPIDER_SQL_DEFAULT_LEN (sizeof(SPIDER_SQL_DEFAULT_STR) - 1)
182 #define SPIDER_SQL_SPACE_STR " "
183 #define SPIDER_SQL_SPACE_LEN (sizeof(SPIDER_SQL_SPACE_STR) - 1)
184 #define SPIDER_SQL_ONE_STR "1"
185 #define SPIDER_SQL_ONE_LEN sizeof(SPIDER_SQL_ONE_STR) - 1
186 #define SPIDER_SQL_SQL_CACHE_STR "sql_cache "
187 #define SPIDER_SQL_SQL_CACHE_LEN (sizeof(SPIDER_SQL_SQL_CACHE_STR) - 1)
188 #define SPIDER_SQL_SQL_NO_CACHE_STR "sql_no_cache "
189 #define SPIDER_SQL_SQL_NO_CACHE_LEN (sizeof(SPIDER_SQL_SQL_NO_CACHE_STR) - 1)
190 #define SPIDER_SQL_SQL_QUICK_MODE_STR "quick "
191 #define SPIDER_SQL_SQL_QUICK_MODE_LEN (sizeof(SPIDER_SQL_SQL_QUICK_MODE_STR) - 1)
192 #define SPIDER_SQL_SET_STR " set "
193 #define SPIDER_SQL_SET_LEN (sizeof(SPIDER_SQL_SET_STR) - 1)
194 #define SPIDER_SQL_UNDERSCORE_STR "_"
195 #define SPIDER_SQL_UNDERSCORE_LEN sizeof(SPIDER_SQL_UNDERSCORE_STR) - 1
196 #define SPIDER_SQL_PF_EQUAL_STR " <=> "
197 #define SPIDER_SQL_PF_EQUAL_LEN (sizeof(SPIDER_SQL_PF_EQUAL_STR) - 1)
198 #define SPIDER_SQL_GROUP_STR " group by "
199 #define SPIDER_SQL_GROUP_LEN (sizeof(SPIDER_SQL_GROUP_STR) - 1)
200 #define SPIDER_SQL_HAVING_STR " having "
201 #define SPIDER_SQL_HAVING_LEN (sizeof(SPIDER_SQL_HAVING_STR) - 1)
202 #define SPIDER_SQL_PLUS_STR " + "
203 #define SPIDER_SQL_PLUS_LEN (sizeof(SPIDER_SQL_PLUS_STR) - 1)
204 #define SPIDER_SQL_MINUS_STR " - "
205 #define SPIDER_SQL_MINUS_LEN (sizeof(SPIDER_SQL_MINUS_STR) - 1)
206 
207 #define SPIDER_SQL_YEAR_STR "year"
208 #define SPIDER_SQL_YEAR_LEN (sizeof(SPIDER_SQL_YEAR_STR) - 1)
209 #define SPIDER_SQL_QUARTER_STR "quarter"
210 #define SPIDER_SQL_QUARTER_LEN (sizeof(SPIDER_SQL_QUARTER_STR) - 1)
211 #define SPIDER_SQL_MONTH_STR "month"
212 #define SPIDER_SQL_MONTH_LEN (sizeof(SPIDER_SQL_MONTH_STR) - 1)
213 #define SPIDER_SQL_WEEK_STR "week"
214 #define SPIDER_SQL_WEEK_LEN (sizeof(SPIDER_SQL_WEEK_STR) - 1)
215 #define SPIDER_SQL_DAY_STR "day"
216 #define SPIDER_SQL_DAY_LEN (sizeof(SPIDER_SQL_DAY_STR) - 1)
217 #define SPIDER_SQL_HOUR_STR "hour"
218 #define SPIDER_SQL_HOUR_LEN (sizeof(SPIDER_SQL_HOUR_STR) - 1)
219 #define SPIDER_SQL_MINUTE_STR "minute"
220 #define SPIDER_SQL_MINUTE_LEN (sizeof(SPIDER_SQL_MINUTE_STR) - 1)
221 #define SPIDER_SQL_SECOND_STR "second"
222 #define SPIDER_SQL_SECOND_LEN (sizeof(SPIDER_SQL_SECOND_STR) - 1)
223 #define SPIDER_SQL_MICROSECOND_STR "microsecond"
224 #define SPIDER_SQL_MICROSECOND_LEN (sizeof(SPIDER_SQL_MICROSECOND_STR) - 1)
225 
226 #define SPIDER_SQL_SHOW_RECORDS_STR "select count(*) from "
227 #define SPIDER_SQL_SHOW_RECORDS_LEN sizeof(SPIDER_SQL_SHOW_RECORDS_STR) - 1
228 #define SPIDER_SQL_SHOW_INDEX_STR "show index from "
229 #define SPIDER_SQL_SHOW_INDEX_LEN sizeof(SPIDER_SQL_SHOW_INDEX_STR) - 1
230 #define SPIDER_SQL_SELECT_STATISTICS_STR "select `column_name`,`cardinality` from `information_schema`.`statistics` where `table_schema` = "
231 #define SPIDER_SQL_SELECT_STATISTICS_LEN sizeof(SPIDER_SQL_SELECT_STATISTICS_STR) - 1
232 #define SPIDER_SQL_MAX_STR "max"
233 #define SPIDER_SQL_MAX_LEN sizeof(SPIDER_SQL_MAX_STR) - 1
234 
235 #define SPIDER_SQL_DROP_TMP_STR "drop temporary table if exists "
236 #define SPIDER_SQL_DROP_TMP_LEN (sizeof(SPIDER_SQL_DROP_TMP_STR) - 1)
237 #define SPIDER_SQL_CREATE_TMP_STR "create temporary table "
238 #define SPIDER_SQL_CREATE_TMP_LEN (sizeof(SPIDER_SQL_CREATE_TMP_STR) - 1)
239 #define SPIDER_SQL_TMP_BKA_STR "tmp_spider_bka_"
240 #define SPIDER_SQL_TMP_BKA_LEN (sizeof(SPIDER_SQL_TMP_BKA_STR) - 1)
241 #define SPIDER_SQL_ENGINE_STR ")engine="
242 #define SPIDER_SQL_ENGINE_LEN (sizeof(SPIDER_SQL_ENGINE_STR) - 1)
243 #define SPIDER_SQL_DEF_CHARSET_STR " default charset="
244 #define SPIDER_SQL_DEF_CHARSET_LEN (sizeof(SPIDER_SQL_DEF_CHARSET_STR) - 1)
245 #define SPIDER_SQL_ID_TYPE_STR " bigint"
246 #define SPIDER_SQL_ID_TYPE_LEN (sizeof(SPIDER_SQL_ID_TYPE_STR) - 1)
247 
248 #define SPIDER_SQL_COLUMN_NAME_STR "`column_name`"
249 #define SPIDER_SQL_COLUMN_NAME_LEN sizeof(SPIDER_SQL_COLUMN_NAME_STR) - 1
250 
251 #define SPIDER_SQL_A_DOT_STR "a."
252 #define SPIDER_SQL_A_DOT_LEN (sizeof(SPIDER_SQL_A_DOT_STR) - 1)
253 #define SPIDER_SQL_B_DOT_STR "b."
254 #define SPIDER_SQL_B_DOT_LEN (sizeof(SPIDER_SQL_B_DOT_STR) - 1)
255 #define SPIDER_SQL_A_STR "a"
256 #define SPIDER_SQL_A_LEN (sizeof(SPIDER_SQL_A_STR) - 1)
257 #define SPIDER_SQL_B_STR "b"
258 #define SPIDER_SQL_B_LEN (sizeof(SPIDER_SQL_B_STR) - 1)
259 
260 #define SPIDER_SQL_TRIM_STR "trim"
261 #define SPIDER_SQL_TRIM_LEN sizeof(SPIDER_SQL_TRIM_STR) - 1
262 #define SPIDER_SQL_TRIM_BOTH_STR "both "
263 #define SPIDER_SQL_TRIM_BOTH_LEN sizeof(SPIDER_SQL_TRIM_BOTH_STR) - 1
264 #define SPIDER_SQL_TRIM_LEADING_STR "leading "
265 #define SPIDER_SQL_TRIM_LEADING_LEN sizeof(SPIDER_SQL_TRIM_LEADING_STR) - 1
266 #define SPIDER_SQL_TRIM_TRAILING_STR "trailing "
267 #define SPIDER_SQL_TRIM_TRAILING_LEN sizeof(SPIDER_SQL_TRIM_TRAILING_STR) - 1
268 
269 #define SPIDER_SQL_INDEX_IGNORE_STR " IGNORE INDEX "
270 #define SPIDER_SQL_INDEX_IGNORE_LEN (sizeof(SPIDER_SQL_INDEX_IGNORE_STR) - 1)
271 #define SPIDER_SQL_INDEX_USE_STR " USE INDEX "
272 #define SPIDER_SQL_INDEX_USE_LEN (sizeof(SPIDER_SQL_INDEX_USE_STR) - 1)
273 #define SPIDER_SQL_INDEX_FORCE_STR " FORCE INDEX "
274 #define SPIDER_SQL_INDEX_FORCE_LEN (sizeof(SPIDER_SQL_INDEX_FORCE_STR) - 1)
275 
276 #define SPIDER_SQL_INT_LEN 20
277 #define SPIDER_SQL_HANDLER_CID_LEN 6
278 #define SPIDER_SQL_HANDLER_CID_FORMAT "t%05u"
279 #define SPIDER_UDF_PING_TABLE_PING_ONLY                (1 << 0)
280 #define SPIDER_UDF_PING_TABLE_USE_WHERE                (1 << 1)
281 #define SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES (1 << 2)
282 
283 int spider_db_connect(
284   const SPIDER_SHARE *share,
285   SPIDER_CONN *conn,
286   int link_idx
287 );
288 
289 int spider_db_ping_internal(
290   SPIDER_SHARE *share,
291   SPIDER_CONN *conn,
292   int all_link_idx,
293   int *need_mon
294 );
295 
296 int spider_db_ping(
297   ha_spider *spider,
298   SPIDER_CONN *conn,
299   int link_idx
300 );
301 
302 void spider_db_disconnect(
303   SPIDER_CONN *conn
304 );
305 
306 int spider_db_conn_queue_action(
307   SPIDER_CONN *conn
308 );
309 
310 int spider_db_before_query(
311   SPIDER_CONN *conn,
312   int *need_mon
313 );
314 
315 int spider_db_query(
316   SPIDER_CONN *conn,
317   const char *query,
318   uint length,
319   int quick_mode,
320   int *need_mon
321 );
322 
323 int spider_db_errorno(
324   SPIDER_CONN *conn
325 );
326 
327 int spider_db_set_trx_isolation(
328   SPIDER_CONN *conn,
329   int trx_isolation,
330   int *need_mon
331 );
332 
333 int spider_db_set_names_internal(
334   SPIDER_TRX *trx,
335   SPIDER_SHARE *share,
336   SPIDER_CONN *conn,
337   int all_link_idx,
338   int *need_mon
339 );
340 
341 int spider_db_set_names(
342   ha_spider *spider,
343   SPIDER_CONN *conn,
344   int link_idx
345 );
346 
347 int spider_db_query_with_set_names(
348   ulong sql_type,
349   ha_spider *spider,
350   SPIDER_CONN *conn,
351   int link_idx
352 );
353 
354 int spider_db_query_for_bulk_update(
355   ha_spider *spider,
356   SPIDER_CONN *conn,
357   int link_idx,
358   ha_rows *dup_key_found
359 );
360 
361 size_t spider_db_real_escape_string(
362   SPIDER_CONN *conn,
363   char *to,
364   const char *from,
365   size_t from_length
366 );
367 
368 int spider_db_consistent_snapshot(
369   SPIDER_CONN *conn,
370   int *need_mon
371 );
372 
373 int spider_db_start_transaction(
374   SPIDER_CONN *conn,
375   int *need_mon
376 );
377 
378 int spider_db_commit(
379   SPIDER_CONN *conn
380 );
381 
382 int spider_db_rollback(
383   SPIDER_CONN *conn
384 );
385 
386 int spider_db_append_hex_string(
387   spider_string *str,
388   uchar *hex_ptr,
389   int hex_ptr_length
390 );
391 
392 void spider_db_append_xid_str(
393   spider_string *tmp_str,
394   XID *xid
395 );
396 
397 int spider_db_xa_end(
398   SPIDER_CONN *conn,
399   XID *xid
400 );
401 
402 int spider_db_xa_prepare(
403   SPIDER_CONN *conn,
404   XID *xid
405 );
406 
407 int spider_db_xa_commit(
408   SPIDER_CONN *conn,
409   XID *xid
410 );
411 
412 int spider_db_xa_rollback(
413   SPIDER_CONN *conn,
414   XID *xid
415 );
416 
417 int spider_db_lock_tables(
418   ha_spider *spider,
419   int link_idx
420 );
421 
422 int spider_db_unlock_tables(
423   ha_spider *spider,
424   int link_idx
425 );
426 
427 int spider_db_append_name_with_quote_str(
428   spider_string *str,
429   const char *name,
430   uint dbton_id
431 );
432 
433 int spider_db_append_name_with_quote_str(
434   spider_string *str,
435   LEX_CSTRING &name,
436   uint dbton_id
437 );
438 
439 int spider_db_append_name_with_quote_str_internal(
440   spider_string *str,
441   const char *name,
442   int length,
443   uint dbton_id
444 );
445 
446 int spider_db_append_name_with_quote_str_internal(
447   spider_string *str,
448   const char *name,
449   int length,
450   CHARSET_INFO *cs,
451   uint dbton_id
452 );
453 
454 int spider_db_append_select(
455   ha_spider *spider
456 );
457 
458 int spider_db_append_select_columns(
459   ha_spider *spider
460 );
461 
462 int spider_db_append_null_value(
463   spider_string *str,
464   KEY_PART_INFO *key_part,
465   const uchar **ptr
466 );
467 
468 int spider_db_append_key_columns(
469   const key_range *start_key,
470   ha_spider *spider,
471   spider_string *str
472 );
473 
474 int spider_db_append_key_hint(
475   spider_string *str,
476   char *hint_str
477 );
478 
479 int spider_db_append_key_where_internal(
480   spider_string *str,
481   spider_string *str_part,
482   spider_string *str_part2,
483   const key_range *start_key,
484   const key_range *end_key,
485   ha_spider *spider,
486   bool set_order,
487   ulong sql_type,
488   uint dbton_id
489 );
490 
491 int spider_db_append_key_where(
492   const key_range *start_key,
493   const key_range *end_key,
494   ha_spider *spider
495 );
496 
497 int spider_db_append_charset_name_before_string(
498   spider_string *str,
499   CHARSET_INFO *cs
500 );
501 
502 #ifdef HANDLER_HAS_DIRECT_AGGREGATE
503 int spider_db_refetch_for_item_sum_funcs(
504   ha_spider *spider
505 );
506 
507 int spider_db_fetch_for_item_sum_funcs(
508   SPIDER_DB_ROW *row,
509   ha_spider *spider
510 );
511 
512 int spider_db_fetch_for_item_sum_func(
513   SPIDER_DB_ROW *row,
514   Item_sum *item_sum,
515   ha_spider *spider
516 );
517 #endif
518 
519 int spider_db_append_match_fetch(
520   ha_spider *spider,
521   st_spider_ft_info *ft_first,
522   st_spider_ft_info *ft_current,
523   SPIDER_DB_ROW *row
524 );
525 
526 int spider_db_append_match_where(
527   ha_spider *spider
528 );
529 
530 int spider_db_append_hint_after_table(
531   ha_spider *spider,
532   spider_string *str,
533   spider_string *hint
534 );
535 
536 int spider_db_append_show_records(
537   SPIDER_SHARE *share
538 );
539 
540 void spider_db_free_show_records(
541   SPIDER_SHARE *share
542 );
543 
544 int spider_db_append_show_index(
545   SPIDER_SHARE *share
546 );
547 
548 void spider_db_free_show_index(
549   SPIDER_SHARE *share
550 );
551 
552 void spider_db_append_handler_next(
553   ha_spider *spider
554 );
555 
556 void spider_db_get_row_from_tmp_tbl_rec(
557   SPIDER_RESULT *current,
558   SPIDER_DB_ROW **row
559 );
560 
561 int spider_db_get_row_from_tmp_tbl(
562   SPIDER_RESULT *current,
563   SPIDER_DB_ROW **row
564 );
565 
566 int spider_db_get_row_from_tmp_tbl_pos(
567   SPIDER_POSITION *pos,
568   SPIDER_DB_ROW **row
569 );
570 
571 int spider_db_fetch_row(
572   SPIDER_SHARE *share,
573   Field *field,
574   SPIDER_DB_ROW *row,
575   my_ptrdiff_t ptr_diff
576 );
577 
578 int spider_db_fetch_table(
579   ha_spider *spider,
580   uchar *buf,
581   TABLE *table,
582   SPIDER_RESULT_LIST *result_list
583 );
584 
585 int spider_db_fetch_key(
586   ha_spider *spider,
587   uchar *buf,
588   TABLE *table,
589   const KEY *key_info,
590   SPIDER_RESULT_LIST *result_list
591 );
592 
593 int spider_db_fetch_minimum_columns(
594   ha_spider *spider,
595   uchar *buf,
596   TABLE *table,
597   SPIDER_RESULT_LIST *result_list
598 );
599 
600 void spider_db_free_one_result_for_start_next(
601   ha_spider *spider
602 );
603 
604 void spider_db_free_one_result(
605   SPIDER_RESULT_LIST *result_list,
606   SPIDER_RESULT *result
607 );
608 
609 void spider_db_free_one_quick_result(
610   SPIDER_RESULT *result
611 );
612 
613 int spider_db_free_result(
614   ha_spider *spider,
615   bool final
616 );
617 
618 int spider_db_store_result(
619   ha_spider *spider,
620   int link_idx,
621   TABLE *table
622 );
623 
624 int spider_db_store_result_for_reuse_cursor(
625   ha_spider *spider,
626   int link_idx,
627   TABLE *table
628 );
629 
630 void spider_db_discard_result(
631   ha_spider *spider,
632   int link_idx,
633   SPIDER_CONN *conn
634 );
635 
636 void spider_db_discard_multiple_result(
637   ha_spider *spider,
638   int link_idx,
639   SPIDER_CONN *conn
640 );
641 
642 #ifdef HA_CAN_BULK_ACCESS
643 int spider_db_bulk_store_result(
644   ha_spider *spider,
645   SPIDER_CONN *conn,
646   int link_idx,
647   bool discard_result
648 );
649 #endif
650 
651 int spider_db_fetch(
652   uchar *buf,
653   ha_spider *spider,
654   TABLE *table
655 );
656 
657 int spider_db_seek_prev(
658   uchar *buf,
659   ha_spider *spider,
660   TABLE *table
661 );
662 
663 int spider_db_seek_next(
664   uchar *buf,
665   ha_spider *spider,
666   int link_idx,
667   TABLE *table
668 );
669 
670 int spider_db_seek_last(
671   uchar *buf,
672   ha_spider *spider,
673   int link_idx,
674   TABLE *table
675 );
676 
677 int spider_db_seek_first(
678   uchar *buf,
679   ha_spider *spider,
680   TABLE *table
681 );
682 
683 void spider_db_set_pos_to_first_row(
684   SPIDER_RESULT_LIST *result_list
685 );
686 
687 void spider_db_create_position(
688   ha_spider *spider,
689   SPIDER_POSITION *pos
690 );
691 
692 int spider_db_seek_tmp(
693   uchar *buf,
694   SPIDER_POSITION *pos,
695   ha_spider *spider,
696   TABLE *table
697 );
698 
699 int spider_db_seek_tmp_table(
700   uchar *buf,
701   SPIDER_POSITION *pos,
702   ha_spider *spider,
703   TABLE *table
704 );
705 
706 int spider_db_seek_tmp_key(
707   uchar *buf,
708   SPIDER_POSITION *pos,
709   ha_spider *spider,
710   TABLE *table,
711   const KEY *key_info
712 );
713 
714 int spider_db_seek_tmp_minimum_columns(
715   uchar *buf,
716   SPIDER_POSITION *pos,
717   ha_spider *spider,
718   TABLE *table
719 );
720 
721 int spider_db_show_table_status(
722   ha_spider *spider,
723   int link_idx,
724   int sts_mode,
725   uint flag
726 );
727 
728 int spider_db_simple_action(
729   uint simple_action,
730   spider_db_handler *db_handler,
731   int link_idx
732 );
733 
734 int spider_db_simple_action(
735   uint simple_action,
736   ha_spider *spider,
737   int link_idx,
738   bool pre_call
739 );
740 
741 void spider_db_set_cardinarity(
742   ha_spider *spider,
743   TABLE *table
744 );
745 
746 int spider_db_show_index(
747   ha_spider *spider,
748   int link_idx,
749   TABLE *table,
750   int crd_mode
751 );
752 
753 ha_rows spider_db_explain_select(
754   const key_range *start_key,
755   const key_range *end_key,
756   ha_spider *spider,
757   int link_idx
758 );
759 
760 int spider_db_bulk_insert_init(
761   ha_spider *spider,
762   const TABLE *table
763 );
764 
765 int spider_db_bulk_insert(
766   ha_spider *spider,
767   TABLE *table,
768   ha_copy_info *copy_info,
769   bool bulk_end
770 );
771 
772 #ifdef HA_CAN_BULK_ACCESS
773 int spider_db_bulk_bulk_insert(
774   ha_spider *spider
775 );
776 #endif
777 
778 int spider_db_update_auto_increment(
779   ha_spider *spider,
780   int link_idx
781 );
782 
783 int spider_db_bulk_update_size_limit(
784   ha_spider *spider,
785   TABLE *table
786 );
787 
788 int spider_db_bulk_update_end(
789   ha_spider *spider,
790   ha_rows *dup_key_found
791 );
792 
793 int spider_db_bulk_update(
794   ha_spider *spider,
795   TABLE *table,
796   my_ptrdiff_t ptr_diff
797 );
798 
799 int spider_db_update(
800   ha_spider *spider,
801   TABLE *table,
802   const uchar *old_data
803 );
804 
805 #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
806 #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
807 int spider_db_direct_update(
808   ha_spider *spider,
809   TABLE *table,
810   KEY_MULTI_RANGE *ranges,
811   uint range_count,
812   ha_rows *update_rows,
813   ha_rows *found_rows
814 );
815 #else
816 int spider_db_direct_update(
817   ha_spider *spider,
818   TABLE *table,
819   ha_rows *update_rows,
820   ha_rows *found_rows
821 );
822 #endif
823 #endif
824 
825 #ifdef HA_CAN_BULK_ACCESS
826 int spider_db_bulk_direct_update(
827   ha_spider *spider,
828   ha_rows *update_rows
829 );
830 #endif
831 
832 int spider_db_bulk_delete(
833   ha_spider *spider,
834   TABLE *table,
835   my_ptrdiff_t ptr_diff
836 );
837 
838 int spider_db_delete(
839   ha_spider *spider,
840   TABLE *table,
841   const uchar *buf
842 );
843 
844 #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
845 #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
846 int spider_db_direct_delete(
847   ha_spider *spider,
848   TABLE *table,
849   KEY_MULTI_RANGE *ranges,
850   uint range_count,
851   ha_rows *delete_rows
852 );
853 #else
854 int spider_db_direct_delete(
855   ha_spider *spider,
856   TABLE *table,
857   ha_rows *delete_rows
858 );
859 #endif
860 #endif
861 
862 int spider_db_delete_all_rows(
863   ha_spider *spider
864 );
865 
866 int spider_db_disable_keys(
867   ha_spider *spider
868 );
869 
870 int spider_db_enable_keys(
871   ha_spider *spider
872 );
873 
874 int spider_db_check_table(
875   ha_spider *spider,
876   HA_CHECK_OPT* check_opt
877 );
878 
879 int spider_db_repair_table(
880   ha_spider *spider,
881   HA_CHECK_OPT* check_opt
882 );
883 
884 int spider_db_analyze_table(
885   ha_spider *spider
886 );
887 
888 int spider_db_optimize_table(
889   ha_spider *spider
890 );
891 
892 int spider_db_flush_tables(
893   ha_spider *spider,
894   bool lock
895 );
896 
897 int spider_db_flush_logs(
898   ha_spider *spider
899 );
900 
901 Field *spider_db_find_field_in_item_list(
902   Item **item_list,
903   uint item_count,
904   uint start_item,
905   spider_string *str,
906   const char *func_name,
907   int func_name_length
908 );
909 
910 int spider_db_print_item_type(
911   Item *item,
912   Field *field,
913   ha_spider *spider,
914   spider_string *str,
915   const char *alias,
916   uint alias_length,
917   uint dbton_id,
918   bool use_fields,
919   spider_fields *fields
920 );
921 
922 int spider_db_print_item_type_default(
923   Item *item,
924   ha_spider *spider,
925   spider_string *str
926 );
927 
928 int spider_db_open_item_cond(
929   Item_cond *item_cond,
930   ha_spider *spider,
931   spider_string *str,
932   const char *alias,
933   uint alias_length,
934   uint dbton_id,
935   bool use_fields,
936   spider_fields *fields
937 );
938 
939 int spider_db_open_item_func(
940   Item_func *item_func,
941   ha_spider *spider,
942   spider_string *str,
943   const char *alias,
944   uint alias_length,
945   uint dbton_id,
946   bool use_fields,
947   spider_fields *fields
948 );
949 
950 #ifdef HANDLER_HAS_DIRECT_AGGREGATE
951 int spider_db_open_item_sum_func(
952   Item_sum *item_sum,
953   ha_spider *spider,
954   spider_string *str,
955   const char *alias,
956   uint alias_length,
957   uint dbton_id,
958   bool use_fields,
959   spider_fields *fields
960 );
961 #endif
962 
963 int spider_db_open_item_ident(
964   Item_ident *item_ident,
965   ha_spider *spider,
966   spider_string *str,
967   const char *alias,
968   uint alias_length,
969   uint dbton_id,
970   bool use_fields,
971   spider_fields *fields
972 );
973 
974 int spider_db_open_item_field(
975   Item_field *item_field,
976   ha_spider *spider,
977   spider_string *str,
978   const char *alias,
979   uint alias_length,
980   uint dbton_id,
981   bool use_fields,
982   spider_fields *fields
983 );
984 
985 int spider_db_open_item_ref(
986   Item_ref *item_ref,
987   ha_spider *spider,
988   spider_string *str,
989   const char *alias,
990   uint alias_length,
991   uint dbton_id,
992   bool use_fields,
993   spider_fields *fields
994 );
995 
996 int spider_db_open_item_row(
997   Item_row *item_row,
998   ha_spider *spider,
999   spider_string *str,
1000   const char *alias,
1001   uint alias_length,
1002   uint dbton_id,
1003   bool use_fields,
1004   spider_fields *fields
1005 );
1006 
1007 int spider_db_open_item_string(
1008   Item *item,
1009   Field *field,
1010   ha_spider *spider,
1011   spider_string *str,
1012   const char *alias,
1013   uint alias_length,
1014   uint dbton_id,
1015   bool use_fields,
1016   spider_fields *fields
1017 );
1018 
1019 int spider_db_open_item_int(
1020   Item *item,
1021   Field *field,
1022   ha_spider *spider,
1023   spider_string *str,
1024   const char *alias,
1025   uint alias_length,
1026   uint dbton_id,
1027   bool use_fields,
1028   spider_fields *fields
1029 );
1030 
1031 int spider_db_open_item_cache(
1032   Item_cache *item_cache,
1033   Field *field,
1034   ha_spider *spider,
1035   spider_string *str,
1036   const char *alias,
1037   uint alias_length,
1038   uint dbton_id,
1039   bool use_fields,
1040   spider_fields *fields
1041 );
1042 
1043 int spider_db_open_item_insert_value(
1044   Item_insert_value *item_insert_value,
1045   Field *field,
1046   ha_spider *spider,
1047   spider_string *str,
1048   const char *alias,
1049   uint alias_length,
1050   uint dbton_id,
1051   bool use_fields,
1052   spider_fields *fields
1053 );
1054 
1055 int spider_db_append_condition(
1056   ha_spider *spider,
1057   const char *alias,
1058   uint alias_length,
1059   bool test_flg
1060 );
1061 
1062 #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
1063 int spider_db_append_update_columns(
1064   ha_spider *spider,
1065   spider_string *str,
1066   const char *alias,
1067   uint alias_length,
1068   uint dbton_id,
1069   bool use_fields,
1070   spider_fields *fields
1071 );
1072 #endif
1073 
1074 #ifdef HANDLER_HAS_DIRECT_AGGREGATE
1075 bool spider_db_check_select_colum_in_group(
1076   st_select_lex *select_lex,
1077   Field *field
1078 );
1079 #endif
1080 
1081 uint spider_db_check_ft_idx(
1082   Item_func *item_func,
1083   ha_spider *spider
1084 );
1085 
1086 int spider_db_udf_fetch_row(
1087   SPIDER_TRX *trx,
1088   Field *field,
1089   SPIDER_DB_ROW *row,
1090   ulong *length
1091 );
1092 
1093 int spider_db_udf_fetch_table(
1094   SPIDER_TRX *trx,
1095   SPIDER_CONN *conn,
1096   TABLE *table,
1097   SPIDER_DB_RESULT *result,
1098   uint set_on,
1099   uint set_off
1100 );
1101 
1102 int spider_db_udf_direct_sql_connect(
1103   const SPIDER_DIRECT_SQL *direct_sql,
1104   SPIDER_CONN *conn
1105 );
1106 
1107 int spider_db_udf_direct_sql_ping(
1108   SPIDER_DIRECT_SQL *direct_sql
1109 );
1110 
1111 int spider_db_udf_direct_sql(
1112   SPIDER_DIRECT_SQL *direct_sql
1113 );
1114 
1115 int spider_db_udf_direct_sql_select_db(
1116   SPIDER_DIRECT_SQL *direct_sql,
1117   SPIDER_CONN *conn
1118 );
1119 
1120 int spider_db_udf_direct_sql_set_names(
1121   SPIDER_DIRECT_SQL *direct_sql,
1122   SPIDER_TRX *trx,
1123   SPIDER_CONN *conn
1124 );
1125 
1126 int spider_db_udf_check_and_set_set_names(
1127   SPIDER_TRX *trx
1128 );
1129 
1130 int spider_db_udf_append_set_names(
1131   SPIDER_TRX *trx
1132 );
1133 
1134 void spider_db_udf_free_set_names(
1135   SPIDER_TRX *trx
1136 );
1137 
1138 int spider_db_udf_ping_table(
1139   SPIDER_TABLE_MON_LIST *table_mon_list,
1140   SPIDER_SHARE *share,
1141   SPIDER_TRX *trx,
1142   SPIDER_CONN *conn,
1143   char *where_clause,
1144   uint where_clause_length,
1145   bool ping_only,
1146   bool use_where,
1147   longlong limit
1148 );
1149 
1150 int spider_db_udf_ping_table_append_mon_next(
1151   spider_string *str,
1152   char *child_table_name,
1153   uint child_table_name_length,
1154   int link_id,
1155   char *where_clause,
1156   uint where_clause_length,
1157   longlong first_sid,
1158   int full_mon_count,
1159   int current_mon_count,
1160   int success_count,
1161   int fault_count,
1162   int flags,
1163   longlong limit
1164 );
1165 
1166 int spider_db_udf_ping_table_append_select(
1167   spider_string *str,
1168   SPIDER_SHARE *share,
1169   SPIDER_TRX *trx,
1170   spider_string *where_str,
1171   bool use_where,
1172   longlong limit,
1173   uint dbton_id
1174 );
1175 
1176 int spider_db_udf_ping_table_mon_next(
1177   THD *thd,
1178   SPIDER_TABLE_MON *table_mon,
1179   SPIDER_CONN *conn,
1180   SPIDER_MON_TABLE_RESULT *mon_table_result,
1181   char *child_table_name,
1182   uint child_table_name_length,
1183   int link_id,
1184   char *where_clause,
1185   uint where_clause_length,
1186   longlong first_sid,
1187   int full_mon_count,
1188   int current_mon_count,
1189   int success_count,
1190   int fault_count,
1191   int flags,
1192   longlong limit
1193 );
1194 
1195 int spider_db_udf_copy_tables(
1196   SPIDER_COPY_TABLES *copy_tables,
1197   ha_spider *spider,
1198   TABLE *table,
1199   longlong bulk_insert_rows
1200 );
1201 
1202 int spider_db_open_handler(
1203   ha_spider *spider,
1204   SPIDER_CONN *conn,
1205   int link_idx
1206 );
1207 
1208 #ifdef HA_CAN_BULK_ACCESS
1209 int spider_db_bulk_open_handler(
1210   ha_spider *spider,
1211   SPIDER_CONN *conn,
1212   int link_idx
1213 );
1214 #endif
1215 
1216 int spider_db_close_handler(
1217   ha_spider *spider,
1218   SPIDER_CONN *conn,
1219   int link_idx,
1220   uint tgt_conn_kind
1221 );
1222 
1223 #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
1224 void spider_db_hs_request_buf_reset(
1225   SPIDER_CONN *conn
1226 );
1227 #endif
1228 
1229 bool spider_db_conn_is_network_error(
1230   int error_num
1231 );
1232