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: add FOR UPDATE locking modes to EXPLAIN output #44790

Merged
merged 1 commit into from
Feb 6, 2020

Conversation

nvanbenschoten
Copy link
Member

Relates to #40205.

This change adds FOR UPDATE locking mode information to the EXPLAIN
output of scanNodes. This is useful for testing that locking modes are
being correctly propagated when a FOR [KEY] UPDATE/SHARE locking clause
is specified. It will be even more useful for testing that locking clauses
are being implicitly applied to UPDATE, UPSERT, and DELETE statements when
we start performing that implicit transformation to their underlying scans.

We currently reject both non-standard locking wait-policies, so we can't easily
test that code. I'm open to suggestions to address that, but I also don't think it's
a very big issue at the moment and I don't think it makes sense to hold off on making
the change while we're already here. If/when we let non-standard locking wait policies
through the optimizer, we'll be able to add similar tests for them.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Relates to cockroachdb#40205.

This change adds FOR UPDATE locking mode information to the EXPLAIN
output of scanNodes. This is useful for testing that locking modes are
being correctly propagated when a FOR [KEY] UPDATE/SHARE locking clause
is specified. It will be even more useful for testing that locking clauses
are being implicitly applied to UPDATE, UPSERT, and DELETE statements when
we start performing that implicit transformation to their underlying scans.
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten and @RaduBerinde)


pkg/sql/walk.go, line 189 at r1 (raw file):

				v.observer.attr(name, "limit", fmt.Sprintf("%d", n.hardLimit))
			}
			if n.lockingStrength != sqlbase.ScanLockingStrength_FOR_NONE {

[nit] consider adding a utility function somewhere that converts uppercase to lowercase and _ to space and then use it with lockingStrength.String()

Copy link
Member Author

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/walk.go, line 189 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] consider adding a utility function somewhere that converts uppercase to lowercase and _ to space and then use it with lockingStrength.String()

I looked into making this change but decided it didn't make things any cleaner. The name we print out here also isn't exactly the name of the enum (which were copied from pg), so we'd need to switch that over. For now, I'm just going to leave this as-is.

craig bot pushed a commit that referenced this pull request Feb 6, 2020
44790: sql: add FOR UPDATE locking modes to EXPLAIN output r=nvanbenschoten a=nvanbenschoten

Relates to #40205.

This change adds FOR UPDATE locking mode information to the EXPLAIN
output of scanNodes. This is useful for testing that locking modes are
being correctly propagated when a FOR [KEY] UPDATE/SHARE locking clause
is specified. It will be even more useful for testing that locking clauses
are being implicitly applied to UPDATE, UPSERT, and DELETE statements when
we start performing that implicit transformation to their underlying scans.

We currently reject both non-standard locking wait-policies, so we can't easily
test that code. I'm open to suggestions to address that, but I also don't think it's
a very big issue at the moment and I don't think it makes sense to hold off on making
the change while we're already here. If/when we let non-standard locking wait policies
through the optimizer, we'll be able to add similar tests for them.

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Contributor

craig bot commented Feb 6, 2020

Build succeeded

@craig craig bot merged commit d8d26ae into cockroachdb:master Feb 6, 2020
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/sfuExplain branch February 6, 2020 23:17
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.

3 participants