text + text

Started by David Garamondover 21 years ago5 messagesgeneral
Jump to latest
#1David Garamond
lists@zara.6.isreserved.com

What is "text + text" supposed to do right now? It doesn't seem very
useful to me. What about making "text + text" as an equivalent for "text
|| text"? Most strongly-typed programming languages do this. And MS SQL
Server too, I think (CMIIW).

--
dave

#2Peter Eisentraut
peter_e@gmx.net
In reply to: David Garamond (#1)
Re: text + text

Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond:

What is "text + text" supposed to do right now?

Nothing.

What about making "text + text" as an equivalent for "text
|| text"? Most strongly-typed programming languages do this. And MS SQL
Server too, I think (CMIIW).

What would this gain except for bloat? It's not like SQL is utterly
compatible with any programming language; users will still have to learn all
the operators anyway.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3David Garamond
lists@zara.6.isreserved.com
In reply to: Peter Eisentraut (#2)
Re: text + text

Peter Eisentraut wrote:

What is "text + text" supposed to do right now?

Nothing.

Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly,
the current behaviour is quite strange to me.

------------------
=# select coalesce('1'+'0','NULL');
a
=# select coalesce('1'+'1','NULL');
b
=# select coalesce('1'+'3','NULL');
d
=# select coalesce('a'+'0','NULL');

=# select coalesce('a'+'1','NULL');

=# select coalesce('a'+'3','NULL');

=# select coalesce('a'+'x','NULL');
�
------------------

What about making "text + text" as an equivalent for "text
|| text"? Most strongly-typed programming languages do this. And MS SQL
Server too, I think (CMIIW).

What would this gain except for bloat? It's not like SQL is utterly
compatible with any programming language; users will still have to learn all
the operators anyway.

I personally don't consider this "bloat". We already have other synonyms
like '!=' and '<>'. '+' is very natural to mean concatenation for strings.

Anyway, either emitting an error or string concatenation is better than
the current behaviour, I think.

--
dave

#4Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: David Garamond (#3)
Re: text + text

On Fri, 8 Oct 2004, David Garamond wrote:

Peter Eisentraut wrote:

What is "text + text" supposed to do right now?

Nothing.

Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly,
the current behaviour is quite strange to me.

------------------
=# select coalesce('1'+'0','NULL');
a

That isn't text+text. It's "char"+"char". "char" is a rather bizarre type
being partially 1 byte integer and partially 1 character string and it
causes strange behaviors like the above where I believe it's taking the
first bytes of the '1' and '0' and adding them together. I think Tom was
talking about removing the math operators from it so that things like the
above don't happen.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Garamond (#3)
Re: text + text

David Garamond <lists@zara.6.isreserved.com> writes:

Peter Eisentraut wrote:

What is "text + text" supposed to do right now?

Nothing.

Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly,
the current behaviour is quite strange to me.

CVS tip gives

regression=# select coalesce('1'+'0','NULL');
ERROR: operator is not unique: "unknown" + "unknown"
HINT: Could not choose a best candidate operator. You may need to add explicit type casts.
regression=#

See http://archives.postgresql.org/pgsql-hackers/2004-10/msg00041.php

regards, tom lane