Simon Riggs wrote: > On Sat, 2006-10-21 at 19:24 -0400, Tom Lane wrote: > > Can you make the patch cover the case of > > > > begin; > > truncate foo; > > copy foo from ... > > commit; > > > > It might be infeasible to detect this case, but if it's not ... > > I think it is possible to detect this case without making catalog > entries, so I'll give this a try. Methinks that the truncate *must* be > the immediately preceding command, otherwise we might have a trigger > executing to put rows back into the table before we COPY.
Hmm, is it possible to save the "is empty" info somewhere in local memory, perhaps the relcache (not necessarily propagated), and have heap_insert turn it off? That would help when you do things like begin; truncate foo, bar; copy foo from ... copy bar from ... commit; On the other hand, what happens if you do begin; truncate foo; -- another session copy foo from ... -- original session copy foo from ... commit; How do you detect that the table is no longer empty? -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match