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

release-2.0: sql: miscellaneous INSERT, UPSERT and UPDATE correctness fixes #26181

Merged
merged 3 commits into from May 29, 2018

Conversation

knz
Copy link
Contributor

@knz knz commented May 29, 2018

Backport 3/3 commits from #26169.

/cc @cockroachdb/release

Fixes #25726.

knz added 3 commits May 29, 2018 22:06
The UPSERT code on the "happy" path (either the fast path, or the long
path when there is no conflict) uses the INSERT row writer with a flag
"ignore duplicate errors", with the expectation that code would do the
Right Thing if the raw already exists (using KV Puts instead of
CPuts).

Unfortunately the INSERT rowwriter does the wrong thing when the row
already existed before, and the new row (or a column family in the new
row) contains just NULLs: in that case, the correct way to "update"
the row in KV is to issue a Del, which INSERT (expectedly) didn't do.

This patch addresses the issue by making the INSERT row writer able to
issue Puts.

Release note (bug fix): UPSERT is now properly able to write NULLs to
every columns in tables containing more than one column family.
Prior to this patch, UPDATE on a column family other than the first
where the column family only contains 1 column, would write an empty
value in KV instead of erasing the K/V pair (as is expected).

This appeared to be OK because the table reader currently
automatically converts unexpected empty values in KV pairs to NULLs,
but the error was messing up with KV tracing.

Release note: None
This was a TODO left by @danhhz a long time ago.

In fact merging this code was useful beyond DRY, since both
implementations were performing slightly different optimizations that
would benefit from being done together, always.

Release note: None
@knz knz requested review from BramGruneir and a team May 29, 2018 20:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz added this to Triage in (DEPRECATED) SQL Front-end, Lang & Semantics via automation May 29, 2018
@knz knz moved this from Triage to Finished (milestone 0529) in (DEPRECATED) SQL Front-end, Lang & Semantics May 29, 2018
@BramGruneir
Copy link
Member

:lgtm:


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks pending.


Comments from Reviewable

@knz
Copy link
Contributor Author

knz commented May 29, 2018

Thanks!

bors r+

craig bot pushed a commit that referenced this pull request May 29, 2018
26181: release-2.0: sql: miscellaneous INSERT, UPSERT and UPDATE correctness fixes r=knz a=knz

Backport 3/3 commits from #26169.

/cc @cockroachdb/release

Fixes #25726.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented May 29, 2018

Build succeeded

@craig craig bot merged commit 7f01983 into cockroachdb:release-2.0 May 29, 2018
@knz knz deleted the backport2.0-26169 branch July 2, 2018 09:31
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.

None yet

3 participants