1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Small improvement to alloc_root

Add support for LIMIT # OFFSET #
Changed lock handling:  Now all locks should be stored in TABLE_LIST instead of passed to functions.
Don't call query_cache_invalidate() twice in some cases
mysql_change_user() now clears states to be equal to close + connect.
Fixed a bug with multi-table-update and multi-table-delete when used with LOCK TABLES
Fixed a bug with replicate-do and UPDATE


BitKeeper/etc/ignore:
  added autom4te.cache/* bdb/dist/autom4te.cache/* innobase/autom4te.cache/*
include/my_alloc.h:
  Small improvement to alloc_root
libmysql/libmysql.c:
  Removed compiler warning
myisam/mi_page.c:
  Better DBUG message
mysql-test/r/multi_update.result:
  Added test with lock tables
mysql-test/r/rpl_replicate_do.result:
  Update results
mysql-test/r/rpl_rotate_logs.result:
  Make test independent of if t1 exists
mysql-test/t/multi_update.test:
  Added test with lock tables
mysql-test/t/rpl_rotate_logs.test:
  Make test independent of if t1 exists
mysys/my_alloc.c:
  Small imprevement to alloc_root
  (Don't free blocks less than ALLOC_MAX_BLOCK_ROOT (4K)
sql/ha_innodb.cc:
  More debug messages
sql/ha_myisam.cc:
  Safety change
sql/lex.h:
  Add support for LIMIT # OFFSET #
sql/lock.cc:
  Added assertion
sql/mysql_priv.h:
  Change of lock handling
sql/mysqld.cc:
  Added function clear_error_messages()
sql/sql_base.cc:
  Change lock handling by open_ltable() and open_and_lock_tables()
sql/sql_class.cc:
  Split THD::THD to two functions
  Move some code from cleanup() to ~THD:THD
  Add THD::change_user()
sql/sql_class.h:
  Prototype changes in class THD
sql/sql_delete.cc:
  Remove locking argument from mysql_delete()
  Locking type is now stored in TABLE_LIST
  Small code change to not call query_cache_invalidate() twice for transactional tables.
sql/sql_insert.cc:
  Remove locking argument from mysql_insert()
  Locking type is now stored in TABLE_LIST
  Small code change to not call query_cache_invalidate() twice for transactional tables.
  Don't use bulk insert if bulk_insert_buff_size is 0
sql/sql_parse.cc:
  Changes to make mysql_change_user() work as close+connect
  Changed command statistics to use statstics_increment to get more speed
  Update code to handle that locks is now stored in TABLE_LIST
sql/sql_update.cc:
  Remove locking argument from mysql_update()
  Locking type is now stored in TABLE_LIST
  Small code change to not call query_cache_invalidate() twice for transactional tables.
sql/sql_yacc.yy:
  Locking type is now stored in TABLE_LIST
  Added support for LIMIT # OFFSET # syntax
  Removed some wrong (never true) checks for SQLCOM_MULTI_UPDATE
mysql-test/t/rpl_replicate_do-slave.opt:
  Changed tables to use t1,t2,...
mysql-test/t/rpl_replicate_do.test:
  Changed tables to use t1,t2,...
This commit is contained in:
unknown
2002-11-16 20:19:10 +02:00
parent ffd1d3df2a
commit bd1c2d65c4
29 changed files with 525 additions and 264 deletions

View File

@ -1403,6 +1403,61 @@ int open_tables(THD *thd,TABLE_LIST *start)
}
/*
Check that lock is ok for tables; Call start stmt if ok
SYNOPSIS
check_lock_and_start_stmt()
thd Thread handle
table_list Table to check
lock_type Lock used for table
RETURN VALUES
0 ok
1 error
*/
static bool check_lock_and_start_stmt(THD *thd, TABLE *table,
thr_lock_type lock_type)
{
int error;
DBUG_ENTER("check_lock_and_start_stmt");
if ((int) lock_type >= (int) TL_WRITE_ALLOW_READ &&
(int) table->reginfo.lock_type < (int) TL_WRITE_ALLOW_READ)
{
my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
ER(ER_TABLE_NOT_LOCKED_FOR_WRITE),
MYF(0),table->table_name);
DBUG_RETURN(1);
}
if ((error=table->file->start_stmt(thd)))
{
table->file->print_error(error,MYF(0));
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
/*
Open and lock one table
SYNOPSIS
open_ltable()
thd Thread handler
table_list Table to open is first table in this list
lock_type Lock to use for open
RETURN VALUES
table Opened table
0 Error
If ok, the following are also set:
table_list->lock_type lock_type
table_list->table table
*/
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
{
TABLE *table;
@ -1415,8 +1470,6 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
&refresh)) && refresh) ;
if (table)
{
int error;
#if defined( __WIN__) || defined(OS2)
/* Win32 can't drop a file that is open */
if (lock_type == TL_WRITE_ALLOW_READ)
@ -1424,39 +1477,29 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
lock_type= TL_WRITE;
}
#endif /* __WIN__ || OS2 */
table_list->table=table;
table_list->lock_type= lock_type;
table_list->table= table;
table->grant= table_list->grant;
if (thd->locked_tables)
{
thd->proc_info=0;
if ((int) lock_type >= (int) TL_WRITE_ALLOW_READ &&
(int) table->reginfo.lock_type < (int) TL_WRITE_ALLOW_READ)
{
my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
ER(ER_TABLE_NOT_LOCKED_FOR_WRITE),
MYF(0),table_list->alias);
table=0;
}
else if ((error=table->file->start_stmt(thd)))
{
table->file->print_error(error,MYF(0));
table=0;
}
thd->proc_info=0;
DBUG_RETURN(table);
if (check_lock_and_start_stmt(thd, table, lock_type))
table= 0;
}
else
{
if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK)
if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1)))
table= 0;
}
if ((table->reginfo.lock_type=lock_type) != TL_UNLOCK)
if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1)))
DBUG_RETURN(0);
}
thd->proc_info=0;
DBUG_RETURN(table);
}
/*
** Open all tables in list and locks them for read.
** The lock will automaticly be freed by the close_thread_tables
Open all tables in list and locks them for read.
The lock will automaticly be freed by close_thread_tables()
*/
int open_and_lock_tables(THD *thd,TABLE_LIST *tables)
@ -1466,10 +1509,27 @@ int open_and_lock_tables(THD *thd,TABLE_LIST *tables)
return 0;
}
/*
Lock all tables in list
SYNOPSIS
lock_tables()
thd Thread handler
tables Tables to lock
RETURN VALUES
0 ok
-1 Error
*/
int lock_tables(THD *thd,TABLE_LIST *tables)
{
TABLE_LIST *table;
if (tables && !thd->locked_tables)
if (!tables)
return 0;
if (!thd->locked_tables)
{
uint count=0;
for (table = tables ; table ; table=table->next)
@ -1486,10 +1546,9 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
{
for (table = tables ; table ; table=table->next)
{
int error;
if ((error=table->table->file->start_stmt(thd)))
if (check_lock_and_start_stmt(thd, table->table, table->lock_type))
{
table->table->file->print_error(error,MYF(0));
ha_rollback_stmt(thd);
return -1;
}
}
@ -1497,10 +1556,11 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
return 0;
}
/*
** Open a single table without table caching and don't set it in open_list
** Used by alter_table to open a temporary table and when creating
** a temporary table with CREATE TEMPORARY ...
Open a single table without table caching and don't set it in open_list
Used by alter_table to open a temporary table and when creating
a temporary table with CREATE TEMPORARY ...
*/
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,