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

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

test files were also updated to provide resultset sorting for a previous fix

Revision history for this message
Paul McCullagh (paul-mccullagh) wrote :
Download full text (6.8 KiB)

Hi Vlad,

Just a little optimization:

Could you place:

err = ha_log_pbxt_thread_error_for_mysql(pb_ignore_dup_key);

and

if (err == HA_ERR_FOUND_DUPP_KEY ...

in { ... }

On Mar 19, 2009, at 11:30 AM, Vladimir Kolesnikov wrote:

> Vladimir Kolesnikov has proposed merging lp:~vkolesnikov/pbxt/pbxt-
> bug-313391 into lp:pbxt.
>
> Requested reviews:
> PBXT Core (pbxt-core)
>
> test files were also updated to provide resultset sorting for a
> previous fix
> --
> https://code.launchpad.net/~vkolesnikov/pbxt/pbxt-bug-313391/+merge/
> 4658
> Your team PBXT Core is subscribed to branch lp:pbxt.
> === modified file 'ChangeLog'
> --- ChangeLog 2009-03-17 16:06:29 +0000
> +++ ChangeLog 2009-03-19 10:20:21 +0000
> @@ -3,6 +3,8 @@
>
> ------- 1.0.08 RC - Not yet released
>
> +RN229: Fixed bug #313391: LOAD DATA..REPLACE broken
> +
> RN228: Fixed bug #341115: 'Out of memory' error (a bug in key
> comparison algorithm)
>
> RN227: Changed conflict handling to use spin locks and improve
> efficiency.
>
> === modified file 'src/ha_pbxt.cc'
> --- src/ha_pbxt.cc 2009-03-11 15:38:29 +0000
> +++ src/ha_pbxt.cc 2009-03-19 10:20:21 +0000
> @@ -2211,6 +2211,15 @@
> if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf))
> err = ha_log_pbxt_thread_error_for_mysql(pb_ignore_dup_key);
>
> + /*
> + * This is needed to allow the same row to be updated multiple
> times in case of bulk REPLACE.
> + * This happens during execution of LOAD DATA...REPLACE MySQL
> first tries to INSERT the row
> + * and if it gets dup-key error it tries UPDATE, so the same row
> can be overwriten multiple
> + * times within the same statement
> + */
> + if (err == HA_ERR_FOUND_DUPP_KEY && pb_open_tab->ot_thread-
> >st_is_update)
> + pb_open_tab->ot_thread->st_update_id++;
> +
> return err;
> }
>
>
> === modified file 'test/mysql-test/r/pbxt_bugs.result'
> --- test/mysql-test/r/pbxt_bugs.result 2009-03-17 16:06:29 +0000
> +++ test/mysql-test/r/pbxt_bugs.result 2009-03-19 10:20:21 +0000
> @@ -1071,18 +1071,18 @@
> 1 SIMPLE t2 index NULL c1 4 NULL 16 Using index
> SELECT c1 FROM t2;
> c1
> --2147483648
> +-1
> +-11
> -12
> --11
> +-2
> +-2147483648
> +-3
> +-4
> +-5
> +-6
> +-7
> +-8
> -9
> --8
> --7
> --6
> --5
> --4
> --3
> --2
> --1
> 0
> 10
> 2147483647
> @@ -1090,6 +1090,7 @@
> UPDATE t2 SET c1=-2147483648 WHERE c2 <> 0 ORDER BY c2 LIMIT 2;
> SELECT * FROM t2 WHERE c2 <> 0 ORDER BY c2;
> c1 c2 c3
> +-12 12 12
> -2147483648 1 1
> -2147483648 2 2
> -3 3 3
> @@ -1099,29 +1100,28 @@
> -7 7 7
> -8 8 8
> -9 9 9
> +0 2147483648 15
> 10 10 10
> --12 12 12
> 2147483647 2147483647 16
> -0 2147483648 15
> 2147483647 4294967295 14
> UPDATE t2 SET c1=-2147483648 WHERE c2 >= 0 ORDER BY c2 DESC LIMIT 2;
> SELECT * FROM t2 WHERE c2 >= 0 ORDER BY c2 DESC;
> c1 c2 c3
> +-12 12 12
> +-2147483648 0 13
> +-2147483648 1 1
> +-2147483648 2 2
> +-2147483648 2147483648 15
> -2147483648 4294967295 14
> --2147483648 2147483648 15
> +-3 3 3
> +-4 4 4
> +-5 5 5
> +-6 6 6
> +-7 7 7
> +-8 8 8
> +-9 9 9
> +10 10 10
> 2147483647 2147483647 16
> --12 12 12
> -10 10 10
> --9 9 9
> --8 8 8
> --7 7 7
> --6 6 6
> --5 5 5
> --4 4 4
> --3 3 3
> --2147483648 2 2
> --2147483648 1 1
> --2147483648 0 13
> ...

Read more...

lp:~vkolesnikov/pbxt/pbxt-bug-313391 updated
586. By Vladimir Kolesnikov

an optimization for the previous bug-fix

Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

done

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2009-03-17 16:06:29 +0000
3+++ ChangeLog 2009-03-19 10:20:21 +0000
4@@ -3,6 +3,8 @@
5
6 ------- 1.0.08 RC - Not yet released
7
8+RN229: Fixed bug #313391: LOAD DATA..REPLACE broken
9+
10 RN228: Fixed bug #341115: 'Out of memory' error (a bug in key comparison algorithm)
11
12 RN227: Changed conflict handling to use spin locks and improve efficiency.
13
14=== modified file 'src/ha_pbxt.cc'
15--- src/ha_pbxt.cc 2009-03-11 15:38:29 +0000
16+++ src/ha_pbxt.cc 2009-03-19 10:20:21 +0000
17@@ -2211,6 +2211,15 @@
18 if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf))
19 err = ha_log_pbxt_thread_error_for_mysql(pb_ignore_dup_key);
20
21+ /*
22+ * This is needed to allow the same row to be updated multiple times in case of bulk REPLACE.
23+ * This happens during execution of LOAD DATA...REPLACE MySQL first tries to INSERT the row
24+ * and if it gets dup-key error it tries UPDATE, so the same row can be overwriten multiple
25+ * times within the same statement
26+ */
27+ if (err == HA_ERR_FOUND_DUPP_KEY && pb_open_tab->ot_thread->st_is_update)
28+ pb_open_tab->ot_thread->st_update_id++;
29+
30 return err;
31 }
32
33
34=== modified file 'test/mysql-test/r/pbxt_bugs.result'
35--- test/mysql-test/r/pbxt_bugs.result 2009-03-17 16:06:29 +0000
36+++ test/mysql-test/r/pbxt_bugs.result 2009-03-19 10:20:21 +0000
37@@ -1071,18 +1071,18 @@
38 1 SIMPLE t2 index NULL c1 4 NULL 16 Using index
39 SELECT c1 FROM t2;
40 c1
41--2147483648
42+-1
43+-11
44 -12
45--11
46+-2
47+-2147483648
48+-3
49+-4
50+-5
51+-6
52+-7
53+-8
54 -9
55--8
56--7
57--6
58--5
59--4
60--3
61--2
62--1
63 0
64 10
65 2147483647
66@@ -1090,6 +1090,7 @@
67 UPDATE t2 SET c1=-2147483648 WHERE c2 <> 0 ORDER BY c2 LIMIT 2;
68 SELECT * FROM t2 WHERE c2 <> 0 ORDER BY c2;
69 c1 c2 c3
70+-12 12 12
71 -2147483648 1 1
72 -2147483648 2 2
73 -3 3 3
74@@ -1099,29 +1100,28 @@
75 -7 7 7
76 -8 8 8
77 -9 9 9
78+0 2147483648 15
79 10 10 10
80--12 12 12
81 2147483647 2147483647 16
82-0 2147483648 15
83 2147483647 4294967295 14
84 UPDATE t2 SET c1=-2147483648 WHERE c2 >= 0 ORDER BY c2 DESC LIMIT 2;
85 SELECT * FROM t2 WHERE c2 >= 0 ORDER BY c2 DESC;
86 c1 c2 c3
87+-12 12 12
88+-2147483648 0 13
89+-2147483648 1 1
90+-2147483648 2 2
91+-2147483648 2147483648 15
92 -2147483648 4294967295 14
93--2147483648 2147483648 15
94+-3 3 3
95+-4 4 4
96+-5 5 5
97+-6 6 6
98+-7 7 7
99+-8 8 8
100+-9 9 9
101+10 10 10
102 2147483647 2147483647 16
103--12 12 12
104-10 10 10
105--9 9 9
106--8 8 8
107--7 7 7
108--6 6 6
109--5 5 5
110--4 4 4
111--3 3 3
112--2147483648 2 2
113--2147483648 1 1
114--2147483648 0 13
115 UPDATE t2 SET c1=-2147483648 WHERE c2 <= 3 ORDER BY c2 LIMIT 2;
116 SELECT * FROM t2 WHERE c2 <= 3 ORDER BY c2;
117 c1 c2 c3
118@@ -1143,8 +1143,8 @@
119 UPDATE t2 SET c1=-2147483648 WHERE c2 IN(8,9) ORDER BY c2 DESC LIMIT 2;
120 SELECT * FROM t2 WHERE c2 IN(8,9) ORDER BY c2 DESC;
121 c1 c2 c3
122+-2147483648 8 8
123 -2147483648 9 9
124--2147483648 8 8
125 UPDATE t2 SET c1=-2147483648 WHERE c2 IS NULL ORDER BY c2 LIMIT 2;
126 SELECT * FROM t2 WHERE c2 IS NULL ORDER BY c2;
127 c1 c2 c3
128@@ -1158,19 +1158,19 @@
129 UPDATE t2 SET c1=-2147483648 WHERE c1=-12 OR c2=1;
130 SELECT * FROM t2 WHERE c1=-2147483648;
131 c1 c2 c3
132--2147483648 2147483648 15
133--2147483648 4294967295 14
134--2147483648 6 6
135--2147483648 NULL 11
136 -2147483648 0 13
137+-2147483648 1 1
138 -2147483648 12 12
139--2147483648 7 7
140--2147483648 1 1
141 -2147483648 2 2
142+-2147483648 2147483648 15
143 -2147483648 4 4
144+-2147483648 4294967295 14
145 -2147483648 5 5
146+-2147483648 6 6
147+-2147483648 7 7
148+-2147483648 8 8
149 -2147483648 9 9
150--2147483648 8 8
151+-2147483648 NULL 11
152 SELECT * FROM t2;
153 c1 c2 c3
154 -2147483648 0 13
155@@ -1210,3 +1210,11 @@
156 -3
157 10
158 2147483647
159+DROP TABLE IF EXISTS t1;
160+CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 VARCHAR(255));
161+LOAD DATA LOCAL INFILE 't/load_unique_error1.inc' REPLACE INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (@c1,c2) SET c1 = @c1 % 2;
162+SELECT * FROM t1 ORDER BY c1;
163+c1 c2
164+0 opq
165+1 jkl
166+DROP TABLE t1;
167
168=== modified file 'test/mysql-test/t/pbxt_bugs.test'
169--- test/mysql-test/t/pbxt_bugs.test 2009-03-17 16:06:29 +0000
170+++ test/mysql-test/t/pbxt_bugs.test 2009-03-19 10:20:21 +0000
171@@ -876,31 +876,52 @@
172
173 # make sure it uses index scan
174 EXPLAIN SELECT c1 FROM t2;
175-
176+--sorted_result
177 SELECT c1 FROM t2;
178
179 UPDATE t2 SET c1=-2147483648 WHERE c2 <> 0 ORDER BY c2 LIMIT 2;
180+--sorted_result
181 SELECT * FROM t2 WHERE c2 <> 0 ORDER BY c2;
182 UPDATE t2 SET c1=-2147483648 WHERE c2 >= 0 ORDER BY c2 DESC LIMIT 2;
183+--sorted_result
184 SELECT * FROM t2 WHERE c2 >= 0 ORDER BY c2 DESC;
185 UPDATE t2 SET c1=-2147483648 WHERE c2 <= 3 ORDER BY c2 LIMIT 2;
186+--sorted_result
187 SELECT * FROM t2 WHERE c2 <= 3 ORDER BY c2;
188 UPDATE t2 SET c1=-2147483648 WHERE c2 <=> 4 ORDER BY c2 DESC LIMIT 2;
189+--sorted_result
190 SELECT * FROM t2 WHERE c2 <=> 4 ORDER BY c2;
191 UPDATE t2 SET c1=-2147483648 WHERE c2 BETWEEN 4 AND 7 ORDER BY c2 LIMIT 2;
192+--sorted_result
193 SELECT * FROM t2 WHERE c2 BETWEEN 4 AND 7 ORDER BY c2;
194 UPDATE t2 SET c1=-2147483648 WHERE c2 IN(8,9) ORDER BY c2 DESC LIMIT 2;
195+--sorted_result
196 SELECT * FROM t2 WHERE c2 IN(8,9) ORDER BY c2 DESC;
197 UPDATE t2 SET c1=-2147483648 WHERE c2 IS NULL ORDER BY c2 LIMIT 2;
198+--sorted_result
199 SELECT * FROM t2 WHERE c2 IS NULL ORDER BY c2;
200 UPDATE t2 SET c1=-2147483648 WHERE c2>= 6 AND c2 < 9 ORDER BY c2 LIMIT 2;
201+--sorted_result
202 SELECT * FROM t2 WHERE c2>= 6 AND c2 < 9 ORDER BY c2;
203 UPDATE t2 SET c1=-2147483648 WHERE c1=-12 OR c2=1;
204+--sorted_result
205 SELECT * FROM t2 WHERE c1=-2147483648;
206 --sorted_result
207 SELECT * FROM t2;
208
209 # make sure it uses index scan
210 EXPLAIN SELECT c1 FROM t2;
211-
212-SELECT c1 FROM t2;
213\ No newline at end of file
214+--sorted_result
215+SELECT c1 FROM t2;
216+
217+# bug 313391: LOAD DATA..REPLACE broken
218+
219+--disable_warnings
220+DROP TABLE IF EXISTS t1;
221+--enable_warnings
222+CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 VARCHAR(255));
223+LOAD DATA LOCAL INFILE 't/load_unique_error1.inc' REPLACE INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (@c1,c2) SET c1 = @c1 % 2;
224+--sorted_result
225+SELECT * FROM t1 ORDER BY c1;
226+DROP TABLE t1;
227+

Subscribers

People subscribed via source and target branches