Commit 3ddc1f99 authored by monty@mysql.com's avatar monty@mysql.com

Merge mysql.com:/home/my/mysql-5.0

into  mysql.com:/home/my/mysql-5.1
parents 86b2be8d 1809adee
......@@ -364,6 +364,10 @@ SOURCE=..\sql-common\my_time.c
# End Source File
# Begin Source File
SOURCE=..\sql-common\my_user.c
# End Source File
# Begin Source File
SOURCE=..\sql\net_serv.cpp
# End Source File
# Begin Source File
......
......@@ -338,6 +338,10 @@ SOURCE="..\sql-common\my_time.c"
# End Source File
# Begin Source File
SOURCE="..\sql-common\my_user.c"
# End Source File
# Begin Source File
SOURCE=..\sql\net_serv.cpp
# End Source File
# Begin Source File
......
......@@ -84,7 +84,7 @@ TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint key_size,
void *tree_search(TREE *tree, void *key, void *custom_arg);
int tree_walk(TREE *tree,tree_walk_action action,
void *argument, TREE_WALK visit);
int tree_delete(TREE *tree, void *key, void *custom_arg);
int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg);
void *tree_search_key(TREE *tree, const void *key,
TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos,
enum ha_rkey_function flag, void *custom_arg);
......
......@@ -46,4 +46,12 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_
execute stmt1;
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
deallocate prepare stmt1;
create temporary table t1(a int, index(a));
insert into t1 values('1'),('2'),('3'),('4'),('5');
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A 5 NULL NULL YES BTREE
drop table t1;
......@@ -246,3 +246,13 @@ DELETE from t1 where a < 100;
SELECT * from t1;
a
DROP TABLE t1;
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
INSERT INTO t1 VALUES(0);
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
INDEX_LENGTH
21
UPDATE t1 SET val=1;
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
INDEX_LENGTH
21
DROP TABLE t1;
......@@ -3455,3 +3455,5 @@ SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
a
1
drop table t2, t1;
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
ERROR HY000: The used table type doesn't support SPATIAL indexes
......@@ -481,14 +481,22 @@ msg text NOT NULL
insert into t1 (msg) values(
'Tries to validate (8 byte length + inline bytes) as UTF8 :(
Fast fix: removed validation for Text. It is not yet indexable
so bad data will not crash kernel.
Proper fix: Set inline bytes to multiple of mbmaxlen and
validate it (after the 8 byte length).');
so bad data will not crash kernel.');
select * from t1;
id msg
1 Tries to validate (8 byte length + inline bytes) as UTF8 :(
Fast fix: removed validation for Text. It is not yet indexable
so bad data will not crash kernel.
Proper fix: Set inline bytes to multiple of mbmaxlen and
validate it (after the 8 byte length).
drop table t1;
create table t1 (
a int primary key not null auto_increment,
b text
) engine=ndbcluster;
select count(*) from t1;
count(*)
500
truncate t1;
select count(*) from t1;
count(*)
0
drop table t1;
drop table if exists t1,t3;
drop procedure if exists bug4902|
create procedure bug4902()
begin
......
......@@ -61,6 +61,14 @@ prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
#
# bug#15225 (ANALYZE temporary has no effect)
#
create temporary table t1(a int, index(a));
insert into t1 values('1'),('2'),('3'),('4'),('5');
analyze table t1;
show index from t1;
drop table t1;
# End of 4.1 tests
......@@ -164,4 +164,16 @@ DELETE from t1 where a < 100;
SELECT * from t1;
DROP TABLE t1;
#
# BUG#18160 - Memory-/HEAP Table endless growing indexes
#
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
INSERT INTO t1 VALUES(0);
--replace_result 37 21
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
UPDATE t1 SET val=1;
--replace_result 37 21
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
DROP TABLE t1;
# End of 4.1 tests
......@@ -2494,3 +2494,9 @@ SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
drop table t2, t1;
#
# Bug #15680 (SPATIAL key in innodb)
#
--error ER_TABLE_CANT_HANDLE_SPKEYS
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
......@@ -403,10 +403,29 @@ create table t1 (
insert into t1 (msg) values(
'Tries to validate (8 byte length + inline bytes) as UTF8 :(
Fast fix: removed validation for Text. It is not yet indexable
so bad data will not crash kernel.
Proper fix: Set inline bytes to multiple of mbmaxlen and
validate it (after the 8 byte length).');
so bad data will not crash kernel.');
select * from t1;
drop table t1;
# -- bug #19201
create table t1 (
a int primary key not null auto_increment,
b text
) engine=ndbcluster;
--disable_query_log
set autocommit=1;
# more rows than batch size (64)
# for this bug no blob parts would be necessary
let $1 = 500;
while ($1)
{
insert into t1 (b) values (repeat('x',4000));
dec $1;
}
--enable_query_log
select count(*) from t1;
truncate t1;
select count(*) from t1;
drop table t1;
# End of 4.1 tests
# Can't test with embedded server
-- source include/not_embedded.inc
--sleep 2
--disable_warnings
drop table if exists t1,t3;
--enable_warnings
delimiter |;
#
......
......@@ -271,7 +271,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
return element;
}
int tree_delete(TREE *tree, void *key, void *custom_arg)
int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg)
{
int cmp,remove_colour;
TREE_ELEMENT *element,***parent, ***org_parent, *nod;
......@@ -326,8 +326,7 @@ int tree_delete(TREE *tree, void *key, void *custom_arg)
rb_delete_fixup(tree,parent);
if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
/* This doesn't include key_size, but better than nothing */
tree->allocated-= sizeof(TREE_ELEMENT)+tree->size_of_element;
tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size;
my_free((gptr) element,MYF(0));
tree->elements_in_tree--;
return 0;
......
......@@ -194,7 +194,7 @@ ha_myisam::ha_myisam(TABLE_SHARE *table_arg)
int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME |
HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD),
HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS),
can_enable_indexes(1)
{}
......
......@@ -84,6 +84,7 @@
access on the table based on a given record.
*/
#define HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS (1 << 16)
#define HA_CAN_RTREEKEYS (1 << 17)
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
#define HA_CAN_FULLTEXT (1 << 21)
......
......@@ -2978,52 +2978,52 @@ ER_UDF_EXISTS
swe "Funktionen '%-.64s' finns redan"
ukr "æ '%-.64s' դ"
ER_CANT_OPEN_LIBRARY
cze "Nemohu otev-Bt sdlenou knihovnu '%-.64s' (errno: %d %s)"
dan "Kan ikke bne delt bibliotek '%-.64s' (errno: %d %s)"
nla "Kan shared library '%-.64s' niet openen (Errcode: %d %s)"
eng "Can't open shared library '%-.64s' (errno: %d %s)"
jps "shared library '%-.64s' Jł܂ (errno: %d %s)",
est "Ei suuda avada jagatud teeki '%-.64s' (veakood: %d %s)"
fre "Impossible d'ouvrir la bibliothque partage '%-.64s' (errno: %d %s)"
ger "Kann Shared Library '%-.64s' nicht ffnen (Fehler: %d %s)"
greek " shared library '%-.64s' ( : %d %s)"
hun "A(z) '%-.64s' megosztott konyvtar nem hasznalhato (hibakod: %d %s)"
ita "Impossibile aprire la libreria condivisa '%-.64s' (errno: %d %s)"
jpn "shared library '%-.64s' 򳫤Ǥޤ (errno: %d %s)"
kor "'%-.64s' ̹ ϴ.(ȣ: %d %s)"
nor "Can't open shared library '%-.64s' (errno: %d %s)"
norwegian-ny "Can't open shared library '%-.64s' (errno: %d %s)"
pol "Can't open shared library '%-.64s' (errno: %d %s)"
por "No pode abrir biblioteca compartilhada '%-.64s' (erro no. '%d' - '%-.64s')"
rum "Nu pot deschide libraria shared '%-.64s' (Eroare: %d %s)"
rus " '%-.64s' (: %d %s)"
serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.64s' (errno: %d %s)"
slo "Nemem otvori zdiean kninicu '%-.64s' (chybov kd: %d %s)"
spa "No puedo abrir libraria conjugada '%-.64s' (errno: %d %s)"
swe "Kan inte ppna det dynamiska biblioteket '%-.64s' (Felkod: %d %s)"
ukr " צ Ħ ¦̦ '%-.64s' (: %d %s)"
cze "Nemohu otev-Bt sdlenou knihovnu '%-.64s' (errno: %d %-.128s)"
dan "Kan ikke bne delt bibliotek '%-.64s' (errno: %d %-.128s)"
nla "Kan shared library '%-.64s' niet openen (Errcode: %d %-.128s)"
eng "Can't open shared library '%-.64s' (errno: %d %-.128s)"
jps "shared library '%-.64s' Jł܂ (errno: %d %-.128s)",
est "Ei suuda avada jagatud teeki '%-.64s' (veakood: %d %-.128s)"
fre "Impossible d'ouvrir la bibliothque partage '%-.64s' (errno: %d %-.128s)"
ger "Kann Shared Library '%-.64s' nicht ffnen (Fehler: %d %-.128s)"
greek " shared library '%-.64s' ( : %d %-.128s)"
hun "A(z) '%-.64s' megosztott konyvtar nem hasznalhato (hibakod: %d %-.128s)"
ita "Impossibile aprire la libreria condivisa '%-.64s' (errno: %d %-.128s)"
jpn "shared library '%-.64s' 򳫤Ǥޤ (errno: %d %-.128s)"
kor "'%-.64s' ̹ ϴ.(ȣ: %d %-.128s)"
nor "Can't open shared library '%-.64s' (errno: %d %-.128s)"
norwegian-ny "Can't open shared library '%-.64s' (errno: %d %-.128s)"
pol "Can't open shared library '%-.64s' (errno: %d %-.128s)"
por "No pode abrir biblioteca compartilhada '%-.64s' (erro no. %d '%-.128s')"
rum "Nu pot deschide libraria shared '%-.64s' (Eroare: %d %-.128s)"
rus " '%-.64s' (: %d %-.128s)"
serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.64s' (errno: %d %-.128s)"
slo "Nemem otvori zdiean kninicu '%-.64s' (chybov kd: %d %-.128s)"
spa "No puedo abrir libraria conjugada '%-.64s' (errno: %d %-.128s)"
swe "Kan inte ppna det dynamiska biblioteket '%-.64s' (Felkod: %d %-.128s)"
ukr " צ Ħ ¦̦ '%-.64s' (: %d %-.128s)"
ER_CANT_FIND_DL_ENTRY
cze "Nemohu naj-Bt funkci '%-.64s' v knihovn"
dan "Kan ikke finde funktionen '%-.64s' i bibliotek"
nla "Kan functie '%-.64s' niet in library vinden"
eng "Can't find symbol '%-.64s' in library"
jps "function '%-.64s' Cu[Ɍt鎖ł܂",
est "Ei leia funktsiooni '%-.64s' antud teegis"
fre "Impossible de trouver la fonction '%-.64s' dans la bibliothque"
ger "Kann Funktion '%-.64s' in der Library nicht finden"
greek " '%-.64s' "
hun "A(z) '%-.64s' fuggveny nem talalhato a konyvtarban"
ita "Impossibile trovare la funzione '%-.64s' nella libreria"
jpn "function '%-.64s' 饤֥꡼˸դǤޤ"
kor "̹ '%-.64s' Լ ã ϴ."
por "No pode encontrar a funo '%-.64s' na biblioteca"
rum "Nu pot gasi functia '%-.64s' in libraria"
rus " '%-.64s' "
serbian "Ne mogu da pronadjem funkciju '%-.64s' u biblioteci"
slo "Nemem njs funkciu '%-.64s' v kninici"
spa "No puedo encontrar funcin '%-.64s' en libraria"
swe "Hittar inte funktionen '%-.64s' in det dynamiska biblioteket"
ukr " æ '%-.64s' ¦̦æ"
cze "Nemohu naj-Bt funkci '%-.128s' v knihovn"
dan "Kan ikke finde funktionen '%-.128s' i bibliotek"
nla "Kan functie '%-.128s' niet in library vinden"
eng "Can't find symbol '%-.128s' in library"
jps "function '%-.128s' Cu[Ɍt鎖ł܂",
est "Ei leia funktsiooni '%-.128s' antud teegis"
fre "Impossible de trouver la fonction '%-.128s' dans la bibliothque"
ger "Kann Funktion '%-.128s' in der Library nicht finden"
greek " '%-.128s' "
hun "A(z) '%-.128s' fuggveny nem talalhato a konyvtarban"
ita "Impossibile trovare la funzione '%-.128s' nella libreria"
jpn "function '%-.128s' 饤֥꡼˸դǤޤ"
kor "̹ '%-.128s' Լ ã ϴ."
por "No pode encontrar a funo '%-.128s' na biblioteca"
rum "Nu pot gasi functia '%-.128s' in libraria"
rus " '%-.128s' "
serbian "Ne mogu da pronadjem funkciju '%-.128s' u biblioteci"
slo "Nemem njs funkciu '%-.128s' v kninici"
spa "No puedo encontrar funcin '%-.128s' en libraria"
swe "Hittar inte funktionen '%-.128s' in det dynamiska biblioteket"
ukr " æ '%-.128s' ¦̦æ"
ER_FUNCTION_NOT_DEFINED
cze "Funkce '%-.64s' nen-B definovna"
dan "Funktionen '%-.64s' er ikke defineret"
......@@ -4898,7 +4898,10 @@ ER_WARN_NULL_TO_NOTNULL 22004
por "Dado truncado, NULL fornecido para NOT NULL coluna '%s' na linha %ld"
spa "Datos truncado, NULL suministrado para NOT NULL columna '%s' en la lnea %ld"
ER_WARN_DATA_OUT_OF_RANGE 22003
eng "Out of range value for column '%s' at row %ld"
eng "Out of range value adjusted for column '%s' at row %ld"
ger "Daten abgeschnitten, auerhalb des Wertebereichs fr Feld '%s' in Zeile %ld"
por "Dado truncado, fora de alcance para coluna '%s' na linha %ld"
spa "Datos truncados, fuera de gama para columna '%s' en la lnea %ld"
WARN_DATA_TRUNCATED 01000
eng "Data truncated for column '%s' at row %ld"
ger "Daten abgeschnitten fr Feld '%s' in Zeile %ld"
......@@ -5602,6 +5605,25 @@ ER_SP_RECURSION_LIMIT
ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde fr Routine %.64s berschritten"
ER_SP_PROC_TABLE_CORRUPT
eng "Failed to load routine %-.64s. The table mysql.proc is missing, corrupt, or contains bad data (internal code %d)"
ER_SP_WRONG_NAME 42000
eng "Incorrect routine name '%-.64s'"
ER_TABLE_NEEDS_UPGRADE
eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!"
ER_SP_NO_AGGREGATE 42000
eng "AGGREGATE is not supported for stored functions"
ER_MAX_PREPARED_STMT_COUNT_REACHED 42000
eng "Can't create more than max_prepared_stmt_count statements (current value: %lu)"
ER_VIEW_RECURSIVE
eng "`%-.64s`.`%-.64s` contains view recursion"
ER_NON_GROUPING_FIELD_USED 42000
eng "non-grouping field '%-.64s' is used in %-.64s clause"
ER_TABLE_CANT_HANDLE_SPKEYS
eng "The used table type doesn't support SPATIAL indexes"
ER_WARN_DEPRECATED_SYNTAX
eng "The syntax '%s' is deprecated and will be removed in MySQL %s. Please use %s instead."
ger "'%s' ist veraltet. Bitte benutzen Sie '%s'"
por "'%s' desatualizado. Use '%s' em seu lugar"
spa "'%s' est desaprobado, use '%s' en su lugar"
ER_PARTITION_REQUIRES_VALUES_ERROR
eng "%-.64s PARTITIONING requires definition of VALUES %-.64s for each partition"
swe "%-.64s PARTITIONering krver definition av VALUES %-.64s fr varje partition"
......@@ -5802,28 +5824,10 @@ ER_CANT_WRITE_LOCK_LOG_TABLE
eng "You can't write-lock a log table. Only read access is possible."
ER_CANT_READ_LOCK_LOG_TABLE
eng "You can't use usual read lock with log tables. Try READ LOCAL instead."
ER_SP_WRONG_NAME 42000
eng "Incorrect routine name '%-.64s'"
ER_FOREIGN_DUPLICATE_KEY 23000 S1009
eng "Upholding foreign key constraints for table '%.64s', entry '%-.64s', key %d would lead to a duplicate entry"
ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE
eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created with MySQL %d, now running %d. Please use scripts/mysql_fix_privilege_tables"
ER_TABLE_NEEDS_UPGRADE
eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!"
ER_ILLEGAL_HA_CREATE_OPTION
eng "Table storage engine '%-.64s' does not support the create option '%.64s'"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
ER_WARN_DEPRECATED
eng "The syntax '%s' is deprecated and will be removed in MySQL %s. Please use %s instead."
ER_SP_NO_AGGREGATE 42000
eng "AGGREGATE is not supported for stored functions"
ER_MAX_PREPARED_STMT_COUNT_REACHED 42000
eng "Can't create more than max_prepared_stmt_count statements (current value: %lu)"
ER_VIEW_RECURSIVE
eng "`%-.64s`.`%-.64s` contains view recursion"
ER_NON_GROUPING_FIELD_USED 42000
eng "non-grouping field '%-.64s' is used in %-.64s clause"
ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
eng "Cannot switch out of the row-based binary log format when the session has open temporary tables"
ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT
......@@ -5840,3 +5844,7 @@ ER_NULL_IN_VALUES_LESS_THAN
ER_WRONG_PARTITION_NAME
eng "Incorrect partition name"
swe "Felaktigt partitionsnamn"
ER_ILLEGAL_HA_CREATE_OPTION
eng "Table storage engine '%-.64s' does not support the create option '%.64s'"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
......@@ -268,7 +268,6 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table)
static int
db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
{
extern int MYSQLparse(void *thd);
TABLE *table;
const char *params, *returns, *body;
int ret;
......@@ -477,6 +476,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
(*sphp)->optimize();
}
end:
lex_end(thd->lex);
thd->spcont= old_spcont;
thd->variables.sql_mode= old_sql_mode;
thd->variables.select_limit= old_select_limit;
......
......@@ -680,6 +680,7 @@ sp_head::destroy()
DBUG_ASSERT(m_lex.is_empty() || m_thd);
while ((lex= (LEX *)m_lex.pop()))
{
lex_end(m_thd->lex);
delete m_thd->lex;
m_thd->lex= lex;
}
......@@ -1682,7 +1683,10 @@ sp_head::restore_lex(THD *thd)
*/
merge_table_list(thd, sublex->query_tables, sublex);
if (! sublex->sp_lex_in_use)
{
lex_end(sublex);
delete sublex;
}
thd->lex= oldlex;
DBUG_VOID_RETURN;
}
......
......@@ -521,8 +521,11 @@ public:
virtual ~sp_lex_keeper()
{
if (m_lex_resp)
{
lex_end(m_lex);
delete m_lex;
}
}
/*
Prepare execution of instruction using LEX, if requested check whenever
......
......@@ -2563,6 +2563,12 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
/* TODO: Add proper checks if handler supports key_type and algorithm */
if (key_info->flags & HA_SPATIAL)
{
if (!(file->table_flags() & HA_CAN_RTREEKEYS))
{
my_message(ER_TABLE_CANT_HANDLE_SPKEYS, ER(ER_TABLE_CANT_HANDLE_SPKEYS),
MYF(0));
DBUG_RETURN(-1);
}
if (key_info->key_parts != 1)
{
my_error(ER_WRONG_ARGUMENTS, MYF(0), "SPATIAL INDEX");
......@@ -3572,7 +3578,9 @@ mysql_rename_table(handlerton *base,
}
}
delete file;
if (error)
if (error == HA_ERR_WRONG_COMMAND)
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "ALTER TABLE");
else if (error)
my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error);
DBUG_RETURN(error != 0);
}
......@@ -4216,12 +4224,17 @@ send_result_message:
if (fatal_error)
table->table->s->version=0; // Force close of table
else if (open_for_modify && !table->table->s->log_table)
{
if (table->table->s->tmp_table)
table->table->file->info(HA_STATUS_CONST);
else
{
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(thd, table->table->s->db.str,
table->table->s->table_name.str, RTFC_NO_FLAG);
pthread_mutex_unlock(&LOCK_open);
/* Something may be modified, that's why we have to invalidate cache */
}
/* May be something modified consequently we have to invalidate cache */
query_cache_invalidate3(thd, table->table, 0);
}
}
......
......@@ -79,7 +79,8 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo,
custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
custom_arg.search_flag= SEARCH_SAME;
old_allocated= keyinfo->rb_tree.allocated;
res= tree_delete(&keyinfo->rb_tree, info->recbuf, &custom_arg);
res= tree_delete(&keyinfo->rb_tree, info->recbuf, custom_arg.key_length,
&custom_arg);
info->s->index_length-= (old_allocated - keyinfo->rb_tree.allocated);
return res;
}
......
......@@ -127,7 +127,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
}
if (keyseg->flag & HA_VAR_LENGTH_PART)
{
uint pack_length= keyseg->bit_start;
uint pack_length= (keyseg->bit_start == 1 ? 1 : 2);
uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos :
uint2korr(pos));
pos+= pack_length; /* Skip VARCHAR length */
......
......@@ -475,7 +475,7 @@ static int examine_log(my_string file_name, char **table_names)
{
if (!curr_file_info->closed)
files_open--;
VOID(tree_delete(&tree, (gptr) curr_file_info, tree.custom_arg));
VOID(tree_delete(&tree, (gptr) curr_file_info, 0, tree.custom_arg));
}
break;
case MI_LOG_EXTRA:
......
......@@ -39,6 +39,7 @@ class TcKeyReq {
friend class NdbOperation;
friend class NdbIndexOperation;
friend class NdbScanOperation;
friend class NdbBlob;
friend class DbUtil;
/**
......
......@@ -326,6 +326,7 @@ private:
bool isWriteOp();
bool isDeleteOp();
bool isScanOp();
bool isTakeOverOp();
// computations
Uint32 getPartNumber(Uint64 pos);
Uint32 getPartCount();
......
......@@ -23,6 +23,7 @@
#include <NdbBlob.hpp>
#include "NdbBlobImpl.hpp"
#include <NdbScanOperation.hpp>
#include <signaldata/TcKeyReq.hpp>
#include <NdbEventOperationImpl.hpp>
/*
......@@ -392,6 +393,13 @@ NdbBlob::isScanOp()
theNdbOp->theOperationType == NdbOperation::OpenRangeScanRequest;
}
inline bool
NdbBlob::isTakeOverOp()
{
return
TcKeyReq::getTakeOverScanFlag(theNdbOp->theScanInfo);
}
// computations (inline)
inline Uint32
......@@ -1527,8 +1535,22 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch)
if (isUpdateOp() || isWriteOp() || isDeleteOp()) {
// add operation before this one to read head+inline
NdbOperation* tOp = theNdbCon->getNdbOperation(theTable, theNdbOp);
/*
* If main op is from take over scan lock, the added read is done
* as committed read:
*
* In normal transactional case, the row is locked by us and
* committed read returns same as normal read.
*
* In current TRUNCATE TABLE, the deleting trans is committed in
* batches and then restarted with new trans id. A normal read
* would hang on the scan delete lock and then fail.
*/
NdbOperation::LockMode lockMode =
! isTakeOverOp() ?
NdbOperation::LM_Read : NdbOperation::LM_CommittedRead;
if (tOp == NULL ||
tOp->readTuple() == -1 ||
tOp->readTuple(lockMode) == -1 ||
setTableKeyValue(tOp) == -1 ||
getHeadInlineValue(tOp) == -1) {
setErrorCode(tOp);
......
......@@ -44,6 +44,7 @@ struct Opt {
bool m_dbg;
bool m_dbgall;
const char* m_dbug;
bool m_fac;
bool m_full;
unsigned m_loop;
unsigned m_parts;
......@@ -72,6 +73,7 @@ struct Opt {
m_dbg(false),
m_dbgall(false),
m_dbug(0),
m_fac(false),
m_full(false),
m_loop(1),
m_parts(10),
......@@ -110,6 +112,7 @@ printusage()
<< " -dbg print debug" << endl
<< " -dbgall print also NDB API debug (if compiled in)" << endl
<< " -dbug opt dbug options" << endl
<< " -fac fetch across commit in scan delete [" << d.m_fac << "]" << endl
<< " -full read/write only full blob values" << endl
<< " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl
<< " -parts N max parts in blob value [" << d.m_parts << "]" << endl
......@@ -1255,23 +1258,11 @@ deleteScan(bool idx)
CHK((ret = g_ops->nextResult(false)) == 0 || ret == 1 || ret == 2);
if (++n == g_opt.m_batch || ret == 2) {
DBG("execute batch: n=" << n << " ret=" << ret);
switch (0) {
case 0: // works normally
if (! g_opt.m_fac) {
CHK(g_con->execute(NoCommit) == 0);
CHK(true || g_con->restart() == 0);
break;
case 1: // nonsense - g_con is invalid for 2nd batch
CHK(g_con->execute(Commit) == 0);
CHK(true || g_con->restart() == 0);
break;
case 2: // DBTC sendSignalErrorRefuseLab
CHK(g_con->execute(NoCommit) == 0);
CHK(g_con->restart() == 0);
break;
case 3: // 266 time-out
} else {
CHK(g_con->execute(Commit) == 0);
CHK(g_con->restart() == 0);
break;
}
n = 0;
}
......@@ -1817,6 +1808,10 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535)
continue;
}
}
if (strcmp(arg, "-fac") == 0) {
g_opt.m_fac = true;
continue;
}
if (strcmp(arg, "-full") == 0) {
g_opt.m_full = true;
continue;
......
......@@ -23,17 +23,21 @@
#include <NDBT.hpp>
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism=240);
bool fetch_across_commit, int parallelism=240);
NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB";
static my_bool _transactional = false;
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
(gptr*) &_dbname, (gptr*) &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "transactional", 't', "Single transaction (may run out of operations)",
(gptr*) &_transactional, (gptr*) &_transactional, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void usage()
......@@ -84,18 +88,11 @@ int main(int argc, char** argv){
ndbout << " Table " << argv[i] << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
// Check if we have any blobs
bool commit_across_open_cursor = true;
for (int j = 0; j < pTab->getNoOfColumns(); j++) {
NdbDictionary::Column::Type t = pTab->getColumn(j)->getType();
if (t == NdbDictionary::Column::Blob ||
t == NdbDictionary::Column::Text) {
commit_across_open_cursor = false;
break;
}
}
ndbout << "Deleting all from " << argv[i] << "...";
if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){
ndbout << "Deleting all from " << argv[i];
if (! _transactional)
ndbout << " (non-transactional)";
ndbout << " ...";
if(clear_table(&MyNdb, pTab, ! _transactional) == NDBT_FAILED){
res = NDBT_FAILED;
ndbout << "FAILED" << endl;
}
......@@ -105,7 +102,7 @@ int main(int argc, char** argv){
int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism)
bool fetch_across_commit, int parallelism)
{
// Scan all records exclusive and delete
// them one by one
......@@ -167,7 +164,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
} while((check = pOp->nextResult(false)) == 0);
if(check != -1){
if (commit_across_open_cursor) {
if (fetch_across_commit) {
check = pTrans->execute(NdbTransaction::Commit);
pTrans->restart(); // new tx id
} else {
......@@ -198,7 +195,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
}
goto failed;
}
if (! commit_across_open_cursor &&
if (! fetch_across_commit &&
pTrans->execute(NdbTransaction::Commit) != 0) {
err = pTrans->getNdbError();
goto failed;
......
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