mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.3 into 10.4
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2018, MariaDB Corporation
|
||||
Copyright (c) 2010, 2019, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -885,7 +885,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
{
|
||||
if (duplic != DUP_ERROR || ignore)
|
||||
{
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS &&
|
||||
table->file->ha_rnd_init_with_error(0))
|
||||
goto abort;
|
||||
}
|
||||
/**
|
||||
This is a simple check for the case when the table has a trigger
|
||||
that reads from it, or when the statement invokes a stored function
|
||||
@ -948,7 +953,10 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
{
|
||||
DBUG_PRINT("info", ("iteration %llu", iteration));
|
||||
if (iteration && bulk_parameters_set(thd))
|
||||
goto abort;
|
||||
{
|
||||
error= 1;
|
||||
goto values_loop_end;
|
||||
}
|
||||
|
||||
while ((values= its++))
|
||||
{
|
||||
@ -1105,7 +1113,11 @@ values_loop_end:
|
||||
error=1;
|
||||
}
|
||||
if (duplic != DUP_ERROR || ignore)
|
||||
{
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
|
||||
table->file->ha_rnd_end();
|
||||
}
|
||||
|
||||
transactional_table= table->file->has_transactions();
|
||||
|
||||
@ -1748,6 +1760,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
goto err;
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
|
||||
{
|
||||
DBUG_ASSERT(table->file->inited == handler::RND);
|
||||
if (table->file->ha_rnd_pos(table->record[1],table->file->dup_ref))
|
||||
goto err;
|
||||
}
|
||||
@ -3283,6 +3296,9 @@ bool Delayed_insert::handle_inserts(void)
|
||||
max_rows= ULONG_MAX; // Do as much as possible
|
||||
}
|
||||
|
||||
if (table->file->ha_rnd_init_with_error(0))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
We can't use row caching when using the binary log because if
|
||||
we get a crash, then binary log will contain rows that are not yet
|
||||
@ -3457,6 +3473,8 @@ bool Delayed_insert::handle_inserts(void)
|
||||
}
|
||||
}
|
||||
|
||||
table->file->ha_rnd_end();
|
||||
|
||||
if (WSREP((&thd)))
|
||||
thd_proc_info(&thd, "Insert done");
|
||||
else
|
||||
@ -3758,7 +3776,12 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
|
||||
thd->cuted_fields=0;
|
||||
if (info.ignore || info.handle_duplicates != DUP_ERROR)
|
||||
{
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS &&
|
||||
table->file->ha_rnd_init_with_error(0))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (info.handle_duplicates == DUP_REPLACE &&
|
||||
(!table->triggers || !table->triggers->has_delete_triggers()))
|
||||
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
|
||||
@ -3938,6 +3961,9 @@ bool select_insert::prepare_eof()
|
||||
if (likely(!error) && unlikely(thd->is_error()))
|
||||
error= thd->get_stmt_da()->sql_errno();
|
||||
|
||||
if (info.ignore || info.handle_duplicates != DUP_ERROR)
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
|
||||
table->file->ha_rnd_end();
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
|
||||
@ -4049,6 +4075,11 @@ void select_insert::abort_result_set() {
|
||||
if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
|
||||
table->file->ha_end_bulk_insert();
|
||||
|
||||
if (table->file->inited)
|
||||
table->file->ha_rnd_end();
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
|
||||
/*
|
||||
If at least one row has been inserted/modified and will stay in
|
||||
the table (the table doesn't have transactions) we must write to
|
||||
@ -4464,7 +4495,12 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
|
||||
restore_record(table,s->default_values); // Get empty record
|
||||
thd->cuted_fields=0;
|
||||
if (info.ignore || info.handle_duplicates != DUP_ERROR)
|
||||
{
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS &&
|
||||
table->file->ha_rnd_init_with_error(0))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (info.handle_duplicates == DUP_REPLACE &&
|
||||
(!table->triggers || !table->triggers->has_delete_triggers()))
|
||||
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
|
||||
@ -4656,9 +4692,6 @@ bool select_create::send_eof()
|
||||
*/
|
||||
exit_done= 1; // Avoid double calls
|
||||
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
|
||||
send_ok_packet();
|
||||
|
||||
if (m_plock)
|
||||
@ -4734,13 +4767,6 @@ void select_create::abort_result_set()
|
||||
thd->locked_tables_list.unlock_locked_table(thd,
|
||||
create_info->mdl_ticket);
|
||||
}
|
||||
if (m_plock)
|
||||
{
|
||||
mysql_unlock_tables(thd, *m_plock);
|
||||
*m_plock= NULL;
|
||||
m_plock= NULL;
|
||||
}
|
||||
|
||||
if (table)
|
||||
{
|
||||
bool tmp_table= table->s->tmp_table;
|
||||
@ -4751,9 +4777,21 @@ void select_create::abort_result_set()
|
||||
thd->restore_tmp_table_share(saved_tmp_table_share);
|
||||
}
|
||||
|
||||
if (table->file->inited &&
|
||||
(info.ignore || info.handle_duplicates != DUP_ERROR) &&
|
||||
(table->file->ha_table_flags() & HA_DUPLICATE_POS))
|
||||
table->file->ha_rnd_end();
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
table->auto_increment_field_not_null= FALSE;
|
||||
|
||||
if (m_plock)
|
||||
{
|
||||
mysql_unlock_tables(thd, *m_plock);
|
||||
*m_plock= NULL;
|
||||
m_plock= NULL;
|
||||
}
|
||||
|
||||
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
|
||||
table=0; // Safety
|
||||
if (thd->log_current_statement && mysql_bin_log.is_open())
|
||||
|
Reference in New Issue
Block a user