Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j6g9p-0000qM-5W for pgsql-docs@arkaria.postgresql.org; Tue, 25 Feb 2020 19:46:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j6g9n-0002Er-M0 for pgsql-docs@arkaria.postgresql.org; Tue, 25 Feb 2020 19:46:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j6fog-0004L3-Ij for pgsql-docs@lists.postgresql.org; Tue, 25 Feb 2020 19:24:26 +0000 Received: from mail.datenzone.de ([212.12.50.98]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j6foY-0007dl-Ro for pgsql-docs@lists.postgresql.org; Tue, 25 Feb 2020 19:24:26 +0000 Received: from mail.datenzone.de (localhost [127.0.0.1]) by mail.datenzone.de (Postfix) with ESMTP id 8BEB7C08C for ; Tue, 25 Feb 2020 20:24:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 Received: from yogi (200116b82aeb6500e35bae2eb0468e6c.dip.versatel-1u1.de [IPv6:2001:16b8:2aeb:6500:e35b:ae2e:b046:8e6c]) by mail.datenzone.de (Postfix) with ESMTPSA for ; Tue, 25 Feb 2020 20:24:14 +0100 (CET) Message-ID: Subject: Better documentation for row_number() combined with set returning functions From: Erik Tews To: pgsql-docs@lists.postgresql.org Date: Tue, 25 Feb 2020 20:24:13 +0100 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-ZDcWA6grhmtTkclvzLgM" User-Agent: Evolution 3.34.1-4 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-ZDcWA6grhmtTkclvzLgM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi The current documentation of Postgresql sounds like row_number() over () can be used to number the rows returned by postgres. However, that doesn't work when the query also uses set returning functions such as json_array_elements. In this case, row_number() will be the same for every element of the set. I suggest to add a paragraph to the description of row_number() that states that this is the behaviour and maybe also reference the "with ordinality" feature that can be used instead. Erik --=-ZDcWA6grhmtTkclvzLgM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEElv4JZscyoZacPOyTh8wK0DGNmtQFAl5VdF4ACgkQh8wK0DGN mtTZuQf+KfAILYenXiaVxINIUDdIzfnywLlritZQ5qjZN7WxWlAxFZSQsZqlHY0H LvF6HM/U5HK2L5JsFZu6BwoD8TdjwsWwd9wiC7zgCqFwevguAGeb0crOIBhwa/dH jQM5zbexjFboXD53AZDNGBr0yGIm9oOpDdgxmNFHwCjPHAuZN1Kyv4rO73dFnfr/ hXVu4q81s/kx7FP9fS9jNmcOG7smI2k9M5kTdrJAzxZBALFs4a3oDKnor6SK1/r0 +W+NVwP5Ip1lP2qY/mLuKx/kicPtl/VaGUr4R+CAft6383CoVu/KGHPTy4trr/bx yMtuBYxAkahsgCXMEXGMztEG7aQBSQ== =cXY6 -----END PGP SIGNATURE----- --=-ZDcWA6grhmtTkclvzLgM--