Skip to content

Commit

Permalink
correct LOAD DATA LOCAL INFILE result information.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtm committed Dec 12, 2021
1 parent 01f1830 commit 841c2e9
Show file tree
Hide file tree
Showing 2 changed files with 2 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 @@ -252,6 +252,7 @@ def get_result
end
if res_packet.field_count.nil? # LOAD DATA LOCAL INFILE
send_local_file(res_packet.message)
res_packet = ResultPacket.parse read
end
@affected_rows, @insert_id, @server_status, @warning_count, @message =
res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count, res_packet.message
Expand All @@ -273,7 +274,6 @@ def send_local_file(filename)
end
ensure
write nil # EOF mark
read
end

# Retrieve n fields
Expand Down
1 change: 1 addition & 0 deletions test/test_mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class TestMysql < Test::Unit::TestCase
@m.connect(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
@m.query('create temporary table t (i int, c char(10))')
@m.query("load data local infile '#{tmpf.path}' into table t")
assert{ @m.info == 'Records: 1 Deleted: 0 Skipped: 0 Warnings: 0' }
assert{ @m.query('select * from t').fetch_row == ['123','abc'] }
end
test 'load_data_local_dir: client can execute LOAD DATA LOCAL INFILE query with specified directory' do
Expand Down

0 comments on commit 841c2e9

Please sign in to comment.