"Anton Pikhteryev" <apikhteryev@sandvine.com> writes:
> I created valid_user domain on the old system (8.0.3) a long time ago
> as:
> CREATE DOMAIN valid_user
> AS name -- pg_catalog.pg_user.usename%TYPE
> DEFAULT SESSION_USER
> CONSTRAINT user_exists
> CHECK (has_table_privilege(VALUE,'pg_user','SELECT'));
Ah. That seems a rather strange way to check that a user exists,
but anyway the missing bit of information was that the domain is
over type "name" which is subscriptable. You need the attached
patch (which will be in 8.2.4).
regards, tom lane
Index: src/backend/utils/cache/lsyscache.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v
retrieving revision 1.138
diff -c -r1.138 lsyscache.c
*** src/backend/utils/cache/lsyscache.c 4 Oct 2006 00:30:00 -0000 1.138
--- src/backend/utils/cache/lsyscache.c 19 Mar 2007 15:56:30 -0000
***************
*** 1366,1375 ****
/*
* Array types get their typelem as parameter; everybody else gets their
! * own type OID as parameter. (This is a change from 8.0, in which only
! * composite types got their own OID as parameter.)
*/
! if (OidIsValid(typeStruct->typelem))
return typeStruct->typelem;
else
return HeapTupleGetOid(typeTuple);
--- 1366,1375 ----
/*
* Array types get their typelem as parameter; everybody else gets their
! * own type OID as parameter. (As of 8.2, domains must get their own OID
! * even if their base type is an array.)
*/
! if (typeStruct->typtype == 'b' && OidIsValid(typeStruct->typelem))
return typeStruct->typelem;
else
return HeapTupleGetOid(typeTuple);