Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/Users/kent/mysql/bk/mysql-4.1
This commit is contained in:
kent@mysql.com 2006-02-10 19:18:45 +01:00
commit d23d02be18
34 changed files with 674 additions and 104 deletions

View file

@ -2966,8 +2966,8 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
warn_res= mysql_store_result(mysql);
}
if (!warn_res)
verbose_msg("Warning count is %u but didn't get any warnings\n",
count);
die("Warning count is %u but didn't get any warnings\n",
count);
else
{
dynstr_append_mem(ds, "Warnings:\n", 10);
@ -3446,8 +3446,8 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds)
{
MYSQL_RES *warn_res= mysql_store_result(mysql);
if (!warn_res)
verbose_msg("Warning count is %u but didn't get any warnings\n",
count);
die("Warning count is %u but didn't get any warnings\n",
count);
else
{
dynstr_append_mem(ds, "Warnings:\n", 10);

View file

@ -191,7 +191,7 @@ static
void
btr_search_info_update_hash(
/*========================*/
btr_search_t* info, /* in: search info */
btr_search_t* info, /* in/out: search info */
btr_cur_t* cursor) /* in: cursor which was just positioned */
{
dict_index_t* index;
@ -443,7 +443,7 @@ Updates the search info. */
void
btr_search_info_update_slow(
/*========================*/
btr_search_t* info, /* in: search info */
btr_search_t* info, /* in/out: search info */
btr_cur_t* cursor) /* in: cursor which was just positioned */
{
buf_block_t* block;
@ -931,7 +931,7 @@ btr_search_drop_page_hash_index(
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
retry:
rw_lock_s_lock(&btr_search_latch);
block = buf_block_align(page);
@ -1007,6 +1007,24 @@ next_rec:
rw_lock_x_lock(&btr_search_latch);
if (!block->is_hashed) {
/* Someone else has meanwhile dropped the hash index */
goto cleanup;
}
if (block->curr_n_fields != n_fields
|| block->curr_n_bytes != n_bytes) {
/* Someone else has meanwhile built a new hash index on the
page, with different parameters */
rw_lock_x_unlock(&btr_search_latch);
mem_free(folds);
goto retry;
}
for (i = 0; i < n_cached; i++) {
ha_remove_all_nodes_to_page(table, folds[i], page);
@ -1014,7 +1032,22 @@ next_rec:
block->is_hashed = FALSE;
rw_lock_x_unlock(&btr_search_latch);
cleanup:
if (block->n_pointers) {
/* Corruption */
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Corruption of adaptive hash index. After dropping\n"
"InnoDB: the hash index to a page of %lu %lu, still %lu hash nodes remain.\n",
(ulong) ut_dulint_get_high(tree_id),
(ulong) ut_dulint_get_low(tree_id),
(ulong) block->n_pointers);
rw_lock_x_unlock(&btr_search_latch);
btr_search_validate();
} else {
rw_lock_x_unlock(&btr_search_latch);
}
mem_free(folds);
}

View file

@ -2755,7 +2755,8 @@ dict_table_get_highest_foreign_id(
if (ut_strlen(foreign->id) > ((sizeof dict_ibfk) - 1) + len
&& 0 == ut_memcmp(foreign->id, table->name, len)
&& 0 == ut_memcmp(foreign->id + len,
dict_ibfk, (sizeof dict_ibfk) - 1)) {
dict_ibfk, (sizeof dict_ibfk) - 1)
&& foreign->id[len + ((sizeof dict_ibfk) - 1)] != '0') {
/* It is of the >= 4.0.18 format */
id = strtoul(foreign->id + len + ((sizeof dict_ibfk) - 1),

View file

@ -179,6 +179,11 @@ struct fil_space_struct {
hash_node_t name_hash;/* hash chain the name_hash table */
rw_lock_t latch; /* latch protecting the file space storage
allocation */
UT_LIST_NODE_T(fil_space_t) unflushed_spaces;
/* list of spaces with at least one unflushed
file we have written to */
ibool is_in_unflushed_spaces; /* TRUE if this space is
currently in the list above */
UT_LIST_NODE_T(fil_space_t) space_list;
/* list of all spaces */
ibuf_data_t* ibuf_data;
@ -211,6 +216,12 @@ struct fil_system_struct {
not put to this list: they are opened
after the startup, and kept open until
shutdown */
UT_LIST_BASE_NODE_T(fil_space_t) unflushed_spaces;
/* base node for the list of those
tablespaces whose files contain
unflushed writes; those spaces have
at least one file node where
modification_counter > flush_counter */
ulint n_open; /* number of files currently open */
ulint max_n_open; /* n_open is not allowed to exceed
this */
@ -387,6 +398,36 @@ fil_space_get_ibuf_data(
return(space->ibuf_data);
}
/**************************************************************************
Checks if all the file nodes in a space are flushed. The caller must hold
the fil_system mutex. */
static
ibool
fil_space_is_flushed(
/*=================*/
/* out: TRUE if all are flushed */
fil_space_t* space) /* in: space */
{
fil_node_t* node;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(fil_system->mutex)));
#endif /* UNIV_SYNC_DEBUG */
node = UT_LIST_GET_FIRST(space->chain);
while (node) {
if (node->modification_counter > node->flush_counter) {
return(FALSE);
}
node = UT_LIST_GET_NEXT(chain, node);
}
return(TRUE);
}
/***********************************************************************
Appends a new file to the chain of files of a space. File must be closed. */
@ -517,7 +558,7 @@ fil_node_open_file(
if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
fprintf(stderr,
"InnoDB: Error: the size of single-table tablespace file %s\n"
"InnoDB: is only %lu %lu, should be at least %lu!", node->name,
"InnoDB: is only %lu %lu, should be at least %lu!\n", node->name,
(ulong) size_high,
(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
@ -687,8 +728,8 @@ fil_try_to_close_file_in_LRU(
ut_print_filename(stderr, node->name);
fprintf(stderr,
", because mod_count %ld != fl_count %ld\n",
(ulong) node->modification_counter,
(ulong) node->flush_counter);
(long) node->modification_counter,
(long) node->flush_counter);
}
node = UT_LIST_GET_PREV(LRU, node);
@ -839,6 +880,16 @@ fil_node_free(
node->modification_counter = node->flush_counter;
if (space->is_in_unflushed_spaces
&& fil_space_is_flushed(space)) {
space->is_in_unflushed_spaces = FALSE;
UT_LIST_REMOVE(unflushed_spaces,
system->unflushed_spaces,
space);
}
fil_node_close_file(node, system);
}
@ -1002,6 +1053,8 @@ try_again:
HASH_INSERT(fil_space_t, name_hash, system->name_hash,
ut_fold_string(name), space);
space->is_in_unflushed_spaces = FALSE;
UT_LIST_ADD_LAST(space_list, system->space_list, space);
mutex_exit(&(system->mutex));
@ -1097,6 +1150,13 @@ fil_space_free(
HASH_DELETE(fil_space_t, name_hash, system->name_hash,
ut_fold_string(space->name), space);
if (space->is_in_unflushed_spaces) {
space->is_in_unflushed_spaces = FALSE;
UT_LIST_REMOVE(unflushed_spaces, system->unflushed_spaces,
space);
}
UT_LIST_REMOVE(space_list, system->space_list, space);
ut_a(space->magic_n == FIL_SPACE_MAGIC_N);
@ -1248,6 +1308,7 @@ fil_system_create(
system->tablespace_version = 0;
UT_LIST_INIT(system->unflushed_spaces);
UT_LIST_INIT(system->space_list);
return(system);
@ -2612,12 +2673,12 @@ fil_open_single_table_tablespace(
fputs("!\n"
"InnoDB: Have you moved InnoDB .ibd files around without using the\n"
"InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n"
"InnoDB: It is also possible that this is a table created with\n"
"InnoDB: CREATE TEMPORARY TABLE, and MySQL removed the .ibd file for this.\n"
"InnoDB: It is also possible that this is a temporary table #sql...,\n"
"InnoDB: and MySQL removed the .ibd file for this.\n"
"InnoDB: Please refer to\n"
"InnoDB:"
" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n"
"InnoDB: how to resolve the issue.\n", stderr);
"InnoDB: for how to resolve the issue.\n", stderr);
mem_free(filepath);
@ -2657,7 +2718,7 @@ fil_open_single_table_tablespace(
"InnoDB: Please refer to\n"
"InnoDB:"
" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n"
"InnoDB: how to resolve the issue.\n", (ulong) space_id, (ulong) id);
"InnoDB: for how to resolve the issue.\n", (ulong) space_id, (ulong) id);
ret = FALSE;
@ -3292,7 +3353,7 @@ fil_space_for_table_exists_in_mem(
ut_print_filename(stderr, name);
fprintf(stderr, "\n"
"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n"
"InnoDB: but tablespace with that id does not exist. There is\n"
"InnoDB: but a tablespace with that id does not exist. There is\n"
"InnoDB: a tablespace of name %s and id %lu, though. Have\n"
"InnoDB: you deleted or moved .ibd files?\n",
(ulong) id, namespace->name,
@ -3303,7 +3364,7 @@ fil_space_for_table_exists_in_mem(
"InnoDB: Please refer to\n"
"InnoDB:"
" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n"
"InnoDB: how to resolve the issue.\n", stderr);
"InnoDB: for how to resolve the issue.\n", stderr);
mem_free(path);
mutex_exit(&(system->mutex));
@ -3317,7 +3378,7 @@ fil_space_for_table_exists_in_mem(
ut_print_filename(stderr, name);
fprintf(stderr, "\n"
"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n"
"InnoDB: but tablespace with that id has name %s.\n"
"InnoDB: but the tablespace with that id has name %s.\n"
"InnoDB: Have you deleted or moved .ibd files?\n", (ulong) id, space->name);
if (namespace != NULL) {
@ -3732,6 +3793,14 @@ fil_node_complete_io(
if (type == OS_FILE_WRITE) {
system->modification_counter++;
node->modification_counter = system->modification_counter;
if (!node->space->is_in_unflushed_spaces) {
node->space->is_in_unflushed_spaces = TRUE;
UT_LIST_ADD_FIRST(unflushed_spaces,
system->unflushed_spaces,
node->space);
}
}
if (node->n_pending == 0 && node->space->purpose == FIL_TABLESPACE
@ -4145,6 +4214,16 @@ retry:
skip_flush:
if (node->flush_counter < old_mod_counter) {
node->flush_counter = old_mod_counter;
if (space->is_in_unflushed_spaces
&& fil_space_is_flushed(space)) {
space->is_in_unflushed_spaces = FALSE;
UT_LIST_REMOVE(unflushed_spaces,
system->unflushed_spaces,
space);
}
}
if (space->purpose == FIL_TABLESPACE) {
@ -4176,7 +4255,7 @@ fil_flush_file_spaces(
mutex_enter(&(system->mutex));
space = UT_LIST_GET_FIRST(system->space_list);
space = UT_LIST_GET_FIRST(system->unflushed_spaces);
while (space) {
if (space->purpose == purpose && !space->is_being_deleted) {
@ -4192,7 +4271,7 @@ fil_flush_file_spaces(
space->n_pending_flushes--;
}
space = UT_LIST_GET_NEXT(space_list, space);
space = UT_LIST_GET_NEXT(unflushed_spaces, space);
}
mutex_exit(&(system->mutex));

View file

@ -16,7 +16,7 @@ Updates the search info. */
void
btr_search_info_update_slow(
/*========================*/
btr_search_t* info, /* in: search info */
btr_search_t* info, /* in/out: search info */
btr_cur_t* cursor);/* in: cursor which was just positioned */
/************************************************************************

View file

@ -4628,6 +4628,12 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
/* If statement hasnt been prepared there is nothing to reset */
if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE)
DBUG_RETURN(0);
if (!stmt->mysql)
{
/* mysql can be reset in mysql_close called from mysql_reconnect */
set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
DBUG_RETURN(1);
}
mysql= stmt->mysql->last_used_con;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */

View file

@ -436,3 +436,14 @@ SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE);
a
testword''
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
a MATCH(a) AGAINST('test1 test')
test1 0.68526661396027
EXECUTE stmt;
a MATCH(a) AGAINST('test1 test')
test1 0.68526661396027
DEALLOCATE PREPARE stmt;
DROP TABLE t1;

View file

@ -297,11 +297,11 @@ insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1
drop table t1;
CREATE TABLE t1 (a int, key(a)) engine=heap;
insert delayed into t1 values (0);
insert into t1 values (0);
delete from t1;
select * from t1;
a
insert delayed into t1 values (0), (1);
insert into t1 values (0), (1);
select * from t1 where a = 0;
a
0

View file

@ -1794,3 +1794,16 @@ a hex(b)
7 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
update t1 set b = 'three' where a = 6;
drop table t1;
CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
CREATE TABLE t2(a INT) ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) default NULL,
KEY `t2_ibfk_0` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2,t1;

View file

@ -27,5 +27,5 @@ select ((@id := kill_id) - kill_id) from t3;
((@id := kill_id) - kill_id)
0
kill @id;
ERROR 08S01: Server shutdown in progress
Got one of the listed errors
drop table t1, t2, t3;

View file

@ -671,3 +671,58 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
select * from t1;
b
drop table t1;
create table t1 (a int) engine=ndb;
create table t2 (a int) engine=ndb;
insert into t1 values (1);
insert into t2 values (1);
delete t1.* from t1, t2 where t1.a = t2.a;
select * from t1;
a
select * from t2;
a
1
drop table t1;
drop table t2;
CREATE TABLE t1 (
i INT,
j INT,
x INT,
y INT,
z INT
) engine=ndb;
CREATE TABLE t2 (
i INT,
k INT,
x INT,
y INT,
z INT
) engine=ndb;
CREATE TABLE t3 (
j INT,
k INT,
x INT,
y INT,
z INT
) engine=ndb;
INSERT INTO t1 VALUES ( 1, 2,13,14,15);
INSERT INTO t2 VALUES ( 1, 3,23,24,25);
INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36);
UPDATE t1 AS a
INNER JOIN t2 AS b
ON a.i = b.i
INNER JOIN t3 AS c
ON a.j = c.j AND b.k = c.k
SET a.x = b.x,
a.y = b.y,
a.z = (
SELECT sum(z)
FROM t3
WHERE y = 34
)
WHERE b.x = 23;
select * from t1;
i j x y z
1 2 23 24 71
drop table t1;
drop table t2;
drop table t3;

View file

@ -428,6 +428,13 @@ delete from t1;
select * from t1;
a b
commit;
replace t1 set a=2, b='y';
select * from t1;
a b
2 y
delete from t1;
select * from t1;
a b
drop table t1;
set autocommit=0;
create table t1 (

View file

@ -0,0 +1,80 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
ERROR 23000: Can't write; duplicate key in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
word
Aarhus
Aarhus
Aaron
Aaron
Ababa
Ababa
aback
aback
abaft
abaft
abandon
abandon
abandoned
abandoned
abandoning
abandoning
abandonment
abandonment
abandons
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
Aberdeen
Abernathy
aberrant
aberration
DROP TABLE t1;

View file

@ -357,4 +357,16 @@ SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE);
SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE);
DROP TABLE t1;
#
# BUG#14496: Crash or strange results with prepared statement,
# MATCH and FULLTEXT
#
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
# End of 4.1 tests

View file

@ -238,10 +238,10 @@ drop table t1;
# Bug 12796: Record doesn't show when selecting through index
#
CREATE TABLE t1 (a int, key(a)) engine=heap;
insert delayed into t1 values (0);
insert into t1 values (0);
delete from t1;
select * from t1;
insert delayed into t1 values (0), (1);
insert into t1 values (0), (1);
select * from t1 where a = 0;
drop table t1;

View file

@ -1365,4 +1365,17 @@ insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
select a,hex(b) from t1 order by b;
update t1 set b = 'three' where a = 6;
drop table t1;
# Ensure that <tablename>_ibfk_0 is not mistreated as a
# generated foreign key identifier. (Bug #16387)
CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
CREATE TABLE t2(a INT) ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
SHOW CREATE TABLE t2;
DROP TABLE t2,t1;
# End of 4.1 tests

View file

@ -78,7 +78,7 @@ select ((@id := kill_id) - kill_id) from t3;
kill @id;
connection conn1;
-- error 1053
-- error 1053,2013
reap;
disconnect conn1;

View file

@ -614,4 +614,70 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
select * from t1;
drop table t1;
#
# Bug #17249 delete statement with join where clause fails
# when table do not have pk
#
create table t1 (a int) engine=ndb;
create table t2 (a int) engine=ndb;
insert into t1 values (1);
insert into t2 values (1);
delete t1.* from t1, t2 where t1.a = t2.a;
select * from t1;
select * from t2;
drop table t1;
drop table t2;
#
# Bug #17257 update fails for inner joins if tables
# do not have Primary Key
#
CREATE TABLE t1 (
i INT,
j INT,
x INT,
y INT,
z INT
) engine=ndb;
CREATE TABLE t2 (
i INT,
k INT,
x INT,
y INT,
z INT
) engine=ndb;
CREATE TABLE t3 (
j INT,
k INT,
x INT,
y INT,
z INT
) engine=ndb;
INSERT INTO t1 VALUES ( 1, 2,13,14,15);
INSERT INTO t2 VALUES ( 1, 3,23,24,25);
INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36);
UPDATE t1 AS a
INNER JOIN t2 AS b
ON a.i = b.i
INNER JOIN t3 AS c
ON a.j = c.j AND b.k = c.k
SET a.x = b.x,
a.y = b.y,
a.z = (
SELECT sum(z)
FROM t3
WHERE y = 34
)
WHERE b.x = 23;
select * from t1;
drop table t1;
drop table t2;
drop table t3;
# End of 4.1 tests

View file

@ -338,7 +338,7 @@ select * from t1 order by a;
drop table t1;
drop database test2;
# -- bug-5252 tinytext crashes plus no-commit result --
# -- bug-5252 tinytext crashes + no-commit result + replace --
set autocommit=0;
create table t1 (
@ -352,6 +352,10 @@ select * from t1;
delete from t1;
select * from t1;
commit;
replace t1 set a=2, b='y';
select * from t1;
delete from t1;
select * from t1;
drop table t1;
# -- bug-5013 insert empty string to text --

View file

@ -0,0 +1,24 @@
-- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Basic test for different types of loading data
#
# should give duplicate key
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
--error 1022
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
DROP TABLE t1;
# now without a primary key we should be ok
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
DROP TABLE t1;
# End of 4.1 tests

View file

@ -2397,7 +2397,19 @@ Dbdict::restartCreateTab_readTableConf(Signal* signal,
Uint32 sz = c_readTableRecord.noOfPages * ZSIZE_OF_PAGES_IN_WORDS;
SimplePropertiesLinearReader r(&pageRecPtr.p->word[0], sz);
handleTabInfoInit(r, &parseRecord);
ndbrequire(parseRecord.errorCode == 0);
if (parseRecord.errorCode != 0)
{
char buf[255];
BaseString::snprintf(buf, sizeof(buf),
"Unable to restart, fail while creating table %d"
" error: %d. Most likely change of configuration",
c_readTableRecord.tableId,
parseRecord.errorCode);
progError(__LINE__,
ERR_INVALID_CONFIG,
buf);
ndbrequire(parseRecord.errorCode == 0);
}
/* ---------------------------------------------------------------- */
// We have read the table description from disk as part of system restart.

View file

@ -774,7 +774,7 @@ private:
//------------------------------------
// Methods for LCP functionality
//------------------------------------
void checkKeepGci(Uint32 replicaStartIndex);
void checkKeepGci(TabRecordPtr, Uint32, Fragmentstore*, Uint32);
void checkLcpStart(Signal *, Uint32 lineNo);
void checkStartMoreLcp(Signal *, Uint32 nodeId);
bool reportLcpCompletion(const class LcpFragRep *);
@ -1292,7 +1292,7 @@ private:
}
Uint32 lcpStart;
Uint32 lcpStartGcp;
Uint32 lcpStopGcp;
Uint32 keepGci; /* USED TO CALCULATE THE GCI TO KEEP AFTER A LCP */
Uint32 oldestRestorableGci;
@ -1361,7 +1361,8 @@ private:
Uint32 cstarttype;
Uint32 csystemnodes;
Uint32 currentgcp;
Uint32 c_newest_restorable_gci;
enum GcpMasterTakeOverState {
GMTOS_IDLE = 0,
GMTOS_INITIAL = 1,

View file

@ -674,6 +674,7 @@ void Dbdih::execCOPY_GCIREQ(Signal* signal)
jam();
coldgcp = SYSFILE->newestRestorableGCI;
crestartGci = SYSFILE->newestRestorableGCI;
c_newest_restorable_gci = SYSFILE->newestRestorableGCI;
Sysfile::setRestartOngoing(SYSFILE->systemRestartBits);
currentgcp = coldgcp + 1;
cnewgcp = coldgcp + 1;
@ -692,6 +693,7 @@ void Dbdih::execCOPY_GCIREQ(Signal* signal)
ok = true;
jam();
cgcpParticipantState = GCP_PARTICIPANT_COPY_GCI_RECEIVED;
c_newest_restorable_gci = SYSFILE->newestRestorableGCI;
setNodeInfo(signal);
break;
}//if
@ -7749,6 +7751,8 @@ void Dbdih::execCOPY_GCICONF(Signal* signal)
signal->theData[1] = coldgcp;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
c_newest_restorable_gci = coldgcp;
CRASH_INSERTION(7004);
emptyWaitGCPMasterQueue(signal);
cgcpStatus = GCP_READY;
@ -9155,7 +9159,7 @@ void Dbdih::checkTcCounterLab(Signal* signal)
}//if
c_lcpState.ctimer += 32;
if ((c_nodeStartMaster.blockLcp == true) ||
((c_lcpState.lcpStartGcp + 1) > currentgcp)) {
(c_lcpState.lcpStopGcp >= c_newest_restorable_gci)) {
jam();
/* --------------------------------------------------------------------- */
// No reason to start juggling the states and checking for start of LCP if
@ -9238,7 +9242,6 @@ void Dbdih::execTCGETOPSIZECONF(Signal* signal)
/* ----------------------------------------------------------------------- */
c_lcpState.ctimer = 0;
c_lcpState.keepGci = coldgcp;
c_lcpState.lcpStartGcp = currentgcp;
/* ----------------------------------------------------------------------- */
/* UPDATE THE NEW LATEST LOCAL CHECKPOINT ID. */
/* ----------------------------------------------------------------------- */
@ -9310,7 +9313,7 @@ void Dbdih::calculateKeepGciLab(Signal* signal, Uint32 tableId, Uint32 fragId)
cnoOfActiveTables++;
FragmentstorePtr fragPtr;
getFragstore(tabPtr.p, fragId, fragPtr);
checkKeepGci(fragPtr.p->storedReplicas);
checkKeepGci(tabPtr, fragId, fragPtr.p, fragPtr.p->storedReplicas);
fragId++;
if (fragId >= tabPtr.p->totalfragments) {
jam();
@ -10168,6 +10171,7 @@ void Dbdih::allNodesLcpCompletedLab(Signal* signal)
signal->theData[0] = EventReport::LocalCheckpointCompleted; //Event type
signal->theData[1] = SYSFILE->latestLCP_ID;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
c_lcpState.lcpStopGcp = c_newest_restorable_gci;
/**
* Start checking for next LCP
@ -10522,7 +10526,8 @@ void Dbdih::checkEscalation()
/* DESCRIPTION: CHECK FOR MINIMUM GCI RESTORABLE WITH NEW LOCAL */
/* CHECKPOINT. */
/*************************************************************************/
void Dbdih::checkKeepGci(Uint32 replicaStartIndex)
void Dbdih::checkKeepGci(TabRecordPtr tabPtr, Uint32 fragId, Fragmentstore*,
Uint32 replicaStartIndex)
{
ReplicaRecordPtr ckgReplicaPtr;
ckgReplicaPtr.i = replicaStartIndex;
@ -10544,7 +10549,6 @@ void Dbdih::checkKeepGci(Uint32 replicaStartIndex)
if (oldestRestorableGci > c_lcpState.oldestRestorableGci) {
jam();
c_lcpState.oldestRestorableGci = oldestRestorableGci;
ndbrequire(((int)c_lcpState.oldestRestorableGci) >= 0);
}//if
ckgReplicaPtr.i = ckgReplicaPtr.p->nextReplica;
}//while
@ -10838,7 +10842,7 @@ void Dbdih::findMinGci(ReplicaRecordPtr fmgReplicaPtr,
do {
ndbrequire(lcpNo < MAX_LCP_STORED);
if (fmgReplicaPtr.p->lcpStatus[lcpNo] == ZVALID &&
fmgReplicaPtr.p->maxGciStarted[lcpNo] <= coldgcp)
fmgReplicaPtr.p->maxGciStarted[lcpNo] < c_newest_restorable_gci)
{
jam();
keepGci = fmgReplicaPtr.p->maxGciCompleted[lcpNo];
@ -10960,7 +10964,7 @@ void Dbdih::initCommonData()
c_lcpState.clcpDelay = 0;
c_lcpState.lcpStart = ZIDLE;
c_lcpState.lcpStartGcp = 0;
c_lcpState.lcpStopGcp = 0;
c_lcpState.setLcpStatus(LCP_STATUS_IDLE, __LINE__);
c_lcpState.currentFragment.tableId = 0;
c_lcpState.currentFragment.fragmentId = 0;
@ -10996,6 +11000,7 @@ void Dbdih::initCommonData()
csystemnodes = 0;
c_updateToLock = RNIL;
currentgcp = 0;
c_newest_restorable_gci = 0;
cverifyQueueCounter = 0;
cwaitLcpSr = false;
@ -11071,6 +11076,7 @@ void Dbdih::initRestartInfo()
currentgcp = 2;
cnewgcp = 2;
crestartGci = 1;
c_newest_restorable_gci = 1;
SYSFILE->keepGCI = 1;
SYSFILE->oldestRestorableGCI = 1;
@ -13042,9 +13048,9 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
if (signal->theData[0] == 7001) {
infoEvent("c_lcpState.keepGci = %d",
c_lcpState.keepGci);
infoEvent("c_lcpState.lcpStatus = %d, clcpStartGcp = %d",
infoEvent("c_lcpState.lcpStatus = %d, clcpStopGcp = %d",
c_lcpState.lcpStatus,
c_lcpState.lcpStartGcp);
c_lcpState.lcpStopGcp);
infoEvent("cgcpStartCounter = %d, cimmediateLcpStart = %d",
cgcpStartCounter, c_lcpState.immediateLcpStart);
}//if
@ -13225,8 +13231,8 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
infoEvent("lcpStatus = %d (update place = %d) ",
c_lcpState.lcpStatus, c_lcpState.lcpStatusUpdatedPlace);
infoEvent
("lcpStart = %d lcpStartGcp = %d keepGci = %d oldestRestorable = %d",
c_lcpState.lcpStart, c_lcpState.lcpStartGcp,
("lcpStart = %d lcpStopGcp = %d keepGci = %d oldestRestorable = %d",
c_lcpState.lcpStart, c_lcpState.lcpStopGcp,
c_lcpState.keepGci, c_lcpState.oldestRestorableGci);
infoEvent

View file

@ -14767,7 +14767,9 @@ void Dblqh::execSr(Signal* signal)
signal->theData[4] = logFilePtr.p->currentFilepage;
signal->theData[5] = logFilePtr.p->currentMbyte;
signal->theData[6] = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
sendSignal(cownref, GSN_DEBUG_SIG, signal, 7, JBA);
signal->theData[7] = ~0;
signal->theData[8] = __LINE__;
sendSignal(cownref, GSN_DEBUG_SIG, signal, 9, JBA);
return;
}//if
}//if
@ -14833,7 +14835,8 @@ void Dblqh::execSr(Signal* signal)
signal->theData[5] = logFilePtr.p->currentFilepage;
signal->theData[6] = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX];
signal->theData[7] = logWord;
sendSignal(cownref, GSN_DEBUG_SIG, signal, 8, JBA);
signal->theData[8] = __LINE__;
sendSignal(cownref, GSN_DEBUG_SIG, signal, 9, JBA);
return;
break;
}//switch
@ -14862,8 +14865,9 @@ void Dblqh::execDEBUG_SIG(Signal* signal)
char buf[100];
BaseString::snprintf(buf, 100,
"Error while reading REDO log.\n"
"Error while reading REDO log. from %d\n"
"D=%d, F=%d Mb=%d FP=%d W1=%d W2=%d",
signal->theData[8],
signal->theData[2], signal->theData[3], signal->theData[4],
signal->theData[5], signal->theData[6], signal->theData[7]);
@ -15439,6 +15443,10 @@ void Dblqh::readSrFourthZeroLab(Signal* signal)
// to read a page from file.
lfoPtr.p->lfoState = LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES;
/**
* Make sure we dont release zero page
*/
seizeLogpage(signal);
invalidateLogAfterLastGCI(signal);
return;
}//Dblqh::readSrFourthZeroLab()
@ -16096,8 +16104,22 @@ void Dblqh::findLogfile(Signal* signal,
}//if
locLogFilePtr.i = locLogFilePtr.p->nextLogFile;
loopCount++;
if (loopCount >= flfLogPartPtr.p->noLogFiles &&
getNodeState().startLevel != NodeState::SL_STARTED)
{
goto error;
}
ndbrequire(loopCount < flfLogPartPtr.p->noLogFiles);
}//while
error:
char buf[255];
BaseString::snprintf(buf, sizeof(buf),
"Unable to restart, failed while reading redo."
" Likely invalid change of configuration");
progError(__LINE__,
ERR_INVALID_CONFIG,
buf);
}//Dblqh::findLogfile()
/* ------------------------------------------------------------------------- */

View file

@ -959,6 +959,8 @@ int
NdbBlob::deletePartsUnknown(Uint32 part)
{
DBG("deletePartsUnknown [in] part=" << part << " count=all");
if (thePartSize == 0) // tinyblob
return 0;
static const unsigned maxbat = 256;
static const unsigned minbat = 1;
unsigned bat = minbat;

View file

@ -841,9 +841,6 @@ insertPk(int style)
CHK(g_con->execute(NoCommit) == 0);
CHK(writeBlobData(tup) == 0);
}
// just another trap
if (urandom(10) == 0)
CHK(g_con->execute(NoCommit) == 0);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
@ -965,21 +962,31 @@ static int
deletePk()
{
DBG("--- deletePk ---");
unsigned n = 0;
CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k];
DBG("deletePk pk1=" << hex << tup.m_pk1);
CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
CHK(g_opr->deleteTuple() == 0);
CHK(g_opr->equal("PK1", tup.m_pk1) == 0);
if (g_opt.m_pk2len != 0)
CHK(g_opr->equal("PK2", tup.m_pk2) == 0);
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
CHK((g_con = g_ndb->startTransaction()) != 0);
n = 0;
}
g_opr = 0;
g_con = 0;
tup.m_exists = false;
}
if (n != 0) {
CHK(g_con->execute(Commit) == 0);
n = 0;
}
g_ndb->closeTransaction(g_con);
g_con = 0;
return 0;
}
@ -1082,19 +1089,27 @@ static int
deleteIdx()
{
DBG("--- deleteIdx ---");
unsigned n = 0;
CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k];
DBG("deleteIdx pk1=" << hex << tup.m_pk1);
CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0);
CHK(g_opx->deleteTuple() == 0);
CHK(g_opx->equal("PK2", tup.m_pk2) == 0);
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
CHK((g_con = g_ndb->startTransaction()) != 0);
n = 0;
}
g_opx = 0;
g_con = 0;
tup.m_exists = false;
}
if (n != 0) {
CHK(g_con->execute(Commit) == 0);
n = 0;
}
return 0;
}
@ -1225,20 +1240,49 @@ deleteScan(bool idx)
CHK(g_ops->getValue("PK2", tup.m_pk2) != 0);
CHK(g_con->execute(NoCommit) == 0);
unsigned rows = 0;
unsigned n = 0;
while (1) {
int ret;
tup.m_pk1 = (Uint32)-1;
memset(tup.m_pk2, 'x', g_opt.m_pk2len);
CHK((ret = rs->nextResult()) == 0 || ret == 1);
CHK((ret = rs->nextResult(true)) == 0 || ret == 1);
if (ret == 1)
break;
DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
CHK(rs->deleteTuple() == 0);
CHK(g_con->execute(NoCommit) == 0);
Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
CHK(k < g_opt.m_rows && g_tups[k].m_exists);
g_tups[k].m_exists = false;
rows++;
while (1) {
DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
CHK(k < g_opt.m_rows && g_tups[k].m_exists);
g_tups[k].m_exists = false;
CHK(rs->deleteTuple() == 0);
rows++;
tup.m_pk1 = (Uint32)-1;
memset(tup.m_pk2, 'x', g_opt.m_pk2len);
CHK((ret = rs->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
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
CHK(g_con->execute(Commit) == 0);
CHK(g_con->restart() == 0);
break;
}
n = 0;
}
if (ret == 2)
break;
}
}
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
@ -1488,13 +1532,16 @@ testperf()
// insert char (one trans)
{
DBG("--- insert char ---");
char b[20];
t1.on();
CHK((g_con = g_ndb->startTransaction()) != 0);
for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) {
CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0);
CHK(g_opr->insertTuple() == 0);
CHK(g_opr->equal(cA, (char*)&k) == 0);
CHK(g_opr->setValue(cB, "b") == 0);
memset(b, 0x20, sizeof(b));
b[0] = 'b';
CHK(g_opr->setValue(cB, b) == 0);
CHK(g_con->execute(NoCommit) == 0);
}
t1.off(g_opt.m_rowsperf);
@ -1531,12 +1578,15 @@ testperf()
{
DBG("--- insert for read test ---");
unsigned n = 0;
char b[20];
CHK((g_con = g_ndb->startTransaction()) != 0);
for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) {
CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0);
CHK(g_opr->insertTuple() == 0);
CHK(g_opr->equal(cA, (char*)&k) == 0);
CHK(g_opr->setValue(cB, "b") == 0);
memset(b, 0x20, sizeof(b));
b[0] = 'b';
CHK(g_opr->setValue(cB, b) == 0);
CHK((g_bh1 = g_opr->getBlobHandle(cC)) != 0);
CHK((g_bh1->setValue("c", 1) == 0));
if (++n == g_opt.m_batch) {
@ -1570,7 +1620,7 @@ testperf()
a = (Uint32)-1;
b[0] = 0;
CHK(g_con->execute(NoCommit) == 0);
CHK(a == k && strcmp(b, "b") == 0);
CHK(a == k && b[0] == 'b');
}
CHK(g_con->execute(Commit) == 0);
t1.off(g_opt.m_rowsperf);
@ -1596,7 +1646,7 @@ testperf()
CHK(g_con->execute(NoCommit) == 0);
Uint32 m = 20;
CHK(g_bh1->readData(c, m) == 0);
CHK(a == k && m == 1 && strcmp(c, "c") == 0);
CHK(a == k && m == 1 && c[0] == 'c');
}
CHK(g_con->execute(Commit) == 0);
t2.off(g_opt.m_rowsperf);
@ -1629,7 +1679,7 @@ testperf()
CHK((ret = rs->nextResult(true)) == 0 || ret == 1);
if (ret == 1)
break;
CHK(a < g_opt.m_rowsperf && strcmp(b, "b") == 0);
CHK(a < g_opt.m_rowsperf && b[0] == 'b');
n++;
}
CHK(n == g_opt.m_rowsperf);
@ -1661,7 +1711,7 @@ testperf()
break;
Uint32 m = 20;
CHK(g_bh1->readData(c, m) == 0);
CHK(a < g_opt.m_rowsperf && m == 1 && strcmp(c, "c") == 0);
CHK(a < g_opt.m_rowsperf && m == 1 && c[0] == 'c');
n++;
}
CHK(n == g_opt.m_rowsperf);

View file

@ -22,7 +22,8 @@
#include <NdbSleep.h>
#include <NDBT.hpp>
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240);
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism=240);
NDB_STD_OPTS_VARS;
@ -81,8 +82,18 @@ 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) == NDBT_FAILED){
if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){
res = NDBT_FAILED;
ndbout << "FAILED" << endl;
}
@ -91,7 +102,8 @@ int main(int argc, char** argv){
}
int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism)
{
// Scan all records exclusive and delete
// them one by one
@ -153,8 +165,12 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
} while((check = rs->nextResult(false)) == 0);
if(check != -1){
check = pTrans->execute(Commit);
pTrans->restart();
if (commit_across_open_cursor) {
check = pTrans->execute(Commit);
pTrans->restart(); // new tx id
} else {
check = pTrans->execute(NoCommit);
}
}
err = pTrans->getNdbError();
@ -180,6 +196,10 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
}
goto failed;
}
if (! commit_across_open_cursor && pTrans->execute(Commit) != 0) {
err = pTrans->getNdbError();
goto failed;
}
pNdb->closeTransaction(pTrans);
return NDBT_OK;
}

View file

@ -45,8 +45,6 @@ static const int max_transactions= 256;
static const char *ha_ndb_ext=".ndb";
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0
#define NDB_AUTO_INCREMENT_RETRIES 10
@ -747,7 +745,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field,
}
// Used for hidden key only
m_value[fieldnr].rec= ndb_op->getValue(fieldnr, NULL);
m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_ref);
DBUG_RETURN(m_value[fieldnr].rec == NULL);
}
@ -2098,13 +2096,10 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
DBUG_PRINT("info", ("Using hidden key"));
// Require that the PK for this record has previously been
// read into m_value
uint no_fields= table->fields;
NdbRecAttr* rec= m_value[no_fields].rec;
DBUG_ASSERT(rec);
DBUG_DUMP("key", (char*)rec->aRef(), NDB_HIDDEN_PRIMARY_KEY_LENGTH);
// read into m_ref
DBUG_DUMP("key", m_ref, NDB_HIDDEN_PRIMARY_KEY_LENGTH);
if (set_hidden_key(op, no_fields, rec->aRef()))
if (set_hidden_key(op, table->fields, m_ref))
ERR_RETURN(op->getNdbError());
}
else
@ -2181,11 +2176,8 @@ int ha_ndbcluster::delete_row(const byte *record)
{
// This table has no primary key, use "hidden" primary key
DBUG_PRINT("info", ("Using hidden key"));
uint no_fields= table->fields;
NdbRecAttr* rec= m_value[no_fields].rec;
DBUG_ASSERT(rec != NULL);
if (set_hidden_key(op, no_fields, rec->aRef()))
if (set_hidden_key(op, table->fields, m_ref))
ERR_RETURN(op->getNdbError());
}
else
@ -2792,7 +2784,7 @@ void ha_ndbcluster::position(const byte *record)
hidden_col->getAutoIncrement() &&
rec != NULL &&
ref_length == NDB_HIDDEN_PRIMARY_KEY_LENGTH);
memcpy(ref, (const void*)rec->aRef(), ref_length);
memcpy(ref, m_ref, ref_length);
}
DBUG_DUMP("ref", (char*)ref, ref_length);
@ -3046,9 +3038,26 @@ int ha_ndbcluster::end_bulk_insert()
"rows_inserted:%d, bulk_insert_rows: %d",
(int) m_rows_inserted, (int) m_bulk_insert_rows));
m_bulk_insert_not_flushed= FALSE;
if (execute_no_commit(this,trans) != 0) {
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
if (m_transaction_on)
{
if (execute_no_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
}
}
else
{
if (execute_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
}
else
{
int res= trans->restart();
DBUG_ASSERT(res == 0);
}
}
}
@ -4867,7 +4876,7 @@ bool ha_ndbcluster::low_byte_first() const
}
bool ha_ndbcluster::has_transactions()
{
return m_transaction_on;
return TRUE;
}
const char* ha_ndbcluster::index_type(uint key_number)
{

View file

@ -27,6 +27,8 @@
#include <ndbapi_limits.h>
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
class Ndb; // Forward declaration
class NdbOperation; // Forward declaration
class NdbConnection; // Forward declaration
@ -226,6 +228,7 @@ class ha_ndbcluster: public handler
// NdbRecAttr has no reference to blob
typedef union { NdbRecAttr *rec; NdbBlob *blob; void *ptr; } NdbValue;
NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE];
byte m_ref[NDB_HIDDEN_PRIMARY_KEY_LENGTH];
bool m_use_write;
bool m_ignore_dup_key;
bool m_primary_key_update;

View file

@ -1056,16 +1056,13 @@ public:
if (!master && ft_handler)
{
ft_handler->please->close_search(ft_handler);
ft_handler=0;
if (join_key)
table->file->ft_handler=0;
table->fulltext_searched=0;
}
if (concat)
{
delete concat;
concat= 0;
}
ft_handler= 0;
DBUG_VOID_RETURN;
}
enum Functype functype() const { return FT_FUNC; }

View file

@ -988,6 +988,8 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table->status=STATUS_NO_RECORD;
table->keys_in_use_for_query= table->keys_in_use;
table->used_keys= table->keys_for_keyread;
table->file->ft_handler=0;
table->fulltext_searched=0;
if (table->timestamp_field)
table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
DBUG_ASSERT(table->key_read == 0);

View file

@ -388,6 +388,12 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
silent Used by replication when internally creating a database.
In this case the entry should not be logged.
SIDE-EFFECTS
1. Report back to client that command succeeded (send_ok)
2. Report errors to client
3. Log event to binary log
(The 'silent' flags turns off 1 and 3.)
RETURN VALUES
0 ok
-1 Error
@ -421,16 +427,17 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
if (my_stat(path,&stat_info,MYF(0)))
{
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
{
my_error(ER_DB_CREATE_EXISTS,MYF(0),db);
error= -1;
goto exit;
}
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db);
ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db);
if (!silent)
send_ok(thd);
error= 0;
send_ok(thd);
goto exit;
}
else

View file

@ -285,8 +285,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
skip_lines);
if (table->file->end_bulk_insert())
error=1; /* purecov: inspected */
if (table->file->end_bulk_insert() && !error)
{
table->file->print_error(my_errno, MYF(0));
error= 1;
}
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->next_number_field=0;
}

View file

@ -11706,6 +11706,37 @@ static void test_bug12001()
DIE_UNLESS(res==1);
}
static void test_bug12744()
{
MYSQL_STMT *prep_stmt = NULL;
int rc;
myheader("test_bug12744");
prep_stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8);
DIE_UNLESS(rc==0);
rc= mysql_kill(mysql, mysql_thread_id(mysql));
DIE_UNLESS(rc==0);
if (rc= mysql_stmt_execute(prep_stmt))
{
if (rc= mysql_stmt_reset(prep_stmt))
printf("OK!\n");
else
{
printf("Error!");
DIE_UNLESS(1==0);
}
}
else
{
fprintf(stderr, "expected error but no error occured\n");
DIE_UNLESS(1==0);
}
rc= mysql_stmt_close(prep_stmt);
}
/*
Bug#11718: query with function, join and order by returns wrong type
*/
@ -12054,6 +12085,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug8378", test_bug8378 },
{ "test_bug9735", test_bug9735 },
{ "test_bug11183", test_bug11183 },
{ "test_bug12744", test_bug12744 },
{ "test_bug12001", test_bug12001 },
{ "test_bug11718", test_bug11718 },
{ "test_bug12925", test_bug12925 },