Re: Error creating function - Mailing list pgsql-general

From Tom Lane
Subject Re: Error creating function
Date
Msg-id 11172.1311173169@sss.pgh.pa.us
Whole thread Raw
In response to Error creating function  (Rebecca Clarke <rebecca@clarke.net.nz>)
Responses Re: Error creating function
List pgsql-general
Rebecca Clarke <rebecca@clarke.net.nz> writes:
> I'm doing a restore into Postgresql 8.4, postgis 1.5.1 and I'm getting the
> following error when it creates the below function:

> pg_restore: creating FUNCTION _get_buffer(geometry, double precision,
> integer)
> pg_restore: [archiver (db)] Error from TOC entry 966; 1255 49162661 FUNCTION
> _get_buffer(geometry, double precision, integer) postgres
> pg_restore: [archiver (db)] could not execute query: ERROR:  SQL function
> cannot accept shell type geometry
>     Command was: CREATE FUNCTION _get_buffer(_geom geometry, _radius double
> precision, _density integer, OUT the_geom geometry) RETURNS geome...

> I don't understand what 'cannot accept shell type geometry' means? Can
> anyone help my lack of knowledge?

Hmm, that is interesting.  A "shell" type is a SQL base data type that
has been declared to the database but its properties are not yet filled
in.  This is needed because the properties include I/O functions, which
have to be declared to take or return the data type, so there's a
circularity involved.  The standard solution is

    CREATE TYPE typename;    -- this creates typename as a shell

    CREATE FUNCTION typename_in(cstring) RETURNS typename ...

    CREATE FUNCTION typename_out(typename) RETURNS cstring ...

    CREATE TYPE typename (input = typename_in, output = typename_out, ...);

The last step changes the type from a shell into a real, usable
datatype.

So what you've apparently got is a situation where that last step got
missed for the geometry type, or else the _get_buffer function somehow
got inserted into the middle of this sequence.  I've not heard of that
happening to people before, so I wonder if you could provide the exact
step-by-step of what you did.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: compile postgres with visual studio 2010
Next
From: Samuel Hwang
Date:
Subject: Re: Another unexpected behaviour