Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 122A6475AB6 for ; Sun, 11 Aug 2002 17:15:41 -0400 (EDT) Received: from squire.barchord.com (squire.barchord.com [216.194.67.18]) by postgresql.org (Postfix) with ESMTP id 8C9B8475AA3 for ; Sun, 11 Aug 2002 17:15:40 -0400 (EDT) Received: from [192.168.1.253] (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by squire.barchord.com (Postfix) with ESMTP id B3DFF3AE for ; Sun, 11 Aug 2002 17:15:41 -0400 (EDT) Subject: Domains and Indexes From: Rod Taylor To: PostgreSQL-development Content-Type: multipart/mixed; boundary="=-yfBoPSjxIUGg3wRG20rQ" X-Mailer: Ximian Evolution 1.0.8 Date: 11 Aug 2002 17:15:47 -0400 Message-Id: <1029100548.239.7.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/688 X-Sequence-Number: 26372 --=-yfBoPSjxIUGg3wRG20rQ Content-Type: text/plain Content-Transfer-Encoding: 7bit Appears there is a problem finding the opclass when indexing a domain. CREATE DOMAIN newint as int4; CREATE TABLE tab (col newint unique); ERROR: data type newint has no default operator class for access method "btree" You must specify an operator class for the index or define a default operator class for the data type Specifically, GetDefaultOpClass() finds 0 exact matches and 3 binary compatible matches. Fetching getBaseType() of the attribute fixes the problem for domains (see attachment). However, I have to wonder why GetDefaultOpClass doesn't simply use the first Binary Compatible opclass. When there is more than one usable it doesn't do anything useful. --=-yfBoPSjxIUGg3wRG20rQ Content-Disposition: attachment; filename=index.patch Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; name=index.patch; charset=ISO-8859-1 Index: src/backend/commands/indexcmds.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/indexcmds.c,v retrieving revision 1.80 diff -c -r1.80 indexcmds.c *** src/backend/commands/indexcmds.c 2002/08/02 18:15:06 1.80 --- src/backend/commands/indexcmds.c 2002/08/11 21:14:13 *************** *** 482,487 **** --- 482,490 ---- Oid exactOid =3D InvalidOid; Oid compatibleOid =3D InvalidOid; =20=20 + /* It could be a domain */ + attrType =3D getBaseType(attrType); +=20 /* * We scan through all the opclasses available for the access method, * looking for one that is marked default and matches the target type --=-yfBoPSjxIUGg3wRG20rQ--