mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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
This commit is contained in:
parent
060393f2a1
commit
1f220c3907
@ -156,6 +156,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
|||||||
Oid existing_relid;
|
Oid existing_relid;
|
||||||
ParseCallbackState pcbstate;
|
ParseCallbackState pcbstate;
|
||||||
bool like_found = false;
|
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
|
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
|
||||||
@ -312,7 +313,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
|||||||
/*
|
/*
|
||||||
* Postprocess check constraints.
|
* Postprocess check constraints.
|
||||||
*/
|
*/
|
||||||
transformCheckConstraints(&cxt, true);
|
transformCheckConstraints(&cxt, !is_foreign_table ? true : false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output results.
|
* Output results.
|
||||||
@ -1935,9 +1936,9 @@ transformCheckConstraints(CreateStmtContext *cxt, bool skipValidation)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If creating a new table, we can safely skip validation of check
|
* If creating a new table (but not a foreign table), we can safely skip
|
||||||
* constraints, and nonetheless mark them valid. (This will override any
|
* validation of check constraints, and nonetheless mark them valid.
|
||||||
* user-supplied NOT VALID flag.)
|
* (This will override any user-supplied NOT VALID flag.)
|
||||||
*/
|
*/
|
||||||
if (skipValidation)
|
if (skipValidation)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user