| 4554 | */ |
| 4555 | |
| 4556 | bool |
| 4557 | Prepared_statement::set_parameters(String *expanded_query, |
| 4558 | const InstrSlice &instrs_set_placeholder, |
| 4559 | uchar *packet, uchar *packet_end) |
| 4560 | { |
| 4561 | bool is_sql_ps= packet == NULL; |
| 4562 | bool res= FALSE; |
| 4563 | |
| 4564 | if (is_sql_ps) |
| 4565 | { |
| 4566 | /* SQL prepared statement */ |
| 4567 | const sp_lex_cursor *clex= thd->lex->get_lex_for_cursor(); |
| 4568 | if (!clex || (clex->get_ps_name().is_null() && |
| 4569 | clex->prepared_stmt.code() == nullptr)) |
| 4570 | { |
| 4571 | /* |
| 4572 | Set placehoder values from prepared_stmt.params() only for |
| 4573 | static cursors. |
| 4574 | Dynamic cursors set placeholder values using a different way: |
| 4575 | with help of sp_instr_set_ps_placeholder instructions. |
| 4576 | */ |
| 4577 | res= set_params_from_actual_params(this, thd->lex->prepared_stmt.params(), |
| 4578 | expanded_query); |
| 4579 | } |
| 4580 | else |
| 4581 | { |
| 4582 | /* |
| 4583 | Set parameters from sp_instr_set_ps_placeholder's. |
| 4584 | Non-zero instr_set_placeholder_count is not possible for |
| 4585 | SQL Standard dynamic cursors: |
| 4586 | DECLARE c CURSOR FOR stmt; |
| 4587 | PREPARE stmt FROM 'SELECT ?'; |
| 4588 | OPEN c USING 'value'; |
| 4589 | It's only possibly for Oracle style dynamic cursors: |
| 4590 | OPEN c FOR 'SELECT ?' |
| 4591 | |
| 4592 | as sp_instr_set_ps_placeholder handles USING expressions as follows: |
| 4593 | - whites the value directly to Prepared_statement::param_array[idx] |
| 4594 | for the former |
| 4595 | - caches the value in sp_instr_set_ps_placeholder for the latter. |
| 4596 | */ |
| 4597 | DBUG_ASSERT(!instrs_set_placeholder.count() || |
| 4598 | clex->prepared_stmt.code() != nullptr); |
| 4599 | if (instrs_set_placeholder.count() && |
| 4600 | set_placeholders_from_instr(instrs_set_placeholder)) |
| 4601 | return true; |
| 4602 | } |
| 4603 | } |
| 4604 | else if (param_count) |
| 4605 | { |
| 4606 | #ifndef EMBEDDED_LIBRARY |
| 4607 | uchar *null_array= packet; |
| 4608 | res= (setup_conversion_functions(this, &packet) || |
| 4609 | set_params(this, null_array, packet, packet_end, expanded_query)); |
| 4610 | #else |
| 4611 | /* |
| 4612 | In embedded library we re-install conversion routines each time |
| 4613 | we set parameters, and also we don't need to parse packet. |
nothing calls this directly
no test coverage detected