Commit 1464733b authored by unknown's avatar unknown

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/bk/work-lower_case-4.1
parents 3b985beb 59dda607
......@@ -2331,11 +2331,17 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
mysql_free_result(warn_res);
}
}
if (!disable_info && mysql_info(mysql))
if (!disable_info)
{
dynstr_append(ds, "info: ");
dynstr_append(ds, mysql_info(mysql));
dynstr_append_mem(ds, "\n", 1);
char buf[40];
sprintf(buf,"affected rows: %ld\n",mysql_affected_rows(mysql));
dynstr_append(ds, buf);
if (mysql_info(mysql))
{
dynstr_append(ds, "info: ");
dynstr_append(ds, mysql_info(mysql));
dynstr_append_mem(ds, "\n", 1);
}
}
}
......
......@@ -67,3 +67,41 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1
DROP TABLE t1;
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
select * from t1;
a b
1 1
2 2
3 3
4 4
5 5
insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18)
on duplicate key update b=b+10;
affected rows: 7
info: Records: 5 Duplicates: 2 Warnings: 0
select * from t1;
a b
1 1
2 2
3 3
4 14
5 15
6 16
7 17
8 18
replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29);
affected rows: 9
info: Records: 5 Duplicates: 4 Warnings: 0
select * from t1;
a b
1 1
2 2
3 3
4 14
5 25
6 26
7 27
8 28
9 29
drop table t1;
......@@ -26,3 +26,25 @@ SELECT *, VALUES(a) FROM t1;
explain extended SELECT *, VALUES(a) FROM t1;
explain extended select * from t1 where values(a);
DROP TABLE t1;
#
# test for Bug #2709 "Affected Rows for ON DUPL.KEY undocumented,
# perhaps illogical"
#
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
select * from t1;
enable_info;
insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18)
on duplicate key update b=b+10;
disable_info;
select * from t1;
enable_info;
replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29);
disable_info;
select * from t1;
drop table t1;
......@@ -194,6 +194,7 @@ class MYSQL_LOG
typedef struct st_copy_info {
ha_rows records;
ha_rows deleted;
ha_rows updated;
ha_rows copied;
ha_rows error_count;
enum enum_duplicates handle_duplicates;
......
......@@ -236,7 +236,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
Fill in the given fields and dump it to the table file
*/
info.records=info.deleted=info.copied=0;
info.records= info.deleted= info.copied= info.updated= 0;
info.handle_duplicates=duplic;
info.update_fields=&update_fields;
info.update_values=&update_values;
......@@ -369,13 +369,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
For the transactional algorithm to work the invalidation must be
before binlog writing and ha_autocommit_...
*/
if (info.copied || info.deleted)
if (info.copied || info.deleted || info.updated)
query_cache_invalidate3(thd, table_list, 1);
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
if ((info.copied || info.deleted || info.updated) &&
(error <= 0 || !transactional_table))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
......@@ -416,7 +417,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
goto abort;
if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) ||
!thd->cuted_fields))
send_ok(thd,info.copied+info.deleted,id);
send_ok(thd,info.copied+info.deleted+info.updated,id);
else
{
char buff[160];
......@@ -426,8 +427,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted,(ulonglong)id,buff);
(ulong) info.deleted+info.updated, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted+info.updated,(ulonglong)id,buff);
}
free_underlaid_joins(thd, &thd->lex->select_lex);
table->insert_values=0;
......@@ -529,7 +530,7 @@ int write_record(TABLE *table,COPY_INFO *info)
goto err;
if ((error=table->file->update_row(table->record[1],table->record[0])))
goto err;
info->deleted++;
info->updated++;
break;
}
else /* DUP_REPLACE */
......@@ -1474,7 +1475,8 @@ void select_insert::send_error(uint errcode,const char *err)
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) && !table->file->has_transactions())
if ((info.copied || info.deleted || info.updated) &&
!table->file->has_transactions())
{
if (last_insert_id)
thd->insert_id(last_insert_id); // For binary log
......@@ -1488,7 +1490,7 @@ void select_insert::send_error(uint errcode,const char *err)
if (!table->tmp_table)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (info.copied || info.deleted)
if (info.copied || info.deleted || info.updated)
query_cache_invalidate3(thd, table, 1);
ha_rollback_stmt(thd);
DBUG_VOID_RETURN;
......@@ -1509,7 +1511,7 @@ bool select_insert::send_eof()
and ha_autocommit_...
*/
if (info.copied || info.deleted)
if (info.copied || info.deleted || info.updated)
{
query_cache_invalidate3(thd, table, 1);
if (!(table->file->has_transactions() || table->tmp_table))
......@@ -1543,8 +1545,8 @@ bool select_insert::send_eof()
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted,last_insert_id,buff);
(ulong) info.deleted+info.updated, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted+info.updated,last_insert_id,buff);
DBUG_RETURN(0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment