Re: How to implement the skip errors for copy from ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: xbzhang <xbzhang(at)kingbase(dot)com(dot)cn>
Cc: "Amit Kapila" <amit(dot)kapila16(at)gmail(dot)com>, "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to implement the skip errors for copy from ?
Date: 2014-06-17 13:40:43
Message-ID: 16380.1403012443@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

xbzhang <xbzhang(at)kingbase(dot)com(dot)cn> writes:
> LWlocks can record in resource owner per tuples, so they can be releasedat rigth way, but the memory allocated on memory contextis one problem.Are there any others problems?

See AbortSubTransaction(), CleanupSubTransaction(), and the rather large
number of subroutines they call. Almost everything that code does is
connected to cleaning up something that might have been left unfinished
after an elog(ERROR) took control away in the middle of some code
sequence.

In addition, you can't just wave your hands and presto the bad tuple is
not there anymore. For example, the failure might have been a unique key
violation in some index or other. Not only is the bad tuple already on
disk, but possibly so are index entries for it in other indexes. In
general the only way to get rid of those index entries is a VACUUM.
So you really have to have a subtransaction whose XID is what you mark
the new tuple with, and then rolling back the subtransaction is what
causes the new tuple to not be seen as good. (Actually getting rid of
it will be left for the next VACUUM.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-06-17 13:46:13 Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules
Previous Message Andres Freund 2014-06-17 13:05:20 Re: Wait free LW_SHARED acquisition - v0.2