aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-02-20 02:22:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-02-20 02:22:07 +0000
commit60b2444cc3ba037630c9b940c3c9ef01b954b87b (patch)
tree801836d707d7b2af3367b9a4fa768a44d2530a1e /src/backend/tcop/postgres.c
parent617d16f4ff4959b1615cc9f57e271629c000ccff (diff)
downloadpostgresql-60b2444cc3ba037630c9b940c3c9ef01b954b87b.tar.gz
postgresql-60b2444cc3ba037630c9b940c3c9ef01b954b87b.zip
Add code to prevent transaction ID wraparound by enforcing a safe limit
in GetNewTransactionId(). Since the limit value has to be computed before we run any real transactions, this requires adding code to database startup to scan pg_database and determine the oldest datfrozenxid. This can conveniently be combined with the first stage of an attack on the problem that the 'flat file' copies of pg_shadow and pg_group are not properly updated during WAL recovery. The code I've added to startup resides in a new file src/backend/utils/init/flatfiles.c, and it is responsible for rewriting the flat files as well as initializing the XID wraparound limit value. This will eventually allow us to get rid of GetRawDatabaseInfo too, but we'll need an initdb so we can add a trigger to pg_database.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index d640c3b602c..58d7bade5c6 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.440 2004/12/31 22:01:16 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.441 2005/02/20 02:21:57 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -55,6 +55,7 @@
#include "tcop/pquery.h"
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
+#include "utils/flatfiles.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
@@ -2706,6 +2707,12 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
LoadFreeSpaceMap();
on_shmem_exit(DumpFreeSpaceMap, 0);
+
+ /*
+ * We have to build the flat file for pg_database, but not for
+ * the user and group tables, since we won't try to do authentication.
+ */
+ BuildFlatFiles(true);
}
/*