Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Support deferrable for foreign key constraints #3995

Closed
ndeodhar opened this issue Mar 17, 2020 · 0 comments
Closed

[YSQL] Support deferrable for foreign key constraints #3995

ndeodhar opened this issue Mar 17, 2020 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL)
Projects

Comments

@ndeodhar
Copy link
Contributor

PG supports deferrable for PK, unique, foreign key and exclude constraints.
In YB, supporting deferrable for PK and unique constraints is non-trivial.
To begin with, we could support it only for FK constraints. This will help unblock issues like #3987 used by Django.

@ndeodhar ndeodhar added the area/ysql Yugabyte SQL (YSQL) label Mar 17, 2020
@ndeodhar ndeodhar self-assigned this Mar 17, 2020
@ndeodhar ndeodhar added this to To do in YSQL via automation Mar 17, 2020
@ndeodhar ndeodhar assigned d-uspenskiy and unassigned ndeodhar Mar 27, 2020
d-uspenskiy added a commit that referenced this issue May 31, 2020
Summary:
Deferred triggers access tuplestore at the end of subtransaction (after call of `AfterTriggerEndQuery` function).
But it is no accessible as pointer to tuplestore is stored in `query_stack` which is already empty at this point.
To solve the issue pointer to tuplestore for deferred trigger is be stored in new field `ybc_txn_fdw_tuplestore` of the `AfterTriggerSharedData` structure.
**Additional changes**
Deferred triggers are fired from the `CommitTransaction` function and YB transaction must not be committed before that time. Calling of `YBCPgCommitTransaction` function is moved inside `CommitTransaction` function.

Test Plan:
Postgresql regression tests were uncommented
```
./yb_build.sh --java-test org.yb.pgsql.TestPgForeignKey
./yb_build.sh --cxx-test pg_on_conflict-test --gtest_filter PgOnConflictTest.ValidSessionAfterTxnCommitConflict
```

Reviewers: mikhail, neha, mihnea

Reviewed By: mihnea

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D8379
YSQL automation moved this from To do to Done May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL)
Projects
YSQL
  
Done
Development

No branches or pull requests

2 participants