Re: getting postgres to emulate mysql/sqlserver bit datatype - Mailing list pgsql-general

From Tom Lane
Subject Re: getting postgres to emulate mysql/sqlserver bit datatype
Date
Msg-id 6863.1171290483@sss.pgh.pa.us
Whole thread Raw
In response to Re: getting postgres to emulate mysql/sqlserver bit datatype  (Shane Ambler <pgsql@007Marketing.com>)
Responses Re: getting postgres to emulate mysql/sqlserver bit datatype  ("Anton Melser" <melser.anton@gmail.com>)
List pgsql-general
Shane Ambler <pgsql@007Marketing.com> writes:
> If you look at the bool type you will find it calls a function called
> boolout(bool) which returns a cstring to return the data for the boolean
> - you could replace this with your own function that returns a 1 or 0
> instead of true or false. Similarly the functions to input/compare etc
> can be changed/replaced.

I think actually what he needs is what Peter suggested upthread, namely
to weaken the context-restriction on the int-to-bool cast.  For a
comparison like
    WHERE boolcol = 1
the system is still gonna see that as a bool vs int comparison, and it
won't take it unless int-to-bool is an implicit cast.

Another route might be to create a bool = int operator.  That seems less
likely to break expected behaviors, but it'd be more work.

            regards, tom lane

pgsql-general by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: Adjacency List or Nested Sets to model file system hierarchy?
Next
From: Tom Lane
Date:
Subject: Re: pg_dump: [tar archiver] write error appending to tar archive