mariadb/storage/spider/spd_param.h
Yuchen Pei 1307d1fbdf
MDEV-27260 implement spider select handler
This is a squash of about two dozen commits for MDEV-37114,
MDEV-37110, MDEV-37111, see below

----

MDEV-27260 [WIP] Initial stub of spider select handler

MDEV-27260 [wip] An dummy implementation of spider select that returns a single row of NULL

Sample test case:

--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link= 1;
set spider_disable_select_handler= 0;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values (1), (2), (3);
select * from t1;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

MDEV-27260 [wip] beelining a spider select handler poc

Works for the following simple case

--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link= 1;
set spider_disable_select_handler= 0;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values (1), (2), (3);
select c from t1;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

MDEV-27260 MDEV-37110 [wip] Make spider sh work with cases not working well with spider gbh

See added testcase

MDEV-27260 MDEV-37111 spider sh: Check backends used by spider tables

MDEV-37111 set first_link_idx and create conn for every ha_spider involved

also return failure when remote query execution fails.

MDEV-37111 Fix some result mismatch

Later we'll have to find a way (rdiff?) to accommodate both sh and gbh

MDEV-37111 spider sh: do not create for partitioned tables

neither does gbh except when there's one partition only.

MDEV-37111 Ban spider sh if containing any subqueries

The same limitation applies to gbh

MDEV-37111 spider sh: reset select_column_mode just like gbh

MDEV-37111 mtr --record spider.direct_join

MDEV-37111 Do not create spider sh if not all tables share the same first connection

We have been only checking the first connection. If no tables have HA,
and they all use the same remote server, then an sh creation can proceed

MDEV-37111 spider sh: sync link idx of dbton_handler and the connection

...so that the table name translation is correct

MDEV-37111 add a possible error caused by the spider sh

spider error reporting. previous query

INSERT INTO t2 SELECT * FROM t3

failed to connect because t1 is self-referencing, though the reported
error is ER_WRONG_VALUE_COUNT_ON_ROW from the sql layer.

in

SELECT * FROM t3

then during optimization (skipped in sh) the previous error gets
reported.

It's mainly a problem with spider error reporting, so we fix it with a record

MDEV-37111 spider sh: check error mode before reporting errors

With erm (error_read_mode) an error becomes an empty result with a
warning

MDEV-37111 spider sh: add checks and set db for udf

udf_pushdown passes, but the two ha tests now fail

MDEV-37111 spider sh: fix mdev_34541

just a different (non-spider version of the) error

MDEV-37111 spider sh: only create if the first link is OK

gbh implementation w.r.t. checking remote link status is unnecessarily
convoluted.

MDEV-37111 spider sh: append correct lock in INSERT...SELECT

Also record spider_fixes tests results because the direct_order_limit
status variable makes no sense

MDEV-37111 spider sh: execute queries that are required by some system variables

Whether these queries are needed is a separate question. This fixes
failures in sql_mode_mysql and sql_mode_mariadb.

For similar reasons, execute start transaction and commit because of
test .result file has them.

MDEV-37111 spider sh: mtr --record engine_defined_attributes

without spider sh, the "FORCE INDEX" hint is appended in
ha_spider::append_hint_after_table_sql_part through
get_index_max_value as part of the optimization, and gbh is not
involved.

TODO: consider respecting the hint in spider sh/gbh

MDEV-37111 spider sh: do not create if the query has been optimized

Check select_lex->first_cond_optimization. It could happen during 2nd
and subsequent ps execution when sh is not created in the first ps
execution
2025-09-24 15:22:04 +10:00

372 lines
7.6 KiB
C++

/* Copyright (C) 2008-2019 Kentoku Shiba
Copyright (C) 2019 MariaDB corp
This program is free software); you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation); version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY); without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program); if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
constexpr uint spider_udf_table_lock_mutex_count= 20;
constexpr uint spider_udf_table_mon_mutex_count= 20;
my_bool spider_param_support_xa();
my_bool spider_param_connect_mutex();
uint spider_param_connect_error_interval();
uint spider_param_table_init_error_interval();
int spider_param_use_table_charset(
int use_table_charset
);
uint spider_param_conn_recycle_mode(
THD *thd
);
uint spider_param_conn_recycle_strict(
THD *thd
);
bool spider_param_sync_trx_isolation(
THD *thd
);
bool spider_param_use_consistent_snapshot(
THD *thd
);
bool spider_param_internal_xa(
THD *thd
);
uint spider_param_internal_xa_snapshot(
THD *thd
);
uint spider_param_force_commit(
THD *thd
);
uint spider_param_xa_register_mode(
THD *thd
);
longlong spider_param_internal_offset(
THD *thd,
longlong internal_offset
);
longlong spider_param_internal_limit(
THD *thd,
longlong internal_limit
);
longlong spider_param_split_read(
THD *thd,
longlong split_read
);
double spider_param_semi_split_read(
THD *thd,
double semi_split_read
);
longlong spider_param_semi_split_read_limit(
THD *thd,
longlong semi_split_read_limit
);
int spider_param_init_sql_alloc_size(
THD *thd,
int init_sql_alloc_size
);
int spider_param_reset_sql_alloc(
THD *thd,
int reset_sql_alloc
);
int spider_param_multi_split_read(
THD *thd,
int multi_split_read
);
int spider_param_max_order(
THD *thd,
int max_order
);
int spider_param_semi_trx_isolation(
THD *thd
);
int spider_param_semi_table_lock(
THD *thd,
int semi_table_lock
);
int spider_param_semi_table_lock_connection(
THD *thd,
int semi_table_lock_connection
);
uint spider_param_block_size(
THD *thd
);
int spider_param_selupd_lock_mode(
THD *thd,
int selupd_lock_mode
);
bool spider_param_sync_autocommit(
THD *thd
);
bool spider_param_use_default_database(
THD *thd
);
int spider_param_internal_sql_log_off(
THD *thd
);
int spider_param_bulk_size(
THD *thd,
int bulk_size
);
int spider_param_bulk_update_mode(
THD *thd,
int bulk_update_mode
);
int spider_param_bulk_update_size(
THD *thd,
int bulk_update_size
);
int spider_param_buffer_size(
THD *thd,
int buffer_size
);
int spider_param_internal_optimize(
THD *thd,
int internal_optimize
);
int spider_param_internal_optimize_local(
THD *thd,
int internal_optimize_local
);
bool spider_param_use_flash_logs(
THD *thd
);
int spider_param_use_snapshot_with_flush_tables(
THD *thd
);
bool spider_param_use_all_conns_snapshot(
THD *thd
);
bool spider_param_lock_exchange(
THD *thd
);
bool spider_param_internal_unlock(
THD *thd
);
bool spider_param_semi_trx(
THD *thd
);
int spider_param_connect_timeout(
THD *thd,
int connect_timeout
);
int spider_param_net_read_timeout(
THD *thd,
int net_read_timeout
);
int spider_param_net_write_timeout(
THD *thd,
int net_write_timeout
);
int spider_param_quick_mode(
THD *thd,
int quick_mode
);
longlong spider_param_quick_page_size(
THD *thd,
longlong quick_page_size
);
longlong spider_param_quick_page_byte(
THD *thd,
longlong quick_page_byte
);
int spider_param_low_mem_read(
THD *thd,
int low_mem_read
);
int spider_param_select_column_mode(
THD *thd,
int select_column_mode
);
int spider_param_bgs_mode(
THD *thd,
int bgs_mode
);
longlong spider_param_bgs_first_read(
THD *thd,
longlong bgs_first_read
);
longlong spider_param_bgs_second_read(
THD *thd,
longlong bgs_second_read
);
longlong spider_param_first_read(
THD *thd,
longlong first_read
);
longlong spider_param_second_read(
THD *thd,
longlong second_read
);
double spider_param_crd_interval(
THD *thd,
double crd_interval
);
int spider_param_crd_mode(
THD *thd,
int crd_mode
);
int spider_param_crd_sync(
THD *thd,
int crd_sync
);
int spider_param_crd_type(
THD *thd,
int crd_type
);
double spider_param_crd_weight(
THD *thd,
double crd_weight
);
int spider_param_crd_bg_mode(
THD *thd,
int crd_bg_mode
);
double spider_param_sts_interval(
THD *thd,
double sts_interval
);
int spider_param_sts_mode(
THD *thd,
int sts_mode
);
int spider_param_sts_sync(
THD *thd,
int sts_sync
);
int spider_param_sts_bg_mode(
THD *thd,
int sts_bg_mode
);
double spider_param_ping_interval_at_trx_start(
THD *thd
);
int spider_param_auto_increment_mode(
THD *thd,
int auto_increment_mode
);
bool spider_param_same_server_link(
THD *thd
);
bool spider_param_local_lock_table(
THD *thd
);
int spider_param_use_pushdown_udf(
THD *thd,
int use_pushdown_udf
);
int spider_param_direct_dup_insert(
THD *thd,
int direct_dup_insert
);
char *spider_param_remote_access_charset();
int spider_param_remote_autocommit();
char *spider_param_remote_time_zone();
int spider_param_remote_sql_log_off();
int spider_param_remote_trx_isolation();
char *spider_param_remote_default_database();
longlong spider_param_connect_retry_interval(
THD *thd
);
int spider_param_connect_retry_count(
THD *thd
);
char *spider_param_bka_engine(
THD *thd,
char *bka_engine
);
int spider_param_bka_mode(
THD *thd,
int bka_mode
);
int spider_param_error_read_mode(
THD *thd,
int error_read_mode
);
int spider_param_error_write_mode(
THD *thd,
int error_write_mode
);
int spider_param_skip_default_condition(
THD *thd,
int skip_default_condition
);
int spider_param_skip_parallel_search(
THD *thd,
int skip_parallel_search
);
longlong spider_param_direct_order_limit(
THD *thd,
longlong direct_order_limit
);
int spider_param_read_only_mode(
THD *thd,
int read_only_mode
);
my_bool spider_param_general_log();
my_bool spider_param_index_hint_pushdown(
THD *thd
);
uint spider_param_max_connections();
uint spider_param_conn_wait_timeout();
uint spider_param_log_result_errors();
uint spider_param_log_result_error_with_sql();
uint spider_param_internal_xa_id_type(
THD *thd
);
int spider_param_casual_read(
THD *thd,
int casual_read
);
my_bool spider_param_dry_access();
int spider_param_delete_all_rows_type(
THD *thd,
int delete_all_rows_type
);
int spider_param_bka_table_name_type(
THD *thd,
int bka_table_name_type
);
int spider_param_use_cond_other_than_pk_for_update(
THD *thd
);
int spider_param_store_last_sts(
int store_last_sts
);
int spider_param_store_last_crd(
int store_last_crd
);
int spider_param_load_sts_at_startup(
int load_sts_at_startup
);
int spider_param_load_crd_at_startup(
int load_crd_at_startup
);
uint spider_param_table_sts_thread_count();
uint spider_param_table_crd_thread_count();
int spider_param_slave_trx_isolation();
int spider_param_remote_wait_timeout(
THD *thd
);
int spider_param_wait_timeout(
THD *thd
);
bool spider_param_sync_sql_mode(
THD *thd
);
int spider_param_strict_group_by(
THD *thd,
int strict_group_by
);
bool spider_param_direct_aggregate(THD *thd);
bool spider_param_disable_group_by_handler(THD *thd);
bool spider_param_disable_select_handler(THD *thd);
bool spider_param_suppress_comment_ignored_warning(THD *thd);
bool spider_param_ignore_comments(THD *thd);