aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-10-05 07:58:02 -0400
committerRobert Haas <rhaas@postgresql.org>2017-10-05 08:32:48 -0400
commit32022e3f55eab593bcd829341216810730911d51 (patch)
tree3bd968014287c1b9cb4605a37e672c7898f0d9ee
parent182abe31387c31bef5cefa700d8ff193ff595713 (diff)
downloadpostgresql-32022e3f55eab593bcd829341216810730911d51.tar.gz
postgresql-32022e3f55eab593bcd829341216810730911d51.zip
Fix more user-visible elog() calls.
Michael Paquier discovered that this could be triggered via SQL; give a nicer message instead. Patch by Michael Paquier, reviewed by Masahiko Sawada. Discussion: http://postgr.es/m/CAB7nPqQtPg+LKKtzdKN26judHcvPZ0s1gNigzOT4j8CYuuuBYg@mail.gmail.com
-rw-r--r--contrib/test_decoding/expected/replorigin.out9
-rw-r--r--contrib/test_decoding/sql/replorigin.sql5
-rw-r--r--src/backend/replication/logical/origin.c12
3 files changed, 21 insertions, 5 deletions
diff --git a/contrib/test_decoding/expected/replorigin.out b/contrib/test_decoding/expected/replorigin.out
index c0f512579ca..52a52df1598 100644
--- a/contrib/test_decoding/expected/replorigin.out
+++ b/contrib/test_decoding/expected/replorigin.out
@@ -26,7 +26,14 @@ SELECT pg_replication_origin_drop('test_decoding: temp');
(1 row)
SELECT pg_replication_origin_drop('test_decoding: temp');
-ERROR: cache lookup failed for replication origin 'test_decoding: temp'
+ERROR: replication origin "test_decoding: temp" does not exist
+-- various failure checks for undefined slots
+select pg_replication_origin_advance('test_decoding: temp', '0/1');
+ERROR: replication origin "test_decoding: temp" does not exist
+select pg_replication_origin_session_setup('test_decoding: temp');
+ERROR: replication origin "test_decoding: temp" does not exist
+select pg_replication_origin_progress('test_decoding: temp', true);
+ERROR: replication origin "test_decoding: temp" does not exist
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
?column?
----------
diff --git a/contrib/test_decoding/sql/replorigin.sql b/contrib/test_decoding/sql/replorigin.sql
index e12404e106e..0e3646a212f 100644
--- a/contrib/test_decoding/sql/replorigin.sql
+++ b/contrib/test_decoding/sql/replorigin.sql
@@ -13,6 +13,11 @@ SELECT pg_replication_origin_create('test_decoding: temp');
SELECT pg_replication_origin_drop('test_decoding: temp');
SELECT pg_replication_origin_drop('test_decoding: temp');
+-- various failure checks for undefined slots
+select pg_replication_origin_advance('test_decoding: temp', '0/1');
+select pg_replication_origin_session_setup('test_decoding: temp');
+select pg_replication_origin_progress('test_decoding: temp', true);
+
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
-- origin tx
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 06f5317a750..ad99739971e 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -221,8 +221,10 @@ replorigin_by_name(char *roname, bool missing_ok)
ReleaseSysCache(tuple);
}
else if (!missing_ok)
- elog(ERROR, "cache lookup failed for replication origin '%s'",
- roname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("replication origin \"%s\" does not exist",
+ roname)));
return roident;
}
@@ -422,8 +424,10 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname)
*roname = NULL;
if (!missing_ok)
- elog(ERROR, "cache lookup failed for replication origin with oid %u",
- roident);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("replication origin with OID %u does not exist",
+ roident)));
return false;
}