@@ -76,6 +76,14 @@ public final class Connection {
76
76
guard let statement = mysql_stmt_init ( cConnection) else {
77
77
throw lastError
78
78
}
79
+
80
+ // important! this must be set for field.max_length
81
+ // to be properly filled
82
+ var truth : my_bool = 1
83
+ guard mysql_stmt_attr_set ( statement, STMT_ATTR_UPDATE_MAX_LENGTH, & truth) == 0 else {
84
+ throw lastError
85
+ }
86
+
79
87
defer {
80
88
mysql_stmt_close ( statement)
81
89
}
@@ -110,8 +118,20 @@ public final class Connection {
110
118
mysql_free_result ( metadata)
111
119
}
112
120
121
+ // Execute the statement!
122
+ // The data is ready to be fetched when this completes.
123
+ guard mysql_stmt_execute ( statement) == 0 else {
124
+ throw lastError
125
+ }
126
+
127
+ // buffers the data on the client
128
+ // important! sets the max_length field
129
+ mysql_stmt_store_result ( statement)
130
+
113
131
// Parse the fields (columns) that will be returned
114
132
// by this statement.
133
+ // important! field information should not be parsed
134
+ // until mysql_stmt_store_result has been called.
115
135
let fields = try Fields ( metadata, self )
116
136
117
137
// Use the fields data to create output bindings.
@@ -124,12 +144,6 @@ public final class Connection {
124
144
throw lastError
125
145
}
126
146
127
- // Execute the statement!
128
- // The data is ready to be fetched when this completes.
129
- guard mysql_stmt_execute ( statement) == 0 else {
130
- throw lastError
131
- }
132
-
133
147
var results : [ StructuredData ] = [ ]
134
148
135
149
// This single dictionary is reused for all rows in the result set
0 commit comments