summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc11
-rw-r--r--sql/field.h7
-rw-r--r--sql/item.cc9
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_insert.cc10
-rw-r--r--sql/sql_select.cc7
6 files changed, 20 insertions, 25 deletions
diff --git a/sql/field.cc b/sql/field.cc
index fc08ce7eb60..4a9487ff7a9 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4587,19 +4587,12 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg,
Field_timestamp::Field_timestamp(bool maybe_null_arg,
const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs)
+ CHARSET_INFO *cs)
:Field_str((char*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, table_arg, cs)
+ NONE, field_name_arg, cs)
{
/* For 4.0 MYD and 4.0 InnoDB compatibility */
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (table && !table->timestamp_field &&
- unireg_check != NONE)
- {
- /* This timestamp has auto-update */
- table->timestamp_field= this;
- flags|=TIMESTAMP_FLAG;
- }
}
diff --git a/sql/field.h b/sql/field.h
index b38c81971e3..3fba0ffbb00 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -793,10 +793,9 @@ public:
Field_timestamp(char *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
- struct st_table *table_arg,
TABLE_SHARE *share, CHARSET_INFO *cs);
Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs);
+ CHARSET_INFO *cs);
enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
enum Item_result cmp_type () const { return INT_RESULT; }
@@ -1148,9 +1147,9 @@ public:
flags|= BLOB_FLAG;
}
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs, bool set_packlength)
+ CHARSET_INFO *cs, bool set_packlength)
:Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, table_arg, cs)
+ NONE, field_name_arg, cs)
{
flags|= BLOB_FLAG;
packlength= 4;
diff --git a/sql/item.cc b/sql/item.cc
index e38142fdb0d..1afe25b1990 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4037,7 +4037,8 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
field= new Field_time(maybe_null, name, &my_charset_bin);
break;
case MYSQL_TYPE_TIMESTAMP:
- return new Field_timestamp(maybe_null, name, table, &my_charset_bin);
+ field= new Field_timestamp(maybe_null, name, &my_charset_bin);
+ break;
case MYSQL_TYPE_DATETIME:
field= new Field_datetime(maybe_null, name, &my_charset_bin);
break;
@@ -4072,10 +4073,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
if (this->type() == Item::TYPE_HOLDER)
- field= new Field_blob(max_length, maybe_null, name, table,
- collation.collation, 1);
+ field= new Field_blob(max_length, maybe_null, name, collation.collation,
+ 1);
else
- field= new Field_blob(max_length, maybe_null, name, table, collation.collation);
+ field= new Field_blob(max_length, maybe_null, name, collation.collation);
break; // Blob handled outside of case
}
if (field)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index e0ad74887f8..7b2fcefe16c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -639,6 +639,7 @@ void THD::cleanup_after_query()
first_successful_insert_id_in_prev_stmt=
first_successful_insert_id_in_cur_stmt;
first_successful_insert_id_in_cur_stmt= 0;
+ substitute_null_with_insert_id= TRUE;
}
arg_of_last_insert_id_function= 0;
/* Free Items that were created during this execution */
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 966fe45e690..fae79ba58c5 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -730,7 +730,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
uint used_fields_buff_size= bitmap_buffer_size(table->s->fields);
uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size);
MY_BITMAP used_fields;
- bool save_set_query_id= thd->set_query_id;
+ enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
DBUG_ENTER("check_key_in_view");
if (!used_fields_buff)
@@ -746,20 +746,20 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
we must not set query_id for fields as they're not
really used in this context
*/
- thd->set_query_id= 0;
+ thd->mark_used_columns= MARK_COLUMNS_NONE;
/* check simplicity and prepare unique test of view */
for (trans= trans_start; trans != trans_end; trans++)
{
if (!trans->item->fixed && trans->item->fix_fields(thd, &trans->item))
{
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
DBUG_RETURN(TRUE);
}
Item_field *field;
/* simple SELECT list entry (field without expression) */
if (!(field= trans->item->filed_for_view_update()))
{
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
DBUG_RETURN(TRUE);
}
if (field->field->unireg_check == Field::NEXT_NUMBER)
@@ -771,7 +771,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
*/
trans->item= field;
}
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
/* unique test */
for (trans= trans_start; trans != trans_end; trans++)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2e86b1e4d24..25887d4f344 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1095,7 +1095,7 @@ JOIN::optimize()
for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
{
Item *item= *tmp_order->item;
- if (item->walk(&Item::is_expensive_processor,(byte*)0))
+ if (item->walk(&Item::is_expensive_processor, 0, (byte*)0))
{
/* Force tmp table without sort */
need_tmp=1; simple_order=simple_group=0;
@@ -7963,7 +7963,8 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
Field *field=((Item_field*) args[0])->field;
if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
(thd->options & OPTION_AUTO_IS_NULL) &&
- (thd->first_successful_insert_id_in_prev_stmt > 0))
+ (thd->first_successful_insert_id_in_prev_stmt > 0 &&
+ thd->substitute_null_with_insert_id))
{
#ifdef HAVE_QUERY_CACHE
query_cache_abort(&thd->net);
@@ -7986,7 +7987,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
IS NULL should be mapped to LAST_INSERT_ID only for first row, so
clear for next row
*/
- thd->first_successful_insert_id_in_prev_stmt= 0;
+ thd->substitute_null_with_insert_id= FALSE;
}
/* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */
else if (((field->type() == FIELD_TYPE_DATE) ||