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

Поиск
Список
Период
Сортировка
От David Sauer
Тема bug report on text text fields. WAS: Re: [SQL] Trouble with ...
Дата
Msg-id m2yajwsdfu.fsf@orfinet.cz
обсуждение исходный текст
Ответ на Trouble with null text fields  ("Glenn Waldron" <gwaldron@wareonearth.com>)
Список pgsql-sql
>>>> "Glenn" == Glenn Waldron <gwaldron@wareonearth.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
thingsworking.
 
   Glenn> I'm having difficulty dealing with null text/varchar fields.  I need   Glenn> to be able to interpret null
valuesas 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@orfinet.cz (mime compatible)


В списке pgsql-sql по дате отправления:

Предыдущее
От: José Soares
Дата:
Сообщение: Re: [SQL] Trouble with null text fields
Следующее
От: Walt Bigelow
Дата:
Сообщение: Re: [SQL] subqueries