Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql外部数据包装约束_Sql_Postgresql_Constraints_Foreign Data Wrapper_Multicorn - Fatal编程技术网

Postgresql外部数据包装约束

Postgresql外部数据包装约束,sql,postgresql,constraints,foreign-data-wrapper,multicorn,Sql,Postgresql,Constraints,Foreign Data Wrapper,Multicorn,我想创建一个外部表并添加一个带有约束的列。它看起来像这样: CREATE FOREIGN TABLE test ( id integer CHECK(id > 1), value character varying ) server test options ( tablename 'test', db_url 'url', primary_key 'id' ); 它给了我一个错误: ERROR: constraints are not supp

我想创建一个外部表并添加一个带有约束的列。它看起来像这样:

CREATE FOREIGN TABLE test (
    id integer CHECK(id > 1),
    value character varying
) server test options (
    tablename 'test',
    db_url 'url',
    primary_key 'id'
);
它给了我一个错误:

ERROR:  constraints are not supported on foreign tables
LINE 2: id int CHECK (id > 1),

显然,目前这是不可能的。有什么解决办法吗?如果没有,那么在将来的某个时候这会起作用吗?我在使用FDW插件的PostgreSQL 9.3.3上,我的外部表在MySQL数据库上。

您现在必须在远程端强制执行该约束。有人讨论过在外部表上支持
check
约束,但问题是Pg无法知道它们是否有效,也无法在远程数据上强制执行它们。计划员根据检查约束进行假设,如果检查约束与外部表中的数据不匹配,则可能导致计划员生成错误的计划。所以现在,它不受支持。@CraigRinger使用用户定义的函数手动检查约束怎么样?这不是解决这个问题的好办法吗?示例:
CHECK(someFunction(field)为TRUE)