From: jonas oreland Date: December 1 2010 1:22pm Subject: bzr push into mysql-5.1-telco-7.1 branch (jonas:4008 to 4009) List-Archive: http://lists.mysql.com/commits/125656 Message-Id: <20101201132230.53A59518875@eel.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4009 jonas oreland 2010-12-01 [merge] ndb - merge 70 to 71 modified: mysql-test/suite/ndb/r/ndb_update_no_read.result mysql-test/suite/ndb/t/ndb_update_no_read.test sql/ha_ndbcluster.cc 4008 Jonas Oreland 2010-11-30 [merge] ndb merge 70 to 71 modified: mysql-test/suite/ndb/r/ndb_dd_alter.result mysql-test/suite/ndb/t/ndb_dd_alter.test sql/ha_ndbcluster.cc storage/ndb/src/kernel/blocks/print_file.cpp === modified file 'mysql-test/suite/ndb/r/ndb_update_no_read.result' --- a/mysql-test/suite/ndb/r/ndb_update_no_read.result 2008-12-05 09:46:39 +0000 +++ b/mysql-test/suite/ndb/r/ndb_update_no_read.result 2010-12-01 12:04:27 +0000 @@ -400,3 +400,81 @@ affected rows: 1 affected rows: 1 drop table t1; affected rows: 0 +create table t1 +(a int not null primary key auto_increment, b int, c varchar(256)) +engine = ndb; +affected rows: 0 +insert into t1(b,c) values (1,'this is a test'), +(2,'this is a test'),(3,'this is a test'), +(4,'this is a test'),(5,'this is a test'),(6,'this is a test'), +(7,'this is a test'),(8,'this is a test'),(9,'this is a test'); +affected rows: 9 +info: Records: 9 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 9 +info: Records: 9 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 18 +info: Records: 18 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 36 +info: Records: 36 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 72 +info: Records: 72 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 144 +info: Records: 144 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 288 +info: Records: 288 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 576 +info: Records: 576 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 1152 +info: Records: 1152 Duplicates: 0 Warnings: 0 +insert into t1(b,c) select b,c from t1; +affected rows: 2304 +info: Records: 2304 Duplicates: 0 Warnings: 0 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +affected rows: 1 +select count(*) from t1 where a in (...) +count(*) +1000 +affected rows: 1 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +5 +affected rows: 1 +update t1 set c = 'kalle' where a in (...) +affected rows: 1000 +info: Rows matched: 1000 Changed: 1000 Warnings: 0 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +9 +affected rows: 1 +delete from t1 where a in (...) +affected rows: 1000 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +3 +affected rows: 1 +delete from t1 where a in (...) +affected rows: 0 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +3 +affected rows: 1 +update t1 set c = 'kalle' where a in (...) +affected rows: 0 +info: Rows matched: 0 Changed: 0 Warnings: 0 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +9 +affected rows: 1 +update t1 set c = 'kalle' where a in (...) +affected rows: 0 +info: Rows matched: 0 Changed: 0 Warnings: 0 +@ndb_execute_count:=VARIABLE_VALUE-@ndb_init_execute_count +9 +affected rows: 1 +drop table t1; +affected rows: 0 === modified file 'mysql-test/suite/ndb/t/ndb_update_no_read.test' --- a/mysql-test/suite/ndb/t/ndb_update_no_read.test 2010-09-22 11:36:01 +0000 +++ b/mysql-test/suite/ndb/t/ndb_update_no_read.test 2010-12-01 12:06:43 +0000 @@ -347,3 +347,131 @@ show warnings; # Workaround to bug#39663 --enable_warnings # Workaround to bug#39663 drop table t1; + +# bug#58040 + +create table t1 +(a int not null primary key auto_increment, b int, c varchar(256)) +engine = ndb; + +# insert some rows... +insert into t1(b,c) values (1,'this is a test'), +(2,'this is a test'),(3,'this is a test'), +(4,'this is a test'),(5,'this is a test'),(6,'this is a test'), +(7,'this is a test'),(8,'this is a test'),(9,'this is a test'); + +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +insert into t1(b,c) select b,c from t1; +analyze table t1; + +# looong in list +let $list = +(3220,3371,709,363,603,2232,1738,2079,585,1798,2786,2495,1631,2000,59,2137, +1703,564,1102,868,3934,427,694,2908,2324,2542,1779,1133,1508,3153,2701,2966, +3687,1551,3395,3157,3914,1096,2755,1433,3096,16,3592,521,1977,1886,441,3285, +3257,2040,911,403,736,3720,496,1244,3221,1386,2988,1442,2271,3050,148,2355, +1751,3349,3512,731,3320,244,2462,1141,1410,1815,4007,1140,1236,2824,1323,1843, +422,3929,182,3064,3603,2798,68,2251,1255,2417,3436,67,1458,1260,1450,1740,3493, +2043,965,4069,2762,3876,2945,2741,1194,3593,2135,4046,659,1263,2416,2539,921, +698,1396,2152,2130,3411,1013,2682,703,240,1933,3581,3798,1926,2381,717,361, +2697,221,3726,2124,1317,89,1413,312,2279,2556,1920,3282,3850,893,2012,1463, +1032,4044,3448,2116,1743,3761,3145,1760,3351,3462,599,2164,4050,2178,4014,519, +2898,610,86,2138,1547,3543,3098,3599,376,2854,2408,2506,1846,2732,950,700,2829, +1724,3989,1644,1700,2706,70,2478,2136,854,1175,3678,2975,1680,471,2508,3069, +289,1758,2768,2398,131,550,948,3625,1476,2760,1974,648,2664,3706,1497,2111, +2784,801,1931,3913,1539,205,3686,1253,2101,1229,1466,909,566,2757,1478,2483, +192,1343,1103,259,3243,2393,547,569,2074,2750,2826,3756,2934,1788,495,410,2797, +1104,883,2899,3083,337,822,829,2698,2723,2285,3155,328,3111,1663,3652,3174, +2429,1298,1720,3757,156,1684,2125,169,58,3937,773,2433,2867,3323,650,4087,1775, +2822,3328,3037,1907,346,3217,1531,1456,3595,3218,2678,762,10,210,2427,2341,75, +1506,2552,2384,2196,2191,2972,1113,4032,378,2953,1389,1916,3253,1742,42,3550, +2835,885,3099,555,393,3135,44,3400,251,2896,3640,3712,282,1995,1187,491,3433, +3968,3176,1459,1126,1088,3534,1634,114,3843,3013,97,2358,1872,1814,1180,3740, +601,3354,216,677,4067,484,3621,3891,2981,2708,953,1652,2197,1426,1218,3735, +2269,1300,2523,3627,174,3529,1192,2369,939,3024,1542,3651,1145,3684,1994,2187, +2498,1546,2418,371,2368,1686,2816,2231,862,3513,3741,1267,389,1615,2096,1636, +739,3800,2168,1537,942,538,954,1234,3112,1676,2165,2019,3364,1613,4056,2371, +3079,2484,3417,3580,17,3980,945,1470,2609,2864,2791,3812,1125,832,1861,2158, +1014,92,2470,1604,1991,903,805,2046,320,1906,1022,2614,1266,2335,3506,3736, +3168,26,2769,2346,2444,1445,479,3965,819,3010,1029,3318,1687,290,1407,3920,379, +3885,2892,3377,1210,2262,1580,107,3517,3302,2334,1027,3166,2217,681,2466,928, +3791,2612,3009,372,2790,2294,2713,3856,2862,2266,2845,2480,1876,3394,1835,735, +1293,1969,3248,237,419,3352,740,2426,3638,2319,1729,3303,2189,283,1839,1905, +1165,3971,2696,3258,2221,665,1559,1734,3416,3835,2894,535,3911,611,1453,3649, +837,2085,1060,3646,4023,2042,1939,1226,2601,2657,967,4059,2035,3556,1529,3845, +170,3842,1928,3407,150,271,936,1952,2543,446,662,804,1349,654,470,3713,3232, +2600,2955,2881,1929,2747,2549,1291,2509,2773,3316,3461,2004,2270,674,3334,1947, +1067,4072,189,2619,122,593,3558,3236,2082,1504,1182,1867,43,2486,3028,4033,448, +1150,4013,1148,1691,3234,459,3807,2195,4063,869,3962,582,660,600,3925,2166, +3179,3846,1620,476,2122,2949,2024,3606,2027,3468,1540,1786,1364,1593,1802,411, +1940,3004,2802,3598,2530,2613,2338,3953,128,1951,4061,3907,2568,2844,2962,2683, +1471,3554,417,767,1526,1480,118,658,209,2656,3295,2123,3117,465,3005,3246,336, +604,2442,1283,2579,2795,3484,1997,463,2877,84,3081,2318,3336,818,3583,3245, +3613,2897,3921,1820,2819,2306,3516,1763,2973,3019,3380,723,19,3444,3795,3065, +1692,1297,1289,3707,3080,1824,1612,2617,3014,621,3988,2842,3813,2204,2298,3233, +2738,2548,2914,902,3200,1061,2081,607,3392,3895,2190,789,2865,943,1595,976, +2863,1666,3496,1896,3568,3249,2200,933,1717,1857,592,467,2770,2663,1560,575, +605,1196,3238,2558,2375,2859,2667,3106,443,1702,2382,284,4017,307,2492,4002, +931,1004,397,619,1052,1003,3797,2694,177,1017,3519,1237,1733,3734,2407,109, +2246,1600,1981,3437,620,1058,530,2112,2449,1381,2403,1198,1062,668,1512,69, +1822,2283,401,1135,3110,3214,670,2645,3586,3924,4078,4090,2083,1566,1563,2516, +675,1491,774,1967,3973,3609,872,2893,2535,1123,2623,2562,3793,1503,1968,113, +2811,3930,1908,447,2419,1117,2471,1051,787,695,1303,146,3633,367,3132,602,1862, +2127,1306,1285,3564,426,3224,273,1385,2807,3701,4041,865,2690,1697,3960,2684, +4079,1772,3171,3716,2120,3918,2922,2497,2154,630,3879,3688,2055,2316,155,1220, +3927,1425,2413,1791,3237,206,3384,1371,3819,4089,94,1404,2343,4031,1144,3034, +2500,2846,3042,2553,1380,166,3487,646,963,3772,3617,1474,3610,1146,386,2592, +3421,1887,3589,141,3033,3326,3509,1475,1320,533,2275,1932,3732,2474,1980,49, +1511,2671,3278,1486,1080,1610,3575,3904,2227,3669,784,1736,3724,729,3818,3825, +3908,3031,3109,704,685,2448,710,359,3235,1583,2376,2810,1619,64,2635,3032,1412, +1159,3792,1890,2885,55,1571,3826,744,80,1683,348,3097,1754,2402,2310,2072,831, +3053,2882,2599,127,2118,3748,2512,844,3376,490,813,2011,2099,3626,1350,3993, +2207,3553,350,2805,2276,2235,2803,159,1039,2075,576,614,1899,3348,649,218,637, +2942,270,3422,3775,3873,3239,989,2463,783,3312); + +--echo select count(*) from t1 where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval select count(*) from t1 where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--echo update t1 set c = 'kalle' where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval update t1 set c = 'kalle' where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--echo delete from t1 where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval delete from t1 where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--echo delete from t1 where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval delete from t1 where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--echo update t1 set c = 'kalle' where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval update t1 set c = 'kalle' where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--echo update t1 set c = 'kalle' where a in (...) +--source suite/ndb/include/ndb_init_execute_count.inc +--disable_query_log +eval update t1 set c = 'kalle' where a in $list; +--source suite/ndb/include/ndb_execute_count.inc + +--enable_query_log + +drop table t1; === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2010-11-30 10:35:37 +0000 +++ b/sql/ha_ndbcluster.cc 2010-12-01 12:06:43 +0000 @@ -554,10 +554,18 @@ static int write_conflict_row(NDB_SHARE inline int check_completed_operations_pre_commit(Thd_ndb *thd_ndb, NdbTransaction *trans, const NdbOperation *first, + const NdbOperation *last, uint *ignore_count) { uint ignores= 0; DBUG_ENTER("check_completed_operations_pre_commit"); + + if (unlikely(first == 0)) + { + assert(last == 0); + DBUG_RETURN(0); + } + /* Check that all errors are "accepted" errors or exceptions to report @@ -565,7 +573,7 @@ check_completed_operations_pre_commit(Th #ifdef HAVE_NDB_BINLOG uint conflict_rows_written= 0; #endif - while (first) + while (true) { const NdbError &err= first->getNdbError(); if (err.classification != NdbError::NoError @@ -661,6 +669,10 @@ check_completed_operations_pre_commit(Th } if (err.classification != NdbError::NoError) ignores++; + + if (first == last) + break; + first= trans->getNextCompletedOperation(first); } if (ignore_count) @@ -687,14 +699,22 @@ check_completed_operations_pre_commit(Th inline int check_completed_operations(Thd_ndb *thd_ndb, NdbTransaction *trans, const NdbOperation *first, + const NdbOperation *last, uint *ignore_count) { uint ignores= 0; DBUG_ENTER("check_completed_operations"); + + if (unlikely(first == 0)) + { + assert(last == 0); + DBUG_RETURN(0); + } + /* Check that all errors are "accepted" errors */ - while (first) + while (true) { const NdbError &err= first->getNdbError(); if (err.classification != NdbError::NoError && @@ -708,6 +728,10 @@ check_completed_operations(Thd_ndb *thd_ } if (err.classification != NdbError::NoError) ignores++; + + if (first == last) + break; + first= trans->getNextCompletedOperation(first); } if (ignore_count) @@ -740,20 +764,21 @@ int execute_no_commit(Thd_ndb *thd_ndb, DBUG_ENTER("execute_no_commit"); ha_ndbcluster::release_completed_operations(trans); const NdbOperation *first= trans->getFirstDefinedOperation(); + const NdbOperation *last= trans->getLastDefinedOperation(); thd_ndb->m_execute_count++; + thd_ndb->m_unsent_bytes= 0; DBUG_PRINT("info", ("execute_count: %u", thd_ndb->m_execute_count)); if (trans->execute(NdbTransaction::NoCommit, NdbOperation::AO_IgnoreError, thd_ndb->m_force_send)) { - thd_ndb->m_unsent_bytes= 0; DBUG_RETURN(-1); } - thd_ndb->m_unsent_bytes= 0; if (!ignore_no_key || trans->getNdbError().code == 0) DBUG_RETURN(trans->getNdbError().code); - DBUG_RETURN(check_completed_operations_pre_commit(thd_ndb, trans, first, + DBUG_RETURN(check_completed_operations_pre_commit(thd_ndb, trans, + first, last, ignore_count)); } @@ -775,25 +800,25 @@ int execute_commit(Thd_ndb *thd_ndb, Ndb ao= NdbOperation::AbortOnError; } const NdbOperation *first= trans->getFirstDefinedOperation(); + const NdbOperation *last= trans->getLastDefinedOperation(); thd_ndb->m_execute_count++; + thd_ndb->m_conflict_fn_usage_count= 0; + thd_ndb->m_unsent_bytes= 0; DBUG_PRINT("info", ("execute_count: %u", thd_ndb->m_execute_count)); if (trans->execute(NdbTransaction::Commit, ao, force_send)) { thd_ndb->m_max_violation_count= 0; thd_ndb->m_old_violation_count= 0; - thd_ndb->m_conflict_fn_usage_count= 0; - thd_ndb->m_unsent_bytes= 0; DBUG_RETURN(-1); } g_ndb_status_conflict_fn_max+= thd_ndb->m_max_violation_count; g_ndb_status_conflict_fn_old+= thd_ndb->m_old_violation_count; thd_ndb->m_max_violation_count= 0; thd_ndb->m_old_violation_count= 0; - thd_ndb->m_conflict_fn_usage_count= 0; - thd_ndb->m_unsent_bytes= 0; if (!ignore_error || trans->getNdbError().code == 0) DBUG_RETURN(trans->getNdbError().code); - DBUG_RETURN(check_completed_operations(thd_ndb, trans, first, ignore_count)); + DBUG_RETURN(check_completed_operations(thd_ndb, trans, first, last, + ignore_count)); } inline @@ -3309,12 +3334,6 @@ int ha_ndbcluster::ordered_index_scan(co if (m_active_cursor && (error= close_scan())) DBUG_RETURN(error); - if (m_thd_ndb->m_unsent_bytes) - { - if ((error = flush_bulk_insert()) != 0) - DBUG_RETURN(error); - } - const NdbOperation::LockMode lm = get_ndb_lock_mode(m_lock.type); NdbScanOperation::ScanOptions options; @@ -3433,12 +3452,6 @@ int ha_ndbcluster::full_table_scan(const DBUG_ENTER("full_table_scan"); DBUG_PRINT("enter", ("Starting new scan on %s", m_tabname)); - if (m_thd_ndb->m_unsent_bytes) - { - if ((error = flush_bulk_insert()) != 0) - DBUG_RETURN(error); - } - if (m_use_partition_pruning && m_user_defined_partitioning) { part_spec.start_part= 0; @@ -4419,6 +4432,8 @@ int ha_ndbcluster::exec_bulk_update(uint no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(m_thd_ndb->trans)); } + assert(m_rows_changed >= ignore_count); + assert(m_rows_updated >= ignore_count); m_rows_changed-= ignore_count; m_rows_updated-= ignore_count; } @@ -4491,7 +4506,8 @@ int ha_ndbcluster::ndb_update_row(const have_pk && bitmap_is_overlapping(table->write_set, m_pk_bitmap_p) && primary_key_cmp(old_data, new_data)); - bool batch_allowed= is_bulk_update || thd_allow_batch(thd); + bool batch_allowed= !m_update_cannot_batch && + (is_bulk_update || thd_allow_batch(thd)); NdbOperation::SetValueSpec sets[1]; DBUG_ENTER("ndb_update_row"); @@ -4719,9 +4735,14 @@ int ha_ndbcluster::ndb_update_row(const } else if (blob_count > 0) m_blobs_pending= TRUE; - - m_rows_changed+= 1 - ignore_count; - m_rows_updated+= 1 - ignore_count; + + m_rows_changed++; + m_rows_updated++; + + assert(m_rows_changed >= ignore_count); + assert(m_rows_updated >= ignore_count); + m_rows_changed-= ignore_count; + m_rows_updated-= ignore_count; DBUG_RETURN(0); } @@ -4759,6 +4780,7 @@ int ha_ndbcluster::end_bulk_delete() no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(m_thd_ndb->trans)); } + assert(m_rows_deleted >= ignore_count); m_rows_deleted-= ignore_count; } m_is_bulk_delete = false; @@ -4780,7 +4802,9 @@ int ha_ndbcluster::ndb_delete_row(const const NdbOperation *op; uint32 part_id= ~uint32(0); int error; - bool allow_batch= m_is_bulk_delete || thd_allow_batch(thd); + bool allow_batch= !m_delete_cannot_batch && + (m_is_bulk_delete || thd_allow_batch(thd)); + DBUG_ENTER("ndb_delete_row"); DBUG_ASSERT(trans); @@ -4850,11 +4874,11 @@ int ha_ndbcluster::ndb_delete_row(const thd_ndb->m_unsent_bytes+= 12; no_uncommitted_rows_update(-1); + m_rows_deleted++; if (!(primary_key_update || m_delete_cannot_batch)) { // If deleting from cursor, NoCommit will be handled in next_result - m_rows_deleted++; DBUG_RETURN(0); } } @@ -4923,6 +4947,7 @@ int ha_ndbcluster::ndb_delete_row(const ERR_RETURN(trans->getNdbError()); no_uncommitted_rows_update(-1); + m_rows_deleted++; /* Check if we can batch the delete. @@ -4950,7 +4975,6 @@ int ha_ndbcluster::ndb_delete_row(const !primary_key_update && !need_flush) { - m_rows_deleted++; DBUG_RETURN(0); } } @@ -4965,7 +4989,10 @@ int ha_ndbcluster::ndb_delete_row(const DBUG_RETURN(ndb_err(trans)); } if (!primary_key_update) - m_rows_deleted+= 1 - ignore_count; + { + assert(m_rows_deleted >= ignore_count); + m_rows_deleted-= ignore_count; + } DBUG_RETURN(0); } @@ -6805,11 +6832,15 @@ int ndbcluster_commit(handlerton *hton, char buff[ STRING_BUFFER_USUAL_SIZE ]; const char* msg= NULL; if (thd->lex->sql_command == SQLCOM_DELETE) + { + assert(thd_ndb->m_handler->m_rows_deleted >= ignore_count); affected= (thd_ndb->m_handler->m_rows_deleted-= ignore_count); + } else { DBUG_PRINT("info", ("Update : message was %s", thd->main_da.message())); + assert(thd_ndb->m_handler->m_rows_updated >= ignore_count); affected= (thd_ndb->m_handler->m_rows_updated-= ignore_count); /* For update in this scenario, we set found and changed to be * the same as affected @@ -11766,12 +11797,6 @@ ha_ndbcluster::read_multi_range_first(KE DBUG_ENTER("ha_ndbcluster::read_multi_range_first"); DBUG_PRINT("info", ("blob fields=%d read_set=0x%x", table_share->blob_fields, table->read_set->bitmap[0])); - if (m_thd_ndb->m_unsent_bytes) - { - if ((error = flush_bulk_insert()) != 0) - DBUG_RETURN(error); - } - /** * blobs and unique hash index with NULL can't be batched currently */ No bundle (reason: useless for push emails).