Skip to content

Commit fb7d899

Browse files
danolivoarssher
authored andcommitted
[PGPRO-4074] add suppress_internal_consistency_checks
(cherry picked from commit fd57355d2d036c0f03c3800d6ebf03601454793b) tags: multimaster (cherry picked from commit 17687da6bed053574913f3ef34d39b415e728f51)
1 parent 10ed487 commit fb7d899

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/backend/utils/adt/domains.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ typedef struct DomainIOData
6161
} DomainIOData;
6262

6363

64+
/*
65+
* In the case of logical replication we can update a tuple. Master sends an old
66+
* and a new version of the tuple. If we use contraint with "NOT VALID" clause
67+
* then old version of the tuple can violate the constraint but new version can
68+
* satisfy the constraint condition. In this case we need to suppress constraint
69+
* checking during restoring tuple from network connection.
70+
*/
71+
bool suppress_internal_consistency_checks = false;
72+
73+
6474
/*
6575
* domain_state_setup - initialize the cache for a new domain type.
6676
*
@@ -133,6 +143,9 @@ domain_check_input(Datum value, bool isnull, DomainIOData *my_extra)
133143
ExprContext *econtext = my_extra->econtext;
134144
ListCell *l;
135145

146+
if (suppress_internal_consistency_checks)
147+
return;
148+
136149
/* Make sure we have up-to-date constraints */
137150
UpdateDomainConstraintRef(&my_extra->constraint_ref);
138151

src/backend/utils/adt/rowtypes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ record_recv(PG_FUNCTION_ARGS)
553553

554554
/* Verify column datatype */
555555
coltypoid = pq_getmsgint(buf, sizeof(Oid));
556+
if (suppress_internal_consistency_checks)
557+
coltypoid = column_type;
558+
556559
if (coltypoid != column_type)
557560
ereport(ERROR,
558561
(errcode(ERRCODE_DATATYPE_MISMATCH),

src/include/utils/builtins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern bool parse_bool(const char *value, bool *result);
2626
extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
2727

2828
/* domains.c */
29+
extern bool suppress_internal_consistency_checks;
2930
extern void domain_check(Datum value, bool isnull, Oid domainType,
3031
void **extra, MemoryContext mcxt);
3132
extern int errdatatype(Oid datatypeOid);

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