loosing connection after function call

From: Markus Wagner <wagner(at)imsd(dot)uni-mainz(dot)de>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: loosing connection after function call
Date: 2001-06-26 05:52:48
Message-ID: 3B382330.3D865E3@imsd.uni-mainz.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-sql

Hi,

I would like to put one table create command into a C function
"my_init", just to provide a simple interface for all tables where these
tables are needed. When I execute "select my_init();" I loose the
database connection (pgaccess). Using psql -f I get the errors below. I
reduced the complexity of my table and I found out: The error occurrs,
as soon as I have a "SERIAL" type within my statement. A simple "CREATE
TABLE atl (idx INT);" runs fine, but "CREATE TABLE (idx SERIAL);"
crashes.

Here is my C function:

bool my_init ()
{
if (SPI_connect () < 0)
return (0);

SPI_exec ("CREATE TABLE atl (idx SERIAL);",0);
SPI_finish ();

return (1);
}

Here is my SQL code that I execute using psql -f:

...
<some create tables>
...
SELECT my_init();
...
<other commands>

Here is the error:

psql:sql/test.sql:19: NOTICE: CREATE TABLE will create implicit
sequence 'atl_idx_seq' for SERIAL column 'atl.idx'
psql:sql/test.sql:19: NOTICE: CREATE TABLE/UNIQUE will create implicit
index 'atl_idx_key' for table 'atl'
psql:sql/test.sql:19: NOTICE: mdopen: couldn't open HÛH$5(at)ÿÿÿÿ: No
such file or directory
psql:sql/test.sql:19: ERROR: RelationClearRelation: relation 1034879
deleted while still in use
ERROR: cannot open relation HÛH$5(at)ÿÿÿÿ
FATAL 2: elog: error during error recovery, giving up!
pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally
before or while processing the request.
psql:sql/test.sql:19: connection to server was lost
make: *** [dbs] Error 2

Please help!
Thank you,

Markus Wagner

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Gianluigi Roveda 2001-06-26 14:23:09 PGresult and for-cycle
Previous Message asergioz 2001-06-25 13:35:26 Re: Re: Calculations With NUMERIC Data Type In C Program

Browse pgsql-sql by date

  From Date Subject
Next Message Ilan Fait 2001-06-26 07:41:03 Changing datatype of a column
Previous Message Robby Slaughter 2001-06-26 00:50:48 pl/pgSQL and escaping LIKE clauses