`IndexError: list index out of range` for stored procedures
I get a crash when trying to run a built-in stored procedure:
HRDB> exec sp_spaceused;
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/eric/.virtualenvs/awscli/lib/python2.7/site-packages/mssqlcli/main.py", line 117, in <module>
main()
File "/home/eric/.virtualenvs/awscli/lib/python2.7/site-packages/mssqlcli/main.py", line 110, in main
run_cli_with(mssqlcli_options)
File "/home/eric/.virtualenvs/awscli/lib/python2.7/site-packages/mssqlcli/main.py", line 55, in run_cli_with
mssqlcli.run()
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssql_cli.py", line 440, in run
self.execute_query(text)
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssql_cli.py", line 365, in execute_query
output = self._execute_interactive_command(text)
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssql_cli.py", line 321, in _execute_interactive_command
output, query = self._evaluate_command(text)
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssql_cli.py", line 548, in _evaluate_command
self.mssqlcliclient_main.execute_query(text):
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssqlcliclient.py", line 112, in execute_query
in self._execute_query(single_query):
File "/home/eric/.virtualenvs/awscli/local/lib/python2.7/site-packages/mssqlcli/mssqlcliclient.py", line 146, in _execute_query
= query_messages[result_set_summary.request_id].message if query_messages else u''
IndexError: list index out of range
Sorry about this @ericlathrop, can you provide some more details on your OS and the exact procedure you're attempting to run?
$ uname -a
Linux xps 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
I'm trying to run sp_spaceused, or sp_helpdb
$ mssql-cli -v
Version: 0.17.2
I can repro this. Thanks for letting us know! I'll investigate this further.
Looks like our implementation to support multiline statements is what's causing the break (#130).
We use result_set_summary.request_id as index for query messages but there appears to be a mismatch with the number of messages it's expecting. If I override the index with 0 it works for single-line statements but not when multiline is enabled.
We also need to improve testing to catch queries like sp_spaceused.
I need to look at this at a later time since the solution is seemingly non-trivial.