From: darcy@druid.net
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using substr with user defined types
Date: Thu, 22 Jun 2000 22:43:38 -0400 (EDT)
Message-ID: <m135JRS-000AY3C@druid.net> (raw)
In-Reply-To: <23390.958661577@sss.pgh.pa.us>
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 <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.
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: <m135JRS-000AY3C@druid.net>
References: <23390.958661577@sss.pgh.pa.us> <m135JRS-000AY3C@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