Re: problem with plpgsql - Mailing list pgsql-bugs

From Tom Lane
Subject Re: problem with plpgsql
Date
Msg-id 8769.998320531@sss.pgh.pa.us
Whole thread Raw
In response to problem with plpgsql  (Pascal Bourguignon <pjb@informatimago.com>)
Responses Re: problem with plpgsql  (Pascal Bourguignon <pjb@informatimago.com>)
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

pgsql-bugs by date:

Previous
From: Andreas Wernitznig
Date:
Subject: low performance
Next
From: grant
Date:
Subject: Re: low performance