Hi all, 2f52518 has removed a couple of extra newlines not needed as PQerrorMessage is used, but some places have been missed: - testlo64.c - testlo.c - findoidjoins.c Those are not really critical, still I think that it would be good practice to be consistent.
pgbench uses at one place CommandFailed() which appends automatically a newline for the message passed by the caller, and calls one PQerrorMessage. Perhaps CommandFailed()'s callers should just define a newline in the message? Or it could be better to have a version of pchomp for frontends? Thanks, -- Michael
diff --git a/src/test/examples/testlo.c b/src/test/examples/testlo.c
index be5c72b9a6..92a45fb137 100644
--- a/src/test/examples/testlo.c
+++ b/src/test/examples/testlo.c
@@ -249,7 +249,7 @@ main(int argc, char **argv)
/* lobjOid = importFile(conn, in_filename); */
lobjOid = lo_import(conn, in_filename);
if (lobjOid == 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
else
{
printf("\tas large object %u.\n", lobjOid);
@@ -263,7 +263,7 @@ main(int argc, char **argv)
printf("exporting large object to file \"%s\" ...\n", out_filename);
/* exportFile(conn, lobjOid, out_filename); */
if (lo_export(conn, lobjOid, out_filename) < 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
}
res = PQexec(conn, "end");
diff --git a/src/test/examples/testlo64.c b/src/test/examples/testlo64.c
index 39ba009c52..a9d7c30cd5 100644
--- a/src/test/examples/testlo64.c
+++ b/src/test/examples/testlo64.c
@@ -273,7 +273,7 @@ main(int argc, char **argv)
/* lobjOid = importFile(conn, in_filename); */
lobjOid = lo_import(conn, in_filename);
if (lobjOid == 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
else
{
printf("\tas large object %u.\n", lobjOid);
@@ -287,14 +287,14 @@ main(int argc, char **argv)
printf("exporting large object to file \"%s\" ...\n", out_filename);
/* exportFile(conn, lobjOid, out_filename); */
if (lo_export(conn, lobjOid, out_filename) < 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
printf("truncating to 3294968000 bytes\n");
my_truncate(conn, lobjOid, 3294968000U);
printf("exporting truncated large object to file \"%s\" ...\n", out_filename2);
if (lo_export(conn, lobjOid, out_filename2) < 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
}
res = PQexec(conn, "end");
diff --git a/src/tools/findoidjoins/findoidjoins.c b/src/tools/findoidjoins/findoidjoins.c
index cbb7b59adc..d3d87e9556 100644
--- a/src/tools/findoidjoins/findoidjoins.c
+++ b/src/tools/findoidjoins/findoidjoins.c
@@ -43,14 +43,14 @@ main(int argc, char **argv)
conn = PQconnectdb(sql.data);
if (PQstatus(conn) == CONNECTION_BAD)
{
- fprintf(stderr, "connection error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "connection error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
res = PQexec(conn, ALWAYS_SECURE_SEARCH_PATH_SQL);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
PQclear(res);
@@ -70,7 +70,7 @@ main(int argc, char **argv)
res = PQexec(conn, sql.data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
pkrel_res = res;
@@ -100,7 +100,7 @@ main(int argc, char **argv)
res = PQexec(conn, sql.data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
fkrel_res = res;
@@ -134,7 +134,7 @@ main(int argc, char **argv)
res = PQexec(conn, sql.data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
@@ -176,7 +176,7 @@ main(int argc, char **argv)
res = PQexec(conn, sql.data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
fkrel_res = res;
@@ -210,7 +210,7 @@ main(int argc, char **argv)
res = PQexec(conn, sql.data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "sql error: %s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
signature.asc
Description: PGP signature
