| 32739 | } |
| 32740 | |
| 32741 | void st_select_lex::print_hints(THD *thd, String *str) |
| 32742 | { |
| 32743 | if (!parent_lex->opt_hints_global) |
| 32744 | return; |
| 32745 | |
| 32746 | const bool is_view= parent_lex->sql_command == SQLCOM_CREATE_VIEW || |
| 32747 | parent_lex->sql_command == SQLCOM_SHOW_CREATE; |
| 32748 | constexpr LEX_CSTRING header={STRING_WITH_LEN("/*+ ")}; |
| 32749 | str->append(header); |
| 32750 | const uint32 len_before_hints= str->length(); |
| 32751 | |
| 32752 | if (opt_hints_qb) |
| 32753 | opt_hints_qb->append_qb_hint(thd, str); |
| 32754 | if (this == parent_lex->unit.first_select() && !is_view) |
| 32755 | { |
| 32756 | /* |
| 32757 | For normal queries (not views creation/show) opt_hints_global will |
| 32758 | print itself and all children recursively into the first select. |
| 32759 | Global hints are not supported inside views, so it is safe to skip them |
| 32760 | */ |
| 32761 | parent_lex->opt_hints_global->print(thd, str); |
| 32762 | } |
| 32763 | if (is_view && opt_hints_qb) |
| 32764 | { |
| 32765 | // For views print hints related to a QB right into the QB they target |
| 32766 | opt_hints_qb->print(thd, str); |
| 32767 | } |
| 32768 | |
| 32769 | // If no hints were added, then rollback the previouly added header. |
| 32770 | if (str->length() <= len_before_hints) |
| 32771 | { |
| 32772 | str->length(len_before_hints - header.length); |
| 32773 | return; |
| 32774 | } |
| 32775 | |
| 32776 | // Some hints were printed, close the hint string |
| 32777 | str->append(STRING_WITH_LEN("*/ ")); |
| 32778 | } |
| 32779 | |
| 32780 | /** |
| 32781 | Change the select_result object of the JOIN. |
nothing calls this directly
no test coverage detected