| 3880 | */ |
| 3881 | |
| 3882 | void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) |
| 3883 | { |
| 3884 | ulong stmt_id; |
| 3885 | uint param_number; |
| 3886 | Prepared_statement *stmt; |
| 3887 | Item_param *param; |
| 3888 | #ifndef EMBEDDED_LIBRARY |
| 3889 | char *packet_end= packet + packet_length; |
| 3890 | #endif |
| 3891 | DBUG_ENTER("mysql_stmt_get_longdata"); |
| 3892 | |
| 3893 | status_var_increment(thd->status_var.com_stmt_send_long_data); |
| 3894 | |
| 3895 | thd->get_stmt_da()->disable_status(); |
| 3896 | #ifndef EMBEDDED_LIBRARY |
| 3897 | /* Minimal size of long data packet is 6 bytes */ |
| 3898 | if (packet_length < MYSQL_LONG_DATA_HEADER) |
| 3899 | DBUG_VOID_RETURN; |
| 3900 | #endif |
| 3901 | |
| 3902 | stmt_id= uint4korr(packet); |
| 3903 | packet+= 4; |
| 3904 | |
| 3905 | if (!(stmt=find_prepared_statement(thd, stmt_id))) |
| 3906 | DBUG_VOID_RETURN; |
| 3907 | |
| 3908 | param_number= uint2korr(packet); |
| 3909 | packet+= 2; |
| 3910 | #ifndef EMBEDDED_LIBRARY |
| 3911 | if (param_number >= stmt->param_count) |
| 3912 | { |
| 3913 | /* Error will be sent in execute call */ |
| 3914 | stmt->state= Query_arena::STMT_ERROR; |
| 3915 | stmt->last_errno= ER_WRONG_ARGUMENTS; |
| 3916 | snprintf(stmt->last_error, sizeof(stmt->last_error), |
| 3917 | ER_THD(thd, ER_WRONG_ARGUMENTS), |
| 3918 | "mysqld_stmt_send_long_data"); |
| 3919 | DBUG_VOID_RETURN; |
| 3920 | } |
| 3921 | #endif |
| 3922 | |
| 3923 | param= stmt->param_array[param_number]; |
| 3924 | |
| 3925 | Diagnostics_area new_stmt_da(thd->query_id, false, true); |
| 3926 | Diagnostics_area *save_stmt_da= thd->get_stmt_da(); |
| 3927 | |
| 3928 | thd->set_stmt_da(&new_stmt_da); |
| 3929 | |
| 3930 | #ifndef EMBEDDED_LIBRARY |
| 3931 | param->set_longdata(packet, (ulong) (packet_end - packet)); |
| 3932 | #else |
| 3933 | param->set_longdata(thd->extra_data, thd->extra_length); |
| 3934 | #endif |
| 3935 | if (unlikely(thd->get_stmt_da()->is_error())) |
| 3936 | { |
| 3937 | stmt->state= Query_arena::STMT_ERROR; |
| 3938 | stmt->last_errno= thd->get_stmt_da()->sql_errno(); |
| 3939 | strmake_buf(stmt->last_error, thd->get_stmt_da()->message()); |
no test coverage detected