Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-13 Thread Anton Melser
On 13/02/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Anton Melser" <[EMAIL PROTECTED]> writes: > ERROR: operator is not unique: boolean = integer > I get this whether castcontext is 'a' or 'i'. If you make both cast directions the same priority then the system has no basis for choosing bool = bool

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Tom Lane
"Anton Melser" <[EMAIL PROTECTED]> writes: > ERROR: operator is not unique: boolean = integer > I get this whether castcontext is 'a' or 'i'. If you make both cast directions the same priority then the system has no basis for choosing bool = bool over int = int or vice versa. Try making one dire

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Anton Melser
On 12/02/07, Anton Melser <[EMAIL PROTECTED]> wrote: > I think actually what he needs is what Peter suggested upthread, namely > to weaken the context-restriction on the int-to-bool cast. Indeed... Peter's suggestion seems to have solved all my problems. So even though it probably shows just how

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Anton Melser
I think actually what he needs is what Peter suggested upthread, namely to weaken the context-restriction on the int-to-bool cast. Indeed... Peter's suggestion seems to have solved all my problems. So even though it probably shows just how embarrassingly bad my sql is... update pg_cast set cast

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Jeff Davis
On Mon, 2007-02-12 at 09:09 +0100, Anton Melser wrote: > In my searching I did turn up a comment (maybe from you even!) about > how it wouldn't work (before at least). I guess my problem is that > there is a body of sql that can't be changed, or at least the other > devs aren't interested enough in

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Tom Lane
Shane Ambler <[EMAIL PROTECTED]> 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. Similarl

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Shane Ambler
Anton Melser wrote: On 12/02/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Joshua D. Drake" <[EMAIL PROTECTED]> writes: > Anton Melser wrote: >> Is there any way >> to force pg to accept 1 and 0 for boolean? > postgres=# insert into bool_test values(1::boolean); > INSERT 166968558 1 > postgres=# ins

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-12 Thread Anton Melser
On 12/02/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Joshua D. Drake" <[EMAIL PROTECTED]> writes: > Anton Melser wrote: >> Is there any way >> to force pg to accept 1 and 0 for boolean? > postgres=# insert into bool_test values(1::boolean); > INSERT 166968558 1 > postgres=# insert into bool_test va

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Tom Lane
"Joshua D. Drake" <[EMAIL PROTECTED]> writes: > Anton Melser wrote: >> Is there any way >> to force pg to accept 1 and 0 for boolean? > postgres=# insert into bool_test values(1::boolean); > INSERT 166968558 1 > postgres=# insert into bool_test values(0::boolean); > INSERT 166968559 1 Possibly An

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Joshua D. Drake
Anton Melser wrote: > Hi, > I am trying to port an app to postgres and have come up against a most > annoying problem. The app works with both mysql and sqlserver, who > both seem to have a bit datatype instead of a proper boolean like pg. > Alas, pg won't accept 1 and 0 for boolean... and npgsql w

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Peter Eisentraut
Phil Endecott wrote: > > Is there any way to force pg to accept 1 and 0 for boolean? > > There is something called "create cast ... without function" which > /might/ do what you want. No, it won't, mainly because int and boolean are not binary compatible. -- Peter Eisentraut http://developer.post

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Phil Endecott
Is there any way to force pg to accept 1 and 0 for boolean? There is something called "create cast ... without function" which /might/ do what you want. Phil. ---(end of broadcast)--- TIP 4: Have you searched our list archives?

Re: [GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Peter Eisentraut
Anton Melser wrote: > Is there any way to force pg to accept 1 and 0 for boolean? You can tweak the context for the cast between int and boolean. Read up about the pg_cast system catalog. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast

[GENERAL] getting postgres to emulate mysql/sqlserver bit datatype

2007-02-11 Thread Anton Melser
Hi, I am trying to port an app to postgres and have come up against a most annoying problem. The app works with both mysql and sqlserver, who both seem to have a bit datatype instead of a proper boolean like pg. Alas, pg won't accept 1 and 0 for boolean... and npgsql won't convert my numeric(1) in