Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYIGc-0008Om-93 for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Aug 2016 19:37:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bYIGb-0002Ak-SI for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Aug 2016 19:37:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bYIGa-00026B-02 for pgsql-hackers@postgresql.org; Fri, 12 Aug 2016 19:37:16 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bYIGX-0000cE-98 for pgsql-hackers@postgresql.org; Fri, 12 Aug 2016 19:37:14 +0000 Received: from localhost ([127.0.0.1]:23941 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1bYIGT-000HU6-OW; Fri, 12 Aug 2016 19:37:09 +0000 From: Andrew Gierth To: Tom Lane Cc: Alvaro Herrera , Kevin Grittner , Stephen Frost , Peter Eisentraut , Robert Haas , "pgsql-hackers\@postgresql.org" Subject: Re: No longer possible to query catalogs for index capabilities? In-Reply-To: <9594.1471028028@sss.pgh.pa.us> (Tom Lane's message of "Fri, 12 Aug 2016 14:53:48 -0400") Message-ID: <874m6pol1i.fsf@news-spur.riddles.org.uk> References: <20160809155623.GA567087@alvherre.pgsql> <87y445ap58.fsf@news-spur.riddles.org.uk> <87a8gkr8fu.fsf@news-spur.riddles.org.uk> <17563.1470843700@sss.pgh.pa.us> <8737mcr3vn.fsf@news-spur.riddles.org.uk> <30901.1470868017@sss.pgh.pa.us> <87fuq9oo12.fsf@news-spur.riddles.org.uk> <9594.1471028028@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Fri, 12 Aug 2016 20:37:09 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -2.4 (--) 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 >>>>> "Tom" == Tom Lane writes: >> distance_orderable now returns true/false depending on the opclass, >> not just on the amcanorderbyop field. In order to do this, I've >> added an optional amproperty function to the AM api, which if it >> exists, gets first dibs on all property calls so it can override the >> result as it sees fit. Tom> Hmm, seems like for that case, it'd be easier to look into pg_amop Tom> and see if the opclass has any suitably-marked operators. I thought about that, but it seemed like it could get painful. The planner is working forwards from a known operator and matching it against the index column, whereas we'd have to work backwards from the opfamily, and there's no good existing index for this; in the presence of binary-compatible types, I don't think even amoplefttype can be assumed (e.g. a varchar column can be ordered by pg_trgm's <-> operator which is declared for text). So it'd have to be the equivalent of: get index column's opclass oid look it up in pg_opclass to get opfamily for r in select * from pg_amop where amopfamily=? and amoppurpose='o' if r.amoplefttype is binary-coercible from the index column's type then return true As opposed to what I have now, which is: get index column's opclass oid look it up in pg_opclass to get opfamily/opcintype result = SearchSysCacheExists4(AMPROCNUM, ...) (in theory this could produce a false positive if there's a distance function but no actual operators to reference it, but I think that's the opclass author's issue) -- Andrew (irc:RhodiumToad) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers