Bug report

Andrea Baldoni <abaldoni@tiscalinet.it>

From: Andrea Baldoni <abaldoni@tiscalinet.it>
To: pgsql-bugs@postgresql.org
Date: 2000-11-20T15:01:25Z
Lists: pgsql-bugs
To report any other bug, fill out the form below and e-mail it to
pgsql-bugs@postgresql.org.

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name		: Andrea Baldoni
Your email address	: abaldoni@tiscalinet.it


System Configuration
---------------------
  Architecture 		: Intel Pentium III 500

  Operating System 	: Linux 2.4.0-test10 (same problem on 2.2.17),
				debian 2.2

  PostgreSQL version 	: PostgreSQL-6.5.2 

  Compiler used 	: gcc version 2.95.2 20000313


Please enter a FULL description of your problem:
------------------------------------------------

Creating tables (temp or normal) inside a transaction sometime fails,
ending with corruption in pg_attribute system data table (if I do
"select * from pg_attribute" the server crash). If I stop and restart the
server the problem remains... I must restore pg_attribute* files to make
things working. The file having the name of the table created sometime
remains in the file system.

Debug output:

.
.
pq_flush: send() failed: Bad file descriptor
pq_flush: send() failed: Bad file descriptor
pq_recvbuf: recv() failed: Bad file descriptor
ERROR: infinite recursion in proc_exit
pq_flush: send() failed: Bad file descriptor
NOTICE: AbortTransaction and not in in-progress state
pq_flush: send() failed: Bad file descriptor
pq_flush: send() failed: Bad file descriptor
pq_recvbuf: recv() failed: Bad file descriptor
ERROR: infinite recursion in proc_exit
.
.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

I'm using many script like this one, accessing different tables, and I haven't
found differences.
Sample bash script:

#!/bin/bash
umask 077
cat << EOF |psql abaldoni 2> /dev/null > /tmp/$0$$

begin transaction;

create temp table excontitmp0 (
	id_documento integer,
	totale real
);

create temp table excontitmp1 (
	id_documento integer,
	totale real
);

create temp table excontitmp2 (
	numerario integer
);

insert into excontitmp2 select numerario from conti_desc where
	capoconto=$1 and sottoconto=$2;

insert into excontitmp0 select id_documento,
	sum(importo) as totale from conti where capo_da=$1 and sotto_da=$2
	and documenti.data>='01/01/2000' and
	id_documento=documenti.id group by id_documento;

insert into excontitmp0 select id_documento,
	-sum(importo) as totale from conti where capo_a=$1 and sotto_a=$2
	and documenti.data>='01/01/2000' and
	id_documento=documenti.id group by id_documento;

insert into excontitmp1 select id_documento, sum(totale)
	as totale from excontitmp0 group by id_documento;

select id_documento, documenti.data, ditte.ragione_sociale,
	totale*(1-excontitmp2.numerario*2) from
	excontitmp1 where ditte.id=documenti.id_clifor and
	documenti.id=id_documento order by documenti.data, id_documento;

select sum(totale*(1-excontitmp2.numerario*2)) as totale from excontitmp0;

commit transaction;

EOF

less /tmp/$0$$
rm /tmp/$0$$

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Ciao,
 AB