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

sql: support outbound FKs on TTL tables #101225

Closed
ecwall opened this issue Apr 11, 2023 · 2 comments · Fixed by #101236
Closed

sql: support outbound FKs on TTL tables #101225

ecwall opened this issue Apr 11, 2023 · 2 comments · Fixed by #101236
Assignees
Labels
A-row-level-ttl C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ecwall
Copy link
Contributor

ecwall commented Apr 11, 2023

Outbound foreign keys are unaffected by rows being deleted from the TTL table itself and should be easier to support than inbound foreign keys.

Jira issue: CRDB-26871

Epic CRDB-26101

@ecwall ecwall added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) A-row-level-ttl labels Apr 11, 2023
@ecwall ecwall added this to Triage in SQL Sessions - Deprecated via automation Apr 11, 2023
@ecwall ecwall self-assigned this Apr 11, 2023
craig bot pushed a commit that referenced this issue Apr 12, 2023
101236: ttl: allow outbound foreign keys on TTL tables r=otan,rafiss a=ecwall

Fixes #101225

This change allows TTL tables to have outbound foreign keys. Outbound foreign
keys are unaffected by rows being deleted from the TTL table itself.

Release note (sql change): Allow outbound foreign keys on TTL tables.

Co-authored-by: Evan Wall <wall@cockroachlabs.com>
@craig craig bot closed this as completed in 85dc0dd Apr 12, 2023
SQL Sessions - Deprecated automation moved this from Triage to Done Apr 12, 2023
@simplenotezy
Copy link

@ecwall In which version will thsi be supported?

I am getting error:

[0A000] ERROR: relation "refresh_token" (6696): unimplemented: foreign keys from table with TTL "refresh_token" are not permitted Hint: You have attempted to use a feature that is not yet implemented. See: https://go.crdb.dev/issue-v/76407/v22.2

With a FK on refresh_token like this:

FOREIGN KEY (user_region, user_id) REFERENCES "user" (region, id) ON DELETE CASCADE ON UPDATE CASCADE

If I understood #76407 correctly, would it work if we removed the ON DELETE CASCADE?

@ecwall
Copy link
Contributor Author

ecwall commented Jun 21, 2023

@simplenotezy

@ecwall In which version will thsi be supported?

Outbound foreign keys are supported in v22.2.9 and v23.1.2.

If I understood #76407 correctly, would it work if we removed the ON DELETE CASCADE?

It isn't related to whether you use ON DELETE CASCADE or not with the outbound foreign key. The complexity around ON DELETE CASCADE only applies to inbound foreign keys, but all foreign keys were initially unsupported for simplicity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-row-level-ttl C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants