Commit 042a0d85 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-27186 spider/partition: Report error on info() failure

Like MDEV-28105, spider may attempt to connect to remote server in
info(), and it may emit an error upon failure to connect. In this
case, the downstream caller ha_partition::open() should return the
error to avoid inconsistency.

This fixes MDEV-27186, MDEV-27237, MDEV-27334, MDEV-28241, MDEV-34101.
parent e9f4b87e
......@@ -3854,7 +3854,8 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
m_part_info->part_expr->get_monotonicity_info();
else if (m_part_info->list_of_part_fields)
m_part_func_monotonicity_info= MONOTONIC_STRICT_INCREASING;
info(HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_OPEN);
if ((error= info(HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_OPEN)))
goto err_handler;
DBUG_RETURN(0);
err_handler:
......
INSTALL SONAME 'ha_spider';
Warnings:
Warning 1105 Cannot enable tc-log at run-time. XA features of SPIDER are disabled
CREATE TABLE t (s INT) ENGINE=SPIDER PARTITION BY HASH (s);
LOAD INDEX INTO CACHE t PARTITION (p,p1);
Table Op Msg_type Msg_text
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys Error Unable to connect to foreign data source: localhost
test.t preload_keys error Corrupt
DROP TABLE t;
CREATE TABLE t (c INT PRIMARY KEY) ENGINE=SPIDER PARTITION BY KEY() PARTITIONS 2;
HANDLER t OPEN AS h;
ERROR HY000: Unable to connect to foreign data source: localhost
DROP TABLE t;
CREATE TABLE t (c INT PRIMARY KEY) ENGINE=SPIDER PARTITION BY HASH (c) PARTITIONS 2;
CREATE TRIGGER t AFTER INSERT ON t FOR EACH ROW INSERT INTO t VALUES(0);
ERROR HY000: Unable to connect to foreign data source: localhost
DROP TABLE t;
CREATE TABLE t (b INT) ENGINE=InnoDB;
PREPARE s FROM 'SELECT * FROM t LIMIT 2';
DROP TABLE t;
CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
EXECUTE s;
ERROR HY000: Unable to connect to foreign data source: localhost
DROP TABLE t;
CREATE TABLE t (c INT) ENGINE=InnoDB;
LOCK TABLES t WRITE;
CREATE OR REPLACE TABLE t (d INT) ENGINE=Spider PARTITION BY LIST COLUMNS (d) (PARTITION p VALUES IN (0));
ERROR HY000: Unable to connect to foreign data source: localhost
drop table t;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
INSTALL SONAME 'ha_spider';
# MDEV-27186
CREATE TABLE t (s INT) ENGINE=SPIDER PARTITION BY HASH (s);
LOAD INDEX INTO CACHE t PARTITION (p,p1);
DROP TABLE t;
# MDEV-27237
CREATE TABLE t (c INT PRIMARY KEY) ENGINE=SPIDER PARTITION BY KEY() PARTITIONS 2;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
HANDLER t OPEN AS h;
DROP TABLE t;
# MDEV-27334
CREATE TABLE t (c INT PRIMARY KEY) ENGINE=SPIDER PARTITION BY HASH (c) PARTITIONS 2;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
CREATE TRIGGER t AFTER INSERT ON t FOR EACH ROW INSERT INTO t VALUES(0);
DROP TABLE t;
# MDEV-28241
CREATE TABLE t (b INT) ENGINE=InnoDB;
PREPARE s FROM 'SELECT * FROM t LIMIT 2';
DROP TABLE t;
CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
EXECUTE s;
DROP TABLE t;
# MDEV-34101
CREATE TABLE t (c INT) ENGINE=InnoDB;
LOCK TABLES t WRITE;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
CREATE OR REPLACE TABLE t (d INT) ENGINE=Spider PARTITION BY LIST COLUMNS (d) (PARTITION p VALUES IN (0));
drop table t;
--disable_query_log
--source ../../include/clean_up_spider.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment