Skip to content

Commit 86705aa

Browse files
committed
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 f27a6b1. Amit Langote, with some changes by me. Discussion: http://postgr.es/m/d2b7419f-4a71-cf86-cc99-bfd0f359a1ea@lab.ntt.co.jp
1 parent 12a34f5 commit 86705aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/backend/parser/parse_utilcmd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
165165
Oid existing_relid;
166166
ParseCallbackState pcbstate;
167167
bool like_found = false;
168+
bool is_foreign_table = IsA(stmt, CreateForeignTableStmt);
168169

169170
/*
170171
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
@@ -330,7 +331,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
330331
/*
331332
* Postprocess check constraints.
332333
*/
333-
transformCheckConstraints(&cxt, true);
334+
transformCheckConstraints(&cxt, !is_foreign_table ? true : false);
334335

335336
/*
336337
* Output results.
@@ -2129,9 +2130,9 @@ transformCheckConstraints(CreateStmtContext *cxt, bool skipValidation)
21292130
return;
21302131

21312132
/*
2132-
* If creating a new table, we can safely skip validation of check
2133-
* constraints, and nonetheless mark them valid. (This will override any
2134-
* user-supplied NOT VALID flag.)
2133+
* If creating a new table (but not a foreign table), we can safely skip
2134+
* validation of check constraints, and nonetheless mark them valid.
2135+
* (This will override any user-supplied NOT VALID flag.)
21352136
*/
21362137
if (skipValidation)
21372138
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy