PostgreSQL error code
PostgreSQL error 22026
22026 is the SQLSTATE PostgreSQL reports for string data length mismatch, in class 22, Data Exception.
| SQLSTATE | 22026 |
|---|---|
| Condition name | string_data_length_mismatch |
| Class | 22 — Data Exception |
Reproduce it, then fix it
A bit(4) column takes exactly four bits, and PostgreSQL won’t pad a shorter value when storing it. Write all four, or use bit varying(4). Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
INSERT INTO flags VALUES (1, B'101') RETURNING *;
INSERT INTO flags VALUES (1, B'0101') RETURNING *;