Refactor processing of query params, which was almost equal for exec_params, exec_prepared, send_query and send_query_prepared.
Add optional type casting to input parameters

Refactor decoding code