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

EnvironmentRiskQuerlyn asks before
Local, DevelopmentLowNothing
Testing, StagingMediumDestructive statements
ProductionHighDestructive 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:

  • DROP of anything: a database, schema, table, view, function, procedure, index, sequence and so on
  • ALTER TABLE … DROP COLUMN
  • TRUNCATE
  • DELETE without a WHERE clause
  • UPDATE without a WHERE clause
  • MERGE with a DELETE action
  • REVOKE, and SQL Server's DENY: 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:

DatabaseAlso destructive
Amazon RedshiftALTER TABLE … APPEND FROM, which empties the source table; UNLOAD that replaces files
ClickHouseDropping, 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 DatabasePURGE; FLASHBACK
SnowflakeCREATE 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
BigQueryCREATE 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
MongoDBdropDatabase(); 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
KafkaNot 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
CassandraDROP 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
ButtonWhat it does
RunRuns everything you asked to run.
Dry Run FirstShown 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.
CancelRuns 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 doWhen Querlyn asks
Apply row changes from the resultsOn 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 compareBy the rules above, statement by statement. See Create and change tables.
Import a fileOn Production. See Import data from a file.
Change users, roles or privilegesOn 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 connectionOn Production. Replacing a table's rows is also asked like a destructive statement. See Copy tables between connections.
Compare the data of a Production tableOnce for each pair of sides, before anything is read. See Compare the data of two tables.
Profile a whole Production tableEvery time, before anything is read. See Profile the values of a column.
Show a masked columnAlways. See Share your screen safely.
Clear the scratch, a schema's history or an undo journalAlways.
Restore a backupAlways; 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 dataOn Production. See See a query's execution plan.
Turn read-only offOn Production. See Read-only connections.
End another session, or cancel its queryEnding a session always asks. Cancelling a query asks on Production. See Server Activity.
Close a tab, disconnect or quit with a transaction openAlways. See Commit and roll back changes.

Change when Querlyn asks

Open Querlyn › Open Settings and find Ask before running statements under Safety. Each risk level has three choices, and one of them is chosen:

ChoiceQuerlyn asks beforeIn the settings file
Ask before destructive or unrecognized statementsDestructive statements and statements it cannot classifydestructive_and_unknown
Ask before destructive statementsDestructive statementsdestructive
Never askNothingnever

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