Skip to content

sql: Improve AS OF SYSTEM TIME error message #40948

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
Sep 30, 2019

Conversation

arulajmani
Copy link
Collaborator

@arulajmani arulajmani commented Sep 20, 2019

Improve the error message to hint the SET TRANSACTION syntax instead
of saying AOST can't be generally used inside a transaction.

Fixes #40204

Release note: None

Release justification: Minor change

@arulajmani arulajmani requested review from solongordon and a team September 20, 2019 19:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@arulajmani arulajmani force-pushed the aost-error-message branch 2 times, most recently from 6ba9593 to 7f61237 Compare September 20, 2019 21:33
@rohany
Copy link
Contributor

rohany commented Sep 23, 2019

LGTM, should leave a note about why the test case was changed too.

Needs @jordanlewis to sign off for landing though.

Copy link
Contributor

@solongordon solongordon 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 (waiting on @arulajmani and @solongordon)


pkg/sql/as_of_test.go, line 230 at r1 (raw file):

	// Can't use in a transaction.
	_, err = db.Query(
		fmt.Sprintf("BEGIN; SELECT a FROM d.t AS OF SYSTEM TIME %s; COMMIT;", tsVal1))

I don't see any reason to delete this test.


pkg/sql/as_of_test.go, line 233 at r1 (raw file):

			"SET TRANSACTION AS OF SYSTEM TIME %s; "+
			"SELECT a FROM d.t; "+
			"COMMIT;", tsVal1)).Scan(&i); err != nil {

Nit: You can use backticks to include newlines in your string:

	if err := db.QueryRow(fmt.Sprintf(`
		BEGIN;
		SET TRANSACTION AS OF SYSTEM TIME %s;
		SELECT a FROM d.t;
		COMMIT;
	`, tsVal1)).Scan(&i); err != nil {

pkg/sql/conn_executor_exec.go, line 392 at r1 (raw file):

					"inconsistent AS OF SYSTEM TIME timestamp; expected: %s", origTs)
				err = errors.WithHint(err, fmt.Sprintf("See %s for help with AS OF SYSTEM TIME",
					base.DocsURL("as-of-system-time.html#using-as-of-system-time-in-transactions")))

I inquired about including docs URLs in errors recently, and the current guidance was to avoid this until we have better guardrails around it. See #40799. Maybe for now we could just change the hint to "try SET TRANSACTION AS OF SYSTEM TIME".

Improve the error message to hint the SET TRANSACTION syntax  instead
of saying AOST can't be generally used inside a transaction.

Fixes cockroachdb#40204

Release note: None

Release justification: Minor change
Copy link
Collaborator Author

@arulajmani arulajmani 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 (waiting on @solongordon)


pkg/sql/as_of_test.go, line 230 at r1 (raw file):

Previously, solongordon (Solon) wrote…

I don't see any reason to delete this test.

Done.


pkg/sql/conn_executor_exec.go, line 392 at r1 (raw file):

Previously, solongordon (Solon) wrote…

I inquired about including docs URLs in errors recently, and the current guidance was to avoid this until we have better guardrails around it. See #40799. Maybe for now we could just change the hint to "try SET TRANSACTION AS OF SYSTEM TIME".

Done.

Copy link
Contributor

@solongordon solongordon 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

@arulajmani
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 30, 2019

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Sep 30, 2019
40948: sql: Improve AS OF SYSTEM TIME error message r=arulajmani a=arulajmani

Improve the error message to hint the SET TRANSACTION syntax  instead
of saying AOST can't be generally used inside a transaction.

Fixes #40204

Release note: None

Release justification: Minor change

Co-authored-by: Arul Ajmani <[email protected]>
@craig
Copy link
Contributor

craig bot commented Sep 30, 2019

Build succeeded

@craig craig bot merged commit f86a3e9 into cockroachdb:master Sep 30, 2019
@awoods187
Copy link
Contributor

@nstewart this is merged now FYI

@arulajmani arulajmani deleted the aost-error-message branch September 30, 2019 22:37
@nstewart
Copy link
Contributor

nstewart commented Oct 1, 2019

awesome. nice usability win. Thank you @arulajmani!

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.

Improve error message: Generally AS OF SYSTEM TIME cannot be used inside a transaction
6 participants