* \conninfo -- display information about the current connection */
| 596 | * \conninfo -- display information about the current connection |
| 597 | */ |
| 598 | static backslashResult |
| 599 | exec_command_conninfo(PsqlScanState scan_state, bool active_branch) |
| 600 | { |
| 601 | if (active_branch) |
| 602 | { |
| 603 | char *db = PQdb(pset.db); |
| 604 | |
| 605 | if (db == NULL) |
| 606 | printf(_("You are currently not connected to a database.\n")); |
| 607 | else |
| 608 | { |
| 609 | char *host = PQhost(pset.db); |
| 610 | char *hostaddr = PQhostaddr(pset.db); |
| 611 | |
| 612 | if (is_unixsock_path(host)) |
| 613 | { |
| 614 | /* hostaddr overrides host */ |
| 615 | if (hostaddr && *hostaddr) |
| 616 | printf(_("You are connected to database \"%s\" as user \"%s\" on address \"%s\" at port \"%s\".\n"), |
| 617 | db, PQuser(pset.db), hostaddr, PQport(pset.db)); |
| 618 | else |
| 619 | printf(_("You are connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"), |
| 620 | db, PQuser(pset.db), host, PQport(pset.db)); |
| 621 | } |
| 622 | else |
| 623 | { |
| 624 | if (hostaddr && *hostaddr && strcmp(host, hostaddr) != 0) |
| 625 | printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" (address \"%s\") at port \"%s\".\n"), |
| 626 | db, PQuser(pset.db), host, hostaddr, PQport(pset.db)); |
| 627 | else |
| 628 | printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"), |
| 629 | db, PQuser(pset.db), host, PQport(pset.db)); |
| 630 | } |
| 631 | printSSLInfo(); |
| 632 | printGSSInfo(); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | return PSQL_CMD_SKIP_LINE; |
| 637 | } |
| 638 | |
| 639 | /* |
| 640 | * \copy -- run a COPY command |
no test coverage detected