Re: problem with plpgsql - Mailing list pgsql-bugs

From Pascal Bourguignon
Subject Re: problem with plpgsql
Date
Msg-id 20010820155053.DAA3A5D327@thalassa.informatimago.com
Whole thread Raw
In response to Re: problem with plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
> Pascal Bourguignon <pjb@informatimago.com> writes:
> > I'm trying to  write a function to either insert a  new row, or update
> > an existing row. However, the test  "if not found" is always true,
>
> I believe you're getting burnt by the fact that lim.login is declared
> as char(8) --- so it has trailing blanks --- whereas the first parameter
> of lim_update is declared as text --- so it doesn't have trailing
> blanks.  What's more, the comparison login=plogin will be done under
> "text" rules wherein trailing blanks are significant.  So 'pjb' is not
> equal to 'pjb     '.
>
> The ip and mac columns have the same problem.
>
> Advice: don't use char(n) for data that's not really fixed-width.
>
>             regards, tom lane

Thank you very much. I overlooked that.


Changing the attributes type from char to varchar solves the problem.

create table lim (
    login     varchar(8),
    ip        varchar(15),
    mac       varchar(17),
    last_date date,
    logcnt    integer
);


--
__Pascal_Bourguignon__              (o_ Software patents are endangering
()  ASCII ribbon against html email //\ the computer industry all around
/\  and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100  2001:my($f)=`fortune`;  http://petition.eurolinux.org/

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++  UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: user authentication crash
Next
From: Andreas Wernitznig
Date:
Subject: Re: low performance