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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/users-lounge/docs/faq.html