Skip to content

Commit 1f220c3

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 060393f commit 1f220c3

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
@@ -156,6 +156,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
156156
Oid existing_relid;
157157
ParseCallbackState pcbstate;
158158
bool like_found = false;
159+
bool is_foreign_table = IsA(stmt, CreateForeignTableStmt);
159160

160161
/*
161162
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
@@ -312,7 +313,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
312313
/*
313314
* Postprocess check constraints.
314315
*/
315-
transformCheckConstraints(&cxt, true);
316+
transformCheckConstraints(&cxt, !is_foreign_table ? true : false);
316317

317318
/*
318319
* Output results.
@@ -1935,9 +1936,9 @@ transformCheckConstraints(CreateStmtContext *cxt, bool skipValidation)
19351936
return;
19361937

19371938
/*
1938-
* If creating a new table, we can safely skip validation of check
1939-
* constraints, and nonetheless mark them valid. (This will override any
1940-
* user-supplied NOT VALID flag.)
1939+
* If creating a new table (but not a foreign table), we can safely skip
1940+
* validation of check constraints, and nonetheless mark them valid.
1941+
* (This will override any user-supplied NOT VALID flag.)
19411942
*/
19421943
if (skipValidation)
19431944
{

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