Re: problem with plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pjb(at)informatimago(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: problem with plpgsql
Date: 2001-08-20 15:15:31
Message-ID: 8769.998320531@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Pascal Bourguignon <pjb(at)informatimago(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-08-20 15:25:42 Re: user authentication crash
Previous Message Tom Lane 2001-08-20 15:08:31 Re: user authentication crash