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: fix UPSERT RETURNING in presence of schema changes #29487

Merged
merged 1 commit into from
Sep 4, 2018

Conversation

jordanlewis
Copy link
Member

@jordanlewis jordanlewis commented Sep 3, 2018

Fixes #29436.

Release note (bug fix): fix crash caused by certain kinds of UPSERT
RETURNING statements on tables with active schema changes.

@jordanlewis jordanlewis requested review from vivekmenezes and a team September 3, 2018 16:41
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@vivekmenezes vivekmenezes left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/descriptor_mutation_test.go, line 191 at r2 (raw file):

	mTest.Exec(t, `UPSERT INTO t.test VALUES('a', 'bar')`)

	mTest.Exec(t, `UPSERT INTO t.test VALUES('foo') RETURNING k`)

Looks like you only need this statement in this test; right?

Also, could you add an INSERT statement as well. Thanks!


pkg/sql/tablewriter_upsert.go, line 43 at r2 (raw file):

	// rowIdxToRetIdx maps the indices in the inserted rows
	// back to indices in rowTemplate. Contains -1 for indices in the inserted
	// rows that shouldn't be returned to the user - mutation columns.

how about creating

const dontReturnCol = -1

It will make this code more readable

@jordanlewis
Copy link
Member Author

Thanks, will do. Also, this fix isn't complete, there's another bug lurking... will send another patch.

Copy link
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/descriptor_mutation_test.go, line 191 at r2 (raw file):

Previously, vivekmenezes wrote…

Looks like you only need this statement in this test; right?

Also, could you add an INSERT statement as well. Thanks!

Done.


pkg/sql/tablewriter_upsert.go, line 43 at r2 (raw file):

Previously, vivekmenezes wrote…

how about creating

const dontReturnCol = -1

It will make this code more readable

Done.

@jordanlewis jordanlewis requested a review from a team September 4, 2018 04:27
Release note (bug fix): fix crash caused by certain kinds of UPSERT
RETURNING statements on tables with active schema changes.
@jordanlewis
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Sep 4, 2018
29487: sql: fix UPSERT RETURNING in presence of schema changes r=jordanlewis a=jordanlewis

Fixes #29436.

Release note (bug fix): fix crash caused by certain kinds of UPSERT
RETURNING statements on tables with active schema changes.

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Contributor

craig bot commented Sep 4, 2018

Build succeeded

@craig craig bot merged commit e9f0f9b into cockroachdb:master Sep 4, 2018
@jordanlewis jordanlewis deleted the fix-upsert-returning branch September 4, 2018 17:45
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.

sql: v2.0.5: panic while executing 1 statements: UPSERT panics in AddRow
3 participants