diff options
author | unknown <kroki/tomash@moonlight.intranet> | 2006-10-27 13:40:28 +0400 |
---|---|---|
committer | unknown <kroki/tomash@moonlight.intranet> | 2006-10-27 13:40:28 +0400 |
commit | 3ce0cadd05e00b31934af0bbf3b1f18891404a8e (patch) | |
tree | cfdb11c23acf46a4552e538e8a9d4116bb4d9a10 /sql/sql_parse.cc | |
parent | b67bb25408cc776fdca562d14eed22314b1b4d96 (diff) | |
parent | 532735e6c8fa330e256149f0c0d94822596ac18c (diff) | |
download | mariadb-git-3ce0cadd05e00b31934af0bbf3b1f18891404a8e.tar.gz |
Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug22584
into moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-bug22584
mysql-test/r/view.result:
Manual merge.
mysql-test/t/view.test:
Manual merge.
sql/sql_parse.cc:
Manual merge.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 09bf1737e39..0dd9823ffe3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3394,9 +3394,17 @@ end_with_restore_list: res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values, lex->update_list, lex->value_list, lex->duplicates, lex->ignore); - /* do not show last insert ID if VIEW does not have auto_inc */ + + /* + If we have inserted into a VIEW, and the base table has + AUTO_INCREMENT column, but this column is not accessible through + a view, then we should restore LAST_INSERT_ID to the value it + had before the statement. + */ if (first_table->view && !first_table->contain_auto_increment) - thd->first_successful_insert_id_in_cur_stmt= 0; + thd->first_successful_insert_id_in_cur_stmt= + thd->first_successful_insert_id_in_prev_stmt; + break; } case SQLCOM_REPLACE_SELECT: @@ -3456,9 +3464,17 @@ end_with_restore_list: /* revert changes for SP */ select_lex->table_list.first= (byte*) first_table; } - /* do not show last insert ID if VIEW does not have auto_inc */ + + /* + If we have inserted into a VIEW, and the base table has + AUTO_INCREMENT column, but this column is not accessible through + a view, then we should restore LAST_INSERT_ID to the value it + had before the statement. + */ if (first_table->view && !first_table->contain_auto_increment) - thd->first_successful_insert_id_in_cur_stmt= 0; + thd->first_successful_insert_id_in_cur_stmt= + thd->first_successful_insert_id_in_prev_stmt; + break; } case SQLCOM_TRUNCATE: |