pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Unexpected zero results
Date: Wed, 23 Mar 2022 18:00:46 +0100
Message-ID: <0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net> (raw)
In-Reply-To: <CAO=iB8K_AJe-x7gZSCS+ndTAsE2XUj8+i7rP5UHxvUO6cMySBw@mail.gmail.com>
References: <CAO=iB8K_AJe-x7gZSCS+ndTAsE2XUj8+i7rP5UHxvUO6cMySBw@mail.gmail.com>

Viliam Ďurina schrieb am 23.03.2022 um 17:56:
> Hello all,
>
> I'm experimenting with JSON-path functions, and stumbled upon this query:
>
>    SELECT jsonb_path_query('[1,2,3]', '$[*]?(@ == 4)')
>
> It returns 0 rows. I expected it to return one row with `null` value.
> Isn't it the case that `SELECT <some expression>` should always
> return 1 row?

jsonb_path_query is a set returning function, so it's actually more like this:

     SELECT *
     FROM jsonb_path_query('[1,2,3]', '$[*]?(@ == 4)')

Then it's obvious why no row is returned.

That's one of the reasons I never use set-returning functions in the SELECT list.






view thread (5+ messages)  latest in thread

Message-ID: <0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net>
Permalink:  ../0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net/
Also on:    postgresql.org/message-id/0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: shammat@gmx.net
  Subject: Re: Unexpected zero results
  In-Reply-To: <0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net>
  References: <CAO=iB8K_AJe-x7gZSCS+ndTAsE2XUj8+i7rP5UHxvUO6cMySBw@mail.gmail.com> <0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox