Skip to content

Commit

Permalink
allow multiple results by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtm committed Dec 12, 2021
1 parent 68c0710 commit 7cfe372
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mysql/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def authenticate
@server_version = init_packet.server_version.split(/\D/)[0,3].inject{|a,b|a.to_i*100+b.to_i}
@server_capabilities = init_packet.server_capabilities
@thread_id = init_packet.thread_id
@client_flags = CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | CLIENT_PLUGIN_AUTH
@client_flags = CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | CLIENT_PLUGIN_AUTH
@client_flags |= CLIENT_LOCAL_FILES if @opts[:local_infile] || @opts[:load_data_local_dir]
@client_flags |= CLIENT_CONNECT_WITH_DB if @opts[:database]
@client_flags |= @opts[:flags]
Expand Down
14 changes: 14 additions & 0 deletions test/test_mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,20 @@ class TestMysql < Test::Unit::TestCase
assert{ m.more_results? == false }
end

test 'procedure returns multiple results' do
m = Mysql.connect(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
m.query 'drop procedure if exists test_proc'
m.query 'create procedure test_proc() begin select 1 as a; select 2 as b; end'
res = m.query 'call test_proc()'
assert{ res.entries == [['1']] }
assert{ m.more_results? == true }
assert{ m.next_result == true }
assert{ m.store_result.entries == [['2']] }
assert{ m.more_results? == true }
assert{ m.next_result == true }
assert{ m.more_results? == false }
end

sub_test_case 'Mysql::Result' do
setup do
@m = Mysql.connect(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
Expand Down

0 comments on commit 7cfe372

Please sign in to comment.