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

Function cli_read_query_result

sql-common/client.c:4086–4155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4084
4085
4086static my_bool cli_read_query_result(MYSQL *mysql)
4087{
4088 uchar *pos;
4089 ulong field_count;
4090 MYSQL_DATA *fields;
4091 ulong length;
4092 DBUG_ENTER("cli_read_query_result");
4093
4094 if ((length = cli_safe_read(mysql)) == packet_error)
4095 DBUG_RETURN(1);
4096 free_old_query(mysql); /* Free old result */
4097#ifdef MYSQL_CLIENT /* Avoid warn of unused labels*/
4098get_info:
4099#endif
4100 pos=(uchar*) mysql->net.read_pos;
4101 if ((field_count= net_field_length(&pos)) == 0)
4102 {
4103 mysql->affected_rows= net_field_length_ll(&pos);
4104 mysql->insert_id= net_field_length_ll(&pos);
4105 DBUG_PRINT("info",("affected_rows: %lu insert_id: %lu",
4106 (ulong) mysql->affected_rows,
4107 (ulong) mysql->insert_id));
4108 if (protocol_41(mysql))
4109 {
4110 mysql->server_status=uint2korr(pos); pos+=2;
4111 mysql->warning_count=uint2korr(pos); pos+=2;
4112 }
4113 else if (mysql->server_capabilities & CLIENT_TRANSACTIONS)
4114 {
4115 /* MySQL 4.0 protocol */
4116 mysql->server_status=uint2korr(pos); pos+=2;
4117 mysql->warning_count= 0;
4118 }
4119 DBUG_PRINT("info",("status: %u warning_count: %u",
4120 mysql->server_status, mysql->warning_count));
4121 if (pos < mysql->net.read_pos+length && net_field_length(&pos))
4122 mysql->info=(char*) pos;
4123 DBUG_RETURN(0);
4124 }
4125#ifdef MYSQL_CLIENT
4126 if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */
4127 {
4128 int error;
4129
4130 if (!(mysql->options.client_flag & CLIENT_LOCAL_FILES))
4131 {
4132 set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
4133 DBUG_RETURN(1);
4134 }
4135
4136 error= handle_local_infile(mysql,(char*) pos);
4137 if ((length= cli_safe_read(mysql)) == packet_error || error)
4138 DBUG_RETURN(1);
4139 goto get_info; /* Get info packet */
4140 }
4141#endif
4142 if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
4143 mysql->server_status|= SERVER_STATUS_IN_TRANS;

Callers

nothing calls this directly

Calls 7

cli_safe_readFunction · 0.85
free_old_queryFunction · 0.85
net_field_lengthFunction · 0.85
net_field_length_llFunction · 0.85
set_mysql_errorFunction · 0.85
cli_read_rowsFunction · 0.85
unpack_fieldsFunction · 0.85

Tested by

no test coverage detected