diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml
index b5962f98cd0..c0526707773 100644
--- a/doc/src/sgml/errcodes.sgml
+++ b/doc/src/sgml/errcodes.sgml
@@ -1369,6 +1369,12 @@
cannot_connect_now
+
+57P04
+DATABASE DROPPED
+database_dropped
+
+
Class 58 — System Error (errors external to PostgreSQL> itself)>
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 08369df2d14..34705750398 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2908,7 +2908,7 @@ ProcessInterrupts(void)
errdetail_recovery_conflict()));
else if (RecoveryConflictPending)
ereport(FATAL,
- (errcode(ERRCODE_ADMIN_SHUTDOWN),
+ (errcode(ERRCODE_DATABASE_DROPPED),
errmsg("terminating connection due to conflict with recovery"),
errdetail_recovery_conflict()));
else
diff --git a/src/include/utils/errcodes.h b/src/include/utils/errcodes.h
index f7be2611f86..be13920530a 100644
--- a/src/include/utils/errcodes.h
+++ b/src/include/utils/errcodes.h
@@ -332,6 +332,7 @@
#define ERRCODE_ADMIN_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','1')
#define ERRCODE_CRASH_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','2')
#define ERRCODE_CANNOT_CONNECT_NOW MAKE_SQLSTATE('5','7', 'P','0','3')
+#define ERRCODE_DATABASE_DROPPED MAKE_SQLSTATE('5','7', 'P','0','4')
/* Class 58 - System Error (class borrowed from DB2) */
/* (we define this as errors external to PostgreSQL itself) */
diff --git a/src/pl/plpgsql/src/plerrcodes.h b/src/pl/plpgsql/src/plerrcodes.h
index 99008be9bf2..dcaf006f3e8 100644
--- a/src/pl/plpgsql/src/plerrcodes.h
+++ b/src/pl/plpgsql/src/plerrcodes.h
@@ -735,6 +735,10 @@
"cannot_connect_now", ERRCODE_CANNOT_CONNECT_NOW
},
+{
+ "database_dropped", ERRCODE_DATABASE_DROPPED
+},
+
{
"io_error", ERRCODE_IO_ERROR
},