pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: darcy@druid.net
To: tgl@sss.pgh.pa.us
Cc: pgsql-sql@postgresql.org
Subject: Re: Using substr with user defined types
Date: Thu, 18 May 2000 06:54:20 -0400 (EDT)
Message-ID: <m12sNwa-000AXnC@druid.net> (raw)
In-Reply-To: <21185.958618355@sss.pgh.pa.us>

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 <darcy@{druid|vex}.net>   |  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.



view thread (10+ messages)  latest in thread

Message-ID: <m12sNwa-000AXnC@druid.net>
Permalink:  ../m12sNwa-000AXnC@druid.net/
Also on:    postgresql.org/message-id/m12sNwa-000AXnC@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, tgl@sss.pgh.pa.us
  Subject: Re: Using substr with user defined types
  In-Reply-To: <m12sNwa-000AXnC@druid.net>
  References: <21185.958618355@sss.pgh.pa.us> <m12sNwa-000AXnC@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox