question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confirm dangerous query execution doesn't work when there's a RETURNING clause in a DELETE statement

See original GitHub issue

System 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:

image

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:

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
manticore-projectscommented, May 7, 2022

Thank you @lukaseder . I have added support for the OUTPUT clause to the INSERT, DELETE and UPDATE 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

1reaction
manticore-projectscommented, May 6, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found