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 1qdVWZ-003gWJ-2K for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Sep 2023 12:51:19 +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 1qdVWX-001x8z-T1 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Sep 2023 12:51:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qdVWX-001x8L-Ic for pgsql-hackers@lists.postgresql.org; Tue, 05 Sep 2023 12:51:17 +0000 Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qdVWU-002rk3-2N for pgsql-hackers@postgresql.org; Tue, 05 Sep 2023 12:51:16 +0000 Received: by mail-ua1-x92d.google.com with SMTP id a1e0cc1a2514c-7a7857e5290so689817241.1 for ; Tue, 05 Sep 2023 05:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693918273; x=1694523073; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LoHqFfkRJDg8mGOkTDivTdWgCE9xDHciv/2It6MwVWE=; b=ZzBjgNn8MHLl209Yhsbe1NvEKXXplVBafrxeDzwouf9QyyxEyM0fxGnRdRwQopYDKM iYyiAc/xWyMVoe+kyFvV6Moq/OqobJcynugAeNlpzveA5wPGu0DZKL45h4bvu2lIWTDD 3mEwZSyOgWGOmvYQOaPRUNZC+6KPlMDXDXS5B8aYCrVjozhQFsvozYsjwDVU4W0bFrB4 WlOtvqtq4VLyhUih7Ql/9YFpatkJXh0o37heFDL2Nchigfj4cr0U3dcGGj1uS0opVvaw RcxCBYIOh2kpoj6uHpJc0OdRw+Lg9cbZL9/BJjotdJ9MMJWQk4u4XcPWj5jiwUQMOF1P V7xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693918273; x=1694523073; h=content-transfer-encoding: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=LoHqFfkRJDg8mGOkTDivTdWgCE9xDHciv/2It6MwVWE=; b=MsnHaNFhVYsLEdeZgkkAPvMMvmzk9mpEM+7JaohKKyNwy3x+Fkk98AQgcjDU4MLSsV 6raVEXEW/T8aYuS7OB1143x1Oi6it2ltNILzgNAbAh/194Z2pM5T8hLzLYn3ZZ/2FYQk nL3APoB7nr/r2V/5X+cjfnJmuLC30heHqypa6oE28lOyA+tLTcvsjZv06ynU4ZEAucab 8fPr9aqYWwx2TD7NWGLbCuuD+/QQFFOrfPjS0ZgK+NAD1ZTRiSPFa0H4GSqJNByUQ/ur CQuNyRAJo+FUuAy9HNIyjtA7Krl2j27r3Ka2irFVtb6fOKAFZs+ZNwivhs4+YxUDx6BY PlCw== X-Gm-Message-State: AOJu0YzJ3RR/LtYaQkmryXwxhuaTFCn9sGS3AAXIPsuoPi69YdcsR09Q swLaiyLjlAjgrxC6tUFOn3msQKbhhqyCTe8eplM= X-Google-Smtp-Source: AGHT+IFEeHGEfFMUZe8Venbtbi9cvO5aMMMOXb64+NlDvXnoG47bIrXDETTbk+nt6RpDHeYxez4XPGUt9v5zEA3CZLw= X-Received: by 2002:a05:6102:91:b0:44d:5a92:ec45 with SMTP id t17-20020a056102009100b0044d5a92ec45mr12157775vsp.23.1693918273189; Tue, 05 Sep 2023 05:51:13 -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: jian he Date: Tue, 5 Sep 2023 20:51:01 +0800 Message-ID: Subject: Re: Extract numeric filed in JSONB more effectively To: Andy Fan Cc: Chapman Flack , Pavel Stehule , Tom Lane , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 4, 2023 at 10:35=E2=80=AFPM Andy Fan = wrote: > > Hi, > > v13 attached. Changes includes: > > 1. fix the bug Jian provides. > 2. reduce more code duplication without DirectFunctionCall. > 3. add the overlooked jsonb_path_query and jsonb_path_query_first as ca= ndidates > > > -- > Best Regards > Andy Fan 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". I am not sure "jsonb_object_field_start" is a good name, so far I only come up with "jsonb_object_field_to_jsonbvalues". linitial(jsonb_start_func->args) =3D 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? list_make2(jsonb_start_func, makeConst(.....). you can just combine two different types then make a list, seems pretty cool...