forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[yugabyte#10594] YSQL: Add sub-query AfterTrigger block for constrain…
…t checking in CopyFrom operation Summary: Previously, when inserting rows via a COPY operation, one adds checking intent that checks for errors during the copy block, but only invokes the event after all rows have been copied. This results in invalid rows could be inserted to the table even though they fail the constraint check. To resolve the issue, we add sub-query block AfterTriggerBeginQuery() and AfterTriggerEndQuery() for each batch of data being copied to the table. AfterTriggerEndQuery() will invoke the constraint checking for the current batch, and fail that batch if the constraint check fails and these rows will not be inserted to the table. In addition, per @dmitry and @mihnea 's suggestion, we disable batching if the table contains non-FK trigger. This makes the table able to rollback if triggers are fired and caused copying to stop. However, it's possible that the prior batches are valid and get inserted to the table. Consider the following example: Input file <valid row 1> <valid row 2> <valid row 3> <invalid row> <invalid row> If ROWS_PER_TRANSACTION=2, the constraint checking will successfully process and insert batch #1, and fail batch #2. As such, the first two rows will be inserted to the table. Test Plan: ybd --java-test org.yb.pgsql.TestBatchCopyFrom Run a copy test manually (with the example shown in the Github ticket). All (successful and failure) should pass. Reviewers: smishra, jason, alex, mihnea, ena, dmitry Reviewed By: dmitry Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D15649
- Loading branch information
1 parent
d2c6be0
commit 7c428da
Showing
6 changed files
with
249 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters