David Rowley writes:
> On Sat, 9 Mar 2019 at 01:25, Artur Zając wrote:
>> CREATE OR REPLACE FUNCTION smarteq(v1 int,v2 INT) RETURNS BOOL AS
>> $BODY$
>> SELECT (CASE WHEN v2 IS NULL THEN (v1 IS NULL) ELSE v1=v2 END);
>> $BODY$ LANGUAGE 'sql' IMMUTABLE PARALLEL SAFE;
> The transformation mentione
On Sat, 9 Mar 2019 at 01:25, Artur Zając wrote:
> I made some workaround. I made function:
>
> CREATE OR REPLACE FUNCTION smarteq(v1 int,v2 INT) RETURNS BOOL AS
> $BODY$
> SELECT (CASE WHEN v2 IS NULL THEN (v1 IS NULL) ELSE v1=v2 END);
> $BODY$ LANGUAGE 'sql' IMMUTABLE PARALLEL SAFE;
> ex
> In short, probably possible, but why not just write an equality clause, if
> you know NULLs are not possible?
In fact I construct query like this (usually in pl/pgsql).
SELECT column FROM table WHERE column1 IS NOT DISTINCT FROM $1 AND column2 IS
NOT DISTINCT FROM $2;
"IS N
On Sat, 9 Mar 2019 at 00:30, Artur Zając wrote:
> Is there any reason that „NOT DISTINCT FROM” can’t be autotransformed to „=”
> when value on right side of expression is not NULL or is this any way to use
> index with „IS NOT DISTINCT FROM” statement?
Probably nothing other than n
Artur Zając wrote:
> Is there any reason that „NOT DISTINCT FROM” can’t be autotransformed to „=”
> when value
> on right side of expression is not NULL or is this any way to use index with
> „IS NOT DISTINCT FROM” statement?
That would subtly change the semantics of the expre
ime: 0.101 ms
(4 rows)
There is unique index on sometable(fkey);
Is there any reason that "NOT DISTINCT FROM" can't be autotransformed to "="
when value on right side of expression is not NULL or is this any way to use
index with "IS NOT DISTINCT FROM" statement?
Artur Zajac