ajbool
ajbool · Three-valued boolean type with a pseudo-NULL unknown state for primary keys.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100243 | ajbool | ajbool | 0.0.3 | TYPE | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16
Usage
Sources:
ajbool adds a one-byte three-state Boolean type whose stored values are t, f, and u. Unlike SQL NULL, the explicit u value can participate in equality, ordering, hash indexes, B-tree indexes, unique constraints, and primary keys. An ajbool column can still separately contain SQL NULL.
Core Workflow
Casts preserve ordinary Boolean values and translate between explicit unknown and SQL nullness:
The first query returns t, f, and u; the second returns true, false, and SQL NULL.
Object Index
ajboolis the scalar type; its text output ist,f, oru.- Cast
boolean AS ajboolis assignment-only and maps SQLNULLtou. - Cast
ajbool AS booleanis implicit and mapsuto SQLNULL. - Operators
=,<>,<,<=,>, and>=support comparisons. btree_ajbool_opsandhash_ajbool_opsprovide default B-tree and hash operator classes.
Operational Notes
Version 0.0.3 is relocatable and declares no dependency or preload requirement. Input parsing examines only the first character: t becomes true, f becomes false, and every other input becomes u. Validate application input before casting if silent conversion of misspellings to unknown is unacceptable.
Do not confuse the stored u value with SQL NULL: u = u is a normal comparison, while NULL = NULL remains unknown. Casting u to boolean re-enters SQL three-valued logic, so predicates may need IS NULL handling after that cast.