From: | darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain) |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Using substr with user defined types |
Date: | 2000-06-23 02:43:38 |
Message-ID: | m135JRS-000AY3C@druid.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thus spake Tom Lane
> darcy(at)druid(dot)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 <darcy(at){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.
From | Date | Subject | |
---|---|---|---|
Next Message | Gary MacMinn | 2000-06-23 03:04:59 | Merging two columns into one |
Previous Message | Ed Loehr | 2000-06-23 01:55:32 | Re: timespan casting |