Below is the list of changes that have just been committed into a local
5.0 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-17 17:45:21+02:00, andrey@stripped +17 -0
Fix for bug#21818 "Return value of ROW_COUNT() is incorrect for
ALTER TABLE, LOAD DATA"
This patch refactores the server code so the only place, where the
affected number of rows of the last statement is stored, is
THD::row_count_func
mysql-test/r/create.result@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +444 -0
update result
mysql-test/r/select.result@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +63 -0
update result
mysql-test/t/create.test@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +196 -0
add tests for ROW_COUNT, mostly CREATE statements
mysql-test/t/select.test@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +28 -0
add ROW_COUNT() tests for SELECT statement
sql/mysql_priv.h@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +1 -0
backport sql_command_flags array from 5.1
sql/protocol.cc@stripped, 2006-10-17 17:45:15+02:00, andrey@stripped +22 -16
thd->row_count_func is used to send the number of affected rows.
This means no direct passing of the aff rows number.
Update few function prototypes
sql/protocol.h@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +1 -2
Update send_ok()'s prototype
sql/sql_class.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +6 -2
affected_rows is no more a parameter of send_ok().
Assign it to thd->row_count_func and then call send_ok().
sql/sql_class.h@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +6 -0
backport sql_command_flags from 5.1
CF_HAS_ROW_COUNT has been removed as it's not needed
after the patch (when merging into 5.1 the flag will be removed
there too)
sql/sql_db.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +6 -3
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_delete.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +3 -3
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_insert.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +3 -3
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_load.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +2 -1
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_parse.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +87 -13
backport sql_command_flags from 5.1 for the needs of
the fix of bug#21818 ROW_COUNT()
thd->row_count_func is reset to 0 for all non-SELECT or
non-SHOW commands, thus obeying to the old prototype of
send_ok() where if not specified, affected_rows was 0.
If the command was SELECT or SHOW, then after it's execution reset
thd->row_count_func to -1
In case of error set thd->row_count_func to -1
sql/sql_prepare.cc@stripped, 2006-10-17 17:45:16+02:00, andrey@stripped +4 -1
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_table.cc@stripped, 2006-10-17 17:45:17+02:00, andrey@stripped +4 -1
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
sql/sql_update.cc@stripped, 2006-10-17 17:45:18+02:00, andrey@stripped +2 -4
Assign the number of affected rows to thd->row_count_func
and then call send_ok()
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: example.com
# Root: /work/mysql-5.0-maint
--- 1.415/sql/mysql_priv.h 2006-10-17 17:45:34 +02:00
+++ 1.416/sql/mysql_priv.h 2006-10-17 17:45:34 +02:00
@@ -1298,6 +1298,7 @@ extern I_List<i_string> binlog_do_db, bi
extern const char* any_db;
extern struct my_option my_long_options[];
extern const LEX_STRING view_type;
+extern uint sql_command_flags[];
/* optional things, have_* variables */
--- 1.116/sql/protocol.cc 2006-10-17 17:45:34 +02:00
+++ 1.117/sql/protocol.cc 2006-10-17 17:45:34 +02:00
@@ -243,7 +243,6 @@ net_printf_error(THD *thd, uint errcode,
SYNOPSIS
send_ok()
thd Thread handler
- affected_rows Number of rows changed by statement
id Auto_increment id for first row (if used)
message Message to send to the client (Used by mysql_status)
@@ -251,7 +250,7 @@ net_printf_error(THD *thd, uint errcode,
The ok packet has the following structure
0 Marker (1 byte)
- affected_rows Stored in 1-9 bytes
+ thd->row_count_func Stored in 1-9 bytes
id Stored in 1-9 bytes
server_status Copy of thd->server_status; Can be used by client
to check if we are inside an transaction
@@ -265,7 +264,7 @@ net_printf_error(THD *thd, uint errcode,
#ifndef EMBEDDED_LIBRARY
void
-send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
+send_ok(THD *thd, ulonglong id, const char *message)
{
NET *net= &thd->net;
char buff[MYSQL_ERRMSG_SIZE+10],*pos;
@@ -280,13 +279,13 @@ send_ok(THD *thd, ha_rows affected_rows,
}
buff[0]=0; // No fields
- pos=net_store_length(buff+1,(ulonglong) affected_rows);
+ pos=net_store_length(buff+1,(ulonglong) thd->row_count_func);
pos=net_store_length(pos, (ulonglong) id);
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
DBUG_PRINT("info",
("affected_rows: %lu id: %lu status: %u warning_count: %u",
- (ulong) affected_rows,
+ (ulong) thd->row_count_func,
(ulong) id,
(uint) (thd->server_status & 0xffff),
(uint) thd->total_warn_count));
@@ -323,8 +322,6 @@ static char eof_buff[1]= { (char) 254 };
SYNOPSIS
send_eof()
thd Thread handler
- no_flush Set to 1 if there will be more data to the client,
- like in send_fields().
DESCRIPTION
The eof packet has the following structure
@@ -386,6 +383,7 @@ static void write_eof_packet(THD *thd, N
VOID(my_net_write(net, eof_buff, 1));
}
+
/*
Please client to send scrambled_password in old format.
SYNOPSYS
@@ -393,8 +391,8 @@ static void write_eof_packet(THD *thd, N
thd thread handle
RETURN VALUE
- 0 ok
- !0 error
+ FALSE ok
+ TRUE error
*/
bool send_old_password_request(THD *thd)
@@ -484,6 +482,7 @@ char *net_store_data(char *to,const char
return to+length;
}
+
char *net_store_data(char *to,int32 from)
{
char buff[20];
@@ -493,6 +492,7 @@ char *net_store_data(char *to,int32 from
return to+length;
}
+
char *net_store_data(char *to,longlong from)
{
char buff[22];
@@ -527,6 +527,7 @@ bool Protocol::flush()
#endif
}
+
/*
Send name and type of result to client.
@@ -535,16 +536,16 @@ bool Protocol::flush()
THD Thread data object
list List of items to send to client
flag Bit mask with the following functions:
- 1 send number of rows
- 2 send default values
- 4 don't write eof packet
+ Protocol::SEND_NUM_ROWS send number of rows
+ Protocol::SEND_DEFAULTS send default values
+ Protocol::SEND_EOF don't write eof packet
DESCRIPTION
Sum fields has table name empty and field_name.
RETURN VALUES
- 0 ok
- 1 Error (Note that in this case the error is not sent to the client)
+ FALSE ok
+ TRUE Error (Note that in this case the error is not sent to the client)
*/
#ifndef EMBEDDED_LIBRARY
@@ -711,8 +712,8 @@ bool Protocol::write()
In most cases one should use store(from, length) instead of this function
RETURN VALUES
- 0 ok
- 1 error
+ FALSE ok
+ TRUE error
*/
bool Protocol::store(const char *from, CHARSET_INFO *cs)
@@ -765,6 +766,7 @@ void Protocol_simple::prepare_for_resend
#endif
}
+
bool Protocol_simple::store_null()
{
#ifndef DBUG_OFF
@@ -1055,6 +1057,7 @@ bool Protocol_prep::store(const char *fr
return store_string_aux(from, length, fromcs, tocs);
}
+
bool Protocol_prep::store(const char *from,uint length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{
@@ -1062,6 +1065,7 @@ bool Protocol_prep::store(const char *fr
return store_string_aux(from, length, fromcs, tocs);
}
+
bool Protocol_prep::store_null()
{
uint offset= (field_pos+2)/8+1, bit= (1 << ((field_pos+2) & 7));
@@ -1127,6 +1131,7 @@ bool Protocol_prep::store_decimal(const
return store(str.ptr(), str.length(), str.charset());
}
+
bool Protocol_prep::store(float from, uint32 decimals, String *buffer)
{
field_pos++;
@@ -1186,6 +1191,7 @@ bool Protocol_prep::store(TIME *tm)
buff[0]=(char) length; // Length is stored first
return packet->append(buff, length+1, PACKET_BUFFER_EXTRA_ALLOC);
}
+
bool Protocol_prep::store_date(TIME *tm)
{
--- 1.248/sql/sql_class.cc 2006-10-17 17:45:34 +02:00
+++ 1.249/sql/sql_class.cc 2006-10-17 17:45:34 +02:00
@@ -1016,7 +1016,10 @@ bool select_to_file::send_eof()
if (my_close(file,MYF(MY_WME)))
error= 1;
if (!error)
- ::send_ok(thd,row_count);
+ {
+ thd->row_count_func= row_count;
+ ::send_ok(thd);
+ }
file= -1;
return error;
}
@@ -1910,7 +1913,8 @@ bool select_dumpvar::send_eof()
if (! row_count)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
- ::send_ok(thd,row_count);
+ thd->row_count_func= row_count;
+ ::send_ok(thd);
return 0;
}
--- 1.304/sql/sql_class.h 2006-10-17 17:45:34 +02:00
+++ 1.305/sql/sql_class.h 2006-10-17 17:45:34 +02:00
@@ -2185,6 +2185,12 @@ public:
void cleanup();
};
+/* Bits in sql_command_flags */
+
+#define CF_CHANGES_DATA 1
+#define CF_STATUS_COMMAND 2
+#define CF_SHOW_TABLE_COMMAND 4
+
/* Functions in sql_class.cc */
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
--- 1.131/sql/sql_db.cc 2006-10-17 17:45:34 +02:00
+++ 1.132/sql/sql_db.cc 2006-10-17 17:45:34 +02:00
@@ -587,7 +587,8 @@ bool mysql_create_db(THD *thd, char *db,
mysql_bin_log.write(&qinfo);
}
- send_ok(thd, result);
+ thd->row_count_func= result;
+ send_ok(thd);
}
exit:
@@ -658,7 +659,8 @@ bool mysql_alter_db(THD *thd, const char
thd->clear_error();
mysql_bin_log.write(&qinfo);
}
- send_ok(thd, result);
+ thd->row_count_func= result;
+ send_ok(thd);
exit:
VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
@@ -782,7 +784,8 @@ bool mysql_rm_db(THD *thd,char *db,bool
mysql_bin_log.write(&qinfo);
}
thd->server_status|= SERVER_STATUS_DB_DROPPED;
- send_ok(thd, (ulong) deleted);
+ thd->row_count_func= deleted;
+ send_ok(thd);
thd->server_status&= ~SERVER_STATUS_DB_DROPPED;
}
else if (mysql_bin_log.is_open())
--- 1.179/sql/sql_delete.cc 2006-10-17 17:45:34 +02:00
+++ 1.180/sql/sql_delete.cc 2006-10-17 17:45:34 +02:00
@@ -109,7 +109,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
delete select;
free_underlaid_joins(thd, select_lex);
thd->row_count_func= 0;
- send_ok(thd,0L);
+ send_ok(thd);
/*
We don't need to call reset_auto_increment in this case, because
@@ -320,7 +320,7 @@ cleanup:
if (error < 0)
{
thd->row_count_func= deleted;
- send_ok(thd,deleted);
+ send_ok(thd);
DBUG_PRINT("info",("%d records deleted",deleted));
}
DBUG_RETURN(error >= 0 || thd->net.report_error);
@@ -787,7 +787,7 @@ bool multi_delete::send_eof()
if (!local_error)
{
thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
+ ::send_ok(thd);
}
return 0;
}
--- 1.204/sql/sql_insert.cc 2006-10-17 17:45:34 +02:00
+++ 1.205/sql/sql_insert.cc 2006-10-17 17:45:34 +02:00
@@ -699,7 +699,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
!thd->cuted_fields))
{
thd->row_count_func= info.copied+info.deleted+info.updated;
- send_ok(thd, (ulong) thd->row_count_func, id);
+ send_ok(thd, id);
}
else
{
@@ -712,7 +712,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields);
thd->row_count_func= info.copied+info.deleted+info.updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
+ ::send_ok(thd, id, buff);
}
thd->abort_on_warning= 0;
DBUG_RETURN(FALSE);
@@ -2600,7 +2600,7 @@ bool select_insert::send_eof()
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields);
thd->row_count_func= info.copied+info.deleted+info.updated;
- ::send_ok(thd, (ulong) thd->row_count_func, last_insert_id, buff);
+ ::send_ok(thd, last_insert_id, buff);
DBUG_RETURN(0);
}
--- 1.99/sql/sql_load.cc 2006-10-17 17:45:34 +02:00
+++ 1.100/sql/sql_load.cc 2006-10-17 17:45:34 +02:00
@@ -455,7 +455,8 @@ bool mysql_load(THD *thd,sql_exchange *e
}
sprintf(name, ER(ER_LOAD_INFO), (ulong) info.records, (ulong) info.deleted,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
- send_ok(thd,info.copied+info.deleted,0L,name);
+ thd->row_count_func= info.copied+info.deleted;
+ send_ok(thd, 0L, name);
if (!transactional_table)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
--- 1.583/sql/sql_parse.cc 2006-10-17 17:45:34 +02:00
+++ 1.584/sql/sql_parse.cc 2006-10-17 17:45:34 +02:00
@@ -623,6 +623,8 @@ void free_max_user_conn(void)
*/
char uc_update_queries[SQLCOM_END+1];
+/* This is a partial backport from 5.1 to enable ROW_COUNT() to work */
+uint sql_command_flags[SQLCOM_END+1];
void init_update_queries(void)
{
@@ -650,8 +652,61 @@ void init_update_queries(void)
uc_update_queries[SQLCOM_DROP_INDEX]=1;
uc_update_queries[SQLCOM_CREATE_VIEW]=1;
uc_update_queries[SQLCOM_DROP_VIEW]=1;
+
+ /*
+ This comment is to say that the following initialization
+ code has been backported from 5.1 . Backported was also
+ the declaration and definition of the array. However, all
+ other relying code but ROW_COUNT() has not been backported.
+ Please don't merge this comment into 5.1
+ */
+
+ bzero((gptr) &sql_command_flags, sizeof(sql_command_flags));
+
+ sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_ALTER_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_TRUNCATE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DROP_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_LOAD]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_CREATE_DB]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_BACKUP_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_RESTORE_TABLE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DROP_VIEW]= CF_CHANGES_DATA;
+
+ sql_command_flags[SQLCOM_UPDATE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_UPDATE_MULTI]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_INSERT]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_INSERT_SELECT]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DELETE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_DELETE_MULTI]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_REPLACE]= CF_CHANGES_DATA;
+ sql_command_flags[SQLCOM_REPLACE_SELECT]= CF_CHANGES_DATA;
+
+ sql_command_flags[SQLCOM_SHOW_STATUS_PROC]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_STATUS_FUNC]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_STATUS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_DATABASES]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_TRIGGERS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_OPEN_TABLES]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_FIELDS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_KEYS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_VARIABLES]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_CHARSETS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_COLLATIONS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_STATUS_PROC]= CF_STATUS_COMMAND;
+
+ sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND |
+ CF_SHOW_TABLE_COMMAND);
+ sql_command_flags[SQLCOM_SHOW_TABLE_STATUS]= (CF_STATUS_COMMAND |
+ CF_SHOW_TABLE_COMMAND);
}
+
bool is_update_query(enum enum_sql_command command)
{
DBUG_ASSERT(command >= 0 && command <= SQLCOM_END);
@@ -2522,6 +2577,17 @@ mysql_execute_command(THD *thd)
if(lex->orig_sql_command == SQLCOM_END)
statistic_increment(thd->status_var.com_stat[lex->sql_command],
&LOCK_status);
+ /*
+ For everything but select initialize ROW_COUNT() to be 0. send_ok()
+ no more asks for affected_rows param and we use thd->row_count_func.
+ The default value is 0. To keep results backward compatible first
+ SELECT with call to ROW_COUNT() will return thd->row_count_func and
+ then the value will be reset to -1. Thus, the second call will return
+ -1. See the end of this function to find how this is being done.
+ */
+ if (lex->sql_command != SQLCOM_SELECT &&
+ !(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND))
+ thd->row_count_func= 0;
switch (lex->sql_command) {
case SQLCOM_SELECT:
@@ -4474,8 +4540,6 @@ end_with_restore_list:
#endif
select_limit= thd->variables.select_limit;
thd->variables.select_limit= HA_POS_ERROR;
-
- thd->row_count_func= 0;
/*
We never write CALL statements into binlog:
@@ -4499,8 +4563,11 @@ end_with_restore_list:
thd->server_status&= ~bits_to_be_cleared;
if (!res)
- send_ok(thd, (ulong) (thd->row_count_func < 0 ? 0 :
- thd->row_count_func));
+ {
+ if (thd->row_count_func < 0)
+ thd->row_count_func= 0;
+ send_ok(thd);
+ }
else
goto error; // Substatement should already have sent error
}
@@ -5027,15 +5094,12 @@ end_with_restore_list:
reset_one_shot_variables(thd);
/*
- The return value for ROW_COUNT() is "implementation dependent" if the
- statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
- wants.
-
- We do not change the value for a CALL or EXECUTE statement, so the value
- generated by the last called (or executed) statement is preserved.
- */
- if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE &&
- uc_update_queries[lex->sql_command]<2)
+ The first SELECT ROW_COUNT() will return the expected value, the next
+ one will return -1 (as it used to be before CF_HAS_ROW_COUNT was
+ removed). This code actually resets the value.
+ */
+ if (lex->sql_command == SQLCOM_SELECT ||
+ (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND))
thd->row_count_func= -1;
goto end;
@@ -5044,6 +5108,16 @@ error:
res= TRUE;
end:
+ /*
+ This piece of code should be common to both execution paths as
+ some commands are void, do not return any value, but still report
+ errors. In case of error we should return -1 as value for ROW_COUNT().
+ Like mysql_affected_rows() of the client library does, though there
+ the value is unsigned and.
+ */
+ if (thd->query_error)
+ thd->row_count_func= -1;
+
if (need_start_waiting)
{
/*
--- 1.322/sql/sql_table.cc 2006-10-17 17:45:34 +02:00
+++ 1.323/sql/sql_table.cc 2006-10-17 17:45:34 +02:00
@@ -3951,7 +3951,10 @@ end_temporary:
(ulong) (copied + deleted), (ulong) deleted,
(ulong) thd->cuted_fields);
if (do_send_ok)
- send_ok(thd,copied+deleted,0L,tmp_name);
+ {
+ thd->row_count_func= copied+deleted;
+ send_ok(thd, 0L, tmp_name);
+ }
thd->some_tables_deleted=0;
DBUG_RETURN(FALSE);
--- 1.199/sql/sql_update.cc 2006-10-17 17:45:34 +02:00
+++ 1.200/sql/sql_update.cc 2006-10-17 17:45:34 +02:00
@@ -567,8 +567,7 @@ int mysql_update(THD *thd,
(ulong) thd->cuted_fields);
thd->row_count_func=
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
+ send_ok(thd, thd->insert_id_used ? thd->last_insert_id : 0L, buff);
DBUG_PRINT("info",("%d records updated",updated));
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
@@ -1560,7 +1559,6 @@ bool multi_update::send_eof()
(ulong) thd->cuted_fields);
thd->row_count_func=
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
+ ::send_ok(thd, thd->insert_id_used ? thd->last_insert_id : 0L, buff);
return FALSE;
}
--- 1.122/mysql-test/r/create.result 2006-10-17 17:45:34 +02:00
+++ 1.123/mysql-test/r/create.result 2006-10-17 17:45:34 +02:00
@@ -775,3 +775,447 @@ insert into t1 values('aaa');
drop table t1;
create table t1 (upgrade int);
drop table t1;
+DROP DATABASE IF EXISTS mysqltest_1;
+CREATE DATABASE mysqltest_1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER DATABASE mysqltest_1 DEFAULT CHARACTER SET utf8;
+SELECT ROW_COUNT();
+ROW_COUNT()
+1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE TABLE mysqltest_1.table1(a int);
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE VIEW mysqltest_1.view1 AS SELECT * FROM mysqltest_1.table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+INSERT INTO mysqltest_1.table1 VALUES (1),(2),(3),(5),(8),(13),(21),(34),(51);
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE INDEX idx1 ON mysqltest_1.table1(a);
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP INDEX idx1 ON mysqltest_1.table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER TABLE mysqltest_1.table1 ADD INDEX idx1(a);
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER TABLE mysqltest_1.table1 DROP INDEX idx1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE INDEX idx1 ON mysqltest_1.table1(a);
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER TABLE mysqltest_1.table1 DROP INDEX idx1, ADD PRIMARY KEY(a);
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER TABLE mysqltest_1.table1 DROP PRIMARY KEY;
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT * FROM mysqltest_1.table1 WHERE a=1;
+a
+1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+INSERT INTO mysqltest_1.table1 SELECT * FROM mysqltest_1.table1 LIMIT 3;
+SELECT ROW_COUNT();
+ROW_COUNT()
+3
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table1(b float);
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table2(b float) SELECT * FROM mysqltest_1.table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+12
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table3 LIKE mysqltest_1.table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE FUNCTION mysqltest_1.FUNC_1() RETURNS INT RETURN 5;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER FUNCTION mysqltest_1.FUNC_1 COMMENT 'comment';
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP FUNCTION mysqltest_1.FUNC_1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE PROCEDURE mysqltest_1.PROC_1()
+BEGIN
+CREATE TABLE mysqltest_1.table2 (c int);
+INSERT INTO mysqltest_1.table2 SELECT * FROM mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT COUNT(*) FROM mysqltest_1.table2;
+TRUNCATE mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+INSERT INTO mysqltest_1.table2 SELECT * FROM mysqltest_1.table1;
+END|
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CALL mysqltest_1.PROC_1();
+ROW_COUNT()
+12
+ROW_COUNT()
+-1
+COUNT(*)
+12
+ROW_COUNT()
+0
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+12
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ALTER PROCEDURE mysqltest_1.PROC_1 COMMENT 'some comment';
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP PROCEDURE mysqltest_1.PROC_1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT COUNT(*) FROM mysqltest_1.table2;
+COUNT(*)
+12
+REPAIR TABLE mysqltest_1.table2;
+Table Op Msg_type Msg_text
+mysqltest_1.table2 repair status OK
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CHECK TABLE mysqltest_1.table2;
+Table Op Msg_type Msg_text
+mysqltest_1.table2 check status OK
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+ANALYZE TABLE mysqltest_1.table2;
+Table Op Msg_type Msg_text
+mysqltest_1.table2 analyze status Table is already up to date
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SET GLOBAL new_cache.key_buffer_size=128*1024;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CACHE INDEX mysqltest_1.table2 IN new_cache;
+Table Op Msg_type Msg_text
+mysqltest_1.table2 assign_to_keycache status OK
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+LOAD INDEX INTO CACHE mysqltest_1.table1 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+mysqltest_1.table1 preload_keys status OK
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+TRUNCATE mysqltest_1.table2;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+FLUSH TABLES;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+KILL 0;
+ERROR HY000: Unknown thread id: 0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP VIEW mysqltest_1.view1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP TABLE mysqltest_1.table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP TABLE mysqltest_1.tmp_table1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SHOW TABLES FROM mysqltest_1;
+Tables_in_mysqltest_1
+table2
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SHOW DATABASES LIKE 'mysql%';
+Database (mysql%)
+mysql
+mysqltest_1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+INSERT INTO mysqltest_1.table2 VALUES (1),(2),(3),(5),(8),(13),(21),(34),(51);
+PREPARE xyz FROM 'CREATE INDEX idx1 ON mysqltest_1.table2(c)';
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+EXECUTE xyz;
+SELECT ROW_COUNT();
+ROW_COUNT()
+9
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DEALLOCATE PREPARE xyz;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SHOW FIELDS FROM mysqltest_1.table2;
+Field Type Null Key Default Extra
+c int(11) YES MUL NULL
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SHOW KEYS FROM mysqltest_1.table2;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+table2 1 idx1 1 c A NULL NULL NULL YES BTREE
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SHOW TRIGGERS FROM mysqltest_1;
+Trigger Event Table Statement Timing Created sql_mode Definer
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+LOCK TABLES mysqltest_1.table2 WRITE;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+UNLOCK TABLES;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+CREATE TRIGGER mysqltest_1.T2_insert BEFORE INSERT ON mysqltest_1.table2 FOR EACH ROW SET NEW.c=NEW.c;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP TRIGGER mysqltest_1.T2_insert;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+RENAME TABLE mysqltest_1.table2 TO mysqltest_1.table3;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+RENAME TABLE mysqltest_1.table3 TO mysqltest_1.table2;
+DROP TABLE mysqltest_1.tmp_table2;
+DROP TABLE mysqltest_1.tmp_table3;
+CREATE USER mysqltest_user@localhost;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+GRANT ALL ON mysqltest_1.* TO mysqltest_user@localhost;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+REVOKE ALL ON mysqltest_1.* FROM mysqltest_user@localhost;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP USER mysqltest_user@localhost;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP DATABASE mysqltest_1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+FLUSH QUERY CACHE;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DO COMPRESS("aaa");
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
--- 1.139/mysql-test/r/select.result 2006-10-17 17:45:34 +02:00
+++ 1.140/mysql-test/r/select.result 2006-10-17 17:45:34 +02:00
@@ -3517,3 +3517,66 @@ id a b c d e
2 NULL NULL NULL 2 40
2 NULL NULL NULL 2 50
DROP TABLE t1,t2,t3;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a int);
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+INSERT INTO t1 VALUES (1), (1), (2), (3), (5), (8), (13), (21);
+SELECT ROW_COUNT();
+ROW_COUNT()
+8
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+8
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT * FROM t1 ORDER BY a;
+a
+1
+1
+2
+3
+5
+8
+13
+21
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT * FROM t1 ORDER BY a LIMIT 1;
+a
+1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT a FROM t1 LIMIT 1 INTO @foobar;
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
+DROP TABLE t1;
+SELECT ROW_COUNT();
+ROW_COUNT()
+0
+SELECT ROW_COUNT();
+ROW_COUNT()
+-1
--- 1.81/mysql-test/t/create.test 2006-10-17 17:45:34 +02:00
+++ 1.82/mysql-test/t/create.test 2006-10-17 17:45:34 +02:00
@@ -680,4 +680,200 @@ drop table t1;
create table t1 (upgrade int);
drop table t1;
+#
+# Test ROW_COUNT
+#
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_1;
+--enable_warnings
+CREATE DATABASE mysqltest_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER DATABASE mysqltest_1 DEFAULT CHARACTER SET utf8;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE TABLE mysqltest_1.table1(a int);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE VIEW mysqltest_1.view1 AS SELECT * FROM mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+INSERT INTO mysqltest_1.table1 VALUES (1),(2),(3),(5),(8),(13),(21),(34),(51);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE INDEX idx1 ON mysqltest_1.table1(a);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP INDEX idx1 ON mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER TABLE mysqltest_1.table1 ADD INDEX idx1(a);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER TABLE mysqltest_1.table1 DROP INDEX idx1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE INDEX idx1 ON mysqltest_1.table1(a);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER TABLE mysqltest_1.table1 DROP INDEX idx1, ADD PRIMARY KEY(a);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER TABLE mysqltest_1.table1 DROP PRIMARY KEY;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT * FROM mysqltest_1.table1 WHERE a=1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+INSERT INTO mysqltest_1.table1 SELECT * FROM mysqltest_1.table1 LIMIT 3;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table1(b float);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table2(b float) SELECT * FROM mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE TEMPORARY TABLE mysqltest_1.tmp_table3 LIKE mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE FUNCTION mysqltest_1.FUNC_1() RETURNS INT RETURN 5;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER FUNCTION mysqltest_1.FUNC_1 COMMENT 'comment';
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP FUNCTION mysqltest_1.FUNC_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DELIMITER |;
+CREATE PROCEDURE mysqltest_1.PROC_1()
+BEGIN
+ CREATE TABLE mysqltest_1.table2 (c int);
+ INSERT INTO mysqltest_1.table2 SELECT * FROM mysqltest_1.table1;
+ SELECT ROW_COUNT();
+ SELECT ROW_COUNT();
+ SELECT COUNT(*) FROM mysqltest_1.table2;
+ TRUNCATE mysqltest_1.table2;
+ SELECT ROW_COUNT();
+ SELECT ROW_COUNT();
+ INSERT INTO mysqltest_1.table2 SELECT * FROM mysqltest_1.table1;
+END|
+DELIMITER ;|
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CALL mysqltest_1.PROC_1();
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ALTER PROCEDURE mysqltest_1.PROC_1 COMMENT 'some comment';
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP PROCEDURE mysqltest_1.PROC_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT COUNT(*) FROM mysqltest_1.table2;
+REPAIR TABLE mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CHECK TABLE mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+ANALYZE TABLE mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SET GLOBAL new_cache.key_buffer_size=128*1024;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CACHE INDEX mysqltest_1.table2 IN new_cache;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+LOAD INDEX INTO CACHE mysqltest_1.table1 IGNORE LEAVES;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+TRUNCATE mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+FLUSH TABLES;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+--error ER_NO_SUCH_THREAD
+KILL 0;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+
+DROP VIEW mysqltest_1.view1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP TABLE mysqltest_1.table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP TABLE mysqltest_1.tmp_table1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SHOW TABLES FROM mysqltest_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SHOW DATABASES LIKE 'mysql%';
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+INSERT INTO mysqltest_1.table2 VALUES (1),(2),(3),(5),(8),(13),(21),(34),(51);
+PREPARE xyz FROM 'CREATE INDEX idx1 ON mysqltest_1.table2(c)';
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+EXECUTE xyz;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DEALLOCATE PREPARE xyz;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SHOW FIELDS FROM mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SHOW KEYS FROM mysqltest_1.table2;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SHOW TRIGGERS FROM mysqltest_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+LOCK TABLES mysqltest_1.table2 WRITE;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+UNLOCK TABLES;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+CREATE TRIGGER mysqltest_1.T2_insert BEFORE INSERT ON mysqltest_1.table2 FOR EACH ROW SET NEW.c=NEW.c;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP TRIGGER mysqltest_1.T2_insert;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+RENAME TABLE mysqltest_1.table2 TO mysqltest_1.table3;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+RENAME TABLE mysqltest_1.table3 TO mysqltest_1.table2;
+DROP TABLE mysqltest_1.tmp_table2;
+DROP TABLE mysqltest_1.tmp_table3;
+CREATE USER mysqltest_user@localhost;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+GRANT ALL ON mysqltest_1.* TO mysqltest_user@localhost;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+REVOKE ALL ON mysqltest_1.* FROM mysqltest_user@localhost;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP USER mysqltest_user@localhost;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP DATABASE mysqltest_1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+FLUSH QUERY CACHE;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DO COMPRESS("aaa");
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+
# End of 5.0 tests
+
--- 1.112/mysql-test/t/select.test 2006-10-17 17:45:34 +02:00
+++ 1.113/mysql-test/t/select.test 2006-10-17 17:45:34 +02:00
@@ -2998,3 +2998,31 @@ SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1
DROP TABLE t1,t2,t3;
+
+#
+# ROW_COUNT test
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1(a int);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+INSERT INTO t1 VALUES (1), (1), (2), (3), (5), (8), (13), (21);
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT COUNT(*) FROM t1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT * FROM t1 ORDER BY a;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT * FROM t1 ORDER BY a LIMIT 1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+SELECT a FROM t1 LIMIT 1 INTO @foobar;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
+DROP TABLE t1;
+SELECT ROW_COUNT();
+SELECT ROW_COUNT();
--- 1.32/sql/protocol.h 2006-10-17 17:45:34 +02:00
+++ 1.33/sql/protocol.h 2006-10-17 17:45:34 +02:00
@@ -162,8 +162,7 @@ public:
void send_warning(THD *thd, uint sql_errno, const char *err=0);
void net_printf_error(THD *thd, uint sql_errno, ...);
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
-void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L,
- const char *info=0);
+void send_ok(THD *thd, ulonglong id=0L, const char *info=0);
void send_eof(THD *thd);
bool send_old_password_request(THD *thd);
char *net_store_length(char *packet,uint length);
--- 1.183/sql/sql_prepare.cc 2006-10-17 17:45:34 +02:00
+++ 1.184/sql/sql_prepare.cc 2006-10-17 17:45:34 +02:00
@@ -2051,7 +2051,10 @@ void mysql_sql_stmt_prepare(THD *thd)
thd->stmt_map.erase(stmt);
}
else
- send_ok(thd, 0L, 0L, "Statement prepared");
+ {
+ thd->row_count_func= 0;
+ send_ok(thd, 0L, "Statement prepared");
+ }
DBUG_VOID_RETURN;
}
| Thread |
|---|
| • bk commit into 5.0 tree (andrey:1.2283) BUG#21818 | ahristov | 17 Oct |