summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <venu@myvenu.com>2002-06-12 13:47:32 -0700
committerunknown <venu@myvenu.com>2002-06-12 13:47:32 -0700
commit049a8386f3ce99e689f1dc3e562c29e7d8113e71 (patch)
tree828ffdb26c08300b6b8d2b10bcfc33bd2949f204 /include
parente413fd4c38735663c6122c7f7e509e3982f9296b (diff)
downloadmariadb-git-049a8386f3ce99e689f1dc3e562c29e7d8113e71.tar.gz
Client-Server Protocol 4.1 changes - Client side:
- Support of prepared execution - Support of Original Table and Column names - Support of direct transactional API - And lot of misc handling (Note that, the pull will not work, unless you have the Server side changes also which will be followed by this commit) BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'include')
-rw-r--r--include/errmsg.h14
-rw-r--r--include/mysql.h114
-rw-r--r--include/mysql_com.h80
3 files changed, 178 insertions, 30 deletions
diff --git a/include/errmsg.h b/include/errmsg.h
index 76a57f47611..175089ba371 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -61,3 +61,17 @@ extern const char *client_errors[]; /* Error messages */
#define CR_PROBE_SLAVE_HOSTS 2023
#define CR_PROBE_SLAVE_CONNECT 2024
#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
+
diff --git a/include/mysql.h b/include/mysql.h
index 5bcdca636c0..d667647d46d 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -68,16 +68,17 @@ extern char *mysql_unix_port;
#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
typedef struct st_mysql_field {
- char *name; /* Name of column */
- char *table; /* Table of column if column was a field */
- char *org_table; /* Org table name if table was an alias */
- char *db; /* Database for table */
- char *def; /* Default value (set by mysql_list_fields) */
- unsigned long length; /* Width of column */
- unsigned long max_length; /* Max width of selected set */
- unsigned int flags; /* Div flags */
- unsigned int decimals; /* Number of decimals in field */
- enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
+ char *name; /* Name of column */
+ char *org_name; /* Original column name, if column was an alias */
+ char *table; /* Table of column if column was a field */
+ char *org_table; /* Org table name, if table was an alias */
+ char *db; /* Database for table */
+ char *def; /* Default value (set by mysql_list_fields) */
+ unsigned long length; /* Width of column */
+ unsigned long max_length; /* Max width of selected set */
+ unsigned int flags; /* Div flags */
+ unsigned int decimals; /* Number of decimals in field */
+ enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
} MYSQL_FIELD;
typedef char **MYSQL_ROW; /* return data as array of strings */
@@ -101,6 +102,23 @@ typedef struct st_mysql_rows {
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
#include <my_alloc.h>
+#ifndef ST_USED_MEM_DEFINED
+#define ST_USED_MEM_DEFINED
+typedef struct st_used_mem { /* struct for once_alloc */
+ struct st_used_mem *next; /* Next block in use */
+ unsigned int left; /* memory left in block */
+ unsigned int size; /* size of block */
+} USED_MEM;
+typedef struct st_mem_root {
+ USED_MEM *free;
+ USED_MEM *used;
+ USED_MEM *pre_alloc;
+ unsigned int min_malloc;
+ unsigned int block_size;
+
+ void (*error_handler)(void);
+} MEM_ROOT;
+#endif
typedef struct st_mysql_data {
my_ulonglong rows;
@@ -391,6 +409,82 @@ int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
char* res_buf,
int res_buf_size);
+
+
+
+/*
+ The following definations are added for the enhanced
+ client-server protocol
+*/
+
+/* statement state */
+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 */
+ ulong buffer_length; /* buffer length */
+ ulong bind_length; /* internal use */
+ my_bool is_null; /* NULL indicator */
+ my_bool is_long_data; /* long data indicator */
+ my_bool long_ended; /* internal use */
+
+} 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 */
+ ulong param_count; /* parameters count */
+ ulong field_count; /* fields count */
+ ulong 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 */
+
+} MYSQL_STMT;
+
+
+MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query);
+int STDCALL mysql_execute(MYSQL_STMT * stmt);
+ulong 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);
+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_send_long_data(MYSQL_STMT *stmt,
+ uint param_number,gptr data, ulong length);
+int STDCALL mysql_multi_query(MYSQL *mysql,const char *query,ulong length);
+MYSQL_RES *STDCALL mysql_next_result(MYSQL *mysql);
+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_NO_DATA 100
+#define MYSQL_NEED_DATA 99
+#define MYSQL_LONG_DATA_END 0xFF
+
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#ifdef USE_OLD_FUNCTIONS
diff --git a/include/mysql_com.h b/include/mysql_com.h
index c30eb30f779..c259259c9e2 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -42,7 +42,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
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_REGISTER_SLAVE,
+ COM_PREPARE,COM_EXECUTE,COM_LONG_DATA };
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
@@ -96,6 +97,7 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
#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 */
@@ -136,27 +138,64 @@ typedef struct st_net {
#define packet_error (~(unsigned long) 0)
-enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
- FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
- FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
- FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
- FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
- FIELD_TYPE_DATE, FIELD_TYPE_TIME,
- FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
- FIELD_TYPE_NEWDATE,
- FIELD_TYPE_ENUM=247,
- FIELD_TYPE_SET=248,
- FIELD_TYPE_TINY_BLOB=249,
- FIELD_TYPE_MEDIUM_BLOB=250,
- FIELD_TYPE_LONG_BLOB=251,
- FIELD_TYPE_BLOB=252,
- FIELD_TYPE_VAR_STRING=253,
- FIELD_TYPE_STRING=254,
- FIELD_TYPE_GEOMETRY=255
+enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
+ MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
+ MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
+ MYSQL_TYPE_NEWDATE,
+ MYSQL_TYPE_ENUM=247,
+ MYSQL_TYPE_SET=248,
+ MYSQL_TYPE_TINY_BLOB=249,
+ MYSQL_TYPE_MEDIUM_BLOB=250,
+ MYSQL_TYPE_LONG_BLOB=251,
+ MYSQL_TYPE_BLOB=252,
+ MYSQL_TYPE_VAR_STRING=253,
+ MYSQL_TYPE_STRING=254,
+ MYSQL_TYPE_GEOMETRY=255
+
};
-#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
-#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
+/* For backward compatibility */
+#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
+#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
+#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
+#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
+#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
+#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
+#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
+#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
+#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
+#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
+#define FIELD_TYPE_DATE MYSQL_TYPE_DATE
+#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
+#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
+#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
+#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
+#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
+#define FIELD_TYPE_SET MYSQL_TYPE_SET
+#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
+#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
+#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
+#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
+#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
+#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
+#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
+#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
+#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
+
+#if TO_BE_INCLUDED_LATER
+/* For bind applications, to indicate unsigned buffers */
+#define MYSQL_TYPE_UTINY -10
+#define MYSQL_TYPE_USHORT -9
+#define MYSQL_TYPE_ULONG -8
+#define MYSQL_TYPE_UFLOAT -7
+#define MYSQL_TYPE_UDOUBLE -6
+#define MYSQL_TYPE_ULONGLONG -5
+#define MYSQL_TYPE_UINT24 -4
+#endif
#define net_new_transaction(net) ((net)->pkt_nr=0)
@@ -251,5 +290,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 */
#endif