4 ms·
> –i-am-a-dummy mode I like Jetbrains DataGrip for this. If you execute a modifying query without a where clause it will stop you and double check that's what
by philliphaydon 4y ago
> –i-am-a-dummy mode
I like Jetbrains DataGrip for this.
If you execute a modifying query without a where clause it will stop you and double check that's what you intended to do.
Likewise you can specify a database connection as read-only so that it wont run modifier queries at all, attempting to do so will stop you but you can then explicitly run it if you need to.
- koolba 4y ago> Likewise you can specify a database connection as read-only so that it wont run modifier queries at all, attempting to do so will stop you but you can then explicitly run it if you need to. Does it parse the SQL and guess if it’s DML or run it in a transaction and rollback after? Because “SELECT foo(‘bar’)” could perform DML.
- canadianfella 4y ago[dead]
- philliphaydon 4y agoSo I just quickly tested this and it appears to block it. I created a function to modify then set the connection to readonly. https://prnt.sc/0mNHkGIa1klR https://prnt.sc/0mNHkGIa1klR
- deleted 4y ago[deleted]
- ht85 4y ago> Likewise you can specify a database connection as read-only We emulate that in prod by having admin users with read only permissions. They are granted other roles without the INHERIT option, thus needing an explicit `SET ROLE ...` before being able to do anything dangerous. I also teach people the habit of combining `BEGIN; SET ROLE ...` everytime they need to write something. It has completely stopped "woops prod" incidents since it was implemented.