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: allow procedures to call other procedures #120674

Merged
merged 2 commits into from Mar 20, 2024

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Mar 18, 2024

sql/logictest: add more tests for UDFs calling UDFs

This commit rearranges some existing tests and adds a few new tests for
UDFs that invoke other UDFs.

Release note: None

sql: allow procedures to call other procedures

Fixes #88198

Release note (sql change): Stored procedures can now invoke other
stored procedures via CALL statements.

@mgartner mgartner requested review from fqazi, yuzefovich, DrewKimball and a team March 18, 2024 20:07
@mgartner mgartner requested a review from a team as a code owner March 18, 2024 20:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

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:

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


pkg/sql/opt/optbuilder/builder.go line 343 at r2 (raw file):

			activeVersion := b.evalCtx.Settings.Version.ActiveVersion(b.ctx)
			if !activeVersion.IsActive(clusterversion.V24_1) {
				panic(unimplemented.Newf("user-defined functions", "%s usage inside a function definition is not supported until version 23.2", stmt.StatementTag()))

[nit] Should this say "stored procedure"?

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

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


pkg/sql/opt/optbuilder/builder.go line 343 at r2 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

[nit] Should this say "stored procedure"?

Also, probably s/23.2/24.1/?


pkg/sql/logictest/testdata/logic_test/procedure line 125 at r1 (raw file):


statement error pgcode 0A000 unimplemented: CALL usage inside a function definition
CREATE FUNCTION err(i INT) RETURNS VOID LANGUAGE SQL AS 'CALL p()'

nit: do we have tests in which a UDF calls a procedure and vice versa?

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.

Reviewable status: :shipit: complete! 3 of 0 LGTMs obtained (waiting on @DrewKimball and @yuzefovich)


pkg/sql/opt/optbuilder/builder.go line 343 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Also, probably s/23.2/24.1/?

done


pkg/sql/logictest/testdata/logic_test/procedure line 125 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: do we have tests in which a UDF calls a procedure and vice versa?

No, but I have a follow-up PR which this that I'll post shortly.

This commit rearranges some existing tests and adds a few new tests for
UDFs that invoke other UDFs.

Release note: None
Release note (sql change): Stored procedures can now invoke other
stored procedures via `CALL` statements.
@mgartner
Copy link
Collaborator Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 20, 2024

@craig craig bot merged commit 3e9ea42 into cockroachdb:master Mar 20, 2024
22 checks passed
@mgartner mgartner deleted the udf-sp-tests branch March 21, 2024 14:29
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.

udf: support calling UDFs / SPs from other UDFs / SPs
5 participants