Received: from druid.net (root@druid.net [216.126.72.98]) by hub.org (8.10.1/8.10.1) with ESMTP id e5N2he191043 for ; Thu, 22 Jun 2000 22:43:40 -0400 (EDT) Received: from localhost (2679 bytes) by druid.net via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp (sender: ) (ident using unix) id for ; Thu, 22 Jun 2000 22:43:38 -0400 (EDT) (Smail-3.2.0.109 1999-Oct-27 #1 built 1999-Dec-25) Message-Id: From: darcy@druid.net (D'Arcy J.M. Cain) Subject: Re: Using substr with user defined types In-Reply-To: <23390.958661577@sss.pgh.pa.us> "from Tom Lane at May 18, 2000 10:52:57 am" To: Tom Lane Date: Thu, 22 Jun 2000 22:43:38 -0400 (EDT) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL78 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200006/198 Thus spake Tom Lane > 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". OK, I tried this. load '/usr/pgsql/modules/chkpass.so'; -- -- Input and output functions and the type itself: -- create function chkpass_in(opaque) returns opaque as '/usr/pgsql/modules/chkpass.so' language 'c'; create function chkpass_out(opaque) returns opaque as '/usr/pgsql/modules/chkpass.so' language 'c'; create type chkpass ( internallength = 16, externallength = 13, input = chkpass_in, output = chkpass_out ); create function raw(chkpass) returns text as '/usr/pgsql/modules/chkpass.so', 'chkpass_rout' language 'c'; Then I did this. darcy=> select 'hello'::chkpass; ?column? -------------- :Rd1xqQo0.2V6. (1 row) darcy=> select raw('hello'::chkpass); pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. I added an fprintf to stderr as the first statement in chkpass_rout() which doesn't print so I am pretty sure it isn't my function. The same thing happens if I create a table with a chkpass type. Any ideas? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.