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

Any chance to get dynamic parameters for user procedures? #7458

Closed
gitasmus opened this issue Feb 5, 2024 · 5 comments · Fixed by dolthub/go-mysql-server#2315
Closed

Any chance to get dynamic parameters for user procedures? #7458

gitasmus opened this issue Feb 5, 2024 · 5 comments · Fixed by dolthub/go-mysql-server#2315
Labels
customer issue enhancement New feature or request sql Issue with SQL

Comments

@gitasmus
Copy link

gitasmus commented Feb 5, 2024

Dear Dolt team,

I would appreciate to be able to hand over parameters to procedures that can be used for SELECT options like LIMIT and OFFSET

dolt sql -q "
 CREATE database test_procedures;
 USE test_procedures;
 CREATE table test_procedures.tab (id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, col INT);
 INSERT INTO test_procedures.tab(col) VALUES (1),(2),(3),(4),(5),(6);
 SELECT * FROM test_procedures.tab;
"

Trying to define a procedure with dynamic parameter use:

dolt sql -q "CREATE PROCEDURE limited(the_limit INT) SELECT * FROM test_procedures.tab LIMIT the_limit;"

causes the error:

Error parsing SQL:
syntax error at position 90 near 'the_limit'

So, the following command cannot be executed, which would be useful for our very large tables.

dolt sql -q "CALL limited(3);"

Thank you for your help (and a great product)!

@timsehn timsehn added enhancement New feature or request sql Issue with SQL labels Feb 5, 2024
@timsehn
Copy link
Contributor

timsehn commented Feb 5, 2024

We have another stored procedure request that @jycor is looking into: #7454

We'll have him scope this one as well.

@max-hoffman
Copy link
Contributor

I've linked a partial fixe for this, I still need to do error testing and figure out some edge cases around nested procedures and trigger columns. Should be able to release tomorrow.

@gitasmus
Copy link
Author

Thank you for enabling this feature so quickly!

Solely the fact that parameters of type unsigned bigint raise an error, is a bit irritating as LIMIT and OFFSET should always be positive integers.

@max-hoffman
Copy link
Contributor

@gitasmus Good point, fix here dolthub/go-mysql-server#2350

@gitasmus
Copy link
Author

gitasmus commented Feb 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer issue enhancement New feature or request sql Issue with SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants