40 if (debug_port == NULL)
95 strftime(timestr, ts_len,
97 localtime_r(&
now, &tmbuf));
99 snprintf(timestr + strlen(timestr), ts_len - strlen(timestr),
100 ".%06u", (
unsigned int) (tval.tv_usec));
115 if (!isprint((
unsigned char) *v))
116 fprintf(pfdebug,
" \\x%02x", *v);
134 fprintf(pfdebug,
" %d", result);
155 fprintf(pfdebug,
" %d", result);
210 if (isprint((
unsigned char) v[
i]))
233 fprintf(f,
"NotificationResponse\t");
249 for (
int i = 0;
i < nparams;
i++)
254 for (
int i = 0;
i < nparams;
i++)
265 for (
int i = 0;
i < nparams;
i++)
280 fprintf(f,
"CommandComplete\t");
301 for (
i = 0;
i < nfields;
i++)
330 field = message[*
cursor - 1];
334 suppress = regress && (field ==
'L' || field ==
'F' || field ==
'R');
368 int length,
bool regress)
377 fprintf(f,
"PasswordMessage\t");
387 fprintf(f,
"SASLInitialResponse\t");
390 if (initialResponse != -1)
396 int length,
bool regress)
412 for (
int i = 0;
i < nfields;
i++)
417 for (
int i = 0;
i < nfields;
i++)
433 fprintf(f,
"CopyInResponse\t");
437 for (
int i = 0;
i < nfields;
i++)
446 fprintf(f,
"CopyOutResponse\t");
450 for (
int i = 0;
i < nfields;
i++)
457 fprintf(f,
"BackendKeyData\t");
472 for (
int i = 0;
i < nparams;
i++)
485 int length,
bool suppress)
489 memcpy(&authType, message + *
cursor, 4);
495 fprintf(f,
"AuthenticationOk");
500 fprintf(f,
"AuthenticationCleartextPassword");
504 fprintf(f,
"AuthenticationMD5Password");
507 fprintf(f,
"AuthenticationGSS");
510 fprintf(f,
"AuthenticationGSSContinue\t");
515 fprintf(f,
"AuthenticationSSPI");
518 fprintf(f,
"AuthenticationSASL\t");
519 while (message[*
cursor] !=
'\0')
524 fprintf(f,
"AuthenticationSASLContinue\t");
529 fprintf(f,
"AuthenticationSASLFinal\t");
534 fprintf(f,
"Unknown authentication message %d", authType);
541 fprintf(f,
"ParameterStatus\t");
551 fprintf(f,
"ParameterDescription\t");
554 for (
int i = 0;
i < nfields;
i++)
563 fprintf(f,
"RowDescription\t");
566 for (
int i = 0;
i < nfields;
i++)
581 fprintf(f,
"NegotiateProtocolVersion\t");
591 fprintf(f,
"FunctionCallResponse\t");
600 fprintf(f,
"CopyBothResponse\t");
622 char *prefix = toServer ?
"F" :
"B";
635 id = message[logCursor++];
637 memcpy(&length, message + logCursor, 4);
720 &logCursor, length, regress);
728 &logCursor, regress);
732 &logCursor, length, regress);
824 if (logCursor - 1 != length)
826 "mismatched message length: consumed %d, expected %d\n",
827 logCursor - 1, length);
852 memcpy(&length, message + logCursor, 4);
864 memcpy(&version, message + logCursor, 4);
892 while (message[logCursor] !=
'\0')
Datum now(PG_FUNCTION_ARGS)
#define Assert(condition)
static void pqTraceOutput_RowDescription(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_GSSResponse(FILE *f, const char *message, int *cursor, int length, bool regress)
static void pqTraceOutputString(FILE *pfdebug, const char *data, int *cursor, bool suppress)
static void pqTraceOutput_FunctionCall(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_CopyInResponse(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_BackendKeyData(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_Authentication(FILE *f, const char *message, int *cursor, int length, bool suppress)
static void pqTraceOutput_Parse(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_NoticeResponse(FILE *f, const char *message, int *cursor, bool regress)
void PQtrace(PGconn *conn, FILE *debug_port)
static void pqTraceOutput_ParameterDescription(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor, bool suppress)
static void pqTraceOutput_DataRow(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_SASLResponse(FILE *f, const char *message, int *cursor, int length, bool regress)
static void pqTraceOutput_Query(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_CopyData(FILE *f, const char *message, int *cursor, int length, bool suppress)
static int pqTraceOutputInt16(FILE *pfdebug, const char *data, int *cursor)
static void pqTraceOutput_SASLInitialResponse(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_NegotiateProtocolVersion(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_CopyBothResponse(FILE *f, const char *message, int *cursor, int length)
static void pqTraceOutput_Bind(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_ErrorResponse(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutputNR(FILE *f, const char *type, const char *message, int *cursor, bool regress)
static void pqTraceOutput_Close(FILE *f, const char *message, int *cursor)
static void pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor)
static void pqTraceOutput_Describe(FILE *f, const char *message, int *cursor)
void pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
static void pqTraceOutput_NotificationResponse(FILE *f, const char *message, int *cursor, bool regress)
static void pqTraceOutput_CommandComplete(FILE *f, const char *message, int *cursor)
void PQsetTraceFlags(PGconn *conn, int flags)
static void pqTraceOutput_ParameterStatus(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_Execute(FILE *f, const char *message, int *cursor, bool regress)
void PQuntrace(PGconn *conn)
static void pqTraceOutput_CopyOutResponse(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_ReadyForQuery(FILE *f, const char *message, int *cursor)
static int pqTraceOutputInt32(FILE *pfdebug, const char *data, int *cursor, bool suppress)
void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
void pqTraceOutputCharResponse(PGconn *conn, const char *responseType, char response)
static void pqTraceFormatTimestamp(char *timestr, size_t ts_len)
static void pqTraceOutput_CopyFail(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_PasswordMessage(FILE *f, const char *message, int *cursor)
static void pqTraceOutput_FunctionCallResponse(FILE *f, const char *message, int *cursor)
#define PQTRACE_SUPPRESS_TIMESTAMPS
#define PQTRACE_REGRESS_MODE
#define AUTH_RESPONSE_PASSWORD
#define AUTH_RESPONSE_SASL
#define AUTH_RESPONSE_SASL_INITIAL
#define AUTH_RESPONSE_GSS
static void const char fflush(stdout)
#define CANCEL_REQUEST_CODE
#define NEGOTIATE_GSS_CODE
#define NEGOTIATE_SSL_CODE
#define PqMsg_CloseComplete
#define AUTH_REQ_SASL_CONT
#define PqMsg_NotificationResponse
#define PqMsg_BindComplete
#define PqMsg_ParameterDescription
#define PqMsg_FunctionCall
#define PqMsg_GSSResponse
#define PqMsg_SASLResponse
#define PqMsg_FunctionCallResponse
#define PqMsg_SASLInitialResponse
#define PqMsg_ReadyForQuery
#define PqMsg_AuthenticationRequest
#define PqMsg_CopyInResponse
#define PqMsg_EmptyQueryResponse
#define PqMsg_RowDescription
#define PqMsg_CopyBothResponse
#define PqMsg_ParameterStatus
#define PqMsg_NegotiateProtocolVersion
#define PqMsg_PortalSuspended
#define AUTH_REQ_PASSWORD
#define AUTH_REQ_GSS_CONT
#define PqMsg_PasswordMessage
#define PqMsg_BackendKeyData
#define PqMsg_CommandComplete
#define PqMsg_ErrorResponse
#define PqMsg_NoticeResponse
#define PqMsg_CopyOutResponse
#define AUTH_REQ_SASL_FIN
#define PqMsg_ParseComplete
char current_auth_response
int gettimeofday(struct timeval *tp, void *tzp)