elog vs errmsg_internal

Started by Peter Eisentrautover 8 years ago3 messages
#1Peter Eisentraut
peter.eisentraut@2ndquadrant.com
1 attachment(s)

Is there a preferred method to select between using elog() and
errmsg_internal()?

Attached is a patch that converts some DEBUG messages to one of those
two to remove them from translation, but I'm not sure which one to pick
other than by random aesthetics.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Remove-DEBUG-messages-from-translation.patchtext/plain; charset=UTF-8; name=0001-Remove-DEBUG-messages-from-translation.patch; x-mac-creator=0; x-mac-type=0Download
From 52f9f20d4141f8537da1a012a7ab99207a92e016 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 2 May 2017 21:49:48 -0400
Subject: [PATCH] Remove DEBUG messages from translation

---
 contrib/amcheck/verify_nbtree.c            | 12 ++++++------
 src/backend/access/transam/multixact.c     | 10 +++++-----
 src/backend/access/transam/slru.c          |  6 ++----
 src/backend/access/transam/varsup.c        |  2 +-
 src/backend/access/transam/xlog.c          | 28 ++++++++++++++--------------
 src/backend/catalog/dependency.c           |  2 +-
 src/backend/catalog/index.c                |  5 ++---
 src/backend/commands/indexcmds.c           |  8 ++++----
 src/backend/commands/tablecmds.c           |  6 +++---
 src/backend/libpq/be-secure-openssl.c      |  2 +-
 src/backend/parser/parse_utilcmd.c         |  2 +-
 src/backend/postmaster/autovacuum.c        |  9 +++------
 src/backend/postmaster/bgworker.c          | 13 +++++--------
 src/backend/postmaster/checkpointer.c      |  5 ++---
 src/backend/postmaster/postmaster.c        |  2 +-
 src/backend/postmaster/syslogger.c         |  3 +--
 src/backend/replication/logical/launcher.c |  3 +--
 src/backend/replication/logical/worker.c   |  8 ++++----
 src/backend/replication/syncrep.c          |  4 ++--
 src/backend/replication/walsender.c        |  4 ++--
 src/backend/storage/lmgr/predicate.c       |  2 +-
 src/backend/storage/lmgr/proc.c            |  4 ++--
 src/backend/storage/smgr/md.c              |  6 +++---
 src/backend/tcop/postgres.c                |  6 +++---
 src/backend/utils/init/miscinit.c          |  3 +--
 25 files changed, 71 insertions(+), 84 deletions(-)

diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index 9ae83dc839..ef5fc947ce 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -315,7 +315,7 @@ bt_check_every_level(Relation rel, bool readonly)
 	if (metad->btm_fastroot != metad->btm_root)
 		ereport(DEBUG1,
 				(errcode(ERRCODE_NO_DATA),
-				 errmsg("harmless fast root mismatch in index %s",
+				 errmsg_internal("harmless fast root mismatch in index %s",
 						RelationGetRelationName(rel)),
 				 errdetail_internal("Fast root block %u (level %u) differs from true root block %u (level %u).",
 									metad->btm_fastroot, metad->btm_fastlevel,
@@ -415,8 +415,8 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
 			else
 				ereport(DEBUG1,
 						(errcode(ERRCODE_NO_DATA),
-						 errmsg("block %u of index \"%s\" ignored",
-								current, RelationGetRelationName(state->rel))));
+						 errmsg_internal("block %u of index \"%s\" ignored",
+										 current, RelationGetRelationName(state->rel))));
 			goto nextpage;
 		}
 		else if (nextleveldown.leftmost == InvalidBlockNumber)
@@ -823,8 +823,8 @@ bt_right_page_check_scankey(BtreeCheckState *state)
 		targetnext = opaque->btpo_next;
 		ereport(DEBUG1,
 				(errcode(ERRCODE_NO_DATA),
-				 errmsg("level %u leftmost page of index \"%s\" was found deleted or half dead",
-						opaque->btpo.level, RelationGetRelationName(state->rel)),
+				 errmsg_internal("level %u leftmost page of index \"%s\" was found deleted or half dead",
+								 opaque->btpo.level, RelationGetRelationName(state->rel)),
 				 errdetail_internal("Deleted page found when building scankey from right sibling.")));
 
 		/* Be slightly more pro-active in freeing this memory, just in case */
@@ -950,7 +950,7 @@ bt_right_page_check_scankey(BtreeCheckState *state)
 		 */
 		ereport(DEBUG1,
 				(errcode(ERRCODE_NO_DATA),
-				 errmsg("%s block %u of index \"%s\" has no first data item",
+				 errmsg_internal("%s block %u of index \"%s\" has no first data item",
 						P_ISLEAF(opaque) ? "leaf" : "internal", targetnext,
 						RelationGetRelationName(state->rel))));
 		return NULL;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 682eef420b..3630a8f68c 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2265,8 +2265,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
 
 	/* Log the info */
 	ereport(DEBUG1,
-			(errmsg("MultiXactId wrap limit is %u, limited by database with OID %u",
-					multiWrapLimit, oldest_datoid)));
+			(errmsg_internal("MultiXactId wrap limit is %u, limited by database with OID %u",
+							 multiWrapLimit, oldest_datoid)));
 
 	/*
 	 * Computing the actual limits is only possible once the data directory is
@@ -2599,7 +2599,7 @@ SetOffsetVacuumLimit(bool is_startup)
 
 		if (oldestOffsetKnown)
 			ereport(DEBUG1,
-					(errmsg("oldest MultiXactId member is at offset %u",
+					(errmsg_internal("oldest MultiXactId member is at offset %u",
 							oldestOffset)));
 		else
 			ereport(LOG,
@@ -2628,8 +2628,8 @@ SetOffsetVacuumLimit(bool is_startup)
 					(errmsg("MultiXact member wraparound protections are now enabled")));
 
 		ereport(DEBUG1,
-				(errmsg("MultiXact member stop limit is now %u based on MultiXact %u",
-						offsetStopLimit, oldestMultiXactId)));
+				(errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
+								 offsetStopLimit, oldestMultiXactId)));
 	}
 	else if (prevOldestOffsetKnown)
 	{
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index d037c369a7..3287ef4d81 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -1250,8 +1250,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, char *filename)
 	char		path[MAXPGPATH];
 
 	snprintf(path, MAXPGPATH, "%s/%s", ctl->Dir, filename);
-	ereport(DEBUG2,
-			(errmsg("removing file \"%s\"", path)));
+	elog(DEBUG2, "removing file \"%s\"", path);
 	unlink(path);
 }
 
@@ -1306,8 +1305,7 @@ SlruDeleteSegment(SlruCtl ctl, int segno)
 		goto restart;
 
 	snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, segno);
-	ereport(DEBUG2,
-			(errmsg("removing file \"%s\"", path)));
+	elog(DEBUG2, "removing file \"%s\"", path);
 	unlink(path);
 
 	LWLockRelease(shared->ControlLock);
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 15e05591b7..02c4194999 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -364,7 +364,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
 
 	/* Log the info */
 	ereport(DEBUG1,
-			(errmsg("transaction ID wrap limit is %u, limited by database with OID %u",
+			(errmsg_internal("transaction ID wrap limit is %u, limited by database with OID %u",
 					xidWrapLimit, oldest_datoid)));
 
 	/*
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3654543919..1f4405541f 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2738,10 +2738,10 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
 			minRecoveryPointTLI = newMinRecoveryPointTLI;
 
 			ereport(DEBUG2,
-					(errmsg("updated min recovery point to %X/%X on timeline %u",
-							(uint32) (minRecoveryPoint >> 32),
-							(uint32) minRecoveryPoint,
-							newMinRecoveryPointTLI)));
+					(errmsg_internal("updated min recovery point to %X/%X on timeline %u",
+									 (uint32) (minRecoveryPoint >> 32),
+									 (uint32) minRecoveryPoint,
+									 newMinRecoveryPointTLI)));
 		}
 	}
 	LWLockRelease(ControlFileLock);
@@ -3993,7 +3993,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
 							   true, recycleSegNo, true))
 	{
 		ereport(DEBUG2,
-				(errmsg("recycled write-ahead log file \"%s\"",
+				(errmsg_internal("recycled write-ahead log file \"%s\"",
 						segname)));
 		CheckpointStats.ckpt_segs_recycled++;
 		/* Needn't recheck that slot on future iterations */
@@ -4005,7 +4005,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
 		int			rc;
 
 		ereport(DEBUG2,
-				(errmsg("removing write-ahead log file \"%s\"",
+				(errmsg_internal("removing write-ahead log file \"%s\"",
 						segname)));
 
 #ifdef WIN32
@@ -6387,8 +6387,8 @@ StartupXLOG(void)
 			memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
 			wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
 			ereport(DEBUG1,
-					(errmsg("checkpoint record is at %X/%X",
-							(uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));
+					(errmsg_internal("checkpoint record is at %X/%X",
+									 (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));
 			InRecovery = true;	/* force recovery even if SHUTDOWNED */
 
 			/*
@@ -6515,8 +6515,8 @@ StartupXLOG(void)
 		if (record != NULL)
 		{
 			ereport(DEBUG1,
-					(errmsg("checkpoint record is at %X/%X",
-							(uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));
+					(errmsg_internal("checkpoint record is at %X/%X",
+									 (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));
 		}
 		else if (StandbyMode)
 		{
@@ -6883,7 +6883,7 @@ StartupXLOG(void)
 			int			nxids;
 
 			ereport(DEBUG1,
-					(errmsg("initializing for hot standby")));
+					(errmsg_internal("initializing for hot standby")));
 
 			InitRecoveryTransactionEnvironment();
 
@@ -8646,7 +8646,7 @@ CreateCheckPoint(int flags)
 			LWLockRelease(CheckpointLock);
 			END_CRIT_SECTION();
 			ereport(DEBUG1,
-					(errmsg("checkpoint skipped due to an idle system")));
+					(errmsg_internal("checkpoint skipped due to an idle system")));
 			return;
 		}
 	}
@@ -9105,7 +9105,7 @@ CreateRestartPoint(int flags)
 	if (!RecoveryInProgress())
 	{
 		ereport(DEBUG2,
-				(errmsg("skipping restartpoint, recovery has already ended")));
+				(errmsg_internal("skipping restartpoint, recovery has already ended")));
 		LWLockRelease(CheckpointLock);
 		return false;
 	}
@@ -9128,7 +9128,7 @@ CreateRestartPoint(int flags)
 		lastCheckPoint.redo <= ControlFile->checkPointCopy.redo)
 	{
 		ereport(DEBUG2,
-				(errmsg("skipping restartpoint, already performed at %X/%X",
+				(errmsg_internal("skipping restartpoint, already performed at %X/%X",
 						(uint32) (lastCheckPoint.redo >> 32),
 						(uint32) lastCheckPoint.redo)));
 
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 6fffc290fa..087dcd5892 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -894,7 +894,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
 			 * log_min_messages are different.
 			 */
 			ereport(DEBUG2,
-					(errmsg("drop auto-cascades to %s",
+					(errmsg_internal("drop auto-cascades to %s",
 							objDesc)));
 		}
 		else if (behavior == DROP_RESTRICT)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index d25b39bb54..86d08bfe1a 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2020,10 +2020,9 @@ index_build(Relation heapRelation,
 	Assert(PointerIsValid(indexRelation->rd_amroutine->ambuild));
 	Assert(PointerIsValid(indexRelation->rd_amroutine->ambuildempty));
 
-	ereport(DEBUG1,
-			(errmsg("building index \"%s\" on table \"%s\"",
+	elog(DEBUG1, "building index \"%s\" on table \"%s\"",
 					RelationGetRelationName(indexRelation),
-					RelationGetRelationName(heapRelation))));
+					RelationGetRelationName(heapRelation));
 
 	/*
 	 * Switch to the table owner's userid, so that any index functions are run
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 620704ec49..1bb726596c 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -649,10 +649,10 @@ DefineIndex(Oid relationId,
 		}
 
 		ereport(DEBUG1,
-				(errmsg("%s %s will create implicit index \"%s\" for table \"%s\"",
-						is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /",
-						constraint_type,
-						indexRelationName, RelationGetRelationName(rel))));
+				(errmsg_internal("%s %s will create implicit index \"%s\" for table \"%s\"",
+								 is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /",
+								 constraint_type,
+								 indexRelationName, RelationGetRelationName(rel))));
 	}
 
 	/*
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7859ef13ac..ee1781febe 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4436,11 +4436,11 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
 
 		if (newrel)
 			ereport(DEBUG1,
-					(errmsg("rewriting table \"%s\"",
+					(errmsg_internal("rewriting table \"%s\"",
 							RelationGetRelationName(oldrel))));
 		else
 			ereport(DEBUG1,
-					(errmsg("verifying table \"%s\"",
+					(errmsg_internal("verifying table \"%s\"",
 							RelationGetRelationName(oldrel))));
 
 		if (newrel)
@@ -8180,7 +8180,7 @@ validateForeignKeyConstraint(char *conname,
 	Snapshot	snapshot;
 
 	ereport(DEBUG1,
-			(errmsg("validating foreign key constraint \"%s\"", conname)));
+			(errmsg_internal("validating foreign key constraint \"%s\"", conname)));
 
 	/*
 	 * Build a trigger call structure; we'll need it either way.
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index 694f76afa6..a2fd64dda1 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -578,7 +578,7 @@ be_tls_open_server(Port *port)
 	}
 
 	ereport(DEBUG2,
-			(errmsg("SSL connection from \"%s\"",
+			(errmsg_internal("SSL connection from \"%s\"",
 					port->peer_cn ? port->peer_cn : "(anonymous)")));
 
 	/* set up debugging/info callback */
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 87cb4188a3..1be13efff7 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -432,7 +432,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
 	}
 
 	ereport(DEBUG1,
-			(errmsg("%s will create implicit sequence \"%s\" for serial column \"%s.%s\"",
+			(errmsg_internal("%s will create implicit sequence \"%s\" for serial column \"%s.%s\"",
 					cxt->stmtType, sname,
 					cxt->relation->relname, column->colname)));
 
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 00b1e823af..45b3d0c560 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -448,8 +448,7 @@ AutoVacLauncherMain(int argc, char *argv[])
 	/* Identify myself via ps */
 	init_ps_display("autovacuum launcher process", "", "", "");
 
-	ereport(DEBUG1,
-			(errmsg("autovacuum launcher started")));
+	elog(DEBUG1, "autovacuum launcher started");
 
 	if (PostAuthDelay)
 		pg_usleep(PostAuthDelay * 1000000L);
@@ -835,8 +834,7 @@ AutoVacLauncherMain(int argc, char *argv[])
 
 	/* Normal exit from the autovac launcher is here */
 shutdown:
-	ereport(DEBUG1,
-			(errmsg("autovacuum launcher shutting down")));
+	elog(DEBUG1, "autovacuum launcher shutting down");
 	AutoVacuumShmem->av_launcherpid = 0;
 
 	proc_exit(0);				/* done */
@@ -1703,8 +1701,7 @@ AutoVacWorkerMain(int argc, char *argv[])
 		InitPostgres(NULL, dbid, NULL, InvalidOid, dbname);
 		SetProcessingMode(NormalProcessing);
 		set_ps_display(dbname, false);
-		ereport(DEBUG1,
-				(errmsg("autovacuum: processing database \"%s\"", dbname)));
+		elog(DEBUG1, "autovacuum: processing database \"%s\"", dbname);
 
 		if (PostAuthDelay)
 			pg_usleep(PostAuthDelay * 1000000L);
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 28af6f0f07..3617436e50 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -389,9 +389,8 @@ BackgroundWorkerStateChange(void)
 		rw->rw_terminate = false;
 
 		/* Log it! */
-		ereport(DEBUG1,
-				(errmsg("registering background worker \"%s\"",
-						rw->rw_worker.bgw_name)));
+		elog(DEBUG1, "registering background worker \"%s\"",
+						rw->rw_worker.bgw_name);
 
 		slist_push_head(&BackgroundWorkerList, &rw->rw_lnode);
 	}
@@ -421,9 +420,8 @@ ForgetBackgroundWorker(slist_mutable_iter *cur)
 
 	slot->in_use = false;
 
-	ereport(DEBUG1,
-			(errmsg("unregistering background worker \"%s\"",
-					rw->rw_worker.bgw_name)));
+	elog(DEBUG1, "unregistering background worker \"%s\"",
+					rw->rw_worker.bgw_name);
 
 	slist_delete_current(cur);
 	free(rw);
@@ -852,8 +850,7 @@ RegisterBackgroundWorker(BackgroundWorker *worker)
 	static int	numworkers = 0;
 
 	if (!IsUnderPostmaster)
-		ereport(DEBUG1,
-				(errmsg("registering background worker \"%s\"", worker->bgw_name)));
+		elog(DEBUG1, "registering background worker \"%s\"", worker->bgw_name);
 
 	if (!process_shared_preload_libraries_in_progress &&
 		strcmp(worker->bgw_library_name, "postgres") != 0)
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index e48ebd557f..492af4582a 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -1279,9 +1279,8 @@ CompactCheckpointerRequestQueue(void)
 			continue;
 		CheckpointerShmem->requests[preserve_count++] = CheckpointerShmem->requests[n];
 	}
-	ereport(DEBUG1,
-			(errmsg("compacted fsync request queue from %d entries to %d entries",
-					CheckpointerShmem->num_requests, preserve_count)));
+	elog(DEBUG1, "compacted fsync request queue from %d entries to %d entries",
+		 CheckpointerShmem->num_requests, preserve_count);
 	CheckpointerShmem->num_requests = preserve_count;
 
 	/* Cleanup. */
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 95180b2ef5..e585103325 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -5634,7 +5634,7 @@ do_start_bgworker(RegisteredBgWorker *rw)
 	}
 
 	ereport(DEBUG1,
-			(errmsg("starting background worker process \"%s\"",
+			(errmsg_internal("starting background worker process \"%s\"",
 					rw->rw_worker.bgw_name)));
 
 #ifdef EXEC_BACKEND
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 3255b42c7d..0e2c1dd412 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -498,8 +498,7 @@ SysLoggerMain(int argc, char *argv[])
 			 * seeing this message on the real stderr is annoying - so we make
 			 * it DEBUG1 to suppress in normal use.
 			 */
-			ereport(DEBUG1,
-					(errmsg("logger shutting down")));
+			elog(DEBUG1, "logger shutting down");
 
 			/*
 			 * Normal exit from the syslogger is here.  Note that we
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index d165d518e1..7ae5effcbf 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -794,8 +794,7 @@ ApplyLauncherMain(Datum main_arg)
 {
 	TimestampTz last_start_time = 0;
 
-	ereport(DEBUG1,
-			(errmsg("logical replication launcher started")));
+	elog(DEBUG1, "logical replication launcher started");
 
 	before_shmem_exit(logicalrep_launcher_onexit, (Datum) 0);
 
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 0d48dfa494..42f0365c30 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -841,10 +841,10 @@ apply_handle_delete(StringInfo s)
 	else
 	{
 		/* The tuple to be deleted could not be found. */
-		ereport(DEBUG1,
-				(errmsg("logical replication could not find row for delete "
-						"in replication target %s",
-						RelationGetRelationName(rel->localrel))));
+		elog(DEBUG1,
+			 "logical replication could not find row for delete "
+			 "in replication target %s",
+			 RelationGetRelationName(rel->localrel));
 	}
 
 	/* Cleanup. */
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index 77e80f1612..765b3863fd 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -396,8 +396,8 @@ SyncRepInitConfig(void)
 		MyWalSnd->sync_standby_priority = priority;
 		LWLockRelease(SyncRepLock);
 		ereport(DEBUG1,
-				(errmsg("standby \"%s\" now has synchronous standby priority %u",
-						application_name, priority)));
+				(errmsg_internal("standby \"%s\" now has synchronous standby priority %u",
+								 application_name, priority)));
 	}
 }
 
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 9a2babef1e..dabddbb5fe 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2153,8 +2153,8 @@ WalSndLoop(WalSndSendDataCallback send_data)
 			if (MyWalSnd->state == WALSNDSTATE_CATCHUP)
 			{
 				ereport(DEBUG1,
-						(errmsg("standby \"%s\" has now caught up with primary",
-								application_name)));
+						(errmsg_internal("standby \"%s\" has now caught up with primary",
+										 application_name)));
 				WalSndSetState(WALSNDSTATE_STREAMING);
 			}
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 74e4b35837..0b8ba55b20 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -1556,7 +1556,7 @@ GetSafeSnapshot(Snapshot origSnapshot)
 		/* else, need to retry... */
 		ereport(DEBUG2,
 				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
-				 errmsg("deferrable snapshot was unsafe; trying a new one")));
+				 errmsg_internal("deferrable snapshot was unsafe; trying a new one")));
 		ReleasePredicateLocks(false);
 	}
 
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index bfa84992ea..07257a2766 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -1308,8 +1308,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
 
 				/* send the autovacuum worker Back to Old Kent Road */
 				ereport(DEBUG1,
-						(errmsg("sending cancel to blocking autovacuum PID %d",
-								pid),
+						(errmsg_internal("sending cancel to blocking autovacuum PID %d",
+										 pid),
 						 errdetail_log("%s", logbuf.data)));
 
 				if (kill(pid, SIGINT) < 0)
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 65e0abe9ec..3f6b05cb45 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -1279,8 +1279,8 @@ mdsync(void)
 					else
 						ereport(DEBUG1,
 								(errcode_for_file_access(),
-								 errmsg("could not fsync file \"%s\" but retrying: %m",
-										path)));
+								 errmsg_internal("could not fsync file \"%s\" but retrying: %m",
+												 path)));
 					pfree(path);
 
 					/*
@@ -1442,7 +1442,7 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
 			return;				/* passed it off successfully */
 
 		ereport(DEBUG1,
-				(errmsg("could not forward fsync request because request queue is full")));
+				(errmsg_internal("could not forward fsync request because request queue is full")));
 
 		if (FileSync(seg->mdfd_vfd, WAIT_EVENT_DATA_FILE_SYNC) < 0)
 			ereport(ERROR,
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index b8d860ebdb..87d07c670b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -343,7 +343,7 @@ SocketBackend(StringInfo inBuf)
 			whereToSendOutput = DestNone;
 			ereport(DEBUG1,
 					(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
-					 errmsg("unexpected EOF on client connection")));
+					 errmsg_internal("unexpected EOF on client connection")));
 		}
 		return qtype;
 	}
@@ -379,7 +379,7 @@ SocketBackend(StringInfo inBuf)
 						whereToSendOutput = DestNone;
 						ereport(DEBUG1,
 								(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
-								 errmsg("unexpected EOF on client connection")));
+								 errmsg_internal("unexpected EOF on client connection")));
 					}
 					return EOF;
 				}
@@ -406,7 +406,7 @@ SocketBackend(StringInfo inBuf)
 						whereToSendOutput = DestNone;
 						ereport(DEBUG1,
 								(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
-								 errmsg("unexpected EOF on client connection")));
+								 errmsg_internal("unexpected EOF on client connection")));
 					}
 					return EOF;
 				}
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index afbf8f8691..811940d341 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -1470,8 +1470,7 @@ load_libraries(const char *libraries, const char *gucname, bool restricted)
 			filename = expanded;
 		}
 		load_file(filename, restricted);
-		ereport(DEBUG1,
-				(errmsg("loaded library \"%s\"", filename)));
+		elog(DEBUG1, "loaded library \"%s\"", filename);
 		if (expanded)
 			pfree(expanded);
 	}
-- 
2.13.3

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Peter Eisentraut (#1)
Re: elog vs errmsg_internal

Peter Eisentraut wrote:

Is there a preferred method to select between using elog() and
errmsg_internal()?

Attached is a patch that converts some DEBUG messages to one of those
two to remove them from translation, but I'm not sure which one to pick
other than by random aesthetics.

I think the contrib changes are probably not useful, since contrib is
not a target for nls anyway.

I'm not sure that all DEBUG messages should stay untranslated. If main
log messages (i.e. NOTICE/LOG and above) are translated, why not debug?
For example the ones in index.c and indexcmds.c. I agree that many of
these debugs are useless when translated, but not all. Clearly, it's a
judgement call which ones to mark for translation.

Some other random thoughts in the same area:

* I think translated messages in the server log are mostly an
operational failure. I think we should default to C, perhaps offer
translation as an option that's not enabled by default. Of course,
messages sent to client should be translated just like currently.

* Much worse is the fact that we send messages to the log in the
database encoding. This means that having a server log mixing lines
from databases with different encodings is a failure; it's just not
possible to read the log at all. A simple fix would be to transliterate
all messages to some common encoding (UTF8) so that at the log
file can at least be opened. Another fix would be to have multiple log
files, one per encoding; or maybe go for one per database. Neither of
these proposals seem particularly great. Simply keeping the server log
in C locale would fix this problem too.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: elog vs errmsg_internal

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

Is there a preferred method to select between using elog() and
errmsg_internal()?

ereport(... errmsg_internal() ...) can be a win for debug messages that
are in hot code paths, because the test for whether the message will
get printed is able to short-circuit more work. In particular,
if you have moderately expensive functions like syscache lookups in
the argument list of elog(), I believe those functions get evaluated
even if we end up not printing anything. ereport() skips the
arg-list evaluation in such cases.

But if that doesn't seem very relevant, I'd tend to go for elog()
just because it's less typing.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers