Received: from druid.net (root@druid.net [216.126.72.98]) by hub.org (8.9.3/8.9.3) with ESMTP id GAA07632 for ; Thu, 18 May 2000 06:54:21 -0400 (EDT) (envelope-from darcy@druid.net) Received: from localhost (1965 bytes) by druid.net via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp (sender: ) (ident using unix) id for ; Thu, 18 May 2000 06:54:20 -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: <21185.958618355@sss.pgh.pa.us> from Tom Lane at "May 17, 2000 10:52:35 pm" To: tgl@sss.pgh.pa.us (Tom Lane) Date: Thu, 18 May 2000 06:54:20 -0400 (EDT) Cc: pgsql-sql@postgresql.org Reply-To: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200005/45 Thus spake Tom Lane > darcy@druid.net (D'Arcy J.M. Cain) writes: > > I created a type (for passwords) but I can't seem to use substr. I > > suppose that's because it is my own type because the errors suggest that > > there is no substr (actually it says ltrim) function for that type. > > Yup --- the system has no idea how to apply any functions to a > user-defined type except the ones you specifically define for that type. OK, I created a function in the C file called chkpass_rout (Raw OUTput) which does exactly what I want. I create a function like this. 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 I tried various combinations of chkpass instead of opaque with no success. > If you make a type-conversion function "text(yourtype) returns text" > then the system will figure out that it should apply that function > whenever you use your type as the argument of a function that needs > text. But without such a function, the system will not assume that > it can do anything text-ish with the datatype. OK, I'll go try this. Thanks. -- 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.