Merge lp:~dshrews/drizzle/bug562349 into lp:~drizzle-trunk/drizzle/development

Proposed by David Shrewsbury
Status: Merged
Approved by: Brian Aker
Approved revision: 1752
Merged at revision: 1755
Proposed branch: lp:~dshrews/drizzle/bug562349
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 649 lines (+236/-49)
13 files modified
drizzled/function/time/dayofmonth.cc (+14/-3)
drizzled/function/time/dayofyear.cc (+14/-3)
drizzled/function/time/extract.cc (+29/-6)
drizzled/function/time/hour.cc (+21/-4)
drizzled/function/time/last_day.cc (+13/-3)
drizzled/function/time/microsecond.cc (+21/-4)
drizzled/function/time/minute.cc (+21/-4)
drizzled/function/time/month.cc (+14/-3)
drizzled/function/time/quarter.cc (+14/-3)
drizzled/function/time/second.cc (+21/-4)
drizzled/function/time/to_days.cc (+26/-6)
drizzled/function/time/weekday.cc (+14/-3)
drizzled/function/time/year.cc (+14/-3)
To merge this branch: bzr merge lp:~dshrews/drizzle/bug562349
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+35050@code.launchpad.net

Description of the change

Use of String::c_ptr() within the temporal functions seems to be corrupting PBXT row cache because the String points to the cache itself. We make sure a local temporary buffer is used instead for the call to c_ptr().

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
1=== modified file 'drizzled/function/time/dayofmonth.cc'
2--- drizzled/function/time/dayofmonth.cc 2010-02-04 08:14:46 +0000
3+++ drizzled/function/time/dayofmonth.cc 2010-09-09 23:08:47 +0000
4@@ -57,13 +57,19 @@
5 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
6 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
7 String *res= args[0]->val_str(&tmp);
8- if (! temporal.from_string(res->c_ptr(), res->length()))
9+
10+ if (res && (res != &tmp))
11+ {
12+ tmp.copy(*res);
13+ }
14+
15+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
16 {
17 /*
18 * Could not interpret the function argument as a temporal value,
19 * so throw an error and return 0
20 */
21- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
22+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
23 return 0;
24 }
25 }
26@@ -85,7 +91,12 @@
27
28 res= args[0]->val_str(&tmp);
29
30- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
31+ if (res && (res != &tmp))
32+ {
33+ tmp.copy(*res);
34+ }
35+
36+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
37 return 0;
38 }
39 }
40
41=== modified file 'drizzled/function/time/dayofyear.cc'
42--- drizzled/function/time/dayofyear.cc 2010-02-04 08:14:46 +0000
43+++ drizzled/function/time/dayofyear.cc 2010-09-09 23:08:47 +0000
44@@ -58,13 +58,19 @@
45 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
46 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
47 String *res= args[0]->val_str(&tmp);
48- if (! temporal.from_string(res->c_ptr(), res->length()))
49+
50+ if (res && (res != &tmp))
51+ {
52+ tmp.copy(*res);
53+ }
54+
55+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
56 {
57 /*
58 * Could not interpret the function argument as a temporal value,
59 * so throw an error and return 0
60 */
61- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
62+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
63 return 0;
64 }
65 }
66@@ -86,7 +92,12 @@
67
68 res= args[0]->val_str(&tmp);
69
70- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
71+ if (res && (res != &tmp))
72+ {
73+ tmp.copy(*res);
74+ }
75+
76+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
77 return 0;
78 }
79 }
80
81=== modified file 'drizzled/function/time/extract.cc'
82--- drizzled/function/time/extract.cc 2010-02-04 08:14:46 +0000
83+++ drizzled/function/time/extract.cc 2010-09-09 23:08:47 +0000
84@@ -113,13 +113,19 @@
85 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
86 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
87 String *res= args[0]->val_str(&tmp);
88- if (! datetime_temporal.from_string(res->c_ptr(), res->length()))
89+
90+ if (res && (res != &tmp))
91+ {
92+ tmp.copy(*res);
93+ }
94+
95+ if (! datetime_temporal.from_string(tmp.c_ptr(), tmp.length()))
96 {
97 /*
98 * Could not interpret the function argument as a temporal value,
99 * so throw an error and return 0
100 */
101- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
102+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
103 return 0;
104 }
105 }
106@@ -141,7 +147,12 @@
107
108 res= args[0]->val_str(&tmp);
109
110- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
111+ if (res && (res != &tmp))
112+ {
113+ tmp.copy(*res);
114+ }
115+
116+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
117 return 0;
118 }
119 }
120@@ -172,7 +183,13 @@
121 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
122 String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
123 String *time_res= args[0]->val_str(&tmp_time);
124- if (! time_temporal.from_string(time_res->c_ptr(), time_res->length()))
125+
126+ if (time_res && (time_res != &tmp_time))
127+ {
128+ tmp_time.copy(*time_res);
129+ }
130+
131+ if (! time_temporal.from_string(tmp_time.c_ptr(), tmp_time.length()))
132 {
133 /*
134 * OK, we failed to match the first argument as a string
135@@ -197,13 +214,19 @@
136 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
137 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
138 String *res= args[0]->val_str(&tmp);
139- if (! datetime_temporal.from_string(res->c_ptr(), res->length()))
140+
141+ if (res && (res != &tmp))
142+ {
143+ tmp.copy(*res);
144+ }
145+
146+ if (! datetime_temporal.from_string(tmp.c_ptr(), tmp.length()))
147 {
148 /*
149 * Could not interpret the function argument as a temporal value,
150 * so throw an error and return 0
151 */
152- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
153+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
154 return 0;
155 }
156 }
157
158=== modified file 'drizzled/function/time/hour.cc'
159--- drizzled/function/time/hour.cc 2010-02-04 08:14:46 +0000
160+++ drizzled/function/time/hour.cc 2010-09-09 23:08:47 +0000
161@@ -57,7 +57,13 @@
162 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
163 String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
164 String *time_res= args[0]->val_str(&tmp_time);
165- if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
166+
167+ if (time_res && (time_res != &tmp_time))
168+ {
169+ tmp_time.copy(*time_res);
170+ }
171+
172+ if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
173 {
174 /*
175 * OK, we failed to match the first argument as a string
176@@ -83,13 +89,19 @@
177 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
178 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
179 String *res= args[0]->val_str(&tmp);
180- if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
181+
182+ if (res && (res != &tmp))
183+ {
184+ tmp.copy(*res);
185+ }
186+
187+ if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
188 {
189 /*
190 * Could not interpret the function argument as a temporal value,
191 * so throw an error and return 0
192 */
193- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
194+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
195 return 0;
196 }
197 }
198@@ -111,7 +123,12 @@
199
200 res= args[0]->val_str(&tmp);
201
202- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
203+ if (res && (res != &tmp))
204+ {
205+ tmp.copy(*res);
206+ }
207+
208+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
209 return 0;
210 }
211 }
212
213=== modified file 'drizzled/function/time/last_day.cc'
214--- drizzled/function/time/last_day.cc 2010-02-04 08:14:46 +0000
215+++ drizzled/function/time/last_day.cc 2010-09-09 23:08:47 +0000
216@@ -78,13 +78,18 @@
217 return false;
218 }
219
220- if (! temporal.from_string(res->c_ptr(), res->length()))
221+ if (res != &tmp)
222+ {
223+ tmp.copy(*res);
224+ }
225+
226+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
227 {
228 /*
229 * Could not interpret the function argument as a temporal value,
230 * so throw an error and return 0
231 */
232- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
233+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
234 return false;
235 }
236 }
237@@ -116,7 +121,12 @@
238 return false;
239 }
240
241- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
242+ if (res != &tmp)
243+ {
244+ tmp.copy(*res);
245+ }
246+
247+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
248 return false;
249 }
250 }
251
252=== modified file 'drizzled/function/time/microsecond.cc'
253--- drizzled/function/time/microsecond.cc 2010-02-04 08:14:46 +0000
254+++ drizzled/function/time/microsecond.cc 2010-09-09 23:08:47 +0000
255@@ -57,7 +57,13 @@
256 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
257 String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
258 String *time_res= args[0]->val_str(&tmp_time);
259- if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
260+
261+ if (time_res && (time_res != &tmp_time))
262+ {
263+ tmp_time.copy(*time_res);
264+ }
265+
266+ if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
267 {
268 /*
269 * OK, we failed to match the first argument as a string
270@@ -83,13 +89,19 @@
271 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
272 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
273 String *res= args[0]->val_str(&tmp);
274- if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
275+
276+ if (res && (res != &tmp))
277+ {
278+ tmp.copy(*res);
279+ }
280+
281+ if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
282 {
283 /*
284 * Could not interpret the function argument as a temporal value,
285 * so throw an error and return 0
286 */
287- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
288+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
289 return 0;
290 }
291 }
292@@ -111,7 +123,12 @@
293
294 res= args[0]->val_str(&tmp);
295
296- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
297+ if (res && (res != &tmp))
298+ {
299+ tmp.copy(*res);
300+ }
301+
302+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
303 return 0;
304 }
305 }
306
307=== modified file 'drizzled/function/time/minute.cc'
308--- drizzled/function/time/minute.cc 2010-02-04 08:14:46 +0000
309+++ drizzled/function/time/minute.cc 2010-09-09 23:08:47 +0000
310@@ -57,7 +57,13 @@
311 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
312 String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
313 String *time_res= args[0]->val_str(&tmp_time);
314- if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
315+
316+ if (time_res && (time_res != &tmp_time))
317+ {
318+ tmp_time.copy(*time_res);
319+ }
320+
321+ if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
322 {
323 /*
324 * OK, we failed to match the first argument as a string
325@@ -83,13 +89,19 @@
326 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
327 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
328 String *res= args[0]->val_str(&tmp);
329- if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
330+
331+ if (res && (res != &tmp))
332+ {
333+ tmp.copy(*res);
334+ }
335+
336+ if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
337 {
338 /*
339 * Could not interpret the function argument as a temporal value,
340 * so throw an error and return 0
341 */
342- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
343+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
344 return 0;
345 }
346 }
347@@ -111,7 +123,12 @@
348
349 res= args[0]->val_str(&tmp);
350
351- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
352+ if (res && (res != &tmp))
353+ {
354+ tmp.copy(*res);
355+ }
356+
357+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
358 return 0;
359 }
360 }
361
362=== modified file 'drizzled/function/time/month.cc'
363--- drizzled/function/time/month.cc 2010-02-04 08:14:46 +0000
364+++ drizzled/function/time/month.cc 2010-09-09 23:08:47 +0000
365@@ -58,13 +58,19 @@
366 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
367 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
368 String *res= args[0]->val_str(&tmp);
369- if (! temporal.from_string(res->c_ptr(), res->length()))
370+
371+ if (res && (res != &tmp))
372+ {
373+ tmp.copy(*res);
374+ }
375+
376+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
377 {
378 /*
379 * Could not interpret the function argument as a temporal value,
380 * so throw an error and return 0
381 */
382- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
383+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
384 return 0;
385 }
386 }
387@@ -86,7 +92,12 @@
388
389 res= args[0]->val_str(&tmp);
390
391- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
392+ if (res && (res != &tmp))
393+ {
394+ tmp.copy(*res);
395+ }
396+
397+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
398 return 0;
399 }
400 }
401
402=== modified file 'drizzled/function/time/quarter.cc'
403--- drizzled/function/time/quarter.cc 2010-02-04 08:14:46 +0000
404+++ drizzled/function/time/quarter.cc 2010-09-09 23:08:47 +0000
405@@ -57,13 +57,19 @@
406 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
407 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
408 String *res= args[0]->val_str(&tmp);
409- if (! temporal.from_string(res->c_ptr(), res->length()))
410+
411+ if (res && (res != &tmp))
412+ {
413+ tmp.copy(*res);
414+ }
415+
416+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
417 {
418 /*
419 * Could not interpret the function argument as a temporal value,
420 * so throw an error and return 0
421 */
422- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
423+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
424 return 0;
425 }
426 }
427@@ -85,7 +91,12 @@
428
429 res= args[0]->val_str(&tmp);
430
431- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
432+ if (res && (res != &tmp))
433+ {
434+ tmp.copy(*res);
435+ }
436+
437+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
438 return 0;
439 }
440 }
441
442=== modified file 'drizzled/function/time/second.cc'
443--- drizzled/function/time/second.cc 2010-02-04 08:14:46 +0000
444+++ drizzled/function/time/second.cc 2010-09-09 23:08:47 +0000
445@@ -56,7 +56,13 @@
446 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
447 String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
448 String *time_res= args[0]->val_str(&tmp_time);
449- if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
450+
451+ if (time_res && (time_res != &tmp_time))
452+ {
453+ tmp_time.copy(*time_res);
454+ }
455+
456+ if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
457 {
458 /*
459 * OK, we failed to match the first argument as a string
460@@ -82,13 +88,19 @@
461 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
462 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
463 String *res= args[0]->val_str(&tmp);
464- if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
465+
466+ if (res && (res != &tmp))
467+ {
468+ tmp.copy(*res);
469+ }
470+
471+ if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
472 {
473 /*
474 * Could not interpret the function argument as a temporal value,
475 * so throw an error and return 0
476 */
477- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
478+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
479 return 0;
480 }
481 }
482@@ -110,7 +122,12 @@
483
484 res= args[0]->val_str(&tmp);
485
486- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
487+ if (res && (res != &tmp))
488+ {
489+ tmp.copy(*res);
490+ }
491+
492+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
493 return 0;
494 }
495 }
496
497=== modified file 'drizzled/function/time/to_days.cc'
498--- drizzled/function/time/to_days.cc 2010-02-04 08:14:46 +0000
499+++ drizzled/function/time/to_days.cc 2010-09-09 23:08:47 +0000
500@@ -82,13 +82,18 @@
501 return false;
502 }
503
504- if (! temporal.from_string(res->c_ptr(), res->length()))
505+ if (res != &tmp)
506+ {
507+ tmp.copy(*res);
508+ }
509+
510+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
511 {
512 /*
513 * Could not interpret the function argument as a temporal value,
514 * so throw an error and return 0
515 */
516- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
517+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
518 return 0;
519 }
520 }
521@@ -120,7 +125,12 @@
522 return false;
523 }
524
525- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
526+ if (res != &tmp)
527+ {
528+ tmp.copy(*res);
529+ }
530+
531+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
532 return 0;
533 }
534 }
535@@ -174,13 +184,18 @@
536 return 0;
537 }
538
539- if (! temporal.from_string(res->c_ptr(), res->length()))
540+ if (res != &tmp)
541+ {
542+ tmp.copy(*res);
543+ }
544+
545+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
546 {
547 /*
548 * Could not interpret the function argument as a temporal value,
549 * so throw an error and return 0
550 */
551- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
552+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
553 return 0;
554 }
555 }
556@@ -212,7 +227,12 @@
557 return 0;
558 }
559
560- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
561+ if (res != &tmp)
562+ {
563+ tmp.copy(*res);
564+ }
565+
566+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
567 return 0;
568 }
569 }
570
571=== modified file 'drizzled/function/time/weekday.cc'
572--- drizzled/function/time/weekday.cc 2010-02-04 08:14:46 +0000
573+++ drizzled/function/time/weekday.cc 2010-09-09 23:08:47 +0000
574@@ -57,13 +57,19 @@
575 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
576 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
577 String *res= args[0]->val_str(&tmp);
578- if (! temporal.from_string(res->c_ptr(), res->length()))
579+
580+ if (res && (res != &tmp))
581+ {
582+ tmp.copy(*res);
583+ }
584+
585+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
586 {
587 /*
588 * Could not interpret the function argument as a temporal value,
589 * so throw an error and return 0
590 */
591- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
592+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
593 return 0;
594 }
595 }
596@@ -85,7 +91,12 @@
597
598 res= args[0]->val_str(&tmp);
599
600- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
601+ if (res && (res != &tmp))
602+ {
603+ tmp.copy(*res);
604+ }
605+
606+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
607 return 0;
608 }
609 }
610
611=== modified file 'drizzled/function/time/year.cc'
612--- drizzled/function/time/year.cc 2010-02-04 08:14:46 +0000
613+++ drizzled/function/time/year.cc 2010-09-09 23:08:47 +0000
614@@ -57,13 +57,19 @@
615 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
616 String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
617 String *res= args[0]->val_str(&tmp);
618- if (! temporal.from_string(res->c_ptr(), res->length()))
619+
620+ if (res && (res != &tmp))
621+ {
622+ tmp.copy(*res);
623+ }
624+
625+ if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
626 {
627 /*
628 * Could not interpret the function argument as a temporal value,
629 * so throw an error and return 0
630 */
631- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
632+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
633 return 0;
634 }
635 }
636@@ -85,7 +91,12 @@
637
638 res= args[0]->val_str(&tmp);
639
640- my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
641+ if (res && (res != &tmp))
642+ {
643+ tmp.copy(*res);
644+ }
645+
646+ my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
647 return 0;
648 }
649 }