From a2580e91a1d32571788863558691ab48bd9b2eb2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Jun 2005 13:28:29 +0200 Subject: [PATCH 1/6] Disallow TL_WRITE_ALLOW_READ being transformed into TL_WRITE_ALLOW_WRITE --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a0080af1dfb..97c40f03d93 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3106,7 +3106,7 @@ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd, /* Since NDB does not currently have table locks this is treated as a ordinary lock */ - if ((lock_type >= TL_WRITE_ALLOW_WRITE && + if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && !thd->in_lock_tables) lock_type= TL_WRITE_ALLOW_WRITE; From 5b50ea27ad181330b33b4e25c9b65d1b0444ee87 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2005 14:45:54 +0200 Subject: [PATCH 2/6] Fix for bug#10936: Cluster engine shows wrong key value for duplicate key error --- mysql-test/r/ndb_insert.result | 16 +++++++++------- mysql-test/t/ndb_insert.test | 15 +++++++++------ sql/ha_ndbcluster.cc | 9 +++++++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index 7503010a66b..464eeb6d607 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -416,10 +416,12 @@ INSERT INTO t1 VALUES SELECT COUNT(*) FROM t1; COUNT(*) 2000 +INSERT INTO t1 VALUES (1,1,1); +ERROR 23000: Duplicate entry '1' for key 1 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' select count(*) from t1; count(*) 2000 @@ -437,7 +439,7 @@ begin; INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' commit; ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster select * from t1 where pk1=1; @@ -456,7 +458,7 @@ begin; INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' rollback; select * from t1 where pk1=1; pk1 b c @@ -474,7 +476,7 @@ begin; INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' SELECT * FROM t1 WHERE pk1=10; ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster rollback; @@ -494,7 +496,7 @@ begin; INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' SELECT * FROM t1 WHERE pk1=10; ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster SELECT * FROM t1 WHERE pk1=10; @@ -517,7 +519,7 @@ begin; INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -ERROR 23000: Duplicate entry '10' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' INSERT INTO t1 values (4000, 40, 44); ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster rollback; @@ -534,7 +536,7 @@ select count(*) from t1; count(*) 2000 insert into t1 select * from t1 where b < 10 order by pk1; -ERROR 23000: Duplicate entry '9' for key 1 +ERROR 23000: Can't write; duplicate key in table 't1' DELETE FROM t1 WHERE pk1=2; begin; INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index f88d33f22f4..68f3817e134 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -434,6 +434,9 @@ SELECT COUNT(*) FROM t1; # Insert duplicate rows # --error 1062 +INSERT INTO t1 VALUES (1,1,1); + +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -457,7 +460,7 @@ rollback; # begin; ---error 1062 +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -477,7 +480,7 @@ select count(*) from t1; # begin; ---error 1062 +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -496,7 +499,7 @@ select count(*) from t1; # begin; ---error 1062 +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -517,7 +520,7 @@ select count(*) from t1; # begin; ---error 1062 +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -543,7 +546,7 @@ select count(*) from t1; # begin; ---error 1062 +--error 1022 INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); @@ -562,7 +565,7 @@ select count(*) from t1; # Insert duplicate rows using "insert .. select" # ---error 1062 +--error 1022 insert into t1 select * from t1 where b < 10 order by pk1; DELETE FROM t1 WHERE pk1=2; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 97c40f03d93..5e8286684ea 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -435,8 +435,13 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans) DBUG_PRINT("info", ("transformed ndbcluster error %d to mysql error %d", err.code, res)); if (res == HA_ERR_FOUND_DUPP_KEY) - m_dupkey= table->primary_key; - + { + if (m_rows_to_insert == 1) + m_dupkey= table->primary_key; + else + // We are batching inserts, offending key is not available + m_dupkey= (uint) -1; + } DBUG_RETURN(res); } From b8cbed7c36bfba7aa08ce67592aeb3ecee9133fa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Jun 2005 17:16:22 +0200 Subject: [PATCH 3/6] Added comment to store_lock --- sql/ha_ndbcluster.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index aaa8e4aab5e..9c0536f391a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3083,7 +3083,13 @@ double ha_ndbcluster::scan_time() DBUG_RETURN(res); } - +/* + Convert MySQL table locks into locks supported by Ndb Cluster. + Note that MySQL Cluster does currently not support distributed + table locks, so to be safe one should set cluster in Single + User Mode, before relying on table locks when updating tables + from several MySQL servers +*/ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) From 84da8b22d5e2c57a4998e68b9200dcd9e1b3c614 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Jun 2005 17:17:44 +0200 Subject: [PATCH 4/6] ha_ndbcluster.cc: Added CR for readability sql/ha_ndbcluster.cc: Added CR for readability --- sql/ha_ndbcluster.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9c0536f391a..88b7ff4dcb8 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3090,6 +3090,7 @@ double ha_ndbcluster::scan_time() User Mode, before relying on table locks when updating tables from several MySQL servers */ + THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) From 0bfbba10647a8a425e1b52a6db047f65db87b7f7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jun 2005 11:49:55 +0300 Subject: [PATCH 5/6] InnoDB: Remove some warnings reported by GCC 4.0.0. innobase/log/log0recv.c: Remove GCC 4.0.0 warnings about possibly uninitialized variables. innobase/row/row0umod.c: row_undo_mod_undo_also_prev_vers(): Remove unused parameter thr, always initialize *undo_no to remove GCC 4.0.0 warning innobase/trx/trx0undo.c: trx_undo_write_xid(): Remove warning about signedness mismatch, add const qualifier to parameter xid. sql/ha_innodb.cc: Add proper casts from ulonglong to ulong in fprintf statements. --- innobase/log/log0recv.c | 5 ++++- innobase/row/row0umod.c | 15 +++------------ innobase/trx/trx0undo.c | 4 ++-- sql/ha_innodb.cc | 4 ++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c index 0417d01d89a..8d9780bfbda 100644 --- a/innobase/log/log0recv.c +++ b/innobase/log/log0recv.c @@ -477,6 +477,7 @@ recv_find_max_checkpoint( max_no = ut_dulint_zero; *max_group = NULL; + *max_field = 0; buf = log_sys->checkpoint_buf; @@ -543,7 +544,6 @@ recv_find_max_checkpoint( "InnoDB: to create the InnoDB data files, but log file creation failed.\n" "InnoDB: If that is the case, please refer to\n" "InnoDB: http://dev.mysql.com/doc/mysql/en/Error_creating_InnoDB.html\n"); - *max_field = 0; return(DB_ERROR); } @@ -1168,6 +1168,7 @@ recv_recover_page( } modification_to_page = FALSE; + start_lsn = end_lsn = ut_dulint_zero; recv = UT_LIST_GET_FIRST(recv_addr->rec_list); @@ -1796,6 +1797,8 @@ recv_parse_log_rec( { byte* new_ptr; + *body = NULL; + if (ptr == end_ptr) { return(0); diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c index 1cade0f304f..0225a9faec5 100644 --- a/innobase/row/row0umod.c +++ b/innobase/row/row0umod.c @@ -52,19 +52,16 @@ row_undo_mod_undo_also_prev_vers( /* out: TRUE if also previous modify or insert of this row should be undone */ undo_node_t* node, /* in: row undo node */ - que_thr_t* thr, /* in: query thread */ dulint* undo_no)/* out: the undo number */ { trx_undo_rec_t* undo_rec; - ibool ret; trx_t* trx; - UT_NOT_USED(thr); - trx = node->trx; if (0 != ut_dulint_cmp(node->new_trx_id, trx->id)) { + *undo_no = ut_dulint_zero; return(FALSE); } @@ -72,13 +69,7 @@ row_undo_mod_undo_also_prev_vers( *undo_no = trx_undo_rec_get_undo_no(undo_rec); - if (ut_dulint_cmp(trx->roll_limit, *undo_no) <= 0) { - ret = TRUE; - } else { - ret = FALSE; - } - - return(ret); + return(ut_dulint_cmp(trx->roll_limit, *undo_no) <= 0); } /*************************************************************** @@ -214,7 +205,7 @@ row_undo_mod_clust( /* Check if also the previous version of the clustered index record should be undone in this same rollback operation */ - more_vers = row_undo_mod_undo_also_prev_vers(node, thr, &new_undo_no); + more_vers = row_undo_mod_undo_also_prev_vers(node, &new_undo_no); pcur = &(node->pcur); diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index bb314dd35e9..c14e4a1f3ab 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -556,7 +556,7 @@ void trx_undo_write_xid( /*===============*/ trx_ulogf_t* log_hdr,/* in: undo log header */ - XID* xid, /* in: X/Open XA Transaction Identification */ + const XID* xid, /* in: X/Open XA Transaction Identification */ mtr_t* mtr) /* in: mtr */ { mlog_write_ulint(log_hdr + TRX_UNDO_XA_FORMAT, xid->formatID, @@ -568,7 +568,7 @@ trx_undo_write_xid( mlog_write_ulint(log_hdr + TRX_UNDO_XA_BQUAL_LEN, xid->bqual_length, MLOG_4BYTES, mtr); - mlog_write_string(log_hdr + TRX_UNDO_XA_XID, xid->data, + mlog_write_string(log_hdr + TRX_UNDO_XA_XID, (const byte*) xid->data, XIDDATASIZE, mtr); } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6dd07930244..db354066849 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -563,7 +563,7 @@ innobase_mysql_print_thd( thd = (const THD*) input_thd; fprintf(f, "MySQL thread id %lu, query id %lu", - thd->thread_id, thd->query_id); + thd->thread_id, (ulong) thd->query_id); if (thd->host) { putc(' ', f); fputs(thd->host, f); @@ -1805,7 +1805,7 @@ try_again: fprintf(stderr, "InnoDB: This transaction needs it to be sent up to\n" "InnoDB: file %s, position %lu\n", trx->repl_wait_binlog_name, - (uint)trx->repl_wait_binlog_pos); + (ulong)trx->repl_wait_binlog_pos); innobase_repl_state = 0; From 77514fbc50eb9650cca695f5d6c928cf91e47e5d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jun 2005 14:55:20 +0300 Subject: [PATCH 6/6] log0log.c: log_checkpoint_margin(): Correct a typo that was introduced when fixing gcc 4.0 warnings. innobase/log/log0log.c: log_checkpoint_margin(): Correct a typo that was introduced when fixing gcc 4.0 warnings. --- innobase/log/log0log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index 5953262ece7..2f76bf450db 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -2064,7 +2064,7 @@ loop: /* A flush is urgent: we have to do a synchronous preflush */ sync = TRUE; - advance = 2 * (age - log->max_modified_age_async); + advance = 2 * (age - log->max_modified_age_sync); } else if (age > log->max_modified_age_async) { /* A flush is not urgent: we do an asynchronous preflush */