Error creating function

Started by Rebecca Clarkeover 14 years ago10 messagesgeneral
Jump to latest
#1Rebecca Clarke
rebecca@clarke.net.nz

Hi

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?

Thanks

Rebecca

#2Sofer, Yuval
Yuval_Sofer@bmc.com
In reply to: Rebecca Clarke (#1)
compile postgres with visual studio 2010

Hi

I would like to build Postgres from source with the visual studio 2010 compiler

Is it supported? Is there any document which describes the process of the implementation?

Thanks,

Yuval Sofer

BMC Software

CTM&D Business Unit

DBA Team

972-52-4286-282

yuval_sofer@bmc.com<mailto:yuval_sofer@bmc.com>

In reply to: Sofer, Yuval (#2)
Re: compile postgres with visual studio 2010

On 20/07/2011 11:56, Sofer, Yuval wrote:

Hi

I would like to build Postgres from source with the visual studio 2010
compiler

Is it supported? Is there any document which describes the process of
the implementation?

Yes, it's in the Fine Manual:

http://www.postgresql.org/docs/9.0/static/install-windows.html

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sofer, Yuval (#2)
Re: compile postgres with visual studio 2010

"Sofer, Yuval" <Yuval_Sofer@bmc.com> writes:

I would like to build Postgres from source with the visual studio 2010 compiler

Is it supported?

Not yet. You could test the pending patch for that:
https://commitfest.postgresql.org/action/patch_view?id=523

regards, tom lane

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rebecca Clarke (#1)
Re: Error creating function

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

#6Craig Ringer
craig@2ndquadrant.com
In reply to: Sofer, Yuval (#2)
Re: compile postgres with visual studio 2010

On 20/07/11 18:56, Sofer, Yuval wrote:

I would like to build Postgres from source with the visual studio 2010
compiler

Unless you're willing to use the patch Tom linked to, you should compile
with Visual Studio 2008 or with the Microsoft Platform SDK 7.0 (Windows
Vista and .NET 3.5).

More testing of the VS 2010 patches would be appreciated, so it'd be
great if you did give them a go.

--
Craig Ringer

#7Sofer, Yuval
Yuval_Sofer@bmc.com
In reply to: Craig Ringer (#6)
Re: compile postgres with visual studio 2010

Hi

Ok - but how do I install the patch in the link?

I pressed the latest "patch" link Tom Lane gave me (Patch by brar on 2011-07-07 12:37:47 AM: Added documentation, removed pgflex.pl and pgbison.pl. No changes to the existing code. ), where I saw some correspondence and very long text file (perl).

Is there a utility for applying the patch, or a README document for step by step implementation?

Regards,
Yuval

-----Original Message-----
From: Craig Ringer [mailto:craig@postnewspapers.com.au]
Sent: Thursday, 21 July 2011 06:16 a.m.
To: Sofer, Yuval
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] compile postgres with visual studio 2010

On 20/07/11 18:56, Sofer, Yuval wrote:

I would like to build Postgres from source with the visual studio 2010
compiler

Unless you're willing to use the patch Tom linked to, you should compile
with Visual Studio 2008 or with the Microsoft Platform SDK 7.0 (Windows
Vista and .NET 3.5).

More testing of the VS 2010 patches would be appreciated, so it'd be
great if you did give them a go.

--
Craig Ringer

#8Brar Piening
brar@gmx.de
In reply to: Sofer, Yuval (#7)
Re: compile postgres with visual studio 2010

-------- Original Message --------
Subject: Re: [GENERAL] compile postgres with visual studio 2010
From: Sofer, Yuval <Yuval_Sofer@bmc.com>
To: Craig Ringer <craig@postnewspapers.com.au>
Date: 21.07.2011 08:56

Hi

Ok - but how do I install the patch in the link?

I pressed the latest "patch" link Tom Lane gave me (Patch by brar on 2011-07-07 12:37:47 AM: Added documentation, removed pgflex.pl and pgbison.pl. No changes to the existing code. ), where I saw some correspondence and very long text file (perl).

Is there a utility for applying the patch, or a README document for step by step implementation?

In short (for the records): download and install msysgit from
http://code.google.com/p/msysgit/downloads/list
Open git bash and cd into an empty directory like:
cd c:
mkdir pgdev
cd pgdev

Clone the postgresql repository:
git clone git://git.postgresql.org/git/postgresql.git
cd postgresql

Copy the patch (the part with the strange perl-like text of the
message) from
http://archives.postgresql.org/message-id/4E14FD1A.8080703@gmx.de and
save it to a file (like VS2010v9.patch) which you put into the directory
which contains your newly created repository (c:\pgdev).

Apply the Patch:
patch -Ec -p 1 -i ../VS2010v9.patch
(which doesn't seem to apply cleanly anymore which will break things for
you - but I currently have no time to fix it)

Put bison and flex into your path like:
echo "\$ENV{PATH}=\$ENV{PATH} . ';C:\Program Files (x86)\Git\bin';" >
src/tools/msvc/buildenv.pl
(you might have to adopt the path)

Open a Visual Studio 2010 command prompt and cd into the src/tools/msvc
directory of your repository like:
cd C:\pgdev\postgresql\src\tools\msvc

Start the build:
build.bat
(which will break because of the fact that the patch didn't apply cleanly)

I'll take care of the patch as soon as I can (which will not be before
this weekend).
I'm sorry for the bad state of the patch but I've been keepnig it up to
date for months now which isn't always easy.

Regards,
Brar

#9Craig Ringer
craig@2ndquadrant.com
In reply to: Sofer, Yuval (#7)
Re: compile postgres with visual studio 2010

On 21/07/2011 2:56 PM, Sofer, Yuval wrote:

Hi

Ok - but how do I install the patch in the link?

I pressed the latest "patch" link Tom Lane gave me (Patch by brar on 2011-07-07 12:37:47 AM: Added documentation, removed pgflex.pl and pgbison.pl. No changes to the existing code. ), where I saw some correspondence and very long text file (perl).

If you're asking that question, it might be best if you just compile
with Visual Studio 2008 and wait for VS 2010 support to come out in
(hopefully) the next release. Especially since Brian says the patch no
longer corresponds with git master, so you'd need to make code changes
to get it to apply correctly.

I strongly recommend that you use Visual Studio 2008 (the free Express
Edition works and is still available for download) or use the free
Windows SDK for Vista and .NET 3.5.

You can get the SDK from here:
http://www.microsoft.com/download/en/details.aspx?id=11310

--
Craig Ringer

POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088 Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/

#10Rebecca Clarke
rebecca@clarke.net.nz
In reply to: Tom Lane (#5)
Re: Error creating function

Hi Tom

Thanks for your reply. I was restoring one schema (with data) at a time from
8.3 db to a pre-created empty 8.4 db. I received a lot of errors which game
down to me not restoring the public schema first. I also realized, I had not
created plpgsql language for the 8.4 db before I did the restoration. So
after I created the language and restarted the restoration from scratch with
the public schema first, I no longer received this error.

Thanks

Rebecca

On Wed, Jul 20, 2011 at 3:46 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

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