mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Add backend-only appendStringInfoStringQuoted
This provides a mechanism to emit literal values in informative messages, such as query parameters. The new code is more complex than what it replaces, primarily because it wants to be more efficient. It also has the (currently unused) additional optional capability of specifying a maximum size to print. The new function lives out of common/stringinfo.c so that frontend users of that file need not pull in unnecessary multibyte-encoding support code. Author: Álvaro Herrera and Alexey Bashtanov, after a suggestion from Andres Freund Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20190920203905.xkv5udsd5dxfs6tr@alap3.anarazel.de
This commit is contained in:
@ -48,6 +48,7 @@
|
||||
#include "libpq/pqformat.h"
|
||||
#include "libpq/pqsignal.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "mb/stringinfo_mb.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/print.h"
|
||||
#include "optimizer/optimizer.h"
|
||||
@ -2348,7 +2349,6 @@ errdetail_params(ParamListInfo params)
|
||||
Oid typoutput;
|
||||
bool typisvarlena;
|
||||
char *pstring;
|
||||
char *p;
|
||||
|
||||
appendStringInfo(¶m_str, "%s$%d = ",
|
||||
paramno > 0 ? ", " : "",
|
||||
@ -2364,14 +2364,7 @@ errdetail_params(ParamListInfo params)
|
||||
|
||||
pstring = OidOutputFunctionCall(typoutput, prm->value);
|
||||
|
||||
appendStringInfoCharMacro(¶m_str, '\'');
|
||||
for (p = pstring; *p; p++)
|
||||
{
|
||||
if (*p == '\'') /* double single quotes */
|
||||
appendStringInfoCharMacro(¶m_str, *p);
|
||||
appendStringInfoCharMacro(¶m_str, *p);
|
||||
}
|
||||
appendStringInfoCharMacro(¶m_str, '\'');
|
||||
appendStringInfoStringQuoted(¶m_str, pstring, 0);
|
||||
|
||||
pfree(pstring);
|
||||
}
|
||||
|
Reference in New Issue
Block a user