HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Use PostgreSQL builtin operator <@ after including extension intarray

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlafteroperatorintarrayextensionbuiltinincludinguse

Problem

I added the intarray extension to my PostgreSQL database in order to make use of the - operator, but I still want to use the builtin <@ operator, not intarray's <@ operator. Is there a way to do this?

The reason to prefer the builtin operator is that the builtin operator allows NULL values in the array in question, whereas the intarray operator raises an error in the event of a NULL value.

Solution

If you installed the intarray extension to the public schema (or some schema other than pg_catalog), you can schema-qualify the operator to choose the built-in one.

Instead of

a <@ b


you can write

a OPERATOR(pg_catalog.<@) b


to schema-qualify it.

e.g.

test=# SELECT 1 OPERATOR(pg_catalog.+) 2;
 ?column? 
----------
        3
(1 row)

Code Snippets

a OPERATOR(pg_catalog.<@) b
test=# SELECT 1 OPERATOR(pg_catalog.+) 2;
 ?column? 
----------
        3
(1 row)

Context

StackExchange Database Administrators Q#110599, answer score: 3

Revisions (0)

No revisions yet.