Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
Date: 2024-06-21 03:11:02
Message-ID: CAKFQuwYiRGL=UoSyh5wxSF5pXWY2m6crtpOUH3qryKZX8UGG=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 20, 2024 at 7:30 PM jian he <jian(dot)universality(at)gmail(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-06-21 03:18:35 Re: configure error when CFLAGS='-Wall -Werror
Previous Message David G. Johnston 2024-06-21 02:57:16 Re: improve predefined roles documentation