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

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-bug-509803
Merge into: lp:pbxt
Diff against target: 143 lines (+49/-9)
6 files modified
ChangeLog (+2/-1)
src/datadic_xt.cc (+4/-6)
src/datadic_xt.h (+0/-1)
src/myxt_xt.cc (+1/-1)
test/mysql-test/r/pbxt_bugs.result (+20/-0)
test/mysql-test/t/pbxt_bugs.test (+22/-0)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-bug-509803
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+19188@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

Fixed a problem in the myxt_create_foreign_key_from_row function. It incorrectly calculated resulting key length which could lead to incorrect inter-table key comparison and false key change detections within a single table. Also perfromaed refactoring: removed XT_KEY_ACTION_DEFAULT that was functionally identical to XT_KEY_ACTION_RESTRICT.

lp:~vkolesnikov/pbxt/pbxt-bug-509803 updated
787. By Vladimir Kolesnikov

updated ChangeLog

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2010-02-11 10:11:06 +0000
+++ ChangeLog 2010-02-12 17:39:16 +0000
@@ -3,7 +3,8 @@
33
4------- 1.0.10g RC4 - 2010-02-114------- 1.0.10g RC4 - 2010-02-11
55
6RN306: All tests now run with MySQL 5.1.42.6RN307: Fixed bug #509803: can't run tpcc (cannot compare FKs that rely on indexes of different length)
7RN306: All tests now run with MySQL 5.1.42.
78
8RN305: Fixed a bug that could cause a crash in filesort. The problem was that the return row estimate was incorrect, which caused the result of estimate_rows_upper_bound() to overflow to zero. Row estimate has been changed, and no longer takes into account deleted rows (so the row estimate is now a maximum).9RN305: Fixed a bug that could cause a crash in filesort. The problem was that the return row estimate was incorrect, which caused the result of estimate_rows_upper_bound() to overflow to zero. Row estimate has been changed, and no longer takes into account deleted rows (so the row estimate is now a maximum).
910
1011
=== modified file 'src/datadic_xt.cc'
--- src/datadic_xt.cc 2010-02-05 08:17:33 +0000
+++ src/datadic_xt.cc 2010-02-12 17:39:16 +0000
@@ -1142,8 +1142,8 @@
11421142
1143void XTParseTable::parseReferenceDefinition(XTThreadPtr self, u_int req_cols)1143void XTParseTable::parseReferenceDefinition(XTThreadPtr self, u_int req_cols)
1144{1144{
1145 int on_delete = XT_KEY_ACTION_DEFAULT;1145 int on_delete = XT_KEY_ACTION_RESTRICT;
1146 int on_update = XT_KEY_ACTION_DEFAULT;1146 int on_update = XT_KEY_ACTION_RESTRICT;
1147 char name[XT_IDENTIFIER_NAME_SIZE];1147 char name[XT_IDENTIFIER_NAME_SIZE];
1148 char parent_name[XT_IDENTIFIER_NAME_SIZE];1148 char parent_name[XT_IDENTIFIER_NAME_SIZE];
1149 u_int cols = 0;1149 u_int cols = 0;
@@ -2145,7 +2145,7 @@
2145 }2145 }
2146 xt_sb_concat(self, sb, "`)");2146 xt_sb_concat(self, sb, "`)");
2147 2147
2148 if (fk_on_delete != XT_KEY_ACTION_DEFAULT && fk_on_delete != XT_KEY_ACTION_RESTRICT) {2148 if (fk_on_delete != XT_KEY_ACTION_RESTRICT) {
2149 xt_sb_concat(self, sb, " ON DELETE ");2149 xt_sb_concat(self, sb, " ON DELETE ");
2150 switch (fk_on_delete) {2150 switch (fk_on_delete) {
2151 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;2151 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;
@@ -2154,10 +2154,9 @@
2154 case XT_KEY_ACTION_NO_ACTION: xt_sb_concat(self, sb, "NO ACTION"); break;2154 case XT_KEY_ACTION_NO_ACTION: xt_sb_concat(self, sb, "NO ACTION"); break;
2155 }2155 }
2156 }2156 }
2157 if (fk_on_update != XT_KEY_ACTION_DEFAULT && fk_on_update != XT_KEY_ACTION_RESTRICT) {2157 if (fk_on_update != XT_KEY_ACTION_RESTRICT) {
2158 xt_sb_concat(self, sb, " ON UPDATE ");2158 xt_sb_concat(self, sb, " ON UPDATE ");
2159 switch (fk_on_update) {2159 switch (fk_on_update) {
2160 case XT_KEY_ACTION_DEFAULT: xt_sb_concat(self, sb, "RESTRICT"); break;
2161 case XT_KEY_ACTION_RESTRICT: xt_sb_concat(self, sb, "RESTRICT"); break;2160 case XT_KEY_ACTION_RESTRICT: xt_sb_concat(self, sb, "RESTRICT"); break;
2162 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;2161 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;
2163 case XT_KEY_ACTION_SET_NULL: xt_sb_concat(self, sb, "SET NULL"); break;2162 case XT_KEY_ACTION_SET_NULL: xt_sb_concat(self, sb, "SET NULL"); break;
@@ -2417,7 +2416,6 @@
2417{2416{
2418 switch (action)2417 switch (action)
2419 {2418 {
2420 case XT_KEY_ACTION_DEFAULT:
2421 case XT_KEY_ACTION_RESTRICT:2419 case XT_KEY_ACTION_RESTRICT:
2422 return "RESTRICT";2420 return "RESTRICT";
2423 case XT_KEY_ACTION_CASCADE:2421 case XT_KEY_ACTION_CASCADE:
24242422
=== modified file 'src/datadic_xt.h'
--- src/datadic_xt.h 2009-07-22 08:31:39 +0000
+++ src/datadic_xt.h 2010-02-12 17:39:16 +0000
@@ -45,7 +45,6 @@
45#define XT_DD_KEY_PRIMARY 245#define XT_DD_KEY_PRIMARY 2
46#define XT_DD_KEY_FOREIGN 346#define XT_DD_KEY_FOREIGN 3
4747
48#define XT_KEY_ACTION_DEFAULT 0
49#define XT_KEY_ACTION_RESTRICT 148#define XT_KEY_ACTION_RESTRICT 1
50#define XT_KEY_ACTION_CASCADE 249#define XT_KEY_ACTION_CASCADE 2
51#define XT_KEY_ACTION_SET_NULL 350#define XT_KEY_ACTION_SET_NULL 3
5251
=== modified file 'src/myxt_xt.cc'
--- src/myxt_xt.cc 2010-01-22 13:24:35 +0000
+++ src/myxt_xt.cc 2010-02-12 17:39:16 +0000
@@ -531,7 +531,7 @@
531 key += length;531 key += length;
532 }532 }
533533
534 return fkey_ind->mi_fix_key ? fkey_ind->mi_key_size : (u_int) (key - start); /* Return keylength */534 return (u_int) (key - start);
535}535}
536536
537/* I may be overcautious here, but can I assume that537/* I may be overcautious here, but can I assume that
538538
=== modified file 'test/mysql-test/r/pbxt_bugs.result'
--- test/mysql-test/r/pbxt_bugs.result 2010-02-02 11:56:39 +0000
+++ test/mysql-test/r/pbxt_bugs.result 2010-02-12 17:39:17 +0000
@@ -1833,3 +1833,23 @@
1833498 Update row 3 Update #497 -> Update #4981833498 Update row 3 Update #497 -> Update #498
1834497 Update row 3 Update #496 -> Update #4971834497 Update row 3 Update #496 -> Update #497
1835496 Update row 3 Update #495 -> Update #4961835496 Update row 3 Update #495 -> Update #496
1836create table t1 (c1 int, c2 int, primary key (c1, c2));
1837insert into t1 values (1,1), (2,2), (3,3);
1838create table t2 (c1 int, c char, primary key(c1));
1839alter table t2 add constraint foreign key (c1) references t1 (c1);
1840insert into t2 (c1) values (1), (2), (3);
1841update t1 set c1 = 4 where c1 = 2;
1842ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (Constraint: `FOREIGN_1`)
1843drop table t2;
1844create table t2 (c1 int, c char, primary key(c1));
1845alter table t2 add constraint foreign key (c1) references t1 (c1) on update cascade;
1846insert into t2 (c1) values (1), (2), (3);
1847update t1 set c1 = 4 where c1 = 2;
1848select * from t2;
1849c1 c
18501 NULL
18513 NULL
18524 NULL
1853update t1 set c1 = 1 where c1 = 4;
1854ERROR 23000: Upholding foreign key constraints for table 't1', entry '1-2', key 1 would lead to a duplicate entry
1855drop table t2, t1;
18361856
=== modified file 'test/mysql-test/t/pbxt_bugs.test'
--- test/mysql-test/t/pbxt_bugs.test 2010-02-02 11:56:39 +0000
+++ test/mysql-test/t/pbxt_bugs.test 2010-02-12 17:39:17 +0000
@@ -1084,6 +1084,28 @@
1084--enable_result_log1084--enable_result_log
1085select * from tb0_logs order by i1 desc limit 5;1085select * from tb0_logs order by i1 desc limit 5;
10861086
1087#
1088# bug 509803: Can't run tpcc (cannot check FKs if they rely on indexes of different length)
1089#
1090
1091create table t1 (c1 int, c2 int, primary key (c1, c2));
1092insert into t1 values (1,1), (2,2), (3,3);
1093create table t2 (c1 int, c char, primary key(c1));
1094alter table t2 add constraint foreign key (c1) references t1 (c1);
1095insert into t2 (c1) values (1), (2), (3);
1096--error 1451
1097update t1 set c1 = 4 where c1 = 2;
1098drop table t2;
1099create table t2 (c1 int, c char, primary key(c1));
1100alter table t2 add constraint foreign key (c1) references t1 (c1) on update cascade;
1101insert into t2 (c1) values (1), (2), (3);
1102update t1 set c1 = 4 where c1 = 2;
1103select * from t2;
1104--error 1557
1105update t1 set c1 = 1 where c1 = 4;
1106drop table t2, t1;
1107
1108
1087--disable_query_log1109--disable_query_log
1088drop trigger tb0_eng2_upd;1110drop trigger tb0_eng2_upd;
1089drop table tb0_eng2, tb0_logs;1111drop table tb0_eng2, tb0_logs;

Subscribers

People subscribed via source and target branches