<entry>Remote host name or IP address</entry>
<entry>yes</entry>
</row>
+ <row>
+ <entry><literal>%L</literal></entry>
+ <entry>Local address (the IP address on the server that the
+ client connected to)</entry>
+ <entry>yes</entry>
+ </row>
<row>
<entry><literal>%b</literal></entry>
<entry>Backend type</entry>
#endif
#include "access/xact.h"
+#include "common/ip.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "mb/pg_wchar.h"
appendStringInfoSpaces(buf,
padding > 0 ? padding : -padding);
break;
+ case 'L':
+ {
+ const char *local_host;
+
+ if (MyProcPort)
+ {
+ if (MyProcPort->local_host[0] == '\0')
+ {
+ /*
+ * First time through: cache the lookup, since it
+ * might not have trivial cost.
+ */
+ (void) pg_getnameinfo_all(&MyProcPort->laddr.addr,
+ MyProcPort->laddr.salen,
+ MyProcPort->local_host,
+ sizeof(MyProcPort->local_host),
+ NULL, 0,
+ NI_NUMERICHOST | NI_NUMERICSERV);
+ }
+ local_host = MyProcPort->local_host;
+ }
+ else
+ {
+ /* Background process, or connection not yet made */
+ local_host = "[none]";
+ }
+ if (padding != 0)
+ appendStringInfo(buf, "%*s", padding, local_host);
+ else
+ appendStringInfoString(buf, local_host);
+ }
+ break;
case 'r':
if (MyProcPort && MyProcPort->remote_host)
{
int remote_hostname_errcode; /* see above */
char *remote_port; /* text rep of remote port */
+ /* local_host is filled only if needed (see log_status_format) */
+ char local_host[64]; /* ip addr of local socket for client conn */
+
/*
* Information that needs to be saved from the startup packet and passed
* into backend execution. "char *" fields are NULL if not set.