annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/fakemysql.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * fakemysql.h --
jpayne@69 3 *
jpayne@69 4 * Fake definitions of the MySQL API sufficient to build tdbc::mysql
jpayne@69 5 * without having an MySQL installation on the build system. This file
jpayne@69 6 * comprises only data type, constant and function definitions.
jpayne@69 7 *
jpayne@69 8 * The programmers of this file believe that it contains material not
jpayne@69 9 * subject to copyright under the doctrines of scenes a faire and
jpayne@69 10 * of merger of idea and expression. Accordingly, this file is in the
jpayne@69 11 * public domain.
jpayne@69 12 *
jpayne@69 13 *-----------------------------------------------------------------------------
jpayne@69 14 */
jpayne@69 15
jpayne@69 16 #ifndef FAKEMYSQL_H_INCLUDED
jpayne@69 17 #define FAKEMYSQL_H_INCLUDED
jpayne@69 18
jpayne@69 19 #include <stddef.h>
jpayne@69 20
jpayne@69 21 #ifndef MODULE_SCOPE
jpayne@69 22 #define MODULE_SCOPE extern
jpayne@69 23 #endif
jpayne@69 24
jpayne@69 25 MODULE_SCOPE Tcl_LoadHandle MysqlInitStubs(Tcl_Interp*);
jpayne@69 26
jpayne@69 27 #ifdef _WIN32
jpayne@69 28 #define STDCALL __stdcall
jpayne@69 29 #else
jpayne@69 30 #define STDCALL /* nothing */
jpayne@69 31 #endif
jpayne@69 32
jpayne@69 33 enum enum_field_types {
jpayne@69 34 MYSQL_TYPE_DECIMAL=0,
jpayne@69 35 MYSQL_TYPE_TINY=1,
jpayne@69 36 MYSQL_TYPE_SHORT=2,
jpayne@69 37 MYSQL_TYPE_LONG=3,
jpayne@69 38 MYSQL_TYPE_FLOAT=4,
jpayne@69 39 MYSQL_TYPE_DOUBLE=5,
jpayne@69 40 MYSQL_TYPE_NULL=6,
jpayne@69 41 MYSQL_TYPE_TIMESTAMP=7,
jpayne@69 42 MYSQL_TYPE_LONGLONG=8,
jpayne@69 43 MYSQL_TYPE_INT24=9,
jpayne@69 44 MYSQL_TYPE_DATE=10,
jpayne@69 45 MYSQL_TYPE_TIME=11,
jpayne@69 46 MYSQL_TYPE_DATETIME=12,
jpayne@69 47 MYSQL_TYPE_YEAR=13,
jpayne@69 48 MYSQL_TYPE_NEWDATE=14,
jpayne@69 49 MYSQL_TYPE_VARCHAR=15,
jpayne@69 50 MYSQL_TYPE_BIT=16,
jpayne@69 51 MYSQL_TYPE_NEWDECIMAL=246,
jpayne@69 52 MYSQL_TYPE_ENUM=247,
jpayne@69 53 MYSQL_TYPE_SET=248,
jpayne@69 54 MYSQL_TYPE_TINY_BLOB=249,
jpayne@69 55 MYSQL_TYPE_MEDIUM_BLOB=250,
jpayne@69 56 MYSQL_TYPE_LONG_BLOB=251,
jpayne@69 57 MYSQL_TYPE_BLOB=252,
jpayne@69 58 MYSQL_TYPE_VAR_STRING=253,
jpayne@69 59 MYSQL_TYPE_STRING=254,
jpayne@69 60 MYSQL_TYPE_GEOMETRY=255
jpayne@69 61 };
jpayne@69 62
jpayne@69 63 enum mysql_option {
jpayne@69 64 MYSQL_SET_CHARSET_NAME=7,
jpayne@69 65 };
jpayne@69 66
jpayne@69 67 enum mysql_status {
jpayne@69 68 MYSQL_STATUS_READY=0,
jpayne@69 69 };
jpayne@69 70
jpayne@69 71 #define CLIENT_COMPRESS 32
jpayne@69 72 #define CLIENT_INTERACTIVE 1024
jpayne@69 73 #define MYSQL_DATA_TRUNCATED 101
jpayne@69 74 #define MYSQL_ERRMSG_SIZE 512
jpayne@69 75 #define MYSQL_NO_DATA 100
jpayne@69 76 #define SCRAMBLE_LENGTH 20
jpayne@69 77 #define SQLSTATE_LENGTH 5
jpayne@69 78
jpayne@69 79 typedef struct st_list LIST;
jpayne@69 80 typedef struct st_mem_root MEM_ROOT;
jpayne@69 81 typedef struct st_mysql MYSQL;
jpayne@69 82 typedef struct st_mysql_bind MYSQL_BIND;
jpayne@69 83 typedef struct st_mysql_field MYSQL_FIELD;
jpayne@69 84 typedef struct st_mysql_res MYSQL_RES;
jpayne@69 85 typedef char** MYSQL_ROW;
jpayne@69 86 typedef struct st_mysql_stmt MYSQL_STMT;
jpayne@69 87 typedef char my_bool;
jpayne@69 88 #ifndef Socket_defined
jpayne@69 89 typedef int my_socket;
jpayne@69 90 #define INVALID_SOCKET -1
jpayne@69 91 #endif
jpayne@69 92 typedef Tcl_WideUInt my_ulonglong;
jpayne@69 93 typedef struct st_net NET;
jpayne@69 94 typedef struct st_used_mem USED_MEM;
jpayne@69 95 typedef struct st_vio Vio;
jpayne@69 96
jpayne@69 97 struct st_mem_root {
jpayne@69 98 USED_MEM *free;
jpayne@69 99 USED_MEM *used;
jpayne@69 100 USED_MEM *pre_alloc;
jpayne@69 101 size_t min_malloc;
jpayne@69 102 size_t block_size;
jpayne@69 103 unsigned int block_num;
jpayne@69 104 unsigned int first_block_usage;
jpayne@69 105 void (*error_handler)(void);
jpayne@69 106 };
jpayne@69 107
jpayne@69 108 struct st_mysql_options {
jpayne@69 109 unsigned int connect_timeout;
jpayne@69 110 unsigned int read_timeout;
jpayne@69 111 unsigned int write_timeout;
jpayne@69 112 unsigned int port;
jpayne@69 113 unsigned int protocol;
jpayne@69 114 unsigned long client_flag;
jpayne@69 115 char *host;
jpayne@69 116 char *user;
jpayne@69 117 char *password;
jpayne@69 118 char *unix_socket;
jpayne@69 119 char *db;
jpayne@69 120 struct st_dynamic_array *init_commands;
jpayne@69 121 char *my_cnf_file;
jpayne@69 122 char *my_cnf_group;
jpayne@69 123 char *charset_dir;
jpayne@69 124 char *charset_name;
jpayne@69 125 char *ssl_key;
jpayne@69 126 char *ssl_cert;
jpayne@69 127 char *ssl_ca;
jpayne@69 128 char *ssl_capath;
jpayne@69 129 char *ssl_cipher;
jpayne@69 130 char *shared_memory_base_name;
jpayne@69 131 unsigned long max_allowed_packet;
jpayne@69 132 my_bool use_ssl;
jpayne@69 133 my_bool compress,named_pipe;
jpayne@69 134 my_bool rpl_probe;
jpayne@69 135 my_bool rpl_parse;
jpayne@69 136 my_bool no_master_reads;
jpayne@69 137 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
jpayne@69 138 my_bool separate_thread;
jpayne@69 139 #endif
jpayne@69 140 enum mysql_option methods_to_use;
jpayne@69 141 char *client_ip;
jpayne@69 142 my_bool secure_auth;
jpayne@69 143 my_bool report_data_truncation;
jpayne@69 144 int (*local_infile_init)(void **, const char *, void *);
jpayne@69 145 int (*local_infile_read)(void *, char *, unsigned int);
jpayne@69 146 void (*local_infile_end)(void *);
jpayne@69 147 int (*local_infile_error)(void *, char *, unsigned int);
jpayne@69 148 void *local_infile_userdata;
jpayne@69 149 void *extension;
jpayne@69 150 };
jpayne@69 151
jpayne@69 152 struct st_net {
jpayne@69 153 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
jpayne@69 154 Vio *vio;
jpayne@69 155 unsigned char *buff;
jpayne@69 156 unsigned char *buff_end;
jpayne@69 157 unsigned char *write_pos;
jpayne@69 158 unsigned char *read_pos;
jpayne@69 159 my_socket fd;
jpayne@69 160 unsigned long remain_in_buf;
jpayne@69 161 unsigned long length;
jpayne@69 162 unsigned long buf_length;
jpayne@69 163 unsigned long where_b;
jpayne@69 164 unsigned long max_packet;
jpayne@69 165 unsigned long max_packet_size;
jpayne@69 166 unsigned int pkt_nr;
jpayne@69 167 unsigned int compress_pkt_nr;
jpayne@69 168 unsigned int write_timeout;
jpayne@69 169 unsigned int read_timeout;
jpayne@69 170 unsigned int retry_count;
jpayne@69 171 int fcntl;
jpayne@69 172 unsigned int *return_status;
jpayne@69 173 unsigned char reading_or_writing;
jpayne@69 174 char save_char;
jpayne@69 175 my_bool unused0;
jpayne@69 176 my_bool unused;
jpayne@69 177 my_bool compress;
jpayne@69 178 my_bool unused1;
jpayne@69 179 #endif
jpayne@69 180 unsigned char *query_cache_query;
jpayne@69 181 unsigned int last_errno;
jpayne@69 182 unsigned char error;
jpayne@69 183 my_bool unused2;
jpayne@69 184 my_bool return_errno;
jpayne@69 185 char last_error[MYSQL_ERRMSG_SIZE];
jpayne@69 186 char sqlstate[SQLSTATE_LENGTH+1];
jpayne@69 187 void *extension;
jpayne@69 188 #if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
jpayne@69 189 my_bool skip_big_packet;
jpayne@69 190 #endif
jpayne@69 191 };
jpayne@69 192
jpayne@69 193 /*
jpayne@69 194 * st_mysql differs between 5.0 and 5.1, but the 5.0 version is a
jpayne@69 195 * strict subset, we don't use any of the 5.1 fields, and we don't
jpayne@69 196 * ever allocate the structure ourselves.
jpayne@69 197 */
jpayne@69 198
jpayne@69 199 struct st_mysql {
jpayne@69 200 NET net;
jpayne@69 201 unsigned char *connector_fd;
jpayne@69 202 char *host;
jpayne@69 203 char *user;
jpayne@69 204 char *passwd;
jpayne@69 205 char *unix_socket;
jpayne@69 206 char *server_version;
jpayne@69 207 char *host_info;
jpayne@69 208 char *info;
jpayne@69 209 char *db;
jpayne@69 210 struct charset_info_st *charset;
jpayne@69 211 MYSQL_FIELD *fields;
jpayne@69 212 MEM_ROOT field_alloc;
jpayne@69 213 my_ulonglong affected_rows;
jpayne@69 214 my_ulonglong insert_id;
jpayne@69 215 my_ulonglong extra_info;
jpayne@69 216 unsigned long thread_id;
jpayne@69 217 unsigned long packet_length;
jpayne@69 218 unsigned int port;
jpayne@69 219 unsigned long client_flag;
jpayne@69 220 unsigned long server_capabilities;
jpayne@69 221 unsigned int protocol_version;
jpayne@69 222 unsigned int field_count;
jpayne@69 223 unsigned int server_status;
jpayne@69 224 unsigned int server_language;
jpayne@69 225 unsigned int warning_count;
jpayne@69 226 struct st_mysql_options options;
jpayne@69 227 enum mysql_status status;
jpayne@69 228 my_bool free_me;
jpayne@69 229 my_bool reconnect;
jpayne@69 230 char scramble[SCRAMBLE_LENGTH+1];
jpayne@69 231 my_bool rpl_pivot;
jpayne@69 232 struct st_mysql *master;
jpayne@69 233 struct st_mysql *next_slave;
jpayne@69 234 struct st_mysql* last_used_slave;
jpayne@69 235 struct st_mysql* last_used_con;
jpayne@69 236 LIST *stmts;
jpayne@69 237 const struct st_mysql_methods *methods;
jpayne@69 238 void *thd;
jpayne@69 239 my_bool *unbuffered_fetch_owner;
jpayne@69 240 char *info_buffer;
jpayne@69 241 };
jpayne@69 242
jpayne@69 243 /*
jpayne@69 244 * There are different version of the MYSQL_BIND structure before and after
jpayne@69 245 * MySQL 5.1. We go after the fields of the structure using accessor functions
jpayne@69 246 * so that the code in this file is compatible with both versions.
jpayne@69 247 */
jpayne@69 248
jpayne@69 249 struct st_mysql_bind_51 { /* Post-5.1 */
jpayne@69 250 unsigned long* length;
jpayne@69 251 my_bool* is_null;
jpayne@69 252 void* buffer;
jpayne@69 253 my_bool* error;
jpayne@69 254 unsigned char* row_ptr;
jpayne@69 255 void (*store_param_func)(NET* net, MYSQL_BIND* param);
jpayne@69 256 void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
jpayne@69 257 void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
jpayne@69 258 unsigned long buffer_length;
jpayne@69 259 unsigned long offset;
jpayne@69 260 unsigned long length_value;
jpayne@69 261 unsigned int param_number;
jpayne@69 262 unsigned int pack_length;
jpayne@69 263 enum enum_field_types buffer_type;
jpayne@69 264 my_bool error_value;
jpayne@69 265 my_bool is_unsigned;
jpayne@69 266 my_bool long_data_used;
jpayne@69 267 my_bool is_null_value;
jpayne@69 268 void* extension;
jpayne@69 269 };
jpayne@69 270
jpayne@69 271 struct st_mysql_bind_50 { /* Pre-5.1 */
jpayne@69 272 unsigned long* length;
jpayne@69 273 my_bool* is_null;
jpayne@69 274 void* buffer;
jpayne@69 275 my_bool* error;
jpayne@69 276 enum enum_field_types buffer_type;
jpayne@69 277 unsigned long buffer_length;
jpayne@69 278 unsigned char* row_ptr;
jpayne@69 279 unsigned long offset;
jpayne@69 280 unsigned long length_value;
jpayne@69 281 unsigned int param_number;
jpayne@69 282 unsigned int pack_length;
jpayne@69 283 my_bool error_value;
jpayne@69 284 my_bool is_unsigned;
jpayne@69 285 my_bool long_data_used;
jpayne@69 286 my_bool is_null_value;
jpayne@69 287 void (*store_param_func)(NET* net, MYSQL_BIND* param);
jpayne@69 288 void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
jpayne@69 289 void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**);
jpayne@69 290 };
jpayne@69 291
jpayne@69 292 /*
jpayne@69 293 * There are also different versions of the MYSQL_FIELD structure; fortunately,
jpayne@69 294 * the 5.1 version is a strict extension of the 5.0 version.
jpayne@69 295 */
jpayne@69 296
jpayne@69 297 struct st_mysql_field {
jpayne@69 298 char* name;
jpayne@69 299 char *org_name;
jpayne@69 300 char* table;
jpayne@69 301 char* org_table;
jpayne@69 302 char* db;
jpayne@69 303 char* catalog;
jpayne@69 304 char* def;
jpayne@69 305 unsigned long length;
jpayne@69 306 unsigned long max_length;
jpayne@69 307 unsigned int name_length;
jpayne@69 308 unsigned int org_name_length;
jpayne@69 309 unsigned int table_length;
jpayne@69 310 unsigned int org_table_length;
jpayne@69 311 unsigned int db_length;
jpayne@69 312 unsigned int catalog_length;
jpayne@69 313 unsigned int def_length;
jpayne@69 314 unsigned int flags;
jpayne@69 315 unsigned int decimals;
jpayne@69 316 unsigned int charsetnr;
jpayne@69 317 enum enum_field_types type;
jpayne@69 318 };
jpayne@69 319 struct st_mysql_field_50 {
jpayne@69 320 struct st_mysql_field field;
jpayne@69 321 };
jpayne@69 322 struct st_mysql_field_51 {
jpayne@69 323 struct st_mysql_field field;
jpayne@69 324 void* extension;
jpayne@69 325 };
jpayne@69 326 #define NOT_NULL_FLAG 1
jpayne@69 327
jpayne@69 328 #define IS_NUM(t) ((t) <= MYSQL_TYPE_INT24 || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
jpayne@69 329
jpayne@69 330 #define mysql_library_init mysql_server_init
jpayne@69 331 #define mysql_library_end mysql_server_end
jpayne@69 332
jpayne@69 333 #include "mysqlStubs.h"
jpayne@69 334
jpayne@69 335 #endif /* not FAKEMYSQL_H_INCLUDED */