diff options
author | monty@mashka.mysql.fi <> | 2002-10-02 13:33:08 +0300 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2002-10-02 13:33:08 +0300 |
commit | d69250a969449da43891ef5b2859df77917183a8 (patch) | |
tree | 5a27bda6d3f628af7dcb922ad022e84cf8cb351c /include | |
parent | 7134ffec210edde21860a2b2c2654be481de49b4 (diff) | |
download | mariadb-git-d69250a969449da43891ef5b2859df77917183a8.tar.gz |
Fixes and code cleanups after merge with 4.0.3
Warning handling and initial prepared statement handling (last not complete yet)
Changed a lot of functions that returned 0/1 to my_bool type.
GRANT handling now uses read/write locks instead of mutex
Change basic net functions to use THD instead of NET
(needed for 4.1 protocol)
Use my_sprintf instead of sprintf() + strlen()
Added alloc_query() to be able to chare query initialization code with
prepared statements.
Cleanup handling of SHOW COUNT(*) WARNINGS and SELECT LAST_INSERT_ID()
Note that the following test fails (will be fixed ASAP):
sub_select, union, rpl_rotate_logs and rpl_mystery22
Diffstat (limited to 'include')
-rw-r--r-- | include/errmsg.h | 21 | ||||
-rw-r--r-- | include/mysql.h | 133 | ||||
-rw-r--r-- | include/mysql_com.h | 46 | ||||
-rw-r--r-- | include/mysqld_error.h | 3 |
4 files changed, 110 insertions, 93 deletions
diff --git a/include/errmsg.h b/include/errmsg.h index 175089ba371..d97522f0972 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -63,15 +63,12 @@ extern const char *client_errors[]; /* Error messages */ #define CR_PROBE_MASTER_CONNECT 2025 /* new 4.1 error codes */ -#define CR_INVALID_CONN_HANDLE 2026 -#define CR_NULL_POINTER 2027 -#define CR_MEMORY_ERROR 2028 -#define CR_NO_PREPARE_STMT 2029 -#define CR_NOT_ALL_PARAMS_BOUND 2030 -#define CR_DATA_TRUNCATED 2031 -#define CR_NOT_ALL_BUFFERS_BOUND 2032 -#define CR_FAILED_TO_SET_PARAM_DATA 2033 -#define CR_NO_PARAMETERS_EXISTS 2033 -#define CR_INVALID_PARAMETER_NO 2035 -#define CR_INVALID_BUFFER_USE 2036 - +#define CR_INVALID_CONN_HANDLE 2026 +#define CR_NULL_POINTER 2027 +#define CR_NO_PREPARE_STMT 2028 +#define CR_NOT_ALL_PARAMS_BOUND 2029 +#define CR_DATA_TRUNCATED 2030 +#define CR_NO_PARAMETERS_EXISTS 2031 +#define CR_INVALID_PARAMETER_NO 2032 +#define CR_INVALID_BUFFER_USE 2033 +#define CR_UNSUPPORTED_PARAM_TYPE 2034 diff --git a/include/mysql.h b/include/mysql.h index 50543c51f6b..376de1a0e08 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -157,7 +157,8 @@ enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN }; -typedef struct st_mysql { +typedef struct st_mysql +{ NET net; /* Communication parameters */ gptr connector_fd; /* ConnectorFd for SSL */ char *host,*user,*passwd,*unix_socket,*server_version,*host_info, @@ -175,6 +176,7 @@ typedef struct st_mysql { unsigned int field_count; unsigned int server_status; unsigned int server_language; + unsigned int warning_count; struct st_mysql_options options; enum mysql_status status; my_bool free_me; /* If free in mysql_close */ @@ -273,12 +275,13 @@ my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); unsigned int STDCALL mysql_errno(MYSQL *mysql); const char * STDCALL mysql_error(MYSQL *mysql); +uint STDCALL mysql_warning_count(MYSQL *mysql); const char * STDCALL mysql_info(MYSQL *mysql); unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); MYSQL * STDCALL mysql_init(MYSQL *mysql); -int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, +my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, @@ -295,19 +298,19 @@ int STDCALL mysql_select_db(MYSQL *mysql, const char *db); int STDCALL mysql_query(MYSQL *mysql, const char *q); int STDCALL mysql_send_query(MYSQL *mysql, const char *q, unsigned long length); -int STDCALL mysql_read_query_result(MYSQL *mysql); +my_bool STDCALL mysql_read_query_result(MYSQL *mysql); int STDCALL mysql_real_query(MYSQL *mysql, const char *q, unsigned long length); /* perform query on master */ -int STDCALL mysql_master_query(MYSQL *mysql, const char *q, - unsigned long length); -int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, - unsigned long length); +my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q, + unsigned long length); +my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, + unsigned long length); /* perform query on slave */ -int STDCALL mysql_slave_query(MYSQL *mysql, const char *q, - unsigned long length); -int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, - unsigned long length); +my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q, + unsigned long length); +my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, + unsigned long length); /* enable/disable parsing of all queries to decide if they go on master or @@ -322,12 +325,12 @@ int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql); void STDCALL mysql_enable_reads_from_master(MYSQL* mysql); void STDCALL mysql_disable_reads_from_master(MYSQL* mysql); /* get the value of the master read flag */ -int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql); +my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql); enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len); /* discover the master and its slaves */ -int STDCALL mysql_rpl_probe(MYSQL* mysql); +my_bool STDCALL mysql_rpl_probe(MYSQL* mysql); /* set the master, close/free the old one, if it is not a pivot */ int STDCALL mysql_set_master(MYSQL* mysql, const char* host, @@ -357,6 +360,7 @@ MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_warnings(MYSQL *mysql); int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg); void STDCALL mysql_free_result(MYSQL_RES *result); @@ -401,7 +405,6 @@ int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, int res_buf_size); - /* The following definitions are added for the enhanced client-server protocol @@ -411,67 +414,76 @@ int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, enum MY_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE }; /* bind structure */ -typedef struct st_mysql_bind { - - enum enum_field_types buffer_type; /* buffer type */ - enum enum_field_types field_type; /* field type */ - gptr buffer; /* buffer */ - long *length; /* output length pointer */ - unsigned long buffer_length; /* buffer length */ - unsigned long bind_length; /* internal use */ - my_bool is_null; /* NULL indicator */ - my_bool is_long_data; /* long data indicator */ - my_bool long_ended; /* internal use */ - +typedef struct st_mysql_bind +{ + long *length; /* output length pointer */ + gptr buffer; /* buffer */ + unsigned long buffer_length; /* buffer length */ + enum enum_field_types buffer_type; /* buffer type */ + enum enum_field_types field_type; /* field type */ + my_bool is_null; /* NULL indicator */ + my_bool is_long_data; /* long data indicator */ + + /* The following are for internal use. Set by mysql_bind_param */ + long bind_length; /* Default length of data */ + my_bool long_ended; /* All data supplied for long */ + uint param_number; /* For null count and error messages */ + void (*store_param_func)(NET *net, struct st_mysql_bind *param); + char *(*fetch_result)(struct st_mysql_bind *, const char *row); } MYSQL_BIND; -/* statement handler */ -typedef struct st_mysql_stmt { - - MYSQL *mysql; /* connection handle */ - MYSQL_BIND *params; /* input parameters */ - MYSQL_RES *result; /* resultset */ - MYSQL_BIND *bind; /* row binding */ - MYSQL_FIELD *fields; /* prepare meta info */ - MEM_ROOT mem_root; /* root allocations */ - unsigned long param_count; /* parameters count */ - unsigned long field_count; /* fields count */ - unsigned long long_length; /* long buffer alloced length */ - uint err_no; /* error code */ - char error[MYSQL_ERRMSG_SIZE]; /* error message */ - char *query; /* query buffer */ - char *long_data; /* long buffer */ - enum MY_STMT_STATE state; /* statement state */ - my_bool long_alloced; /* flag to indicate long alloced */ - my_bool types_supplied; /* to indicate types supply */ +/* statement handler */ +typedef struct st_mysql_stmt +{ + MYSQL *mysql; /* connection handle */ + MYSQL_BIND *params; /* input parameters */ + MYSQL_RES *result; /* resultset */ + MYSQL_BIND *bind; /* row binding */ + MYSQL_FIELD *fields; /* prepare meta info */ + char *query; /* query buffer */ + MEM_ROOT mem_root; /* root allocations */ + MYSQL_RES tmp_result; /* Used by mysql_prepare_result */ + unsigned long param_count; /* parameters count */ + unsigned long field_count; /* fields count */ + unsigned long long_length; /* long buffer alloced length */ + ulong stmt_id; /* Id for prepared statement */ + uint last_errno; /* error code */ + enum MY_STMT_STATE state; /* statement state */ + char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ + my_bool long_alloced; /* flag to indicate long alloced */ + my_bool types_supplied; /* to indicate types supply */ } MYSQL_STMT; -MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query); +MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query, + unsigned long length); int STDCALL mysql_execute(MYSQL_STMT * stmt); unsigned long STDCALL mysql_param_count(MYSQL_STMT * stmt); -int STDCALL mysql_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bind); -int STDCALL mysql_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bind); -int STDCALL mysql_stmt_close(MYSQL_STMT * stmt); +my_bool STDCALL mysql_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bind); +my_bool STDCALL mysql_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bind); +my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt); uint STDCALL mysql_stmt_errno(MYSQL_STMT * stmt); const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt); -int STDCALL mysql_commit(MYSQL * mysql); -int STDCALL mysql_rollback(MYSQL * mysql); -int STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode); -int STDCALL mysql_fetch(MYSQL_STMT *stmt); +my_bool STDCALL mysql_commit(MYSQL * mysql); +my_bool STDCALL mysql_rollback(MYSQL * mysql); +my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode); +int STDCALL mysql_fetch(MYSQL_STMT *stmt); my_bool STDCALL mysql_send_long_data(MYSQL_STMT *stmt, - uint param_number,gptr data, - unsigned long length); -int STDCALL mysql_multi_query(MYSQL *mysql,const char *query,unsigned long len); + uint param_number, + const char *data, + unsigned long length, + my_bool last_data); +int STDCALL mysql_multi_query(MYSQL *mysql,const char *query, + unsigned long len); MYSQL_RES *STDCALL mysql_next_result(MYSQL *mysql); -MYSQL_RES * STDCALL mysql_prepare_result(MYSQL_STMT *stmt); +MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt); /* new status messages */ #define MYSQL_SUCCESS 0 #define MYSQL_WARNING 1 -#define MYSQL_ERROR -1 +#define MYSQL_STATUS_ERROR 2 #define MYSQL_NO_DATA 100 #define MYSQL_NEED_DATA 99 #define MYSQL_LONG_DATA_END 0xFF @@ -492,8 +504,9 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); They are not for general usage */ -int simple_command(MYSQL *mysql,enum enum_server_command command, - const char *arg, unsigned long length, my_bool skipp_check); +my_bool +simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, + ulong length, my_bool skip_check); unsigned long net_safe_read(MYSQL* mysql); #ifdef __cplusplus diff --git a/include/mysql_com.h b/include/mysql_com.h index 9743fc4c3f5..1edaa99db28 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -34,15 +34,15 @@ #define MYSQL_SERVICENAME "MySql" #endif /* __WIN__ */ -enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, - COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH, - COM_SHUTDOWN,COM_STATISTICS, - COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL, - COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT, - COM_CHANGE_USER, COM_BINLOG_DUMP, - COM_TABLE_DUMP, COM_CONNECT_OUT, - COM_REGISTER_SLAVE, - COM_PREPARE,COM_EXECUTE,COM_LONG_DATA }; +enum enum_server_command +{ + COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, + COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, + COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, + COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, + COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE, + COM_PREPARE, COM_EXECUTE, COM_LONG_DATA, COM_CLOSE_STMT +}; #define NOT_NULL_FLAG 1 /* Field can't be NULL */ #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ @@ -98,8 +98,9 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ #define CLIENT_PROTOCOL_41 16384 /* New 4.1 protocol */ -#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ -#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ +#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ +#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ +#define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */ #define MYSQL_ERRMSG_SIZE 200 #define NET_READ_TIMEOUT 30 /* Timeout on read */ @@ -203,21 +204,26 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, extern "C" { #endif -int my_net_init(NET *net, Vio* vio); +my_bool my_net_init(NET *net, Vio* vio); void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net); -int net_flush(NET *net); -int my_net_write(NET *net,const char *packet,unsigned long len); -int net_write_command(NET *net,unsigned char command,const char *packet, - unsigned long len); +my_bool net_realloc(NET *net, unsigned long length); +my_bool net_flush(NET *net); +my_bool my_net_write(NET *net,const char *packet,unsigned long len); +my_bool net_write_command(NET *net,unsigned char command, + const char *header, unsigned long head_len, + const char *packet, unsigned long len); int net_real_write(NET *net,const char *packet,unsigned long len); unsigned long my_net_read(NET *net); -/* The following function is not meant for normal usage */ +/* + The following function is not meant for normal usage + Currently it's used internally by manager.c +*/ struct sockaddr; -int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, - unsigned int timeout); +my_bool my_connect(my_socket s, const struct sockaddr *name, + unsigned int namelen, unsigned int timeout); struct rand_struct { unsigned long seed1,seed2,max_value; @@ -291,6 +297,6 @@ void my_thread_end(void); #endif #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ -#define MYSQL_LONG_DATA_END 0xFF /* For indication of long data ending */ +#define MYSQL_LONG_DATA_HEADER 8 #endif diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 635d8390c2c..fc5df43f309 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -257,4 +257,5 @@ #define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1238 #define ER_SUBSELECT_NO_1_COL 1239 #define ER_SUBSELECT_NO_1_ROW 1240 -#define ER_ERROR_MESSAGES 241 +#define ER_UNKNOWN_STMT_HANDLER 1241 +#define ER_ERROR_MESSAGES 242 |