Skip to content

Make MYSQL_TYPE_DATETIME packet length to 11 #29

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mysql/packets.cr
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ module MySql::Protocol
packet.write_bytes caps, IO::ByteFormat::LittleEndian

packet.write_bytes 0x00000000u32, IO::ByteFormat::LittleEndian
packet.write_byte 0x21u8 # utf8_general_ci
# packet.write_byte 0x21u8 # utf8_general_ci
packet.write_byte 0x2du8 # UTF8MB4_GENERAL_CI
23.times { packet.write_byte 0_u8 }

packet << @username
Expand Down
2 changes: 1 addition & 1 deletion src/mysql/types.cr
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract struct MySql::Type
decl_type Time, 0x0bu8
decl_type DateTime, 0x0cu8, ::Time do
def self.write(packet, v : ::Time)
packet.write_blob UInt8.slice(v.year.to_i16, v.year.to_i16/256, v.month.to_i8, v.day.to_i8, v.hour.to_i8, v.minute.to_i8, v.second.to_i8, v.millisecond*1000, v.millisecond*1000/256, v.millisecond*1000/65536)
packet.write_blob UInt8.slice(v.year.to_i16, v.year.to_i16/256, v.month.to_i8, v.day.to_i8, v.hour.to_i8, v.minute.to_i8, v.second.to_i8, v.millisecond*1000, v.millisecond*1000/256, v.millisecond*1000/65536, v.millisecond*1000/16777216)
end

def self.read(packet)
Expand Down