1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

WL#1567: Add ROW_COUNT() Function to retrieve count of rows updated/inserted/deleted

mysql-test/r/sp.result:
  New test cases for function ROW_COUNT().
mysql-test/t/sp.test:
  New test cases for function ROW_COUNT().
sql/item_func.cc:
  New Item_func_row_count.
sql/item_func.h:
  New Item_func_row_count.
sql/lex.h:
  New symbol for function ROW_COUNT().
sql/sql_class.h:
  New slot in THD for storing the row_count after insert, delete and update.
sql/sql_delete.cc:
  Set thd->row_count_func when deleting.
sql/sql_insert.cc:
  Set thd->row_count_func when inserting.
sql/sql_parse.cc:
  Stored procedure CALLs send the row count from the last insert, delete or update.
sql/sql_update.cc:
  Set thd->row_count_func when updating.
sql/sql_yacc.yy:
  New function ROW_COUNT().
This commit is contained in:
unknown
2004-05-04 13:45:20 +02:00
parent 2eecc377a6
commit 7c4ceb739f
11 changed files with 88 additions and 8 deletions

View File

@@ -419,7 +419,10 @@ 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+info.updated,id);
{
thd->row_count_func= info.copied+info.deleted+info.updated;
send_ok(thd, thd->row_count_func, id);
}
else
{
char buff[160];
@@ -430,7 +433,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted+info.updated, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted+info.updated,(ulonglong)id,buff);
thd->row_count_func= info.copied+info.deleted+info.updated;
::send_ok(thd, thd->row_count_func, (ulonglong)id,buff);
}
free_underlaid_joins(thd, &thd->lex->select_lex);
table->insert_values=0;
@@ -1565,7 +1569,8 @@ bool select_insert::send_eof()
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) info.deleted+info.updated, (ulong) thd->cuted_fields);
::send_ok(thd,info.copied+info.deleted+info.updated,last_insert_id,buff);
thd->row_count_func= info.copied+info.deleted+info.updated;
::send_ok(thd, thd->row_count_func, last_insert_id, buff);
DBUG_RETURN(0);
}