Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#659: [YSQL] Support updating primary key columns
Summary: # Main changes: * We now allow `UPDATE` to change primary key columns. * For that, when we detect that `UPDATE` affects one or more primary key columns, instead of a regular "update", we perform a "replace" operation - we delete an existing row and insert a new one instead. - This is less efficient than a normal `UPDATE` (especially in a single row case), so we should recommend avoiding overusing this for performance reasons. - Note that unlike a regular "update", this changes `ybctid` of an updated row. * "Single-row transaction" optimization is not applicable to such "replacing" `UPDATE`s, so it was disabled for them at the query planner level. * Fixed various broken `pg_regress` tests, but most importantly `yb_pg_foreign_key` - I used original `foreign_key` test as a reference and verified changes against vanilla PostgreSQL v11. # Other changes: * `GetYBTablePrimaryKey` was a function where we weirdly used original `FirstLowInvalidHeapAttributeNumber` instead of `YBGetFirstLowInvalidAttributeNumber(rel)` as we do in other places. This has been changed for uniformity. * A bunch of (sometimes local) utility functions were moved to `pg_yb_utils.h` and `ybcplan.h` since they're used across different source files now. Their names were changed accordingly. * Avoided unnecessary reopen of relation in `yb_single_row_update_or_delete_path` * `YBCAllPrimaryKeysProvided` changed to rely on `YBGetTablePrimaryKeyBms` --- Resolves #659 Test Plan: ybd --java-test org.yb.pgsql.TestPgUpdatePrimaryKey Also indirectly by other tests: ybd --java-test org.yb.pgsql.TestPgUpdate ybd --java-test org.yb.pgsql.TestPgForeignKey ybd --java-test org.yb.pgsql.TestPgRegressDml ybd --java-test org.yb.pgsql.TestPgRegressPlpgsql ybd --java-test org.yb.pgsql.TestPgRegressAuthorization Reviewers: neil, mikhail, dmitry, mihnea Reviewed By: mihnea Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D8998
- Loading branch information
1 parent
955a872
commit 3f3bf49
Showing
18 changed files
with
1,038 additions
and
366 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
Oops, something went wrong.