@@ -723,6 +723,33 @@ mysql-driver: make object! [
723
723
]
724
724
]
725
725
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
+
726
753
parse-a-packet : func [
727
754
port [port! ]
728
755
/local pl status rules
@@ -735,27 +762,8 @@ mysql-driver: make object! [
735
762
736
763
switch status [
737
764
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
- ]
757
765
pl/state: 'idle
758
- cause -error 'mysql 'message reduce [pl /error-code pl /error-msg ]
766
+ on -error-packet port
759
767
return 'ERR
760
768
]
761
769
254 [
@@ -867,11 +875,8 @@ mysql-driver: make object! [
867
875
sys/log/more 'MySQL["state changed to sending-old-auth-pack" ]
868
876
][
869
877
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
875
880
]
876
881
sys/log/more 'MySQL "handshaked"
877
882
;OK?
@@ -1694,14 +1699,18 @@ send-sql: func [
1694
1699
print ["******* Unexpected wakeup from tcp-port *********" ]
1695
1700
]
1696
1701
;sys/log/more 'MySQL"wait returned none"
1697
- cause-error 'Access ' timeout reduce [ port none none]
1702
+ throw- timeout port
1698
1703
]
1699
1704
;sys/log/more 'MySQL["trying again..."]
1700
1705
]
1701
- cause-error 'Access ' timeout reduce [ port none none]
1706
+ throw- timeout port
1702
1707
]
1703
1708
]
1704
1709
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
+
1705
1714
connect-sql : func [
1706
1715
"Opens connection to MySQL port (waits for a handshake)"
1707
1716
port [port! url! ] "MySQL port or url"
@@ -1711,6 +1720,6 @@ connect-sql: func [
1711
1720
port/locals/exit-wait-after-handshaked?: true
1712
1721
p: wait /only [port port/locals/tcp-port port/spec/timeout ]
1713
1722
if port? p [return port]
1714
- cause-error 'Access ' timeout reduce [ port none none]
1723
+ throw- timeout port
1715
1724
]
1716
1725
0 commit comments