X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2CE2747592C for ; Tue, 25 Feb 2003 22:41:16 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 63143-01 for ; Tue, 25 Feb 2003 22:41:05 -0500 (EST) Received: from nycsmtp2out.rdc-nyc.rr.com (nycsmtp2out.rdc-nyc.rr.com [24.29.99.223]) by postgresql.org (Postfix) with ESMTP id 9889647580B for ; Tue, 25 Feb 2003 22:40:54 -0500 (EST) Received: from math-hat.com (66-65-68-135.nyc.rr.com [66.65.68.135]) by nycsmtp2out.rdc-nyc.rr.com (8.12.1/Road Runner SMTP Server 1.0) with SMTP id h1Q3ZCBe007399; Tue, 25 Feb 2003 22:35:12 -0500 (EST) Received: (nullmailer pid 21445 invoked by uid 1000); Wed, 26 Feb 2003 03:40:58 -0000 To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: Polymorphic? Mail-Copies-To: never From: Itai Zukerman Date: Tue, 25 Feb 2003 22:40:58 -0500 In-Reply-To: <10960.1046190011@sss.pgh.pa.us> (Tom Lane's message of "Tue, 25 Feb 2003 11:20:11 -0500") Message-ID: <878yw31zg5.fsf@matt.w80.math-hat.com> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: <87lm041jnq.fsf@matt.w80.math-hat.com> <10960.1046190011@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/573 X-Sequence-Number: 11971 >> 1. Extract information about the underlying type from the arrays, in >> particular the size of the type? >> 2. Apply an operator from within C? > > contrib/array might be a useful example of array manipulation. As for > the other stuff, do you actually want to invoke those operators > specifically, or are you looking for sorting? In any case you might > prefer to use any_ordering_op, SelectSortFunction and ApplySortFunction > rather than nailing down your own assumptions about what to compare > with. I think ApplySortFunction is exactly what I wanted. I'm not sure when I'm going to get to it, but what I'd like to do is: given an existing order relation on a type, extend it to an order on arrays of that type. I've done it for INT4[], and it looks like the general case is possible, just a question of figuring out which pegs go in which slots. So far PostgreSQL's been a pleasure to work with; kudos! CREATE FUNCTION arr_int4_lt(int4[], int4[]) RETURNS boolean AS 'arr_ops', 'generic_lt' LANGUAGE 'C' STRICT; CREATE FUNCTION arr_foo_lt(foo, foo) RETURNS boolean AS 'arr_ops', 'generic_lt' LANGUAGE 'C' STRICT; etc. -- Itai Zukerman