Re: remaining sql/json patches

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: remaining sql/json patches
Date: 2023-09-21 08:32:01
Message-ID: CA+HiwqE38o73m78Xvf8Lzt2X5O9vfhj2fNxNg+tCotoQ_xwz3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 21, 2023 at 4:14 AM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> On 2023-09-19 Tu 23:07, Amit Langote wrote:
> On Tue, Sep 19, 2023 at 9:00 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> On Tue, Sep 19, 2023 at 7:37 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> -------------------
> https://www.postgresql.org/docs/current/extend-type-system.html#EXTEND-TYPES-POLYMORPHIC
>
> When the return value of a function is declared as a polymorphic type, there must be at least one argument position that is also
> polymorphic, and the actual data type(s) supplied for the polymorphic arguments determine the actual result type for that call.
>
> select json_query(jsonb'{"a":[{"a":[2,3]},{"a":[4,5]}]}','$.a[*].a?(@<=3)'
> returning anyrange);
> should fail. Now it returns NULL. Maybe we can validate it in
> transformJsonFuncExpr?
> -------------------
>
> I'm not sure whether we should make the parser complain about the
> weird types being specified in RETURNING.
>
> Sleeping over this, maybe adding the following to
> transformJsonOutput() does make sense?
>
> + if (get_typtype(ret->typid) == TYPTYPE_PSEUDO)
> + ereport(ERROR,
> + errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> + errmsg("returning pseudo-types is not supported in
> SQL/JSON functions"));
> +
>
> Seems reasonable.

OK, thanks for confirming.

Here is a set where I've included the above change in 0003.

I had some doubts about the following bit in 0001 but I've come to
know through some googling that LLVM handles this alright:

+/*
+ * Emit constant oid.
+ */
+static inline LLVMValueRef
+l_oid_const(Oid i)
+{
+ return LLVMConstInt(LLVMInt32Type(), i, false);
+}
+

The doubt I had was whether the Oid that l_oid_const() takes, which is
an unsigned int, might overflow the integer that LLVM provides through
LLVMConstInt() here. Apparently, LLVM IR always uses the full 32-bit
width to store the integer value, so there's no worry of the overflow
if I'm understanding this correctly.

Patches 0001 and 0002 look ready to me to go in. Please let me know
if anyone thinks otherwise.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v18-0002-Add-soft-error-handling-to-populate_record_field.patch application/octet-stream 22.8 KB
v18-0005-Claim-SQL-standard-compliance-for-SQL-JSON-featu.patch application/octet-stream 2.3 KB
v18-0001-Add-soft-error-handling-during-CoerceViaIO-evalu.patch application/octet-stream 15.1 KB
v18-0004-JSON_TABLE.patch application/octet-stream 170.8 KB
v18-0003-SQL-JSON-query-functions.patch application/octet-stream 204.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-09-21 08:57:54 Re: remaining sql/json patches
Previous Message Maxim Orlov 2023-09-21 08:29:48 Re: should frontend tools use syncfs() ?