Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSPRz-0000oa-S8 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jul 2016 14:04:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bSPRz-0006Yd-Ej for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jul 2016 14:04:43 +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 1bSPRy-0006YV-QS for pgsql-hackers@postgresql.org; Wed, 27 Jul 2016 14:04:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSPRq-0008Hu-7y for pgsql-hackers@postgresql.org; Wed, 27 Jul 2016 14:04:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u6RE4U8q005279; Wed, 27 Jul 2016 10:04:30 -0400 From: Tom Lane To: Stephen Frost cc: Peter Eisentraut , Andrew Gierth , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: No longer possible to query catalogs for index capabilities? In-reply-to: <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> <20160727022424.GL4028@tamriel.snowman.net> Comments: In-reply-to Stephen Frost message dated "Tue, 26 Jul 2016 22:24:24 -0400" Date: Wed, 27 Jul 2016 10:04:30 -0400 Message-ID: <5278.1469628270@sss.pgh.pa.us> 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 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? > 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. 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? 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. 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". regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers