MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / net_send_ok

Function net_send_ok

sql/protocol.cc:204–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202
203#ifndef EMBEDDED_LIBRARY
204bool
205net_send_ok(THD *thd,
206 uint server_status, uint statement_warn_count,
207 ulonglong affected_rows, ulonglong id, const char *message)
208{
209 NET *net= &thd->net;
210 uchar buff[MYSQL_ERRMSG_SIZE+10],*pos;
211 bool error= FALSE;
212 DBUG_ENTER("net_send_ok");
213
214 if (! net->vio) // hack for re-parsing queries
215 {
216 DBUG_PRINT("info", ("vio present: NO"));
217 DBUG_RETURN(FALSE);
218 }
219
220 buff[0]=0; // No fields
221 pos=net_store_length(buff+1,affected_rows);
222 pos=net_store_length(pos, id);
223 if (thd->client_capabilities & CLIENT_PROTOCOL_41)
224 {
225 DBUG_PRINT("info",
226 ("affected_rows: %lu id: %lu status: %u warning_count: %u",
227 (ulong) affected_rows,
228 (ulong) id,
229 (uint) (server_status & 0xffff),
230 (uint) statement_warn_count));
231 int2store(pos, server_status);
232 pos+=2;
233
234 /* We can only return up to 65535 warnings in two bytes */
235 uint tmp= min(statement_warn_count, 65535U);
236 int2store(pos, tmp);
237 pos+= 2;
238 }
239 else if (net->return_status) // For 4.0 protocol
240 {
241 int2store(pos, server_status);
242 pos+=2;
243 }
244 thd->get_stmt_da()->set_overwrite_status(true);
245
246 if (message && message[0])
247 pos= net_store_data(pos, (uchar*) message, strlen(message));
248 error= my_net_write(net, buff, (size_t) (pos-buff));
249 if (!error)
250 error= net_flush(net);
251
252
253 thd->get_stmt_da()->set_overwrite_status(false);
254 DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
255
256 DBUG_RETURN(error);
257}
258
259static uchar eof_buff[1]= { (uchar) 254 }; /* Marker for end of fields */
260

Callers 1

send_okMethod · 0.85

Calls 5

net_store_lengthFunction · 0.85
minFunction · 0.85
net_store_dataFunction · 0.85
set_overwrite_statusMethod · 0.80
get_stmt_daMethod · 0.80

Tested by

no test coverage detected