Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
Date
Msg-id CAKFQuwYiRGL=UoSyh5wxSF5pXWY2m6crtpOUH3qryKZX8UGG=g@mail.gmail.com
Whole thread Raw
In response to minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions  (jian he <jian.universality@gmail.com>)
Responses Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
List pgsql-hackers
On Thu, Jun 20, 2024 at 7:30 PM jian he <jian.universality@gmail.com> wrote:
"predicate check expressions return the single three-valued result of
the predicate: true, false, or unknown."
"unknown" is wrong, because `select 'unknown'::jsonb;` will fail.
here "unknown" should be "null"? see jsonb_path_query doc entry also.


The syntax for json_exists belies this claim (assuming our docs are accurate there).  Its "on error" options are true/false/unknown.  Additionally, the predicate test operator is named "is unknown" not "is null".

The result of the predicate test, which is never produced as a value, only a concept, is indeed "unknown" - which then devolves to false when it is practically applied to determining whether to output the path item being tested.  As it does also when used in a parth expression.

postgres=# select json_value('[null]','$[0] < 1');
 json_value
------------
 f

postgres=# select json_value('[null]','$[0] == null');
 json_value
------------
 t

Not sure how to peek inside the jsonpath system here though...

postgres=# select json_value('[null]','($[0] < 1) == null');
ERROR:  syntax error at or near "==" of jsonpath input
LINE 1: select json_value('[null]','($[0] < 1) == null');

I am curious if that produces true (the unknown is left as null) or false (the unknown becomes false immediately).       

David J.


pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: improve predefined roles documentation
Next
From: Tom Lane
Date:
Subject: Re: configure error when CFLAGS='-Wall -Werror