| 1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License as published by |
| 5 | the Free Software Foundation; version 2 of the License. |
| 6 | |
| 7 | This program is distributed in the hope that it will be useful, |
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | GNU General Public License for more details. |
| 11 | |
| 12 | You should have received a copy of the GNU General Public License |
| 13 | along with this program; if not, write to the Free Software |
| 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 15 | |
| 16 | |
| 17 | /* Execute DO statement */ |
| 18 | |
| 19 | #include "mariadb.h" |
| 20 | #include "sql_priv.h" |
| 21 | #include "transaction.h" |
| 22 | #include "unireg.h" |
| 23 | #include "sql_do.h" |
| 24 | #include "sql_base.h" // setup_fields |
| 25 | #include "sql_select.h" // free_underlaid_joins |
| 26 | |
| 27 | bool mysql_do(THD *thd, List<Item> &values) |
| 28 | { |
| 29 | List_iterator<Item> li(values); |
| 30 | Item *value; |
| 31 | DBUG_ENTER("mysql_do" ); |
| 32 | if (setup_fields(thd, Ref_ptr_array(), values, COLUMNS_READ, 0, NULL, 0)) |
| 33 | DBUG_RETURN(TRUE); |
| 34 | while ((value = li++)) |
| 35 | (void) value->is_null(); |
| 36 | free_underlaid_joins(thd, &thd->lex->select_lex); |
| 37 | |
| 38 | if (unlikely(thd->is_error())) |
| 39 | { |
| 40 | /* |
| 41 | Rollback the effect of the statement, since next instruction |
| 42 | will clear the error and the rollback in the end of |
| 43 | mysql_execute_command() won't work. |
| 44 | */ |
| 45 | if (! thd->in_sub_stmt) |
| 46 | trans_rollback_stmt(thd); |
| 47 | thd->clear_error(); // DO always is OK |
| 48 | } |
| 49 | my_ok(thd); |
| 50 | DBUG_RETURN(FALSE); |
| 51 | } |
| 52 | |