Merge lp:~vkolesnikov/pbxt/pbxt-bug-340316 into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-bug-340316
Merge into: lp:pbxt
Diff against target: None lines
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-bug-340316
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+4370@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2009-03-05 15:28:42 +0000
+++ ChangeLog 2009-03-10 17:43:39 +0000
@@ -3,6 +3,10 @@
33
4------- 1.0.08 RC - Not yet released4------- 1.0.08 RC - Not yet released
55
6RN226: Fixed bug #340316: Issue with bigint unsigned auto-increment field
7
8RN225: Fixed bug #308557: UPDATE fails to match all rows in a transactional scenario
9
6RN224: Fixed a deadlock which could occur during table scans.10RN224: Fixed a deadlock which could occur during table scans.
711
8RN223: Index scans now use handles to cache buffers instead of making a copy of the index page. The handles are "copy-on-write".12RN223: Index scans now use handles to cache buffers instead of making a copy of the index page. The handles are "copy-on-write".
913
=== modified file 'src/ha_pbxt.cc'
--- src/ha_pbxt.cc 2009-02-27 09:22:44 +0000
+++ src/ha_pbxt.cc 2009-03-11 11:18:00 +0000
@@ -2065,7 +2065,7 @@
2065 MX_ULONGLONG_T *nb_reserved_values __attribute__((unused)))2065 MX_ULONGLONG_T *nb_reserved_values __attribute__((unused)))
2066{2066{
2067 register XTTableHPtr tab;2067 register XTTableHPtr tab;
2068 MX_ULONGLONG_T nr;2068 MX_ULONGLONG_T nr, nr_plus_inc;
20692069
2070 ASSERT_NS(pb_ex_in_use);2070 ASSERT_NS(pb_ex_in_use);
20712071
@@ -2077,7 +2077,11 @@
2077 nr = offset;2077 nr = offset;
2078 else if (increment > 1 && ((nr - offset) % increment) != 0)2078 else if (increment > 1 && ((nr - offset) % increment) != 0)
2079 nr += increment - ((nr - offset) % increment);2079 nr += increment - ((nr - offset) % increment);
2080 tab->tab_auto_inc = (xtWord8) (nr + increment);2080 nr_plus_inc = nr + increment;
2081 if (table->next_number_field->cmp((const unsigned char *)&nr, (const unsigned char *)&nr_plus_inc) < 0)
2082 tab->tab_auto_inc = (xtWord8) (nr_plus_inc);
2083 else
2084 nr = ~0; /* indicate error to the caller */
2081 xt_spinlock_unlock(&tab->tab_ainc_lock);2085 xt_spinlock_unlock(&tab->tab_ainc_lock);
20822086
2083 *first_value = nr;2087 *first_value = nr;
@@ -2091,25 +2095,34 @@
2091 * insert into t1 values (-1);2095 * insert into t1 values (-1);
2092 * insert into t1 values (NULL);2096 * insert into t1 values (NULL);
2093 */2097 */
2094void ha_pbxt::set_auto_increment(MX_LONGLONG_T nr)2098void ha_pbxt::set_auto_increment(Field *nr)
2095{2099{
2096 register XTTableHPtr tab;2100 register XTTableHPtr tab;
2101 MX_ULONGLONG_T nr_int_val;
2102
2103 nr_int_val = nr->val_int();
2104 tab = pb_open_tab->ot_table;
20972105
2098 tab = pb_open_tab->ot_table;2106 if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) {
2099 if ((MX_LONGLONG_T) tab->tab_auto_inc <= nr) {
2100 xt_spinlock_lock(&tab->tab_ainc_lock);2107 xt_spinlock_lock(&tab->tab_ainc_lock);
2101 if ((MX_LONGLONG_T) tab->tab_auto_inc <= nr && nr > 0)2108
2102 tab->tab_auto_inc = nr + 1;2109 if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) {
2110 MX_ULONGLONG_T nr_int_val_plus_one = nr_int_val + 1;
2111 if (nr->cmp((const unsigned char *)&nr_int_val_plus_one) < 0)
2112 tab->tab_auto_inc = nr_int_val_plus_one;
2113 else
2114 tab->tab_auto_inc = nr_int_val;
2115 }
2103 xt_spinlock_unlock(&tab->tab_ainc_lock);2116 xt_spinlock_unlock(&tab->tab_ainc_lock);
2104 }2117 }
21052118
2106 if (xt_db_auto_increment_mode == 1) {2119 if (xt_db_auto_increment_mode == 1) {
2107 if (nr > (MX_LONGLONG_T) tab->tab_dic.dic_min_auto_inc) {2120 if (nr_int_val > (MX_ULONGLONG_T) tab->tab_dic.dic_min_auto_inc) {
2108 /* Do this every 100 calls: */2121 /* Do this every 100 calls: */
2109#ifdef DEBUG2122#ifdef DEBUG
2110 tab->tab_dic.dic_min_auto_inc = nr + 5;2123 tab->tab_dic.dic_min_auto_inc = nr_int_val + 5;
2111#else2124#else
2112 tab->tab_dic.dic_min_auto_inc = nr + 100;2125 tab->tab_dic.dic_min_auto_inc = nr_int_val + 100;
2113#endif2126#endif
2114 pb_open_tab->ot_thread = xt_get_self();2127 pb_open_tab->ot_thread = xt_get_self();
2115 if (!xt_tab_write_min_auto_inc(pb_open_tab))2128 if (!xt_tab_write_min_auto_inc(pb_open_tab))
@@ -2187,8 +2200,12 @@
2187 table->timestamp_field->set_time();2200 table->timestamp_field->set_time();
21882201
2189 if (table->next_number_field && buf == table->record[0]) {2202 if (table->next_number_field && buf == table->record[0]) {
2190 update_auto_increment();2203 int err = update_auto_increment();
2191 set_auto_increment(table->next_number_field->val_int());2204 if (err) {
2205 ha_log_pbxt_thread_error_for_mysql(pb_ignore_dup_key);
2206 return err;
2207 }
2208 set_auto_increment(table->next_number_field);
2192 }2209 }
21932210
2194 if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf))2211 if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf))
@@ -2281,8 +2298,8 @@
22812298
2282 old_map = mx_tmp_use_all_columns(table, table->read_set);2299 old_map = mx_tmp_use_all_columns(table, table->read_set);
2283 nr = table->found_next_number_field->val_int();2300 nr = table->found_next_number_field->val_int();
2301 set_auto_increment(table->found_next_number_field);
2284 mx_tmp_restore_column_map(table, old_map);2302 mx_tmp_restore_column_map(table, old_map);
2285 set_auto_increment(nr);
2286 }2303 }
22872304
2288 if (!xt_tab_update_record(pb_open_tab, (xtWord1 *) old_data, (xtWord1 *) new_data))2305 if (!xt_tab_update_record(pb_open_tab, (xtWord1 *) old_data, (xtWord1 *) new_data))
22892306
=== modified file 'src/ha_pbxt.h'
--- src/ha_pbxt.h 2008-12-10 20:34:30 +0000
+++ src/ha_pbxt.h 2009-03-10 17:43:39 +0000
@@ -171,7 +171,7 @@
171 MX_ULONGLONG_T nb_desired_values,171 MX_ULONGLONG_T nb_desired_values,
172 MX_ULONGLONG_T *first_value,172 MX_ULONGLONG_T *first_value,
173 MX_ULONGLONG_T *nb_reserved_values);173 MX_ULONGLONG_T *nb_reserved_values);
174 void set_auto_increment(MX_LONGLONG_T nr);174 void set_auto_increment(Field *nr);
175175
176 int write_row(byte * buf);176 int write_row(byte * buf);
177 int update_row(const byte * old_data, byte * new_data);177 int update_row(const byte * old_data, byte * new_data);
178178
=== modified file 'src/index_xt.cc'
--- src/index_xt.cc 2009-03-06 13:40:00 +0000
+++ src/index_xt.cc 2009-03-10 08:28:54 +0000
@@ -2327,7 +2327,9 @@
2327#endif2327#endif
2328 ASSERT_NS(ot->ot_ind_rhandle);2328 ASSERT_NS(ot->ot_ind_rhandle);
2329 xt_ind_lock_handle(ot->ot_ind_rhandle);2329 xt_ind_lock_handle(ot->ot_ind_rhandle);
2330 if (!ot->ot_ind_state.i_node_ref_size && ot->ot_ind_state.i_item_offset < ot->ot_ind_state.i_total_size) {2330 if (!ot->ot_ind_state.i_node_ref_size &&
2331 ot->ot_ind_state.i_item_offset < ot->ot_ind_state.i_total_size &&
2332 ot->ot_ind_rhandle->ih_cache_reference) {
2331 key_value.sv_key = &ot->ot_ind_rhandle->ih_branch->tb_data[ot->ot_ind_state.i_item_offset];2333 key_value.sv_key = &ot->ot_ind_rhandle->ih_branch->tb_data[ot->ot_ind_state.i_item_offset];
2332 key_value.sv_length = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;2334 key_value.sv_length = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
23332335
23342336
=== modified file 'test/mysql-test/r/pbxt_bugs.result'
--- test/mysql-test/r/pbxt_bugs.result 2008-12-16 13:39:34 +0000
+++ test/mysql-test/r/pbxt_bugs.result 2009-03-11 11:18:00 +0000
@@ -986,3 +986,62 @@
986insert into t1 values ("1");986insert into t1 values ("1");
987insert into t2 values ("1");987insert into t2 values ("1");
988DROP TABLE IF EXISTS t2,t1;988DROP TABLE IF EXISTS t2,t1;
989DROP TABLE IF EXISTS t5;
990CREATE TABLE t5 (
991c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
992c2 BIGINT SIGNED NULL,
993c3 BIGINT SIGNED NOT NULL,
994c4 TINYINT, c5 SMALLINT,
995c6 MEDIUMINT,
996c7 INT,
997c8 INTEGER,
998PRIMARY KEY(c1,c2), UNIQUE INDEX(c3));
999INSERT INTO t5 VALUES
1000(0,-9223372036854775808,1,2,3,4,5,5),
1001(255,-2147483648,6,7,8,9,10,10),
1002(65535,-8388608,11,12,13,14,15,15),
1003(16777215,-32768,16,17,18,19,20,20),
1004(4294967295,-128,21,22,23,24,25,25),
1005(18446744073709551615,9223372036854775807,26,27,28,29,30,30);
1006INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
1007ERROR HY000: Failed to read auto-increment value from storage engine
1008INSERT INTO t5(c2,c3) VALUES(33,34);
1009ERROR HY000: Failed to read auto-increment value from storage engine
1010SELECT * FROM t5;
1011c1 c2 c3 c4 c5 c6 c7 c8
10121 -9223372036854775808 1 2 3 4 5 5
1013255 -2147483648 6 7 8 9 10 10
101465535 -8388608 11 12 13 14 15 15
101516777215 -32768 16 17 18 19 20 20
10164294967295 -128 21 22 23 24 25 25
101718446744073709551615 9223372036854775807 26 27 28 29 30 30
1018DROP TABLE t5;
1019/* same test as above with signed bigint */
1020CREATE TABLE t5 (
1021c1 BIGINT SIGNED NOT NULL AUTO_INCREMENT,
1022c2 BIGINT SIGNED NULL,
1023c3 BIGINT SIGNED NOT NULL,
1024c4 TINYINT, c5 SMALLINT,
1025c6 MEDIUMINT,
1026c7 INT,
1027c8 INTEGER,
1028PRIMARY KEY(c1,c2), UNIQUE INDEX(c3));
1029INSERT INTO t5 VALUES
1030(0,-9223372036854775808,1,2,3,4,5,5),
1031(255,-2147483648,6,7,8,9,10,10),
1032(65535,-8388608,11,12,13,14,15,15),
1033(16777215,-32768,16,17,18,19,20,20),
1034(4294967295,-128,21,22,23,24,25,25),
1035(9223372036854775807,9223372036854775807,26,27,28,29,30,30);
1036INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
1037ERROR HY000: Failed to read auto-increment value from storage engine
1038INSERT INTO t5(c2,c3) VALUES(33,34);
1039ERROR HY000: Failed to read auto-increment value from storage engine
1040SELECT * FROM t5;
1041c1 c2 c3 c4 c5 c6 c7 c8
10421 -9223372036854775808 1 2 3 4 5 5
1043255 -2147483648 6 7 8 9 10 10
104465535 -8388608 11 12 13 14 15 15
104516777215 -32768 16 17 18 19 20 20
10464294967295 -128 21 22 23 24 25 25
10479223372036854775807 9223372036854775807 26 27 28 29 30 30
9891048
=== modified file 'test/mysql-test/t/pbxt_bugs.test'
--- test/mysql-test/t/pbxt_bugs.test 2008-12-16 13:39:34 +0000
+++ test/mysql-test/t/pbxt_bugs.test 2009-03-11 11:18:00 +0000
@@ -807,3 +807,61 @@
807insert into t2 values ("1");807insert into t2 values ("1");
808808
809DROP TABLE IF EXISTS t2,t1;809DROP TABLE IF EXISTS t2,t1;
810
811# bug 340316: Issue with bigint unsigned auto-increment field
812
813--disable_warnings
814DROP TABLE IF EXISTS t5;
815--enable_warnings
816CREATE TABLE t5 (
817 c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
818 c2 BIGINT SIGNED NULL,
819 c3 BIGINT SIGNED NOT NULL,
820 c4 TINYINT, c5 SMALLINT,
821 c6 MEDIUMINT,
822 c7 INT,
823 c8 INTEGER,
824 PRIMARY KEY(c1,c2), UNIQUE INDEX(c3));
825
826INSERT INTO t5 VALUES
827 (0,-9223372036854775808,1,2,3,4,5,5),
828 (255,-2147483648,6,7,8,9,10,10),
829 (65535,-8388608,11,12,13,14,15,15),
830 (16777215,-32768,16,17,18,19,20,20),
831 (4294967295,-128,21,22,23,24,25,25),
832 (18446744073709551615,9223372036854775807,26,27,28,29,30,30);
833
834--error 1467
835INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
836--error 1467
837INSERT INTO t5(c2,c3) VALUES(33,34);
838
839SELECT * FROM t5;
840
841DROP TABLE t5;
842
843/* same test as above with signed bigint */
844CREATE TABLE t5 (
845 c1 BIGINT SIGNED NOT NULL AUTO_INCREMENT,
846 c2 BIGINT SIGNED NULL,
847 c3 BIGINT SIGNED NOT NULL,
848 c4 TINYINT, c5 SMALLINT,
849 c6 MEDIUMINT,
850 c7 INT,
851 c8 INTEGER,
852 PRIMARY KEY(c1,c2), UNIQUE INDEX(c3));
853
854INSERT INTO t5 VALUES
855 (0,-9223372036854775808,1,2,3,4,5,5),
856 (255,-2147483648,6,7,8,9,10,10),
857 (65535,-8388608,11,12,13,14,15,15),
858 (16777215,-32768,16,17,18,19,20,20),
859 (4294967295,-128,21,22,23,24,25,25),
860 (9223372036854775807,9223372036854775807,26,27,28,29,30,30);
861
862--error 1467
863INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
864--error 1467
865INSERT INTO t5(c2,c3) VALUES(33,34);
866
867SELECT * FROM t5;

Subscribers

People subscribed via source and target branches