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

From Andreas 'ads' Scherbaum
Subject Re: Binary data type with other output method
Date
Msg-id 20071227130926.49513b71@iridium.wars-nicht.de
Whole thread Raw
In response to Re: Binary data type with other output method  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Binary data type with other output method  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
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.

As i told earlier, this is really a PHP bug, since libpq knows the type
of every returned row in PQftype. DBD::Pg and PHP PDO seems to use this
information.

Anyway, this does not help in my case. My question was if there is a
shorter way to create a boolean type with another output than to
recreate all the casts, operators ect. If not, i have to go with this
approach but maybe someone else has a more elegant idea.


Kind regards

--             Andreas 'ads' Scherbaum
German PostgreSQL User Group


pgsql-hackers by date:

Previous
From: Tomasz Ostrowski
Date:
Subject: Re: Spoofing as the postmaster
Next
From: Peter Eisentraut
Date:
Subject: Re: duplicate columns with COPY