Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id BAA16292 for postgres-redist; Tue, 19 Jul 1994 01:34:38 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199407190834.BAA16292@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from tutkie.tutkie.tut.ac.jp (tutkie.tut.ac.jp [133.15.160.64]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id BAA16282 for <postgres@postgres.berkeley.edu>; Tue, 19 Jul 1994 01:34:36 -0700
Received: from molout.tutkie.tut.ac.jp by tutkie.tutkie.tut.ac.jp (8.6.5+2.3W/6.4J.6)
	id RAA24998; Tue, 19 Jul 1994 17:31:50 +0900
Received: by molout.tutkie.tut.ac.jp (4.30/6.4J.6)
	id AA03166; Tue, 19 Jul 94 17:35:19 jst
Date: Tue, 19 Jul 94 17:35:19 jst
From: wolf@molout.tutkie.tut.ac.jp (Wolf-D. Ihlenfeldt)
Message-Id: <9407190835.AA03166@molout.tutkie.tut.ac.jp>
To: postgres@postgres.Berkeley.EDU
Subject: How to retrieve owner of class
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Tue, 19 Jul 94 01:34:38 -0700
Resent-XMts: smtp



In Postgres4.2, the id of the owner of a class is stored as
pg_class.relowner as type 'oid'.
This entry refers to pg_user.usesysid, which is of type 'int2'.

Question 1: Why are the types different ?

I tried to retrieve class name and owner by
retrieve (c.relname, u.usename) from c in pg_class, u in pg_user
where u.usesysid = c.relowner

and I get
NOTICE:Jul 19 17:53:31:there is no operator = for types int2 and oid
NOTICE:Jul 19 17:53:31:You will either have to retype this query using an
NOTICE:Jul 19 17:53:31:explicit cast, or you will have to define the operator
WARN:Jul 19 17:53:31:= for int2 and oid using DEFINE OPERATOR

Casting does not work:

retrieve (c.relname, u.usename) from c in pg_class, u in pg_user
where u.usesysid = c.relowner::int2
NOTICE:Jul 19 17:54:16:there is no operator = for types int2 and oid
NOTICE:Jul 19 17:54:17:You will either have to retype this query using an
NOTICE:Jul 19 17:54:17:explicit cast, or you will have to define the operator
WARN:Jul 19 17:54:17:= for int2 and oid using DEFINE OPERATOR


I solved the problem by writing a private oid/int2 comparison 
function and introducing a '=' operator. However, I wonder if
this is really necessary.
Question 2: Is there another way to specify this query ?

Question 3: Looking at the built-in functions, I found names like
'oidint2' and functions for this type. However, these are NO 
oid/int2 functions, but seem to operate on an exotic oidint2 type.
What is this type being used for ?

WDI

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
