Subject Re: A few Firebird questions about future features
Author burmair
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@...> wrote:
>
> > > Are there any plans to add support for true booleans? If yes, which
> > > version will support this?
> >
> > You can easily add boolean type via domains:
> >
> > CREATE DOMAIN BOOLEAN
> > AS SMALLINT
> > CHECK (value is null or value in (0, 1));
> >
> > And use it like this:
> >
> > CREATE TABLE t1
> > (
> > C1 VARCHAR(10),
> > B1 BOOLEAN,
> > B2 BOOLEAN NOT NULL,
> > ...
> > );
> >
> > As you can see, not much different than 'real' boolean.
>
> Well, except that INSERT INTO t1 VALUES ('', TRUE, FALSE)
> won't work.
>
> Neither will a query:
>
> WHERE B1 AND ...
>
> Or:
> declare variable myvar boolean;
>
> myvar = exists( ... );
>
>
> Etc.

Another thing you can't do is map it to a bool variable in C++ (via an
XSQLDA). The SMALLINT is 2 bytes, bool is 1. So you can try making
it a CHAR and now the XSQLDA is happy, but tools like IBExpert won't
display the value, even if you specify CHARACTER SET NONE, which you'd
think would mean display the byte as a numeric value from 0 to 255.
You can use 'T' and 'F' as the values, which will display just fine,
but they're not the 0 and 1 (actually, any non-0 value) which C++
requires.

Personally, I think a boolean type would be very useful.