src/bin/psql/command.c
static backslashResult
exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
{
	if (active_branch)
	{
		char	   *db = PQdb(pset.db);

		if (db == NULL)
			printf(_("You are currently not connected to a database.\n"));
		else
		{
			char	   *host = PQhost(pset.db);
			char	   *hostaddr = PQhostaddr(pset.db);

			if (is_unixsock_path(host))
			{
				/* hostaddr overrides host */
				if (hostaddr && *hostaddr)
					printf(_("You are connected to database \"%s\" as user \"%s\" on address \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), hostaddr, PQport(pset.db));
				else
					printf(_("You are connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), host, PQport(pset.db));
			}
			else
			{
				if (hostaddr && *hostaddr && strcmp(host, hostaddr) != 0)
					printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" (address \"%s\") at port \"%s\".\n"),
						   db, PQuser(pset.db), host, hostaddr, PQport(pset.db));
				else
					printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), host, PQport(pset.db));
			}
			printSSLInfo();
			printGSSInfo();
		}
	}

	return PSQL_CMD_SKIP_LINE;
}
/*
 * \conninfo -- display information about the current connection
 */
\conninfo -- display information about the current connection
\ conninfo -- display information about the current connection
static backslashResult
exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
{
	if (active_branch)
	{
		char	   *db = PQdb(pset.db);
		if (db == NULL)
			printf(_("You are currently not connected to a database.\n"));
		else
		{
			char	   *host = PQhost(pset.db);
			char	   *hostaddr = PQhostaddr(pset.db);
			if (is_unixsock_path(host))
			{
				if (hostaddr && *hostaddr)
					printf(_("You are connected to database \"%s\" as user \"%s\" on address \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), hostaddr, PQport(pset.db));
				else
					printf(_("You are connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), host, PQport(pset.db));
			}
			else
			{
				if (hostaddr && *hostaddr && strcmp(host, hostaddr) != 0)
					printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" (address \"%s\") at port \"%s\".\n"),
						   db, PQuser(pset.db), host, hostaddr, PQport(pset.db));
				else
					printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
						   db, PQuser(pset.db), host, PQport(pset.db));
			}
			printSSLInfo();
			printGSSInfo();
		}
	}
	return PSQL_CMD_SKIP_LINE;
}
static backslashResult exec_command_conninfo ( PsqlScanState scan_state , bool active_branch ) { if ( active_branch ) { char * db = PQdb ( pset . db ) ; if ( db == NULL ) printf ( _ ( " \n " ) ) ; else { char * host = PQhost ( pset . db ) ; char * hostaddr = PQhostaddr ( pset . db ) ; if ( is_unixsock_path ( host ) ) { if ( hostaddr && * hostaddr ) printf ( _ ( " \" \" \" \" \" \" \" \" \n " ) , db , PQuser ( pset . db ) , hostaddr , PQport ( pset . db ) ) ; else printf ( _ ( " \" \" \" \" \" \" \" \" \n " ) , db , PQuser ( pset . db ) , host , PQport ( pset . db ) ) ; } else { if ( hostaddr && * hostaddr && strcmp ( host , hostaddr ) != 0 ) printf ( _ ( " \" \" \" \" \" \" \" \" \" \" \n " ) , db , PQuser ( pset . db ) , host , hostaddr , PQport ( pset . db ) ) ; else printf ( _ ( " \" \" \" \" \" \" \" \" \n " ) , db , PQuser ( pset . db ) , host , PQport ( pset . db ) ) ; } printSSLInfo ( ) ; printGSSInfo ( ) ; } } return PSQL_CMD_SKIP_LINE ; }
\conninfo -- display information about the current connection
\ conninfo -- display information about the current connection
/* hostaddr overrides host */