Skip to content

Minor updates to support UPDATE ... FROM in Doltgres #3016

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

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

fulghum
Copy link
Contributor

@fulghum fulghum commented Jun 6, 2025

Minor changes to support UPDATE ... FROM in Doltgres (dolthub/doltgresql#1536)

While working on this, I noticed a few issues with the UPDATE ... JOIN support in GMS:

  • There was duplicated logic for UPDATE ... JOIN in PlanBuilder.buildUpdate() and in the analyzer rule modifyUpdateExprsForJoin. Not all UPDATE ... JOIN statements can be handled in PlanBuilder, because some statements, like IN SUBQUERY, are transformed into a join during analysis, so we need logic in the analyzer to identify UPDATE ... JOIN plans after that transformation. To reduce the duplication, I removed the logic from PlanBuilder and now we rely on on the modifyUpdateExprsForJoin rule to mark all UPDATE ... JOIN plans.
  • Callers use plan.GetUpdatable() to get a reference to the table being updated, but UPDATE ... JOIN can update multiple tables. The GetUpdatable() APIs should be refactored to model this, otherwise we cannot accurately track multiple tables being modified and apply all the correct triggers/constraints.
  • Currently UPDATE ... JOIN never honors foreign key constraints, due to limitations in the concrete type UpdateJoin.GetUpdatable() returns. The updatableJoinTable type does not implement sql.ForeignKeyTable, so GMS is unable to load any foreign key constraints from it. This also needs to be handled in a future PR.

@fulghum fulghum force-pushed the fulghum/update_join branch from 9dfae69 to 81ea421 Compare June 9, 2025 20:57
@fulghum fulghum marked this pull request as ready for review June 9, 2025 21:09
@fulghum fulghum force-pushed the fulghum/update_join branch from 81ea421 to 5e9e2f3 Compare June 9, 2025 21:24
@fulghum fulghum requested a review from jycor June 9, 2025 21:36
Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fulghum fulghum merged commit c44b30c into main Jun 9, 2025
8 checks passed
@fulghum fulghum deleted the fulghum/update_join branch June 9, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants