MCPcopy Create free account
hub / github.com/apache/cloudberry / exec_command_conninfo

Function exec_command_conninfo

src/bin/psql/command.c:598–637  ·  view source on GitHub ↗

* \conninfo -- display information about the current connection */

Source from the content-addressed store, hash-verified

596 * \conninfo -- display information about the current connection
597 */
598static backslashResult
599exec_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

Callers 1

exec_commandFunction · 0.85

Calls 8

PQdbFunction · 0.85
PQhostFunction · 0.85
PQhostaddrFunction · 0.85
is_unixsock_pathFunction · 0.85
PQuserFunction · 0.85
PQportFunction · 0.85
printSSLInfoFunction · 0.85
printGSSInfoFunction · 0.85

Tested by

no test coverage detected