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

Commit7adec2d

Browse files
committed
libpq: Trace StartupMessage/SSLRequest/GSSENCRequest correctly
libpq tracing via PQtrace would uselessly print the wrong thing forthese types of messages. With this commit, their type and contentswould be correctly listed. (This can be verified with PQconnectStart(),but we don't use that in libpq_pipeline, so I (Álvaro) haven't botheredto add any tests.)Author: Jelte Fennema-Nio <postgres@jeltef.nl>Discussion:https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
1 parenta79ed10 commit7adec2d

File tree

1 file changed

+43
-12
lines changed

1 file changed

+43
-12
lines changed

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

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,12 @@ void
707707
pqTraceOutputNoTypeByteMessage(PGconn*conn,constchar*message)
708708
{
709709
intlength;
710+
intversion;
711+
boolregress;
710712
intlogCursor=0;
711713

714+
regress= (conn->traceFlags&PQTRACE_REGRESS_MODE)!=0;
715+
712716
if ((conn->traceFlags&PQTRACE_SUPPRESS_TIMESTAMPS)==0)
713717
{
714718
chartimestr[128];
@@ -723,19 +727,46 @@ pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
723727

724728
fprintf(conn->Pfdebug,"F\t%d\t",length);
725729

726-
switch (length)
730+
if (length<8)
727731
{
728-
case16:/* CancelRequest */
729-
fprintf(conn->Pfdebug,"CancelRequest\t");
730-
pqTraceOutputInt32(conn->Pfdebug,message,&logCursor, false);
731-
pqTraceOutputInt32(conn->Pfdebug,message,&logCursor, false);
732-
pqTraceOutputInt32(conn->Pfdebug,message,&logCursor, false);
733-
break;
734-
case8:/* GSSENCRequest or SSLRequest */
735-
/* These messages do not reach here. */
736-
default:
737-
fprintf(conn->Pfdebug,"Unknown message: length is %d",length);
738-
break;
732+
fprintf(conn->Pfdebug,"Unknown message\n");
733+
return;
734+
}
735+
736+
memcpy(&version,message+logCursor,4);
737+
version= (int)pg_ntoh32(version);
738+
739+
if (version==CANCEL_REQUEST_CODE&&length >=16)
740+
{
741+
fprintf(conn->Pfdebug,"CancelRequest\t");
742+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
743+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
744+
pqTraceOutputInt32(conn->Pfdebug,message,&logCursor,regress);
745+
pqTraceOutputInt32(conn->Pfdebug,message,&logCursor,regress);
746+
}
747+
elseif (version==NEGOTIATE_SSL_CODE)
748+
{
749+
fprintf(conn->Pfdebug,"SSLRequest\t");
750+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
751+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
752+
}
753+
elseif (version==NEGOTIATE_GSS_CODE)
754+
{
755+
fprintf(conn->Pfdebug,"GSSENCRequest\t");
756+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
757+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
758+
}
759+
else
760+
{
761+
fprintf(conn->Pfdebug,"StartupMessage\t");
762+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
763+
pqTraceOutputInt16(conn->Pfdebug,message,&logCursor);
764+
while (message[logCursor]!='\0')
765+
{
766+
/* XXX should we suppress anything in regress mode? */
767+
pqTraceOutputString(conn->Pfdebug,message,&logCursor, false);
768+
pqTraceOutputString(conn->Pfdebug,message,&logCursor, false);
769+
}
739770
}
740771

741772
fputc('\n',conn->Pfdebug);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp