mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge chilla.local:/home/mydev/mysql-5.0-amain
into chilla.local:/home/mydev/mysql-5.0-axmrg sql/sql_insert.cc: Auto merged
This commit is contained in:
@@ -567,6 +567,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
int error, res;
|
||||
bool transactional_table, joins_freed= FALSE;
|
||||
bool changed;
|
||||
bool was_insert_delayed= (table_list->lock_type == TL_WRITE_DELAYED);
|
||||
uint value_count;
|
||||
ulong counter = 1;
|
||||
ulonglong id;
|
||||
@@ -739,7 +740,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
if (lock_type != TL_WRITE_DELAYED && !thd->prelocked_mode)
|
||||
table->file->start_bulk_insert(values_list.elements);
|
||||
|
||||
thd->no_trans_update.stmt= FALSE;
|
||||
thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES)));
|
||||
@@ -866,14 +866,16 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
|
||||
transactional_table= table->file->has_transactions();
|
||||
|
||||
if ((changed= (info.copied || info.deleted || info.updated)))
|
||||
if ((changed= (info.copied || info.deleted || info.updated)) ||
|
||||
was_insert_delayed)
|
||||
{
|
||||
/*
|
||||
Invalidate the table in the query cache if something changed.
|
||||
For the transactional algorithm to work the invalidation must be
|
||||
before binlog writing and ha_autocommit_or_rollback
|
||||
*/
|
||||
query_cache_invalidate3(thd, table_list, 1);
|
||||
if (changed)
|
||||
query_cache_invalidate3(thd, table_list, 1);
|
||||
if (error <= 0 || !transactional_table)
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
@@ -911,10 +913,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
if (mysql_bin_log.write(&qinfo) && transactional_table)
|
||||
error=1;
|
||||
}
|
||||
if (!transactional_table)
|
||||
thd->no_trans_update.all= TRUE;
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
thd->transaction.all.modified_non_trans_table= TRUE;
|
||||
}
|
||||
}
|
||||
DBUG_ASSERT(transactional_table || !changed ||
|
||||
thd->transaction.stmt.modified_non_trans_table);
|
||||
if (transactional_table)
|
||||
error=ha_autocommit_or_rollback(thd,error);
|
||||
|
||||
@@ -1315,7 +1319,7 @@ static int last_uniq_key(TABLE *table,uint keynr)
|
||||
then both on update triggers will work instead. Similarly both on
|
||||
delete triggers will be invoked if we will delete conflicting records.
|
||||
|
||||
Sets thd->no_trans_update.stmt to TRUE if table which is updated didn't have
|
||||
Sets thd->transaction.stmt.modified_non_trans_table to TRUE if table which is updated didn't have
|
||||
transactions.
|
||||
|
||||
RETURN VALUE
|
||||
@@ -1482,7 +1486,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
goto err;
|
||||
info->deleted++;
|
||||
if (!table->file->has_transactions())
|
||||
thd->no_trans_update.stmt= TRUE;
|
||||
thd->transaction.stmt.modified_non_trans_table= TRUE;
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
@@ -1514,7 +1518,7 @@ ok_or_after_trg_err:
|
||||
if (key)
|
||||
my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH);
|
||||
if (!table->file->has_transactions())
|
||||
thd->no_trans_update.stmt= TRUE;
|
||||
thd->transaction.stmt.modified_non_trans_table= TRUE;
|
||||
DBUG_RETURN(trg_error);
|
||||
|
||||
err:
|
||||
@@ -2794,7 +2798,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
}
|
||||
if (info.handle_duplicates == DUP_UPDATE)
|
||||
table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE);
|
||||
thd->no_trans_update.stmt= FALSE;
|
||||
thd->abort_on_warning= (!info.ignore &&
|
||||
(thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
@@ -2931,7 +2934,8 @@ void select_insert::send_error(uint errcode,const char *err)
|
||||
|
||||
bool select_insert::send_eof()
|
||||
{
|
||||
int error,error2;
|
||||
int error, error2;
|
||||
bool changed, transactional_table= table->file->has_transactions();
|
||||
DBUG_ENTER("select_insert::send_eof");
|
||||
|
||||
error= (!thd->prelocked_mode) ? table->file->end_bulk_insert():0;
|
||||
@@ -2943,12 +2947,14 @@ bool select_insert::send_eof()
|
||||
and ha_autocommit_or_rollback
|
||||
*/
|
||||
|
||||
if (info.copied || info.deleted || info.updated)
|
||||
if (changed= (info.copied || info.deleted || info.updated))
|
||||
{
|
||||
query_cache_invalidate3(thd, table, 1);
|
||||
if (!(table->file->has_transactions() || table->s->tmp_table))
|
||||
thd->no_trans_update.all= TRUE;
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
thd->transaction.all.modified_non_trans_table= TRUE;
|
||||
}
|
||||
DBUG_ASSERT(transactional_table || !changed ||
|
||||
thd->transaction.stmt.modified_non_trans_table);
|
||||
|
||||
if (last_insert_id)
|
||||
thd->insert_id(info.copied ? last_insert_id : 0); // For binary log
|
||||
@@ -2958,7 +2964,7 @@ bool select_insert::send_eof()
|
||||
if (!error)
|
||||
thd->clear_error();
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||
table->file->has_transactions(), FALSE);
|
||||
transactional_table, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error)
|
||||
@@ -2984,6 +2990,7 @@ bool select_insert::send_eof()
|
||||
|
||||
void select_insert::abort()
|
||||
{
|
||||
bool changed, transactional_table;
|
||||
DBUG_ENTER("select_insert::abort");
|
||||
|
||||
if (!table)
|
||||
@@ -2994,6 +3001,7 @@ void select_insert::abort()
|
||||
*/
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
transactional_table= table->file->has_transactions();
|
||||
if (!thd->prelocked_mode)
|
||||
table->file->end_bulk_insert();
|
||||
/*
|
||||
@@ -3002,21 +3010,22 @@ void select_insert::abort()
|
||||
error while inserting into a MyISAM table) we must write to the binlog (and
|
||||
the error code will make the slave stop).
|
||||
*/
|
||||
if ((info.copied || info.deleted || info.updated) &&
|
||||
!table->file->has_transactions())
|
||||
if ((changed= info.copied || info.deleted || info.updated) &&
|
||||
!transactional_table)
|
||||
{
|
||||
if (last_insert_id)
|
||||
thd->insert_id(last_insert_id); // For binary log
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||
table->file->has_transactions(), FALSE);
|
||||
transactional_table, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
if (!table->s->tmp_table)
|
||||
thd->no_trans_update.all= TRUE;
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
thd->transaction.all.modified_non_trans_table= TRUE;
|
||||
}
|
||||
if (info.copied || info.deleted || info.updated)
|
||||
DBUG_ASSERT(transactional_table || !changed || thd->transaction.stmt.modified_non_trans_table);
|
||||
if (changed)
|
||||
{
|
||||
query_cache_invalidate3(thd, table, 1);
|
||||
}
|
||||
@@ -3263,7 +3272,6 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE);
|
||||
if (!thd->prelocked_mode)
|
||||
table->file->start_bulk_insert((ha_rows) 0);
|
||||
thd->no_trans_update.stmt= FALSE;
|
||||
thd->abort_on_warning= (!info.ignore &&
|
||||
(thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
|
Reference in New Issue
Block a user