Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUDtk-0001G5-9B for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Aug 2016 14:08:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bUDtj-0004iT-OP for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Aug 2016 14:08:51 +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 1bUDsN-00037R-6y for pgsql-hackers@postgresql.org; Mon, 01 Aug 2016 14:07:27 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUDsG-0002gN-6X for pgsql-hackers@postgresql.org; Mon, 01 Aug 2016 14:07:26 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 555775F7A7; Mon, 1 Aug 2016 10:07:19 -0400 (EDT) Date: Mon, 1 Aug 2016 10:07:19 -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: <20160801140719.GK4028@tamriel.snowman.net> References: <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> <20160727022424.GL4028@tamriel.snowman.net> <5278.1469628270@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NLzDv8tv2umAfrXO" Content-Disposition: inline In-Reply-To: <5278.1469628270@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: 09:58:19 up 23 days, 15:22, 7 users, load average: 0.05, 0.06, 0.09 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -3.1 (---) 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 --NLzDv8tv2umAfrXO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Tom, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Stephen Frost writes: > > * Tom Lane (tgl@sss.pgh.pa.us) wrote: > >> 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 > > 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. >=20 > No, I reject that entirely. It would be insane for example to expect that > random client-side code should be able to interpret the node trees stored > in places like pg_index.indexprs. It's barely possible that we could > maintain such logic in pg_dump, though having to maintain a different > version for each supported server branch would be a giant PITA. But do > you also want to maintain translated-into-Java copies of each of those > libraries for the benefit of JDBC? Or any other language that client > code might be written in? Honestly, I anticipated the focus on the pg_get_expr() and should have explicitly commented on it. I agree that we shouldn't look to have pg_dump or client utilities be able to understand node trees and that, instead, we should continue to provide a way for those to be reconstructed into SQL expressions. > Now, obviously knowing which bit in pg_index.indoption does what would be > a few orders of magnitude less of a maintenance hazard than knowing what > expression node trees contain. But that doesn't make it a good > future-proof thing for clients to be doing. If the answer to the question > "why do you need access to pg_am.amcanorder?" is "so I can interpret the > bits in pg_index.indoption", I think it's clear that we've got an > abstraction failure that is not going to be fixed by just exposing > something equivalent to the old pg_am definition. I agree- asking clients to interpret the bits in pg_index.indoption isn't the right answer either. > Building on the has-property approach Andrew suggested, I wonder if > we need something like pg_index_column_has_property(indexoid, colno, > propertyname) with properties like "sortable", "desc", "nulls first". Right, this makes sense to me. The point which I was trying to get at above is that we should be able to replace most of what is provided in pg_get_indexdef() by using this function to rebuild the CREATE INDEX command- again, similar to how we build a CREATE TABLE command rather than simply provide a 'pg_get_tabledef()'. Thanks! Stephen --NLzDv8tv2umAfrXO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJXn1eWAAoJEO1sijiDR2RVh6EP/16sjSCfGjnAHordidLpGM8j 6c7O/Uaw3VKJNkNmQB6q8kdmEHNyq9YSUzbbn26FRpKTsiu6TMrF5wECXweSy8n7 ScKN8jrgI0G6azCabsHibiG4tObM0LpkCtva1bFCNsKt5p7E7mx8k9JMTcx6HOmj WVfo4uuAbUYIFYLNysbTobcJ7SBRfvI91j0CO8mujOPSJ30KDQWXO4Viw58d7/7I g7Hn7+iwEZYcoqKP6nlO6FH0MC0kLwkOD+bUtaI4L9TW1US3aB+5PqFaYdyzcXmm lbz4CmJgTeXvdccELxg2yHh5AwxC8k6Vpjjzy5UAFGwCeAz/u+OqUl9i1FAJdf2a vYbq0kLy8DVKp+0mIY7Zgbl75AV6z2qsePpMX0JpwUHWalBwHrgBZ4n+Tc8Zm0OD Yk72QQLvIe/WF2eYyPWqXgrUZLyG6uEiPjIK9zvGt6cKkAy7jPr6MLnUNnquizsi 7LIu36ABMRBcBk+Z3Krd9H230lzTGo71oGAuTTCcQJvydpA9JwgHDjWnDruXrD3T 1BTX/VhUbJW9EhtAQTl5m5sRqoNkIJ4qZdXeTsfsADS+qIUUqjEofliOCGzzjGy5 aY6iN4MKK3ncOck2S4KSZ90Y4C2LbuPYnspI9EEjxhpTxq2uqFk3b3NCiNmCTmkm t+vhlV1fXsv+Ktb4xBZn =SZbw -----END PGP SIGNATURE----- --NLzDv8tv2umAfrXO--