summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-04-04 16:43:25 +0300
committermonty@mysql.com <>2005-04-04 16:43:25 +0300
commit5ba3f707f773f1f6a5e2c9cb948c03e68d527668 (patch)
tree3ad1b7dadf9b015e59e0f817db58b9dbc155cb5e /sql
parent9616c9a80d6490ac33bc80c3c9444e8d2bf726e5 (diff)
downloadmariadb-git-5ba3f707f773f1f6a5e2c9cb948c03e68d527668.tar.gz
Don't use -lsupc++ with gcc 3.3 and below as this gives linking problems when linking staticly
Fix that mysql.proc works with new VARCHAR fields Give warnings for wrong zero dates
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc10
-rw-r--r--sql/sp.cc33
-rw-r--r--sql/time.cc3
3 files changed, 25 insertions, 21 deletions
diff --git a/sql/item.cc b/sql/item.cc
index b96ba2cdd66..1572efb0f23 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1474,6 +1474,10 @@ double Item_string::val_real()
&error);
if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end)))
{
+ /*
+ We can use str_value.ptr() here as Item_string is gurantee to put an
+ end \0 here.
+ */
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
@@ -4902,7 +4906,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
int intp2= max_length - min(decimals, NOT_FIXED_DEC - 1);
/* can't be overflow because it work only for decimals (no strings) */
int dec_length= max(intp1, intp2) + decimals;
- max_length= max(max_length, max(item_length, dec_length));
+ max_length= max(max_length, (uint) max(item_length, dec_length));
/*
we can't allow decimals to be NOT_FIXED_DEC, to prevent creation
decimal with max precision (see Field_new_decimal constcuctor)
@@ -4929,8 +4933,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
}
maybe_null|= item->maybe_null;
get_full_info(item);
- DBUG_PRINT("info:", ("become type %d len %d, dec %d",
- fld_type, max_length, decimals));
+ DBUG_PRINT("info", ("become type: %d len: %u dec: %u",
+ (int) fld_type, max_length, (uint) decimals));
DBUG_RETURN(FALSE);
}
diff --git a/sql/sp.cc b/sql/sp.cc
index 84169ab8172..23d389cd299 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -64,8 +64,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
enum thr_lock_type ltype, TABLE **tablep, bool *opened)
{
TABLE *table;
- byte key[64+64+1]; // db, name, type
- uint keylen;
+ byte key[NAME_LEN*2+4+1]; // db, name, optional key length type
DBUG_ENTER("db_find_routine_aux");
DBUG_PRINT("enter", ("type: %d name: %*s",
type, name->m_name.length, name->m_name.str));
@@ -78,20 +77,6 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
if (!mysql_proc_table_exists && ltype == TL_READ)
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
- // Put the key used to read the row together
- keylen= name->m_db.length;
- if (keylen > 64)
- keylen= 64;
- memcpy(key, name->m_db.str, keylen);
- memset(key+keylen, (int)' ', 64-keylen); // Pad with space
- keylen= name->m_name.length;
- if (keylen > 64)
- keylen= 64;
- memcpy(key+64, name->m_name.str, keylen);
- memset(key+64+keylen, (int)' ', 64-keylen); // Pad with space
- key[128]= type;
- keylen= sizeof(key);
-
if (thd->lex->proc_table)
table= thd->lex->proc_table->table;
else
@@ -120,8 +105,22 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
}
mysql_proc_table_exists= 1;
+ /*
+ Create key to find row. We have to use field->store() to be able to
+ handle VARCHAR and CHAR fields.
+ Assumption here is that the three first fields in the table are
+ 'db', 'name' and 'type' and the first key is the primary key over the
+ same fields.
+ */
+ table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin);
+ table->field[1]->store(name->m_name.str, name->m_name.length,
+ &my_charset_bin);
+ table->field[2]->store((longlong) type);
+ key_copy(key, table->record[0], table->key_info,
+ table->key_info->key_length);
+
if (table->file->index_read_idx(table->record[0], 0,
- key, keylen,
+ key, table->key_info->key_length,
HA_READ_KEY_EXACT))
{
*tablep= NULL;
diff --git a/sql/time.cc b/sql/time.cc
index 52a2ae13892..a3ec2283860 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -186,6 +186,7 @@ ulong convert_month_to_period(ulong month)
NOTE
See description of str_to_datetime() for more information.
*/
+
timestamp_type
str_to_datetime_with_warn(const char *str, uint length, TIME *l_time,
uint flags)
@@ -199,7 +200,7 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time,
(MODE_INVALID_DATES |
MODE_NO_ZERO_DATE))),
&was_cut);
- if (was_cut)
+ if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR)
make_truncated_value_warning(current_thd, str, length, ts_type, NullS);
return ts_type;
}