1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Merge with 4.1

BitKeeper/etc/ignore:
  auto-union
BitKeeper/etc/logging_ok:
  auto-union
Build-tools/Do-compile:
  Auto merged
VC++Files/sql/mysqld.dsp:
  Auto merged
client/Makefile.am:
  Auto merged
client/mysql.cc:
  Auto merged
BitKeeper/deleted/.del-acinclude.m4~f4ab416bac5003:
  Auto merged
client/mysqltest.c:
  Auto merged
include/my_base.h:
  Auto merged
innobase/dict/dict0dict.c:
  Auto merged
innobase/dict/dict0load.c:
  Auto merged
innobase/include/dict0dict.h:
  Auto merged
innobase/include/row0mysql.h:
  Auto merged
innobase/os/os0file.c:
  Auto merged
innobase/srv/srv0srv.c:
  Auto merged
libmysql/libmysql.c:
  Auto merged
myisam/mi_check.c:
  Auto merged
myisam/mi_rnext_same.c:
  Auto merged
myisam/mi_write.c:
  Auto merged
myisam/sort.c:
  Auto merged
mysql-test/mysql-test-run.sh:
  Auto merged
mysql-test/r/ctype_ucs.result:
  Auto merged
mysql-test/r/ctype_ujis.result:
  Auto merged
mysql-test/r/gis-rtree.result:
  Auto merged
mysql-test/r/group_by.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/metadata.result:
  Auto merged
mysql-test/r/ndb_alter_table.result:
  Auto merged
mysql-test/r/ps_1general.result:
  Auto merged
mysql-test/r/insert_update.result:
  Auto merged
mysql-test/r/timezone2.result:
  Auto merged
mysql-test/r/type_enum.result:
  Auto merged
mysql-test/r/variables.result:
  Auto merged
mysql-test/t/ctype_ucs.test:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/ps_1general.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/system_mysql_db_fix.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
ndb/include/ndbapi/NdbConnection.hpp:
  Auto merged
ndb/include/ndbapi/NdbDictionary.hpp:
  Auto merged
ndb/src/common/util/version.c:
  Auto merged
ndb/src/kernel/blocks/dbacc/DbaccInit.cpp:
  Auto merged
ndb/src/kernel/blocks/dbacc/Makefile.am:
  Auto merged
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  Auto merged
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  Auto merged
ndb/src/kernel/blocks/dblqh/DblqhInit.cpp:
  Auto merged
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  Auto merged
ndb/src/kernel/blocks/dbtux/Dbtux.hpp:
  Auto merged
ndb/src/ndbapi/NdbBlob.cpp:
  Auto merged
ndb/src/ndbapi/NdbConnection.cpp:
  Auto merged
ndb/src/ndbapi/NdbDictionary.cpp:
  Auto merged
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Auto merged
ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  Auto merged
ndb/src/ndbapi/NdbOperationExec.cpp:
  Auto merged
ndb/src/ndbapi/NdbScanOperation.cpp:
  Auto merged
ndb/test/ndbapi/Makefile.am:
  Auto merged
scripts/make_win_src_distribution.sh:
  Auto merged
scripts/mysql_install_db.sh:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_create.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_geofunc.cc:
  Auto merged
sql/item_row.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_strfunc.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_sum.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/password.c:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_derived.cc:
  Auto merged
sql/sql_do.cc:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_help.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_union.cc:
  Auto merged
sql/examples/ha_archive.cc:
  Auto merged
sql/strfunc.cc:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/tztime.h:
  Auto merged
sql/udf_example.cc:
  Auto merged
sql/unireg.cc:
  Auto merged
Makefile.am:
  Simple merge
client/mysqldump.c:
  Simple merge
configure.in:
  Simple merge
libmysqld/lib_sql.cc:
  Automatic merge
mysql-test/r/func_str.result:
  Automatic merge
mysql-test/r/grant.result:
  simple merge
mysql-test/r/multi_update.result:
  automatc merge
mysql-test/r/ps.result:
  automatic merge
mysql-test/r/ps_2myisam.result:
  Automatic merge
mysql-test/r/ps_3innodb.result:
  Automatic merge
mysql-test/r/ps_4heap.result:
  Automatic merge
mysql-test/r/ps_5merge.result:
  Automatic merge
mysql-test/r/ps_6bdb.result:
  Automatic merge
mysql-test/r/ps_7ndb.result:
  Automatic merge
mysql-test/r/show_check.result:
  Automatic merge
mysql-test/r/subselect.result:
  Automatic merge
mysql-test/t/grant.test:
  Automatic merge
mysql-test/t/multi_update.test:
  Automatic merge
mysql-test/t/ps.test:
  Automatic merge
mysql-test/t/show_check.test:
  Automatic merge
ndb/docs/wl2077.txt:
  merge
ndb/src/mgmsrv/main.cpp:
  merge
scripts/mysql_fix_privilege_tables.sh:
  merge
sql/item.cc:
  Merge (difficult)
sql/item.h:
  simple merge
sql/item_cmpfunc.h:
  Automatic merge
sql/item_subselect.cc:
  Simple merge
sql/item_subselect.h:
  Automatic merge
sql/mysql_priv.h:
  Simple merge
sql/slave.h:
  Automatic merge
sql/sql_base.cc:
  Removed code that was backported to 4.1
sql/sql_class.h:
  Merge (some code moved to sql_insert.cc)
sql/sql_db.cc:
  simple merge
sql/sql_insert.cc:
  Merge (difficult as logic had changed both in 4.1 and 5.0)
  Some coded moved here from sql_class.h
sql/sql_parse.cc:
  Merge (difficult)
sql/sql_prepare.cc:
  Simple merge
sql/sql_select.cc:
  Automatic merge
sql/sql_table.cc:
  Simple merge
sql/sql_update.cc:
  Difficult merge because of different logic for multi-updates
sql/sql_yacc.yy:
  Simple merge
tests/client_test.c:
  Simple merge
This commit is contained in:
unknown
2004-12-22 13:54:39 +02:00
395 changed files with 11807 additions and 25533 deletions

View File

@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_repl.h"
#include "repl_failsafe.h"
#include <m_ctype.h>
@@ -1129,13 +1128,26 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
thd->init_for_queries();
while (fgets(buff, thd->net.max_packet, file))
{
uint length=(uint) strlen(buff);
if (buff[length-1]!='\n' && !feof(file))
{
net_send_error(thd, ER_NET_PACKET_TOO_LARGE, NullS);
thd->fatal_error();
break;
}
ulong length= (ulong) strlen(buff);
while (buff[length-1] != '\n' && !feof(file))
{
/*
We got only a part of the current string. Will try to increase
net buffer then read the rest of the current string.
*/
if (net_realloc(&(thd->net), 2 * thd->net.max_packet))
{
net_send_error(thd, ER_NET_PACKET_TOO_LARGE, NullS);
thd->fatal_error();
break;
}
buff= (char*) thd->net.buff;
fgets(buff + length, thd->net.max_packet - length, file);
length+= (ulong) strlen(buff + length);
}
if (thd->is_fatal_error)
break;
while (length && (my_isspace(thd->charset(), buff[length-1]) ||
buff[length-1] == ';'))
length--;
@@ -2817,7 +2829,9 @@ create_error:
check_access(thd, SELECT_ACL | EXTRA_ACL, first_table->db,
&first_table->grant.privilege, 0, 0))
goto error;
res = mysqld_show_create(thd, first_table);
if (grant_option && check_grant(thd, SELECT_ACL, all_tables, 2, UINT_MAX, 0))
goto error;
res= mysqld_show_create(thd, first_table);
break;
}
#endif
@@ -2945,7 +2959,7 @@ create_error:
if ((res= insert_precheck(thd, all_tables)))
break;
res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values,
select_lex->item_list, lex->value_list,
lex->update_list, lex->value_list,
(lex->value_list.elements ?
DUP_UPDATE : lex->duplicates));
if (first_table->view && !first_table->contain_auto_increment)
@@ -2956,7 +2970,7 @@ create_error:
case SQLCOM_INSERT_SELECT:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_select_precheck(thd, all_tables)))
if ((res= insert_precheck(thd, all_tables)))
break;
/* Fix lock for first table */
@@ -2969,19 +2983,23 @@ create_error:
select_result *result;
unit->set_limit(select_lex, select_lex);
if (!(res= open_and_lock_tables(thd, all_tables)))
if (!(res= open_and_lock_tables(thd, all_tables)) &&
!(res= mysql_prepare_insert(thd, tables, first_local_table,
tables->table, lex->field_list, 0,
lex->update_list, lex->value_list,
lex->duplicates)))
{
TABLE *table= tables->table;
/* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*)first_table->next_local;
res= mysql_insert_select_prepare(thd);
if (!res && (result= new select_insert(first_table, first_table->table,
&lex->field_list,
&lex->update_list, &lex->value_list,
lex->duplicates,
lex->duplicates == DUP_IGNORE)))
{
TABLE_LIST *first_select_table;
/*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
@@ -2990,6 +3008,7 @@ create_error:
res= handle_select(thd, lex, result);
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
delete result;
table->insert_values= 0;
}
/* revert changes for SP */
lex->select_lex.table_list.first= (byte*) first_table;
@@ -3355,7 +3374,13 @@ create_error:
}
case SQLCOM_ALTER_DB:
{
if (!strip_sp(lex->name) || check_db_name(lex->name))
char *db= lex->name ? lex->name : thd->db;
if (!db)
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
break;
}
if (!strip_sp(db) || check_db_name(db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
break;
@@ -3369,14 +3394,14 @@ create_error:
*/
#ifdef HAVE_REPLICATION
if (thd->slave_thread &&
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name)))
(!db_ok(db, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(db)))
{
my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
break;
}
#endif
if (check_access(thd,ALTER_ACL,lex->name,0,1,0))
if (check_access(thd, ALTER_ACL, db, 0, 1, 0))
break;
if (thd->locked_tables || thd->active_transaction())
{
@@ -3384,7 +3409,7 @@ create_error:
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
res=mysql_alter_db(thd,lex->name,&lex->create_info);
res= mysql_alter_db(thd, db, &lex->create_info);
break;
}
case SQLCOM_SHOW_CREATE_DB:
@@ -3396,12 +3421,6 @@ create_error:
}
if (check_access(thd,SELECT_ACL,lex->name,0,1,0))
break;
if (thd->locked_tables || thd->active_transaction())
{
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
res=mysqld_show_create_db(thd,lex->name,&lex->create_info);
break;
}
@@ -4093,7 +4112,7 @@ error:
/*
Check grants for commands which work only with one table and all other
tables belong to subselects.
tables belonging to subselects or implicitly opened tables.
SYNOPSIS
check_one_table_access()
@@ -4116,7 +4135,7 @@ bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
if (grant_option && check_grant(thd, privilege, all_tables, 0, 1, 0))
return 1;
/* Check rights on tables of subselect (if exists) */
/* Check rights on tables of subselects and implictly opened tables */
TABLE_LIST *subselects_tables;
if ((subselects_tables= all_tables->next_global))
{
@@ -5977,9 +5996,9 @@ Item * all_any_subquery_creator(Item *left_expr,
Item_allany_subselect *it=
new Item_allany_subselect(left_expr, (*cmp)(all), select_lex, all);
if (all)
return it->upper_not= new Item_func_not_all(it); /* ALL */
return it->upper_item= new Item_func_not_all(it); /* ALL */
return it; /* ANY/SOME */
return it->upper_item= new Item_func_nop_all(it); /* ANY/SOME */
}
@@ -6083,6 +6102,9 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
DBUG_PRINT("info",("Checking sub query list"));
for (table= tables; table; table= table->next_global)
{
if (my_tz_check_n_skip_implicit_tables(&table,
lex->time_zone_tables_used))
continue;
if (!table->table_in_first_from_clause && table->derived)
{
if (check_access(thd, SELECT_ACL, table->db,
@@ -6167,32 +6189,6 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
}
/*
INSERT ... SELECT query pre-check
SYNOPSIS
insert_delete_precheck()
thd Thread handler
tables Global table list
RETURN VALUE
FALSE OK
TRUE Error
*/
bool insert_select_precheck(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("insert_select_precheck");
/*
Check that we have modify privileges for the first table and
select privileges for the rest
*/
ulong privilege= (thd->lex->duplicates == DUP_REPLACE ?
INSERT_ACL | DELETE_ACL : INSERT_ACL);
DBUG_RETURN(check_one_table_access(thd, privilege, tables));
}
/*
simple UPDATE query pre-check
@@ -6261,6 +6257,10 @@ bool insert_precheck(THD *thd, TABLE_LIST *tables)
LEX *lex= thd->lex;
DBUG_ENTER("insert_precheck");
/*
Check that we have modify privileges for the first table and
select privileges for the rest
*/
ulong privilege= (INSERT_ACL |
(lex->duplicates == DUP_REPLACE ? DELETE_ACL : 0) |
(lex->value_list.elements ? UPDATE_ACL : 0));
@@ -6268,7 +6268,7 @@ bool insert_precheck(THD *thd, TABLE_LIST *tables)
if (check_one_table_access(thd, privilege, tables))
DBUG_RETURN(TRUE);
if (lex->select_lex.item_list.elements != lex->value_list.elements)
if (lex->update_list.elements != lex->value_list.elements)
{
my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
DBUG_RETURN(TRUE);