如何获取IMPORT FOREIGN SCHEMA生成的SQL?

时间:2016-04-22 11:31:47

标签: mysql postgresql postgres-fdw

当我import foreign schema constructor from server mysql_svr into mysql_fdw;时,我得到:

ERROR:  type "set" does not exist
LINE 6:   type set NOT NULL,
               ^
QUERY:  CREATE FOREIGN TABLE search_requests (
  id int NOT NULL,
  ctime timestamp NOT NULL,
  site_id int NOT NULL,
  query_id int NOT NULL,
  type set NOT NULL,
  page smallint NOT NULL
) SERVER mysql_svr OPTIONS (dbname 'constructor', table_name 'search_requests');

CONTEXT:  importing foreign table "search_requests"

源表是:

CREATE TABLE `search_requests` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `site_id` int(11) NOT NULL,
  `query_id` int(10) unsigned NOT NULL,
  `type` set('content','catalog','gallery') NOT NULL,
  `page` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `site` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=391 DEFAULT CHARSET=utf8

我可以获得IMPORT FOREIGN SCHEMA生成的SQL进行所有修复并手动运行吗?

1 个答案:

答案 0 :(得分:1)

API没有提及类似的内容(至少在SQL级别上),但您可以import the schema without explicit tables。你可以尝试:

void btnPostBack_Click(object sender, EventArgs e)
{
    txtFocus.Attributes["onfocus"] = "var value = this.value; this.value = ''; this.value = value; onfocus = null;";
    txtFocus.Focus();
}

导入后,您可以尝试为每个排除的表f.ex。编写映射:

IMPORT FOREIGN SCHEMA constructor
  EXCEPT (search_requests)
  FROM SERVER mysql_svr
  INTO mysql_fdw

注意:我不确定CREATE FOREIGN TABLE search_requests ( id int NOT NULL, ctime timestamp NOT NULL, site_id int NOT NULL, query_id int NOT NULL, type text NOT NULL, page smallint NOT NULL ) SERVER mysql_svr OPTIONS (dbname 'constructor', table_name 'search_requests'); 类型是否适合MySQL text类型。 MySQL中的set通常意味着错误的规范化(如PostgreSQL中的数组列类型),如果你可以改变外表,你应该这样做。

此外,这似乎是mysql_fdw bug;如果是这种情况,您应该在他们的错误跟踪系统中报告。