Commit ddf6c80
Jorgen Loland
Bug#14578060: INNODB: WARNING: USING A PARTIAL-FIELD KEY
PREFIX IN SEARCH
When UPDATE creates a duplicate out of columns defined as unique,
an error is issued. The error message needs info about the column
values to make this error message, and if this info is not
available in the offended index a table read is done through
ha_rnd_pos().
The were multiple problems in this code.
1) the error-creation code in mysql_update() called ha_rnd_pos()
without calling ha_rnd_init() first. This was OK for InnoDB
in MySQL 5.5 because InnoDB noticed it and called
change_active_index() internally. In 5.6 InnoDB no longer
automatically switches index, resulting in this bug report.
2) When doing an UPDATE, InnoDB reads all columns of the row
to update. For this reason, mysql_update() does not even
have to call ha_rnd_pos() to get the info. Furthermore,
MyISAM always reads all rows anyway.
Due to 2), the simplest bug fix would have been to not read
additional columns from the table if the SE is InnoDB. However,
the problem would persist for other SEs. An alternative patch
would be to open another handler that calls
ha_rnd_init();ha_rnd_pos();ha_rnd_end() and is then destroyed,
but it makes more sense to change the contract with the handler
slightly: If ha_update_row() returns duplicate key error, all
columns relevant for the error message must have been read. The
need for an extra ha_rnd_pos() is therefore eliminated.
MyISAM and InnoDB already obeys this new contract. NDB Cluster
(Magnus) has agreed to fix this in their codebase.1 parent 90a04e3 commit ddf6c80
4 files changed
Lines changed: 19 additions & 82 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2990 | 2990 | | |
2991 | 2991 | | |
2992 | 2992 | | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
2993 | 3001 | | |
2994 | 3002 | | |
2995 | 3003 | | |
| |||
3066 | 3074 | | |
3067 | 3075 | | |
3068 | 3076 | | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
3069 | 3082 | | |
3070 | 3083 | | |
3071 | 3084 | | |
3072 | 3085 | | |
3073 | | - | |
3074 | | - | |
3075 | 3086 | | |
3076 | 3087 | | |
3077 | 3088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | 193 | | |
263 | 194 | | |
264 | 195 | | |
| |||
793 | 724 | | |
794 | 725 | | |
795 | 726 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | 727 | | |
801 | 728 | | |
802 | 729 | | |
| |||
895 | 822 | | |
896 | 823 | | |
897 | 824 | | |
898 | | - | |
899 | 825 | | |
900 | 826 | | |
901 | 827 | | |
| |||
932 | 858 | | |
933 | 859 | | |
934 | 860 | | |
935 | | - | |
936 | 861 | | |
937 | 862 | | |
938 | 863 | | |
| |||
993 | 918 | | |
994 | 919 | | |
995 | 920 | | |
996 | | - | |
997 | 921 | | |
998 | 922 | | |
999 | 923 | | |
| |||
2135 | 2059 | | |
2136 | 2060 | | |
2137 | 2061 | | |
2138 | | - | |
2139 | 2062 | | |
2140 | 2063 | | |
2141 | 2064 | | |
| |||
2416 | 2339 | | |
2417 | 2340 | | |
2418 | 2341 | | |
2419 | | - | |
2420 | 2342 | | |
2421 | 2343 | | |
2422 | 2344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4935 | 4935 | | |
4936 | 4936 | | |
4937 | 4937 | | |
4938 | | - | |
| 4938 | + | |
4939 | 4939 | | |
4940 | 4940 | | |
4941 | | - | |
4942 | 4941 | | |
4943 | 4942 | | |
4944 | 4943 | | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
4945 | 4948 | | |
4946 | 4949 | | |
4947 | 4950 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2533 | 2533 | | |
2534 | 2534 | | |
2535 | 2535 | | |
| 2536 | + | |
2536 | 2537 | | |
2537 | 2538 | | |
2538 | 2539 | | |
| |||
0 commit comments