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
1=== modified file 'ChangeLog'
2--- ChangeLog 2010-02-11 10:11:06 +0000
3+++ ChangeLog 2010-02-12 17:39:16 +0000
4@@ -3,7 +3,8 @@
5
6 ------- 1.0.10g RC4 - 2010-02-11
7
8-RN306: All tests now run with MySQL 5.1.42.
9+RN307: Fixed bug #509803: can't run tpcc (cannot compare FKs that rely on indexes of different length)
10+RN306: All tests now run with MySQL 5.1.42.
11
12 RN305: 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).
13
14
15=== modified file 'src/datadic_xt.cc'
16--- src/datadic_xt.cc 2010-02-05 08:17:33 +0000
17+++ src/datadic_xt.cc 2010-02-12 17:39:16 +0000
18@@ -1142,8 +1142,8 @@
19
20 void XTParseTable::parseReferenceDefinition(XTThreadPtr self, u_int req_cols)
21 {
22- int on_delete = XT_KEY_ACTION_DEFAULT;
23- int on_update = XT_KEY_ACTION_DEFAULT;
24+ int on_delete = XT_KEY_ACTION_RESTRICT;
25+ int on_update = XT_KEY_ACTION_RESTRICT;
26 char name[XT_IDENTIFIER_NAME_SIZE];
27 char parent_name[XT_IDENTIFIER_NAME_SIZE];
28 u_int cols = 0;
29@@ -2145,7 +2145,7 @@
30 }
31 xt_sb_concat(self, sb, "`)");
32
33- if (fk_on_delete != XT_KEY_ACTION_DEFAULT && fk_on_delete != XT_KEY_ACTION_RESTRICT) {
34+ if (fk_on_delete != XT_KEY_ACTION_RESTRICT) {
35 xt_sb_concat(self, sb, " ON DELETE ");
36 switch (fk_on_delete) {
37 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;
38@@ -2154,10 +2154,9 @@
39 case XT_KEY_ACTION_NO_ACTION: xt_sb_concat(self, sb, "NO ACTION"); break;
40 }
41 }
42- if (fk_on_update != XT_KEY_ACTION_DEFAULT && fk_on_update != XT_KEY_ACTION_RESTRICT) {
43+ if (fk_on_update != XT_KEY_ACTION_RESTRICT) {
44 xt_sb_concat(self, sb, " ON UPDATE ");
45 switch (fk_on_update) {
46- case XT_KEY_ACTION_DEFAULT: xt_sb_concat(self, sb, "RESTRICT"); break;
47 case XT_KEY_ACTION_RESTRICT: xt_sb_concat(self, sb, "RESTRICT"); break;
48 case XT_KEY_ACTION_CASCADE: xt_sb_concat(self, sb, "CASCADE"); break;
49 case XT_KEY_ACTION_SET_NULL: xt_sb_concat(self, sb, "SET NULL"); break;
50@@ -2417,7 +2416,6 @@
51 {
52 switch (action)
53 {
54- case XT_KEY_ACTION_DEFAULT:
55 case XT_KEY_ACTION_RESTRICT:
56 return "RESTRICT";
57 case XT_KEY_ACTION_CASCADE:
58
59=== modified file 'src/datadic_xt.h'
60--- src/datadic_xt.h 2009-07-22 08:31:39 +0000
61+++ src/datadic_xt.h 2010-02-12 17:39:16 +0000
62@@ -45,7 +45,6 @@
63 #define XT_DD_KEY_PRIMARY 2
64 #define XT_DD_KEY_FOREIGN 3
65
66-#define XT_KEY_ACTION_DEFAULT 0
67 #define XT_KEY_ACTION_RESTRICT 1
68 #define XT_KEY_ACTION_CASCADE 2
69 #define XT_KEY_ACTION_SET_NULL 3
70
71=== modified file 'src/myxt_xt.cc'
72--- src/myxt_xt.cc 2010-01-22 13:24:35 +0000
73+++ src/myxt_xt.cc 2010-02-12 17:39:16 +0000
74@@ -531,7 +531,7 @@
75 key += length;
76 }
77
78- return fkey_ind->mi_fix_key ? fkey_ind->mi_key_size : (u_int) (key - start); /* Return keylength */
79+ return (u_int) (key - start);
80 }
81
82 /* I may be overcautious here, but can I assume that
83
84=== modified file 'test/mysql-test/r/pbxt_bugs.result'
85--- test/mysql-test/r/pbxt_bugs.result 2010-02-02 11:56:39 +0000
86+++ test/mysql-test/r/pbxt_bugs.result 2010-02-12 17:39:17 +0000
87@@ -1833,3 +1833,23 @@
88 498 Update row 3 Update #497 -> Update #498
89 497 Update row 3 Update #496 -> Update #497
90 496 Update row 3 Update #495 -> Update #496
91+create table t1 (c1 int, c2 int, primary key (c1, c2));
92+insert into t1 values (1,1), (2,2), (3,3);
93+create table t2 (c1 int, c char, primary key(c1));
94+alter table t2 add constraint foreign key (c1) references t1 (c1);
95+insert into t2 (c1) values (1), (2), (3);
96+update t1 set c1 = 4 where c1 = 2;
97+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (Constraint: `FOREIGN_1`)
98+drop table t2;
99+create table t2 (c1 int, c char, primary key(c1));
100+alter table t2 add constraint foreign key (c1) references t1 (c1) on update cascade;
101+insert into t2 (c1) values (1), (2), (3);
102+update t1 set c1 = 4 where c1 = 2;
103+select * from t2;
104+c1 c
105+1 NULL
106+3 NULL
107+4 NULL
108+update t1 set c1 = 1 where c1 = 4;
109+ERROR 23000: Upholding foreign key constraints for table 't1', entry '1-2', key 1 would lead to a duplicate entry
110+drop table t2, t1;
111
112=== modified file 'test/mysql-test/t/pbxt_bugs.test'
113--- test/mysql-test/t/pbxt_bugs.test 2010-02-02 11:56:39 +0000
114+++ test/mysql-test/t/pbxt_bugs.test 2010-02-12 17:39:17 +0000
115@@ -1084,6 +1084,28 @@
116 --enable_result_log
117 select * from tb0_logs order by i1 desc limit 5;
118
119+#
120+# bug 509803: Can't run tpcc (cannot check FKs if they rely on indexes of different length)
121+#
122+
123+create table t1 (c1 int, c2 int, primary key (c1, c2));
124+insert into t1 values (1,1), (2,2), (3,3);
125+create table t2 (c1 int, c char, primary key(c1));
126+alter table t2 add constraint foreign key (c1) references t1 (c1);
127+insert into t2 (c1) values (1), (2), (3);
128+--error 1451
129+update t1 set c1 = 4 where c1 = 2;
130+drop table t2;
131+create table t2 (c1 int, c char, primary key(c1));
132+alter table t2 add constraint foreign key (c1) references t1 (c1) on update cascade;
133+insert into t2 (c1) values (1), (2), (3);
134+update t1 set c1 = 4 where c1 = 2;
135+select * from t2;
136+--error 1557
137+update t1 set c1 = 1 where c1 = 4;
138+drop table t2, t1;
139+
140+
141 --disable_query_log
142 drop trigger tb0_eng2_upd;
143 drop table tb0_eng2, tb0_logs;

Subscribers

People subscribed via source and target branches