-
Notifications
You must be signed in to change notification settings - Fork 3
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
slack-15.0
: backport vitessio/vitess#16154
#420
Changes from 8 commits
529c16b
4ac6278
3ee6f07
31bee01
748d9c2
6de3492
75f552b
4ab096b
20ee454
cb6e9ad
2f10041
261f9c5
b978f63
35353c5
121d127
ae6c966
92cd529
7a5457e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2707,6 +2707,34 @@ type ( | |
} | ||
|
||
CountStar struct { | ||
Name string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GuptaManan100 would this reduce the cost of this change? Enough to matter?
or a more generic:
(
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could matter. It would definitely reduce the size of the struct, but how meaningful that overall change is going to be to runtime, we'll have to test. I don't think it would be very significant either way, because we do need to print the string eventually during formatting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GuptaManan100 makes sense. I think we aren't too worried about something this finite, so I suppose I'm just thinking aloud how a potential fix to |
||
_ bool | ||
// TL;DR; This makes sure that reference equality checks works as expected | ||
// | ||
// You're correct that this might seem a bit strange at first glance. | ||
// It's a quirk of Go's handling of empty structs. In Go, two instances of an empty struct are considered | ||
// identical, which can be problematic when using these as keys in maps. | ||
// They would be treated as the same key and potentially lead to incorrect map behavior. | ||
// | ||
// Here's a brief example: | ||
// | ||
// ```golang | ||
// func TestWeirdGo(t *testing.T) { | ||
// type CountStar struct{} | ||
// | ||
// cs1 := &CountStar{} | ||
// cs2 := &CountStar{} | ||
// if cs1 == cs2 { | ||
// panic("what the what!?") | ||
// } | ||
// } | ||
// ``` | ||
// | ||
// In the above code, cs1 and cs2, despite being distinct variables, would be treated as the same object. | ||
// | ||
// The solution we employed was to add a dummy field `_ bool` to the otherwise empty struct `CountStar`. | ||
// This ensures that each instance of `CountStar` is treated as a separate object, | ||
// even in the context of out semantic state which uses these objects as map keys. | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting that I didn't include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Context on |
||
|
||
Avg struct { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
I don't think anything calls this, but in the upstream change something does. I'll just leave it here
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.
This is only used by https://github.com/vitessio/vitess-tester, AFAIK