Re: Boolean output format

From: Jeff Davis <list-pgsql-general(at)empires(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Boolean output format
Date: 2002-10-05 05:08:45
Message-ID: 200210042208.45827.list-pgsql-general@empires.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mario Weilguni 2002-10-05 06:31:05 Re: [HACKERS] Advice: Where could I be of help?
Previous Message Jeff Davis 2002-10-05 04:50:06 Re: Boolean output format