On Thu, 2006-08-31 at 17:25, Alban Hertroys wrote: > Csaba Nagy wrote: > > The code is possible to be executed in parallel by multiple threads, on > > different connections, or in sequence on the same connection. I would > > expect it in both cases to work correctly... in manual tests I was able > > to create in parallel temporary tables named identically in different > > connections, and on the same connection after rolling back the > > transaction which created the first table... so I don't know what to try > > to trigger this. > > > > Any ideas what's the problem ? > > Are you sure that you're not re-using an existing connection from a pool? Of course I'm re-using a connection from a pool... but if you look at the pseudo-code from the OP, the temporary table is either dropped or the transaction which creates it is rolled back, before the connection is returned to the pool. When another thread is reusing the connection, the table should be dropped either way, and manual tests show that it works both ways, so I guess it is some race condition somewhere else. In any case, the error message is strange in itself, as if I try to create the temporary table when it exists, the error I get in manual trial is: ERROR: relation "test_temp_table" already exists ^^^^^^^^ compared to the error from the OP which I cite here for reference: ERROR: type "temp_report" already exists ^^^^ So it was complaining about an already existing type, not relation. Any ideas ? I'm still clueless. Cheers, Csaba.