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

Commit 9e943d0

Browse files
knizhnikkelvich
authored andcommitted
Produce warning on creation table without primary key in multimaster
1 parent 46962bc commit 9e943d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

multimaster.c

+18
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"
@@ -5193,6 +5194,23 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51935194
{
51945195
MtmFinishDDLCommand();
51955196
}
5197+
if (nodeTag(parsetree) == T_CreateStmt)
5198+
{
5199+
CreateStmt* create = (CreateStmt*)parsetree;
5200+
Oid relid = RangeVarGetRelid(create->relation, NoLock, true);
5201+
if (relid != InvalidOid) {
5202+
Oid constraint_oid;
5203+
Bitmapset* pk = get_primary_key_attnos(relid, true, &constraint_oid);
5204+
if (pk == NULL) {
5205+
elog(WARNING,
5206+
MtmIgnoreTablesWithoutPk
5207+
? "Table %s.%s without primary will not be replicated"
5208+
: "Updates and deletes of table %s.%s without primary will not be replicated",
5209+
create->relation->schemaname ? create->relation->schemaname : "public",
5210+
create->relation->relname);
5211+
}
5212+
}
5213+
}
51965214
}
51975215

51985216
static void

0 commit comments

Comments
 (0)