Confirm dangerous query execution doesn't work when there's a RETURNING clause in a DELETE statement
See original GitHub issueSystem information:
- Operating system (distribution) and version: Microsoft Windows [Version 10.0.22000.556]
- DBeaver version: 22.0.1.202203181646
- Java version: openjdk version “17.0.2” 2022-01-18
Connection specification:
- Database name and version: PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
- Driver name: org.postgresql:postgresql:42.2.5
- Do you use tunnels or proxies (SSH, SOCKS, etc)? No
Describe the problem you’re observing:
The dangerous query execution confirmation doesn’t work when a DELETE
statement has a RETURNING
clause
Steps to reproduce, if exist:
Turn on the “Confirm dangerous query execution” feature:
Then create a table like this:
create table t (id int, a int);
Then run this statement:
delete from t returning *;
It executes without a prompt. The problem doesn’t affect UPDATE
statements. The following statement produces a prompt:
update t set a = 1 returning *;
The prompt being:
Issue Analytics
- State:
- Created a year ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Cannot SELECT from UPDATE RETURNING clause in postgres
You update two rows in your UPDATE query, add a WHERE clause to restrict the rows affected. UPDATE test SET description = 'test'...
Read more >Using the DELETE Statement in SQL - Universal Class
Just like the UPDATE statement, the DELETE statement doesn't technically require a WHERE clause but forgetting the clause can be catastrophic for your...
Read more >How to prevent accidental data loss from executing a query in ...
Then, just execute UPDATE or DELETE statement with the same WHERE clause. But we'll explore some other tips and tricks for “safe SQL...
Read more >SQL DELETE Statement Examples and Coding Best Practices
In this article, we look at how to use the SQL DELETE statement along with several examples and a way to not accidentally...
Read more >Learn SQL: SQL Best Practices for Deleting and Updating data
If any statement fails for any reason, there will be no changes applied. This is not only SQL best practice (you should always...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @lukaseder . I have added support for the
OUTPUT
clause to theINSERT
,DELETE
andUPDATE
statement. This should make those statements parsable and help to trigger the warning in DBeaver.@E1izabeth: Please do let me know, when anything else was needed. I have attached a Snapshot JAR including the PR again. Unfortunately I can not merge the PR myself, but I would write an e-mail to the Project Owner @wumpz.
jsqlparser-4.5-SNAPSHOT.zip
Should be fixed by PR https://github.com/JSQLParser/JSqlParser/pull/1528 I have attached JSQLParser 4.4 + PR 1528, it should be sufficient to just replace the JAR file. jsqlparser-4.5-SNAPSHOT.zip