Skip to content

Commit d6c1dc1

Browse files
Create new errcode for recovery conflict caused by db drop on master.
Previously reported as ERRCODE_ADMIN_SHUTDOWN, this case is now reported as ERRCODE_DATABASE_DROPPED. No message text change. Unlikely to happen on most servers, so low impact change to allow session poolers to correctly handle this situation. Tatsuo Ishii and Simon Riggs
1 parent 9a01285 commit d6c1dc1

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

doc/src/sgml/errcodes.sgml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,12 @@
13691369
<entry>cannot_connect_now</entry>
13701370
</row>
13711371

1372+
<row>
1373+
<entry><literal>57P04</literal></entry>
1374+
<entry>DATABASE DROPPED</entry>
1375+
<entry>database_dropped</entry>
1376+
</row>
1377+
13721378

13731379
<row>
13741380
<entry spanname="span13"><emphasis role="bold">Class 58 &mdash; System Error (errors external to <productname>PostgreSQL</> itself)</></entry>

src/backend/tcop/postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ ProcessInterrupts(void)
29082908
errdetail_recovery_conflict()));
29092909
else if (RecoveryConflictPending)
29102910
ereport(FATAL,
2911-
(errcode(ERRCODE_ADMIN_SHUTDOWN),
2911+
(errcode(ERRCODE_DATABASE_DROPPED),
29122912
errmsg("terminating connection due to conflict with recovery"),
29132913
errdetail_recovery_conflict()));
29142914
else

src/include/utils/errcodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@
332332
#define ERRCODE_ADMIN_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','1')
333333
#define ERRCODE_CRASH_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','2')
334334
#define ERRCODE_CANNOT_CONNECT_NOW MAKE_SQLSTATE('5','7', 'P','0','3')
335+
#define ERRCODE_DATABASE_DROPPED MAKE_SQLSTATE('5','7', 'P','0','4')
335336

336337
/* Class 58 - System Error (class borrowed from DB2) */
337338
/* (we define this as errors external to PostgreSQL itself) */

src/pl/plpgsql/src/plerrcodes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@
735735
"cannot_connect_now", ERRCODE_CANNOT_CONNECT_NOW
736736
},
737737

738+
{
739+
"database_dropped", ERRCODE_DATABASE_DROPPED
740+
},
741+
738742
{
739743
"io_error", ERRCODE_IO_ERROR
740744
},

0 commit comments

Comments
 (0)