pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Wagner <wagner@imsd.uni-mainz.de>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
To: pgsql-interfaces <pgsql-interfaces@postgresql.org>
Subject: loosing connection after function call
Date: Tue, 26 Jun 2001 07:52:48 +0200
Message-ID: <3B382330.3D865E3@imsd.uni-mainz.de> (raw)

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@ÿÿÿÿ: 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@ÿÿÿÿ
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



view thread (2+ messages)  latest in thread

Message-ID: <3B382330.3D865E3@imsd.uni-mainz.de>
Permalink:  ../3B382330.3D865E3@imsd.uni-mainz.de/
Also on:    postgresql.org/message-id/3B382330.3D865E3@imsd.uni-mainz.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: wagner@imsd.uni-mainz.de, pgsql-sql@postgresql.org
  Subject: Re: loosing connection after function call
  In-Reply-To: <3B382330.3D865E3@imsd.uni-mainz.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox