1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Back-patch fix to ensure we abort any open transaction at backend exit.

This commit is contained in:
Tom Lane
2000-08-30 21:19:32 +00:00
parent a2661b57e1
commit dae17e5ad1

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.155 2000/05/21 02:23:30 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.155.2.1 2000/08/30 21:19:32 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
@ -1452,14 +1452,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.155 $ $Date: 2000/05/21 02:23:30 $\n"); puts("$Revision: 1.155.2.1 $ $Date: 2000/08/30 21:19:32 $\n");
} }
/* /*
* Initialize the deferred trigger manager * Initialize the deferred trigger manager
*/ */
if (DeferredTriggerInit() != 0) if (DeferredTriggerInit() != 0)
proc_exit(0); goto normalexit;
SetProcessingMode(NormalProcessing); SetProcessingMode(NormalProcessing);
@ -1479,12 +1479,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
TPRINTF(TRACE_VERBOSE, "AbortCurrentTransaction"); TPRINTF(TRACE_VERBOSE, "AbortCurrentTransaction");
AbortCurrentTransaction(); AbortCurrentTransaction();
InError = false;
if (ExitAfterAbort) if (ExitAfterAbort)
{ goto errorexit;
ProcReleaseLocks(); /* Just to be sure... */
proc_exit(0); InError = false;
}
} }
Warn_restart_ready = true; /* we can now handle elog(ERROR) */ Warn_restart_ready = true; /* we can now handle elog(ERROR) */
@ -1553,8 +1552,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (HandleFunctionRequest() == EOF) if (HandleFunctionRequest() == EOF)
{ {
/* lost frontend connection during F message input */ /* lost frontend connection during F message input */
pq_close(); goto normalexit;
proc_exit(0);
} }
break; break;
@ -1608,11 +1606,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
*/ */
case 'X': case 'X':
case EOF: case EOF:
if (!IsUnderPostmaster) goto normalexit;
ShutdownXLOG();
pq_close();
proc_exit(0);
break;
default: default:
elog(ERROR, "unknown frontend message was received"); elog(ERROR, "unknown frontend message was received");
@ -1642,10 +1636,20 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (IsUnderPostmaster) if (IsUnderPostmaster)
NullCommand(Remote); NullCommand(Remote);
} }
} /* infinite for-loop */ } /* end of main loop */
proc_exit(0); /* shouldn't get here... */ normalexit:
return 1; ExitAfterAbort = true; /* ensure we will exit if elog during abort */
AbortOutOfAnyTransaction();
if (!IsUnderPostmaster)
ShutdownXLOG();
errorexit:
pq_close();
ProcReleaseLocks(); /* Just to be sure... */
proc_exit(0);
return 1; /* keep compiler quiet */
} }
#ifndef HAVE_GETRUSAGE #ifndef HAVE_GETRUSAGE