jpayne@69: /* jpayne@69: * fakemysql.h -- jpayne@69: * jpayne@69: * Fake definitions of the MySQL API sufficient to build tdbc::mysql jpayne@69: * without having an MySQL installation on the build system. This file jpayne@69: * comprises only data type, constant and function definitions. jpayne@69: * jpayne@69: * The programmers of this file believe that it contains material not jpayne@69: * subject to copyright under the doctrines of scenes a faire and jpayne@69: * of merger of idea and expression. Accordingly, this file is in the jpayne@69: * public domain. jpayne@69: * jpayne@69: *----------------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: #ifndef FAKEMYSQL_H_INCLUDED jpayne@69: #define FAKEMYSQL_H_INCLUDED jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: #ifndef MODULE_SCOPE jpayne@69: #define MODULE_SCOPE extern jpayne@69: #endif jpayne@69: jpayne@69: MODULE_SCOPE Tcl_LoadHandle MysqlInitStubs(Tcl_Interp*); jpayne@69: jpayne@69: #ifdef _WIN32 jpayne@69: #define STDCALL __stdcall jpayne@69: #else jpayne@69: #define STDCALL /* nothing */ jpayne@69: #endif jpayne@69: jpayne@69: enum enum_field_types { jpayne@69: MYSQL_TYPE_DECIMAL=0, jpayne@69: MYSQL_TYPE_TINY=1, jpayne@69: MYSQL_TYPE_SHORT=2, jpayne@69: MYSQL_TYPE_LONG=3, jpayne@69: MYSQL_TYPE_FLOAT=4, jpayne@69: MYSQL_TYPE_DOUBLE=5, jpayne@69: MYSQL_TYPE_NULL=6, jpayne@69: MYSQL_TYPE_TIMESTAMP=7, jpayne@69: MYSQL_TYPE_LONGLONG=8, jpayne@69: MYSQL_TYPE_INT24=9, jpayne@69: MYSQL_TYPE_DATE=10, jpayne@69: MYSQL_TYPE_TIME=11, jpayne@69: MYSQL_TYPE_DATETIME=12, jpayne@69: MYSQL_TYPE_YEAR=13, jpayne@69: MYSQL_TYPE_NEWDATE=14, jpayne@69: MYSQL_TYPE_VARCHAR=15, jpayne@69: MYSQL_TYPE_BIT=16, jpayne@69: MYSQL_TYPE_NEWDECIMAL=246, jpayne@69: MYSQL_TYPE_ENUM=247, jpayne@69: MYSQL_TYPE_SET=248, jpayne@69: MYSQL_TYPE_TINY_BLOB=249, jpayne@69: MYSQL_TYPE_MEDIUM_BLOB=250, jpayne@69: MYSQL_TYPE_LONG_BLOB=251, jpayne@69: MYSQL_TYPE_BLOB=252, jpayne@69: MYSQL_TYPE_VAR_STRING=253, jpayne@69: MYSQL_TYPE_STRING=254, jpayne@69: MYSQL_TYPE_GEOMETRY=255 jpayne@69: }; jpayne@69: jpayne@69: enum mysql_option { jpayne@69: MYSQL_SET_CHARSET_NAME=7, jpayne@69: }; jpayne@69: jpayne@69: enum mysql_status { jpayne@69: MYSQL_STATUS_READY=0, jpayne@69: }; jpayne@69: jpayne@69: #define CLIENT_COMPRESS 32 jpayne@69: #define CLIENT_INTERACTIVE 1024 jpayne@69: #define MYSQL_DATA_TRUNCATED 101 jpayne@69: #define MYSQL_ERRMSG_SIZE 512 jpayne@69: #define MYSQL_NO_DATA 100 jpayne@69: #define SCRAMBLE_LENGTH 20 jpayne@69: #define SQLSTATE_LENGTH 5 jpayne@69: jpayne@69: typedef struct st_list LIST; jpayne@69: typedef struct st_mem_root MEM_ROOT; jpayne@69: typedef struct st_mysql MYSQL; jpayne@69: typedef struct st_mysql_bind MYSQL_BIND; jpayne@69: typedef struct st_mysql_field MYSQL_FIELD; jpayne@69: typedef struct st_mysql_res MYSQL_RES; jpayne@69: typedef char** MYSQL_ROW; jpayne@69: typedef struct st_mysql_stmt MYSQL_STMT; jpayne@69: typedef char my_bool; jpayne@69: #ifndef Socket_defined jpayne@69: typedef int my_socket; jpayne@69: #define INVALID_SOCKET -1 jpayne@69: #endif jpayne@69: typedef Tcl_WideUInt my_ulonglong; jpayne@69: typedef struct st_net NET; jpayne@69: typedef struct st_used_mem USED_MEM; jpayne@69: typedef struct st_vio Vio; jpayne@69: jpayne@69: struct st_mem_root { jpayne@69: USED_MEM *free; jpayne@69: USED_MEM *used; jpayne@69: USED_MEM *pre_alloc; jpayne@69: size_t min_malloc; jpayne@69: size_t block_size; jpayne@69: unsigned int block_num; jpayne@69: unsigned int first_block_usage; jpayne@69: void (*error_handler)(void); jpayne@69: }; jpayne@69: jpayne@69: struct st_mysql_options { jpayne@69: unsigned int connect_timeout; jpayne@69: unsigned int read_timeout; jpayne@69: unsigned int write_timeout; jpayne@69: unsigned int port; jpayne@69: unsigned int protocol; jpayne@69: unsigned long client_flag; jpayne@69: char *host; jpayne@69: char *user; jpayne@69: char *password; jpayne@69: char *unix_socket; jpayne@69: char *db; jpayne@69: struct st_dynamic_array *init_commands; jpayne@69: char *my_cnf_file; jpayne@69: char *my_cnf_group; jpayne@69: char *charset_dir; jpayne@69: char *charset_name; jpayne@69: char *ssl_key; jpayne@69: char *ssl_cert; jpayne@69: char *ssl_ca; jpayne@69: char *ssl_capath; jpayne@69: char *ssl_cipher; jpayne@69: char *shared_memory_base_name; jpayne@69: unsigned long max_allowed_packet; jpayne@69: my_bool use_ssl; jpayne@69: my_bool compress,named_pipe; jpayne@69: my_bool rpl_probe; jpayne@69: my_bool rpl_parse; jpayne@69: my_bool no_master_reads; jpayne@69: #if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY) jpayne@69: my_bool separate_thread; jpayne@69: #endif jpayne@69: enum mysql_option methods_to_use; jpayne@69: char *client_ip; jpayne@69: my_bool secure_auth; jpayne@69: my_bool report_data_truncation; jpayne@69: int (*local_infile_init)(void **, const char *, void *); jpayne@69: int (*local_infile_read)(void *, char *, unsigned int); jpayne@69: void (*local_infile_end)(void *); jpayne@69: int (*local_infile_error)(void *, char *, unsigned int); jpayne@69: void *local_infile_userdata; jpayne@69: void *extension; jpayne@69: }; jpayne@69: jpayne@69: struct st_net { jpayne@69: #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) jpayne@69: Vio *vio; jpayne@69: unsigned char *buff; jpayne@69: unsigned char *buff_end; jpayne@69: unsigned char *write_pos; jpayne@69: unsigned char *read_pos; jpayne@69: my_socket fd; jpayne@69: unsigned long remain_in_buf; jpayne@69: unsigned long length; jpayne@69: unsigned long buf_length; jpayne@69: unsigned long where_b; jpayne@69: unsigned long max_packet; jpayne@69: unsigned long max_packet_size; jpayne@69: unsigned int pkt_nr; jpayne@69: unsigned int compress_pkt_nr; jpayne@69: unsigned int write_timeout; jpayne@69: unsigned int read_timeout; jpayne@69: unsigned int retry_count; jpayne@69: int fcntl; jpayne@69: unsigned int *return_status; jpayne@69: unsigned char reading_or_writing; jpayne@69: char save_char; jpayne@69: my_bool unused0; jpayne@69: my_bool unused; jpayne@69: my_bool compress; jpayne@69: my_bool unused1; jpayne@69: #endif jpayne@69: unsigned char *query_cache_query; jpayne@69: unsigned int last_errno; jpayne@69: unsigned char error; jpayne@69: my_bool unused2; jpayne@69: my_bool return_errno; jpayne@69: char last_error[MYSQL_ERRMSG_SIZE]; jpayne@69: char sqlstate[SQLSTATE_LENGTH+1]; jpayne@69: void *extension; jpayne@69: #if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) jpayne@69: my_bool skip_big_packet; jpayne@69: #endif jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * st_mysql differs between 5.0 and 5.1, but the 5.0 version is a jpayne@69: * strict subset, we don't use any of the 5.1 fields, and we don't jpayne@69: * ever allocate the structure ourselves. jpayne@69: */ jpayne@69: jpayne@69: struct st_mysql { jpayne@69: NET net; jpayne@69: unsigned char *connector_fd; jpayne@69: char *host; jpayne@69: char *user; jpayne@69: char *passwd; jpayne@69: char *unix_socket; jpayne@69: char *server_version; jpayne@69: char *host_info; jpayne@69: char *info; jpayne@69: char *db; jpayne@69: struct charset_info_st *charset; jpayne@69: MYSQL_FIELD *fields; jpayne@69: MEM_ROOT field_alloc; jpayne@69: my_ulonglong affected_rows; jpayne@69: my_ulonglong insert_id; jpayne@69: my_ulonglong extra_info; jpayne@69: unsigned long thread_id; jpayne@69: unsigned long packet_length; jpayne@69: unsigned int port; jpayne@69: unsigned long client_flag; jpayne@69: unsigned long server_capabilities; jpayne@69: unsigned int protocol_version; jpayne@69: unsigned int field_count; jpayne@69: unsigned int server_status; jpayne@69: unsigned int server_language; jpayne@69: unsigned int warning_count; jpayne@69: struct st_mysql_options options; jpayne@69: enum mysql_status status; jpayne@69: my_bool free_me; jpayne@69: my_bool reconnect; jpayne@69: char scramble[SCRAMBLE_LENGTH+1]; jpayne@69: my_bool rpl_pivot; jpayne@69: struct st_mysql *master; jpayne@69: struct st_mysql *next_slave; jpayne@69: struct st_mysql* last_used_slave; jpayne@69: struct st_mysql* last_used_con; jpayne@69: LIST *stmts; jpayne@69: const struct st_mysql_methods *methods; jpayne@69: void *thd; jpayne@69: my_bool *unbuffered_fetch_owner; jpayne@69: char *info_buffer; jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * There are different version of the MYSQL_BIND structure before and after jpayne@69: * MySQL 5.1. We go after the fields of the structure using accessor functions jpayne@69: * so that the code in this file is compatible with both versions. jpayne@69: */ jpayne@69: jpayne@69: struct st_mysql_bind_51 { /* Post-5.1 */ jpayne@69: unsigned long* length; jpayne@69: my_bool* is_null; jpayne@69: void* buffer; jpayne@69: my_bool* error; jpayne@69: unsigned char* row_ptr; jpayne@69: void (*store_param_func)(NET* net, MYSQL_BIND* param); jpayne@69: void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**); jpayne@69: void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**); jpayne@69: unsigned long buffer_length; jpayne@69: unsigned long offset; jpayne@69: unsigned long length_value; jpayne@69: unsigned int param_number; jpayne@69: unsigned int pack_length; jpayne@69: enum enum_field_types buffer_type; jpayne@69: my_bool error_value; jpayne@69: my_bool is_unsigned; jpayne@69: my_bool long_data_used; jpayne@69: my_bool is_null_value; jpayne@69: void* extension; jpayne@69: }; jpayne@69: jpayne@69: struct st_mysql_bind_50 { /* Pre-5.1 */ jpayne@69: unsigned long* length; jpayne@69: my_bool* is_null; jpayne@69: void* buffer; jpayne@69: my_bool* error; jpayne@69: enum enum_field_types buffer_type; jpayne@69: unsigned long buffer_length; jpayne@69: unsigned char* row_ptr; jpayne@69: unsigned long offset; jpayne@69: unsigned long length_value; jpayne@69: unsigned int param_number; jpayne@69: unsigned int pack_length; jpayne@69: my_bool error_value; jpayne@69: my_bool is_unsigned; jpayne@69: my_bool long_data_used; jpayne@69: my_bool is_null_value; jpayne@69: void (*store_param_func)(NET* net, MYSQL_BIND* param); jpayne@69: void (*fetch_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**); jpayne@69: void (*skip_result)(MYSQL_BIND*, MYSQL_FIELD*, unsigned char**); jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * There are also different versions of the MYSQL_FIELD structure; fortunately, jpayne@69: * the 5.1 version is a strict extension of the 5.0 version. jpayne@69: */ jpayne@69: jpayne@69: struct st_mysql_field { jpayne@69: char* name; jpayne@69: char *org_name; jpayne@69: char* table; jpayne@69: char* org_table; jpayne@69: char* db; jpayne@69: char* catalog; jpayne@69: char* def; jpayne@69: unsigned long length; jpayne@69: unsigned long max_length; jpayne@69: unsigned int name_length; jpayne@69: unsigned int org_name_length; jpayne@69: unsigned int table_length; jpayne@69: unsigned int org_table_length; jpayne@69: unsigned int db_length; jpayne@69: unsigned int catalog_length; jpayne@69: unsigned int def_length; jpayne@69: unsigned int flags; jpayne@69: unsigned int decimals; jpayne@69: unsigned int charsetnr; jpayne@69: enum enum_field_types type; jpayne@69: }; jpayne@69: struct st_mysql_field_50 { jpayne@69: struct st_mysql_field field; jpayne@69: }; jpayne@69: struct st_mysql_field_51 { jpayne@69: struct st_mysql_field field; jpayne@69: void* extension; jpayne@69: }; jpayne@69: #define NOT_NULL_FLAG 1 jpayne@69: jpayne@69: #define IS_NUM(t) ((t) <= MYSQL_TYPE_INT24 || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL) jpayne@69: jpayne@69: #define mysql_library_init mysql_server_init jpayne@69: #define mysql_library_end mysql_server_end jpayne@69: jpayne@69: #include "mysqlStubs.h" jpayne@69: jpayne@69: #endif /* not FAKEMYSQL_H_INCLUDED */