List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:August 26 2009 10:36pm
Subject:Re: bzr commit into mysql-5.0-bugteam branch (satya.bn:2790) Bug#46384
View as plain text  
Hi Satya,

On 8/18/09 8:49 AM, Satya B wrote:
> #At file:///home/satya/WORK/46384/mysql-5.0-bugteam-46384/ based on
> revid:joro@stripped
>
>   2790 Satya B	2009-08-18
>        Fix for BUG#46384 - mysqld segfault when trying to create table with same
>                            name as existing view
>
>        When trying to create a table with the same name as existing view with join,
>        mysql server crashes.
>
>        The problem is when create table is issued with the same name as view, while
>        verifying with the existing tables, we assume that base table object is
> created always.

Please limit lines to 80 characters.

>        In this case, since it is a view over multiple tables, we don't have the
> mysql
>        derived table object.
>
>        Fixed the logic which checks if there is an existing table to not to assume
>        that table object is created when the base table is view over multiple
> tables.
>        modified:
>          mysql-test/r/create.result
>          mysql-test/t/create.test
>          sql/sql_insert.cc
>
> per-file messages:
>    mysql-test/r/create.result
>      Testcase for BUG#46384
>    mysql-test/t/create.test
>      Testcase for BUG#46384
>    sql/sql_insert.cc
>      BUG#46384 - mysqld segfault when trying to create table with same
>                  name as existing view
>
>      Fixed create_table_from_items() method to properly check, if the base table
>      is a view over multiple tables.
> === modified file 'mysql-test/r/create.result'
> --- a/mysql-test/r/create.result	2008-10-02 11:57:52 +0000
> +++ b/mysql-test/r/create.result	2009-08-18 11:49:06 +0000
> @@ -1559,4 +1559,17 @@ CREATE TABLE IF NOT EXISTS t2 (a INTEGER
>   SELECT a FROM t1;
>   ERROR 23000: Duplicate entry '1' for key 1
>   DROP TABLE t1, t2;
> +#
> +# BUG#46384 - mysqld segfault when trying to create table with same
> +#             name as existing view
> +#
> +CREATE TABLE t1 (a INT);
> +CREATE TABLE t2 (a INT);
> +INSERT INTO t1 VALUES (1),(2),(3);
> +INSERT INTO t2 VALUES (1),(2),(3);
> +CREATE VIEW v1 AS SELECT t1.a FROM t1,t2;
> +CREATE TABLE v1 AS SELECT * FROM t1;
> +ERROR 42S01: Table 'v1' already exists
> +DROP VIEW v1;
> +DROP TABLE t1,t2;
>   End of 5.0 tests
>
> === modified file 'mysql-test/t/create.test'
> --- a/mysql-test/t/create.test	2008-10-02 11:57:52 +0000
> +++ b/mysql-test/t/create.test	2009-08-18 11:49:06 +0000
> @@ -1194,5 +1194,22 @@ CREATE TABLE IF NOT EXISTS t2 (a INTEGER
>
>   DROP TABLE t1, t2;
>
> +--echo #
> +--echo # BUG#46384 - mysqld segfault when trying to create table with same
> +--echo #             name as existing view
> +--echo #
> +
> +CREATE TABLE t1 (a INT);
> +CREATE TABLE t2 (a INT);
> +
> +INSERT INTO t1 VALUES (1),(2),(3);
> +INSERT INTO t2 VALUES (1),(2),(3);
> +
> +CREATE VIEW v1 AS SELECT t1.a FROM t1,t2;
> +--error ER_TABLE_EXISTS_ERROR
> +CREATE TABLE v1 AS SELECT * FROM t1;
> +
> +DROP VIEW v1;
> +DROP TABLE t1,t2;
>
>   --echo End of 5.0 tests
>
> === modified file 'sql/sql_insert.cc'
> --- a/sql/sql_insert.cc	2009-08-10 18:53:26 +0000
> +++ b/sql/sql_insert.cc	2009-08-18 11:49:06 +0000
> @@ -3217,7 +3217,8 @@ static TABLE *create_table_from_items(TH
>     DBUG_EXECUTE_IF("sleep_create_select_before_check_if_exists",
> my_sleep(6000000););
>
>     if (!(create_info->options&  HA_LEX_CREATE_TMP_TABLE)&&
> -      create_table->table->db_stat)
> +      ((create_table->multitable_view == true&&  create_table->table
> ==  NULL) ||
> +      create_table->table->db_stat))

Hum, I think just checking for create_table->table would be sufficient.

mysql_create_table will perform more extensive tests for the presence of 
the table anyway.

OK to push given that the suggestion is implemented.
Thread
bzr commit into mysql-5.0-bugteam branch (satya.bn:2790) Bug#46384Satya B18 Aug
  • Re: bzr commit into mysql-5.0-bugteam branch (satya.bn:2790) Bug#46384Davi Arnaut27 Aug
    • Re: bzr commit into mysql-5.0-bugteam branch (satya.bn:2790) Bug#46384satya27 Aug