Re: Minor difference in behavior between +/-

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ryan Murphy <ryanmurf(at)gmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Minor difference in behavior between +/-
Date: 2023-01-25 14:12:18
Message-ID: CAKFQuwZpDPkgwX8J46H23hYzN9ezdT5W3cQZA9z5rJgFVOSPjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tuesday, January 24, 2023, Ryan Murphy <ryanmurf(at)gmail(dot)com> wrote:

> SELECT NULL - date '2023-01-05';
> -> result is null
> SELECT NULL + date '2023-01-05';
> -> result is [42725] ERROR: operator is not unique: unknown + date Hint:
> Could not choose a best candidate operator. You might need to add explicit
> type casts. Position: 13
>
>
There is no bug here.

> I would expect both of those to be null.
>

I get why you expect that but we expend little to no effort to handle null
in a type agnostic way. Type inference has to happen first and regardless
of whether the literal is null. Type inference failed in the + case but
not the - case. That is just happenstance of what operators happen to
exist in the system.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2023-01-25 16:41:10 Re: BUG #17759: MERGE UPDATE statements do not cause generated columns to update
Previous Message Peter Bex 2023-01-25 12:29:11 Re: Unique constraint error instead of serialization_failure