postgres.git / summary / log / commit / refs

commit    86705aa8c3f3ec78c0b8e66cd8a4b0768e51adeb
Author:   Robert Haas <rhaas@postgresql.org>
Date:     Thu Aug 03 17:09:15 2017 +0000
First released in: 10.0, 9.6.4

    Allow a foreign table CHECK constraint to be initially NOT VALID.
    
    For a table, the constraint can be considered validated immediately,
    because the table must be empty.  But for a foreign table this is
    not necessarily the case.
    
    Fixes a bug in commit f27a6b15e6566fba7748d0d9a3fc5bcfd52c4a1b.
    
    Amit Langote, with some changes by me.
    
    Discussion: http://postgr.es/m/d2b7419f-4a71-cf86-cc99-bfd0f359a1ea@lab.ntt.co.jp


src/backend/parser/parse_utilcmd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index a86c2341f50..87cb4188a39 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -165,6 +165,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) Oid existing_relid; ParseCallbackState pcbstate; bool like_found = false; + bool is_foreign_table = IsA(stmt, CreateForeignTableStmt); /* * We must not scribble on the passed-in CreateStmt, so copy it. (This is @@ -330,7 +331,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) /* * Postprocess check constraints. */ - transformCheckConstraints(&cxt, true); + transformCheckConstraints(&cxt, !is_foreign_table ? true : false); /* * Output results. @@ -2129,9 +2130,9 @@ transformCheckConstraints(CreateStmtContext *cxt, bool skipValidation) return; /* - * If creating a new table, we can safely skip validation of check - * constraints, and nonetheless mark them valid. (This will override any - * user-supplied NOT VALID flag.) + * If creating a new table (but not a foreign table), we can safely skip + * validation of check constraints, and nonetheless mark them valid. + * (This will override any user-supplied NOT VALID flag.) */ if (skipValidation) { [parent: 12a34f59bf8b]