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 issues with stored procedures #693

Open
ADHdev opened this issue Dec 20, 2017 · 1 comment
Open

SQL issues with stored procedures #693

ADHdev opened this issue Dec 20, 2017 · 1 comment

Comments

@ADHdev
Copy link

ADHdev commented Dec 20, 2017

The bug: Regular queries work fine, but stored procedures cause MySQL to disconnect immediately after a successful call with the error: Aborted connection #### to db: 'dbname' user: 'dbuser' host: 'localhost' (Got an error reading communication packets) The error messages TinyMUX gives are "#-3 UNAVAILABLE" for @query and "#-1 SQL UNAVAILABLE" for sql().

Scope: @query and sql() on MUX 2.10.1.14 #3 [2017-AUG-05] and MySQL version 5.7.20-0ubuntu0.16.04.1. I have not been able to test on any other machines because I don't have permissions, sorry. :(

MySQL setup:

CREATE TABLE IF NOT EXISTS tblDataValues ( DBref varchar(10) NOT NULL, Name varchar(60) NOT NULL, Value varchar(7900), PRIMARY KEY (DBref, Name) ) ENGINE=InnoDB;

CREATE UNIQUE INDEX uix_dataNames ON tblDataValues (DBref, Name);

CREATE DEFINER=`**YOURDBUSERNAMEHERE**`@`localhost` PROCEDURE `usp_GetDataValue`(IN `up_DBref` VARCHAR(10), IN `up_Name` VARCHAR(60)) SELECT Value FROM tblDataValues WHERE DBref = up_DBref AND Name = up_Name;

INSERT INTO tblDataValues (DBref, Name) VALUES('#13', 'Test', 'Testing');
INSERT INTO tblDataValues (DBref, Name) VALUES('#13', 'Test2', 'Sandwiches');

MUX code:

&FOO.TR me=@if rserror()={@pemit %#=Rows: [rsrows()];@if rsrows()={@trig me/bar.tr}}, {@pemit %#=Error: [rserror()]}
&BAR.TR me=@pemit %#=rsrec(|);@if rsnext()={@trig me/bar.tr}

@query/sql me/foo.tr=**YOURDBHERE**/SELECT Value FROM tblDataValues WHERE DBRef='#13' AND Name = 'Test'
@query/sql me/foo.tr=**YOURDBHERE**/CALL usp_GetDataValue('#13', 'Test')
@query/sql me/foo.tr=**YOURDBHERE**/SELECT Value FROM tblDataValues WHERE DBRef='#13' AND Name = 'Test'
th sql(SELECT Value FROM tblDataValues WHERE DBRef='#13' AND Name = 'Test')
th sql(CALL usp_GetDataValue('#13'%,'Test'))
th sql(SELECT Value FROM tblDataValues WHERE DBRef='#13' AND Name = 'Test')
@ADHdev
Copy link
Author

ADHdev commented Dec 21, 2017

New information! It is only SELECT stored procedures that cause this - INSERT SPs do not (perhaps because my inserts return nothing).

That lead me to this: https://stackoverflow.com/questions/24321955/error-after-calling-mysql-stored-procedures - which sounds like a similar problem.

That in turn lead me to https://stackoverflow.com/questions/614671/commands-out-of-sync-you-cant-run-this-command-now, which is where I got lost. The third post down relates to C and may be related, might not - I can't judge, unfortunately.

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

No branches or pull requests

1 participant