Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ArloL committed Nov 28, 2022
1 parent 831fd12 commit 1308ad2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,34 @@ only return one row but it returns three.
# Quickstart

`./mvnw test`

# Explanation

Given this table:
```
CREATE TABLE "queue" (
"id" BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
"action" TEXT NOT NULL
);
Repeat these queries for a while:
```
INSERT INTO queue (action) VALUES ('action1');
INSERT INTO queue (action) VALUES ('action2');
INSERT INTO queue (action) VALUES ('action3');

# repeat three times
DELETE FROM queue
WHERE
id IN (
SELECT id
FROM queue
ORDER BY id
LIMIT 1
FOR UPDATE
SKIP LOCKED
)
RETURNING *;
```
If you check the number of results from the delete query it will not return one result but three. That should not be the case due to the LIMIT statement in the query.

0 comments on commit 1308ad2

Please sign in to comment.