Skip to content

Commit a1e61ba

Browse files
committed
Disallow user-created replication origins named "pg_xxx".
Since we generate such names internally, it seems like a good idea to have a policy of disallowing them for user use, as we do for many other object types. Otherwise attempts to use them will randomly fail due to collisions with internally-generated names. Discussion: https://postgr.es/m/3606.1561747369@sss.pgh.pa.us
1 parent c0faa72 commit a1e61ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/backend/replication/logical/origin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "access/table.h"
7979
#include "access/xact.h"
8080

81+
#include "catalog/catalog.h"
8182
#include "catalog/indexing.h"
8283
#include "nodes/execnodes.h"
8384

@@ -1228,6 +1229,15 @@ pg_replication_origin_create(PG_FUNCTION_ARGS)
12281229
replorigin_check_prerequisites(false, false);
12291230

12301231
name = text_to_cstring((text *) DatumGetPointer(PG_GETARG_DATUM(0)));
1232+
1233+
/* Replication origins "pg_xxx" are reserved for internal use */
1234+
if (IsReservedName(name))
1235+
ereport(ERROR,
1236+
(errcode(ERRCODE_RESERVED_NAME),
1237+
errmsg("replication origin name \"%s\" is reserved",
1238+
name),
1239+
errdetail("Origin names starting with \"pg_\" are reserved.")));
1240+
12311241
roident = replorigin_create(name);
12321242

12331243
pfree(name);

0 commit comments

Comments
 (0)