Re: Building SPI programs - Mailing list pgsql-general

From Ian Lance Taylor
Subject Re: Building SPI programs
Date
Msg-id siwvai2h3v.fsf@daffy.airs.com
Whole thread Raw
In response to Building SPI programs  (Aristide Aragon <zuri@busa.lionking.org>)
List pgsql-general
Aristide Aragon <zuri@busa.lionking.org> writes:

> I have to do some programming in C or C++ and PostgreSQL.
> Having not ever done this before, I opened the documentation (in my machine, /usr/local/pgsql/doc) and read about the
optionsI had. SPI, libpq, libpq++ and ecpg. I don't want, if possible, an embeded language, or anything that requires a
preprocessor.So, I thought to start by trying the first, SPI, which also seemed to be simple. 

SPI is only for stored procedures which are dynamically linked into
the Postgres backend.

Ordinary code doesn't do that.  It uses some one of the other
mechanisms.

Ian

> /tmp/ccPIp24d.o(.text+0x7): undefined reference to `SPI_connect'
> /tmp/ccPIp24d.o(.text+0x2b): undefined reference to `SPI_exec'
> /tmp/ccPIp24d.o(.text+0x33): undefined reference to `SPI_finish'

When your program is dynamically linked in, those functions will be
satisfied by definitions in the Postgres backend.

> So I supposed I needed to link against some library. With grep I searched /usr/local/pgsql/lib for SPI_, and I found
no.a's matching. 
> I found that /usr/local/pgsql/lib/plpgsql.so and /usr/local/pgsql/lib/pltcl.so had "SPI_", however none worked.

Those are examples of backend procedures which are dynamically linked
in, in those cases to define a language.

Ian

pgsql-general by date:

Previous
From: Aristide Aragon
Date:
Subject: Re: Building SPI programs
Next
From: Ian Lance Taylor
Date:
Subject: Re: Building SPI programs