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

parser: add AsOfClause for START TRANSACTION READ ONLY statement #1215

Merged
merged 10 commits into from
May 18, 2021
7 changes: 6 additions & 1 deletion ast/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ const (
Year = "year"
YearWeek = "yearweek"
LastDay = "last_day"
TiDBParseTso = "tidb_parse_tso"
// TSO functions
// TiDBBoundStaleness is used to determine the TS for a read only request.
// It will be used in the Stale Read feature.
// For more info, please see AsOfClause.
TiDBBoundStaleness = "tidb_bound_staleness"
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be bounded staleness rather than bound staleness.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's ok to use the passive voice bound here as an adjective, and it's shorter than bounded.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you google bound staleness, the results are all bounded staleness.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough. So what about tidb_bounded_staleness or tidb_staleness_bound?

Copy link
Member Author

@JmPotato JmPotato May 11, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I rename it to tidb_staleness_bound, PTAL!

Copy link
Contributor

Choose a reason for hiding this comment

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

@morgo PTAL, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer tidb_bounded_staleness . :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I agree with @nolouch :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

@morgo @nolouch @djshow832 I finished the renaming, PTAL.

TiDBParseTso = "tidb_parse_tso"

// string functions
ASCII = "ascii"
Expand Down
6 changes: 6 additions & 0 deletions ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ type BeginStmt struct {
ReadOnly bool
Bound *TimestampBound
CausalConsistencyOnly bool
// AS OF is used to see the data as it was at a specific point in time.
JmPotato marked this conversation as resolved.
Show resolved Hide resolved
// Should only be used when ReadOnly is true.
AsOf *AsOfClause
}

// Restore implements Node interface.
Expand All @@ -415,6 +418,9 @@ func (n *BeginStmt) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord(" WITH TIMESTAMP BOUND MIN READ TIMESTAMP ")
return n.Bound.Timestamp.Restore(ctx)
}
} else if n.AsOf != nil {
ctx.WriteKeyWord(" ")
return n.AsOf.Restore(ctx)
}
} else if n.CausalConsistencyOnly {
ctx.WriteKeyWord("START TRANSACTION WITH CAUSAL CONSISTENCY ONLY")
Expand Down
Loading