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: handle AOST in multi-stmt implicit txn #97063

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Feb 13, 2023

fixes #85066

Release note (bug fix): Fixed a bug where the AS OF SYSTEM TIME clause was handled correctly in an implicit transaction that had multiple statements.

@rafiss rafiss requested review from Xiang-Gu, ZhouXing19 and a team February 13, 2023 19:28
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@ZhouXing19 ZhouXing19 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 @rafiss and @Xiang-Gu)


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

	// Implicit transactions can have multiple statements, so we need to check
	// if one has already been executed.
	if ex.implicitTxn() && !ex.extraTxnState.firstStmtExecuted {

Just to make sure I understand it correctly -- in this block, we set the planner's txn-state's timestamp with the one of the asof stmt, as we assume there's only one statement, which is the as of , running. We shouldn't do this if there're more than 1 stmts in the implicit txn.

Does it mean that if there're more than 1 statements, and the first one is an AS OF, it still should work?

If so, maybe we can add this case to the logic test as well?

@rafiss
Copy link
Collaborator Author

rafiss commented Feb 13, 2023

Yeah that is correct. That's a good idea for a test! I added it.

@rafiss rafiss requested a review from ZhouXing19 February 13, 2023 19:52
Copy link
Collaborator

@ZhouXing19 ZhouXing19 left a comment

Choose a reason for hiding this comment

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

LGTM!

@rafiss rafiss requested a review from a team as a code owner February 13, 2023 21:00
Release note (bug fix): Fixed a bug where the AS OF SYSTEM TIME
clause was handled correctly in an implicit transaction that had
multiple statements.
@rafiss
Copy link
Collaborator Author

rafiss commented Feb 14, 2023

bors r=ZhouXing19

@craig
Copy link
Contributor

craig bot commented Feb 14, 2023

Build succeeded:

@craig craig bot merged commit f3ff417 into cockroachdb:master Feb 14, 2023
@blathers-crl
Copy link

blathers-crl bot commented Feb 14, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 33c9c53 to blathers/backport-release-22.2-97063: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

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.

v22.1.4: txn_coord_sender.go:1085: cannot set fixed timestamp
3 participants