Re: Binary data type with other output method - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Binary data type with other output method
Date
Msg-id 4773AE0F.80705@dunslane.net
Whole thread Raw
In response to Re: Binary data type with other output method  (Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>)
Responses Re: Binary data type with other output method  (Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>)
List pgsql-hackers

Andreas 'ads' Scherbaum wrote:
> On Wed, 26 Dec 2007 20:20:59 -0500 Andrew Dunstan wrote:
>
>   
>> Andreas 'ads' Scherbaum wrote:
>>     
>>> The reason for my question is: PHP (yes *grumble*) does not recognize
>>> boolean columns but instead makes a simple string from a PG boolean.
>>>
>>> So every time you select a boolean column in PHP, you cannot use
>>> expressions like:
>>>
>>> if (!$bool)
>>>
>>> because 't' and 'f' give TRUE in PHP.
>>>
>>> I was begged many times by our people coding PHP to find a workaround
>>> for this problem.
>>>       
>> The answer is surely to fix the PHP driver rather than trying to mangle 
>> Postgres. The Perl DBD::Pg driver does not suffer this problem, so it 
>> can certainly be worked around (in fact in DBD::Pg you get a choice if 
>> 1/0 or t/f values for booleans).
>>     
>
> This PHP driver is in use since years, do you really expect they will
> fix this bug and make thousands of applications fail? Everyone like
> Mark who posted an example earlier would have to change the PHP code
> if the variable is now a true/false boolean instead a 't'/'f' string.
> No, i don't expect a bugfix here. Newer drivers like PDO seems to
> behave correct but this will not help if you cannot use this driver.
>
>
>   

I don't see why it couldn't be switchable behaviour, just as it is in 
DBD::Pg.

Also, earlier you said:

> > I think you'd really need a separate type.  But have you considered
> > something simple like
> >     CREATE DOMAIN boolint AS int CHECK (value = 0 OR value = 1)
>   
>
> i considered this one but this would only bring 0/1 as input, not as
> output values, which is what i want.

er, what? This domain would have input and output values of 0/1.

cheers

andrew



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: duplicate columns with COPY
Next
From: "Joris Dobbelsteen"
Date:
Subject: Re: Sorting Improvements for 8.4