4 * Fake definitions of the MySQL API sufficient to build tdbc::mysql
5 * without having an MySQL installation on the build system. This file
6 * comprises only data type, constant and function definitions.
8 * The programmers of this file believe that it contains material not
9 * subject to copyright under the doctrines of scenes a faire and
10 * of merger of idea and expression. Accordingly, this file is in the
13 *-----------------------------------------------------------------------------
16 #ifndef FAKEMYSQL_H_INCLUDED
17 #define FAKEMYSQL_H_INCLUDED
22 #define MODULE_SCOPE extern
25 MODULE_SCOPE Tcl_LoadHandle MysqlInitStubs(Tcl_Interp*);
28 #define STDCALL __stdcall
30 #define STDCALL /* nothing */
33 enum enum_field_types {
41 MYSQL_TYPE_TIMESTAMP=7,
42 MYSQL_TYPE_LONGLONG=8,
46 MYSQL_TYPE_DATETIME=12,
48 MYSQL_TYPE_NEWDATE=14,
49 MYSQL_TYPE_VARCHAR=15,
51 MYSQL_TYPE_NEWDECIMAL=246,
54 MYSQL_TYPE_TINY_BLOB=249,
55 MYSQL_TYPE_MEDIUM_BLOB=250,
56 MYSQL_TYPE_LONG_BLOB=251,
58 MYSQL_TYPE_VAR_STRING=253,
59 MYSQL_TYPE_STRING=254,
60 MYSQL_TYPE_GEOMETRY=255
64 MYSQL_SET_CHARSET_NAME=7,
71 #define CLIENT_COMPRESS 32
72 #define CLIENT_INTERACTIVE 1024
73 #define MYSQL_DATA_TRUNCATED 101
74 #define MYSQL_ERRMSG_SIZE 512
75 #define MYSQL_NO_DATA 100
76 #define SCRAMBLE_LENGTH 20
77 #define SQLSTATE_LENGTH 5
79 typedef struct st_list LIST;
80 typedef struct st_mem_root MEM_ROOT;
81 typedef struct st_mysql MYSQL;
82 typedef struct st_mysql_bind MYSQL_BIND;
83 typedef struct st_mysql_field MYSQL_FIELD;
84 typedef struct st_mysql_res MYSQL_RES;
85 typedef char** MYSQL_ROW;
86 typedef struct st_mysql_stmt MYSQL_STMT;
88 #ifndef Socket_defined
89 typedef int my_socket;
90 #define INVALID_SOCKET -1
92 typedef Tcl_WideUInt my_ulonglong;
93 typedef struct st_net NET;
94 typedef struct st_used_mem USED_MEM;
95 typedef struct st_vio Vio;
103 unsigned int block_num;
104 unsigned int first_block_usage;
105 void (*error_handler)(void);
108 struct st_mysql_options {
109 unsigned int connect_timeout;
110 unsigned int read_timeout;
111 unsigned int write_timeout;
113 unsigned int protocol;
114 unsigned long client_flag;
120 struct st_dynamic_array *init_commands;
130 char *shared_memory_base_name;
131 unsigned long max_allowed_packet;
133 my_bool compress,named_pipe;
136 my_bool no_master_reads;
137 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
138 my_bool separate_thread;
140 enum mysql_option methods_to_use;
143 my_bool report_data_truncation;
144 int (*local_infile_init)(void **, const char *, void *);
145 int (*local_infile_read)(void *, char *, unsigned int);
146 void (*local_infile_end)(void *);
147 int (*local_infile_error)(void *, char *, unsigned int);
148 void *local_infile_userdata;
153 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
156 unsigned char *buff_end;
157 unsigned char *write_pos;
158 unsigned char *read_pos;
160 unsigned long remain_in_buf;
161 unsigned long length;
162 unsigned long buf_length;
163 unsigned long where_b;
164 unsigned long max_packet;
165 unsigned long max_packet_size;
167 unsigned int compress_pkt_nr;
168 unsigned int write_timeout;
169 unsigned int read_timeout;
170 unsigned int retry_count;
172 unsigned int *return_status;
173 unsigned char reading_or_writing;
180 unsigned char *query_cache_query;
181 unsigned int last_errno;
184 my_bool return_errno;
185 char last_error[MYSQL_ERRMSG_SIZE];
186 char sqlstate[SQLSTATE_LENGTH+1];
188 #if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
189 my_bool skip_big_packet;
194 * st_mysql differs between 5.0 and 5.1, but the 5.0 version is a
195 * strict subset, we don't use any of the 5.1 fields, and we don't
196 * ever allocate the structure ourselves.
201 unsigned char *connector_fd;
206 char *server_version;
210 struct charset_info_st *charset;
212 MEM_ROOT field_alloc;
213 my_ulonglong affected_rows;
214 my_ulonglong insert_id;
215 my_ulonglong extra_info;
216 unsigned long thread_id;
217 unsigned long packet_length;
219 unsigned long client_flag;
220 unsigned long server_capabilities;
221 unsigned int protocol_version;
222 unsigned int field_count;
223 unsigned int server_status;
224 unsigned int server_language;
225 unsigned int warning_count;
226 struct st_mysql_options options;
227 enum mysql_status status;
230 char scramble[SCRAMBLE_LENGTH+1];
232 struct st_mysql *master;
233 struct st_mysql *next_slave;
234 struct st_mysql* last_used_slave;
235 struct st_mysql* last_used_con;
237 const struct st_mysql_methods *methods;
239 my_bool *unbuffered_fetch_owner;
244 * There are different version of the MYSQL_BIND structure before and after
245 * MySQL 5.1. We go after the fields of the structure using accessor functions
246 * so that the code in this file is compatible with both versions.
249 struct st_mysql_bind_51 { /* Post-5.1 */
250 unsigned long* length;
254 unsigned char* row_ptr;
255 void (*store_param_func)(NET* net, MYSQL_BIND* param);
256 void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
257 void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
258 unsigned long buffer_length;
259 unsigned long offset;
260 unsigned long length_value;
261 unsigned int param_number;
262 unsigned int pack_length;
263 enum enum_field_types buffer_type;
266 my_bool long_data_used;
267 my_bool is_null_value;
271 struct st_mysql_bind_50 { /* Pre-5.1 */
272 unsigned long* length;
276 enum enum_field_types buffer_type;
277 unsigned long buffer_length;
278 unsigned char* row_ptr;
279 unsigned long offset;
280 unsigned long length_value;
281 unsigned int param_number;
282 unsigned int pack_length;
285 my_bool long_data_used;
286 my_bool is_null_value;
287 void (*store_param_func)(NET* net, MYSQL_BIND* param);
288 void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
289 void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
293 * There are also different versions of the MYSQL_FIELD structure; fortunately,
294 * the 5.1 version is a strict extension of the 5.0 version.
297 struct st_mysql_field {
305 unsigned long length;
306 unsigned long max_length;
307 unsigned int name_length;
308 unsigned int org_name_length;
309 unsigned int table_length;
310 unsigned int org_table_length;
311 unsigned int db_length;
312 unsigned int catalog_length;
313 unsigned int def_length;
315 unsigned int decimals;
316 unsigned int charsetnr;
317 enum enum_field_types type;
319 struct st_mysql_field_50 {
320 struct st_mysql_field field;
322 struct st_mysql_field_51 {
323 struct st_mysql_field field;
326 #define NOT_NULL_FLAG 1
328 #define IS_NUM(t) ((t) <= MYSQL_TYPE_INT24 || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
330 #define mysql_library_init mysql_server_init
331 #define mysql_library_end mysql_server_end
333 #include "mysqlStubs.h"
335 #endif /* not FAKEMYSQL_H_INCLUDED */