Commit 2f93aa9e authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Test that all MERGE tables comes from the same database

parent 788bc3f4
...@@ -4502,6 +4502,13 @@ Minimum respective maximum possible @code{double} value. ...@@ -4502,6 +4502,13 @@ Minimum respective maximum possible @code{double} value.
@item @item
@code{LIMIT} on negative numbers are treated as big positive numbers. @code{LIMIT} on negative numbers are treated as big positive numbers.
@item
If you use @code{ALTER TABLE} to first add an @code{UNIQUE} index to a
table used in a @code{MERGE} table and then use @code{ALTER TABLE} to
add a normal index on the @code{MERGE} table, the key order will be
different for the tables if there was an old not-unique key in the
table. This is because @code{ALTER TABLE} puts @code{UNIQUE} keys before
normal keys to be able to detect duplicate keys as early as possible.
@end itemize @end itemize
The following are known bugs in earlier versions of MySQL: The following are known bugs in earlier versions of MySQL:
...@@ -11688,9 +11695,9 @@ work: ...@@ -11688,9 +11695,9 @@ work:
@example @example
CC="cc -pthread" CC="cc -pthread"
CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host" CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
CXX="cxx -pthread" CXX="cxx -pthread"
CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host" CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
export CC CFLAGS CXX CXXFLAGS export CC CFLAGS CXX CXXFLAGS
./configure \ ./configure \
--prefix=/usr/local/mysql \ --prefix=/usr/local/mysql \
...@@ -34149,6 +34156,12 @@ index exists, it drops the first @code{UNIQUE} index in the table. ...@@ -34149,6 +34156,12 @@ index exists, it drops the first @code{UNIQUE} index in the table.
(MySQL marks the first @code{UNIQUE} key as the @code{PRIMARY KEY} (MySQL marks the first @code{UNIQUE} key as the @code{PRIMARY KEY}
if no @code{PRIMARY KEY} was specified explicitly.) if no @code{PRIMARY KEY} was specified explicitly.)
@findex UNIQUE
@findex PRIMARY KEY
If you add a @code{UNIQUE INDEX} or @code{PRIMARY KEY} to a table, this
is stored before any not @code[UNIQUE} index so that MySQL can detect
duplicate keys as early as possible.
@findex ORDER BY @findex ORDER BY
@item @item
@code{ORDER BY} allows you to create the new table with the rows in a @code{ORDER BY} allows you to create the new table with the rows in a
...@@ -35558,14 +35571,15 @@ mapped tables. (We plan to fix this in 4.0). ...@@ -35558,14 +35571,15 @@ mapped tables. (We plan to fix this in 4.0).
With identical tables we mean that all tables are created with identical With identical tables we mean that all tables are created with identical
column and key information. You can't put a MERGE over tables where the column and key information. You can't put a MERGE over tables where the
columns are packed differently or doesn't have exactly the same columns. columns are packed differently, doesn't have exactly the same columns or
Some of the tables can however be compressed with @code{myisampack}. have the keys in different order. Some of the tables can however be
@xref{myisampack}. compressed with @code{myisampack}. @xref{myisampack}.
When you create a @code{MERGE} table, you will get a @code{.frm} table When you create a @code{MERGE} table, you will get a @code{.frm} table
definition file and a @code{.MRG} table list file. The @code{.MRG} just definition file and a @code{.MRG} table list file. The @code{.MRG} just
contains a list of the index files (@code{.MYI} files) that should contains a list of the index files (@code{.MYI} files) that should
be used as one. be used as one. All used tables must be in the same database as the
@code{MERGE} table itself.
For the moment you need to have @code{SELECT}, @code{UPDATE}, and For the moment you need to have @code{SELECT}, @code{UPDATE}, and
@code{DELETE} privileges on the tables you map to a @code{MERGE} table. @code{DELETE} privileges on the tables you map to a @code{MERGE} table.
...@@ -35691,7 +35705,6 @@ Change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the ...@@ -35691,7 +35705,6 @@ Change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the
read the new definition file. read the new definition file.
@end itemize @end itemize
@node ISAM, HEAP, MERGE, Table types @node ISAM, HEAP, MERGE, Table types
@section ISAM Tables @section ISAM Tables
...@@ -46683,15 +46696,26 @@ not yet 100% confident in this code. ...@@ -46683,15 +46696,26 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.42 @appendixsubsec Changes in release 3.23.42
@itemize @bullet @itemize @bullet
@item @item
Enforce that all tables in a @code{MERGE} table comes from the same
database.
@item
Fixed bug with @code{LOAD DATA INFILE} and transactional tables.
@item
Fix bug when using @code{INSERT DELAYED} with wrong column definition.
@item
Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns. Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
@item @item
Fixed critical bug in @code{InnoDB} and @code{BLOB}'s. If one has used
@code{BLOB}'s larger than 8K in an @code{InnoDB} table one must dump
the table with @code{mysqldump}, drop it and restore it from the dump.
@item
Applied large patch for OS/2 from Yuri Dario. Applied large patch for OS/2 from Yuri Dario.
@item @item
Fixed problem with InnoDB when one could get the error @code{Can't Fixed problem with InnoDB when one could get the error @code{Can't
execute the given command...} even when one didn't have an active execute the given command...} even when one didn't have an active
transaction. transaction.
@item @item
Applied some fixes for Gemini. Applied some minor fixes that concerns Gemini.
@item @item
Use real arithmetic operations even in integer context if not Use real arithmetic operations even in integer context if not
all arguments are integers. (Fixes uncommon bug in some integer all arguments are integers. (Fixes uncommon bug in some integer
...@@ -212,4 +212,5 @@ ...@@ -212,4 +212,5 @@
#define ER_CREATE_DB_WITH_READ_LOCK 1209 #define ER_CREATE_DB_WITH_READ_LOCK 1209
#define ER_WRONG_ARGUMENTS 1210 #define ER_WRONG_ARGUMENTS 1210
#define ER_NO_PERMISSON_TO_CREATE_USER 1211 #define ER_NO_PERMISSON_TO_CREATE_USER 1211
#define ER_ERROR_MESSAGES 212 #define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
#define ER_ERROR_MESSAGES 213
...@@ -35,9 +35,13 @@ show create table t3; ...@@ -35,9 +35,13 @@ show create table t3;
# The following should give errors # The following should give errors
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2); create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
--error 1016
select * from t4;
--error 1212
create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
# Because of windows, it's important that we drop the merge tables first! # Because of windows, it's important that we drop the merge tables first!
drop table if exists t4,t3,t1,t2; drop table if exists t5,t4,t3,t1,t2;
create table t1 (c char(10)) type=myisam; create table t1 (c char(10)) type=myisam;
create table t2 (c char(10)) type=myisam; create table t2 (c char(10)) type=myisam;
......
...@@ -472,7 +472,7 @@ int main(int argc,char **argv) ...@@ -472,7 +472,7 @@ int main(int argc,char **argv)
int error; int error;
MY_INIT(argv[0]); MY_INIT(argv[0]);
start_value=4597269L; best_t1=6001982L; best_t2=5063828L; best_type=4; /* mode=4513 add=8 type: 0 */ start_value=6130115L; best_t1=3632784L; best_t2=86437L; best_type=3; /* mode=4229 add=2 type: 0 */
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);
......
...@@ -86,7 +86,6 @@ int ha_myisammrg::delete_row(const byte * buf) ...@@ -86,7 +86,6 @@ int ha_myisammrg::delete_row(const byte * buf)
int ha_myisammrg::index_read(byte * buf, const byte * key, int ha_myisammrg::index_read(byte * buf, const byte * key,
uint key_len, enum ha_rkey_function find_flag) uint key_len, enum ha_rkey_function find_flag)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_key_count,&LOCK_status); statistic_increment(ha_read_key_count,&LOCK_status);
int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag); int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
...@@ -96,7 +95,6 @@ int ha_myisammrg::index_read(byte * buf, const byte * key, ...@@ -96,7 +95,6 @@ int ha_myisammrg::index_read(byte * buf, const byte * key,
int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
uint key_len, enum ha_rkey_function find_flag) uint key_len, enum ha_rkey_function find_flag)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_key_count,&LOCK_status); statistic_increment(ha_read_key_count,&LOCK_status);
int error=myrg_rkey(file,buf,index, key, key_len, find_flag); int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
...@@ -105,7 +103,6 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -105,7 +103,6 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
int ha_myisammrg::index_next(byte * buf) int ha_myisammrg::index_next(byte * buf)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_next_count,&LOCK_status); statistic_increment(ha_read_next_count,&LOCK_status);
int error=myrg_rnext(file,buf,active_index); int error=myrg_rnext(file,buf,active_index);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
...@@ -114,7 +111,6 @@ int ha_myisammrg::index_next(byte * buf) ...@@ -114,7 +111,6 @@ int ha_myisammrg::index_next(byte * buf)
int ha_myisammrg::index_prev(byte * buf) int ha_myisammrg::index_prev(byte * buf)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_prev_count,&LOCK_status); statistic_increment(ha_read_prev_count,&LOCK_status);
int error=myrg_rprev(file,buf, active_index); int error=myrg_rprev(file,buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
...@@ -123,7 +119,6 @@ int ha_myisammrg::index_prev(byte * buf) ...@@ -123,7 +119,6 @@ int ha_myisammrg::index_prev(byte * buf)
int ha_myisammrg::index_first(byte * buf) int ha_myisammrg::index_first(byte * buf)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_first_count,&LOCK_status); statistic_increment(ha_read_first_count,&LOCK_status);
int error=myrg_rfirst(file, buf, active_index); int error=myrg_rfirst(file, buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
...@@ -132,7 +127,6 @@ int ha_myisammrg::index_first(byte * buf) ...@@ -132,7 +127,6 @@ int ha_myisammrg::index_first(byte * buf)
int ha_myisammrg::index_last(byte * buf) int ha_myisammrg::index_last(byte * buf)
{ {
// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_last_count,&LOCK_status); statistic_increment(ha_read_last_count,&LOCK_status);
int error=myrg_rlast(file, buf, active_index); int error=myrg_rlast(file, buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0; table->status=error ? STATUS_NOT_FOUND: 0;
......
...@@ -222,3 +222,4 @@ ...@@ -222,3 +222,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -216,3 +216,4 @@ ...@@ -216,3 +216,4 @@
"CREATE DATABASE er ikke tilladt mens en tråd holder på globalt read lock", "CREATE DATABASE er ikke tilladt mens en tråd holder på globalt read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -217,3 +217,4 @@ ...@@ -217,3 +217,4 @@
"CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit", "CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit",
"Foutieve parameters voor %s", "Foutieve parameters voor %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -217,3 +217,4 @@ ...@@ -217,3 +217,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -216,3 +216,4 @@ ...@@ -216,3 +216,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -215,3 +215,4 @@ ...@@ -215,3 +215,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -215,3 +215,4 @@ ...@@ -215,3 +215,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -215,3 +215,4 @@ ...@@ -215,3 +215,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -215,3 +215,4 @@ ...@@ -215,3 +215,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -217,3 +217,4 @@ ...@@ -217,3 +217,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura", "CREATE DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura",
"Argumentos errados para %s", "Argumentos errados para %s",
"Não é permitido a %-.32s@%-.64s criar novos usuários", "Não é permitido a %-.32s@%-.64s criar novos usuários",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -217,3 +217,4 @@ ...@@ -217,3 +217,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -216,3 +216,4 @@ ...@@ -216,3 +216,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -221,3 +221,4 @@ ...@@ -221,3 +221,4 @@
"CREATE DATABASE not allowed while thread is holding global read lock", "CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -214,3 +214,4 @@ ...@@ -214,3 +214,4 @@
"CREATE DATABASE no permitido mientras un thread está ejerciendo un bloqueo de lectura global", "CREATE DATABASE no permitido mientras un thread está ejerciendo un bloqueo de lectura global",
"Wrong arguments to %s", "Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users", "%-.32s@%-.64s is not allowed to create new users",
"Incorrect table definition; All MERGE tables must be in the same database",
...@@ -213,3 +213,4 @@ ...@@ -213,3 +213,4 @@
"CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås", "CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås",
"Felaktiga argument till %s", "Felaktiga argument till %s",
"%-.32s@%-.64s har inte rättigheter att skapa nya användare", "%-.32s@%-.64s har inte rättigheter att skapa nya användare",
"Felaktig tabell definition: Alla tabeller i en MERGE tabell måste vara i samma databas",
...@@ -2178,10 +2178,18 @@ static bool check_merge_table_access(THD *thd, char *db, ...@@ -2178,10 +2178,18 @@ static bool check_merge_table_access(THD *thd, char *db,
int error=0; int error=0;
if (table_list) if (table_list)
{ {
/* Force all tables to use the current database */ /* Check that all tables use the current database */
TABLE_LIST *tmp; TABLE_LIST *tmp;
for (tmp=table_list; tmp ; tmp=tmp->next) for (tmp=table_list; tmp ; tmp=tmp->next)
tmp->db=db; {
if (!tmp->db || !tmp->db[0])
tmp->db=db;
else if (!strcmp(tmp->db,db))
{
send_error(&thd->net,ER_UNION_TABLES_IN_DIFFERENT_DIR);
return 1;
}
}
error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
table_list); table_list);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment