Bug #862: strange select results

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #862: strange select results
Date: 2003-01-02 10:58:27
Message-ID: 20030102105827.0AE43475A9E@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Krzysztof Wonica (kw(at)b3(dot)4it(dot)pl) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
strange select results

Long Description
I have created an view. When I select fields separately all looks ok but when I try to select 3 fields for concatention (f1 || f2 || f3) the resul is empty when f3 is empty. I think it is not expected bahaviour.

Sample Code
the view:
SELECT person.id, person.sex, person.salutation, person.firstname, person.secondname, person.lastname, person.birthday, person.number, person.nip, (SELECT ((((((((address.street || ' '::text) || btrim((address.building)::text, ' '::text)) || '/'::text) || btrim((address.apartament)::text, ' '::text)) || ', '::text) || address.city) || ', '::text) || (address.country)::text) FROM address WHERE (((address.personid = person.id) AND (((address.fromdate < '2003-01-02'::date) OR (address.todate IS NULL)) AND ((address.todate > '2003-01-02'::date) OR (address.todate IS NULL)))) AND (address."primary" = 't'::bool)) LIMIT 1) AS address, (SELECT contact.howto FROM contact WHERE (((contact.personid = person.id) AND ((contact."type" = 'cel'::bpchar) OR (contact."type" = 'pho'::bpchar))) AND (((contact.fromdate < '2003-01-02'::date) OR (contact.fromdate IS NULL)) AND ((contact.todate > '2003-01-02'::date) OR (contact.todate IS NULL)))) LIMIT 1) AS phone, (SELECT contact.howto FROM contact
WHERE (((contact.personid = person.id) AND (contact."type" = 'eml'::bpchar)) AND (((contact.fromdate < '2003-01-02'::date) OR (contact.fromdate IS NULL)) AND ((contact.todate > '2003-01-02'::date) OR (contact.todate IS NULL)))) LIMIT 1) AS email FROM person;

forvhost=# select id, lastname, address from person_list;
id | lastname | address
-----+---------------------------------------+--------------------------------
2 | KKKKKKK |
1 | WWWWW |
92 | JJJJJJJJ | Kj Ji 1/1, Radom, PL
93 | KAZKAZ |
94 | 4IT S.A. |
96 | Kowalski |
(6 rows)

forvhost=# select id, (lastname || '; ' || (address)::text)::text from person_list;
id | text
-----+--------------------------------------------
2 |
1 |
92 | JJJJJJJJ; Kj Ji 1/1, Radom, PL
93 |
94 |
96 |
(6 rows)

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-01-02 14:31:12 Re: Bug #862: strange select results
Previous Message Tom Lane 2003-01-01 19:42:00 Re: Bug #861: postgresql fails to build on FreeBSD/sparc64