8000 Change some frequently-reached elog(DEBUG...) calls to ereport(DEBUG...) · s-monk/postgres@fcb90fd · GitHub
[go: up one dir, main page]

Skip to content

Commit fcb90fd

Browse files
committed
Change some frequently-reached elog(DEBUG...) calls to ereport(DEBUG...)
for speed reasons. (ereport falls out much more quickly when no output is needed than elog does.)
1 parent 1c6702f commit fcb90fd

File tree

5 files changed

+96
-50
lines changed

5 files changed

+96
-50
lines changed

src/backend/libpq/be-secure.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.40 2003/08/04 17:58:14 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.41 2003/08/12 18:23:20 tgl Exp $
1515
*
1616
* Since the server static private key ($DataDir/server.key)
1717
* will normally be stored unencrypted so that the database
@@ -469,7 +469,9 @@ load_dh_buffer(const char *buffer, size_t len)
469469
return NULL;
470470
dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
471471
if (dh == NULL)
472-
elog(DEBUG2, "DH load buffer: %s", SSLerrmessage());
472+
ereport(DEBUG2,
473+
(errmsg_internal("DH load buffer: %s",
474+
SSLerrmessage())));
473475
BIO_free(bio);
474476

475477
return dh;
@@ -541,7 +543,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
541543
/* this may take a long time, but it may be necessary... */
542544
if (r == NULL || 8 * DH_size(r) < keylength)
543545
{
544-
elog(DEBUG2, "DH: generating parameters (%d bits)....", keylength);
546+
ereport(DEBUG2,
547+
(errmsg_internal("DH: generating parameters (%d bits)....",
548+
keylength)));
545549
r = DH_generate_parameters(keylength, DH_GENERATOR_2, NULL, NULL);
546550
}
547551

@@ -575,28 +579,36 @@ info_cb(const SSL *ssl, int type, int args)
575579
switch (type)
576580
{
577581
case SSL_CB_HANDSHAKE_START:
578-
elog(DEBUG4, "SSL: handshake start");
582+
ereport(DEBUG4,
583+
(errmsg_internal("SSL: handshake start")));
579584
break;
580585
case SSL_CB_HANDSHAKE_DONE:
581-
elog(DEBUG4, "SSL: handshake done");
586+
ereport(DEBUG4,
587+
(errmsg_internal("SSL: handshake done")));
582588
break;
583589
case SSL_CB_ACCEPT_LOOP:
584-
elog(DEBUG4, "SSL: accept loop");
590+
ereport(DEBUG4,
591+
(errmsg_internal("SSL: accept loop")));
585592
break;
586593
case SSL_CB_ACCEPT_EXIT:
587-
elog(DEBUG4, "SSL: accept exit (%d)", args);
594+
ereport(DEBUG4,
595+
(errmsg_internal("SSL: accept exit (%d)", args)));
588596
break;
589597
case SSL_CB_CONNECT_LOOP:
590-
elog(DEBUG4, "SSL: connect loop");
598+
ereport(DEBUG4,
599+
(errmsg_internal("SSL: connect loop")));
591600
break;
592601
case SSL_CB_CONNECT_EXIT:
593-
elog(DEBUG4, "SSL: connect exit (%d)", args);
602+
ereport(DEBUG4,
603+
(errmsg_internal("SSL: connect exit (%d)", args)));
594604
break;
595605
case SSL_CB_READ_ALERT:
596-
elog(DEBUG4, "SSL: read alert (0x%04x)", args);
606+
ereport(DEBUG4,
607+
(errmsg_internal("SSL: read alert (0x%04x)", args)));
597608
break;
598609
case SSL_CB_WRITE_ALERT:
599-
elog(DEBUG4, "SSL: write alert (0x%04x)", args);
610+
ereport(DEBUG4,
611+
(errmsg_internal("SSL: write alert (0x%04x)", args)));
600612
break;
601613
}
602614
}

src/backend/optimizer/geqo/geqo_main.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.38 2003/08/04 02:39:59 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.39 2003/08/12 18:23:20 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -120,30 +120,36 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
120120
daddy = alloc_chromo(pool->string_length);
121121

122122
#if defined (ERX)
123-
elog(DEBUG2, "using edge recombination crossover [ERX]");
123+
ereport(DEBUG2,
124+
(errmsg_internal("using edge recombination crossover [ERX]")));
124125
/* allocate edge table memory */
125126
edge_table = alloc_edge_table(pool->string_length);
126127
#elif defined(PMX)
127-
elog(DEBUG2, "using partially matched crossover [PMX]");
128+
ereport(DEBUG2,
129+
(errmsg_internal("using partially matched crossover [PMX]")));
128130
/* allocate chromosome kid memory */
129131
kid = alloc_chromo(pool->string_length);
130132
#elif defined(CX)
131-
elog(DEBUG2, "using cycle crossover [CX]");
133+
ereport(DEBUG2,
134+
(errmsg_internal("using cycle crossover [CX]")));
132135
/* allocate city table memory */
133136
kid = alloc_chromo(pool->string_length);
134137
city_table = alloc_city_table(pool->string_length);
135138
#elif defined(PX)
136-
elog(DEBUG2, "using position crossover [PX]");
139+
ereport(DEBUG2,
140+
(errmsg_internal("using position crossover [PX]")));
137141
/* allocate city table memory */
138142
kid = alloc_chromo(pool->string_length);
139143
city_table = alloc_city_table(pool->string_length);
140144
#elif defined(OX1)
141-
elog(DEBUG2, "using order crossover [OX1]");
145+
ereport(DEBUG2,
146+
(errmsg_internal("using order crossover [OX1]")));
142147
/* allocate city table memory */
143148
kid = alloc_chromo(pool->string_length);
144149
city_table = alloc_city_table(pool->string_length);
145150
#elif defined(OX2)
146-
elog(DEBUG2, "using order crossover [OX2]");
151+
ereport(DEBUG2,
152+
(errmsg_internal("using order crossover [OX2]")));
147153
/* allocate city table memory */
148154
kid = alloc_chromo(pool->string_length);
149155
city_table = alloc_city_table(pool->string_length);

src/backend/postmaster/postmaster.c

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.340 2003/08/04 02:40:02 momjian Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.341 2003/08/12 18:23:20 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -654,11 +654,16 @@ PostmasterMain(int argc, char *argv[])
654654
extern char **environ;
655655
char **p;
656656

657-
elog(DEBUG3, "%s: PostmasterMain: initial environ dump:", progname);
658-
elog(DEBUG3, "-----------------------------------------");
657+
ereport(DEBUG3,
658+
(errmsg_internal("%s: PostmasterMain: initial environ dump:",
659+
progname)));
660+
ereport(DEBUG3,
661+
(errmsg_internal("-----------------------------------------")));
659662
for (p = environ; *p; ++p)
660-
elog(DEBUG3, "\t%s", *p);
661-
elog(DEBUG3, "-----------------------------------------");
663+
ereport(DEBUG3,
664+
(errmsg_internal("\t%s", *p)));
665+
ereport(DEBUG3,
666+
(errmsg_internal("-----------------------------------------")));
662667
}
663668

664669
/*
@@ -1468,8 +1473,9 @@ processCancelRequest(Port *port, void *pkt)
14681473

14691474
if (backendPID == CheckPointPID)
14701475
{
1471-
elog(DEBUG2, "ignoring cancel request for checkpoint process %d",
1472-
backendPID);
1476+
ereport(DEBUG2,
1477+
(errmsg_internal("ignoring cancel request for checkpoint process %d",
1478+
backendPID)));
14731479
return;
14741480
}
14751481
else if (ExecBackend)
@@ -1485,20 +1491,24 @@ processCancelRequest(Port *port, void *pkt)
14851491
if (bp->cancel_key == cancelAuthCode)
14861492
{
14871493
/* Found a match; signal that backend to cancel current op */
1488-
elog(DEBUG2, "processing cancel request: sending SIGINT to process %d",
1489-
backendPID);
1494+
ereport(DEBUG2,
1495+
(errmsg_internal("processing cancel request: sending SIGINT to process %d",
1496+
backendPID)));
14901497
kill(bp->pid, SIGINT);
14911498
}
14921499
else
14931500
/* Right PID, wrong key: no way, Jose */
1494-
elog(DEBUG2, "bad key in cancel request for process %d",
1495-
backendPID);
1501+
ereport(DEBUG2,
1502+
(errmsg_internal("bad key in cancel request for process %d",
1503+
backendPID)));
14961504
return;
14971505
}
14981506
}
14991507

15001508
/* No matching backend */
1501-
elog(DEBUG2, "bad pid in cancel request for process %d", backendPID);
1509+
ereport(DEBUG2,
1510+
(errmsg_internal("bad pid in cancel request for process %d",
1511+
backendPID)));
15021512
}
15031513

15041514
/*
@@ -1669,7 +1679,9 @@ pmdie(SIGNAL_ARGS)
16691679

16701680
PG_SETMASK(&BlockSig);
16711681

1672 F438 -
elog(DEBUG2, "postmaster received signal %d", postgres_signal_arg);
1682+
ereport(DEBUG2,
1683+
(errmsg_internal("postmaster received signal %d",
1684+
postgres_signal_arg)));
16731685

16741686
switch (postgres_signal_arg)
16751687
{
@@ -1797,7 +1809,8 @@ reaper(SIGNAL_ARGS)
17971809

17981810
PG_SETMASK(&BlockSig);
17991811

1800-
elog(DEBUG4, "reaping dead processes");
1812+
ereport(DEBUG4,
1813+
(errmsg_internal("reaping dead processes")));
18011814
#ifdef HAVE_WAITPID
18021815
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
18031816
{
@@ -2007,8 +2020,10 @@ CleanupProc(int pid,
20072020
*/
20082021
if (!FatalError)
20092022
{
2010-
elog(DEBUG2, "sending %s to process %d",
2011-
(SendStop ? "SIGSTOP" : "SIGQUIT"), (int) bp->pid);
2023+
ereport(DEBUG2,
2024+
(errmsg_internal("sending %s to process %d",
2025+
(SendStop ? "SIGSTOP" : "SIGQUIT"),
2026+
(int) bp->pid)));
20122027
kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT));
20132028
}
20142029
}
@@ -2093,8 +2108,10 @@ SignalChildren(int signal)
20932108

20942109
if (bp->pid != MyProcPid)
20952110
{
2096-
elog(DEBUG2, "sending signal %d to process %d",
2097-
signal, (int) bp->pid);
2111+
ereport(DEBUG2,
2112+
(errmsg_internal("sending signal %d to process %d",
2113+
signal,
2114+
(int) bp->pid)));
20982115
kill(bp->pid, signal);
20992116
}
21002117

@@ -2207,8 +2224,9 @@ BackendStartup(Port *port)
22072224
}
22082225

22092226
/* in parent, normal */
2210-
elog(DEBUG2, "forked new backend, pid=%d socket=%d",
2211-
(int) pid, port->sock);
2227+
ereport(DEBUG2,
2228+
(errmsg_internal("forked new backend, pid=%d socket=%d",
2229+
(int) pid, port->sock)));
22122230

22132231
/*
22142232
* Everything's been successful, it's safe to add this backend to our
@@ -2525,10 +2543,14 @@ BackendFork(Port *port)
25252543
/*
25262544
* Debug: print arguments being passed to backend
25272545
*/
2528-
elog(DEBUG3, "%s child[%d]: starting with (", progname, MyProcPid);
2546+
ereport(DEBUG3,
2547+
(errmsg_internal("%s child[%d]: starting with (",
2548+
progname, MyProcPid)));
25292549
for (i = 0; i < ac; ++i)
2530-
elog(DEBUG3, "\t%s", av[i]);
2531-
elog(DEBUG3, ")");
2550+
ereport(DEBUG3,
2551+
(errmsg_internal("\t%s", av[i])));
2552+
ereport(DEBUG3,
2553+
(errmsg_internal(")")));
25322554

25332555
ClientAuthInProgress = false; /* client_min_messages is active
25342556
* now */

src/backend/tcop/postgres.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.357 2003/08/06 17:46:45 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.358 2003/08/12 18:23:21 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1730,7 +1730,8 @@ start_xact_command(void)
17301730
{
17311731
if (!xact_started)
17321732
{
1733-
elog(DEBUG3, "StartTransactionCommand");
1733+
ereport(DEBUG3,
1734+
(errmsg_internal("StartTransactionCommand")));
17341735
StartTransactionCommand();
17351736

17361737
/* Set statement timeout running, if any */
@@ -1753,7 +1754,8 @@ finish_xact_command(void)
17531754
disable_sig_alarm(true);
17541755

17551756
/* Now commit the command */
1756-
elog(DEBUG3, "CommitTransactionCommand");
1757+
ereport(DEBUG3,
1758+
(errmsg_internal("CommitTransactionCommand")));
17571759

17581760
CommitTransactionCommand();
17591761

@@ -2620,7 +2622,8 @@ PostgresMain(int argc, char *argv[], const char *username)
26202622
* putting it inside InitPostgres() instead. In particular, anything
26212623
* that involves database access should be there, not here.
26222624
*/
2623-
elog(DEBUG3, "InitPostgres");
2625+
ereport(DEBUG3,
2626+
(errmsg_internal("InitPostgres")));
26242627
InitPostgres(dbname, username);
26252628

26262629
SetProcessingMode(NormalProcessing);
@@ -2643,7 +2646,7 @@ PostgresMain(int argc, char *argv[], const char *username)
26432646
if (!IsUnderPostmaster)
26442647
{
26452648
puts("\nPOSTGRES backend interactive interface ");
2646-
puts("$Revision: 1.357 $ $Date: 2003/08/06 17:46:45 $\n");
2649+
puts("$Revision: 1.358 $ $Date: 2003/08/12 18:23:21 $\n");
26472650
}
26482651

26492652
/*
@@ -2702,7 +2705,8 @@ PostgresMain(int argc, char *argv[], const char *username)
27022705
MemoryContextSwitchTo(ErrorContext);
27032706

27042707
/* Do the recovery */
2705-
elog(DEBUG2, "AbortCurrentTransaction");
2708+
ereport(DEBUG2,
2709+
(errmsg_internal("AbortCurrentTransaction")));
27062710
AbortCurrentTransaction();
27072711

27082712
/*

src/backend/tcop/pquery.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.71 2003/08/06 17:46:46 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.72 2003/08/12 18:23:21 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -723,7 +723,8 @@ PortalRunUtility(Portal portal, Query *query,
723723
{
724724
Node *utilityStmt = query->utilityStmt;
725725

726-
elog(DEBUG3, "ProcessUtility");
726+
ereport(DEBUG3,
727+
(errmsg_internal("ProcessUtility")));
727728

728729
/*
729730
* Set snapshot if utility stmt needs one. Most reliable way to do
@@ -827,7 +828,8 @@ PortalRunMulti(Portal portal,
827828
/*
828829
* process a plannable query.
829830
*/
830-
elog(DEBUG3, "ProcessQuery");
831+
ereport(DEBUG3,
832+
(errmsg_internal("ProcessQuery")));
831833

832834
/* Must always set snapshot for plannable queries */
833835
SetQuerySnapshot();

0 commit comments

Comments
 (0)
0