Index: src/backend/commands/vacuum.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/vacuum.c,v retrieving revision 1.195 diff -c -r1.195 vacuum.c *** src/backend/commands/vacuum.c 2001/05/25 15:45:32 1.195 --- src/backend/commands/vacuum.c 2001/06/13 21:01:37 *************** *** 17,22 **** --- 17,23 ---- #include #include #include + #include #include #include #include *************** *** 159,166 **** static bool enough_space(VacPage vacpage, Size len); static void init_rusage(VacRUsage *ru0); static char *show_rusage(VacRUsage *ru0); - /* * Primary entry point for VACUUM and ANALYZE commands. */ --- 160,167 ---- static bool enough_space(VacPage vacpage, Size len); static void init_rusage(VacRUsage *ru0); static char *show_rusage(VacRUsage *ru0); + static void check_limits(void); /* * Primary entry point for VACUUM and ANALYZE commands. */ *************** *** 236,241 **** --- 237,243 ---- /* clean up */ vacuum_shutdown(); + check_limits(); } /* *************** *** 2645,2648 **** --- 2647,2674 ---- (int) (ru1.tv.tv_usec - ru0->tv.tv_usec) / 10000); return result; + } + + /* + * check if we are near OID or XID wraparound + */ + static void check_limits(void) + { + Oid nextOid; + + /* If we are 75% to the limit, warn the user */ + if (GetCurrentTransactionId() > UINT_MAX - UINT_MAX / 4) + elog(NOTICE,"You are %.0f%% toward the limit for transaction ids.\n" + "\t Dumping your databases, running initdb, and reloading will reset\n" + "\t the transaction id counter.", + GetCurrentTransactionId() / (float)UINT_MAX * 100); + + /* If we are 75% to the limit, warn the user */ + GetNewObjectId(&nextOid); + if (nextOid > OID_MAX - OID_MAX / 4) + elog(NOTICE,"You are %.0f%% toward the limit for object ids.\n" + "\t If you are not using object ids as primary keys, dumping your\n" + "\t databases, running initdb, and reloading will reset\n" + "\t the oid counter.", + (float)nextOid / OID_MAX * 100); }