Re: CREATE TYPE function examples - Mailing list pgsql-sql

From Tom Lane
Subject Re: CREATE TYPE function examples
Date
Msg-id 29500.994786206@sss.pgh.pa.us
Whole thread Raw
In response to CREATE TYPE function examples  (Roberto Mello <rmello@cc.usu.edu>)
List pgsql-sql
Roberto Mello <rmello@cc.usu.edu> writes:
> What would the functions my_procedure_1 and my_procedure_2 look like?

src/backend/utils/adt/ is full of examples of datatype I/O procedures.
Pick an existing type that does something vaguely like your type
(at the very least pick one that uses the same kind of representation:
pass-by-value, fixed-length pass-by-reference, or variable-length),
and use its code as a model.

The only thing you need to do differently in dynamically loaded C code
than is done in the main sources is to declare version-1 calling
convention functions with PG_FUNCTION_INFO_V1().  This is assumed for
builtin functions as of 7.1, but the default for dynamically loaded
functions is to assume old-style calling conventions.
        regards, tom lane


pgsql-sql by date:

Previous
From: Roberto Mello
Date:
Subject: Re: CREATE TYPE function examples
Next
From: "Richard Huxton"
Date:
Subject: Re: Problems with PG_DUMP and restore