-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
6ba9593
to
7f61237
Compare
LGTM, should leave a note about why the test case was changed too. Needs @jordanlewis to sign off for landing though. |
7f61237
to
d01147e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
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
d01147e
to
f86a3e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained
bors r+ |
Build failed (retrying...) |
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]>
Build succeeded |
@nstewart this is merged now FYI |
awesome. nice usability win. Thank you @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