Re: Using substr with user defined types
| От | darcy@druid.net (D'Arcy J.M. Cain) |
|---|---|
| Тема | Re: Using substr with user defined types |
| Дата | |
| Msg-id | m12sNwa-000AXnC@druid.net обсуждение |
| Ответ на | Re: Using substr with user defined types (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Using substr with user defined types
|
| Список | pgsql-sql |
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.
В списке pgsql-sql по дате отправления: