'远程系统错误:0'在 MariaDB 上使用 FederatedX 时

'Error on remote system: 0 'when using FederatedX on MariaDB

我正在使用 MariaDB 10.1 64x,但遇到 FederatedX 引擎错误。 首先,我创建一个服务器:

CREATE SERVER AAA_fed
Foreign data Wrapper mysql_1
OPTIONS (
    User 'user1',
    password 'password',
    host 'x.x.x.x',
    Port 3306,
    database 'AAA'
    );

然后使用与服务器的连接创建联合 table。

CREATE TABLE table1 
ENGINE = FEDERATED 
CONNECTION='AAA_fed';

table创建成功,但从中选择数据时,返回错误:

Error Code: 1296. Got error 10000 'Error on remote system: 0: ' from FEDERATED

有人知道解决办法吗?我一直在寻找,但找不到答案。谢谢。

WRAPPER应该是公认的连接协议。

示例:

MariaDB [(none)]> SELECT VERSION();
+--------------------------+
| VERSION()                |
+--------------------------+
| 10.1.14-MariaDB-1~xenial | -- 64 bit
+--------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> DROP DATABASE IF EXISTS `BBB`;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> DROP DATABASE IF EXISTS `AAA`;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `AAA`;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `BBB`;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE TABLE IF NOT EXISTS `AAA`.`table1` (
    ->   `id` int(20) NOT NULL,
    ->   `name` varchar(64) NOT NULL default ''
    -> ) ENGINE='InnoDB';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> DROP SERVER IF EXISTS `AAA_fed`;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE SERVER IF NOT EXISTS `AAA_fed`
    -> FOREIGN DATA WRAPPER `mysql_1` -- <-- Unsupported
    -> OPTIONS (
    ->   HOST 'x.x.x.x',
    ->   DATABASE 'AAA',
    ->   USER 'user1',
    ->   PASSWORD 'password',
    ->   PORT 3306,
    ->   SOCKET '/path/to/mysqld.sock',
    ->   OWNER 'user1'
    -> );
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE TABLE IF NOT EXISTS `BBB`.`table1`
    -> ENGINE=FEDERATED CONNECTION='AAA_fed';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT `id`, `name` FROM `BBB`.`table1`;
ERROR 1296 (HY000): Got error 10000 'Error on remote system: 0: ' from FEDERATED

MariaDB [(none)]> DROP TABLE IF EXISTS `BBB`.`table1`;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> DROP SERVER IF EXISTS `AAA_fed`;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE SERVER IF NOT EXISTS `AAA_fed`
    -> FOREIGN DATA WRAPPER `mysql` -- <-- Supported
    -> OPTIONS (
    ->   HOST 'x.x.x.x',
    ->   DATABASE 'AAA',
    ->   USER 'user1',
    ->   PASSWORD 'password',
    ->   PORT 3306,
    ->   SOCKET '/path/to/mysqld.sock',
    ->   OWNER 'user1'
    -> );
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE TABLE IF NOT EXISTS `BBB`.`table1`
    -> ENGINE=FEDERATED CONNECTION='AAA_fed';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT `id`, `name` FROM `BBB`.`table1`;
Empty set (0.00 sec)

这个错误还有一个原因。当您创建联合 table 时会发生这种情况,它指向同一服务器中的 table。