Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4eb179e

Browse files
committed
libpq: Add suppress argument to pqTraceOutputNchar
In future commits we're going to trace authentication related messages.Some of these messages contain challenge bytes as part of achallenge-response flow. Since these bytes are different for everyconnection, we want to normalize them when the PQTRACE_REGRESS_MODEtrace flag is set. This commit modifies pqTraceOutputNchar to take asuppress argument, which makes it possible to do so.Author: Jelte Fennema-Nio <postgres@jeltef.nl>Discussion:https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
1 parenta90bdd7 commit4eb179e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎src/interfaces/libpq/fe-trace.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ pqTraceOutputInt32(FILE *pfdebug, const char *data, int *cursor, bool suppress)
158158

159159
/*
160160
* pqTraceOutputString: output a string message to the log
161+
*
162+
* If 'suppress' is true, print a literal "SSSS" instead of the actual string.
161163
*/
162164
staticvoid
163165
pqTraceOutputString(FILE*pfdebug,constchar*data,int*cursor,boolsuppress)
@@ -183,14 +185,23 @@ pqTraceOutputString(FILE *pfdebug, const char *data, int *cursor, bool suppress)
183185

184186
/*
185187
* pqTraceOutputNchar: output a string of exactly len bytes message to the log
188+
*
189+
* If 'suppress' is true, print a literal 'BBBB' instead of the actual bytes.
186190
*/
187191
staticvoid
188-
pqTraceOutputNchar(FILE*pfdebug,intlen,constchar*data,int*cursor)
192+
pqTraceOutputNchar(FILE*pfdebug,intlen,constchar*data,int*cursor,boolsuppress)
189193
{
190194
inti,
191195
next;/* first char not yet printed */
192196
constchar*v=data+*cursor;
193197

198+
if (suppress)
199+
{
200+
fprintf(pfdebug," 'BBBB'");
201+
*cursor+=len;
202+
return;
203+
}
204+
194205
fprintf(pfdebug," \'");
195206

196207
for (next=i=0;i<len;++i)
@@ -246,7 +257,7 @@ pqTraceOutput_Bind(FILE *f, const char *message, int *cursor)
246257
nbytes=pqTraceOutputInt32(f,message,cursor, false);
247258
if (nbytes==-1)
248259
continue;
249-
pqTraceOutputNchar(f,nbytes,message,cursor);
260+
pqTraceOutputNchar(f,nbytes,message,cursor, false);
250261
}
251262

252263
nparams=pqTraceOutputInt16(f,message,cursor);
@@ -283,7 +294,7 @@ pqTraceOutput_DataRow(FILE *f, const char *message, int *cursor)
283294
len=pqTraceOutputInt32(f,message,cursor, false);
284295
if (len==-1)
285296
continue;
286-
pqTraceOutputNchar(f,len,message,cursor);
297+
pqTraceOutputNchar(f,len,message,cursor, false);
287298
}
288299
}
289300

@@ -363,7 +374,7 @@ pqTraceOutput_FunctionCall(FILE *f, const char *message, int *cursor, bool regre
363374
nbytes=pqTraceOutputInt32(f,message,cursor, false);
364375
if (nbytes==-1)
365376
continue;
366-
pqTraceOutputNchar(f,nbytes,message,cursor);
377+
pqTraceOutputNchar(f,nbytes,message,cursor, false);
367378
}
368379

369380
pqTraceOutputInt16(f,message,cursor);
@@ -487,7 +498,7 @@ pqTraceOutput_FunctionCallResponse(FILE *f, const char *message, int *cursor)
487498
fprintf(f,"FunctionCallResponse\t");
488499
len=pqTraceOutputInt32(f,message,cursor, false);
489500
if (len!=-1)
490-
pqTraceOutputNchar(f,len,message,cursor);
501+
pqTraceOutputNchar(f,len,message,cursor, false);
491502
}
492503

493504
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp