PostgreSQL error code
PostgreSQL error 23P01
23P01 is the SQLSTATE PostgreSQL reports for exclusion violation, in class 23, Integrity Constraint Violation.
| SQLSTATE | 23P01 |
|---|---|
| Condition name | exclusion_violation |
| Class | 23 — Integrity Constraint Violation |
Reproduce it, then fix it
The exclusion constraint rejects bookings that overlap an existing one, and 10:30–11:30 overlaps 10:00–11:00. Ranges written with [) leave out their end point, so a booking starting at 11:00 fits. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
INSERT INTO bookings VALUES ('[2024-06-01 10:30, 2024-06-01 11:30)');INSERT INTO bookings VALUES ('[2024-06-01 11:00, 2024-06-01 12:00)') RETURNING *;