Skip to content

Commit 149aebe

Browse files
committed
FIX: Minor modifications of MySQL protocol error messages.
1 parent 3ba379e commit 149aebe

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

src/mezz/prot-mysql.r

+37-28
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,33 @@ mysql-driver: make object! [
723723
]
724724
]
725725

726+
on-error-packet: func[
727+
port [port!]
728+
/local pl
729+
][
730+
pl: port/locals
731+
parse next port/data case [
732+
pl/capabilities and defs/client/protocol-41 [
733+
[
734+
read-int (pl/error-code: int)
735+
6 skip
736+
read-string (pl/error-msg: string)
737+
]
738+
]
739+
any [none? pl/protocol pl/protocol > 9][
740+
[
741+
read-int (pl/error-code: int)
742+
read-string (pl/error-msg: string)
743+
]
744+
]
745+
true [
746+
pl/error-code: 0
747+
[read-string (pl/error-msg: string)]
748+
]
749+
]
750+
cause-error 'mysql 'message reduce [pl/error-code pl/error-msg]
751+
]
752+
726753
parse-a-packet: func [
727754
port [port!]
728755
/local pl status rules
@@ -735,27 +762,8 @@ mysql-driver: make object! [
735762

736763
switch status [
737764
255 [
738-
parse/all next port/data case [
739-
pl/capabilities and defs/client/protocol-41 [
740-
[
741-
read-int (pl/error-code: int)
742-
6 skip
743-
read-string (pl/error-msg: string)
744-
]
745-
]
746-
any [none? pl/protocol pl/protocol > 9][
747-
[
748-
read-int (pl/error-code: int)
749-
read-string (pl/error-msg: string)
750-
]
751-
]
752-
true [
753-
pl/error-code: 0
754-
[read-string (pl/error-msg: string)]
755-
]
756-
]
757765
pl/state: 'idle
758-
cause-error 'mysql 'message reduce [pl/error-code pl/error-msg]
766+
on-error-packet port
759767
return 'ERR
760768
]
761769
254 [
@@ -867,11 +875,8 @@ mysql-driver: make object! [
867875
sys/log/more 'MySQL["state changed to sending-old-auth-pack"]
868876
][
869877
if buf/1 = 255 [;error packet
870-
parse/all skip buf 1 [
871-
read-int (pl/error-code: int)
872-
read-string (pl/error-msg: string)
873-
]
874-
cause-error 'mysql 'message reduce [pl/error-code pl/error-msg ]
878+
pl/state: 'init
879+
on-error-packet port
875880
]
876881
sys/log/more 'MySQL "handshaked"
877882
;OK?
@@ -1694,14 +1699,18 @@ send-sql: func [
16941699
print ["******* Unexpected wakeup from tcp-port *********"]
16951700
]
16961701
;sys/log/more 'MySQL"wait returned none"
1697-
cause-error 'Access 'timeout reduce [port none none]
1702+
throw-timeout port
16981703
]
16991704
;sys/log/more 'MySQL["trying again..."]
17001705
]
1701-
cause-error 'Access 'timeout reduce [port none none]
1706+
throw-timeout port
17021707
]
17031708
]
17041709

1710+
throw-timeout: func[port [port!]] [
1711+
cause-error 'Access 'timeout to url! rejoin [port/spec/scheme "://" port/spec/host #":" port/spec/port-id]
1712+
]
1713+
17051714
connect-sql: func [
17061715
"Opens connection to MySQL port (waits for a handshake)"
17071716
port [port! url!] "MySQL port or url"
@@ -1711,6 +1720,6 @@ connect-sql: func [
17111720
port/locals/exit-wait-after-handshaked?: true
17121721
p: wait/only [port port/locals/tcp-port port/spec/timeout]
17131722
if port? p [return port]
1714-
cause-error 'Access 'timeout reduce [port none none]
1723+
throw-timeout port
17151724
]
17161725

0 commit comments

Comments
 (0)