Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
sql: support UPDATE ... FROM #7841
(edit @knz 2018-05-19)
performs (I think) a lateral join of X with Z and then makes the values computed by Z available for the scalar expressions in Y, to serve as values to update.
Reduced support when the relational expression Z is uncorrelated (a common case) could perhaps be added with a simple join, although additional execution machinery is still needed to propagate the PK prefixes for the X operand to the join through up to the point UPDATE can pick them up.
As to which rows get updated:
The work to be done is twofold:
I would also like to vote for this to be implemented. I need to do some conditional operations on a sum of values from child records. In PostgreSQL I can do it in a single query, while I guess in CockroachDB I will need to split it into multiple separate ones.
The query looks something like this (with simplified conditions here):
moved this from Triage
to Feature requests / pie-in-the-skie
in SQL Front-end, Lang & Semantics
May 3, 2018
referenced this issue
Sep 8, 2018
Discussed this with @andy-kimball yesterday - Andy confirmed that once the opt framework knows about mutations, planning update...from will be a natural extension of the support for correlated subqueries and lateral joins.
(Of course ensuring the statement is recognized in the first place will still require some extra work)
Example use on the forum: https://forum.cockroachlabs.com/t/how-to-update-one-table-from-another/2217