Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 91dbb86

Browse files
committed
Produce warning on creation table without primary key in multimaster
1 parent 791692a commit 91dbb86

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contrib/mmts/multimaster.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "access/htup_details.h"
6363
#include "catalog/indexing.h"
6464
#include "catalog/namespace.h"
65+
#include "catalog/pg_constraint_fn.h"
6566
#include "pglogical_output/hooks.h"
6667
#include "parser/analyze.h"
6768
#include "parser/parse_relation.h"
@@ -5179,6 +5180,23 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51795180
{
51805181
MtmFinishDDLCommand();
51815182
}
5183+
if (nodeTag(parsetree) == T_CreateStmt)
5184+
{
5185+
CreateStmt* create = (CreateStmt*)parsetree;
5186+
Oid relid = RangeVarGetRelid(create->relation, NoLock, true);
5187+
if (relid != InvalidOid) {
5188+
Oid constraint_oid;
5189+
Bitmapset* pk = get_primary_key_attnos(relid, true, &constraint_oid);
5190+
if (pk == NULL) {
5191+
elog(WARNING,
5192+
MtmIgnoreTablesWithoutPk
5193+
? "Table %s.%s without primary will not be replicated"
5194+
: "Updates and deletes of table %s.%s without primary will not be replicated",
5195+
create->relation->schemaname ? create->relation->schemaname : "public",
5196+
create->relation->relname);
5197+
}
5198+
}
5199+
}
51825200
}
51835201

51845202
static void

0 commit comments

Comments
 (0)