Changeset 7882 for trunk/tools/database/mysql/mysql.h
- Timestamp:
- Feb 12, 2002, 8:05:28 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/mysql/mysql.h
r1993 r7882 1 /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB 2 This file is public domain and comes with NO WARRANTY of any kind */ 3 4 /* defines for libmysql */ 1 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 2 3 This library is free software; you can redistribute it and/or 4 modify it under the terms of the GNU Library General Public 5 License as published by the Free Software Foundation; either 6 version 2 of the License, or (at your option) any later version. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Library General Public License for more details. 12 13 You should have received a copy of the GNU Library General Public 14 License along with this library; if not, write to the Free 15 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 16 MA 02111-1307, USA */ 17 18 /* defines for the libmysql library */ 5 19 6 20 #ifndef _mysql_h 7 21 #define _mysql_h 8 #ifdef __cplusplus 22 23 #ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */ 24 #undef WIN 25 #undef _WIN 26 #undef _WIN32 27 #undef _WIN64 28 #undef __WIN__ 29 #endif 30 31 #ifndef MYSQL_SERVER 32 #ifdef __cplusplus 9 33 extern "C" { 10 34 #endif 11 12 #ifndef _global_h /* If not standard header */ 35 #endif 36 37 #ifndef _global_h /* If not standard header */ 13 38 #include <sys/types.h> 14 39 typedef char my_bool; 15 #if !defined(WIN32) 16 #if defined(__IBMC__) || defined(__IBMCPP__) 17 #define STDCALL _System 18 #else 19 #define STDCALL 20 #endif 40 #if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) 41 #define __WIN__ 42 #endif 43 #if defined(__IBMC__) || defined(__IBMCPP__) 44 #define STDCALL _System _Export 45 #elif !defined(__WIN__) 46 #define STDCALL 21 47 #else 22 48 #define STDCALL __stdcall … … 26 52 #ifndef ST_USED_MEM_DEFINED 27 53 #define ST_USED_MEM_DEFINED 28 typedef struct st_used_mem { 29 struct st_used_mem *next; 30 unsigned int left;/* memory left in block */31 unsigned int size;/* size of block */54 typedef struct st_used_mem { /* struct for once_alloc */ 55 struct st_used_mem *next; /* Next block in use */ 56 unsigned int left; /* memory left in block */ 57 unsigned int size; /* size of block */ 32 58 } USED_MEM; 33 59 typedef struct st_mem_root { 34 60 USED_MEM *free; 35 61 USED_MEM *used; 36 unsigned int min_malloc; 37 unsigned int block_size; 62 USED_MEM *pre_alloc; 63 unsigned int min_malloc; 64 unsigned int block_size; 65 38 66 void (*error_handler)(void); 39 67 } MEM_ROOT; … … 41 69 42 70 #ifndef my_socket_defined 43 #ifdef WIN3271 #ifdef __WIN__ 44 72 #define my_socket SOCKET 45 73 #else … … 54 82 extern char *mysql_unix_port; 55 83 56 #define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) 57 #define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) 58 #define IS_BLOB(n) ((n) & BLOB_FLAG) 59 #define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR) 84 #define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) 85 #define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) 86 #define IS_BLOB(n) ((n) & BLOB_FLAG) 87 #define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR) 88 #define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) 89 #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) 60 90 61 91 typedef struct st_mysql_field { 62 char *name; 63 char *table; 64 char *def; 65 enum enum_field_types type; 66 unsigned int length; 67 unsigned int max_length; 68 unsigned int flags; 69 unsigned int decimals; 92 char *name; /* Name of column */ 93 char *table; /* Table of column if column was a field */ 94 char *def; /* Default value (set by mysql_list_fields) */ 95 enum enum_field_types type; /* Type of field. Se mysql_com.h for types */ 96 unsigned int length; /* Width of column */ 97 unsigned int max_length; /* Max width of selected set */ 98 unsigned int flags; /* Div flags */ 99 unsigned int decimals; /* Number of decimals in field */ 70 100 } MYSQL_FIELD; 71 101 72 typedef char **MYSQL_ROW; 102 typedef char **MYSQL_ROW; /* return data as array of strings */ 73 103 typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ 74 104 75 105 #if defined(NO_CLIENT_LONG_LONG) 76 106 typedef unsigned long my_ulonglong; 77 #elif defined ( WIN32)107 #elif defined (__WIN__) 78 108 typedef unsigned __int64 my_ulonglong; 79 109 #else … … 84 114 85 115 typedef struct st_mysql_rows { 86 struct st_mysql_rows *next; 116 struct st_mysql_rows *next; /* list of rows */ 87 117 MYSQL_ROW data; 88 118 } MYSQL_ROWS; 89 119 90 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; 120 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ 91 121 92 122 typedef struct st_mysql_data { 93 #if defined(__IBMC__) || defined(__IBMCPP__)94 unsigned long rows;95 unsigned long rows_;96 #else97 123 my_ulonglong rows; 98 #endif99 124 unsigned int fields; 100 125 MYSQL_ROWS *data; … … 107 132 unsigned int port; 108 133 char *host,*init_command,*user,*password,*unix_socket,*db; 109 char *my_cnf_file,*my_cnf_group; 134 char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; 135 my_bool use_ssl; /* if to use SSL or not */ 136 char *ssl_key; /* PEM key file */ 137 char *ssl_cert; /* PEM cert file */ 138 char *ssl_ca; /* PEM CA file */ 139 char *ssl_capath; /* PEM directory of CA-s? */ 110 140 }; 111 141 112 142 enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, 113 MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, 114 MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP }; 143 MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, 144 MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, 145 MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME}; 115 146 116 147 enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT, 117 148 MYSQL_STATUS_USE_RESULT}; 118 149 119 150 typedef struct st_mysql { 120 NET net; /* Communication parameters */ 121 char *host,*user,*passwd,*unix_socket,*server_version,*host_info, 122 *info,*db; 123 unsigned int port,client_flag,server_capabilities; 124 unsigned int protocol_version; 125 unsigned int field_count; 126 unsigned long thread_id; /* Id for connection in server */ 127 #if defined(__IBMC__) || defined(__IBMCPP__) 128 unsigned long affected_rows; 129 unsigned long _affected_rows; 130 unsigned long insert_id; /* id if insert on table with NEXTNR */ 131 unsigned long _insert_id; /* id if insert on table with NEXTNR */ 132 unsigned long extra_info; /* Used by mysqlshow */ 133 unsigned long _extra_info; /* Used by mysqlshow */ 134 #else 151 NET net; /* Communication parameters */ 152 gptr connector_fd; /* ConnectorFd for SSL */ 153 char *host,*user,*passwd,*unix_socket,*server_version,*host_info, 154 *info,*db; 155 unsigned int port,client_flag,server_capabilities; 156 unsigned int protocol_version; 157 unsigned int field_count; 158 unsigned int server_status; 159 unsigned long thread_id; /* Id for connection in server */ 135 160 my_ulonglong affected_rows; 136 my_ulonglong insert_id; /* id if insert on table with NEXTNR */ 137 my_ulonglong extra_info; /* Used by mysqlshow */ 138 #endif 139 161 my_ulonglong insert_id; /* id if insert on table with NEXTNR */ 162 my_ulonglong extra_info; /* Used by mysqlshow */ 140 163 unsigned long packet_length; 141 164 enum mysql_status status; 142 MYSQL_FIELD 143 MEM_ROOT 144 my_bool free_me;/* If free in mysql_close */145 my_bool reconnect;/* set to 1 if automatic reconnect */165 MYSQL_FIELD *fields; 166 MEM_ROOT field_alloc; 167 my_bool free_me; /* If free in mysql_close */ 168 my_bool reconnect; /* set to 1 if automatic reconnect */ 146 169 struct st_mysql_options options; 170 char scramble_buff[9]; 171 struct charset_info_st *charset; 172 unsigned int server_language; 147 173 } MYSQL; 148 174 149 175 150 176 typedef struct st_mysql_res { 151 #if defined(__IBMC__) || defined(__IBMCPP__)152 unsigned long row_count;153 unsigned long _row_count;154 #else155 177 my_ulonglong row_count; 156 #endif 157 unsigned int field_count, current_field; 158 MYSQL_FIELD *fields; 159 MYSQL_DATA *data; 160 MYSQL_ROWS *data_cursor; 161 MEM_ROOT field_alloc; 162 MYSQL_ROW row; /* If unbuffered read */ 163 MYSQL_ROW current_row; /* buffer to current row */ 164 unsigned long *lengths; /* column lengths of current row */ 165 MYSQL *handle; /* for unbuffered reads */ 166 my_bool eof; /* Used my mysql_fetch_row */ 178 unsigned int field_count, current_field; 179 MYSQL_FIELD *fields; 180 MYSQL_DATA *data; 181 MYSQL_ROWS *data_cursor; 182 MEM_ROOT field_alloc; 183 MYSQL_ROW row; /* If unbuffered read */ 184 MYSQL_ROW current_row; /* buffer to current row */ 185 unsigned long *lengths; /* column lengths of current row */ 186 MYSQL *handle; /* for unbuffered reads */ 187 my_bool eof; /* Used my mysql_fetch_row */ 167 188 } MYSQL_RES; 168 189 169 170 #define mysql_num_rows(res) (res)->row_count 171 #define mysql_num_fields(res) (res)->field_count 172 #define mysql_eof(res) (res)->eof 173 #define mysql_fetch_field_direct(res,fieldnr) (&(res)->fields[fieldnr]) 174 #define mysql_fetch_fields(res) (res)->fields 175 #define mysql_row_tell(res) (res)->data_cursor 176 #define mysql_field_tell(res) (res)->current_field 177 178 #define mysql_field_count(mysql) (mysql)->field_count 179 #define mysql_affected_rows(mysql) (mysql)->affected_rows 180 #define mysql_insert_id(mysql) (mysql)->insert_id 181 #define mysql_error(mysql) (mysql)->net.last_error 182 #define mysql_errno(mysql) (mysql)->net.last_errno 183 #define mysql_info(mysql) (mysql)->info 184 #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) 185 #define mysql_thread_id(mysql) (mysql)->thread_id 186 187 MYSQL * STDCALL mysql_init(MYSQL *mysql); 188 MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, 189 const char *user, const char *passwd); 190 /* Functions to get information from the MYSQL and MYSQL_RES structures */ 191 /* Should definitely be used if one uses shared libraries */ 192 193 my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); 194 unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); 195 my_bool STDCALL mysql_eof(MYSQL_RES *res); 196 MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, 197 unsigned int fieldnr); 198 MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res); 199 MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res); 200 unsigned int STDCALL mysql_field_tell(MYSQL_RES *res); 201 202 unsigned int STDCALL mysql_field_count(MYSQL *mysql); 203 my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); 204 my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); 205 unsigned int STDCALL mysql_errno(MYSQL *mysql); 206 char * STDCALL mysql_error(MYSQL *mysql); 207 char * STDCALL mysql_info(MYSQL *mysql); 208 unsigned long STDCALL mysql_thread_id(MYSQL *mysql); 209 const char * STDCALL mysql_character_set_name(MYSQL *mysql); 210 211 MYSQL * STDCALL mysql_init(MYSQL *mysql); 212 #ifdef HAVE_OPENSSL 213 int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, 214 const char *cert, const char *ca, 215 const char *capath); 216 char * STDCALL mysql_ssl_cipher(MYSQL *mysql); 217 int STDCALL mysql_ssl_clear(MYSQL *mysql); 218 #endif /* HAVE_OPENSSL */ 219 MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, 220 const char *user, const char *passwd); 221 my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, 222 const char *passwd, const char *db); 190 223 #if MYSQL_VERSION_ID >= 32200 191 MYSQL * 192 193 194 195 196 197 224 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 225 const char *user, 226 const char *passwd, 227 const char *db, 228 unsigned int port, 229 const char *unix_socket, 230 unsigned int clientflag); 198 231 #else 199 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 200 const char *user, 201 const char *passwd, 202 unsigned int port, 203 const char *unix_socket, 204 unsigned int clientflag); 205 #endif 206 void STDCALL mysql_close(MYSQL *sock); 207 int STDCALL mysql_select_db(MYSQL *mysql, const char *db); 208 int STDCALL mysql_query(MYSQL *mysql, const char *q); 209 int STDCALL mysql_real_query(MYSQL *mysql, const char *q, 210 unsigned int length); 211 int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); 212 int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); 213 int STDCALL mysql_shutdown(MYSQL *mysql); 214 int STDCALL mysql_dump_debug_info(MYSQL *mysql); 215 int STDCALL mysql_refresh(MYSQL *mysql, 216 unsigned int refresh_options); 217 int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); 218 int STDCALL mysql_ping(MYSQL *mysql); 219 char * STDCALL mysql_stat(MYSQL *mysql); 220 char * STDCALL mysql_get_server_info(MYSQL *mysql); 221 char * STDCALL mysql_get_client_info(void); 222 char * STDCALL mysql_get_host_info(MYSQL *mysql); 223 unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); 224 MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); 225 MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); 226 MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, 227 const char *wild); 228 MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); 229 MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); 230 MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); 231 int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, 232 const char *arg); 233 void STDCALL mysql_free_result(MYSQL_RES *result); 234 void STDCALL mysql_data_seek(MYSQL_RES *result,unsigned int offset); 232 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 233 const char *user, 234 const char *passwd, 235 unsigned int port, 236 const char *unix_socket, 237 unsigned int clientflag); 238 #endif 239 void STDCALL mysql_close(MYSQL *sock); 240 int STDCALL mysql_select_db(MYSQL *mysql, const char *db); 241 int STDCALL mysql_query(MYSQL *mysql, const char *q); 242 int STDCALL mysql_send_query(MYSQL *mysql, const char *q, 243 unsigned int length); 244 int STDCALL mysql_read_query_result(MYSQL *mysql); 245 int STDCALL mysql_real_query(MYSQL *mysql, const char *q, 246 unsigned int length); 247 int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); 248 int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); 249 int STDCALL mysql_shutdown(MYSQL *mysql); 250 int STDCALL mysql_dump_debug_info(MYSQL *mysql); 251 int STDCALL mysql_refresh(MYSQL *mysql, 252 unsigned int refresh_options); 253 int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); 254 int STDCALL mysql_ping(MYSQL *mysql); 255 char * STDCALL mysql_stat(MYSQL *mysql); 256 char * STDCALL mysql_get_server_info(MYSQL *mysql); 257 char * STDCALL mysql_get_client_info(void); 258 char * STDCALL mysql_get_host_info(MYSQL *mysql); 259 unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); 260 MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); 261 MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); 262 MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, 263 const char *wild); 264 MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); 265 MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); 266 MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); 267 int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, 268 const char *arg); 269 void STDCALL mysql_free_result(MYSQL_RES *result); 270 void STDCALL mysql_data_seek(MYSQL_RES *result, 271 my_ulonglong offset); 235 272 MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET); 236 273 MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, 237 238 MYSQL_ROW 274 MYSQL_FIELD_OFFSET offset); 275 MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); 239 276 unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); 240 MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); 241 unsigned int STDCALL mysql_escape_string(char *to,const char *from, 242 unsigned int from_length); 243 void STDCALL mysql_debug(const char *debug); 277 MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); 278 unsigned long STDCALL mysql_escape_string(char *to,const char *from, 279 unsigned long from_length); 280 unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, 281 char *to,const char *from, 282 unsigned long length); 283 void STDCALL mysql_debug(const char *debug); 284 char * STDCALL mysql_odbc_escape_string(MYSQL *mysql, 285 char *to, 286 unsigned long to_length, 287 const char *from, 288 unsigned long from_length, 289 void *param, 290 char * 291 (*extend_buffer) 292 (void *, char *to, 293 unsigned long *length)); 294 void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name); 295 unsigned int STDCALL mysql_thread_safe(void); 296 297 298 #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) 244 299 245 300 /* new api functions */ … … 247 302 #define HAVE_MYSQL_REAL_CONNECT 248 303 249 #ifdef __cplusplus 304 #ifndef MYSQL_SERVER 305 #ifdef __cplusplus 250 306 } 251 307 #endif 252 308 #endif 309 310 #endif
Note:
See TracChangeset
for help on using the changeset viewer.