summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2007-11-07 13:25:20 -0500
committerunknown <cmiller@zippy.cornsilk.net>2007-11-07 13:25:20 -0500
commita49d3f018b9562e847578d06766ced772519a333 (patch)
tree4d1fff7efb5c0a6a068b26db4aec58c3c745c9eb /sql
parent75902e8d07fa8ae565183909cc6e6fa0defc58c1 (diff)
parentddeec5ab8dcee15ccedf693b508d7ee9e7e857a9 (diff)
downloadmariadb-git-a49d3f018b9562e847578d06766ced772519a333.tar.gz
Merge mysqldev@production.mysql.com:/data0/mysqldev/my/mysql-5.0-release
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community sql/item_func.cc: Auto merged sql/sql_cache.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc25
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/item_timefunc.cc3
-rw-r--r--sql/sql_cache.cc6
4 files changed, 39 insertions, 8 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 8191d885a27..aa302e54a05 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5272,7 +5272,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
if (!error && (ret != MYSQL_TIMESTAMP_DATE) &&
- thd->count_cuted_fields != CHECK_FIELD_IGNORE)
+ (l_time.hour || l_time.minute || l_time.second || l_time.second_part))
error= 3; // Datetime was cut (note)
}
@@ -5319,10 +5319,16 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
else
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
+ if (!error && l_time.time_type != MYSQL_TIMESTAMP_DATE &&
+ (l_time.hour || l_time.minute || l_time.second || l_time.second_part))
+ error= 3;
+
if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
- WARN_DATA_TRUNCATED,nr,MYSQL_TIMESTAMP_DATE, 1);
+ set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ error == 2 ?
+ ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED,
+ nr,MYSQL_TIMESTAMP_DATE, 1);
int3store(ptr,tmp);
return error;
@@ -5349,6 +5355,17 @@ int Field_newdate::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
}
+ if (!error && ltime->time_type != MYSQL_TIMESTAMP_DATE &&
+ (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
+ {
+ char buff[MAX_DATE_STRING_REP_LENGTH];
+ String str(buff, sizeof(buff), &my_charset_latin1);
+ make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE,
+ WARN_DATA_TRUNCATED,
+ str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
+ error= 3;
+ }
}
else
{
diff --git a/sql/item_func.cc b/sql/item_func.cc
index df3d04c106f..f9331093495 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5583,8 +5583,13 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
#endif /* ! NO_EMBEDDED_ACCESS_CHECKS */
}
+
if (!m_sp->m_chistics->detistic)
- used_tables_cache |= RAND_TABLE_BIT;
+ {
+ used_tables_cache |= RAND_TABLE_BIT;
+ const_item_cache= FALSE;
+ }
+
DBUG_RETURN(res);
}
@@ -5592,6 +5597,10 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
void Item_func_sp::update_used_tables()
{
Item_func::update_used_tables();
+
if (!m_sp->m_chistics->detistic)
- used_tables_cache |= RAND_TABLE_BIT;
+ {
+ used_tables_cache |= RAND_TABLE_BIT;
+ const_item_cache= FALSE;
+ }
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index ae18e4786d7..b9a923fcb0f 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1603,8 +1603,7 @@ bool Item_func_now::get_date(MYSQL_TIME *res,
int Item_func_now::save_in_field(Field *to, bool no_conversions)
{
to->set_notnull();
- to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
- return 0;
+ return to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
}
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 84f715a5a1d..8ca96a2bddc 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1035,12 +1035,14 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Query_cache_block_table *block_table, *block_table_end;
ulong tot_length;
Query_cache_query_flags flags;
+#ifndef __WIN__
const uint spin_treshold= 50000;
const double lock_time_treshold= 0.1; /* Time in seconds */
uint spin_count= 0;
int lock_status= 0;
ulong new_time= 0;
ulong stop_time= 0;
+#endif
DBUG_ENTER("Query_cache::send_result_to_client");
@@ -1088,6 +1090,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
}
}
+#ifdef __WIN__
+ STRUCT_LOCK(&structure_guard_mutex);
+#else
stop_time= my_clock()+(ulong)lock_time_treshold*CLOCKS_PER_SEC;
while ((lock_status= pthread_mutex_trylock(&structure_guard_mutex)) == EBUSY
&& spin_count < spin_treshold
@@ -1110,6 +1115,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
thd->lex->safe_to_cache_query= FALSE;
goto err;
}
+#endif
if (query_cache_size == 0 || flush_in_progress)
{