Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL - what does symbol ||| do?

I found such code:

SELECT 'a' ||| 'b';

I tried to google the meaning of this operator, but google ignores symbolic data. SymbolHound did not return any meaningful results.

I tested it one PostgreSQL 8.4 server and 9.1 server.

In PostgreSQL 8.4, it is same as string concatenation, with one difference:

SELECT 'a' ||| 'b'; -- 'ab'
SELECT 'a' || 'b'; -- 'ab'

SELECT 'a' ||| NULL; -- 'a'
SELECT 'a' || NULL; -- NULL

In PostgreSQL 9.1, this operator is not defined.

SELECT 'a' ||| 'b'; -- ERROR
SELECT 'a' || 'b'; -- 'ab'
SELECT 'a' || NULL; -- NULL

Is this officially documented somewhere? Is this configuration-specific?

like image 800
Rauni Lillemets Avatar asked Dec 27 '22 13:12

Rauni Lillemets


1 Answers

||| isn't a standard operator shipped with PostgreSQL; as you can see here, it doesn't exist in stock 8.4 either. I'd say someone installed it with CREATE OPERATOR in your 8.4 install.

Try using the psql command \do (ie "describe operators") in the 8.4 DB, or do a pg_dump and examine the dump for the definition of the operator and its associated function.

select * from pg_operator where oprname = '|||'; may also be useful. Note the oprcode column, which shows the function that implements the operator.

like image 78
Craig Ringer Avatar answered Dec 29 '22 12:12

Craig Ringer