Skip to content

PostgreSQL

KryoDesk connects to PostgreSQL over TCP with the tokio-postgres client (TLS through macOS). A PostgreSQL connection is read-only: browsing, quick search, structure and the query editor. Write mode, users and privileges, structure editing, tools, export and migration are MySQL / MariaDB only for now.

A connection belongs to one database (the session’s Database, empty = postgres). The Databases window and the connection tab list the schemas of that database where MySQL shows databases; another database needs another session or quick connection.

Sessions → New session → Databases, arrow of the tile → PostgreSQL. Picking it swaps the port 3306 for 5432 (a port you typed stays).

Field Values Default What it does
Encryption Preferred, Required, Disabled Preferred See TLS below.
Database Name; empty = postgres Empty Database the connection logs in to.
Client certificate, Client key PEM certificate and unencrypted PKCS#8 key Empty Presented in the TLS handshake (cert authentication). Not with TLS disabled.

Quick connect: postgres://[user@]host[:port][/database] (also postgresql://), port 5432 by default, TLS preferred. A password in the URL is refused.

The password is kept in the vault as password:postgres://user@host:port, after Save the password in the vault? [y/N] in the console.

Each step is printed in the console of the connection tab:

  1. DNS: resolving <host>... and the addresses (10 s limit; an IP address skips it).
  2. TCP: connecting to <address>... for each address in turn (10 s each).
  3. Startup: TLS negotiation and authentication (20 s), application_name = KryoDesk. Without a saved password the first attempt sends none (trust, certificate login); The server asks for a password then prompts for it. Up to 3 typed passwords.
  4. The first read-only transaction (below) reads the server details: version(), current_user, session_user, current_database(), server_version_num, pg_backend_pid(), pg_is_in_recovery(), inet_server_addr(), transaction_read_only and statement_timeout. transaction_read_only other than on stops the login. Nothing is set for the whole session.
  5. On 9.5 and later: the TLS protocol and cipher from pg_stat_ssl.

While idle, an empty query every 60 s keeps the connection open. Server NOTICE and WARNING messages are printed in the console.

Encryption What KryoDesk does
Preferred First attempt with TLS required. A server without TLS: the console prints The server does not offer TLS: continuing WITHOUT encryption and connects again without it; a password saved in the vault is sent only after Send the password saved in the vault (…) over this connection without TLS? [y/N].
Required TLS or no connection: TLS: the server does not offer TLS (ssl = off in postgresql.conf, or a pooler without TLS) and the session requires it.
Disabled No TLS. With password or md5 authentication the password travels in clear text; scram-sha-256 sends none.

The certificate is checked with the macOS trust settings (Windows: the Windows certificate store) against the host name of the session. A certificate macOS does not trust (self-signed, expired, another name) prints the TLS error; KryoDesk then reads the certificate in a separate TLS handshake (nothing else is sent) and shows its subject, SAN, issuer, validity, serial and SHA-256. Trust this certificate for host:port (pin its SHA-256)? [y/N] saves the pin in postgres_known_hosts.json in the configuration folder. Compare the SHA-256 with the server’s own:

Terminal window
openssl x509 -noout -fingerprint -sha256 -in server.crt

A pinned host accepts only that certificate, also when macOS would trust another one; the pin is checked right after the handshake, before the login and database name are sent. Another certificate prints TLS: CERTIFICATE CHANGED for host:port with both fingerprints and asks Replace the pin of host:port with this certificate? [y/N] (No disconnects). The cancel request uses the same pin.

With a pinned certificate and a password, the login requires SCRAM channel binding (SCRAM-SHA-256-PLUS): the password method cannot fall back to md5 or clear text. A server with md5 or password in pg_hba.conf, or a pooler without channel binding, prints the reason and asks Log in without channel binding? [y/N].

The padlock in the connection tab shows TLS off, verified by macOS or pinned.

Every operation (a page of rows, a catalog read, an editor statement) runs in its own transaction:

BEGIN TRANSACTION READ ONLY; SET LOCAL statement_timeout = 60000; SET LOCAL lock_timeout = 10000; SELECT 1
-- the statements of the operation
ROLLBACK

SELECT 1 takes the transaction’s first snapshot, after which SET TRANSACTION READ WRITE is refused (SQLSTATE 25001). An editor statement is followed by SELECT current_setting('transaction_read_only') in the same transaction; anything other than on closes the session. A failed ROLLBACK marks the connection unusable and closes the session too; an operation that ended without ROLLBACK (a cancelled command) is rolled back before the next one. Past statement_timeout + 30 s without an answer KryoDesk sends a cancel request (the same as pg_cancel_backend) over a new TCP connection. cancel in the console sends one for the running statement.

READ ONLY refuses changes to committed data and DDL. It does not stop what takes effect outside the transaction; these still run within the login’s privileges:

  • session advisory locks (pg_advisory_lock) and DEALLOCATE / DISCARD;
  • pg_cancel_backend, pg_terminate_backend, pg_reload_conf;
  • replication slots (pg_create_physical_replication_slot, pg_create_logical_replication_slot);
  • server files for privileged roles (lo_export, pg_read_file, pg_ls_dir);
  • LOCK TABLE (held until the ROLLBACK);
  • functions that EXPLAIN ANALYZE executes, and DO blocks.

pg_notify and NOTIFY are delivered only on commit, so the ROLLBACK drops them. The console names the statements above before sending them (Not undone by READ ONLY and ROLLBACK: …) without blocking them.

Schema, table and column names come from pg_catalog; names are always quoted ("name", " doubled), values are parameters. A page reads each column as left("col"::text, 4097); a longer value is shown cut to 4096 characters. Without a sort column, pages follow the primary key.

The quick search sends:

SELECT … FROM "public"."customers" WHERE ("email"::text ILIKE $1 ESCAPE '!' OR "note"::text ILIKE $1 ESCAPE '!') ORDER BY "id" LIMIT 101
-- $1 = '%O''Brien%'
SELECT count(*) FROM "public"."customers" WHERE (…)

%, _ and ! in the typed text are escaped with !.

In the window PostgreSQL
Tables Tables and partitioned tables (kind BASE TABLE, engine column partitioned / partition), views, materialized views, foreign tables. Rows: the estimate pg_class.reltuples (empty when PostgreSQL 14+ marks it unknown, before the first VACUUM / ANALYZE); size: pg_total_relation_size.
Routines Functions, procedures, aggregates and window functions, named with their arguments, e.g. total(integer, text).
Load schema sizes Relations and total size per schema from pg_class.
Show CREATE SCHEMA / TABLE / VIEW PostgreSQL has no SHOW CREATE: schemas and tables are rebuilt from the catalog (columns, defaults, identity, generated columns, constraints, indexes, triggers, comments, PARTITION BY; no storage parameters, grants, inheritance, tablespace or partition bounds). Views: pg_get_viewdef, routines: pg_get_functiondef (aggregates have none).
Edit definition (views, routines) The definition in an object tab, read-only.
Server variables / Server status pg_settings and the statistics views, read-only. Server variables and status
Structure Columns (type from format_type, default, identity or generated, primary key, comment) and the rebuilt CREATE statement.

The schema picked in the editor becomes the search_path of the statement: SELECT set_config('search_path', quote_ident($1), true) (the name is a parameter, the setting ends with the transaction).

One run is one statement:

  1. Refused before sending: a statement whose first keyword is BEGIN, START, COMMIT, END, ROLLBACK, ABORT, SAVEPOINT, RELEASE, PREPARE (also PREPARE TRANSACTION) or COPY (comments before it are skipped).
  2. The server parses it first (Parse of the extended protocol): a; b fails with 42601 cannot insert multiple commands into a prepared statement, and $1 placeholders are refused.
  3. Then it is sent over the simple protocol, so every type comes back as text. Up to 5,000 rows (32 MB of text) are kept; the rest are counted.
  4. After a statement that worked, SELECT current_setting('transaction_read_only') in the same transaction; anything other than on closes the connection. Then ROLLBACK.

A write fails on the server with 25006 cannot execute … in a read-only transaction. Errors show the severity, SQLSTATE, message, DETAIL, HINT, position and the object (schema, table, column, constraint), with a short explanation of common SQLSTATEs.

Command What it does
status version(), address, user, current_user / session_user, database, backend PID, standby, TLS, statement_timeout.
databases Databases on the server (pg_database, without templates): owner, encoding, size when you may connect, whether connections are allowed.
cancel Cancel request for the statement running on this connection.

Scroll or pinch to zoom · drag to move · double-click to zoom · Esc or click outside to close