Search Postgresql Archives

Surprising results from array concatenation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The docs (section 9.18 for PG 9.6) show as an example for array concatenation

ARRAY[4,5,6] || 7

which works fine.  However, trying the same with an array of text doesn't work:

# select array['a','b','c'] || 'd';
ERROR:  malformed array literal: "d"
LINE 1: select array['a','b','c'] || 'd';
                                     ^
DETAIL:  Array value must start with "{" or dimension information.

Casting the second value to TEXT works.

# select array['a','b','c'] || 'd'::TEXT;
 ?column?  
-----------
 {a,b,c,d}
(1 row)

The assumption that the second argument is an array constant seems surprising.

__________________________________________________________________________________
Mike Blackwell | Technical Analyst, Distribution Services/Rollout Management | RRD
1750 Wallace Ave | St Charles, IL 60174-3401
Office: 630.313.7818
Mike.Blackwell@xxxxxxx
http://www.rrdonnelley.com



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux