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'; ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend