]> granicus.if.org Git - postgresql/commitdiff
Disallow user-created replication origins named "pg_xxx".
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 29 Jun 2019 14:30:08 +0000 (10:30 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 29 Jun 2019 14:30:08 +0000 (10:30 -0400)
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

src/backend/replication/logical/origin.c

index ff4d54d6edd6f94ada52a91628c8eb8a61d7f0b1..5bb804cece1d24b3ab0ccc59f73915cb513212ac 100644 (file)
@@ -78,6 +78,7 @@
 #include "access/table.h"
 #include "access/xact.h"
 
+#include "catalog/catalog.h"
 #include "catalog/indexing.h"
 #include "nodes/execnodes.h"
 
@@ -1228,6 +1229,15 @@ pg_replication_origin_create(PG_FUNCTION_ARGS)
        replorigin_check_prerequisites(false, false);
 
        name = text_to_cstring((text *) DatumGetPointer(PG_GETARG_DATUM(0)));
+
+       /* Replication origins "pg_xxx" are reserved for internal use */
+       if (IsReservedName(name))
+               ereport(ERROR,
+                               (errcode(ERRCODE_RESERVED_NAME),
+                                errmsg("replication origin name \"%s\" is reserved",
+                                               name),
+                                errdetail("Origin names starting with \"pg_\" are reserved.")));
+
        roident = replorigin_create(name);
 
        pfree(name);