5

Reviewing some of the regression tests for PostgreSQL, I can see

SELECT x, x IS OF (text) AS is_text FROM q;

This apparently dates back to 7.3

Add IS OF / IS NOT OF type predicate (Thomas)

Is this form supported. In my own code, I would have written,

pg_typeof(x) = 'text'

But I like IS OF better.

1
  • I cannot find this in the docs, so I guess it's not really supported. Jul 27, 2017 at 14:03

1 Answer 1

2

It's not documented, yet, but it is certainly supported and should be moving forward. It's actually in the SQL 2011 spec as type predicate.

8.19 <type predicate>
Function
Specify a type test.

Format
<type predicate> ::=
<row value predicand> <type predicate part 2>

<type predicate part 2> ::=
IS [ NOT ] OF <left paren> <type list> <right paren>

<type list> ::=
<user-defined type specification>
[ { <comma> <user-defined type specification> }... ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.