diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-06-29 10:30:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-06-29 10:30:08 -0400 |
commit | a1e61badf97bc446053145ba40de6db835678ce3 (patch) | |
tree | 6a4a8c2123d783c2b2761bd2db40cfefb59d3c46 /src | |
parent | c0faa727507ed34db0d02769d21bbaaf9605e2e4 (diff) | |
download | postgresql-a1e61badf97bc446053145ba40de6db835678ce3.tar.gz postgresql-a1e61badf97bc446053145ba40de6db835678ce3.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/logical/origin.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index ff4d54d6edd..5bb804cece1 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -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); |