MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:July 19 2006 7:37pm
Subject:bk commit into 4.1 tree (igor:1.2535) BUG#17526
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-07-19 12:36:55-07:00, igor@stripped +4 -0
  Fixed bug #17526: incorrect print method
  for class Item_func_trim. 
  For 4.1 it caused wrong output for EXPLAIN EXTENDED commands
  if expressions with the TRIM function of two arguments were used.
  For 5.0 it caused an error message when trying to select
  from a view with the TRIM function of two arguments.
  This unexpected error message was due to the fact that the
  print method for the class Item_func_trim was inherited from
  the class Item_func. Yet the TRIM function does not take a list
  of its arguments. Rather it takes the arguments in the form:
    [{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
    [remstr FROM] str

  mysql-test/r/func_str.result@stripped, 2006-07-19 12:36:54-07:00, igor@stripped +28 -0
    Added a test case for bug #17526: uncorrect print method
    for class Item_func_trim.

  mysql-test/t/func_str.test@stripped, 2006-07-19 12:36:54-07:00, igor@stripped +15 -0
    Added a test case for bug #17526: incorrect print method
    for class Item_func_trim.

  sql/item_strfunc.cc@stripped, 2006-07-19 12:36:54-07:00, igor@stripped +17 -0
    Fixed bug #17526: incorrect print method
    for class Item_func_trim.
        
    Added an implementation for the virtual function print
    in the class Item_func_trim.
    The implementation takes into account the fact the TRIM
    function takes the arguments in the following forms:
      [{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
      [remstr FROM] str

  sql/item_strfunc.h@stripped, 2006-07-19 12:36:54-07:00, igor@stripped +4 -0
    Fixed bug #17526: incorrect print method
    for class Item_func_trim.
        
    Added an implementation for the virtual function print
    in the class Item_func_trim.
    Declared a virtual method to return the mode of the TRIM 
    function: LEADING, TRAILING or BOTH.
    Added implementations of this method for Item_func_trim and
    its descendants Item_func_ltrim and Item_func_rtrim.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/mysql-4.1-opt

--- 1.246/sql/item_strfunc.cc	2006-07-19 12:37:00 -07:00
+++ 1.247/sql/item_strfunc.cc	2006-07-19 12:37:00 -07:00
@@ -1444,6 +1444,23 @@
   }
 }
 
+void Item_func_trim::print(String *str)
+{
+  if (arg_count == 1)
+  {
+    Item_func::print(str);
+    return;
+  }
+  str->append(Item_func_trim::func_name());
+  str->append('(');
+  str->append(mode_name());
+  str->append(' ');
+  args[1]->print(str);
+  str->append(" from ",6);
+  args[0]->print(str);
+  str->append(')');
+}
+
 
 /* Item_func_password */
 

--- 1.102/sql/item_strfunc.h	2006-07-19 12:37:00 -07:00
+++ 1.103/sql/item_strfunc.h	2006-07-19 12:37:00 -07:00
@@ -218,6 +218,8 @@
   String *val_str(String *);
   void fix_length_and_dec();
   const char *func_name() const { return "trim"; }
+  void print(String *str);
+  virtual const char *mode_name() const { return "both"; }
 };
 
 
@@ -228,6 +230,7 @@
   Item_func_ltrim(Item *a) :Item_func_trim(a) {}
   String *val_str(String *);
   const char *func_name() const { return "ltrim"; }
+  const char *mode_name() const { return "leading"; }
 };
 
 
@@ -238,6 +241,7 @@
   Item_func_rtrim(Item *a) :Item_func_trim(a) {}
   String *val_str(String *);
   const char *func_name() const { return "rtrim"; }
+  const char *mode_name() const { return "trailing"; }
 };
 
 

--- 1.102/mysql-test/r/func_str.result	2006-07-19 12:37:00 -07:00
+++ 1.103/mysql-test/r/func_str.result	2006-07-19 12:37:00 -07:00
@@ -1036,4 +1036,32 @@
 abc	abc abc
 xyz	xyz xyz
 DROP TABLE t1;
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yaddy');
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+Warnings:
+Note	1003	select test.t1.s AS `s` from test.t1 where (trim(test.t1.s) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+Warnings:
+Note	1003	select test.t1.s AS `s` from test.t1 where (trim(both _latin1'y' from test.t1.s) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+Warnings:
+Note	1003	select test.t1.s AS `s` from test.t1 where (trim(leading _latin1'y' from test.t1.s) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+Warnings:
+Note	1003	select test.t1.s AS `s` from test.t1 where (trim(trailing _latin1'y' from test.t1.s) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+Warnings:
+Note	1003	select test.t1.s AS `s` from test.t1 where (trim(both _latin1'y' from test.t1.s) > _latin1'ab')
+DROP TABLE t1;
 End of 4.1 tests

--- 1.84/mysql-test/t/func_str.test	2006-07-19 12:37:00 -07:00
+++ 1.85/mysql-test/t/func_str.test	2006-07-19 12:37:00 -07:00
@@ -697,5 +697,20 @@
                      INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
 
 DROP TABLE t1;
+
+#
+# Bug#17526: WRONG PRINT for TRIM FUNCTION with two arguments
+#
+
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yaddy');
+
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
+
+DROP TABLE t1;
  
 --echo End of 4.1 tests
Thread
bk commit into 4.1 tree (igor:1.2535) BUG#17526igor19 Jul