Обсуждение: boolean 't' 'f' vs. '1' '0' - perl question

Поиск
Список
Период
Сортировка

boolean 't' 'f' vs. '1' '0' - perl question

От
"Henrik Steffen"
Дата:
(excuse me, if it's a little off topic)

hello all,

I am just trying to (finally) upgrade from Pg.pm to
DBI (DBD::Pg) ...

I encounter the following problem:

Until today, Pg.pm delivered a 't' or a 'f' for
true or false boolean values.

Since the upgrade, DBI delivers a '1' or a '0'.

This is a problem for me, because of hundred thousands
lines of code containing many many comparisons in perl
like: if ($member eq "t") { foo; } -- which I really
don't fance to change one by one...

Question: Does anyone know if there's possibly a
parameter to set to tell DBI to deliver 't' and 'f'
instead of '1' and '0' ?

thanks,

happy new year ;-))

--

Mit freundlichem Gruß

Henrik Steffen
Geschäftsführer

top concepts Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - Germany
--------------------------------------------------------
http://www.topconcepts.com          Tel. +49 4141 991230
mail: steffen@topconcepts.com       Fax. +49 4141 991233
--------------------------------------------------------
24h-Support Hotline:  +49 1908 34697 (EUR 1.86/Min,topc)
--------------------------------------------------------
Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de
System-Partner gesucht: http://www.franchise.city-map.de
--------------------------------------------------------
Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563
--------------------------------------------------------


Re: boolean 't' 'f' vs. '1' '0' - perl question

От
"Peter Haworth"
Дата:
On Tue, 31 Dec 2002 15:18:08 +0100, Henrik Steffen wrote:
> I am just trying to (finally) upgrade from Pg.pm to
> DBI (DBD::Pg) ...
>
> Until today, Pg.pm delivered a 't' or a 'f' for
> true or false boolean values.
>
> Since the upgrade, DBI delivers a '1' or a '0'.
>
> Question: Does anyone know if there's possibly a
> parameter to set to tell DBI to deliver 't' and 'f'
> instead of '1' and '0' ?

Not in the current version. It looks like it should be easy enough to hack,
though. Just remove lines 1360-1362 of dbdimp.c:

            if (16 == type) {
               *val = (*val == 'f') ? '0' : '1'; /* bool: translate postgres into perl */
            }

This will probably mean that tests will fail, but looks harmless enough
otherwise.


--
    Peter Haworth    pmh@edison.ioppublishing.com
"I don't have to impress you.  And as you're an emacs weenie who
 doesn't even speak Martian Swahili, I would never expect to."
        -- Tom Christiansen

Re: boolean 't' 'f' vs. '1' '0' - perl question

От
"Henrik Steffen"
Дата:
thanks, this works fine for me ;-)

happy new year,


--

Mit freundlichem Gruß

Henrik Steffen
Geschäftsführer

top concepts Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - Germany
--------------------------------------------------------
http://www.topconcepts.com          Tel. +49 4141 991230
mail: steffen@topconcepts.com       Fax. +49 4141 991233
--------------------------------------------------------
24h-Support Hotline:  +49 1908 34697 (EUR 1.86/Min,topc)
--------------------------------------------------------
Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de
System-Partner gesucht: http://www.franchise.city-map.de
--------------------------------------------------------
Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563
--------------------------------------------------------

----- Original Message -----
From: "Peter Haworth" <pmh@edison.ioppublishing.com>
To: "Henrik Steffen" <steffen@city-map.de>; <pgsql-general@postgresql.org>
Sent: Tuesday, December 31, 2002 4:11 PM
Subject: Re: [GENERAL] boolean 't' 'f' vs. '1' '0' - perl question


> On Tue, 31 Dec 2002 15:18:08 +0100, Henrik Steffen wrote:
> > I am just trying to (finally) upgrade from Pg.pm to
> > DBI (DBD::Pg) ...
> >
> > Until today, Pg.pm delivered a 't' or a 'f' for
> > true or false boolean values.
> >
> > Since the upgrade, DBI delivers a '1' or a '0'.
> >
> > Question: Does anyone know if there's possibly a
> > parameter to set to tell DBI to deliver 't' and 'f'
> > instead of '1' and '0' ?
>
> Not in the current version. It looks like it should be easy enough to
hack,
> though. Just remove lines 1360-1362 of dbdimp.c:
>
>             if (16 == type) {
>                *val = (*val == 'f') ? '0' : '1'; /* bool: translate
postgres into perl */
>             }
>
> This will probably mean that tests will fail, but looks harmless enough
> otherwise.
>
>
> --
> Peter Haworth pmh@edison.ioppublishing.com
> "I don't have to impress you.  And as you're an emacs weenie who
>  doesn't even speak Martian Swahili, I would never expect to."
> -- Tom Christiansen


Re: boolean 't' 'f' vs. '1' '0' - perl question

От
Michael Teter
Дата:
With each successive release of DBD::Pg, you'll have
to go modify the module again...

Wouldn't it make more sense to modify your code to use
1/0 instead?

MT

--- Henrik Steffen <steffen@city-map.de> wrote:
> thanks, this works fine for me ;-)
>
> happy new year,
>
>
> --
>
> Mit freundlichem Gru�
>
> Henrik Steffen
> Gesch�ftsf�hrer
>
> top concepts Internetmarketing GmbH
> Am Steinkamp 7 - D-21684 Stade - Germany
>
--------------------------------------------------------
> http://www.topconcepts.com          Tel. +49 4141
> 991230
> mail: steffen@topconcepts.com       Fax. +49 4141
> 991233
>
--------------------------------------------------------
> 24h-Support Hotline:  +49 1908 34697 (EUR
> 1.86/Min,topc)
>
--------------------------------------------------------
> Ihr SMS-Gateway: JETZT NEU unter:
> http://sms.city-map.de
> System-Partner gesucht:
> http://www.franchise.city-map.de
>
--------------------------------------------------------
> Handelsregister: AG Stade HRB 5811 - UstId: DE
> 213645563
>
--------------------------------------------------------
>
> ----- Original Message -----
> From: "Peter Haworth" <pmh@edison.ioppublishing.com>
> To: "Henrik Steffen" <steffen@city-map.de>;
> <pgsql-general@postgresql.org>
> Sent: Tuesday, December 31, 2002 4:11 PM
> Subject: Re: [GENERAL] boolean 't' 'f' vs. '1' '0' -
> perl question
>
>
> > On Tue, 31 Dec 2002 15:18:08 +0100, Henrik Steffen
> wrote:
> > > I am just trying to (finally) upgrade from Pg.pm
> to
> > > DBI (DBD::Pg) ...
> > >
> > > Until today, Pg.pm delivered a 't' or a 'f' for
> > > true or false boolean values.
> > >
> > > Since the upgrade, DBI delivers a '1' or a '0'.
> > >
> > > Question: Does anyone know if there's possibly a
> > > parameter to set to tell DBI to deliver 't' and
> 'f'
> > > instead of '1' and '0' ?
> >
> > Not in the current version. It looks like it
> should be easy enough to
> hack,
> > though. Just remove lines 1360-1362 of dbdimp.c:
> >
> >             if (16 == type) {
> >                *val = (*val == 'f') ? '0' : '1';
> /* bool: translate
> postgres into perl */
> >             }
> >
> > This will probably mean that tests will fail, but
> looks harmless enough
> > otherwise.
> >
> >
> > --
> > Peter Haworth pmh@edison.ioppublishing.com
> > "I don't have to impress you.  And as you're an
> emacs weenie who
> >  doesn't even speak Martian Swahili, I would never
> expect to."
> > -- Tom Christiansen
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Re: boolean 't' 'f' vs. '1' '0' - perl question

От
"Peter Haworth"
Дата:
On Tue, 31 Dec 2002 08:34:54 -0800 (PST), Michael Teter wrote:
> With each successive release of DBD::Pg, you'll have to go modify the
> module again...

Well, I just sent in a patch which makes this behaviour switchable with
a database handle attribute, so maybe it'll be in the next version of
the driver.

--
    Peter Haworth    pmh@edison.ioppublishing.com
'As Annie Oakley almost said, "Anything you can do, I can do meta."'
        -- Larry Wall

Re: boolean 't' 'f' vs. '1' '0' - perl question

От
Michael Teter
Дата:
Very nice of you :)

I thought it, but didn't suggest it since I'm not
qualified to make such a change.

MT

--- Peter Haworth <pmh@edison.ioppublishing.com>
wrote:
> On Tue, 31 Dec 2002 08:34:54 -0800 (PST), Michael
> Teter wrote:
> > With each successive release of DBD::Pg, you'll
> have to go modify the
> > module again...
>
> Well, I just sent in a patch which makes this
> behaviour switchable with
> a database handle attribute, so maybe it'll be in
> the next version of
> the driver.
>
> --
>     Peter Haworth    pmh@edison.ioppublishing.com
> 'As Annie Oakley almost said, "Anything you can do,
> I can do meta."'
>         -- Larry Wall
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

help

От
Mohd Ghalib Akhtar
Дата:
how to connect html page to psql ?

=====
Take careMohd.Ghalib Akhtar(office)91-11-6152172,Ext-217
Fax : 91-11-6146217, 6149446
---------------------------------

---------------------------------


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Re: help

От
Lincoln Yeoh
Дата:
Why do you want to do that?

Can you explain more on what you are trying to do?

At 04:08 AM 1/1/03 -0800, Mohd Ghalib Akhtar wrote:

>how to connect html page to psql ?
>
>=====
>Take careMohd.Ghalib Akhtar(office)91-11-6152172,Ext-217
>Fax : 91-11-6146217, 6149446



Re: help

От
Medi Montaseri
Дата:
Try SSI (Server Side Include)...

I have feeling you mean something else....something like how do you
write a web (or HTML)
based application with PG backend.

Mohd Ghalib Akhtar wrote:

>how to connect html page to psql ?
>
>=====
>Take careMohd.Ghalib Akhtar(office)91-11-6152172,Ext-217
>Fax : 91-11-6146217, 6149446
>---------------------------------
>
>---------------------------------
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>