bug on CHAR_LENGTH function ?

From: "Jose' Soares" <jose(at)sferacarta(dot)com>
To: pgsql-bugs(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: bug on CHAR_LENGTH function ?
Date: 1998-09-24 07:39:46
Message-ID: 3609F742.CED88739@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Seems that CHAR_LENGTH function has a bug.
It doesn't work if you try to have the length of columns with nulls.
Example:

insert into c values('foo');
insert into c values(NULL);
insert into c values('');

select b from c;
b
-------
foo
<-- this is a NULL
<-- this is a ''
(3 rows)

select char_length(b) from c;
ERROR: Bad (null) varchar() external representation

-- Why this error?
-- I think it should be:

length
------
3
<-- length of NULL should be "unknown" this is the behavior of
other databases
0
(3 rows)

What do you think about ?
Jose'

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 1998-09-24 08:55:50 Re: [HACKERS] SQL Triggers
Previous Message Thomas G. Lockhart 1998-09-24 06:03:56 Re: [HACKERS] pg_dump, problem with user defined types?