Re: Boolean output format - Mailing list pgsql-general

From Jeff Davis
Subject Re: Boolean output format
Date
Msg-id 200210042208.45827.list-pgsql-general@empires.org
Whole thread Raw
In response to Re: Boolean output format  (Garo Hussenjian <garo@xapnet.com>)
List pgsql-general
> I understand. I can implement a wrapper to convert bools, but I'd have to
> store the schema in my application. Using php, the database is the only
> place where types are actually known! I should check to see if Pear's DB
> object does any type-casting at run-time.

I suppose you could also have your application consult the catlogs rather than
store the schema in the app, but that's annoying as well (extra selects).

>
> I have thought about this as well. The user-defined types are extremely
> useful but they add additional (in this case undesirable) complexity. If we
> were talking about anything other than booleans, I would not be making this
> case in the first place.

True enough. Seems like what you want to do is very basic, so it's not
supposed to be hard.

>
> Is this because of processing overhead or other reasons? I'd argue that the
> boolean is an extremely important type, and just as (if not more) common as
> date and datetime, and it's certainly less complicated.

I was mostly wrong about this one, at least with respect to one developer who
also responded. Looks like I spoke too soon. You can read his post, for I
don't think now's the time for me to make another interpretation :)

>
> Now you've hit the root of the problem! I want to be able to forward and
> reverse engineer postgres and mysql schemas in php for a basic set of
> datatypes (varchar, int, decimal, boolean, date, datetime, and maybe a
> couple others). The problem with smallint is that I can translate boolean
> to smallint, but it doesn't work in reverse! This is mostly an
> interoperability concern.
>
> I have a database abstraction layer in my application that further
> generalizes my queries with some sql abstration... Right now the only
> difference between postgres and mysql is the return result of a native
> boolean.
>

I don't entirely understand what you mean, but it looks like you'd like to
easily be able to take data from MySQL and put it in PostgreSQL and vice
versa. Is there a problem with using smallint? PHP should be able to supply
an int to either database or retrieve the result as an int from either
database, right? I don't have a MySQL DB readily available, so I'm not 100%
sure how they handle booleans.

>
> I can understand the developers' desire for efficiency in the core. I
> should always be weighed against user needs. The answer, in this case, is
> unlikely to be a true or false... I'd never expect that the world could be
> as precise as our favorite database!

See above. I'd say the developers do a good job addressing users concerns, and
if they did reject a feature like you describe it would most certainly be for
a reason other than efficiency. Again, of course, I don't speak for the
developers.

Regards,
    Jeff Davis

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Boolean output format
Next
From: Mario Weilguni
Date:
Subject: Re: [HACKERS] Advice: Where could I be of help?