Cast Operator Precedence

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Hackers Pg <pgsql-hackers(at)postgresql(dot)org>
Subject: Cast Operator Precedence
Date: 2012-09-11 23:23:35
Message-ID: 2982FC68-BED4-421E-91FD-F725CA769755@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers,

I found this surprising:

david=# CREATE DOMAIN STATUS AS INTEGER CHECK ( VALUE IN (1, 2, 3) );
CREATE DOMAIN

david=# select -4::status;
ERROR: value for domain status violates check constraint "status_check"

david=# select -1::status;
?column?
----------
-1
(1 row)

david=# select (-1)::status;
ERROR: value for domain status violates check constraint "status_check"

So I guess the precedence of :: is higher than -?

Thanks,

David

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-09-11 23:39:29 Re: Cast Operator Precedence
Previous Message Bruce Momjian 2012-09-11 21:13:35 Re: Draft release notes complete