diff options
author | unknown <kostja@bodhi.(none)> | 2008-05-20 20:36:26 +0400 |
---|---|---|
committer | unknown <kostja@bodhi.(none)> | 2008-05-20 20:36:26 +0400 |
commit | 02c901ee5eea72ad0b366066027ba5c6a2438258 (patch) | |
tree | d253d230a92a5e5b0cd4824c58c4baef794fb3b0 /sql/sql_parse.cc | |
parent | 4175806efca7644c41ab77e5a8f07d1cc5a1ac00 (diff) | |
download | mariadb-git-02c901ee5eea72ad0b366066027ba5c6a2438258.tar.gz |
Bug#27430 "Crash in subquery code when in PS and table DDL changed after
PREPARE", review fixes:
- make the patch follow the specification of WL#4166 and remove
the new error that was originally introduced.
Now the client never gets an error from reprepare, unless it failed.
I.e. even if the statement at hand returns a completely different
result set, this is not considered a server error.
The C API library, that can not handle this situation, was modified to
return a client error.
Added additional test coverage.
include/errmsg.h:
Add a new client side error: now when we automatically
reprepare a statement, the new result set may contain a different
number of columns.
include/mysql_com.h:
Add a new server status to be sent to the client if the
number of columns in the result set is different.
libmysql/errmsg.c:
Add a new error message.
libmysql/libmysql.c:
Make the client library robust against a result set that
contains a different number of columns from prepare time.
Previously that could never happen, and we simply had an assert.
That means in particular that all clients are advised to upgrade
with transition to 5.1, if they are using prepared statements C API.
Make mysql_stmt_store_result() and mysql_stmt_execute() robust against
"broken" statement handles (those that have an error).
sql/sql_parse.cc:
Clear transient server status flags at start of statement more
systematically.
sql/share/errmsg.txt:
Remove an error that is unused and is not part of any public release.
sql/sql_prepare.cc:
Instead of returning an error in case the number of result set columns
has changed, simply update the client in server status.
That will allow modern clients automatically recover from an error.
tests/mysql_client_test.c:
Add additional coverage to the cases when the number of result
set columns changed as a result of reprepare.
Cover conversion and truncation of result set columns.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ee251e6511b..b8f2228d6e7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -914,8 +914,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* TODO: set thd->lex->sql_command to SQLCOM_END here */ VOID(pthread_mutex_unlock(&LOCK_thread_count)); - thd->server_status&= - ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); + /** + Clear the set of flags that are expected to be cleared at the + beginning of each command. + */ + thd->server_status&= ~SERVER_STATUS_CLEAR_SET; switch (command) { case COM_INIT_DB: { @@ -5377,9 +5380,11 @@ void mysql_reset_thd_for_next_command(THD *thd) thd->query_start_used= 0; thd->is_fatal_error= thd->time_zone_used= 0; - thd->server_status&= ~ (SERVER_MORE_RESULTS_EXISTS | - SERVER_QUERY_NO_INDEX_USED | - SERVER_QUERY_NO_GOOD_INDEX_USED); + /* + Clear the status flag that are expected to be cleared at the + beginning of each SQL statement. + */ + thd->server_status&= ~SERVER_STATUS_CLEAR_SET; /* If in autocommit mode and not in a transaction, reset OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG to not get warnings |