X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 50672D1C9BA for ; Sat, 9 Aug 2003 10:12:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48049-08 for ; Sat, 9 Aug 2003 07:11:11 -0300 (ADT) Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by svr1.postgresql.org (Postfix) with ESMTP id 89F66D1C4C8 for ; Sat, 9 Aug 2003 07:12:27 -0300 (ADT) Received: from frmug.org (localhost [127.0.0.1]) by frmug.org (8.12.9/8.11.3/frmug-2.7/nospam) with ESMTP id h79ACNXd008803 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified NO) for ; Sat, 9 Aug 2003 12:12:26 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) Received: (from uucp@localhost) by frmug.org (8.12.9/8.12.9/Submit) with UUCP id h79ACN1a008802 for pgsql-sql@postgresql.org; Sat, 9 Aug 2003 12:12:23 +0200 (CEST) Received: (from elrond@localhost) by memo.frmug.org (8.11.6/8.11.6) id h79ACCg72000 for pgsql-sql@postgresql.org; Sat, 9 Aug 2003 12:12:12 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) X-Authentication-Warning: memo.frmug.org: elrond set sender to pgsql-sql@phoe.frmug.org using -f Date: Sat, 9 Aug 2003 12:12:12 +0200 From: Bertrand Petit To: PostgreSQL-sql Subject: Comparing arrays Message-ID: <20030809121212.A71948@memo.frmug.org> Mail-Followup-To: PostgreSQL-sql Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/80 X-Sequence-Number: 14696 Hello, I advance in my postgres exploration and found something that looks quite strange, or at least unexpected regarding the present 7.3.3 documentation. In two table I store "objects" and their attributes. The attributes, which are not meant to be searched, are stored as unbound arrays of varchars. I have a query that needs to use those attributes on both sides of an EXCEPT statement: SELECT left.id, left.attribs FROM left EXCEPT SELECT right.id, right.attribs FROM right; That query can't be planed because of the following error: "Unable to identify an ordering operator '<' for type 'character varying[]'". I thought that I could build such an operator using PL/pgSQL, unfortunately this language can't receive arguments of type ANYARRAY. So this led me to the creation of a new ATTRIBUTES data type, the should be acceptable as an argument to a PL/pgSQL procedure. When I tried to create such a datatype, using a query modelled after the documentation examples: CREATE TYPE attributes (INPUT=array_in, OUTPUT=array_out, INTERNALLENGTH=VARIABLE, ELEMENT=VARCHAR); I'm signaled that the array_out procedure is not defined: "ERROR: TypeCreate: function array_out(attributes) does not exist". That error sounds strange as the CREATE TYPE manual describes uniform array type creation as illustrated above and that array_out() seems to exist as shown bellow. SELECT proname, oidvectortypes(proargtypes) FROM pg_proc WHERE proname LIKE 'array_%'; proname | oidvectortypes ---------------------+---------------------------- array_dims | anyarray array_eq | anyarray, anyarray array_in | cstring, oid, integer array_length_coerce | anyarray, integer, boolean array_out | anyarray (5 rows) All of this leads to the unavoidable questions: 1/ What went wrong with the ATTRIBUTES datatype creation? How to correctly create it using 7.3.x backends? 2/ There may be better paths than creating a new datatype and the associated operators that would permit using unbound uniform arrays on both sides of an EXCEPT statement. What would be such paths? Regards. -- %!PS 297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100 180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180 0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont 240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage