| 2137 | */ |
| 2138 | |
| 2139 | bool Sql_cmd_delete::execute_inner(THD *thd) |
| 2140 | { |
| 2141 | Running_stmt_guard guard(thd, active_dml_stmt::DELETING_STMT); |
| 2142 | |
| 2143 | if (!multitable) |
| 2144 | { |
| 2145 | if (lex->has_returning()) |
| 2146 | { |
| 2147 | select_result *sel_result= NULL; |
| 2148 | delete result; |
| 2149 | /* This is DELETE ... RETURNING. It will return output to the client */ |
| 2150 | if (thd->lex->analyze_stmt) |
| 2151 | { |
| 2152 | /* |
| 2153 | Actually, it is ANALYZE .. DELETE .. RETURNING. We need to produce |
| 2154 | output and then discard it. |
| 2155 | */ |
| 2156 | sel_result= new (thd->mem_root) select_send_analyze(thd); |
| 2157 | save_protocol= thd->protocol; |
| 2158 | thd->protocol= new Protocol_discard(thd); |
| 2159 | } |
| 2160 | else |
| 2161 | { |
| 2162 | if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd))) |
| 2163 | return true; |
| 2164 | } |
| 2165 | result= lex->result ? lex->result : sel_result; |
| 2166 | } |
| 2167 | } |
| 2168 | |
| 2169 | bool res= multitable ? Sql_cmd_dml::execute_inner(thd) |
| 2170 | : delete_from_single_table(thd); |
| 2171 | |
| 2172 | res|= thd->is_error(); |
| 2173 | |
| 2174 | if (save_protocol) |
| 2175 | { |
| 2176 | delete thd->protocol; |
| 2177 | thd->protocol= save_protocol; |
| 2178 | } |
| 2179 | { |
| 2180 | if (unlikely(res)) |
| 2181 | { |
| 2182 | if (multitable) |
| 2183 | result->abort_result_set(); |
| 2184 | } |
| 2185 | else |
| 2186 | { |
| 2187 | if (thd->lex->describe || thd->lex->analyze_stmt) |
| 2188 | { |
| 2189 | bool extended= thd->lex->describe & DESCRIBE_EXTENDED; |
| 2190 | res= thd->lex->explain->send_explain(thd, extended); |
| 2191 | } |
| 2192 | } |
| 2193 | } |
| 2194 | |
| 2195 | if (result) |
| 2196 | { |
nothing calls this directly
no test coverage detected