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 1rmpnx-00A7om-O3 for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 06:52:06 +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 1rmpnw-003763-Au for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 06:52:04 +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 1rmpnw-00375v-1N for pgsql-hackers@lists.postgresql.org; Wed, 20 Mar 2024 06:52:04 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rmpns-005VBp-Se for pgsql-hackers@postgresql.org; Wed, 20 Mar 2024 06:52:03 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-4765a8015bbso1835438137.1 for ; Tue, 19 Mar 2024 23:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710917519; x=1711522319; 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=t9uKERzony/IXV8rOIgQ1MGatqYKQ/Tv3Ol8l0f00ls=; b=VTD/x1FdNOHX5BQaZkMaZybL+uQAPrc0I9zz1GGCX72bEYQmF7GdAwcsB5A9/t9mI3 6SoscKQkPmHkNJeNBHGI4zkucvcqyqljeFmGbFfIDez3aIRRifY1rYYQAd7y5i0lE+fA xwheQZ5jUZ/uqzjT0mNfr+R9q8ojNY700ZW30Vp7wV708VJSQObrkaaNeEi7cIQ4Dry/ TXrVLFbb6hmjdQOIEhXNU0dINudb/JNAuOggun05m8D4L3JWYVMze0gjEN7OjqAUM/Hv HcgRJTfXUNdZgnggecTnoS+E6SWCzh8bNSFTPHlnhs7ZWX/32yQFAoEVIQpHaNKLOF+2 zieQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710917519; x=1711522319; 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=t9uKERzony/IXV8rOIgQ1MGatqYKQ/Tv3Ol8l0f00ls=; b=eUWsBs/00hph0C9VUI6g/OuGwBGIcKk6gp28XYv9L37Kc473SWboUdcEAWRVNyt15A dcyDBDMnAmPPVd29pcTn7MH2jlyjJ881hJ9DCcHaJ3wBPtme+IG6qIQXVWF/o6bgFHpU 4BlUEJRIXc+57suA9UFJye/DPcIJQ75vwD8MSTrlkI2Mku7PYpN/0+rrAuNxJ+7afBha yv8ustXM9KJhcvFGUDQ28TQv78v1bYXoTAbjZs/e2Zq4trqhx2WTrUmCqtuRd7zV9taL pY7EN8IwbN/miU4Zy35FVgrZQX+I+9HgtcOs3KnuvUSbRSofOOm0QaFb7RYaBN58n1qk 8bmw== X-Forwarded-Encrypted: i=1; AJvYcCV3UuF9R9YEZRTBIS7qzj0U7VXp2vagyxJ5iw1w7UfQCMgfxEBPzDLIDxpUBwNpir3QiNYXxCnUIHoqmdHcizKp7d+s2cuzXgsHUsPf X-Gm-Message-State: AOJu0YwrMemlMNGl6pwpaP2P1XMUaOm3SH86cEll63qOCwaXwEyeJq// s34xc1J6lr+9PDZO+hPZhERVmVZcblx3ISJycojsmKHKuSfqvPD8lvgaF/S26jKVZSeg0TWPFcu E0sOHoKvycN1ahzqg8/RzfsPMBbM= X-Google-Smtp-Source: AGHT+IEo1lGBFjYP/5XEiI/oLFwZokVe2s3hydqXSFUemWA+NGZGxIkIfvRn0Ofe19lWt1eF9kmk4bPLuSe1htFqdEw= X-Received: by 2002:a67:ea82:0:b0:473:885:bd97 with SMTP id f2-20020a67ea82000000b004730885bd97mr4206671vso.12.1710917519511; Tue, 19 Mar 2024 23:51:59 -0700 (PDT) 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: jian he Date: Wed, 20 Mar 2024 14:51:48 +0800 Message-ID: Subject: Re: remaining sql/json patches To: Amit Langote Cc: Tomas Vondra , Himanshu Upadhyaya , Alvaro Herrera , Erik Rijkers , Andres Freund , Andrew Dunstan , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk minor issues I found while looking through it. other than these issues, looks good! /* * Convert the a given JsonbValue to its C string representation * * Returns the string as a Datum setting *resnull if the JsonbValue is a * a jbvNull. */ static char * ExecGetJsonValueItemString(JsonbValue *item, bool *resnull) { } I think the comments are not right? /* * Checks if the coercion evaluation led to an error. If an error did occur, * this sets post_eval->error to trigger the ON ERROR handling steps. */ void ExecEvalJsonCoercionFinish(ExprState *state, ExprEvalStep *op) { } these comments on ExecEvalJsonCoercionFinish also need to be updated? + /* + * Coerce the result value by calling the input function coercion. + * *op->resvalue must point to C string in this case. + */ + if (!*op->resnull && jsexpr->use_io_coercion) + { + FunctionCallInfo fcinfo; + + fcinfo = jsestate->input_fcinfo; + Assert(fcinfo != NULL); + Assert(val_string != NULL); + fcinfo->args[0].value = PointerGetDatum(val_string); + fcinfo->args[0].isnull = *op->resnull; + /* second and third arguments are already set up */ + + fcinfo->isnull = false; + *op->resvalue = FunctionCallInvoke(fcinfo); + if (SOFT_ERROR_OCCURRED(&jsestate->escontext)) + error = true; + + jump_eval_coercion = -1; + } + /* second and third arguments are already set up */ change to /* second and third arguments are already set up in ExecInitJsonExpr */ would be great. commit message <<<< All of these functions only operate on jsonb values. The workaround for now is to cast the argument to jsonb. <<<< should be removed? + case T_JsonFuncExpr: + { + JsonFuncExpr *jfe = (JsonFuncExpr *) node; + + if (WALK(jfe->context_item)) + return true; + if (WALK(jfe->pathspec)) + return true; + if (WALK(jfe->passing)) + return true; + if (jfe->output && WALK(jfe->output)) + return true; + if (jfe->on_empty) + return true; + if (jfe->on_error) + return true; + } + if (jfe->output && WALK(jfe->output)) + return true; can be simplified: + if (WALK(jfe->output)) + return true;