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 /include | |
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 'include')
-rw-r--r-- | include/errmsg.h | 3 | ||||
-rw-r--r-- | include/mysql_com.h | 24 |
2 files changed, 24 insertions, 3 deletions
diff --git a/include/errmsg.h b/include/errmsg.h index e7b59ca8bd7..a6d8c770de8 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -96,6 +96,7 @@ extern const char *client_errors[]; /* Error messages */ #define CR_NOT_IMPLEMENTED 2054 #define CR_SERVER_LOST_EXTENDED 2055 #define CR_STMT_CLOSED 2056 -#define CR_ERROR_LAST /*Copy last error nr:*/ 2056 +#define CR_NEW_STMT_METADATA 2057 +#define CR_ERROR_LAST /*Copy last error nr:*/ 2057 /* Add error numbers before CR_ERROR_LAST and change it accordingly. */ diff --git a/include/mysql_com.h b/include/mysql_com.h index 25bf58e58ba..db5a5eb8741 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -184,19 +184,38 @@ enum enum_server_command #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ #define SERVER_QUERY_NO_GOOD_INDEX_USED 16 #define SERVER_QUERY_NO_INDEX_USED 32 -/* +/** The server was able to fulfill the clients request and opened a read-only non-scrollable cursor for a query. This flag comes in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. */ #define SERVER_STATUS_CURSOR_EXISTS 64 -/* +/** This flag is sent when a read-only cursor is exhausted, in reply to COM_STMT_FETCH command. */ #define SERVER_STATUS_LAST_ROW_SENT 128 #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 +/** + Sent to the client if after a prepared statement reprepare + we discovered that the new statement returns a different + number of result set columns. +*/ +#define SERVER_STATUS_METADATA_CHANGED 1024 + +/** + Server status flags that must be cleared when starting + execution of a new SQL statement. + Flags from this set are only added to the + current server status by the execution engine, but + never removed -- the execution engine expects them + to disappear automagically by the next command. +*/ +#define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \ + SERVER_QUERY_NO_INDEX_USED|\ + SERVER_MORE_RESULTS_EXISTS|\ + SERVER_STATUS_METADATA_CHANGED) #define MYSQL_ERRMSG_SIZE 512 #define NET_READ_TIMEOUT 30 /* Timeout on read */ @@ -205,6 +224,7 @@ enum enum_server_command #define ONLY_KILL_QUERY 1 + struct st_vio; /* Only C */ typedef struct st_vio Vio; |