Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA46250 for ; Thu, 18 May 2000 10:52:59 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id KAA23393 for ; Thu, 18 May 2000 10:52:57 -0400 (EDT) To: pgsql-sql@postgresql.org Subject: Re: Using substr with user defined types In-reply-to: References: Comments: In-reply-to darcy@druid.net (D'Arcy J.M. Cain) message dated "Thu, 18 May 2000 06:54:20 -0400" Date: Thu, 18 May 2000 10:52:57 -0400 Message-ID: <23390.958661577@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200005/49 darcy@druid.net (D'Arcy J.M. Cain) writes: > create function chkpass_rout(opaque) > returns opaque > as '/usr/pgsql/modules/chkpass.so' > language 'c'; > Here is what happens. > soccer=> select chkpass_rout('hello'::chkpass); > ERROR: typeidTypeRelid: Invalid type - oid = 0 Functions that you intend to invoke as ordinary functions shouldn't have inputs or outputs declared "opaque", because the expression evaluation code won't have any idea what to do. When you are building functions that will be the input or output converters for a datatype, you can read "opaque" as meaning "C string", so for example the input converter takes opaque and returns your type. But otherwise you don't want to be using opaque. Perhaps what you wanted here was "create function chkpass_rout(chkpass) returns text". I'd like to see "opaque" eliminated from Postgres, because it's unhelpfully named and is used to cover several distinct purposes that would be better served with distinct names. Might create too much of a backwards compatibility problem though :-( regards, tom lane