Help › Stay safe
Confirm risky statements
Which statements Querlyn asks about before running them, on which connections, what the question shows, and how to change the rules.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
Before your SQL reaches the database, Querlyn reads it. If a statement could destroy data, and the connection's environment calls for it, Querlyn shows you what it found and waits for your answer.
When it asks
| Environment | Risk | Querlyn asks before |
|---|---|---|
| Local, Development | Low | Nothing |
| Testing, Staging | Medium | Destructive statements |
| Production | High | Destructive statements, and statements it cannot classify |
When you run several statements at once, each is checked, and one question lists every statement that needs your answer. Nothing runs until you answer.
When you run one statement on several connections, each connection is checked by its own environment, and one question covers them all, naming every Production connection. A statement that changes data asks there whenever the set has a Production connection. See Run a query on several connections.
What counts as destructive
On every database:
DROPof anything: a database, schema, table, view, function, procedure, index, sequence and so onALTER TABLE … DROP COLUMNTRUNCATEDELETEwithout aWHEREclauseUPDATEwithout aWHEREclauseMERGEwith aDELETEactionREVOKE, and SQL Server'sDENY: they take privileges or roles away, as the same change does in Users and Roles
A WHERE clause that is always true, such as WHERE 1 = 1, counts as no
WHERE clause.
And statements that are special to one database:
| Database | Also destructive |
|---|---|
| Amazon Redshift | ALTER TABLE … APPEND FROM, which empties the source table; UNLOAD that replaces files |
| ClickHouse | Dropping, detaching, moving or replacing a partition; ALTER TABLE … CLEAR COLUMN; OPTIMIZE … DEDUPLICATE; REPLACE TABLE; RESTORE; SYSTEM commands that stop the server or remove replicas |
| Oracle Database | PURGE; FLASHBACK |
| Snowflake | CREATE OR REPLACE of a table or another object that holds data; CREATE OR ALTER TABLE; INSERT OVERWRITE; SWAP WITH; REMOVE of staged files; writing files with OVERWRITE = TRUE |
| BigQuery | CREATE OR REPLACE TABLE; LOAD DATA OVERWRITE; EXPORT DATA with overwrite = true; DROP ALL ROW ACCESS POLICIES; a scripting block (BEGIN … END, IF, WHILE) is judged by the statements in it |
| MongoDB | dropDatabase(); drop(); a delete or update whose filter matches every document, such as deleteMany({}); dropping indexes; an aggregation ending in $out; renameCollection with dropTarget; convertToCapped; dropping users or roles; revoking roles or privileges; commands that stop or reconfigure the server. A command Querlyn does not know, or one that grants roles or privileges, cannot be classified. See Query MongoDB |
| Kafka | Not statements: deleting a topic or its records, resetting or deleting a consumer group, and lowering how long a topic keeps messages. Producing a message, creating a topic and other changes ask on Production. See Manage Kafka topics |
| Cassandra | DROP KEYSPACE, DROP TABLE and the other DROPs; TRUNCATE; ALTER TABLE … DROP; REVOKE; a DELETE that does not name one whole primary key (a whole partition or a range of rows), judged by the table's key; the same inside a batch. A statement Querlyn cannot read, and GRANT, cannot be classified. On Production also a SELECT with ALLOW FILTERING, and Explain, which runs the read to trace it. See Query Cassandra |
For example, DELETE FROM sessions asks on Testing, Staging and
Production, because it has no WHERE clause.
DELETE FROM sessions WHERE expires_at < now() does not ask.
Statements Querlyn cannot classify
Some statements cannot be judged from their text: a block of procedural
code, a call of a stored procedure, EXECUTE, COPY, GRANT (what it
gives away is not checked), or SQL in a form Querlyn does not know. On
Production, Querlyn asks about these too. It
cannot tell that they are harmless, so it does not assume so. The question
then says "Cannot be checked", with the reason.
Note: The check reads the SQL you are about to run. It cannot see what a stored procedure, a function or a trigger does when your statement calls it.
Statements that make others wait
On PostgreSQL, MySQL and MariaDB, a schema change that would make other sessions wait for a lock, on a table not known to be small, is asked about in the same question, with the table's size. See Migration lock warnings.
The question
The question is titled Run on Production? (or the name of the connection's environment). It lists each statement that needs your answer, with what it does, for example:
Statement 2: UPDATE without WHERE on accounts — UPDATE accounts SET balance = 0
| Button | What it does |
|---|---|
| Run | Runs everything you asked to run. |
| Dry Run First | Shown for one UPDATE or DELETE that a dry run can take: runs nothing, and dry-runs the statement instead, so you see the rows it would change before anything is committed. See See a change before you commit it. |
| Cancel | Runs nothing. ⎋ on macOS or Esc on Windows and Linux does the same. |
↩ on macOS or Enter on Windows and Linux does not confirm. You have to choose Run yourself, so that a key pressed out of habit cannot run a destructive statement.
To answer with your fingerprint instead of a click, turn on Confirm with Touch ID for the risk level; see Confirm with Touch ID.
Other things that ask
| What you do | When Querlyn asks |
|---|---|
| Apply row changes from the results | On Production always. On Testing and Staging when rows are deleted or edited without a key. See Edit rows in a result. |
| Apply a structure change from the table designer, an ER diagram or schema compare | By the rules above, statement by statement. See Create and change tables. |
| Import a file | On Production. See Import data from a file. |
| Change users, roles or privileges | On Production always. On Testing and Staging when a change takes access away: a revoke, a denial, a removed membership or a drop. See Manage users, roles and privileges. |
| Copy tables into another connection | On Production. Replacing a table's rows is also asked like a destructive statement. See Copy tables between connections. |
| Compare the data of a Production table | Once for each pair of sides, before anything is read. See Compare the data of two tables. |
| Profile a whole Production table | Every time, before anything is read. See Profile the values of a column. |
| Show a masked column | Always. See Share your screen safely. |
| Clear the scratch, a schema's history or an undo journal | Always. |
| Restore a backup | Always; on Testing, Staging and Production you type the database's name. See Back up and restore a database. |
| Explain Analyze of a statement that may change data | On Production. See See a query's execution plan. |
| Turn read-only off | On Production. See Read-only connections. |
| End another session, or cancel its query | Ending a session always asks. Cancelling a query asks on Production. See Server Activity. |
| Close a tab, disconnect or quit with a transaction open | Always. See Commit and roll back changes. |
Change when Querlyn asks
Open and find Ask before running statements under Safety. Each risk level has three choices, and one of them is chosen:
| Choice | Querlyn asks before | In the settings file |
|---|---|---|
| Ask before destructive or unrecognized statements | Destructive statements and statements it cannot classify | destructive_and_unknown |
| Ask before destructive statements | Destructive statements | destructive |
| Never ask | Nothing | never |
High risk (Production) starts with the first, medium risk (Testing, Staging) with the second and low risk (Local, Development) with the third. A change applies from the next statement you run.
A team's policy, a Preview, can set the least each risk level asks on the connections shared in that team: there, the stricter of your choice and the team's applies.
The choice also decides the questions under Other things that ask that go by risk level: applying row changes, a structure change, an import, a copy of tables, and cancelling another session's query.
Warning: Never ask for high risk turns these questions off for all your Production connections. The question before a restore is asked all the same.
The same three settings are in the settings file, and each choice is a command; see Settings reference.
[safety]
high_risk = "destructive_and_unknown"
medium_risk = "destructive"
low_risk = "never"
The example shows the values Querlyn starts with.
To make a connection refuse changes altogether instead of asking, see Read-only connections.
Help for Querlyn 0.1.0. All help topics