Merge lp:~brianaker/drizzle/bug_798959 into lp:~drizzle-trunk/drizzle/development

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: 2367
Merged at revision: 2368
Proposed branch: lp:~brianaker/drizzle/bug_798959
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 494 lines (+112/-46) (has conflicts)
19 files modified
.bzrignore (+1/-0)
drizzled/function/set_user_var.cc (+2/-0)
drizzled/item/boolean.h (+20/-0)
drizzled/item/cmpfunc.cc (+32/-22)
drizzled/item/cmpfunc.h (+7/-4)
drizzled/message.cc (+0/-6)
drizzled/message.h (+0/-1)
drizzled/set_var.cc (+1/-0)
drizzled/signal_handler.cc (+1/-1)
drizzled/sql_string.cc (+2/-2)
drizzled/sql_string.h (+9/-0)
drizzled/sql_yacc.yy (+3/-1)
drizzled/util/backtrace.cc (+2/-3)
drizzled/util/backtrace.h (+3/-1)
plugin/debug/module.cc (+1/-1)
plugin/utility_functions/tests/r/result_type.result (+2/-2)
plugin/utility_functions/tests/r/typeof.result (+2/-2)
tests/suite/regression/r/798959.result (+18/-0)
tests/suite/regression/t/798959.test (+6/-0)
Text conflict in drizzled/item/boolean.h
Text conflict in drizzled/sql_string.h
To merge this branch: bzr merge lp:~brianaker/drizzle/bug_798959
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+68036@code.launchpad.net

Description of the change

Fix for 798959

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 '.bzrignore'
2--- .bzrignore 2011-06-28 21:02:08 +0000
3+++ .bzrignore 2011-07-14 22:36:00 +0000
4@@ -359,3 +359,4 @@
5 drizzled/execute/parser.output
6 drizzled/execute/scanner.cc
7 drizzled/execute/scanner.h
8+plugin/innobase/xtrabackup/drizzlebackup.innobase
9
10=== modified file 'drizzled/function/set_user_var.cc'
11--- drizzled/function/set_user_var.cc 2011-05-28 16:23:09 +0000
12+++ drizzled/function/set_user_var.cc 2011-07-14 22:36:00 +0000
13@@ -144,8 +144,10 @@
14 {
15 save_result.vint= use_result_field ? result_field->val_int() :
16 args[0]->val_int();
17+
18 unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
19 args[0]->unsigned_flag;
20+
21 break;
22 }
23 case STRING_RESULT:
24
25=== modified file 'drizzled/item/boolean.h'
26--- drizzled/item/boolean.h 2011-07-05 09:52:28 +0000
27+++ drizzled/item/boolean.h 2011-07-14 22:36:00 +0000
28@@ -20,6 +20,7 @@
29 #pragma once
30
31 #include <drizzled/item/basic_constant.h>
32+#include <drizzled/util/backtrace.h>
33
34 namespace drizzled {
35 namespace item {
36@@ -48,6 +49,11 @@
37
38 enum Type type() const { return BOOLEAN_ITEM; }
39
40+ Item_result result_type() const
41+ {
42+ return INT_RESULT;
43+ }
44+
45 virtual bool val_bool()
46 {
47 return value;
48@@ -55,6 +61,7 @@
49
50 double val_real()
51 {
52+ call_backtrace();
53 return value ? 1 : 0;
54 }
55
56@@ -66,7 +73,20 @@
57 drizzled::String* val_str(drizzled::String *value_buffer)
58 {
59 value_buffer->realloc(5);
60+<<<<<<< TREE
61 value_buffer->append(value ? "TRUE" : "FALSE");
62+=======
63+
64+ if (value)
65+ {
66+ value_buffer->copy("TRUE", 4, default_charset());
67+ }
68+ else
69+ {
70+ value_buffer->copy("FALSE", 5, default_charset());
71+ }
72+
73+>>>>>>> MERGE-SOURCE
74 return value_buffer;
75 }
76
77
78=== modified file 'drizzled/item/cmpfunc.cc'
79--- drizzled/item/cmpfunc.cc 2011-07-08 21:39:07 +0000
80+++ drizzled/item/cmpfunc.cc 2011-07-14 22:36:00 +0000
81@@ -26,6 +26,7 @@
82 #include <drizzled/cached_item.h>
83 #include <drizzled/check_stack_overrun.h>
84 #include <drizzled/current_session.h>
85+#include <drizzled/display.h>
86 #include <drizzled/error.h>
87 #include <drizzled/internal/my_sys.h>
88 #include <drizzled/item/cache_int.h>
89@@ -33,11 +34,11 @@
90 #include <drizzled/item/int_with_ref.h>
91 #include <drizzled/item/subselect.h>
92 #include <drizzled/session.h>
93+#include <drizzled/sql_lex.h>
94 #include <drizzled/sql_select.h>
95+#include <drizzled/system_variables.h>
96 #include <drizzled/temporal.h>
97 #include <drizzled/time_functions.h>
98-#include <drizzled/sql_lex.h>
99-#include <drizzled/system_variables.h>
100
101 #include <math.h>
102 #include <algorithm>
103@@ -94,7 +95,9 @@
104 for (; item < item_end; item++)
105 {
106 if ((*item)->type() != Item::NULL_ITEM)
107+ {
108 *type= item_store_type(*type, *item, unsigned_flag);
109+ }
110 }
111 }
112
113@@ -2371,8 +2374,7 @@
114 }
115
116
117-void
118-Item_func_if::fix_length_and_dec()
119+void Item_func_if::fix_length_and_dec()
120 {
121 maybe_null= args[1]->maybe_null || args[2]->maybe_null;
122 decimals= max(args[1]->decimals, args[2]->decimals);
123@@ -2397,32 +2399,38 @@
124 }
125 else
126 {
127- agg_result_type(&cached_result_type, args+1, 2);
128+ agg_result_type(&cached_result_type, args +1, 2);
129 if (cached_result_type == STRING_RESULT)
130 {
131- if (agg_arg_charsets(collation, args+1, 2, MY_COLL_ALLOW_CONV, 1))
132+ if (agg_arg_charsets(collation, args +1, 2, MY_COLL_ALLOW_CONV, 1))
133 return;
134 }
135 else
136 {
137 collation.set(&my_charset_bin); // Number
138 }
139- cached_field_type= agg_field_type(args + 1, 2);
140+ cached_field_type= agg_field_type(args +1, 2);
141 }
142
143- if ((cached_result_type == DECIMAL_RESULT )
144- || (cached_result_type == INT_RESULT))
145+ switch (cached_result_type)
146 {
147- int len1= args[1]->max_length - args[1]->decimals
148- - (args[1]->unsigned_flag ? 0 : 1);
149-
150- int len2= args[2]->max_length - args[2]->decimals
151- - (args[2]->unsigned_flag ? 0 : 1);
152-
153- max_length= max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
154- }
155- else
156+ case DECIMAL_RESULT:
157+ case INT_RESULT:
158+ {
159+ int len1= args[1]->max_length -args[1]->decimals -(args[1]->unsigned_flag ? 0 : 1);
160+ int len2= args[2]->max_length -args[2]->decimals -(args[2]->unsigned_flag ? 0 : 1);
161+ max_length= max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
162+ }
163+ break;
164+ case REAL_RESULT:
165+ case STRING_RESULT:
166 max_length= max(args[1]->max_length, args[2]->max_length);
167+ break;
168+
169+ case ROW_RESULT:
170+ assert(0);
171+ break;
172+ }
173 }
174
175
176@@ -2449,8 +2457,8 @@
177 {
178 assert(fixed == 1);
179 Item *arg= args[0]->val_bool() ? args[1] : args[2];
180- int64_t value=arg->val_int();
181- null_value=arg->null_value;
182+ int64_t value= arg->val_int();
183+ null_value= arg->null_value;
184 return value;
185 }
186
187@@ -2459,10 +2467,12 @@
188 {
189 assert(fixed == 1);
190 Item *arg= args[0]->val_bool() ? args[1] : args[2];
191- String *res=arg->val_str(str);
192+ String *res= arg->val_str(str);
193 if (res)
194+ {
195 res->set_charset(collation.collation);
196- null_value=arg->null_value;
197+ }
198+ null_value= arg->null_value;
199 return res;
200 }
201
202
203=== modified file 'drizzled/item/cmpfunc.h'
204--- drizzled/item/cmpfunc.h 2011-07-05 09:52:28 +0000
205+++ drizzled/item/cmpfunc.h 2011-07-14 22:36:00 +0000
206@@ -677,17 +677,20 @@
207
208 class Item_func_if :public Item_func
209 {
210- enum Item_result cached_result_type;
211+ Item_result cached_result_type;
212 enum_field_types cached_field_type;
213+
214 public:
215- Item_func_if(Item *a,Item *b,Item *c)
216- :Item_func(a,b,c), cached_result_type(INT_RESULT)
217+ Item_func_if(Item *a, Item *b, Item *c) :
218+ Item_func(a,b,c),
219+ cached_result_type(INT_RESULT)
220 {}
221+
222 double val_real();
223 int64_t val_int();
224 String *val_str(String *str);
225 type::Decimal *val_decimal(type::Decimal *);
226- enum Item_result result_type () const { return cached_result_type; }
227+ Item_result result_type () const { return cached_result_type; }
228 enum_field_types field_type() const { return cached_field_type; }
229 bool fix_fields(Session *, Item **);
230 void fix_length_and_dec();
231
232=== modified file 'drizzled/message.cc'
233--- drizzled/message.cc 2011-04-03 06:02:00 +0000
234+++ drizzled/message.cc 2011-07-14 22:36:00 +0000
235@@ -207,12 +207,6 @@
236 return NO_ACTION;
237 }
238
239-// This matches SQL standard of using YES/NO not the normal TRUE/FALSE
240-const std::string &type(bool type)
241-{
242- return type ? YES : NO;
243-}
244-
245 const std::string &type(drizzled::message::Table::Index::IndexType type)
246 {
247 switch (type)
248
249=== modified file 'drizzled/message.h'
250--- drizzled/message.h 2011-04-04 21:37:55 +0000
251+++ drizzled/message.h 2011-07-14 22:36:00 +0000
252@@ -42,7 +42,6 @@
253 const std::string &type(const drizzled::message::Table::Field &type);
254 const std::string &type(drizzled::message::Table::Field::FieldType type);
255 const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption type);
256-const std::string &type(bool type);
257 const std::string &type(drizzled::message::Table::Index::IndexType type);
258 const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyMatchOption type);
259 const std::string &type(drizzled::message::Table::TableType type);
260
261=== modified file 'drizzled/set_var.cc'
262--- drizzled/set_var.cc 2011-06-25 13:36:24 +0000
263+++ drizzled/set_var.cc 2011-07-14 22:36:00 +0000
264@@ -70,6 +70,7 @@
265 error|= it->update(session); // Returns 0, -1 or 1
266 }
267 }
268+
269 err:
270 free_underlaid_joins(session, &session->lex().select_lex);
271 return error;
272
273=== modified file 'drizzled/signal_handler.cc'
274--- drizzled/signal_handler.cc 2011-04-20 09:27:49 +0000
275+++ drizzled/signal_handler.cc 2011-07-14 22:36:00 +0000
276@@ -153,7 +153,7 @@
277 "Hope that's ok; if not, decrease some variables in the "
278 "equation.\n\n"));
279
280- drizzled::util::custom_backtrace();
281+ call_backtrace();
282
283 write_core(sig);
284
285
286=== modified file 'drizzled/sql_string.cc'
287--- drizzled/sql_string.cc 2011-07-04 18:16:24 +0000
288+++ drizzled/sql_string.cc 2011-07-14 22:36:00 +0000
289@@ -286,14 +286,14 @@
290
291 void String::append(const char *s,size_t arg_length)
292 {
293- if (!arg_length)
294+ if (arg_length == 0)
295 return;
296
297 /*
298 For an ASCII compatinble string we can just append.
299 */
300 realloc(str_length+arg_length);
301- memcpy(Ptr+str_length,s,arg_length);
302+ memcpy(Ptr +str_length, s, arg_length);
303 str_length+=arg_length;
304 }
305
306
307=== modified file 'drizzled/sql_string.h'
308--- drizzled/sql_string.h 2011-07-04 17:50:09 +0000
309+++ drizzled/sql_string.h 2011-07-14 22:36:00 +0000
310@@ -137,6 +137,7 @@
311 Ptr= str; str_length=Alloced_length=arg_length ; alloced=0;
312 str_charset=cs;
313 }
314+
315 inline void set(const char *str,size_t arg_length, const charset_info_st * const cs)
316 {
317 free();
318@@ -145,6 +146,7 @@
319 str_charset=cs;
320 }
321 void set_ascii(const char *str, size_t arg_length);
322+
323 inline void set_quick(char *str,size_t arg_length, const charset_info_st * const cs)
324 {
325 if (!alloced)
326@@ -153,6 +155,7 @@
327 }
328 str_charset= cs;
329 }
330+
331 void set_int(int64_t num, bool unsigned_flag, const charset_info_st * const cs);
332 void set(int64_t num, const charset_info_st * const cs)
333 { set_int(num, false, cs); }
334@@ -243,7 +246,13 @@
335 void copy(const String&); // Allocate new string
336 void copy(const std::string&, const charset_info_st*); // Allocate new string
337 void copy(const char*, size_t, const charset_info_st*); // Allocate new string
338+<<<<<<< TREE
339 static bool needs_conversion(size_t arg_length, const charset_info_st* cs_from, const charset_info_st* cs_to);
340+=======
341+ static bool needs_conversion(size_t arg_length,
342+ const charset_info_st* cs_from, const charset_info_st* cs_to,
343+ size_t *offset);
344+>>>>>>> MERGE-SOURCE
345 void set_or_copy_aligned(const char *s, size_t arg_length, const charset_info_st*);
346 void copy(const char*s,size_t arg_length, const charset_info_st& csto);
347 void append(const String &s);
348
349=== modified file 'drizzled/sql_yacc.yy'
350--- drizzled/sql_yacc.yy 2011-07-01 18:59:28 +0000
351+++ drizzled/sql_yacc.yy 2011-07-14 22:36:00 +0000
352@@ -2999,7 +2999,9 @@
353 }
354 }
355 | IF '(' expr ',' expr ',' expr ')'
356- { $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
357+ {
358+ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7);
359+ }
360 | KILL_SYM kill_option '(' expr ')'
361 {
362 List<Item> *args= new (YYSession->mem_root) List<Item>;
363
364=== modified file 'drizzled/util/backtrace.cc'
365--- drizzled/util/backtrace.cc 2011-02-17 00:14:13 +0000
366+++ drizzled/util/backtrace.cc 2011-07-14 22:36:00 +0000
367@@ -18,7 +18,6 @@
368 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
369 */
370
371-
372 #include <config.h>
373 #include <drizzled/util/backtrace.h>
374
375@@ -33,14 +32,14 @@
376 #endif // HAVE_BACKTRACE
377 #endif // __GNUC__
378
379-
380 namespace drizzled
381 {
382 namespace util
383 {
384
385-void custom_backtrace(void)
386+void custom_backtrace(const char *file, int line, const char *func)
387 {
388+ std::cerr << std::endl << "call_backtrace() began at " << file << ":" << line << " for " << func << "()" << std::endl;
389 #ifdef __GNUC__
390 #ifdef HAVE_BACKTRACE
391 void *array[50];
392
393=== modified file 'drizzled/util/backtrace.h'
394--- drizzled/util/backtrace.h 2011-03-14 05:40:28 +0000
395+++ drizzled/util/backtrace.h 2011-07-14 22:36:00 +0000
396@@ -22,6 +22,8 @@
397
398 #include <drizzled/visibility.h>
399
400+#define call_backtrace() drizzled::util::custom_backtrace(__FILE__, __LINE__, __func__)
401+
402 namespace drizzled
403 {
404
405@@ -29,7 +31,7 @@
406 {
407
408 DRIZZLED_API
409-void custom_backtrace(void);
410+void custom_backtrace(const char *file, int line, const char *func);
411
412 } /* namespace util */
413 } /* namespace drizzled */
414
415=== modified file 'plugin/debug/module.cc'
416--- plugin/debug/module.cc 2011-02-17 00:14:13 +0000
417+++ plugin/debug/module.cc 2011-07-14 22:36:00 +0000
418@@ -101,7 +101,7 @@
419
420 bool val_bool()
421 {
422- util::custom_backtrace();
423+ call_backtrace();
424 return true;
425 }
426
427
428=== modified file 'plugin/utility_functions/tests/r/result_type.result'
429--- plugin/utility_functions/tests/r/result_type.result 2010-12-30 04:59:36 +0000
430+++ plugin/utility_functions/tests/r/result_type.result 2011-07-14 22:36:00 +0000
431@@ -3,10 +3,10 @@
432 STRING
433 SELECT RESULT_TYPE(FALSE);
434 RESULT_TYPE(FALSE)
435-REAL
436+INTEGER
437 SELECT RESULT_TYPE(TRUE);
438 RESULT_TYPE(TRUE)
439-REAL
440+INTEGER
441 SELECT RESULT_TYPE("");
442 RESULT_TYPE("")
443 STRING
444
445=== modified file 'plugin/utility_functions/tests/r/typeof.result'
446--- plugin/utility_functions/tests/r/typeof.result 2010-12-30 06:23:25 +0000
447+++ plugin/utility_functions/tests/r/typeof.result 2011-07-14 22:36:00 +0000
448@@ -3,10 +3,10 @@
449 DRIZZLE_TYPE_NULL
450 SELECT TYPEOF(FALSE);
451 TYPEOF(FALSE)
452-DRIZZLE_TYPE_DOUBLE
453+DRIZZLE_TYPE_LONGLONG
454 SELECT TYPEOF(TRUE);
455 TYPEOF(TRUE)
456-DRIZZLE_TYPE_DOUBLE
457+DRIZZLE_TYPE_LONGLONG
458 SELECT TYPEOF("");
459 TYPEOF("")
460 DRIZZLE_TYPE_VARCHAR
461
462=== added file 'tests/suite/regression/r/798959.result'
463--- tests/suite/regression/r/798959.result 1970-01-01 00:00:00 +0000
464+++ tests/suite/regression/r/798959.result 2011-07-14 22:36:00 +0000
465@@ -0,0 +1,18 @@
466+SELECT IF(true, result_type(1), 'yes');
467+IF(true, result_type(1), 'yes')
468+INTEGER
469+SELECT IF(true, typeof(1), 'yes');
470+IF(true, typeof(1), 'yes')
471+DRIZZLE_TYPE_LONGLONG
472+SELECT IF(true, result_type(true), 'yes');
473+IF(true, result_type(true), 'yes')
474+INTEGER
475+SELECT IF(true, typeof(true), 'yes');
476+IF(true, typeof(true), 'yes')
477+DRIZZLE_TYPE_LONGLONG
478+SELECT IF(true, true, 'yes');
479+IF(true, true, 'yes')
480+TRUE
481+SELECT IF(true, true, '');
482+IF(true, true, '')
483+TRUE
484
485=== added file 'tests/suite/regression/t/798959.test'
486--- tests/suite/regression/t/798959.test 1970-01-01 00:00:00 +0000
487+++ tests/suite/regression/t/798959.test 2011-07-14 22:36:00 +0000
488@@ -0,0 +1,6 @@
489+SELECT IF(true, result_type(1), 'yes');
490+SELECT IF(true, typeof(1), 'yes');
491+SELECT IF(true, result_type(true), 'yes');
492+SELECT IF(true, typeof(true), 'yes');
493+SELECT IF(true, true, 'yes');
494+SELECT IF(true, true, '');