Below is the list of changes that have just been committed into a local
5.0 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-18 19:08:37-07:00, igor@stripped +4 -0
Fixed bug #17526: an error 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/view.result@stripped, 2006-07-18 19:08:34-07:00, igor@stripped +33 -0
Added a test case for bug #17526.
mysql-test/t/view.test@stripped, 2006-07-18 19:08:34-07:00, igor@stripped +24 -0
Added a test case for bug #17526.
sql/item_strfunc.cc@stripped, 2006-07-18 19:08:35-07:00, igor@stripped +18 -0
Fixed bug #17526: an error when trying to select from a view
with the TRIM function of two arguments.
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-18 19:08:35-07:00, igor@stripped +4 -0
Fixed bug #17526: an error when trying to select from a view
with the TRIM function of two arguments.
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-5.0-opt
--- 1.274/sql/item_strfunc.cc 2006-07-18 19:08:42 -07:00
+++ 1.275/sql/item_strfunc.cc 2006-07-18 19:08:42 -07:00
@@ -1503,6 +1503,24 @@
}
}
+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(STRING_WITH_LEN(" from "));
+ args[0]->print(str);
+ str->append(')');
+}
+
+
/* Item_func_password */
--- 1.110/sql/item_strfunc.h 2006-07-18 19:08:42 -07:00
+++ 1.111/sql/item_strfunc.h 2006-07-18 19:08:42 -07:00
@@ -233,6 +233,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"; }
};
@@ -243,6 +245,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"; }
};
@@ -253,6 +256,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.165/mysql-test/r/view.result 2006-07-18 19:08:42 -07:00
+++ 1.166/mysql-test/r/view.result 2006-07-18 19:08:42 -07:00
@@ -2774,3 +2774,36 @@
COALESCE(i,j) int(11) YES NULL
DROP VIEW v1;
DROP TABLE t1,t2;
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yady');
+SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+TRIM(BOTH 'y' FROM s)
+adda
+ad
+CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(BOTH 'y' FROM s)
+adda
+ad
+DROP VIEW v1;
+SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+TRIM(LEADING 'y' FROM s)
+adda
+ady
+CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(LEADING 'y' FROM s)
+adda
+ady
+DROP VIEW v1;
+SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+TRIM(TRAILING 'y' FROM s)
+yadda
+yad
+CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(TRAILING 'y' FROM s)
+yadda
+yad
+DROP VIEW v1;
+DROP TABLE t1;
--- 1.150/mysql-test/t/view.test 2006-07-18 19:08:42 -07:00
+++ 1.151/mysql-test/t/view.test 2006-07-18 19:08:42 -07:00
@@ -2643,3 +2643,27 @@
DROP VIEW v1;
DROP TABLE t1,t2;
+
+#
+# Bug #17526: views with TRIM functions
+#
+
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yady');
+
+SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2206) BUG#17526 | igor | 19 Jul |