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
sqlsmith: add initial support for PL/pgSQL #119037
Conversation
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
The first three commits are #119034. |
Example generated statement:
|
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.
Nice! I have a few nits.
Reviewed 3 of 3 files at r4, 5 of 5 files at r5, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball and @rytaft)
pkg/internal/sqlsmith/plpgsql.go
line 90 at r5 (raw file):
for i := 0; i < numStmts; i++ { for { // No need for a retry counter, because eventually a NULL statement will
I'm a bit confused by this comment - can you expand on it? Is it effectively saying that we don't need to count the number of times Next
is called when it returns ok = false
because at some point NULL
stmt is returned which will have ok = true
, so infinite loop is impossible?
pkg/internal/sqlsmith/plpgsql.go
line 109 at r5 (raw file):
} if s.coin() { numElsIfs := s.rnd.Intn(3) + 1
nit: perhaps s/numElsIfs/numElseIfs/
.
pkg/internal/sqlsmith/plpgsql.go
line 136 at r5 (raw file):
} // TODO(#106368): implement generation for the remaining statements.
nit: this issue is being closed by this PR right now - should this refer to a different issue? Or should this PR not fully close it?
7566d37
to
b9eb1d3
Compare
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rytaft and @yuzefovich)
pkg/internal/sqlsmith/plpgsql.go
line 90 at r5 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
I'm a bit confused by this comment - can you expand on it? Is it effectively saying that we don't need to count the number of times
Next
is called when it returnsok = false
because at some pointNULL
stmt is returned which will haveok = true
, so infinite loop is impossible?
Yes, that's exactly it. I modified the comment to explain that better.
pkg/internal/sqlsmith/plpgsql.go
line 109 at r5 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
nit: perhaps
s/numElsIfs/numElseIfs/
.
Done.
pkg/internal/sqlsmith/plpgsql.go
line 136 at r5 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
nit: this issue is being closed by this PR right now - should this refer to a different issue? Or should this PR not fully close it?
Good point. I'll leave the issue open to track support for other statements.
This commit implements the PL/pgSQL NULL statement, which is a no-op. This will be convenient for the following commit, which adds initial support for PL/pgSQL to sqlsmith. Informs cockroachdb#117744 Informs cockroachdb#106368 Release note (sql change): Added support for the PL/pgSQL NULL statement.
This commit adds initial support for PL/pgSQL routines. The following statements are supported: * Block * If/Elsif/Else * Return * Null * Assign * SQL statements Informs cockroachdb#106368 Release note: None
b9eb1d3
to
b2137ac
Compare
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.
Reviewed 8 of 9 files at r1, 1 of 3 files at r7, 2 of 2 files at r8, 3 of 3 files at r9, 5 of 5 files at r10, 17 of 17 files at r11, 16 of 16 files at r12, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @rytaft)
pkg/internal/sqlsmith/plpgsql.go
line 109 at r5 (raw file):
Previously, DrewKimball (Drew Kimball) wrote…
Done.
Sorry, I didn't realize that ELSIF
is the keyword - up to you whether you want to revert the change in response to my comment.
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @rytaft)
pkg/internal/sqlsmith/plpgsql.go
line 109 at r5 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
Sorry, I didn't realize that
ELSIF
is the keyword - up to you whether you want to revert the change in response to my comment.
Eh, I think numElseIfs
is good. TFYR!
bors r+ |
Build succeeded: |
plpgsql: add support for NULL statements
This commit implements the PL/pgSQL NULL statement, which is a no-op.
This will be convenient for the following commit, which adds initial
support for PL/pgSQL to sqlsmith.
Informs #117744
Informs #106368
Release note (sql change): Added support for the PL/pgSQL NULL statement.
sqlsmith: add initial support for PL/pgSQL
This commit adds initial support for PL/pgSQL routines. The following
statements are supported:
Informs #106368
Release note: None