21
21
#include <drizzled/server_includes.h>
22
22
#include <drizzled/sql_select.h>
23
#include <drizzled/drizzled_error_messages.h>
23
#include <drizzled/error.h>
24
#include <drizzled/probes.h>
25
#include <drizzled/sql_base.h>
26
#include <drizzled/field/timestamp.h>
26
29
check that all fields are real fields
33
session thread handler
31
34
items Items for check
151
int mysql_update(THD *thd,
152
TableList *table_list,
154
int mysql_update(Session *session, TableList *table_list,
155
List<Item> &fields, List<Item> &values, COND *conds,
156
156
uint32_t order_num, order_st *order,
158
enum enum_duplicates handle_duplicates __attribute__((unused)),
157
ha_rows limit, enum enum_duplicates,
161
160
bool using_limit= limit != HA_POS_ERROR;
162
bool safe_update= test(thd->options & OPTION_SAFE_UPDATES);
161
bool safe_update= test(session->options & OPTION_SAFE_UPDATES);
163
162
bool used_key_is_modified, transactional_table, will_batch;
164
163
bool can_compare_record;
165
164
int error, loc_error;
172
171
SQL_SELECT *select;
173
172
READ_RECORD info;
174
SELECT_LEX *select_lex= &thd->lex->select_lex;
173
SELECT_LEX *select_lex= &session->lex->select_lex;
175
174
bool need_reopen;
177
176
List<Item> all_fields;
178
THD::killed_state killed_status= THD::NOT_KILLED;
177
Session::killed_state killed_status= Session::NOT_KILLED;
182
if (open_tables(thd, &table_list, &table_count, 0))
181
if (open_tables(session, &table_list, &table_count, 0))
185
if (!lock_tables(thd, table_list, table_count, &need_reopen))
184
if (!lock_tables(session, table_list, table_count, &need_reopen))
187
186
if (!need_reopen)
189
close_tables_for_reopen(thd, &table_list);
188
close_tables_for_reopen(session, &table_list);
192
if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
193
(thd->fill_derived_tables() &&
194
mysql_handle_derived(thd->lex, &mysql_derived_filling)))
191
if (mysql_handle_derived(session->lex, &mysql_derived_prepare) ||
192
(session->fill_derived_tables() &&
193
mysql_handle_derived(session->lex, &mysql_derived_filling)))
197
196
DRIZZLE_UPDATE_START();
198
thd_proc_info(thd, "init");
197
session->set_proc_info("init");
199
198
table= table_list->table;
201
200
/* Calculate "table->covering_keys" based on the WHERE */
202
201
table->covering_keys= table->s->keys_in_use;
203
202
table->quick_keys.clear_all();
205
if (mysql_prepare_update(thd, table_list, &conds, order_num, order))
204
if (mysql_prepare_update(session, table_list, &conds, order_num, order))
208
207
old_covering_keys= table->covering_keys; // Keys used in WHERE
209
208
/* Check the fields we are going to modify */
210
if (setup_fields_with_no_wrap(thd, 0, fields, MARK_COLUMNS_WRITE, 0, 0))
209
if (setup_fields_with_no_wrap(session, 0, fields, MARK_COLUMNS_WRITE, 0, 0))
211
210
goto abort; /* purecov: inspected */
212
211
if (table->timestamp_field)
227
if (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0))
226
if (setup_fields(session, 0, values, MARK_COLUMNS_READ, 0, 0))
229
free_underlaid_joins(thd, select_lex);
228
free_underlaid_joins(session, select_lex);
230
229
goto abort; /* purecov: inspected */
233
232
if (select_lex->inner_refs_list.elements &&
234
fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
233
fix_inner_refs(session, all_fields, select_lex, select_lex->ref_pointer_array))
236
235
DRIZZLE_UPDATE_END();
264
263
select= make_select(table, 0, 0, conds, 0, &error);
265
264
if (error || !limit ||
266
(select && select->check_quick(thd, safe_update, limit)))
265
(select && select->check_quick(session, safe_update, limit)))
269
free_underlaid_joins(thd, select_lex);
268
free_underlaid_joins(session, select_lex);
271
270
goto abort; // Error in where
272
271
DRIZZLE_UPDATE_END();
273
my_ok(thd); // No matching records
272
my_ok(session); // No matching records
276
275
if (!select && limit != HA_POS_ERROR)
281
280
/* If running in safe sql mode, don't allow updates without keys */
282
281
if (table->quick_keys.is_clear_all())
284
thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
283
session->server_status|=SERVER_QUERY_NO_INDEX_USED;
285
284
if (safe_update && !using_limit)
287
286
my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
338
337
SORT_FIELD *sortorder;
339
338
ha_rows examined_rows;
341
table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
342
MYF(MY_FAE | MY_ZEROFILL));
340
table->sort.io_cache = new IO_CACHE;
341
memset(table->sort.io_cache, 0, sizeof(IO_CACHE));
343
343
if (!(sortorder=make_unireg_sortorder(order, &length, NULL)) ||
344
(table->sort.found_records= filesort(thd, table, sortorder, length,
344
(table->sort.found_records= filesort(session, table, sortorder, length,
345
345
select, limit, 1,
387
387
if (used_index == MAX_KEY || (select && select->quick))
388
init_read_record(&info,thd,table,select,0,1);
388
init_read_record(&info,session,table,select,0,1);
390
init_read_record_idx(&info, thd, table, 1, used_index);
390
init_read_record_idx(&info, session, table, 1, used_index);
392
thd_proc_info(thd, "Searching rows for update");
392
session->set_proc_info("Searching rows for update");
393
393
ha_rows tmp_limit= limit;
395
while (!(error=info.read_record(&info)) && !thd->killed)
395
while (!(error=info.read_record(&info)) && !session->killed)
397
397
if (!(select && select->skip_record()))
449
449
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
451
451
if (select && select->quick && select->quick->reset())
453
453
table->file->try_semi_consistent_read(1);
454
init_read_record(&info,thd,table,select,0,1);
454
init_read_record(&info,session,table,select,0,1);
456
456
updated= found= 0;
457
457
/* Generate an error when trying to set a NOT NULL field to NULL. */
458
thd->count_cuted_fields= ignore ? CHECK_FIELD_WARN
458
session->count_cuted_fields= ignore ? CHECK_FIELD_WARN
459
459
: CHECK_FIELD_ERROR_FOR_NULL;
460
thd->cuted_fields=0L;
461
thd_proc_info(thd, "Updating");
460
session->cuted_fields=0L;
461
session->set_proc_info("Updating");
463
463
transactional_table= table->file->has_transactions();
464
thd->abort_on_warning= test(!ignore);
464
session->abort_on_warning= test(!ignore);
465
465
will_batch= !table->file->start_bulk_update();
488
488
continue; /* repeat the read of the same row if it still exists */
490
490
store_record(table,record[1]);
491
if (fill_record(thd, fields, values, 0))
491
if (fill_record(session, fields, values, 0))
492
492
break; /* purecov: inspected */
617
617
It's assumed that if an error was set in combination with an effective
618
618
killed status then the error is due to killing.
620
killed_status= thd->killed; // get the status of the volatile
620
killed_status= session->killed; // get the status of the volatile
621
621
// simulated killing after the loop must be ineffective for binlogging
622
error= (killed_status == THD::NOT_KILLED)? error : 1;
622
error= (killed_status == Session::NOT_KILLED)? error : 1;
646
646
table->file->try_semi_consistent_read(0);
648
648
if (!transactional_table && updated > 0)
649
thd->transaction.stmt.modified_non_trans_table= true;
649
session->transaction.stmt.modified_non_trans_table= true;
651
651
end_read_record(&info);
653
thd_proc_info(thd, "end");
653
session->set_proc_info("end");
654
654
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
662
662
Sometimes we want to binlog even if we updated no rows, in case user used
663
663
it to be sure master and slave are in same state.
665
if ((error < 0) || thd->transaction.stmt.modified_non_trans_table)
665
if ((error < 0) || session->transaction.stmt.modified_non_trans_table)
667
if (mysql_bin_log.is_open())
671
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
672
thd->query, thd->query_length,
673
transactional_table, false, killed_status) &&
676
error=1; // Rollback update
679
if (thd->transaction.stmt.modified_non_trans_table)
680
thd->transaction.all.modified_non_trans_table= true;
667
if (session->transaction.stmt.modified_non_trans_table)
668
session->transaction.all.modified_non_trans_table= true;
682
assert(transactional_table || !updated || thd->transaction.stmt.modified_non_trans_table);
683
free_underlaid_joins(thd, select_lex);
670
assert(transactional_table || !updated || session->transaction.stmt.modified_non_trans_table);
671
free_underlaid_joins(session, select_lex);
685
673
/* If LAST_INSERT_ID(X) was used, report X */
686
id= thd->arg_of_last_insert_id_function ?
687
thd->first_successful_insert_id_in_prev_stmt : 0;
674
id= session->arg_of_last_insert_id_function ?
675
session->first_successful_insert_id_in_prev_stmt : 0;
689
677
DRIZZLE_UPDATE_END();
692
680
char buff[STRING_BUFFER_USUAL_SIZE];
693
681
sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated,
694
(ulong) thd->cuted_fields);
696
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
697
my_ok(thd, (ulong) thd->row_count_func, id, buff);
682
(ulong) session->cuted_fields);
683
session->row_count_func=
684
(session->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
685
my_ok(session, (ulong) session->row_count_func, id, buff);
699
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
700
thd->abort_on_warning= 0;
701
return((error >= 0 || thd->is_error()) ? 1 : 0);
687
session->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
688
session->abort_on_warning= 0;
689
return((error >= 0 || session->is_error()) ? 1 : 0);
705
free_underlaid_joins(thd, select_lex);
693
free_underlaid_joins(session, select_lex);
706
694
if (table->key_read)
708
696
table->key_read=0;
709
697
table->file->extra(HA_EXTRA_NO_KEYREAD);
711
thd->abort_on_warning= 0;
699
session->abort_on_warning= 0;
714
702
DRIZZLE_UPDATE_END();
733
bool mysql_prepare_update(THD *thd, TableList *table_list,
721
bool mysql_prepare_update(Session *session, TableList *table_list,
734
722
Item **conds, uint32_t order_num, order_st *order)
736
724
List<Item> all_fields;
737
SELECT_LEX *select_lex= &thd->lex->select_lex;
740
Statement-based replication of UPDATE ... LIMIT is not safe as order of
741
rows is not defined, so in mixed mode we go to row-based.
743
Note that we may consider a statement as safe if order_st BY primary_key
744
is present. However it may confuse users to see very similiar statements
745
replicated differently.
747
if (thd->lex->current_select->select_limit)
749
thd->lex->set_stmt_unsafe();
750
thd->set_current_stmt_binlog_row_based_if_mixed();
753
thd->lex->allow_sum_func= 0;
755
if (setup_tables_and_check_access(thd, &select_lex->context,
725
SELECT_LEX *select_lex= &session->lex->select_lex;
727
session->lex->allow_sum_func= 0;
729
if (setup_tables_and_check_access(session, &select_lex->context,
756
730
&select_lex->top_join_list,
758
732
&select_lex->leaf_tables,
760
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
761
select_lex->setup_ref_array(thd, order_num) ||
762
setup_order(thd, select_lex->ref_pointer_array,
734
setup_conds(session, table_list, select_lex->leaf_tables, conds) ||
735
select_lex->setup_ref_array(session, order_num) ||
736
setup_order(session, select_lex->ref_pointer_array,
763
737
table_list, all_fields, all_fields, order))
766
740
/* Check that we are not using table that we are updating in a sub select */
768
742
TableList *duplicate;
769
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
743
if ((duplicate= unique_table(session, table_list, table_list->next_global, 0)))
771
745
update_non_unique_table_error(table_list, "UPDATE", duplicate);
772
746
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
824
798
count in open_tables()
826
800
uint32_t table_count= lex->table_count;
827
const bool using_lock_tables= thd->locked_tables != 0;
828
bool original_multiupdate= (thd->lex->sql_command == SQLCOM_UPDATE_MULTI);
801
const bool using_lock_tables= session->locked_tables != 0;
802
bool original_multiupdate= (session->lex->sql_command == SQLCOM_UPDATE_MULTI);
829
803
bool need_reopen= false;
832
806
/* following need for prepared statements, to run next time multi-update */
833
thd->lex->sql_command= SQLCOM_UPDATE_MULTI;
807
session->lex->sql_command= SQLCOM_UPDATE_MULTI;
837
811
/* open tables and create derived ones, but do not lock and fill them */
838
812
if (((original_multiupdate || need_reopen) &&
839
open_tables(thd, &table_list, &table_count, 0)) ||
813
open_tables(session, &table_list, &table_count, 0)) ||
840
814
mysql_handle_derived(lex, &mysql_derived_prepare))
845
819
call in setup_tables()).
848
if (setup_tables_and_check_access(thd, &lex->select_lex.context,
822
if (setup_tables_and_check_access(session, &lex->select_lex.context,
849
823
&lex->select_lex.top_join_list,
851
825
&lex->select_lex.leaf_tables, false))
854
if (setup_fields_with_no_wrap(thd, 0, *fields, MARK_COLUMNS_WRITE, 0, 0))
828
if (setup_fields_with_no_wrap(session, 0, *fields, MARK_COLUMNS_WRITE, 0, 0))
857
if (update_view && check_fields(thd, *fields))
831
if (update_view && check_fields(session, *fields))
935
909
tl->lock_type != TL_READ_NO_INSERT)
937
911
TableList *duplicate;
938
if ((duplicate= unique_table(thd, tl, table_list, 0)))
912
if ((duplicate= unique_table(session, tl, table_list, 0)))
940
914
update_non_unique_table_error(table_list, "UPDATE", duplicate);
972
946
multi_update *result;
975
949
if (!(result= new multi_update(table_list,
976
thd->lex->select_lex.leaf_tables,
950
session->lex->select_lex.leaf_tables,
978
952
handle_duplicates, ignore)))
981
thd->abort_on_warning= true;
955
session->abort_on_warning= true;
983
957
List<Item> total_list;
984
res= mysql_select(thd, &select_lex->ref_pointer_array,
958
res= mysql_select(session, &select_lex->ref_pointer_array,
985
959
table_list, select_lex->with_wild,
987
961
conds, 0, (order_st *) NULL, (order_st *)NULL, (Item *) NULL,
1030
1004
List_iterator_fast<Item> value_it(*values);
1031
1005
uint32_t i, max_fields;
1032
1006
uint32_t leaf_table_count= 0;
1034
thd->count_cuted_fields= CHECK_FIELD_WARN;
1035
thd->cuted_fields=0L;
1036
thd_proc_info(thd, "updating main table");
1008
session->count_cuted_fields= CHECK_FIELD_WARN;
1009
session->cuted_fields=0L;
1010
session->set_proc_info("updating main table");
1038
1012
tables_to_update= get_table_map(fields);
1081
1055
table_count= update.elements;
1082
1056
update_tables= (TableList*) update.first;
1084
tmp_tables = (Table**) thd->calloc(sizeof(Table *) * table_count);
1085
tmp_table_param = (TMP_TABLE_PARAM*) thd->calloc(sizeof(TMP_TABLE_PARAM) *
1058
tmp_tables = (Table**) session->calloc(sizeof(Table *) * table_count);
1059
tmp_table_param = (TMP_TABLE_PARAM*) session->calloc(sizeof(TMP_TABLE_PARAM) *
1087
fields_for_table= (List_item **) thd->alloc(sizeof(List_item *) *
1089
values_for_table= (List_item **) thd->alloc(sizeof(List_item *) *
1091
if (thd->is_fatal_error)
1061
fields_for_table= (List_item **) session->alloc(sizeof(List_item *) *
1063
values_for_table= (List_item **) session->alloc(sizeof(List_item *) *
1065
if (session->is_fatal_error)
1093
1067
for (i=0 ; i < table_count ; i++)
1095
1069
fields_for_table[i]= new List_item;
1096
1070
values_for_table[i]= new List_item;
1098
if (thd->is_fatal_error)
1072
if (session->is_fatal_error)
1101
1075
/* Split fields into fields_for_table[] and values_by_table[] */
1152
1126
1 Safe to update
1155
static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab,
1129
static bool safe_update_on_fly(Session *session, JOIN_TAB *join_tab,
1156
1130
TableList *table_ref, TableList *all_tables)
1158
1132
Table *table= join_tab->table;
1159
if (unique_table(thd, table_ref, all_tables, 0))
1133
if (unique_table(session, table_ref, all_tables, 0))
1161
1135
switch (join_tab->type) {
1162
1136
case JT_SYSTEM:
1219
1193
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
1220
1194
if (table == main_table) // First table in join
1222
if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables))
1196
if (safe_update_on_fly(session, join->join_tab, table_ref, all_tables))
1224
1198
table_to_update= main_table; // Update table on the fly
1241
1215
Table *tbl= table;
1244
Field_string *field= new Field_string(tbl->file->ref_length, 0,
1245
tbl->alias, &my_charset_bin);
1247
1218
Field_varstring *field= new Field_varstring(tbl->file->ref_length, 0,
1248
1219
tbl->alias, tbl->s, &my_charset_bin);
1252
1222
field->init(tbl);
1273
1243
tmp_param->field_count=temp_fields.elements;
1274
1244
tmp_param->group_parts=1;
1275
1245
tmp_param->group_length= table->file->ref_length;
1276
if (!(tmp_tables[cnt]=create_tmp_table(thd,
1246
if (!(tmp_tables[cnt]=create_tmp_table(session,
1279
1249
(order_st*) &group, 0, 0,
1304
1274
if (tmp_tables[cnt])
1306
tmp_tables[cnt]->free_tmp_table(thd);
1276
tmp_tables[cnt]->free_tmp_table(session);
1307
1277
tmp_table_param[cnt].cleanup();
1311
1281
if (copy_field)
1312
1282
delete [] copy_field;
1313
thd->count_cuted_fields= CHECK_FIELD_IGNORE; // Restore this setting
1283
session->count_cuted_fields= CHECK_FIELD_IGNORE; // Restore this setting
1314
1284
assert(trans_safe || !updated ||
1315
thd->transaction.all.modified_non_trans_table);
1285
session->transaction.all.modified_non_trans_table);
1319
bool multi_update::send_data(List<Item> ¬_used_values __attribute__((unused)))
1289
bool multi_update::send_data(List<Item> &)
1321
1291
TableList *cur_table;
1323
1293
for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
1325
1295
Table *table= cur_table->table;
1353
1323
table->read_set));
1354
1324
table->status|= STATUS_UPDATED;
1355
1325
store_record(table,record[1]);
1356
if (fill_record(thd, *fields_for_table[offset],
1326
if (fill_record(session, *fields_for_table[offset],
1357
1327
*values_for_table[offset], 0))
1427
1397
tbl->file->position(tbl->record[0]);
1428
memcpy(tmp_table->field[field_num]->ptr,
1429
tbl->file->ref, tbl->file->ref_length);
1398
Field_varstring *ref_field=
1399
reinterpret_cast<Field_varstring *>(tmp_table->field[field_num]);
1400
ref_field->store((char *)tbl->file->ref, tbl->file->ref_length,
1431
1403
} while ((tbl= tbl_it++));
1433
1405
/* Store regular updated fields in the row. */
1406
fill_record(session,
1435
1407
tmp_table->field + 1 + unupdated_check_opt_tables.elements,
1436
1408
*values_for_table[offset], 1);
1440
1412
if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE)
1443
create_myisam_from_heap(thd, tmp_table,
1415
create_myisam_from_heap(session, tmp_table,
1444
1416
tmp_table_param[offset].start_recinfo,
1445
1417
&tmp_table_param[offset].recinfo,
1477
1449
if (! trans_safe)
1479
assert(thd->transaction.stmt.modified_non_trans_table);
1451
assert(session->transaction.stmt.modified_non_trans_table);
1480
1452
if (do_update && table_count > 1)
1482
1454
/* Add warning here */
1484
1456
todo/fixme: do_update() is never called with the arg 1.
1485
1457
should it change the signature to become argless?
1490
if (thd->transaction.stmt.modified_non_trans_table)
1462
if (session->transaction.stmt.modified_non_trans_table)
1493
The query has to binlog because there's a modified non-transactional table
1494
either from the query's list or via a stored routine: bug#13270,23333
1496
if (mysql_bin_log.is_open())
1499
THD::killed status might not have been set ON at time of an error
1500
got caught and if happens later the killed error is written
1503
thd->binlog_query(THD::ROW_QUERY_TYPE,
1504
thd->query, thd->query_length,
1505
transactional_tables, false);
1507
thd->transaction.all.modified_non_trans_table= true;
1464
session->transaction.all.modified_non_trans_table= true;
1509
assert(trans_safe || !updated || thd->transaction.stmt.modified_non_trans_table);
1466
assert(trans_safe || !updated || session->transaction.stmt.modified_non_trans_table);
1547
1504
Setup copy functions to copy fields from temporary table
1549
1506
List_iterator_fast<Item> field_it(*fields_for_table[offset]);
1550
Field **field= tmp_table->field +
1507
Field **field= tmp_table->field +
1551
1508
1 + unupdated_check_opt_tables.elements; // Skip row pointers
1552
1509
Copy_field *copy_field_ptr= copy_field, *copy_field_end;
1553
1510
for ( ; *field ; field++)
1584
1541
uint32_t field_num= 0;
1544
Field_varstring *ref_field=
1545
reinterpret_cast<Field_varstring *>(tmp_table->field[field_num]);
1587
1546
if((local_error=
1588
1547
tbl->file->rnd_pos(tbl->record[0],
1589
(unsigned char *) tmp_table->field[field_num]->ptr)))
1548
(unsigned char *) ref_field->ptr
1549
+ ref_field->length_bytes)))
1592
1552
} while((tbl= check_opt_it++));
1669
1629
char buff[STRING_BUFFER_USUAL_SIZE];
1671
THD::killed_state killed_status= THD::NOT_KILLED;
1673
thd_proc_info(thd, "updating reference tables");
1631
Session::killed_state killed_status= Session::NOT_KILLED;
1633
session->set_proc_info("updating reference tables");
1676
1636
Does updates for the last n - 1 tables, returns 0 if ok;
1677
1637
error takes into account killed status gained in do_updates()
1681
1641
if local_error is not set ON until after do_updates() then
1682
1642
later carried out killing should not affect binlogging.
1684
killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed;
1685
thd_proc_info(thd, "end");
1644
killed_status= (local_error == 0)? Session::NOT_KILLED : session->killed;
1645
session->set_proc_info("end");
1688
1648
Write the SQL statement to the binlog if we updated
1689
1649
rows and we succeeded or if we updated some non
1690
1650
transactional tables.
1692
1652
The query has to binlog because there's a modified non-transactional table
1693
1653
either from the query's list or via a stored routine: bug#13270,23333
1696
assert(trans_safe || !updated ||
1697
thd->transaction.stmt.modified_non_trans_table);
1698
if (local_error == 0 || thd->transaction.stmt.modified_non_trans_table)
1656
assert(trans_safe || !updated ||
1657
session->transaction.stmt.modified_non_trans_table);
1658
if (local_error == 0 || session->transaction.stmt.modified_non_trans_table)
1700
if (mysql_bin_log.is_open())
1702
if (local_error == 0)
1704
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
1705
thd->query, thd->query_length,
1706
transactional_tables, false, killed_status) &&
1709
local_error= 1; // Rollback update
1712
if (thd->transaction.stmt.modified_non_trans_table)
1713
thd->transaction.all.modified_non_trans_table= true;
1660
if (session->transaction.stmt.modified_non_trans_table)
1661
session->transaction.all.modified_non_trans_table= true;
1715
1663
if (local_error != 0)
1716
1664
error_handled= true; // to force early leave from ::send_error()
1726
id= thd->arg_of_last_insert_id_function ?
1727
thd->first_successful_insert_id_in_prev_stmt : 0;
1674
id= session->arg_of_last_insert_id_function ?
1675
session->first_successful_insert_id_in_prev_stmt : 0;
1728
1676
sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated,
1729
(ulong) thd->cuted_fields);
1730
thd->row_count_func=
1731
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
1732
::my_ok(thd, (ulong) thd->row_count_func, id, buff);
1677
(ulong) session->cuted_fields);
1678
session->row_count_func=
1679
(session->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
1680
::my_ok(session, (ulong) session->row_count_func, id, buff);