Re: Error creating function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rebecca Clarke <rebecca(at)clarke(dot)net(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Error creating function
Date: 2011-07-20 14:46:09
Message-ID: 11172.1311173169@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rebecca Clarke <rebecca(at)clarke(dot)net(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Samuel Hwang 2011-07-20 15:18:57 Re: Another unexpected behaviour
Previous Message Tom Lane 2011-07-20 14:33:59 Re: compile postgres with visual studio 2010