Re: Using pl/pgsql or sql for in/out functions for types - Mailing list pgsql-general

From Tom Lane
Subject Re: Using pl/pgsql or sql for in/out functions for types
Date
Msg-id 4600.987180612@sss.pgh.pa.us
Whole thread Raw
In response to Using pl/pgsql or sql for in/out functions for types  (John Havard <enigma@sevensages.org>)
Responses Re: Using pl/pgsql or sql for in/out functions for types
List pgsql-general
John Havard <enigma@sevensages.org> writes:
> Is there anyway to do this without having to resort to writing the
> functions in C or some other language?

You really cannot write datatype I/O functions in anything but C,
because the I/O functions have to deal in C-style strings, which are
not a SQL datatype; so there is no way to describe the necessary
behavior in any PL language.

There has been some talk of promoting "C string" to be at least a
second-class SQL datatype (on the order of being able to declare
functions that take or return them, but not use them as a column
datatype).  Hasn't happened yet though.

> Why doesn't CREATE FUNCTION complain about plpgsql functions not being
> able to accept the opaque type as an argument?

Because it makes no assumptions about what abilities PL languages might
have.  The PLs are plug-ins, remember.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_dump dying (and VACUUM ANALYZE woes)...
Next
From: "Steve Wolfe"
Date:
Subject: Re: Shared memory failure?