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 1qdmWQ-004iqo-Oi for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Sep 2023 07:00:18 +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 1qdmWP-007c8k-59 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Sep 2023 07:00:16 +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 1qdmWO-007c8W-PY for pgsql-hackers@lists.postgresql.org; Wed, 06 Sep 2023 07:00:16 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qdmWL-003MYS-4x for pgsql-hackers@postgresql.org; Wed, 06 Sep 2023 07:00:15 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3a5a7e7cd61so351503b6e.0 for ; Wed, 06 Sep 2023 00:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693983611; x=1694588411; 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=kvVOA8IIEWMaSAGCoQcj/jjALJ9vI2tOT9m49VUI9fE=; b=GrvCmwnC4P5nsKe9rHVoB6khAgimSOyHcr3e+T/P+2bfPhGCwIbOFOZHLJpwNvOHE8 I/3NYWdzt5CffJFEQigOojrbU0Yylt1XZKN8HHCtSw3AOkgnozz/nqPU7OSJxCxxq5ze oIy608OEObLY0q4H/DCCeEqDHIJ/f1z1tp4d++SOh/R4+ZTDpX0s/54yVZ0NnPLfVM2D 9MMLzKD4ka+5ovgGDJ3aK5XvDrEpLkXMT16tKvR0KWQnl8sPtcdiLU98OGHjnsntxNrR yRoxoS/88Ngimoz9+P5vnzVyQJbcfmnrXvccglwWoWTm9DWDVtHsyF88ZXvAGWsxMJF+ Cl8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693983611; x=1694588411; 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=kvVOA8IIEWMaSAGCoQcj/jjALJ9vI2tOT9m49VUI9fE=; b=VetUmWK09DgBv0c1IAb2WkssJWz0oMI09qDuAeOjZpRAztkMpSj7LgIQfaAruHp9tB 6P9oCkYXsZZM+IP7zZ99PIbpwoJmWVm9kbpi76aYoaoG9jOn1AYo9O6pS6WRcxe7w1kS tQtpBAnytpLvsrg+JsrcRx66Ioj8m/uuWfTWl8YOkG/ADsT6wVNNMhHExAuaLb9uPk+2 /DE/pyq3E7zlA8mFdx2X6yntMtf1Ve2WDNvZdyvMTdKNksdhuTsTZoymJpBnkf1GTLf6 LU29TasF2qRDMVIQWBSxDuio5tOZufekavePJbL0VvqvhmUtlVmhR9+2JAHvW9ohQ6DU vHeg== X-Gm-Message-State: AOJu0YxpqDSI6/lDdjdvBBHThDHy/YH8tWymE5lx2uICmFVG9l2ra2kP ZITOOII0Ydv1Nc1TmcinBQIys7LNAQRUQQlUl6k= X-Google-Smtp-Source: AGHT+IHTzJDsHpe5TgW9Apr1iJu4grcAkweZ5b5suJRsKOpVJFk4v4YQ6oQ+g+a56gOZLk2YqjMEdS70k2DOHAAYuIg= X-Received: by 2002:a05:6808:10c6:b0:3a8:3d2f:347e with SMTP id s6-20020a05680810c600b003a83d2f347emr11373342ois.20.1693983611589; Wed, 06 Sep 2023 00:00:11 -0700 (PDT) MIME-Version: 1.0 References: <3507485.1691090027@sss.pgh.pa.us> <900892914fdc3f477b101d699efb40e0@anastigmatix.net> <903341.1692022214@sss.pgh.pa.us> <4b97f1a1dd9b6e45443d24870d3be698@anastigmatix.net> <111272f2dc112c7becdd35ad89f6b935@anastigmatix.net> <5138c6b5fd239e7ce4e1a4e63826ac27@anastigmatix.net> <369543439e988ae43f0a6307500b27c4@anastigmatix.net> <5955e93347a7e3b1612cf7e129ae6d04@anastigmatix.net> In-Reply-To: From: Andy Fan Date: Wed, 6 Sep 2023 15:00:00 +0800 Message-ID: Subject: Re: Extract numeric filed in JSONB more effectively To: jian he Cc: Chapman Flack , Pavel Stehule , Tom Lane , pgsql-hackers Content-Type: multipart/alternative; boundary="0000000000006c9ba00604ab4b9a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006c9ba00604ab4b9a Content-Type: text/plain; charset="UTF-8" > > > based on v13. > IMHO, it might be a good idea to write some comments on > jsonb_object_field_internal. especially the second boolean argument. > something like "some case, we just want return JsonbValue rather than > Jsonb. to return JsonbValue, make as_jsonb be false". > OK, I will proposal "return a JsonbValue when as_jsonb is false". > I am not sure "jsonb_object_field_start" is a good name, so far I only > come up with "jsonb_object_field_to_jsonbvalues". Yes, I think it is a good idea. Puting the jsonbvalue in the name can compensate for the imprecision of "internal" as a return type. I am thinking if we should rename jsonb_finish_numeric to jsonbvalue_to_numeric as well. > linitial(jsonb_start_func->args) = > makeRelabelType(linitial(jsonb_start_func->args), > INTERNALOID, 0, > InvalidOid, > COERCE_IMPLICIT_CAST); > > if no need, output typmod (usually -1), so here should be -1 rather than 0? I agree. -1 is better than 0. Thanks for the code level review again! I want to wait for some longer time to gather more feedback. I'm willing to name it better, but hope I didn't rename it to A and rename it back shortly. -- Best Regards Andy Fan --0000000000006c9ba00604ab4b9a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

based on v13.
IMHO, it might be a good idea to write some comments on
jsonb_object_field_internal. especially the second boolean argument.
something like "some case, we just want return JsonbValue rather than<= br> Jsonb. to return JsonbValue, make as_jsonb be false".
=

OK,=C2=A0 I will=C2=A0proposal=C2=A0 "return a Jso= nbValue=C2=A0when as_jsonb is false".=C2=A0
=C2=A0
I am not sure "jsonb_object_field_start" is a good name, so far I= only
come up with "jsonb_object_field_to_jsonbvalues".
Yes, I think it is a good idea.=C2=A0 Puting the jsonbvalu= e=C2=A0in the name can
compensate= =C2=A0for the imprecision of "internal" as a re= turn type.=C2=A0 I am thinking
if we should rename jsonb_finish_n= umeric to jsonbvalue_to_numeric as
well.=C2=A0

=C2=A0
=
linitial(jsonb_start_func->args) =3D
makeRelabelType(linitial(jsonb_start_func->args),
=C2=A0 =C2=A0INTERNALOID, 0,
=C2=A0 =C2=A0InvalidOid,
=C2=A0 =C2=A0COERCE_IMPLICIT_CAST);

if no need, output typmod (usually -1), so here should be -1 rather than 0?=
=C2=A0
I agree. -1 is better than 0.=C2=A0

Thanks for the code level review again! I want to wait= for some longer time
to gather more feedback.=C2=A0 I'm will= ing to name it better,=C2=A0 but hope I didn't
rename it to A= and rename it back shortly.=C2=A0

--
Best Regards
Andy Fan
--0000000000006c9ba00604ab4b9a--