Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRKvR-0007iQ-PJ for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Mar 2021 20:25:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRKvQ-00054n-Lz for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Mar 2021 20:25:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRKvQ-00054g-6R for pgsql-hackers@lists.postgresql.org; Tue, 30 Mar 2021 20:25:20 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRKvI-0007di-La for pgsql-hackers@postgresql.org; Tue, 30 Mar 2021 20:25:19 +0000 Received: from [192.168.0.105] (unknown [37.113.5.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id BF79F21C2C57; Tue, 30 Mar 2021 23:25:10 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1617135910; bh=JGyj1uHykdE4hPbjQh2X3nL9DvRpx/yoGy0dtVjuSrs=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=V+4Bh4SgbIkZFOIw9hatTsZnqet9a0wvSL6LRxeG1SBry/ExOPaeFvJZR8nEPDFUj oI2p1xyrPG7dLFopw0XwChnHU9qcO0innNdZ+c7TybmOopXyDAdDfFTsc40RH5Gt8C rqhqxkOlw39hj1kOTjkJsIyIpUfBTQmGgdViWotw= Subject: Re: SQL/JSON: JSON_TABLE To: Erik Rijkers , PostgreSQL-development Cc: Andrew Dunstan , David Steele , Michael Paquier , Justin Pryzby , Pavel Stehule , Robert Haas , Dmitry Dolgov <9erthalion6@gmail.com>, Oleg Bartunov , Andrew Dunstan , Zhihong Yu References: <20200705171558.GP4107@telsasoft.com> <20200803075558.GQ3317@paquier.xyz> <7e2cb85d-24cf-4abb-30a5-1a33715959bd@postgrespro.ru> <775a7d16-481c-978f-a6cf-29604a38102b@pgmasters.net> <1238462749.310979.1616791680679@webmailclassic.xs4all.nl> <2d8dcd2f-fe6e-bf31-a21a-90a843edfafc@postgrespro.ru> <2101814418.20240.1617123418368@webmailclassic.xs4all.nl> From: Nikita Glukhov Organization: Postgres Professional Message-ID: <69eefc5a-cabc-8dd3-c689-93da038c0d6a@postgrespro.ru> Date: Tue, 30 Mar 2021 23:25:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <2101814418.20240.1617123418368@webmailclassic.xs4all.nl> Content-Type: multipart/alternative; boundary="------------CD88F8DBFF385810F3147BFC" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------CD88F8DBFF385810F3147BFC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 30.03.2021 19:56, Erik Rijkers wrote: >> On 2021.03.27. 02:12 Nikita Glukhov wrote: >> >> Attached 47th version of the patches. > Hi, > > Apply, build all fine. It also works quite well, and according to specification, as far as I can tell. > > But today I ran into: > > ERROR: function ExecEvalJson not in llvmjit_types.c > > I think that it is caused by: > > set enable_bitmapscan = off; > > (I installed llvm a few days ago. llvm-3.9-dev on this debian stretch). > > > This is the test sql I concocted, which runs fine with enable_bitmapscan on (the default): > > select jt1.* > from myjsonfile100k as t(js, id) > , json_table( > t.js > , '$' columns ( > "lastname" text path '$. "lastname" ' > , "firstname" text path '$. "firstname" ' > , "date" text path '$. "date" ' > , "city" text path '$. "city" ' > , "country" text path '$. "country" ' > , "name 0(1)" text path '$. "array"[0] ' > , "name 4(5)" text path '$. "array"[4] ' > , "names" text[] path '$. "array" ' > , "randfloat" float path '$. "random float" ' > ) > ) as jt1 > where js @> ('[ { "city": "Santiago de Cuba" } ]') > and js[0]->>'firstname' = 'Gilda' > ; > ERROR: function ExecEvalJson not in llvmjit_types.c > > That statement only errors out if the table is large enough. I have no time now to make a sample table but if no-one understands the problem off-hand, I'll try to construct such a table later this week (the one I'm using is large, 1.5 GB). Thank you for testing. I think you can try to add 3 missing functions references to the end of src/backend/jit/llvm/llvmjit_types.c:  void       *referenced_functions[] = {      ...      ExecEvalXmlExpr, +    ExecEvalJsonConstructor, +    ExecEvalIsJsonPredicate, +    ExecEvalJson,      MakeExpandedObjectReadOnlyInternal,      ... }; If this fixes problem, I will add this to the new version of the patches. -- Nikita Glukhov Postgres Professional:http://www.postgrespro.co The Russian Postgres Company --------------CD88F8DBFF385810F3147BFC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 30.03.2021 19:56, Erik Rijkers wrote:

On 2021.03.27. 02:12 Nikita Glukhov <n.gluhov@postgrespro.ru> wrote:

Attached 47th version of the patches.
Hi,

Apply, build all fine.  It also works quite well, and according to specification, as far as I can tell.

But today I ran into:

ERROR:  function ExecEvalJson not in llvmjit_types.c

I think that it is caused by:

set enable_bitmapscan = off;

(I installed llvm a few days ago. llvm-3.9-dev on this debian stretch).


This is the test sql I concocted, which runs fine with enable_bitmapscan on (the default):

select jt1.* 
from myjsonfile100k as t(js, id) 
  , json_table(
      t.js
   , '$' columns (
        "lastname"   text    path  '$. "lastname"     '
      , "firstname"  text    path  '$. "firstname"    '
      , "date"       text    path  '$. "date"         '
      , "city"       text    path  '$. "city"         '
      , "country"    text    path  '$. "country"      '
      , "name 0(1)"  text    path  '$. "array"[0]     '
      , "name 4(5)"  text    path  '$. "array"[4]     '
      , "names"      text[]  path  '$. "array"        '
      , "randfloat"  float   path  '$. "random float" '
    )
) as jt1
where  js @> ('[ { "city": "Santiago de Cuba" } ]')
   and js[0]->>'firstname' = 'Gilda'
;
ERROR:  function ExecEvalJson not in llvmjit_types.c

That statement only errors out if the table is large enough. I have no time now to make a sample table but if no-one understands the problem off-hand, I'll try to construct such a table later this week (the one I'm using is large, 1.5 GB).
Thank you for testing. 


I think you can try to add 3 missing functions references to the end of 
src/backend/jit/llvm/llvmjit_types.c:
 void       *referenced_functions[] =
 {
     ...
     ExecEvalXmlExpr,
+    ExecEvalJsonConstructor,
+    ExecEvalIsJsonPredicate,
+    ExecEvalJson,
     MakeExpandedObjectReadOnlyInternal,
     ...
 };


If this fixes problem, I will add this to the new version of the patches.


-- 
Nikita Glukhov
Postgres Professional: http://www.postgrespro.co
The Russian Postgres Company
--------------CD88F8DBFF385810F3147BFC--