Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSEXh-0007nx-T1 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jul 2016 02:25:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bSEXh-0007pk-B9 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jul 2016 02:25:53 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSEWL-0006GJ-49 for pgsql-hackers@postgresql.org; Wed, 27 Jul 2016 02:24:29 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSEWH-00056Q-VP for pgsql-hackers@postgresql.org; Wed, 27 Jul 2016 02:24:28 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id CB3F65F7B6; Tue, 26 Jul 2016 22:24:24 -0400 (EDT) Date: Tue, 26 Jul 2016 22:24:24 -0400 From: Stephen Frost To: Tom Lane Cc: Peter Eisentraut , Andrew Gierth , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: No longer possible to query catalogs for index capabilities? Message-ID: <20160727022424.GL4028@tamriel.snowman.net> References: <87mvl5on7n.fsf@news-spur.riddles.org.uk> <23668.1469454897@sss.pgh.pa.us> <87invtolnc.fsf@news-spur.riddles.org.uk> <25197.1469457317@sss.pgh.pa.us> <8957.1469474359@sss.pgh.pa.us> <8737mxo747.fsf@news-spur.riddles.org.uk> <4dea49ae-3110-5e97-1548-24ddf8f07c34@2ndquadrant.com> <5265.1469584987@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="e59cmCxsGlzMyaN0" Content-Disposition: inline In-Reply-To: <5265.1469584987@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 22:07:55 up 18 days, 3:32, 7 users, load average: 0.05, 0.07, 0.07 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --e59cmCxsGlzMyaN0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Peter Eisentraut writes: > > On 7/25/16 3:26 PM, Andrew Gierth wrote: > >> The issue I ran into was the exact same one as in the JDBC thread I > >> linked to earlier: correctly interpreting pg_index.indoption (to get t= he > >> ASC / DESC and NULLS FIRST/LAST settings), which requires knowing > >> whether amcanorder is true to determine whether to look at the bits at > >> all. >=20 > > Maybe we should provide a facility to decode those bits then? >=20 > Yeah. I'm not very impressed by the underlying assumption that it's > okay for client-side code to hard-wire knowledge about what indoption > bits mean, but not okay for it to hard-wire knowledge about which index > AMs use which indoption bits. There's something fundamentally wrong > in that. We don't let psql or pg_dump look directly at indoption, so > why would we think that third-party client-side code should do so? >=20 > Andrew complained upthread that pg_get_indexdef() was too heavyweight > for his purposes, but it's not clear to me what he wants instead. I guess I'm missing something because it seems quite clear to me. He wants to know if the index was built with ASC or DESC, and if it was built with NULLS FIRST or NULLS LAST, just like the JDBC driver. pg_get_indexdef() will return that information, but as an SQL statement with a lot of other information that isn't relevant and is difficult to deal with when all you're trying to do is write an SQL query (no, I don't believe the solution here is to use pg_get_indexef() ~ 'DESC'). For my 2c, I'd like to see pg_dump able to use the catalog tables to derive the index definition, just as they manage to figure out table definitions without (for the most part) using functions. More generally, I believe we should be working to reach a point where we can reconstruct all objects in the database using just the catalog, without any SQL bits being provided from special functions which access information that isn't available at the SQL level. I don't see any problem with what Andrew has proposed as the information returned informs the creation of the DDL statement, but does not provide a textual "drop-in"/black-box component to include in the statement to recreate the object, the way pg_get_indexdef() does. Thanks! Stephen --e59cmCxsGlzMyaN0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJXmBtYAAoJEO1sijiDR2RVs3sP/j/bUQFiZbSg9qA1T8FpfO6g u/z9JaaEzllvJDSOn39W95pUGZD9eFwEFJ/Nv3vk8zwlp2jRZjkJuFn8Ks8oTMzn 7EeHz1GuA9Yumnp76NtXFYpE7ZCv+0OlCA/U8iONow5K6I+sKedAm2wPBiSgafF8 2LGOA+MOcbdVUdB687fjQ/ar8gHmJpjtxZnCeYqWJMm8Xzdw7JCZT9ekYfHyyJXO WC/uF12ynRKzzSU+EfF7WeYQIvymhV1emNTAUdDyNP1R5NP4erH6SB4oPJwOrWOg qvn/7zcSYoDAF21KlOFyma/7sSVD0JFz9prtkAj6vrTc2xQ2TwuejvWCrTCbNS+V 2a/0VgDBxIMINm4JKr7NpiccZ2WdpEDyo7VE3u6tD9D5ax5zqcpUk3aKRF7vy/sf zCXId8f/5dnKIW0Ra4Fsh4NBmo0vSAKF5s34YAYytGB+PMzd9/MeLTqZJjGguFSW qNDf1gjSbzAKq4Ir3PqYGnqXlVfGgFyqCA9aqcvXZXqiW67FKhOcFE+ULuBP87yD VC/4kW9BACQLO7WibwNXOiJK5JrF61bCy6mEFhaDBJR+Cmb28SzLDLBklTXWev0s GPUpaEZOpWZ/2cFVESUTwOTi4vj+Ms6WaHqgxkRY/HkenK/CPhQNzEH5Vytj+EDQ 0GqlqvmR3+J9EWid4mOY =hso4 -----END PGP SIGNATURE----- --e59cmCxsGlzMyaN0--