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: add plpgsql parser for telemetry purposes #98147

Merged
merged 11 commits into from
Apr 13, 2023

Conversation

e-mbrown
Copy link
Contributor

@e-mbrown e-mbrown commented Mar 7, 2023

Informs: #91569

This commit adds the in use portions of the plpgsql parser from #91606.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ZhouXing19
Copy link
Collaborator

Could you also rewrite the messages of the existing commits? I believe they are drafts. Thanks!

@e-mbrown e-mbrown force-pushed the eb/bareplpg branch 2 times, most recently from 3c0cb70 to 019a4af Compare March 13, 2023 15:16
@ZhouXing19
Copy link
Collaborator

The last commit contains lots of rewrites of build.bazel. I think it's because of rebasing. Can we squash it with the first commit (the scaffold one)?

@e-mbrown e-mbrown force-pushed the eb/bareplpg branch 3 times, most recently from a92f71d to 609e6a4 Compare March 14, 2023 18:41
@e-mbrown e-mbrown requested a review from rafiss March 14, 2023 18:42
@e-mbrown e-mbrown marked this pull request as ready for review March 14, 2023 18:42
@e-mbrown e-mbrown requested a review from a team as a code owner March 14, 2023 18:42
@e-mbrown e-mbrown force-pushed the eb/bareplpg branch 12 times, most recently from b4f2eb3 to 4e4d76f Compare March 16, 2023 19:10
@rimadeodhar
Copy link
Collaborator

@ZhouXing19 and @chengxiong-ruan gentle ping to review this PR when you get a chance. Thanks!

@e-mbrown e-mbrown requested a review from a team as a code owner March 29, 2023 16:58
chengxiong-ruan and others added 9 commits April 12, 2023 15:16
Adds the first test which parses an empty function or
function with bare sql queries.

Release note: None
This commit adds `lexer.ReadSqlExpressionStr()` which
gives access to the return type of a plpgsql function.

This commit also adds grammar rules and AST for
`stmt_if`

Release note: None
This commit adds AST and grammar rules for
`decl_header` and `stmt_assert`

Release note: None
This commit adds the AST and grammar rules for `stmt_call`,
`stmt_close`, `stmt_dynaexec`, and `stmt_exit`

Release note: None
This commit adds the AST and grammar rules for
`stmt_assign` and `stmt_getdiag`

Release note: None
This commit adds portions of the logic to parse `stmt_case`.
Does not yet support ELSE, sql statements in THEN body, or END CASE (it
uses an ENDCASE hack).

Release note: None
This commit corrects the grammar rules for `stmt_case`.

Release note: None
This commit corrects the grammar rules and AST of
`stmt_if`, `elsif`, `else` statements.

Release note: None
This commit adds logic for `stmt_open`

Release note: None
Copy link
Contributor Author

@e-mbrown e-mbrown 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 @chengxiong-ruan, @DrewKimball, @knz, @rafiss, and @ZhouXing19)


pkg/sql/sem/plpgsqltree/constants.go line 16 at r70 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

Here and for all the other comments:

  1. each comment for an individual exported symbol needs to be prefixed by the name of the exported symbol.
  2. comments contain sentence and thus should end with a period.

Done.


pkg/sql/sem/plpgsqltree/constants.go line 40 at r70 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

String is special - usually we document // String implements the fmt.Stringer interface.

Done.


pkg/sql/plpgsql/parser/parser_test.go line 32 at r59 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

Would it be possible to define the data driven test framework in 1 place, and us it from both packages?

We will do this at a later date.

@chengxiong-ruan
Copy link
Contributor

pkg/sql/plpgsql/parser/parser_test.go line 32 at r59 (raw file):

Previously, e-mbrown (Ebony Brown) wrote…

We will do this at a later date.

Could you file an issue to track or at least a TODO? Thanks.

This commit makes Statement generic so it can be shared between
the sql and plpgsql parsers.

Release note: None
Copy link
Contributor Author

@e-mbrown e-mbrown 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 @chengxiong-ruan, @DrewKimball, @knz, @rafiss, and @ZhouXing19)


pkg/sql/plpgsql/parser/parser_test.go line 32 at r59 (raw file):

data driven test framework
I'll add a TODO for now.

Copy link
Contributor

@chengxiong-ruan chengxiong-ruan left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for your patience through this.

@e-mbrown
Copy link
Contributor Author

Thanks for all the reviews!!

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 13, 2023

Build succeeded:

@craig craig bot merged commit 8fbb38c into cockroachdb:master Apr 13, 2023
craig bot pushed a commit that referenced this pull request Apr 27, 2023
99517: sql:  add unimplemented errors and telemetry for plpgsql r=e-mbrown a=e-mbrown

Part of: #98147
Closes: #91569

This PR expands grammar rules and adds unimplemented support for pl/pgsql statements.

[sql: Add telemetry for parsable plpgsql statements](37aa95d) Is the first commit unique to this PR.

Release Notes: None

Co-authored-by: Jane Xing <zhouxing@uchicago.edu>
Co-authored-by: e-mbrown <ebsonari@gmail.com>
@e-mbrown e-mbrown deleted the eb/bareplpg branch April 27, 2023 20:12
@e-mbrown e-mbrown added backport-22.2.x backport-23.1.x Flags PRs that need to be backported to 23.1 labels Apr 27, 2023
@e-mbrown
Copy link
Contributor Author

blathers backport 23.1 22.2

@blathers-crl
Copy link

blathers-crl bot commented Apr 27, 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 9688586 to blathers/backport-release-23.1-98147: 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 23.1 failed. See errors above.


error creating merge commit from 19b6cb9 to blathers/backport-release-22.2-98147: 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 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
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants