empty concatenate

From: Karel Zak - Zakkr <zakkr(at)zf(dot)jcu(dot)cz>
To: pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: empty concatenate
Date: 1999-12-23 15:20:23
Message-ID: Pine.LNX.3.96.991223152436.24288A-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

I try concatenate text via standard '||' oprerator, but result is
interesting:

PgSQL 6.5.3/7.0:
~~~~~~~~~~~~~~~
test=> select * from x;
a |b
---+---
AAA|BBB
xxx|
(2 rows)

test=> select a || b from x;
?column?
--------
AAABBB
<-------------- empty !
(2 rows)

Oracle8:
~~~~~~~~
SVRMGR> select * from x;
A B
-------------------------------- --------------------------------
AAA BBB
xxx
2 rows selected.
SVRMGR> select a || b from x;
A||B
----------------------------------------------------------------
AAABBB
xxx <---------------- not empty !
2 rows selected.

I fistly think that problem is in the textcat() routine, but PgSQL ignore
all functions's results if any argument (column) is empty. Example:

text *
xxx(text *t1, text *t2)
{
text *result;

result = (text *) palloc(10 + VARHDRSZ);
strcpy(VARDATA(result), "happy");
VARSIZE(result) = 5 + VARHDRSZ;
elog(NOTICE, "RETURN: %s", VARDATA(result));

return result; /* always return 'happy' */
}


test=> select * from x;
a |b
---+---
AAA|BBB
xxx|
(2 rows)

test=> select xxx(a, b) from x;
NOTICE: RETURN: happy
NOTICE: RETURN: happy
xxx
----
happy
<--------- empty ?!
(2 rows)

Why is it empty? I believe that is not feature :-)

Karel

PS. sorry, if this is old point, mail-list archive seacher (htdig)
not work...

----------------------------------------------------------------------
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> http://home.zf.jcu.cz/~zakkr/

Docs: http://docs.linux.cz (big docs archive)
Kim Project: http://home.zf.jcu.cz/~zakkr/kim/ (process manager)
FTP: ftp://ftp2.zf.jcu.cz/users/zakkr/ (C/ncurses/PgSQL)
-----------------------------------------------------------------------

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Karel Zak - Zakkr 1999-12-23 15:55:55 Re: [HACKERS] empty concatenate
Previous Message Keith Parks 1999-12-22 20:55:13 Re: [HACKERS] Non-group columns with aggregate functions