Change some frequently-reached elog(DEBUG...) calls to ereport(DEBUG...)
authorTom Lane
Tue, 12 Aug 2003 18:23:21 +0000 (18:23 +0000)
committerTom Lane
Tue, 12 Aug 2003 18:23:21 +0000 (18:23 +0000)
for speed reasons.  (ereport falls out much more quickly when no output
is needed than elog does.)

src/backend/libpq/be-secure.c
src/backend/optimizer/geqo/geqo_main.c
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/backend/tcop/pquery.c

index dfedaf4ea90d926dbaa207f705c0466ea456e719..953530cf327d1f2ff5645efb997bf59808349469 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.40 2003/08/04 17:58:14 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.41 2003/08/12 18:23:20 tgl Exp $
  *
  *   Since the server static private key ($DataDir/server.key)
  *   will normally be stored unencrypted so that the database
@@ -469,7 +469,9 @@ load_dh_buffer(const char *buffer, size_t len)
        return NULL;
    dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
    if (dh == NULL)
-       elog(DEBUG2, "DH load buffer: %s", SSLerrmessage());
+       ereport(DEBUG2,
+               (errmsg_internal("DH load buffer: %s",
+                                SSLerrmessage())));
    BIO_free(bio);
 
    return dh;
@@ -541,7 +543,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
    /* this may take a long time, but it may be necessary... */
    if (r == NULL || 8 * DH_size(r) < keylength)
    {
-       elog(DEBUG2, "DH: generating parameters (%d bits)....", keylength);
+       ereport(DEBUG2,
+               (errmsg_internal("DH: generating parameters (%d bits)....",
+                                keylength)));
        r = DH_generate_parameters(keylength, DH_GENERATOR_2, NULL, NULL);
    }
 
@@ -575,28 +579,36 @@ info_cb(const SSL *ssl, int type, int args)
    switch (type)
    {
        case SSL_CB_HANDSHAKE_START:
-           elog(DEBUG4, "SSL: handshake start");
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: handshake start")));
            break;
        case SSL_CB_HANDSHAKE_DONE:
-           elog(DEBUG4, "SSL: handshake done");
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: handshake done")));
            break;
        case SSL_CB_ACCEPT_LOOP:
-           elog(DEBUG4, "SSL: accept loop");
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: accept loop")));
            break;
        case SSL_CB_ACCEPT_EXIT:
-           elog(DEBUG4, "SSL: accept exit (%d)", args);
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: accept exit (%d)", args)));
            break;
        case SSL_CB_CONNECT_LOOP:
-           elog(DEBUG4, "SSL: connect loop");
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: connect loop")));
            break;
        case SSL_CB_CONNECT_EXIT:
-           elog(DEBUG4, "SSL: connect exit (%d)", args);
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: connect exit (%d)", args)));
            break;
        case SSL_CB_READ_ALERT:
-           elog(DEBUG4, "SSL: read alert (0x%04x)", args);
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: read alert (0x%04x)", args)));
            break;
        case SSL_CB_WRITE_ALERT:
-           elog(DEBUG4, "SSL: write alert (0x%04x)", args);
+           ereport(DEBUG4,
+                   (errmsg_internal("SSL: write alert (0x%04x)", args)));
            break;
    }
 }
index 1c54a4d468b56ba82d78eb2518bbb28296ccf089..d657fdf8db64f22ab1197642a10c8eb7d746e85c 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.38 2003/08/04 02:39:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.39 2003/08/12 18:23:20 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -120,30 +120,36 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
    daddy = alloc_chromo(pool->string_length);
 
 #if defined (ERX)
-   elog(DEBUG2, "using edge recombination crossover [ERX]");
+   ereport(DEBUG2,
+           (errmsg_internal("using edge recombination crossover [ERX]")));
 /* allocate edge table memory */
    edge_table = alloc_edge_table(pool->string_length);
 #elif defined(PMX)
-   elog(DEBUG2, "using partially matched crossover [PMX]");
+   ereport(DEBUG2,
+           (errmsg_internal("using partially matched crossover [PMX]")));
 /* allocate chromosome kid memory */
    kid = alloc_chromo(pool->string_length);
 #elif defined(CX)
-   elog(DEBUG2, "using cycle crossover [CX]");
+   ereport(DEBUG2,
+           (errmsg_internal("using cycle crossover [CX]")));
 /* allocate city table memory */
    kid = alloc_chromo(pool->string_length);
    city_table = alloc_city_table(pool->string_length);
 #elif defined(PX)
-   elog(DEBUG2, "using position crossover [PX]");
+   ereport(DEBUG2,
+           (errmsg_internal("using position crossover [PX]")));
 /* allocate city table memory */
    kid = alloc_chromo(pool->string_length);
    city_table = alloc_city_table(pool->string_length);
 #elif defined(OX1)
-   elog(DEBUG2, "using order crossover [OX1]");
+   ereport(DEBUG2,
+           (errmsg_internal("using order crossover [OX1]")));
 /* allocate city table memory */
    kid = alloc_chromo(pool->string_length);
    city_table = alloc_city_table(pool->string_length);
 #elif defined(OX2)
-   elog(DEBUG2, "using order crossover [OX2]");
+   ereport(DEBUG2,
+           (errmsg_internal("using order crossover [OX2]")));
 /* allocate city table memory */
    kid = alloc_chromo(pool->string_length);
    city_table = alloc_city_table(pool->string_length);
index 1e8aa879b65dd2ebce1f8a7e8d77f6229512a58d..e48bdca98d1f0a15fbaafee906fcbbb9835361a4 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.340 2003/08/04 02:40:02 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.341 2003/08/12 18:23:20 tgl Exp $
  *
  * NOTES
  *
@@ -654,11 +654,16 @@ PostmasterMain(int argc, char *argv[])
        extern char **environ;
        char      **p;
 
-       elog(DEBUG3, "%s: PostmasterMain: initial environ dump:", progname);
-       elog(DEBUG3, "-----------------------------------------");
+       ereport(DEBUG3,
+               (errmsg_internal("%s: PostmasterMain: initial environ dump:",
+                                progname)));
+       ereport(DEBUG3,
+               (errmsg_internal("-----------------------------------------")));
        for (p = environ; *p; ++p)
-           elog(DEBUG3, "\t%s", *p);
-       elog(DEBUG3, "-----------------------------------------");
+           ereport(DEBUG3,
+                   (errmsg_internal("\t%s", *p)));
+       ereport(DEBUG3,
+               (errmsg_internal("-----------------------------------------")));
    }
 
    /*
@@ -1468,8 +1473,9 @@ processCancelRequest(Port *port, void *pkt)
 
    if (backendPID == CheckPointPID)
    {
-       elog(DEBUG2, "ignoring cancel request for checkpoint process %d",
-            backendPID);
+       ereport(DEBUG2,
+               (errmsg_internal("ignoring cancel request for checkpoint process %d",
+                                backendPID)));
        return;
    }
    else if (ExecBackend)
@@ -1485,20 +1491,24 @@ processCancelRequest(Port *port, void *pkt)
            if (bp->cancel_key == cancelAuthCode)
            {
                /* Found a match; signal that backend to cancel current op */
-               elog(DEBUG2, "processing cancel request: sending SIGINT to process %d",
-                    backendPID);
+               ereport(DEBUG2,
+                       (errmsg_internal("processing cancel request: sending SIGINT to process %d",
+                                        backendPID)));
                kill(bp->pid, SIGINT);
            }
            else
                /* Right PID, wrong key: no way, Jose */
-               elog(DEBUG2, "bad key in cancel request for process %d",
-                    backendPID);
+               ereport(DEBUG2,
+                       (errmsg_internal("bad key in cancel request for process %d",
+                                        backendPID)));
            return;
        }
    }
 
    /* No matching backend */
-   elog(DEBUG2, "bad pid in cancel request for process %d", backendPID);
+   ereport(DEBUG2,
+           (errmsg_internal("bad pid in cancel request for process %d",
+                            backendPID)));
 }
 
 /*
@@ -1669,7 +1679,9 @@ pmdie(SIGNAL_ARGS)
 
    PG_SETMASK(&BlockSig);
 
-   elog(DEBUG2, "postmaster received signal %d", postgres_signal_arg);
+   ereport(DEBUG2,
+           (errmsg_internal("postmaster received signal %d",
+                            postgres_signal_arg)));
 
    switch (postgres_signal_arg)
    {
@@ -1797,7 +1809,8 @@ reaper(SIGNAL_ARGS)
 
    PG_SETMASK(&BlockSig);
 
-   elog(DEBUG4, "reaping dead processes");
+   ereport(DEBUG4,
+           (errmsg_internal("reaping dead processes")));
 #ifdef HAVE_WAITPID
    while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
    {
@@ -2007,8 +2020,10 @@ CleanupProc(int pid,
             */
            if (!FatalError)
            {
-               elog(DEBUG2, "sending %s to process %d",
-                    (SendStop ? "SIGSTOP" : "SIGQUIT"), (int) bp->pid);
+               ereport(DEBUG2,
+                       (errmsg_internal("sending %s to process %d",
+                                        (SendStop ? "SIGSTOP" : "SIGQUIT"),
+                                        (int) bp->pid)));
                kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT));
            }
        }
@@ -2093,8 +2108,10 @@ SignalChildren(int signal)
 
        if (bp->pid != MyProcPid)
        {
-           elog(DEBUG2, "sending signal %d to process %d",
-                signal, (int) bp->pid);
+           ereport(DEBUG2,
+                   (errmsg_internal("sending signal %d to process %d",
+                                    signal,
+                                    (int) bp->pid)));
            kill(bp->pid, signal);
        }
 
@@ -2207,8 +2224,9 @@ BackendStartup(Port *port)
    }
 
    /* in parent, normal */
-   elog(DEBUG2, "forked new backend, pid=%d socket=%d",
-        (int) pid, port->sock);
+   ereport(DEBUG2,
+           (errmsg_internal("forked new backend, pid=%d socket=%d",
+                            (int) pid, port->sock)));
 
    /*
     * Everything's been successful, it's safe to add this backend to our
@@ -2525,10 +2543,14 @@ BackendFork(Port *port)
    /*
     * Debug: print arguments being passed to backend
     */
-   elog(DEBUG3, "%s child[%d]: starting with (", progname, MyProcPid);
+   ereport(DEBUG3,
+           (errmsg_internal("%s child[%d]: starting with (",
+                            progname, MyProcPid)));
    for (i = 0; i < ac; ++i)
-       elog(DEBUG3, "\t%s", av[i]);
-   elog(DEBUG3, ")");
+       ereport(DEBUG3,
+               (errmsg_internal("\t%s", av[i])));
+   ereport(DEBUG3,
+           (errmsg_internal(")")));
 
    ClientAuthInProgress = false;       /* client_min_messages is active
                                         * now */
index 22cd42f98004746057deb94bb38047b1fe314c4c..72af4d0bf98123cdd2144d886be213e09a75589d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.357 2003/08/06 17:46:45 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.358 2003/08/12 18:23:21 tgl Exp $
  *
  * NOTES
  *   this is the "main" module of the postgres backend and
@@ -1730,7 +1730,8 @@ start_xact_command(void)
 {
    if (!xact_started)
    {
-       elog(DEBUG3, "StartTransactionCommand");
+       ereport(DEBUG3,
+               (errmsg_internal("StartTransactionCommand")));
        StartTransactionCommand();
 
        /* Set statement timeout running, if any */
@@ -1753,7 +1754,8 @@ finish_xact_command(void)
        disable_sig_alarm(true);
 
        /* Now commit the command */
-       elog(DEBUG3, "CommitTransactionCommand");
+       ereport(DEBUG3,
+               (errmsg_internal("CommitTransactionCommand")));
 
        CommitTransactionCommand();
 
@@ -2620,7 +2622,8 @@ PostgresMain(int argc, char *argv[], const char *username)
     * putting it inside InitPostgres() instead.  In particular, anything
     * that involves database access should be there, not here.
     */
-   elog(DEBUG3, "InitPostgres");
+   ereport(DEBUG3,
+           (errmsg_internal("InitPostgres")));
    InitPostgres(dbname, username);
 
    SetProcessingMode(NormalProcessing);
@@ -2643,7 +2646,7 @@ PostgresMain(int argc, char *argv[], const char *username)
    if (!IsUnderPostmaster)
    {
        puts("\nPOSTGRES backend interactive interface ");
-       puts("$Revision: 1.357 $ $Date: 2003/08/06 17:46:45 $\n");
+       puts("$Revision: 1.358 $ $Date: 2003/08/12 18:23:21 $\n");
    }
 
    /*
@@ -2702,7 +2705,8 @@ PostgresMain(int argc, char *argv[], const char *username)
        MemoryContextSwitchTo(ErrorContext);
 
        /* Do the recovery */
-       elog(DEBUG2, "AbortCurrentTransaction");
+       ereport(DEBUG2,
+               (errmsg_internal("AbortCurrentTransaction")));
        AbortCurrentTransaction();
 
        /*
index f204d2214dcad7b0ce6dc5cb08589f9e4402b7b8..83dd0d54d8d83934dced908a3ad248b4f3185d1f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.71 2003/08/06 17:46:46 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.72 2003/08/12 18:23:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -723,7 +723,8 @@ PortalRunUtility(Portal portal, Query *query,
 {
    Node       *utilityStmt = query->utilityStmt;
 
-   elog(DEBUG3, "ProcessUtility");
+   ereport(DEBUG3,
+           (errmsg_internal("ProcessUtility")));
 
    /*
     * Set snapshot if utility stmt needs one.  Most reliable way to do
@@ -827,7 +828,8 @@ PortalRunMulti(Portal portal,
            /*
             * process a plannable query.
             */
-           elog(DEBUG3, "ProcessQuery");
+           ereport(DEBUG3,
+                   (errmsg_internal("ProcessQuery")));
 
            /* Must always set snapshot for plannable queries */
            SetQuerySnapshot();