mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
chomp PQerrorMessage() in backend uses
PQerrorMessage() returns an error message with a trailing newline, but in backend use (dblink, postgres_fdw, libpqwalreceiver), we want to have the error message without that for emitting via ereport(). To simplify that, add a function pchomp() that returns a pstrdup'ed string with the trailing newline characters removed.
This commit is contained in:
@@ -1181,3 +1181,17 @@ pnstrdup(const char *in, Size len)
|
||||
out[len] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make copy of string with all trailing newline characters removed.
|
||||
*/
|
||||
char *
|
||||
pchomp(const char *in)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
n = strlen(in);
|
||||
while (n > 0 && in[n - 1] == '\n')
|
||||
n--;
|
||||
return pnstrdup(in, n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user