Production and read-only
Two marks on a connection decide how careful the window is with it: Production asks before the statements that hurt, and Read-only sends nothing that writes.
Production
Tick Production on the connection’s General tab and three things change.
- The window marks it: the status bar is tinted and says PRODUCTION, and so does the path above the console.
- Its sessions open in Manual commit, so a statement that writes waits in a transaction for Commit or Roll back. The mode can still be switched on the toolbar.
- Before a risky statement it asks Run on production?, with Do not run and Run anyway.
A risky statement is one of three: an UPDATE or DELETE with no WHERE, which touches every row; one that destroys data or schema, such as DROP, TRUNCATE or dropping a column; and one the window could not recognise, because then what it does is unknown. An INSERT, or a write with a WHERE, runs without the question.
Settings → Connection → Ask before a risky statement can ask on Every connection instead of Production only; the question is then Run this statement?
NoteConnections taken from DataGrip or TablePlus arrive marked Production, because neither file says, and asking is the safe side.
Read-only
Tick Read-only and only statements that read are sent. Anything else, a statement the window cannot recognise included, is refused with This connection is read-only. Only statements that read are sent from it. The window checks before sending and the application checks again before the driver sees it.
CautionA function call that writes cannot be told apart from one that reads. Read-only is a guard against a slip, not a permission: for a real one, connect as a user the server lets only read.
Settings → Connection → New connections are read-only makes it the default for connections made from now on; a saved connection keeps its own choice.
A colour of its own
The Options tab gives a connection a Colour, drawn before it in the tree: violet, indigo, blue, cyan, teal or plum. Red, amber and green are left out on purpose: the window spends them on meaning, production among it, and a connection’s own colour must never look like one.
Other machines
A device paired with this machine is never shown a production connection, and a read-only one stays read-only for it (see Another machine).