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