MCPcopy Create free account
hub / github.com/MariaDB/server / cli_read_query_result

Function cli_read_query_result

sql-common/client.c:3531–3586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3529
3530
3531static my_bool cli_read_query_result(MYSQL *mysql)
3532{
3533 uchar *pos;
3534 ulong field_count;
3535 MYSQL_DATA *fields;
3536 ulong length;
3537#ifdef MYSQL_CLIENT
3538 my_bool can_local_infile= mysql->auto_local_infile != WAIT_FOR_QUERY;
3539#endif
3540 DBUG_ENTER("cli_read_query_result");
3541
3542 if (mysql->auto_local_infile == ACCEPT_FILE_REQUEST)
3543 mysql->auto_local_infile= WAIT_FOR_QUERY;
3544
3545 if ((length = cli_safe_read(mysql)) == packet_error)
3546 DBUG_RETURN(1);
3547 free_old_query(mysql); /* Free old result */
3548#ifdef MYSQL_CLIENT /* Avoid warn of unused labels*/
3549get_info:
3550#endif
3551 pos= mysql->net.read_pos;
3552 if ((field_count= net_field_length(&pos)) == 0)
3553 DBUG_RETURN(parse_ok_packet(mysql, length));
3554
3555#ifdef MYSQL_CLIENT
3556 if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */
3557 {
3558 int error;
3559
3560 if (!(mysql->options.client_flag & CLIENT_LOCAL_FILES) ||
3561 !can_local_infile)
3562 {
3563 set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
3564 DBUG_RETURN(1);
3565 }
3566
3567 error= handle_local_infile(mysql,(char*) pos);
3568 if ((length= cli_safe_read(mysql)) == packet_error || error)
3569 DBUG_RETURN(1);
3570 goto get_info; /* Get info packet */
3571 }
3572#endif
3573 if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
3574 mysql->server_status|= SERVER_STATUS_IN_TRANS;
3575
3576 if (!(fields=cli_read_rows(mysql,(MYSQL_FIELD*)0, protocol_41(mysql) ? 7:5)))
3577 DBUG_RETURN(1);
3578 if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc,
3579 (uint) field_count,0,
3580 mysql->server_capabilities)))
3581 DBUG_RETURN(1);
3582 mysql->status= MYSQL_STATUS_GET_RESULT;
3583 mysql->field_count= (uint) field_count;
3584 DBUG_PRINT("exit",("ok"));
3585 DBUG_RETURN(0);
3586}
3587
3588

Callers

nothing calls this directly

Calls 8

cli_safe_readFunction · 0.85
free_old_queryFunction · 0.85
net_field_lengthFunction · 0.85
parse_ok_packetFunction · 0.85
set_mysql_errorFunction · 0.85
handle_local_infileFunction · 0.85
cli_read_rowsFunction · 0.85
unpack_fieldsFunction · 0.85

Tested by

no test coverage detected