summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-07-19 11:05:49 -0700
committerunknown <jimw@mysql.com>2005-07-19 11:05:49 -0700
commite9c64ae296457b04bd68945c5de12c369de71b8b (patch)
tree04692d95c000bd65df72b0a4c5c605b71afa5287 /sql/item_strfunc.cc
parent6ae060305541019882bcb60bf086458b010faa45 (diff)
parentabcd8b032cb4afad6640d21e08763349e116da32 (diff)
downloadmariadb-git-e9c64ae296457b04bd68945c5de12c369de71b8b.tar.gz
Merge mysql.com:/home/jimw/my/mysql-4.1-clean
into mysql.com:/home/jimw/my/mysql-5.0-clean extra/perror.c: Auto merged include/my_global.h: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/ps_7ndb.result: Auto merged mysql-test/r/select.result: Auto merged ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged ndb/src/mgmsrv/main.cpp: Auto merged sql/des_key_file.cc: Auto merged sql/field_conv.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged tests/mysql_client_test.c: Auto merged mysql-test/t/select.test: Resolve conflicts scripts/mysqld_safe.sh: Resolve conflict sql/item.cc: Resolve conflict, don't return FIELD_TYPE_BLOB since VARCHAR can be longer in 5.0 than 4.1. sql/log_event.cc: Resolve conflict sql/mysql_priv.h: Resolve conflict sql/mysqld.cc: Remove incorrect fix (merge from 4.1) sql/sql_show.cc: Resolve conflict
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc106
1 files changed, 55 insertions, 51 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 6d519c73b13..eb37609c28e 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -335,19 +335,20 @@ null:
void Item_func_concat::fix_length_and_dec()
{
- max_length=0;
+ ulonglong max_result_length= 0;
if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV))
return;
for (uint i=0 ; i < arg_count ; i++)
- max_length+=args[i]->max_length;
+ max_result_length+= args[i]->max_length;
- if (max_length > MAX_BLOB_WIDTH)
+ if (max_result_length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_result_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) max_result_length;
}
/*
@@ -378,9 +379,6 @@ String *Item_func_des_encrypt::val_str(String *str)
if (arg_count == 1)
{
- /* Make sure LOCK_des_key_file was initialized. */
- init_des_key_file();
-
/* Protect against someone doing FLUSH DES_KEY_FILE */
VOID(pthread_mutex_lock(&LOCK_des_key_file));
keyschedule= des_keyschedule[key_number=des_default_key];
@@ -391,10 +389,6 @@ String *Item_func_des_encrypt::val_str(String *str)
key_number= (uint) args[1]->val_int();
if (key_number > 9)
goto error;
-
- /* Make sure LOCK_des_key_file was initialized. */
- init_des_key_file();
-
VOID(pthread_mutex_lock(&LOCK_des_key_file));
keyschedule= des_keyschedule[key_number];
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
@@ -482,9 +476,6 @@ String *Item_func_des_decrypt::val_str(String *str)
if (!(current_thd->master_access & SUPER_ACL) || key_number > 9)
goto error;
- /* Make sure LOCK_des_key_file was initialized. */
- init_des_key_file();
-
VOID(pthread_mutex_lock(&LOCK_des_key_file));
keyschedule= des_keyschedule[key_number];
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
@@ -658,7 +649,7 @@ null:
void Item_func_concat_ws::fix_length_and_dec()
{
- max_length=0;
+ ulonglong max_result_length;
if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV))
return;
@@ -668,15 +659,16 @@ void Item_func_concat_ws::fix_length_and_dec()
it is done on parser level in sql_yacc.yy
so, (arg_count - 2) is safe here.
*/
- max_length= args[0]->max_length * (arg_count - 2);
+ max_result_length= (ulonglong) args[0]->max_length * (arg_count - 2);
for (uint i=1 ; i < arg_count ; i++)
- max_length+=args[i]->max_length;
+ max_result_length+=args[i]->max_length;
- if (max_length > MAX_BLOB_WIDTH)
+ if (max_result_length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_result_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) max_result_length;
}
@@ -855,18 +847,19 @@ null:
void Item_func_replace::fix_length_and_dec()
{
- max_length=args[0]->max_length;
+ ulonglong max_result_length= args[0]->max_length;
int diff=(int) (args[2]->max_length - args[1]->max_length);
if (diff > 0 && args[1]->max_length)
{ // Calculate of maxreplaces
- uint max_substrs= max_length/args[1]->max_length;
- max_length+= max_substrs * (uint) diff;
+ ulonglong max_substrs= max_result_length/args[1]->max_length;
+ max_result_length+= max_substrs * (uint) diff;
}
- if (max_length > MAX_BLOB_WIDTH)
+ if (max_result_length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_result_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) max_result_length;
if (agg_arg_charsets(collation, args, 3, MY_COLL_CMP_CONV))
return;
@@ -914,18 +907,22 @@ null:
void Item_func_insert::fix_length_and_dec()
{
Item *cargs[2];
+ ulonglong max_result_length;
+
cargs[0]= args[0];
cargs[1]= args[3];
if (agg_arg_charsets(collation, cargs, 2, MY_COLL_ALLOW_CONV))
return;
args[0]= cargs[0];
args[3]= cargs[1];
- max_length=args[0]->max_length+args[3]->max_length;
- if (max_length > MAX_BLOB_WIDTH)
+ max_result_length= ((ulonglong) args[0]->max_length+
+ (ulonglong) args[3]->max_length);
+ if (max_result_length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_result_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) max_result_length;
}
@@ -2001,17 +1998,19 @@ void Item_func_repeat::fix_length_and_dec()
collation.set(args[0]->collation);
if (args[1]->const_item())
{
- max_length=(long) (args[0]->max_length * args[1]->val_int());
- if (max_length >= MAX_BLOB_WIDTH)
+ ulonglong max_result_length= ((ulonglong) args[0]->max_length *
+ args[1]->val_int());
+ if (max_result_length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_result_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) max_result_length;
}
else
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
}
@@ -2066,6 +2065,7 @@ err:
void Item_func_rpad::fix_length_and_dec()
{
Item *cargs[2];
+
cargs[0]= args[0];
cargs[1]= args[2];
if (agg_arg_charsets(collation, cargs, 2, MY_COLL_ALLOW_CONV))
@@ -2074,18 +2074,20 @@ void Item_func_rpad::fix_length_and_dec()
args[2]= cargs[1];
if (args[1]->const_item())
{
- uint32 length= (uint32) args[1]->val_int() * collation.collation->mbmaxlen;
- max_length=max(args[0]->max_length,length);
- if (max_length >= MAX_BLOB_WIDTH)
+ ulonglong length= ((ulonglong) args[1]->val_int() *
+ collation.collation->mbmaxlen);
+ length= max((ulonglong) args[0]->max_length, length);
+ if (length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) length;
}
else
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
}
@@ -2160,18 +2162,20 @@ void Item_func_lpad::fix_length_and_dec()
if (args[1]->const_item())
{
- uint32 length= (uint32) args[1]->val_int() * collation.collation->mbmaxlen;
- max_length=max(args[0]->max_length,length);
- if (max_length >= MAX_BLOB_WIDTH)
+ ulonglong length= ((ulonglong) args[1]->val_int() *
+ collation.collation->mbmaxlen);
+ length= max((ulonglong) args[0]->max_length, length);
+ if (length >= MAX_BLOB_WIDTH)
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
+ max_length= (ulong) length;
}
else
{
- max_length=MAX_BLOB_WIDTH;
- maybe_null=1;
+ max_length= MAX_BLOB_WIDTH;
+ maybe_null= 1;
}
}