Re: || versus concat( ), diff behavior

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: c k <shreeseva(dot)learning(at)gmail(dot)com>
Cc: David Johnston <polobo(at)yahoo(dot)com>, Philip Couling <phil(at)pedal(dot)me(dot)uk>, david(dot)sahagian(at)emc(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: || versus concat( ), diff behavior
Date: 2012-03-04 20:11:45
Message-ID: 1914.1330891905@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

c k <shreeseva(dot)learning(at)gmail(dot)com> writes:
> what will be the reason for this?

The short answer is that || uses cast-to-text semantics, whereas concat
uses output-function semantics, and char(n) is one of the weird types
for which those are different. Don't blame us, blame the SQL committee.
Or rather than blaming anybody, stop using char(n); it's a badly
defined data type, and there are almost no cases where varchar or text
isn't preferable.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rory Campbell-Lange 2012-03-04 20:43:15 Re: Return unknown resultset from a function
Previous Message David Johnston 2012-03-04 20:00:24 Re: Return unknown resultset from a function