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 1rhMdS-00B50B-2b for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 04:42:38 +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 1rhMdQ-00DQbQ-Lm for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 04:42:37 +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 1rhMdQ-00DQbH-CM for pgsql-hackers@lists.postgresql.org; Tue, 05 Mar 2024 04:42:36 +0000 Received: from mail-ua1-x930.google.com ([2607:f8b0:4864:20::930]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhMdI-002uWI-WF for pgsql-hackers@postgresql.org; Tue, 05 Mar 2024 04:42:35 +0000 Received: by mail-ua1-x930.google.com with SMTP id a1e0cc1a2514c-7da763255b7so1918302241.2 for ; Mon, 04 Mar 2024 20:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709613749; x=1710218549; 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=DiFJcBHIGk91RwHQCoTYWKAtjpedkTZEQuyxcj2fkpQ=; b=T7x1074K+pXFKv+b5Du5rFU385wD/4dbUxQulcpJ5SavLWC9CZ2DgdHtsCnWqu4GpK wtMHoazgwFGheKR+zzgmqQLt2PsLOnOSpyoLqnL8fKv5oDU17QL4Ed16q/xssTgzrQqs ucD+y4OeBCHnNrfensRnH4GbrmCzqNXm9RaCFhc9490ExhQ6gybknRjbBRRCjG+gEEgc Y+cfhpy5lRXgTYKevEZhiFl1pwHgkqKZwnmR8GhNmUX+rtxzeu/Tj5Zh4oeF1rpA3QNx SsPY/05WpxeXuSjoXo0wD7UAItN7ExCLeg4T32x7wnXIWH96RPuAfijDlj0yQXkKrHs0 gGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709613749; x=1710218549; 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=DiFJcBHIGk91RwHQCoTYWKAtjpedkTZEQuyxcj2fkpQ=; b=IYieX1Fj6fIZCzDQKCl31XRQZ/lMZJK1Bl5SWU9k08uxBFflQOo5I48auhKhoWQMNE C4rdaFUyAlRkfKSETRqQN/ohpbQ06bRjyp+oE5zuq9/QrMRYR9bK6SQ9exzQ0ys1HTPE Pi0ebxobAGv3bLzfBAdIqqdm8t6MF4TfLO5YkQjRLUl4454RKX68A/6Ihg4QbwTJSlvB 4LgdOKGXpQvTbp06tA5n48lUz/cKJWiDE6LAArpoUXLonCNkrEht+JIQWeXA0618vRE0 rhVeaUt9+8/Qsrs8U0o9RZMuFFRX0YZsC2qRh6iM0RI+MtuMrZxOZ56ShAECv4eYSLBF Zxqg== X-Forwarded-Encrypted: i=1; AJvYcCWpBs4tz/CZw2CuHJ7qxejXXqKpBy/VrnT+iIiqxcsSixGZTbr9/amdk1Zeri9Mg/x3Mbt355niFjaTFz5ADPH1OsYAtFnFilOJUGKh X-Gm-Message-State: AOJu0YzigAMh3A7xfDI+L+ATG0dsbORkRJVLjURHBMEKwT0B+zuzfViH yQw5auBHjoHonzeKb37wtTu4mluEphFSJsCNwdZcvAEG9JzhV06a/El5edATdv3j6cKji6P7apP eqj+CsDSdyYYSHD0Cuya4QX5GFIw= X-Google-Smtp-Source: AGHT+IHxddrky7GcO83BUx5tdlI5JFj+3cmb60ynebcObjwH+dUlaUbksBPtf81sEZa9mzicpBDSB545tTdq+gm3vCU= X-Received: by 2002:a05:6102:d8c:b0:472:cc6a:5dd8 with SMTP id d12-20020a0561020d8c00b00472cc6a5dd8mr857496vst.3.1709613749246; Mon, 04 Mar 2024 20:42:29 -0800 (PST) MIME-Version: 1.0 References: <1cee81f3-312f-30e3-0282-c4df7ee72f93@xs4all.nl> <202403041503.5momp6knupgo@alvherre.pgsql> In-Reply-To: From: jian he Date: Tue, 5 Mar 2024 12:42:17 +0800 Message-ID: Subject: Re: remaining sql/json patches To: Amit Langote Cc: Alvaro Herrera , Erik Rijkers , Andres Freund , Andrew Dunstan , PostgreSQL-development 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 Tue, Mar 5, 2024 at 9:22=E2=80=AFAM Amit Langote wrote: > > Thanks for the heads up. Attaching rebased patches. > Walking through the v41-0001-Add-SQL-JSON-query-functions.patch documentati= on. I found some minor cosmetic issues. + + select json_query(jsonb '{"a": "[1, 2]"}', 'lax $.a' RETURNING int[] OMIT QUOTES); + + this example is not so good, it returns NULL, makes it harder to render the result. + context_item (the document); seen + for more details on what + path_expression can contain. "seen" should be "see"? + + This function must return a JSON string, so if the path expression + returns multiple SQL/JSON items, you must wrap the result using th= e + WITH WRAPPER clause. If the wrapper is "must" may be not correct? since we have a RETURNING clause. "generally" may be more accurate, I think. maybe we can rephrase the sentence: + This function generally return a JSON string, so if the path expre= ssion + yield multiple SQL/JSON items, you must wrap the result using the + WITH WRAPPER clause + is spcified, the returned value will be of type text. + If no RETURNING is spcified, the returned value= will two typos, and should be "specified". + Note that if the path_expression + is strict and ON ERROR behav= ior + is ON ERROR, an error is generated if it yields= no + items. may be the following: + Note that if the path_expression + is strict and ON ERROR behav= ior + is ERROR, an error is generated if it yields no + items. most of the place, you use path_expression but there are two place you use: path_expression I guess that's ok, but the appearance is different. more prominent. Anyway, it is a minor issue. + json_query. Note that scalar strings returne= d + by json_value always have their quotes remove= d, + equivalent to what one would get with OMIT QUOTES + when using json_query. I think we can simplify it like the following: + json_query. Note that scalar strings returne= d + by json_value always have their quotes remove= d, + equivalent to OMIT QUOTES + when using json_query.