Re: CREATE TYPE in Postgres 7.3.4 - Mailing list pgsql-general

From Joe Conway
Subject Re: CREATE TYPE in Postgres 7.3.4
Date
Msg-id 3FC61CDE.80302@joeconway.com
Whole thread Raw
In response to CREATE TYPE in Postgres 7.3.4  (Alex Page <alex.page@cancer.org.uk>)
Responses Re: CREATE TYPE in Postgres 7.3.4  (Alex Page <alex.page@cancer.org.uk>)
List pgsql-general
Alex Page wrote:

[...creates enum_gender_in and enum_gender_out as PL/pgSQL functions...]

>   CREATE TYPE enum_gender (
>     INPUT = enum_gender_in,
>     OUTPUT = enum_gender_out,
>     INTERNALLENGTH = 2,
>     PASSEDBYVALUE
>   );
>
> According to the Postgres documentation, when I create the input
> function, it should create a placeholder entry in pg_type for
> enum_gender and wait for the type to be created. However, when I execute
> the CREATE FUNCTION statement, I get:

According to the docs, you cannot use PL/pgSQL functions for I/O
conversion functions. See
http://www.postgresql.org/docs/current/static/plpgsql.html#PLPGSQL-OVERVIEW
where it says:
    "Except for input/output conversion and calculation functions for
     user-defined types, anything that can be defined in C language
     functions can also be done with PL/pgSQL."

In general, I don't think I/O functions can be anything other than C
functions.

On this page
http://www.postgresql.org/docs/current/static/sql-createtype.html
it says:
    "The support functions input_function and output_function are
     required, while the functions receive_function and send_function are
     optional. Generally these functions have to be coded in C or another
     low-level language."

Joe


pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Postgresql on file system EXT2 or EXT3
Next
From: Joe Conway
Date:
Subject: Re: passing function's output into C function