From 1a5fb654639ea5d2ecad085cc7c2d5d3d269f620 Mon Sep 17 00:00:00 2001 From: Marc G. Fournier Date: Tue, 25 Aug 1998 21:04:41 +0000 Subject: From: Massimo Dal Zotto assert.patch adds a switch to turn on/off the assert checking if enabled at compile time. You can now compile postgres with assert checking and disable it at runtime in a production environment. --- src/backend/postmaster/postmaster.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/backend/postmaster') diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 7f33dfedba3..0525282fd50 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.93 1998/07/09 03:28:47 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.94 1998/08/25 21:04:36 scrappy Exp $ * * NOTES * @@ -238,6 +238,9 @@ void GetCharSetByHost(char *, int, char *); #endif +#ifdef USE_ASSERT_CHECKING +int assert_enabled = 1; +#endif static void checkDataDir(const char *DataDir, bool *DataDirOK) @@ -295,8 +298,6 @@ checkDataDir(const char *DataDir, bool *DataDirOK) } } - - int PostmasterMain(int argc, char *argv[]) { @@ -365,10 +366,22 @@ PostmasterMain(int argc, char *argv[]) DataDir = getenv("PGDATA"); /* default value */ opterr = 0; - while ((opt = getopt(nonblank_argc, argv, "a:B:b:D:dim:Mno:p:Ss")) != EOF) + while ((opt = getopt(nonblank_argc, argv,"A:a:B:b:D:dim:Mno:p:Ss")) != EOF) { switch (opt) { + case 'A': +#ifndef USE_ASSERT_CHECKING + fprintf(stderr, "Assert checking is not enabled\n"); +#else + /* + * Pass this option also to each backend. + */ + assert_enabled = atoi(optarg); + strcat(ExtraOptions, " -A "); + strcat(ExtraOptions, optarg); +#endif + break; case 'a': /* Can no longer set authentication method. */ break; @@ -566,6 +579,9 @@ static void usage(const char *progname) { fprintf(stderr, "usage: %s [options]\n", progname); +#ifdef USE_ASSERT_CHECKING + fprintf(stderr, "\t-A [1|0]\tenable/disable runtime assert checking\n"); +#endif fprintf(stderr, "\t-B nbufs\tset number of shared buffers\n"); fprintf(stderr, "\t-D datadir\tset data directory\n"); fprintf(stderr, "\t-S \t\tsilent mode (disassociate from tty)\n"); -- cgit v1.2.3