new type question - Mailing list pgsql-general

From Sim Zacks
Subject new type question
Date
Msg-id dit533$b6k$1@news.hub.org
Whole thread Raw
Responses Re: new type question  (Martijn van Oosterhout <kleptog@svana.org>)
Re: new type question  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-general
I tried to create a new type with input and output functions in plpgsql and
it didn't work.
The error I got is there is no type uint2.
Is this because plpgsql does not allow you to create input/output fuctions?
It is a very simple function, so I didn't want to do it in C.
Is there a reason that it only works in C and not plpgsql?

I was expecting a message like:
NOTICE:  type "uint2" is not yet defined
DETAIL:  Creating a shell type definition.

but instead I got:
ERROR:  type "uint2" does not exist

create function uint_in(val cstring) returns uint2 as
$$
declare thisval int4;
begin
 thisval=val::int4
 if thisval between 0 and 65535 then
  return (thisval-32768)::int2;
 else
  return 0;
 end if;
end
$$ language 'plpgsql';



pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: Re: unsigned types
Next
From: Martijn van Oosterhout
Date:
Subject: Re: new type question