diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-08-18 13:55:37 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-08-18 13:55:37 +0200 |
commit | f2123f34e3c0b9315626406786293a5fafa2fc13 (patch) | |
tree | 34705bdb0e8d518cdc7400d5d2afb11ae8cf2bab /sql/sql_parse.cc | |
parent | eb498cce4dafc2eda285c71ed96d64e451f02ec2 (diff) | |
parent | d0d8bbed5e901e59044be6bcaa6d4020238a1eb4 (diff) | |
download | mariadb-git-f2123f34e3c0b9315626406786293a5fafa2fc13.tar.gz |
Merge from mysql-5.5-bugfixing to mysql-5.5-runtime
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5dde85577ca..b78815f0e52 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2457,13 +2457,7 @@ case SQLCOM_PREPARE: } #endif - /* Set strategies: reset default or 'prepared' values. */ - create_table->open_strategy= TABLE_LIST::OPEN_IF_EXISTS; - create_table->lock_strategy= TABLE_LIST::OTLS_DOWNGRADE_IF_EXISTS; - - /* - Close any open handlers for the table - */ + /* Close any open handlers for the table. */ mysql_ha_rm_tables(thd, create_table); if (select_lex->item_list.elements) // With select @@ -2523,44 +2517,25 @@ case SQLCOM_PREPARE: goto end_with_restore_list; } - if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE)) - { - /* Base table and temporary table are not in the same name space. */ - create_table->open_type= OT_BASE_ONLY; - } - if (!(res= open_and_lock_tables(thd, lex->query_tables, TRUE, 0))) { - /* - Is table which we are changing used somewhere in other parts - of query - */ - if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE)) + /* The table already exists */ + if (create_table->table) { - TABLE_LIST *duplicate; - if ((duplicate= unique_table(thd, create_table, select_tables, 0))) + if (create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS) { - update_non_unique_table_error(create_table, "CREATE", duplicate); - res= 1; - goto end_with_restore_list; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_TABLE_EXISTS_ERROR, + ER(ER_TABLE_EXISTS_ERROR), + create_info.alias); + my_ok(thd); } - } - /* If we create merge table, we have to test tables in merge, too */ - if (create_info.used_fields & HA_CREATE_USED_UNION) - { - TABLE_LIST *tab; - for (tab= create_info.merge_list.first; - tab; - tab= tab->next_local) + else { - TABLE_LIST *duplicate; - if ((duplicate= unique_table(thd, tab, select_tables, 0))) - { - update_non_unique_table_error(tab, "CREATE", duplicate); - res= 1; - goto end_with_restore_list; - } + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_info.alias); + res= 1; } + goto end_with_restore_list; } /* @@ -2593,7 +2568,7 @@ case SQLCOM_PREPARE: res= handle_select(thd, lex, result, 0); delete result; } - + lex->link_first_table_back(create_table, link_to_local); } } @@ -6938,7 +6913,7 @@ void create_table_set_open_action_and_adjust_tables(LEX *lex) if (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) create_table->open_type= OT_TEMPORARY_ONLY; - else if (!lex->select_lex.item_list.elements) + else create_table->open_type= OT_BASE_ONLY; if (!lex->select_lex.item_list.elements) |