Re: [GENERAL] char(xx) problem

Lists: pgsql-general
From: "Gene Selkov, Jr(dot)" <selkovjr(at)mcs(dot)anl(dot)gov>
To: "Nikolay Mijaylov" <nmmm(at)nmmm(dot)nu>
Cc: "pgsql-general" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] char(xx) problem
Date: 1999-12-17 02:02:45
Message-ID: 199912170100.TAA11338@mail.xnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> Hi
> we have two servers with installed Linux and PostGreSQL. They are quite
> same. One is for development (Linux 2.2.9; 128 MB RAM; very overloaded with
> processes), another for real HTTP serving in Internet (Linux 2.2.9; 64 MB
> RAM; only http and pgsql)
>
> In one of projects we had two tables:
>
> create table a(
> x char(2)
> );
>
> create table b(
> y char(3)
> );
>
> When we try to execute SQL like this:
>
> select * from a, b
> where a.x = b.y;
>
> one of servers selects 5-6 records (e.g. all mached records)
> another selects empty table.
>
> The database is one and same.

What are the versions of pg?

I have similar experience. I used to routinely join on char() and
text, or on char() attributes of different length. Can't do that
anymore. Not sure when the change occurred -- some time between 6.3
and 6.5. The problem is I beleive related to blank padding: it formerly
showed through only in selects, now it affects comparison as well.

I'm just wondering: are there any alternatives to blank padding? Why
is it done in the first place?

--Gene


From: "Nikolay Mijaylov" <nmmm(at)nmmm(dot)nu>
To: "Gene Selkov, Jr(dot)" <selkovjr(at)mcs(dot)anl(dot)gov>
Cc: "pgsql-general" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] char(xx) problem
Date: 1999-12-17 07:19:54
Message-ID: 002501bf485f$3f5fd000$ce2a18c3@skillbrokers.bg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Sorry PG is 6.4.2
--------------------------------------------------------------
The reboots are for hardware upgrades!
"http://www.nmmm.nu; <nmmm(at)nmmm(dot)nu>

----- Original Message -----
From: Gene Selkov, Jr. <selkovjr(at)mcs(dot)anl(dot)gov>
To: Nikolay Mijaylov <nmmm(at)nmmm(dot)nu>
Cc: pgsql-general <pgsql-general(at)postgreSQL(dot)org>
Sent: петък, Декември 17, 1999 04:02
Subject: Re: [GENERAL] char(xx) problem

> > Hi
> > we have two servers with installed Linux and PostGreSQL. They are quite
> > same. One is for development (Linux 2.2.9; 128 MB RAM; very overloaded
with
> > processes), another for real HTTP serving in Internet (Linux 2.2.9; 64
MB
> > RAM; only http and pgsql)
> >
> > In one of projects we had two tables:
> >
> > create table a(
> > x char(2)
> > );
> >
> > create table b(
> > y char(3)
> > );
> >
> > When we try to execute SQL like this:
> >
> > select * from a, b
> > where a.x = b.y;
> >
> > one of servers selects 5-6 records (e.g. all mached records)
> > another selects empty table.
> >
> > The database is one and same.
>
> What are the versions of pg?
>
> I have similar experience. I used to routinely join on char() and
> text, or on char() attributes of different length. Can't do that
> anymore. Not sure when the change occurred -- some time between 6.3
> and 6.5. The problem is I beleive related to blank padding: it formerly
> showed through only in selects, now it affects comparison as well.
>
> I'm just wondering: are there any alternatives to blank padding? Why
> is it done in the first place?
>
> --Gene
>
> ************


From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "pgsql-general" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] char(xx) problem
Date: 1999-12-21 12:08:50
Message-ID: l03130301b4851b846903@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

At 4:02 +0200 on 17/12/1999, Gene Selkov, Jr. wrote:

> I'm just wondering: are there any alternatives to blank padding? Why
> is it done in the first place?

That's how fixed-length char type works, since the early days of SQL. You
come to expect it, which means that if you use legacy code that has a
fixed-width char type, or you decided to use it for its time-saving
possibilities, it should behave according to some way which has been
established long ago.

What I don't get is why, given two bpchar argument, Postgres doesn't just
pad the shorter one to the length of the other and then compares, selects
and whatnot.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herouth/personal/