From 8ac386226d76b29a9f54c26b157e04e9b8368606 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Thu, 13 Oct 2005 20:58:42 +0000
Subject: [PATCH] The patch updates the documentation to reflect the fact that
 higher values of client_min_messages (fatal + panic) are valid and also fixes
 a slight issue with how psql tried to display error messages that aren't sent
 to the client.

We often tell people to ignore errors in response to requests for things
like "drop if exists", but there's no good way to completely hide this
without upping client_min_messages past ERROR.  When running a file like

SET client_min_messages TO 'FATAL';

DROP TABLE doesntexist;

with "psql -f filename" you get an error prefix of
"psql:/home/username/filename:3" even though there is no error message to
prefix because it isn't sent to the client.

Kris Jurka
---
 doc/src/sgml/config.sgml | 5 +++--
 src/bin/psql/common.c    | 7 +++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 5da06fddce3..b64ba6c1561 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.26 2005/10/13 17:32:42 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.27 2005/10/13 20:58:42 momjian Exp $
 -->
 <chapter Id="runtime-config">
   <title>Run-time Configuration</title>
@@ -2295,7 +2295,8 @@ SELECT * FROM parent WHERE key = 2400;
         Valid values are <literal>DEBUG5</>,
         <literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
         <literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
-        <literal>WARNING</>, and <literal>ERROR</>.  Each level
+        <literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
+        and <literal>PANIC</>.  Each level
         includes all the levels that follow it.  The later the level,
         the fewer messages are sent.  The default is
         <literal>NOTICE</>.  Note that <literal>LOG</> has a different
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 9b087adf010..886bcde1786 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.106 2005/10/04 19:01:18 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.107 2005/10/13 20:58:42 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "common.h"
@@ -681,7 +681,10 @@ AcceptResult(const PGresult *result, const char *query)
 
 	if (!OK)
 	{
-		psql_error("%s", PQerrorMessage(pset.db));
+		const char *error = PQerrorMessage(pset.db);
+		if (strlen(error))
+			psql_error("%s", error);
+
 		ReportSyntaxErrorPosition(result, query);
 		CheckConnection();
 	}
-- 
GitLab