bug report on text text fields. WAS: Re: [SQL] Trouble with ...

From: David Sauer <davids(at)orfinet(dot)cz>
To: "Glenn Waldron" <gwaldron(at)wareonearth(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: bug report on text text fields. WAS: Re: [SQL] Trouble with ...
Date: 1999-04-13 16:16:53
Message-ID: m2yajwsdfu.fsf@orfinet.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>> "Glenn" == Glenn Waldron <gwaldron(at)wareonearth(dot)com> writes:

Glenn> Using Postgres 6.5 beta (snap 12 apr), on Linux i386. I moved up from
Glenn> 6.4.2 when I couldn't get things working.

Glenn> I'm having difficulty dealing with null text/varchar fields. I need
Glenn> to be able to interpret null values as the null string '' for the
Glenn> purposes on concatenation.

Glenn> 1) ----
Glenn> For example, the query:

Glenn> SELECT (field_one || field_two) from t1;

Glenn> Will return the concatenation of the two fields. If either of the fields

Glenn> is null, it is interpreted as the empty string '' and the correct answer
Glenn> is printed.

Correct ?

I have a table:

david=> \d t
Table = t
+----------------------------------+----------------------------------+-------+| Field | Type | Length|+----------------------------------+----------------------------------+-------+| a | text | var || b | text | var |+----------------------------------+----------------------------------+-------+

david=> insert into t values (NULL, '1111');
INSERT 26656 1
david=> insert into t values ('2222', NULL);
INSERT 26657 1

david=> select a||b from t;
?column?
--------


(2 rows)

But I expect something like:
1111
2222

not 2 empty strings. It is wrong ?

================================================

And yet, I found bug in cast. Try on table above:
select a::int from t;

... this will crash backend on field with NULL value ....

I have postgres 6.5beta1 compiled by egcs-1.1.2 on linux box with
IBM 6x86L processor ...

--
* David Sauer, student of Czech Technical University
* electronic mail: davids(at)orfinet(dot)cz (mime compatible)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-04-13 23:31:11 Re: [SQL] subqueries
Previous Message José Soares 1999-04-13 16:07:53 Re: [SQL] Trouble with null text fields