Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1riESw-00FsBE-1t for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 14:11:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1riESu-005icZ-Jf for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 14:11:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1riESu-005icR-8b for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2024 14:11:20 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1riESr-003Gv1-58 for pgsql-hackers@postgresql.org; Thu, 07 Mar 2024 14:11:20 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso688658a12.3 for ; Thu, 07 Mar 2024 06:11:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709820675; x=1710425475; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dvMmx7oUnBR+ZLv2gSfulVmmGGrNZ1+rcYuZw7qbCCc=; b=Pcihvfm/vbMjTr/itye7U/0DI1t0cuMq5SZ1iWlcL7bGDqjyCmjOTPcq/te8IYQmAP TeQE4Cxc1lFIMG24Sg4cov8fSFRiU9UPdbJfqK4tNrarsLShLM0hePHPXlrxgEVIh/cg argZT9ZPeIg5svtqlzTiwsRwKHfq1e2cFow5g/IcqRsrE8/zXhqC4XDrX+4/gdyErbFu v02VXfbmB/hFgwlaiRTernxmO5dJWRN/L8H4QlU2Py52oerNi81D4feKW/xESaDqFZLk VeG8fVANXOXiUNUSZ97pY+szzx/zXqXXPOHYpwJwIwJOroH41SoqGBGSorrR9h9B4M0C xMpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709820675; x=1710425475; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dvMmx7oUnBR+ZLv2gSfulVmmGGrNZ1+rcYuZw7qbCCc=; b=NwM8vjhcNeh6XFsX59aOlBaIIQpYELZxCt2FZdHsrW8C21bFFCSRJeMwfCa9xV7MVX FJwdDKZypekp+XucDP7nsDD9mG8yBsAMrMLFORKdTwj7cSZWhStDj6hIfkTf4ok9mdUB JESir2zKTHDgz0XymUKD7/LeCLgqj8SdMwKoomnW2HTuYo9+MC8yYmHCAPt5qX58LMv3 eZNos8ZNIL8zj+sY8VtJhlLsyknRreddrpkst18wqIwxLlH5S3LTc/to7eSn+SzgibY0 A5NpSnMPicnf+Cs3iT33NvY1mmYSPPxlu3KThscNrPrWe4tEZ7S6+IBcIkXDLkoZxYaB hADw== X-Forwarded-Encrypted: i=1; AJvYcCV/ibwiAHWxU4tWm7b0sJCWh9guKiDlbPzaU4rbB98R9XNr9/afP3iKCwQWcAaGIjfUy7lrAz/yTynDiW2mFimFligNK3Lv2Zw1WqWr X-Gm-Message-State: AOJu0YyuFKqCyg6Pv0u0hQeMmXaf0NfUUgGXuj+y+h9HfZztvyDLbm+Y kW6sb/UqXO3YRd6lOqNEfJGjZPlUswfXZN3BRHoD/D8s08JIx5XddE0fpyR2BRhWJgb2rXRt/L4 YtTzeoCAbU4NHupMBs4+jasCDUiA= X-Google-Smtp-Source: AGHT+IGKMSevKhwA6M5iDVcphzK0xOiDv4o9Zz0p01eTUh4161b+cGA1GkDz2Y/r7PKczkM5psmN50GR5RJrGEnAZiU= X-Received: by 2002:a17:90a:1049:b0:29a:264b:8853 with SMTP id y9-20020a17090a104900b0029a264b8853mr15459411pjd.12.1709820675021; Thu, 07 Mar 2024 06:11:15 -0800 (PST) MIME-Version: 1.0 References: <1cee81f3-312f-30e3-0282-c4df7ee72f93@xs4all.nl> <202403041503.5momp6knupgo@alvherre.pgsql> <562e5ad9-1357-4752-ad28-7e56740f74f8@enterprisedb.com> In-Reply-To: From: Amit Langote Date: Thu, 7 Mar 2024 23:11:03 +0900 Message-ID: Subject: Re: remaining sql/json patches To: jian he Cc: Alvaro Herrera , Andres Freund , Andrew Dunstan , Erik Rijkers , Himanshu Upadhyaya , PostgreSQL-development , Tomas Vondra Content-Type: multipart/alternative; boundary="000000000000f6f222061312a5fa" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f6f222061312a5fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 7, 2024 at 22:46 jian he wrote: > On Thu, Mar 7, 2024 at 8:06=E2=80=AFPM Amit Langote > wrote: > > > > > > Indeed. > > > > This boils down to the difference in the cast expression chosen to > > convert the source value to int in the two cases. > > > > The case where the source value has no quotes, the chosen cast > > expression is a FuncExpr for function numeric_int4(), which has no way > > to suppress errors. When the source value has quotes, the cast > > expression is a CoerceViaIO expression, which can suppress the error. > > The default behavior is to suppress the error and return NULL, so the > > correct behavior is when the source value has quotes. > > > > I think we'll need either: > > > > * fix the code in 0001 to avoid getting numeric_int4() in this case, > > and generally cast functions that don't have soft-error handling > > support, in favor of using IO coercion. > > * fix FuncExpr (like CoerceViaIO) to respect SQL/JSON's request to > > suppress errors and fix downstream functions like numeric_int4() to > > comply by handling errors softly. > > > > I'm inclined to go with the 1st option as we already have the > > infrastructure in place -- input functions can all handle errors > > softly. > > not sure this is the right way. > but attached patches solved this problem. > > Also, can you share the previous memory-hogging bug issue > when you are free, I want to know which part I am missing..... Take a look at the json_populate_type() call in ExecEvalJsonCoercion() or specifically compare the new way of passing its void *cache parameter with the earlier patches. > --000000000000f6f222061312a5fa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Mar 7, 2024 at 22:46 jian he <jian.universality@gmail.com> wrote:
=
On Thu, Mar 7, 2024 at 8:06=E2= =80=AFPM Amit Langote <amitlangote09@gmail.com> wrote:
>
>
> Indeed.
>
> This boils down to the difference in the cast expression chosen to
> convert the source value to int in the two cases.
>
> The case where the source value has no quotes, the chosen cast
> expression is a FuncExpr for function numeric_int4(), which has no way=
> to suppress errors.=C2=A0 When the source value has quotes, the cast > expression is a CoerceViaIO expression, which can suppress the error.<= br> > The default behavior is to suppress the error and return NULL, so the<= br> > correct behavior is when the source value has quotes.
>
> I think we'll need either:
>
> * fix the code in 0001 to avoid getting numeric_int4() in this case, > and generally cast functions that don't have soft-error handling > support, in favor of using IO coercion.
> * fix FuncExpr (like CoerceViaIO) to respect SQL/JSON's request to=
> suppress errors and fix downstream functions like numeric_int4() to > comply by handling errors softly.
>
> I'm inclined to go with the 1st option as we already have the
> infrastructure in place -- input functions can all handle errors
> softly.

not sure this is the right way.
but attached patches solved this problem.

Also, can you share the previous memory-hogging bug issue
when you are free, I want to know which part I am missing.....
=

Take a look at the json_popul= ate_type() call in ExecEvalJsonCoercion() or specifically compare the new w= ay of passing its void *cache parameter with the earlier patches.
--000000000000f6f222061312a5fa--