Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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


pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group