Use subtransaction , the tuples that had inserted into heap must be inserted again when some exception is raised,
it is too expensive.
My solution is :
1. delete the tuple that caused the error tuple;
2. release all the resources when inserting the tuple;
3. continue insert next tuple
Is it feasible? Anybody give me some suggestion?
no, it should not work - after any exception some memory structures should be in undefined state. Errors in PostgreSQL are destructive and any error must be followed by ROLLBACK.
Subtransaction for any row is expensive, but subtransaction for some block is cheap