Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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
1.2002 05/06/23 22:05:23 bell@stripped +5 -0
stop evaluation constant functions in WHERE (BUG#4663)
sql/item_cmpfunc.cc
1.158 05/06/23 22:03:44 bell@stripped +21 -18
do not evaluate items during view creation
sql/item.h
1.145 05/06/23 22:03:44 bell@stripped +6 -0
support of Item_static_string_func creation
sql/item.cc
1.142 05/06/23 22:03:44 bell@stripped +21 -10
Item_static_string_func creation if it is need
mysql-test/t/view.test
1.74 05/06/23 22:03:44 bell@stripped +15 -0
evaluation constant functions in WHERE (BUG#4663)
mysql-test/r/view.result
1.86 05/06/23 22:03:44 bell@stripped +15 -0
evaluation constant functions in WHERE (BUG#4663)
# 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: bell
# Host: sanja.is.com.ua
# Root: /home/bell/mysql/bk/work-bug6-5.0
--- 1.141/sql/item.cc Wed Jun 22 23:56:00 2005
+++ 1.142/sql/item.cc Thu Jun 23 22:03:44 2005
@@ -616,17 +616,28 @@
uint conv_errors;
String tmp, cstr, *ostr= val_str(&tmp);
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs,
&conv_errors);
- if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(),
- cstr.charset(),
- collation.derivation)))
- {
- /*
- Safe conversion is not possible (or EOM).
- We could not convert a string into the requested character set
- without data loss. The target charset does not cover all the
- characters from the string. Operation cannot be done correctly.
- */
+ if (conv_errors)
return NULL;
+ {
+ const char* func_name= static_string_func();
+ if (func_name)
+ conv= new Item_static_string_func(func_name, cstr.ptr(), cstr.length(),
+ cstr.charset(),
+ collation.derivation);
+ else
+ conv= new Item_string(cstr.ptr(), cstr.length(),
+ cstr.charset(),
+ collation.derivation);
+ if (!conv)
+ {
+ /*
+ Safe conversion is not possible (or EOM).
+ We could not convert a string into the requested character set
+ without data loss. The target charset does not cover all the
+ characters from the string. Operation cannot be done correctly.
+ */
+ return NULL;
+ }
}
conv->str_value.copy();
/* Ensure that no one is going to change the result string */
--- 1.144/sql/item.h Wed Jun 22 23:56:00 2005
+++ 1.145/sql/item.h Thu Jun 23 22:03:44 2005
@@ -1209,6 +1209,11 @@
void print(String *str);
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
+ /*
+ method to detect Item_static_string_func, and made correct item in
+ safe_charset_converter
+ */
+ virtual const char * static_string_func() { return 0; }
};
@@ -1221,6 +1226,7 @@
Derivation dv= DERIVATION_COERCIBLE)
:Item_string(NullS, str, length, cs, dv), func_name(name_par)
{}
+ const char * static_string_func() { return func_name; }
void print(String *str) { str->append(func_name); }
};
--- 1.157/sql/item_cmpfunc.cc Fri Jun 17 22:26:18 2005
+++ 1.158/sql/item_cmpfunc.cc Thu Jun 23 22:03:44 2005
@@ -237,30 +237,33 @@
set_cmp_func();
return;
}
-
- if (args[0]->type() == FIELD_ITEM)
+
+ if (!thd->lex->view_prepare_mode)
{
- Field *field=((Item_field*) args[0])->field;
- if (field->can_be_compared_as_longlong())
+ if (args[0]->type() == FIELD_ITEM)
{
- if (convert_constant_item(thd, field,&args[1]))
+ Field *field=((Item_field*) args[0])->field;
+ if (field->can_be_compared_as_longlong())
{
- cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
- INT_RESULT); // Works for all types.
- return;
+ if (convert_constant_item(thd, field,&args[1]))
+ {
+ cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
+ INT_RESULT); // Works for all types.
+ return;
+ }
}
}
- }
- if (args[1]->type() == FIELD_ITEM /* && !args[1]->const_item() */)
- {
- Field *field=((Item_field*) args[1])->field;
- if (field->can_be_compared_as_longlong())
+ if (args[1]->type() == FIELD_ITEM /* && !args[1]->const_item() */)
{
- if (convert_constant_item(thd, field,&args[0]))
+ Field *field=((Item_field*) args[1])->field;
+ if (field->can_be_compared_as_longlong())
{
- cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
- INT_RESULT); // Works for all types.
- return;
+ if (convert_constant_item(thd, field,&args[0]))
+ {
+ cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
+ INT_RESULT); // Works for all types.
+ return;
+ }
}
}
}
@@ -991,7 +994,7 @@
if (args[0]->type() == FIELD_ITEM)
{
Field *field=((Item_field*) args[0])->field;
- if (field->can_be_compared_as_longlong())
+ if (!thd->lex->view_prepare_mode &&
field->can_be_compared_as_longlong())
{
/*
The following can't be recoded with || as convert_constant_item
--- 1.85/mysql-test/r/view.result Wed Jun 22 08:52:02 2005
+++ 1.86/mysql-test/r/view.result Thu Jun 23 22:03:44 2005
@@ -1831,3 +1831,18 @@
t
01:00
drop view v1;
+create table t1 (a timestamp default now());
+create table t2 (b timestamp default now());
+create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now();
+SHOW CREATE VIEW v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select sql_no_cache `test`.`t1`.`a` AS
`a`,`test`.`t2`.`b` AS `b`,(`test`.`t1`.`a` < now()) AS `t1.a < now()` from
`test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` < now())
+drop view v1;
+drop table t1, t2;
+CREATE TABLE t1 ( a varchar(50) );
+CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER();
+SHOW CREATE VIEW v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select sql_no_cache `test`.`t1`.`a` AS
`a` from `test`.`t1` where (`test`.`t1`.`a` = current_user())
+DROP TABLE t1;
+DROP VIEW v1;
--- 1.73/mysql-test/t/view.test Wed Jun 22 08:42:00 2005
+++ 1.74/mysql-test/t/view.test Thu Jun 23 22:03:44 2005
@@ -1673,3 +1673,18 @@
create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
select * from v1;
drop view v1;
+
+#
+# evaluation constant functions in WHERE (BUG#4663)
+#
+create table t1 (a timestamp default now());
+create table t2 (b timestamp default now());
+create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now();
+SHOW CREATE VIEW v1;
+drop view v1;
+drop table t1, t2;
+CREATE TABLE t1 ( a varchar(50) );
+CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER();
+SHOW CREATE VIEW v1;
+DROP TABLE t1;
+DROP VIEW v1;
| Thread |
|---|
| • bk commit into 5.0 tree (bell:1.2002) BUG#4663 | sanja | 23 Jun |