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/parser: only retain scanned SQL comments when necessary #129053

Conversation

mgartner
Copy link
Collaborator

In #86968 the scanner gained the ability to retain comments in scanned
SQL strings, and this was an always-on feature. However, the comments
are only used when populating the crdb_internal.cluster_queries table,
see sql.formatActiveQuery. Now, comments are only retained when the
parser is used from this function, reducing allocations for all other
cases.

Fixes #127713

Release note: None

@mgartner mgartner requested review from a team and removed request for a team August 15, 2024 14:53
@mgartner mgartner requested a review from a team as a code owner August 15, 2024 14:54
@mgartner mgartner requested a review from mw5h August 15, 2024 14:54
@mgartner mgartner requested a review from a team as a code owner August 15, 2024 14:54
Copy link

blathers-crl bot commented Aug 15, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner mgartner force-pushed the 127713-do-not-always-retain-scanned-comments branch from 159d096 to c4b9525 Compare August 15, 2024 14:55
@mgartner mgartner requested a review from DrewKimball August 15, 2024 14:55
Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice! Just a nit.

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @mw5h)


pkg/sql/parser/parse.go line 151 at r1 (raw file):

const (
	retainComments  commentsMode = true
	disgardComments commentsMode = false

[nit] disgard -> discard here and elsewhere.

@mgartner mgartner force-pushed the 127713-do-not-always-retain-scanned-comments branch from c4b9525 to 6d3a672 Compare August 15, 2024 21:04
In cockroachdb#86968 the scanner gained the ability to retain comments in scanned
SQL strings, and this was an always-on feature. However, the comments
are only used when populating the crdb_internal.cluster_queries table,
see `sql.formatActiveQuery`. Now, comments are only retained when the
parser is used from this function, reducing allocations for all other
cases.

Fixes cockroachdb#127713

Release note: None
@mgartner mgartner force-pushed the 127713-do-not-always-retain-scanned-comments branch from 6d3a672 to f9e0f16 Compare August 15, 2024 21:05
@mgartner mgartner requested a review from DrewKimball August 15, 2024 21:06
Copy link
Collaborator Author

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @DrewKimball and @mw5h)


pkg/sql/parser/parse.go line 151 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

[nit] disgard -> discard here and elsewhere.

Good catch. Fixed!

@craig
Copy link
Contributor

craig bot commented Aug 15, 2024

Build failed (retrying...):

@craig craig bot merged commit ec66ae7 into cockroachdb:master Aug 15, 2024
23 checks passed
@rafiss
Copy link
Collaborator

rafiss commented Aug 16, 2024

Nice fix! Should this get backported?

@rafiss
Copy link
Collaborator

rafiss commented Aug 16, 2024

Nevermind, I see that #127711 was backported, and I think that's the only one that should be.

@mgartner mgartner deleted the 127713-do-not-always-retain-scanned-comments branch August 16, 2024 16:19
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.

sql/parser: only retain scanned comments when necessary
4 participants