Skip to main content
MySQL has no boolean. BOOL is an alias for TINYINT(1), which accepts 5 and -1 as happily as 1, and gives them back unchanged. vsql_boolean adds a STRICTBOOL column type that stores one byte and holds two values.

Install

vsql_boolean.veb is already in the server’s lib/veb/ directory if you installed VillageSQL with the install script, the Docker image, or a release tarball. Install it into the server with one statement:
Confirm it is there:
To build it yourself, follow the build instructions in the repository.

What it adds

The STRICTBOOL type

A STRICTBOOL column takes the strings 'true'/'false', 't'/'f', 'yes'/'no', 'on'/'off' and '1'/'0', in any letter case. Pass them as strings: a bare number is refused. It reads back as true or false whichever form went in, and it occupies one byte.

Functions

Example

Four spellings went in, and two values came back out. Count them:
Anything outside the accepted spellings is refused at insert time: INSERT INTO flags VALUES (5, 'eps', 'maybe') fails with ERROR 1366 (HY000): Incorrect STRICTBOOL value: 'maybe' for column 'active' at row 1. So does an unquoted 1, with ERROR 3219 (HY000): Incorrect STRICTBOOL value: '1' for column 'active' at row 1.

See also