simple function crashes my postmaster - Mailing list pgsql-sql

From Meggus
Subject simple function crashes my postmaster
Date
Msg-id 01062617341600.20616@mws
Whole thread Raw
Responses Re: simple function crashes my postmaster
List pgsql-sql
Hi,

there is a mystic problem with a simple C function which creates a table. 
I minimized the code to reproduce the error. It crashes on two different 
Linux systems (SuSE) and with pg 7.0/7.1. I found that the crash occurrs 
as soon as I use a SERIAL type in the table creation command.

Please help,

thank you,

Markus

Here is the C function:

bool crash ()
{if (SPI_connect () < 0) return (false);
SPI_exec ("CREATE TABLE atl (idx SERIAL)",0);
SPI_finish ();
return (true);
}

Here is the SQL code:

CREATE FUNCTION    crash() RETURNS BOOL AS '/usr/lib/mycode.so' LANGUAGE 'C';
SELECT crash();

And this is the backend's log:

{ QUERY   :command 5    :create atl      { CREATE      :relname atl      :istemp false          :columns (        {
COLUMNDEF        :colname idx         :typename            { TYPENAME            :name int4            :timezone false
         :setof false typmod -1            :arrayBounds <>           }                 :is_not_null true
:is_sequencetrue         :raw_default            {FUNCTION nextval            :args (              {CONST
"\"atl_idx_seq""               :typename <>              }           )                       :agg_star false
:agg_distinctfalse            }                 :cooked_default <>         :constraints (           { atl_idx_seq
    :type DEFAULT            :raw               {FUNCTION nextval               :args (                 {CONST
"\"atl_idx_seq""                  :typename <>                 }              )                             :agg_star
false              :agg_distinct false               }                       :cooked <>           }
{atl_idx_key            :type UNIQUE (              { IDENT idx              }           )           }
 { <>            :type NOT NULL           }        )        }     )           :inhRelnames <>      :constraints <>
}    :resultRelation 0   :into <>   :isPortal false   :isBinary false   :isTemp false   :unionall false
:distinctClause<>   :sortClause <>   :rtable <>   :targetlist <>   :qual <>   :groupClause <>   :havingQual <>
:hasAggsfalse   :hasSubLinks false   :unionClause <>   :intersectClause <>   :limitOffset <>   :limitCount <>
:rowMark<>  }
 

{ QUERY   :command 5    :index atl_idx_key on atl      { INDEX      :idxname atl_idx_key      :relname atl
:accessMethodbtree      :indexParams (        { INDEXELEM         :name idx         :args <>         :class <>
:typename<>        }     )           :withClause <>      :whereClause <>      :rangetable <>      :lossy false
:uniquetrue      }     :resultRelation 0   :into <>   :isPortal false   :isBinary false   :isTemp false   :unionall
false  :distinctClause <>   :sortClause <>   :rtable <>   :targetlist <>   :qual <>   :groupClause <>   :havingQual <>
:hasAggs false   :hasSubLinks false   :unionClause <>   :intersectClause <>   :limitOffset <>   :limitCount <>
:rowMark<>  }
 
010626.17:02:16.391 [21378] ERROR:  RelationClearRelation: relation 38354 
deleted while still in use

010626.17:02:16.391 [21378] AbortCurrentTransaction
010626.17:02:16.392 [21378] NOTICE:  mdopen: couldn't open ØÈÞ"ÿÿÿÿ: No 
such file or directory
010626.17:02:16.392 [21378] ERROR:  cannot open relation ØÈÞ"ÿÿÿÿ
010626.17:02:16.393 [21378] FATAL 2:  elog: error during error recovery, 
giving up!
010626.17:02:16.393 [21378] proc_exit(2)
010626.17:02:16.393 [21378] shmem_exit(2)
010626.17:02:16.393 [21378] exit(2)
/usr/bin/postmaster: reaping dead processes...
/usr/bin/postmaster: CleanupProc: pid 21378 exited with status 512
Server process (pid 21378) exited with status 512 at Tue Jun 26 17:02:16 
2001
Terminating any active server processes...
Server processes were terminated at Tue Jun 26 17:02:16 2001
Reinitializing shared memory and semaphores
010626.17:02:16.397 [21346] shmem_exit(0)
binding ShmemCreate(key=52e325, size=1104896)
010626.17:02:16.398 [21379] DEBUG:  Data Base System is starting up at Tue 
Jun 26 17:02:16 2001
010626.17:02:16.398 [21379] DEBUG:  Data Base System was interrupted being 
in production at Tue Jun 26 17:02:12 2001
010626.17:02:16.399 [21379] DEBUG:  Data Base System is in production 
state at Tue Jun 26 17:02:16 2001
010626.17:02:16.399 [21379] proc_exit(0)
010626.17:02:16.399 [21379] shmem_exit(0)
010626.17:02:16.399 [21379] exit(0)
/usr/bin/postmaster: reaping dead processes...
010626.17:02:19.997 [21346] pmdie 2
Fast Shutdown request at Tue Jun 26 17:02:19 2001
010626.17:02:19.998 [21380] DEBUG:  Data Base System shutting down at Tue 
Jun 26 17:02:19 2001
010626.17:02:19.999 [21380] DEBUG:  Data Base System shut down at Tue Jun 
26 17:02:19 2001
010626.17:02:19.999 [21380] proc_exit(0)
010626.17:02:19.999 [21380] shmem_exit(0)
010626.17:02:19.999 [21380] exit(0)
/usr/bin/postmaster: reaping dead processes...
010626.17:02:19.999 [21346] proc_exit(0)
010626.17:02:19.999 [21346] shmem_exit(0)
010626.17:02:20.007 [21346] exit(0)


pgsql-sql by date:

Previous
From: jim_esti@hotmail.com (Jim)
Date:
Subject: Text manipulation in SQL
Next
From: Bhuvan A
Date:
Subject: ConnecDB() -- couldn't send SSL negotiation packet: